leduo-patrol 2.0.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +27 -4
  2. package/dist/server/__tests__/access-key-prompt.test.js +80 -0
  3. package/dist/server/__tests__/acp-session.test.js +92 -0
  4. package/dist/server/__tests__/activity-monitor.test.js +13 -1
  5. package/dist/server/__tests__/claude-cli-session.test.js +17 -0
  6. package/dist/server/__tests__/pty-runtime.test.js +28 -0
  7. package/dist/server/__tests__/session-manager.test.js +215 -1
  8. package/dist/server/access-key-prompt.js +84 -0
  9. package/dist/server/acp-session.js +476 -0
  10. package/dist/server/activity-monitor.js +22 -7
  11. package/dist/server/claude-cli-session.js +57 -12
  12. package/dist/server/index.js +104 -21
  13. package/dist/server/launch-mode.js +4 -22
  14. package/dist/server/pty-runtime.js +28 -0
  15. package/dist/server/session-manager.js +1117 -121
  16. package/dist/server/shell-session.js +2 -0
  17. package/dist/server/startup-preferences.js +45 -0
  18. package/dist/web/assets/index-B-YXVUoQ.css +1 -0
  19. package/dist/web/assets/index-Bu0K7QgY.js +21 -0
  20. package/dist/web/index.html +2 -2
  21. package/package.json +3 -1
  22. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/LICENSE +191 -0
  23. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/README.md +53 -0
  24. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.d.ts +823 -0
  25. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.js +965 -0
  26. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
  27. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.test.d.ts +1 -0
  28. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.test.js +839 -0
  29. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.test.js.map +1 -0
  30. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/agent.d.ts +2 -0
  31. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/agent.js +225 -0
  32. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/agent.js.map +1 -0
  33. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/client.d.ts +2 -0
  34. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/client.js +130 -0
  35. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/client.js.map +1 -0
  36. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.d.ts +35 -0
  37. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js +5 -0
  38. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js.map +1 -0
  39. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/index.d.ts +27 -0
  40. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/index.js +28 -0
  41. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/index.js.map +1 -0
  42. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.d.ts +2870 -0
  43. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.js +3 -0
  44. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.js.map +1 -0
  45. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.d.ts +5333 -0
  46. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js +1554 -0
  47. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js.map +1 -0
  48. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/stream.d.ts +24 -0
  49. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/stream.js +64 -0
  50. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
  51. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/package.json +66 -0
  52. package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/schema/schema.json +4125 -0
  53. package/vendor/claude-code-acp/node_modules/@types/node/LICENSE +21 -0
  54. package/vendor/claude-code-acp/node_modules/@types/node/README.md +15 -0
  55. package/vendor/claude-code-acp/node_modules/@types/node/assert/strict.d.ts +105 -0
  56. package/vendor/claude-code-acp/node_modules/@types/node/assert.d.ts +955 -0
  57. package/vendor/claude-code-acp/node_modules/@types/node/async_hooks.d.ts +623 -0
  58. package/vendor/claude-code-acp/node_modules/@types/node/buffer.buffer.d.ts +466 -0
  59. package/vendor/claude-code-acp/node_modules/@types/node/buffer.d.ts +1810 -0
  60. package/vendor/claude-code-acp/node_modules/@types/node/child_process.d.ts +1428 -0
  61. package/vendor/claude-code-acp/node_modules/@types/node/cluster.d.ts +486 -0
  62. package/vendor/claude-code-acp/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  63. package/vendor/claude-code-acp/node_modules/@types/node/console.d.ts +151 -0
  64. package/vendor/claude-code-acp/node_modules/@types/node/constants.d.ts +20 -0
  65. package/vendor/claude-code-acp/node_modules/@types/node/crypto.d.ts +4065 -0
  66. package/vendor/claude-code-acp/node_modules/@types/node/dgram.d.ts +564 -0
  67. package/vendor/claude-code-acp/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
  68. package/vendor/claude-code-acp/node_modules/@types/node/dns/promises.d.ts +503 -0
  69. package/vendor/claude-code-acp/node_modules/@types/node/dns.d.ts +922 -0
  70. package/vendor/claude-code-acp/node_modules/@types/node/domain.d.ts +166 -0
  71. package/vendor/claude-code-acp/node_modules/@types/node/events.d.ts +1054 -0
  72. package/vendor/claude-code-acp/node_modules/@types/node/fs/promises.d.ts +1329 -0
  73. package/vendor/claude-code-acp/node_modules/@types/node/fs.d.ts +4676 -0
  74. package/vendor/claude-code-acp/node_modules/@types/node/globals.d.ts +150 -0
  75. package/vendor/claude-code-acp/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  76. package/vendor/claude-code-acp/node_modules/@types/node/http.d.ts +2167 -0
  77. package/vendor/claude-code-acp/node_modules/@types/node/http2.d.ts +2480 -0
  78. package/vendor/claude-code-acp/node_modules/@types/node/https.d.ts +405 -0
  79. package/vendor/claude-code-acp/node_modules/@types/node/index.d.ts +115 -0
  80. package/vendor/claude-code-acp/node_modules/@types/node/inspector/promises.d.ts +41 -0
  81. package/vendor/claude-code-acp/node_modules/@types/node/inspector.d.ts +224 -0
  82. package/vendor/claude-code-acp/node_modules/@types/node/inspector.generated.d.ts +4226 -0
  83. package/vendor/claude-code-acp/node_modules/@types/node/module.d.ts +819 -0
  84. package/vendor/claude-code-acp/node_modules/@types/node/net.d.ts +933 -0
  85. package/vendor/claude-code-acp/node_modules/@types/node/os.d.ts +507 -0
  86. package/vendor/claude-code-acp/node_modules/@types/node/package.json +155 -0
  87. package/vendor/claude-code-acp/node_modules/@types/node/path/posix.d.ts +8 -0
  88. package/vendor/claude-code-acp/node_modules/@types/node/path/win32.d.ts +8 -0
  89. package/vendor/claude-code-acp/node_modules/@types/node/path.d.ts +187 -0
  90. package/vendor/claude-code-acp/node_modules/@types/node/perf_hooks.d.ts +643 -0
  91. package/vendor/claude-code-acp/node_modules/@types/node/process.d.ts +2161 -0
  92. package/vendor/claude-code-acp/node_modules/@types/node/punycode.d.ts +117 -0
  93. package/vendor/claude-code-acp/node_modules/@types/node/querystring.d.ts +152 -0
  94. package/vendor/claude-code-acp/node_modules/@types/node/quic.d.ts +910 -0
  95. package/vendor/claude-code-acp/node_modules/@types/node/readline/promises.d.ts +161 -0
  96. package/vendor/claude-code-acp/node_modules/@types/node/readline.d.ts +541 -0
  97. package/vendor/claude-code-acp/node_modules/@types/node/repl.d.ts +415 -0
  98. package/vendor/claude-code-acp/node_modules/@types/node/sea.d.ts +162 -0
  99. package/vendor/claude-code-acp/node_modules/@types/node/sqlite.d.ts +955 -0
  100. package/vendor/claude-code-acp/node_modules/@types/node/stream/consumers.d.ts +38 -0
  101. package/vendor/claude-code-acp/node_modules/@types/node/stream/promises.d.ts +211 -0
  102. package/vendor/claude-code-acp/node_modules/@types/node/stream/web.d.ts +296 -0
  103. package/vendor/claude-code-acp/node_modules/@types/node/stream.d.ts +1760 -0
  104. package/vendor/claude-code-acp/node_modules/@types/node/string_decoder.d.ts +67 -0
  105. package/vendor/claude-code-acp/node_modules/@types/node/test/reporters.d.ts +96 -0
  106. package/vendor/claude-code-acp/node_modules/@types/node/test.d.ts +2240 -0
  107. package/vendor/claude-code-acp/node_modules/@types/node/timers/promises.d.ts +108 -0
  108. package/vendor/claude-code-acp/node_modules/@types/node/timers.d.ts +159 -0
  109. package/vendor/claude-code-acp/node_modules/@types/node/tls.d.ts +1198 -0
  110. package/vendor/claude-code-acp/node_modules/@types/node/trace_events.d.ts +197 -0
  111. package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
  112. package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  113. package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  114. package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/index.d.ts +117 -0
  115. package/vendor/claude-code-acp/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  116. package/vendor/claude-code-acp/node_modules/@types/node/ts5.7/index.d.ts +117 -0
  117. package/vendor/claude-code-acp/node_modules/@types/node/tty.d.ts +250 -0
  118. package/vendor/claude-code-acp/node_modules/@types/node/url.d.ts +519 -0
  119. package/vendor/claude-code-acp/node_modules/@types/node/util/types.d.ts +558 -0
  120. package/vendor/claude-code-acp/node_modules/@types/node/util.d.ts +1662 -0
  121. package/vendor/claude-code-acp/node_modules/@types/node/v8.d.ts +983 -0
  122. package/vendor/claude-code-acp/node_modules/@types/node/vm.d.ts +1208 -0
  123. package/vendor/claude-code-acp/node_modules/@types/node/wasi.d.ts +202 -0
  124. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  125. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  126. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/console.d.ts +9 -0
  127. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  128. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  129. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  130. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/events.d.ts +106 -0
  131. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  132. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  133. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  134. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  135. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  136. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  137. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/streams.d.ts +115 -0
  138. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  139. package/vendor/claude-code-acp/node_modules/@types/node/web-globals/url.d.ts +24 -0
  140. package/vendor/claude-code-acp/node_modules/@types/node/worker_threads.d.ts +717 -0
  141. package/vendor/claude-code-acp/node_modules/@types/node/zlib.d.ts +618 -0
  142. package/vendor/claude-code-acp/node_modules/undici-types/LICENSE +21 -0
  143. package/vendor/claude-code-acp/node_modules/undici-types/README.md +6 -0
  144. package/vendor/claude-code-acp/node_modules/undici-types/agent.d.ts +32 -0
  145. package/vendor/claude-code-acp/node_modules/undici-types/api.d.ts +43 -0
  146. package/vendor/claude-code-acp/node_modules/undici-types/balanced-pool.d.ts +29 -0
  147. package/vendor/claude-code-acp/node_modules/undici-types/cache-interceptor.d.ts +172 -0
  148. package/vendor/claude-code-acp/node_modules/undici-types/cache.d.ts +36 -0
  149. package/vendor/claude-code-acp/node_modules/undici-types/client-stats.d.ts +15 -0
  150. package/vendor/claude-code-acp/node_modules/undici-types/client.d.ts +108 -0
  151. package/vendor/claude-code-acp/node_modules/undici-types/connector.d.ts +34 -0
  152. package/vendor/claude-code-acp/node_modules/undici-types/content-type.d.ts +21 -0
  153. package/vendor/claude-code-acp/node_modules/undici-types/cookies.d.ts +30 -0
  154. package/vendor/claude-code-acp/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  155. package/vendor/claude-code-acp/node_modules/undici-types/dispatcher.d.ts +276 -0
  156. package/vendor/claude-code-acp/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  157. package/vendor/claude-code-acp/node_modules/undici-types/errors.d.ts +161 -0
  158. package/vendor/claude-code-acp/node_modules/undici-types/eventsource.d.ts +66 -0
  159. package/vendor/claude-code-acp/node_modules/undici-types/fetch.d.ts +211 -0
  160. package/vendor/claude-code-acp/node_modules/undici-types/formdata.d.ts +108 -0
  161. package/vendor/claude-code-acp/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  162. package/vendor/claude-code-acp/node_modules/undici-types/global-origin.d.ts +7 -0
  163. package/vendor/claude-code-acp/node_modules/undici-types/h2c-client.d.ts +73 -0
  164. package/vendor/claude-code-acp/node_modules/undici-types/handlers.d.ts +15 -0
  165. package/vendor/claude-code-acp/node_modules/undici-types/header.d.ts +160 -0
  166. package/vendor/claude-code-acp/node_modules/undici-types/index.d.ts +80 -0
  167. package/vendor/claude-code-acp/node_modules/undici-types/interceptors.d.ts +39 -0
  168. package/vendor/claude-code-acp/node_modules/undici-types/mock-agent.d.ts +68 -0
  169. package/vendor/claude-code-acp/node_modules/undici-types/mock-call-history.d.ts +111 -0
  170. package/vendor/claude-code-acp/node_modules/undici-types/mock-client.d.ts +27 -0
  171. package/vendor/claude-code-acp/node_modules/undici-types/mock-errors.d.ts +12 -0
  172. package/vendor/claude-code-acp/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  173. package/vendor/claude-code-acp/node_modules/undici-types/mock-pool.d.ts +27 -0
  174. package/vendor/claude-code-acp/node_modules/undici-types/package.json +55 -0
  175. package/vendor/claude-code-acp/node_modules/undici-types/patch.d.ts +29 -0
  176. package/vendor/claude-code-acp/node_modules/undici-types/pool-stats.d.ts +19 -0
  177. package/vendor/claude-code-acp/node_modules/undici-types/pool.d.ts +41 -0
  178. package/vendor/claude-code-acp/node_modules/undici-types/proxy-agent.d.ts +29 -0
  179. package/vendor/claude-code-acp/node_modules/undici-types/readable.d.ts +68 -0
  180. package/vendor/claude-code-acp/node_modules/undici-types/retry-agent.d.ts +8 -0
  181. package/vendor/claude-code-acp/node_modules/undici-types/retry-handler.d.ts +125 -0
  182. package/vendor/claude-code-acp/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  183. package/vendor/claude-code-acp/node_modules/undici-types/util.d.ts +18 -0
  184. package/vendor/claude-code-acp/node_modules/undici-types/utility.d.ts +7 -0
  185. package/vendor/claude-code-acp/node_modules/undici-types/webidl.d.ts +341 -0
  186. package/vendor/claude-code-acp/node_modules/undici-types/websocket.d.ts +186 -0
  187. package/dist/web/assets/index-B0sSFjwT.css +0 -1
  188. package/dist/web/assets/index-Cdb0JMLq.js +0 -13
@@ -0,0 +1,43 @@
1
+ import { URL, UrlObject } from 'url'
2
+ import { Duplex } from 'stream'
3
+ import Dispatcher from './dispatcher'
4
+
5
+ /** Performs an HTTP request. */
6
+ declare function request<TOpaque = null> (
7
+ url: string | URL | UrlObject,
8
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
9
+ ): Promise<Dispatcher.ResponseData<TOpaque>>
10
+
11
+ /** A faster version of `request`. */
12
+ declare function stream<TOpaque = null> (
13
+ url: string | URL | UrlObject,
14
+ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path'>,
15
+ factory: Dispatcher.StreamFactory<TOpaque>
16
+ ): Promise<Dispatcher.StreamData<TOpaque>>
17
+
18
+ /** For easy use with `stream.pipeline`. */
19
+ declare function pipeline<TOpaque = null> (
20
+ url: string | URL | UrlObject,
21
+ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions<TOpaque>, 'origin' | 'path'>,
22
+ handler: Dispatcher.PipelineHandler<TOpaque>
23
+ ): Duplex
24
+
25
+ /** Starts two-way communications with the requested resource. */
26
+ declare function connect<TOpaque = null> (
27
+ url: string | URL | UrlObject,
28
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin' | 'path'>
29
+ ): Promise<Dispatcher.ConnectData<TOpaque>>
30
+
31
+ /** Upgrade to a different protocol. */
32
+ declare function upgrade (
33
+ url: string | URL | UrlObject,
34
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
35
+ ): Promise<Dispatcher.UpgradeData>
36
+
37
+ export {
38
+ request,
39
+ stream,
40
+ pipeline,
41
+ connect,
42
+ upgrade
43
+ }
@@ -0,0 +1,29 @@
1
+ import Pool from './pool'
2
+ import Dispatcher from './dispatcher'
3
+ import { URL } from 'url'
4
+
5
+ export default BalancedPool
6
+
7
+ type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
8
+
9
+ declare class BalancedPool extends Dispatcher {
10
+ constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
11
+
12
+ addUpstream (upstream: string | URL): BalancedPool
13
+ removeUpstream (upstream: string | URL): BalancedPool
14
+ upstreams: Array<string>
15
+
16
+ /** `true` after `pool.close()` has been called. */
17
+ closed: boolean
18
+ /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
19
+ destroyed: boolean
20
+
21
+ // Override dispatcher APIs.
22
+ override connect (
23
+ options: BalancedPoolConnectOptions
24
+ ): Promise<Dispatcher.ConnectData>
25
+ override connect (
26
+ options: BalancedPoolConnectOptions,
27
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
28
+ ): void
29
+ }
@@ -0,0 +1,172 @@
1
+ import { Readable, Writable } from 'node:stream'
2
+
3
+ export default CacheHandler
4
+
5
+ declare namespace CacheHandler {
6
+ export type CacheMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE'
7
+
8
+ export interface CacheHandlerOptions {
9
+ store: CacheStore
10
+
11
+ cacheByDefault?: number
12
+
13
+ type?: CacheOptions['type']
14
+ }
15
+
16
+ export interface CacheOptions {
17
+ store?: CacheStore
18
+
19
+ /**
20
+ * The methods to cache
21
+ * Note we can only cache safe methods. Unsafe methods (i.e. PUT, POST)
22
+ * invalidate the cache for a origin.
23
+ * @see https://www.rfc-editor.org/rfc/rfc9111.html#name-invalidating-stored-respons
24
+ * @see https://www.rfc-editor.org/rfc/rfc9110#section-9.2.1
25
+ */
26
+ methods?: CacheMethods[]
27
+
28
+ /**
29
+ * RFC9111 allows for caching responses that we aren't explicitly told to
30
+ * cache or to not cache.
31
+ * @see https://www.rfc-editor.org/rfc/rfc9111.html#section-3-5
32
+ * @default undefined
33
+ */
34
+ cacheByDefault?: number
35
+
36
+ /**
37
+ * TODO docs
38
+ * @default 'shared'
39
+ */
40
+ type?: 'shared' | 'private'
41
+ }
42
+
43
+ export interface CacheControlDirectives {
44
+ 'max-stale'?: number;
45
+ 'min-fresh'?: number;
46
+ 'max-age'?: number;
47
+ 's-maxage'?: number;
48
+ 'stale-while-revalidate'?: number;
49
+ 'stale-if-error'?: number;
50
+ public?: true;
51
+ private?: true | string[];
52
+ 'no-store'?: true;
53
+ 'no-cache'?: true | string[];
54
+ 'must-revalidate'?: true;
55
+ 'proxy-revalidate'?: true;
56
+ immutable?: true;
57
+ 'no-transform'?: true;
58
+ 'must-understand'?: true;
59
+ 'only-if-cached'?: true;
60
+ }
61
+
62
+ export interface CacheKey {
63
+ origin: string
64
+ method: string
65
+ path: string
66
+ headers?: Record<string, string | string[]>
67
+ }
68
+
69
+ export interface CacheValue {
70
+ statusCode: number
71
+ statusMessage: string
72
+ headers: Record<string, string | string[]>
73
+ vary?: Record<string, string | string[] | null>
74
+ etag?: string
75
+ cacheControlDirectives?: CacheControlDirectives
76
+ cachedAt: number
77
+ staleAt: number
78
+ deleteAt: number
79
+ }
80
+
81
+ export interface DeleteByUri {
82
+ origin: string
83
+ method: string
84
+ path: string
85
+ }
86
+
87
+ type GetResult = {
88
+ statusCode: number
89
+ statusMessage: string
90
+ headers: Record<string, string | string[]>
91
+ vary?: Record<string, string | string[] | null>
92
+ etag?: string
93
+ body?: Readable | Iterable<Buffer> | AsyncIterable<Buffer> | Buffer | Iterable<string> | AsyncIterable<string> | string
94
+ cacheControlDirectives: CacheControlDirectives,
95
+ cachedAt: number
96
+ staleAt: number
97
+ deleteAt: number
98
+ }
99
+
100
+ /**
101
+ * Underlying storage provider for cached responses
102
+ */
103
+ export interface CacheStore {
104
+ get(key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
105
+
106
+ createWriteStream(key: CacheKey, val: CacheValue): Writable | undefined
107
+
108
+ delete(key: CacheKey): void | Promise<void>
109
+ }
110
+
111
+ export interface MemoryCacheStoreOpts {
112
+ /**
113
+ * @default Infinity
114
+ */
115
+ maxCount?: number
116
+
117
+ /**
118
+ * @default Infinity
119
+ */
120
+ maxSize?: number
121
+
122
+ /**
123
+ * @default Infinity
124
+ */
125
+ maxEntrySize?: number
126
+
127
+ errorCallback?: (err: Error) => void
128
+ }
129
+
130
+ export class MemoryCacheStore implements CacheStore {
131
+ constructor (opts?: MemoryCacheStoreOpts)
132
+
133
+ get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
134
+
135
+ createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
136
+
137
+ delete (key: CacheKey): void | Promise<void>
138
+ }
139
+
140
+ export interface SqliteCacheStoreOpts {
141
+ /**
142
+ * Location of the database
143
+ * @default ':memory:'
144
+ */
145
+ location?: string
146
+
147
+ /**
148
+ * @default Infinity
149
+ */
150
+ maxCount?: number
151
+
152
+ /**
153
+ * @default Infinity
154
+ */
155
+ maxEntrySize?: number
156
+ }
157
+
158
+ export class SqliteCacheStore implements CacheStore {
159
+ constructor (opts?: SqliteCacheStoreOpts)
160
+
161
+ /**
162
+ * Closes the connection to the database
163
+ */
164
+ close (): void
165
+
166
+ get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
167
+
168
+ createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
169
+
170
+ delete (key: CacheKey): void | Promise<void>
171
+ }
172
+ }
@@ -0,0 +1,36 @@
1
+ import type { RequestInfo, Response, Request } from './fetch'
2
+
3
+ export interface CacheStorage {
4
+ match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
5
+ has (cacheName: string): Promise<boolean>,
6
+ open (cacheName: string): Promise<Cache>,
7
+ delete (cacheName: string): Promise<boolean>,
8
+ keys (): Promise<string[]>
9
+ }
10
+
11
+ declare const CacheStorage: {
12
+ prototype: CacheStorage
13
+ new(): CacheStorage
14
+ }
15
+
16
+ export interface Cache {
17
+ match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
18
+ matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
19
+ add (request: RequestInfo): Promise<undefined>,
20
+ addAll (requests: RequestInfo[]): Promise<undefined>,
21
+ put (request: RequestInfo, response: Response): Promise<undefined>,
22
+ delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
23
+ keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
24
+ }
25
+
26
+ export interface CacheQueryOptions {
27
+ ignoreSearch?: boolean,
28
+ ignoreMethod?: boolean,
29
+ ignoreVary?: boolean
30
+ }
31
+
32
+ export interface MultiCacheQueryOptions extends CacheQueryOptions {
33
+ cacheName?: string
34
+ }
35
+
36
+ export declare const caches: CacheStorage
@@ -0,0 +1,15 @@
1
+ import Client from './client'
2
+
3
+ export default ClientStats
4
+
5
+ declare class ClientStats {
6
+ constructor (pool: Client)
7
+ /** If socket has open connection. */
8
+ connected: boolean
9
+ /** Number of open socket connections in this client that do not have an active request. */
10
+ pending: number
11
+ /** Number of currently active requests of this client. */
12
+ running: number
13
+ /** Number of active, pending, or queued requests of this client. */
14
+ size: number
15
+ }
@@ -0,0 +1,108 @@
1
+ import { URL } from 'url'
2
+ import Dispatcher from './dispatcher'
3
+ import buildConnector from './connector'
4
+ import TClientStats from './client-stats'
5
+
6
+ type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
7
+
8
+ /**
9
+ * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
10
+ */
11
+ export class Client extends Dispatcher {
12
+ constructor (url: string | URL, options?: Client.Options)
13
+ /** Property to get and set the pipelining factor. */
14
+ pipelining: number
15
+ /** `true` after `client.close()` has been called. */
16
+ closed: boolean
17
+ /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
18
+ destroyed: boolean
19
+ /** Aggregate stats for a Client. */
20
+ readonly stats: TClientStats
21
+
22
+ // Override dispatcher APIs.
23
+ override connect (
24
+ options: ClientConnectOptions
25
+ ): Promise<Dispatcher.ConnectData>
26
+ override connect (
27
+ options: ClientConnectOptions,
28
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
29
+ ): void
30
+ }
31
+
32
+ export declare namespace Client {
33
+ export interface OptionsInterceptors {
34
+ Client: readonly Dispatcher.DispatchInterceptor[];
35
+ }
36
+ export interface Options {
37
+ /** TODO */
38
+ interceptors?: OptionsInterceptors;
39
+ /** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
40
+ maxHeaderSize?: number;
41
+ /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
42
+ headersTimeout?: number;
43
+ /** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
44
+ socketTimeout?: never;
45
+ /** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
46
+ requestTimeout?: never;
47
+ /** TODO */
48
+ connectTimeout?: number;
49
+ /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
50
+ bodyTimeout?: number;
51
+ /** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
52
+ idleTimeout?: never;
53
+ /** @deprecated unsupported keepAlive, use pipelining=0 instead */
54
+ keepAlive?: never;
55
+ /** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
56
+ keepAliveTimeout?: number;
57
+ /** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
58
+ maxKeepAliveTimeout?: never;
59
+ /** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
60
+ keepAliveMaxTimeout?: number;
61
+ /** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
62
+ keepAliveTimeoutThreshold?: number;
63
+ /** TODO */
64
+ socketPath?: string;
65
+ /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
66
+ pipelining?: number;
67
+ /** @deprecated use the connect option instead */
68
+ tls?: never;
69
+ /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
70
+ strictContentLength?: boolean;
71
+ /** TODO */
72
+ maxCachedSessions?: number;
73
+ /** TODO */
74
+ connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
75
+ /** TODO */
76
+ maxRequestsPerClient?: number;
77
+ /** TODO */
78
+ localAddress?: string;
79
+ /** Max response body size in bytes, -1 is disabled */
80
+ maxResponseSize?: number;
81
+ /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
82
+ autoSelectFamily?: boolean;
83
+ /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
84
+ autoSelectFamilyAttemptTimeout?: number;
85
+ /**
86
+ * @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
87
+ * @default false
88
+ */
89
+ allowH2?: boolean;
90
+ /**
91
+ * @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
92
+ * @default 100
93
+ */
94
+ maxConcurrentStreams?: number;
95
+ }
96
+ export interface SocketInfo {
97
+ localAddress?: string
98
+ localPort?: number
99
+ remoteAddress?: string
100
+ remotePort?: number
101
+ remoteFamily?: string
102
+ timeout?: number
103
+ bytesWritten?: number
104
+ bytesRead?: number
105
+ }
106
+ }
107
+
108
+ export default Client
@@ -0,0 +1,34 @@
1
+ import { TLSSocket, ConnectionOptions } from 'tls'
2
+ import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from 'net'
3
+
4
+ export default buildConnector
5
+ declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
6
+
7
+ declare namespace buildConnector {
8
+ export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
9
+ allowH2?: boolean;
10
+ maxCachedSessions?: number | null;
11
+ socketPath?: string | null;
12
+ timeout?: number | null;
13
+ port?: number;
14
+ keepAlive?: boolean | null;
15
+ keepAliveInitialDelay?: number | null;
16
+ }
17
+
18
+ export interface Options {
19
+ hostname: string
20
+ host?: string
21
+ protocol: string
22
+ port: string
23
+ servername?: string
24
+ localAddress?: string | null
25
+ httpSocket?: Socket
26
+ }
27
+
28
+ export type Callback = (...args: CallbackArgs) => void
29
+ type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
30
+
31
+ export interface connector {
32
+ (options: buildConnector.Options, callback: buildConnector.Callback): void
33
+ }
34
+ }
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+
3
+ interface MIMEType {
4
+ type: string
5
+ subtype: string
6
+ parameters: Map<string, string>
7
+ essence: string
8
+ }
9
+
10
+ /**
11
+ * Parse a string to a {@link MIMEType} object. Returns `failure` if the string
12
+ * couldn't be parsed.
13
+ * @see https://mimesniff.spec.whatwg.org/#parse-a-mime-type
14
+ */
15
+ export function parseMIMEType (input: string): 'failure' | MIMEType
16
+
17
+ /**
18
+ * Convert a MIMEType object to a string.
19
+ * @see https://mimesniff.spec.whatwg.org/#serialize-a-mime-type
20
+ */
21
+ export function serializeAMimeType (mimeType: MIMEType): string
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+
3
+ import type { Headers } from './fetch'
4
+
5
+ export interface Cookie {
6
+ name: string
7
+ value: string
8
+ expires?: Date | number
9
+ maxAge?: number
10
+ domain?: string
11
+ path?: string
12
+ secure?: boolean
13
+ httpOnly?: boolean
14
+ sameSite?: 'Strict' | 'Lax' | 'None'
15
+ unparsed?: string[]
16
+ }
17
+
18
+ export function deleteCookie (
19
+ headers: Headers,
20
+ name: string,
21
+ attributes?: { name?: string, domain?: string }
22
+ ): void
23
+
24
+ export function getCookies (headers: Headers): Record<string, string>
25
+
26
+ export function getSetCookies (headers: Headers): Cookie[]
27
+
28
+ export function setCookie (headers: Headers, cookie: Cookie): void
29
+
30
+ export function parseCookie (cookie: string): Cookie | null
@@ -0,0 +1,74 @@
1
+ import { Socket } from 'net'
2
+ import { URL } from 'url'
3
+ import buildConnector from './connector'
4
+ import Dispatcher from './dispatcher'
5
+
6
+ declare namespace DiagnosticsChannel {
7
+ interface Request {
8
+ origin?: string | URL;
9
+ completed: boolean;
10
+ method?: Dispatcher.HttpMethod;
11
+ path: string;
12
+ headers: any;
13
+ }
14
+ interface Response {
15
+ statusCode: number;
16
+ statusText: string;
17
+ headers: Array<Buffer>;
18
+ }
19
+ interface ConnectParams {
20
+ host: URL['host'];
21
+ hostname: URL['hostname'];
22
+ protocol: URL['protocol'];
23
+ port: URL['port'];
24
+ servername: string | null;
25
+ }
26
+ type Connector = buildConnector.connector
27
+ export interface RequestCreateMessage {
28
+ request: Request;
29
+ }
30
+ export interface RequestBodySentMessage {
31
+ request: Request;
32
+ }
33
+
34
+ export interface RequestBodyChunkSentMessage {
35
+ request: Request;
36
+ chunk: Uint8Array | string;
37
+ }
38
+ export interface RequestBodyChunkReceivedMessage {
39
+ request: Request;
40
+ chunk: Buffer;
41
+ }
42
+ export interface RequestHeadersMessage {
43
+ request: Request;
44
+ response: Response;
45
+ }
46
+ export interface RequestTrailersMessage {
47
+ request: Request;
48
+ trailers: Array<Buffer>;
49
+ }
50
+ export interface RequestErrorMessage {
51
+ request: Request;
52
+ error: Error;
53
+ }
54
+ export interface ClientSendHeadersMessage {
55
+ request: Request;
56
+ headers: string;
57
+ socket: Socket;
58
+ }
59
+ export interface ClientBeforeConnectMessage {
60
+ connectParams: ConnectParams;
61
+ connector: Connector;
62
+ }
63
+ export interface ClientConnectedMessage {
64
+ socket: Socket;
65
+ connectParams: ConnectParams;
66
+ connector: Connector;
67
+ }
68
+ export interface ClientConnectErrorMessage {
69
+ error: Error;
70
+ socket: Socket;
71
+ connectParams: ConnectParams;
72
+ connector: Connector;
73
+ }
74
+ }