deepv-code 1.0.182 → 1.0.183

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 (193) hide show
  1. package/bundle/dvcode.js +635 -635
  2. package/package.json +1 -1
  3. package/bundle/assets/help/README.md +0 -113
  4. package/bundle/assets/sounds/README.md +0 -74
  5. package/bundle/node_modules/undici/LICENSE +0 -21
  6. package/bundle/node_modules/undici/README.md +0 -472
  7. package/bundle/node_modules/undici/docs/docs/api/Agent.md +0 -83
  8. package/bundle/node_modules/undici/docs/docs/api/BalancedPool.md +0 -99
  9. package/bundle/node_modules/undici/docs/docs/api/CacheStorage.md +0 -30
  10. package/bundle/node_modules/undici/docs/docs/api/CacheStore.md +0 -151
  11. package/bundle/node_modules/undici/docs/docs/api/Client.md +0 -281
  12. package/bundle/node_modules/undici/docs/docs/api/ClientStats.md +0 -27
  13. package/bundle/node_modules/undici/docs/docs/api/Connector.md +0 -115
  14. package/bundle/node_modules/undici/docs/docs/api/ContentType.md +0 -57
  15. package/bundle/node_modules/undici/docs/docs/api/Cookies.md +0 -101
  16. package/bundle/node_modules/undici/docs/docs/api/Debug.md +0 -62
  17. package/bundle/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +0 -204
  18. package/bundle/node_modules/undici/docs/docs/api/Dispatcher.md +0 -1200
  19. package/bundle/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +0 -159
  20. package/bundle/node_modules/undici/docs/docs/api/Errors.md +0 -49
  21. package/bundle/node_modules/undici/docs/docs/api/EventSource.md +0 -45
  22. package/bundle/node_modules/undici/docs/docs/api/Fetch.md +0 -52
  23. package/bundle/node_modules/undici/docs/docs/api/H2CClient.md +0 -262
  24. package/bundle/node_modules/undici/docs/docs/api/MockAgent.md +0 -603
  25. package/bundle/node_modules/undici/docs/docs/api/MockCallHistory.md +0 -197
  26. package/bundle/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +0 -43
  27. package/bundle/node_modules/undici/docs/docs/api/MockClient.md +0 -77
  28. package/bundle/node_modules/undici/docs/docs/api/MockErrors.md +0 -12
  29. package/bundle/node_modules/undici/docs/docs/api/MockPool.md +0 -548
  30. package/bundle/node_modules/undici/docs/docs/api/Pool.md +0 -84
  31. package/bundle/node_modules/undici/docs/docs/api/PoolStats.md +0 -35
  32. package/bundle/node_modules/undici/docs/docs/api/ProxyAgent.md +0 -227
  33. package/bundle/node_modules/undici/docs/docs/api/RedirectHandler.md +0 -96
  34. package/bundle/node_modules/undici/docs/docs/api/RetryAgent.md +0 -45
  35. package/bundle/node_modules/undici/docs/docs/api/RetryHandler.md +0 -117
  36. package/bundle/node_modules/undici/docs/docs/api/Util.md +0 -25
  37. package/bundle/node_modules/undici/docs/docs/api/WebSocket.md +0 -85
  38. package/bundle/node_modules/undici/docs/docs/api/api-lifecycle.md +0 -91
  39. package/bundle/node_modules/undici/docs/docs/best-practices/client-certificate.md +0 -64
  40. package/bundle/node_modules/undici/docs/docs/best-practices/mocking-request.md +0 -190
  41. package/bundle/node_modules/undici/docs/docs/best-practices/proxy.md +0 -127
  42. package/bundle/node_modules/undici/docs/docs/best-practices/writing-tests.md +0 -20
  43. package/bundle/node_modules/undici/index-fetch.js +0 -35
  44. package/bundle/node_modules/undici/index.d.ts +0 -3
  45. package/bundle/node_modules/undici/index.js +0 -183
  46. package/bundle/node_modules/undici/lib/api/abort-signal.js +0 -59
  47. package/bundle/node_modules/undici/lib/api/api-connect.js +0 -110
  48. package/bundle/node_modules/undici/lib/api/api-pipeline.js +0 -252
  49. package/bundle/node_modules/undici/lib/api/api-request.js +0 -199
  50. package/bundle/node_modules/undici/lib/api/api-stream.js +0 -209
  51. package/bundle/node_modules/undici/lib/api/api-upgrade.js +0 -110
  52. package/bundle/node_modules/undici/lib/api/index.js +0 -7
  53. package/bundle/node_modules/undici/lib/api/readable.js +0 -558
  54. package/bundle/node_modules/undici/lib/api/util.js +0 -95
  55. package/bundle/node_modules/undici/lib/cache/memory-cache-store.js +0 -234
  56. package/bundle/node_modules/undici/lib/cache/sqlite-cache-store.js +0 -461
  57. package/bundle/node_modules/undici/lib/core/connect.js +0 -164
  58. package/bundle/node_modules/undici/lib/core/constants.js +0 -143
  59. package/bundle/node_modules/undici/lib/core/diagnostics.js +0 -196
  60. package/bundle/node_modules/undici/lib/core/errors.js +0 -244
  61. package/bundle/node_modules/undici/lib/core/request.js +0 -397
  62. package/bundle/node_modules/undici/lib/core/symbols.js +0 -68
  63. package/bundle/node_modules/undici/lib/core/tree.js +0 -160
  64. package/bundle/node_modules/undici/lib/core/util.js +0 -988
  65. package/bundle/node_modules/undici/lib/dispatcher/agent.js +0 -135
  66. package/bundle/node_modules/undici/lib/dispatcher/balanced-pool.js +0 -206
  67. package/bundle/node_modules/undici/lib/dispatcher/client-h1.js +0 -1615
  68. package/bundle/node_modules/undici/lib/dispatcher/client-h2.js +0 -798
  69. package/bundle/node_modules/undici/lib/dispatcher/client.js +0 -614
  70. package/bundle/node_modules/undici/lib/dispatcher/dispatcher-base.js +0 -161
  71. package/bundle/node_modules/undici/lib/dispatcher/dispatcher.js +0 -48
  72. package/bundle/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +0 -151
  73. package/bundle/node_modules/undici/lib/dispatcher/fixed-queue.js +0 -159
  74. package/bundle/node_modules/undici/lib/dispatcher/h2c-client.js +0 -122
  75. package/bundle/node_modules/undici/lib/dispatcher/pool-base.js +0 -191
  76. package/bundle/node_modules/undici/lib/dispatcher/pool.js +0 -118
  77. package/bundle/node_modules/undici/lib/dispatcher/proxy-agent.js +0 -275
  78. package/bundle/node_modules/undici/lib/dispatcher/retry-agent.js +0 -35
  79. package/bundle/node_modules/undici/lib/global.js +0 -32
  80. package/bundle/node_modules/undici/lib/handler/cache-handler.js +0 -448
  81. package/bundle/node_modules/undici/lib/handler/cache-revalidation-handler.js +0 -124
  82. package/bundle/node_modules/undici/lib/handler/decorator-handler.js +0 -67
  83. package/bundle/node_modules/undici/lib/handler/redirect-handler.js +0 -227
  84. package/bundle/node_modules/undici/lib/handler/retry-handler.js +0 -342
  85. package/bundle/node_modules/undici/lib/handler/unwrap-handler.js +0 -96
  86. package/bundle/node_modules/undici/lib/handler/wrap-handler.js +0 -95
  87. package/bundle/node_modules/undici/lib/interceptor/cache.js +0 -372
  88. package/bundle/node_modules/undici/lib/interceptor/dns.js +0 -432
  89. package/bundle/node_modules/undici/lib/interceptor/dump.js +0 -111
  90. package/bundle/node_modules/undici/lib/interceptor/redirect.js +0 -21
  91. package/bundle/node_modules/undici/lib/interceptor/response-error.js +0 -95
  92. package/bundle/node_modules/undici/lib/interceptor/retry.js +0 -19
  93. package/bundle/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  94. package/bundle/node_modules/undici/lib/llhttp/constants.d.ts +0 -97
  95. package/bundle/node_modules/undici/lib/llhttp/constants.js +0 -498
  96. package/bundle/node_modules/undici/lib/llhttp/constants.js.map +0 -1
  97. package/bundle/node_modules/undici/lib/llhttp/llhttp-wasm.js +0 -15
  98. package/bundle/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +0 -15
  99. package/bundle/node_modules/undici/lib/llhttp/utils.d.ts +0 -2
  100. package/bundle/node_modules/undici/lib/llhttp/utils.js +0 -15
  101. package/bundle/node_modules/undici/lib/llhttp/utils.js.map +0 -1
  102. package/bundle/node_modules/undici/lib/mock/mock-agent.js +0 -224
  103. package/bundle/node_modules/undici/lib/mock/mock-call-history.js +0 -248
  104. package/bundle/node_modules/undici/lib/mock/mock-client.js +0 -64
  105. package/bundle/node_modules/undici/lib/mock/mock-errors.js +0 -19
  106. package/bundle/node_modules/undici/lib/mock/mock-interceptor.js +0 -209
  107. package/bundle/node_modules/undici/lib/mock/mock-pool.js +0 -64
  108. package/bundle/node_modules/undici/lib/mock/mock-symbols.js +0 -31
  109. package/bundle/node_modules/undici/lib/mock/mock-utils.js +0 -433
  110. package/bundle/node_modules/undici/lib/mock/pending-interceptors-formatter.js +0 -43
  111. package/bundle/node_modules/undici/lib/util/cache.js +0 -368
  112. package/bundle/node_modules/undici/lib/util/date.js +0 -259
  113. package/bundle/node_modules/undici/lib/util/stats.js +0 -32
  114. package/bundle/node_modules/undici/lib/util/timers.js +0 -423
  115. package/bundle/node_modules/undici/lib/web/cache/cache.js +0 -862
  116. package/bundle/node_modules/undici/lib/web/cache/cachestorage.js +0 -152
  117. package/bundle/node_modules/undici/lib/web/cache/util.js +0 -45
  118. package/bundle/node_modules/undici/lib/web/cookies/constants.js +0 -12
  119. package/bundle/node_modules/undici/lib/web/cookies/index.js +0 -199
  120. package/bundle/node_modules/undici/lib/web/cookies/parse.js +0 -322
  121. package/bundle/node_modules/undici/lib/web/cookies/util.js +0 -282
  122. package/bundle/node_modules/undici/lib/web/eventsource/eventsource-stream.js +0 -399
  123. package/bundle/node_modules/undici/lib/web/eventsource/eventsource.js +0 -484
  124. package/bundle/node_modules/undici/lib/web/eventsource/util.js +0 -37
  125. package/bundle/node_modules/undici/lib/web/fetch/LICENSE +0 -21
  126. package/bundle/node_modules/undici/lib/web/fetch/body.js +0 -532
  127. package/bundle/node_modules/undici/lib/web/fetch/constants.js +0 -131
  128. package/bundle/node_modules/undici/lib/web/fetch/data-url.js +0 -744
  129. package/bundle/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +0 -46
  130. package/bundle/node_modules/undici/lib/web/fetch/formdata-parser.js +0 -501
  131. package/bundle/node_modules/undici/lib/web/fetch/formdata.js +0 -263
  132. package/bundle/node_modules/undici/lib/web/fetch/global.js +0 -40
  133. package/bundle/node_modules/undici/lib/web/fetch/headers.js +0 -719
  134. package/bundle/node_modules/undici/lib/web/fetch/index.js +0 -2258
  135. package/bundle/node_modules/undici/lib/web/fetch/request.js +0 -1099
  136. package/bundle/node_modules/undici/lib/web/fetch/response.js +0 -636
  137. package/bundle/node_modules/undici/lib/web/fetch/util.js +0 -1782
  138. package/bundle/node_modules/undici/lib/web/fetch/webidl.js +0 -740
  139. package/bundle/node_modules/undici/lib/web/websocket/connection.js +0 -325
  140. package/bundle/node_modules/undici/lib/web/websocket/constants.js +0 -126
  141. package/bundle/node_modules/undici/lib/web/websocket/events.js +0 -331
  142. package/bundle/node_modules/undici/lib/web/websocket/frame.js +0 -138
  143. package/bundle/node_modules/undici/lib/web/websocket/permessage-deflate.js +0 -70
  144. package/bundle/node_modules/undici/lib/web/websocket/receiver.js +0 -454
  145. package/bundle/node_modules/undici/lib/web/websocket/sender.js +0 -109
  146. package/bundle/node_modules/undici/lib/web/websocket/stream/websocketerror.js +0 -83
  147. package/bundle/node_modules/undici/lib/web/websocket/stream/websocketstream.js +0 -485
  148. package/bundle/node_modules/undici/lib/web/websocket/util.js +0 -338
  149. package/bundle/node_modules/undici/lib/web/websocket/websocket.js +0 -686
  150. package/bundle/node_modules/undici/package.json +0 -149
  151. package/bundle/node_modules/undici/scripts/strip-comments.js +0 -10
  152. package/bundle/node_modules/undici/types/README.md +0 -6
  153. package/bundle/node_modules/undici/types/agent.d.ts +0 -35
  154. package/bundle/node_modules/undici/types/api.d.ts +0 -43
  155. package/bundle/node_modules/undici/types/balanced-pool.d.ts +0 -29
  156. package/bundle/node_modules/undici/types/cache-interceptor.d.ts +0 -172
  157. package/bundle/node_modules/undici/types/cache.d.ts +0 -36
  158. package/bundle/node_modules/undici/types/client-stats.d.ts +0 -15
  159. package/bundle/node_modules/undici/types/client.d.ts +0 -110
  160. package/bundle/node_modules/undici/types/connector.d.ts +0 -34
  161. package/bundle/node_modules/undici/types/content-type.d.ts +0 -21
  162. package/bundle/node_modules/undici/types/cookies.d.ts +0 -30
  163. package/bundle/node_modules/undici/types/diagnostics-channel.d.ts +0 -66
  164. package/bundle/node_modules/undici/types/dispatcher.d.ts +0 -281
  165. package/bundle/node_modules/undici/types/env-http-proxy-agent.d.ts +0 -21
  166. package/bundle/node_modules/undici/types/errors.d.ts +0 -171
  167. package/bundle/node_modules/undici/types/eventsource.d.ts +0 -61
  168. package/bundle/node_modules/undici/types/fetch.d.ts +0 -210
  169. package/bundle/node_modules/undici/types/formdata.d.ts +0 -108
  170. package/bundle/node_modules/undici/types/global-dispatcher.d.ts +0 -9
  171. package/bundle/node_modules/undici/types/global-origin.d.ts +0 -7
  172. package/bundle/node_modules/undici/types/h2c-client.d.ts +0 -75
  173. package/bundle/node_modules/undici/types/handlers.d.ts +0 -15
  174. package/bundle/node_modules/undici/types/header.d.ts +0 -160
  175. package/bundle/node_modules/undici/types/index.d.ts +0 -75
  176. package/bundle/node_modules/undici/types/interceptors.d.ts +0 -34
  177. package/bundle/node_modules/undici/types/mock-agent.d.ts +0 -68
  178. package/bundle/node_modules/undici/types/mock-call-history.d.ts +0 -111
  179. package/bundle/node_modules/undici/types/mock-client.d.ts +0 -25
  180. package/bundle/node_modules/undici/types/mock-errors.d.ts +0 -12
  181. package/bundle/node_modules/undici/types/mock-interceptor.d.ts +0 -93
  182. package/bundle/node_modules/undici/types/mock-pool.d.ts +0 -25
  183. package/bundle/node_modules/undici/types/patch.d.ts +0 -29
  184. package/bundle/node_modules/undici/types/pool-stats.d.ts +0 -19
  185. package/bundle/node_modules/undici/types/pool.d.ts +0 -41
  186. package/bundle/node_modules/undici/types/proxy-agent.d.ts +0 -29
  187. package/bundle/node_modules/undici/types/readable.d.ts +0 -68
  188. package/bundle/node_modules/undici/types/retry-agent.d.ts +0 -8
  189. package/bundle/node_modules/undici/types/retry-handler.d.ts +0 -116
  190. package/bundle/node_modules/undici/types/util.d.ts +0 -18
  191. package/bundle/node_modules/undici/types/utility.d.ts +0 -7
  192. package/bundle/node_modules/undici/types/webidl.d.ts +0 -266
  193. package/bundle/node_modules/undici/types/websocket.d.ts +0 -184
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepv-code",
3
- "version": "1.0.182",
3
+ "version": "1.0.183",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
@@ -1,113 +0,0 @@
1
- # 智能帮助系统资源目录
2
-
3
- ## 目录说明
4
-
5
- 此目录包含 DeepV Code CLI 智能帮助系统的知识库文件。
6
-
7
- ## 文件清单
8
-
9
- ### `cli-help-knowledge.md`
10
- 智能帮助系统的主知识库文件,包含:
11
- - 所有斜杠命令的详细说明
12
- - At 命令使用方法
13
- - Shell 模式说明
14
- - 配置系统文档
15
- - 常见问题解答
16
- - 使用场景示例
17
- - 故障排查指南
18
-
19
- **用途:** 作为 Help Subagent 的上下文,用于回答用户关于 CLI 功能的问题。
20
-
21
- **维护:** 当 CLI 添加新功能或修改现有功能时,需同步更新此文件。
22
-
23
- ## 构建和打包
24
-
25
- ### 开发阶段
26
- 在开发时,文件位于:
27
- ```
28
- packages/cli/src/assets/help/cli-help-knowledge.md
29
- ```
30
-
31
- ### 构建后
32
- 构建后,文件应被复制到:
33
- ```
34
- dist/assets/help/cli-help-knowledge.md
35
- bundle/cli/assets/help/cli-help-knowledge.md
36
- ```
37
-
38
- ### esbuild 配置
39
- 需要在 `esbuild.config.js` 中添加资源复制配置:
40
- ```javascript
41
- {
42
- entryPoints: ['packages/cli/src/assets/help/cli-help-knowledge.md'],
43
- loader: { '.md': 'text' },
44
- outdir: 'dist/assets/help',
45
- }
46
- ```
47
-
48
- ### 构建脚本
49
- 在 `scripts/build.js` 或 `scripts/copy_bundle_assets.js` 中添加:
50
- ```javascript
51
- await copyAssets([
52
- {
53
- from: 'packages/cli/src/assets/help',
54
- to: 'bundle/cli/assets/help',
55
- },
56
- ]);
57
- ```
58
-
59
- ## 使用方式
60
-
61
- ### 在代码中加载
62
- ```typescript
63
- import { readFileSync } from 'node:fs';
64
- import { join, dirname } from 'node:path';
65
- import { fileURLToPath } from 'node:url';
66
-
67
- const __dirname = dirname(fileURLToPath(import.meta.url));
68
- const helpKnowledgePath = join(__dirname, '../assets/help/cli-help-knowledge.md');
69
- const knowledgeBase = readFileSync(helpKnowledgePath, 'utf-8');
70
- ```
71
-
72
- ### 用于 Subagent
73
- ```typescript
74
- const systemPrompt = `你是 DeepV Code CLI 的智能帮助助手。
75
-
76
- 以下是完整的 CLI 功能知识库:
77
-
78
- ${knowledgeBase}
79
-
80
- 请根据知识库内容回答用户的问题。`;
81
- ```
82
-
83
- ## 知识库更新指南
84
-
85
- ### 何时更新
86
- - 添加新的斜杠命令
87
- - 修改现有命令行为
88
- - 添加新的配置选项
89
- - 修改默认值或行为
90
- - 添加新的使用场景
91
-
92
- ### 更新流程
93
- 1. 修改 `cli-help-knowledge.md`
94
- 2. 验证内容准确性
95
- 3. 测试 Help Subagent 能否正确回答
96
- 4. 提交代码变更
97
-
98
- ### 内容原则
99
- - **准确性:** 确保所有信息与实际实现一致
100
- - **完整性:** 涵盖所有用户可能遇到的功能
101
- - **清晰性:** 使用简洁明确的语言
102
- - **示例:** 提供实际可用的示例代码
103
- - **可搜索:** 使用关键词便于 AI 检索
104
-
105
- ## 相关文件
106
-
107
- - **设计文档:** `docs/cli/智能帮助系统设计方案.md`
108
- - **实现代码:** `packages/cli/src/ui/commands/HelpCommand.ts`(待实现)
109
- - **Subagent:** `packages/cli/src/services/HelpSubagent.ts`(待实现)
110
-
111
- ## 许可证
112
-
113
- 遵循项目主许可证(Apache-2.0)。
@@ -1,74 +0,0 @@
1
- # 音频通知配置
2
-
3
- DeepV Code 支持在关键交互点播放提示音,提升用户体验。
4
-
5
- ## 音频文件
6
-
7
- 请将以下 WAV 格式音频文件放在此目录:
8
-
9
- - `response-complete.wav` - Agent响应完成时播放
10
- - `confirmation-required.wav` - 需要用户确认工具执行时播放
11
- - `selection-made.wav` - 用户做出选择后播放
12
-
13
- ## 配置选项
14
-
15
- 在你的 `~/.deepv/settings.json` 文件中添加以下配置:
16
-
17
- ```json
18
- {
19
- "audioNotifications": {
20
- "enabled": true,
21
- "responseComplete": true,
22
- "confirmationRequired": true,
23
- "selectionMade": true
24
- }
25
- }
26
- ```
27
-
28
- ### 配置说明
29
-
30
- - `enabled`: 总开关,设为 `false` 可完全禁用音频通知
31
- - `responseComplete`: Agent响应完成提示音
32
- - `confirmationRequired`: 工具执行确认提示音
33
- - `selectionMade`: 选择完成提示音
34
-
35
- ## 测试音频
36
-
37
- 运行以下命令测试音频功能:
38
-
39
- ```bash
40
- dvcode --test-audio
41
- ```
42
-
43
- ## 跨平台支持
44
-
45
- 音频通知支持以下平台:
46
-
47
- ### Windows
48
- - 优先使用 PowerShell 播放自定义 WAV 文件
49
- - 备选使用系统提示音(不同频率区分类型)
50
-
51
- ### macOS
52
- - 优先使用 `afplay` 播放自定义 WAV 文件
53
- - 备选使用系统音效(Glass.aiff, Ping.aiff, Pop.aiff)
54
-
55
- ### Linux
56
- - 优先使用 `paplay` 或 `aplay` 播放自定义 WAV 文件
57
- - 备选使用 `speaker-test` 生成不同频率提示音
58
-
59
- ## 故障排除
60
-
61
- 如果音频不工作:
62
-
63
- 1. 检查系统音量设置
64
- 2. 确保音频文件格式正确(WAV 格式)
65
- 3. 运行 `dvcode --test-audio` 进行诊断
66
- 4. 查看控制台调试信息
67
- 5. 临时禁用音频通知继续使用
68
-
69
- ## 音频文件建议
70
-
71
- - 文件大小:建议小于 100KB
72
- - 时长:建议 0.2-1 秒
73
- - 格式:WAV(16-bit PCM)
74
- - 音量:适中,避免过于刺耳
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Matteo Collina and Undici contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,472 +0,0 @@
1
- # undici
2
-
3
- [![Node CI](https://github.com/nodejs/undici/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![neostandard javascript style](https://img.shields.io/badge/neo-standard-7fffff?style=flat\&labelColor=ff80ff)](https://github.com/neostandard/neostandard) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici)
4
-
5
- An HTTP/1.1 client, written from scratch for Node.js.
6
-
7
- > Undici means eleven in Italian. 1.1 -> 11 -> Eleven -> Undici.
8
- It is also a Stranger Things reference.
9
-
10
- ## How to get involved
11
-
12
- Have a question about using Undici? Open a [Q&A Discussion](https://github.com/nodejs/undici/discussions/new) or join our official OpenJS [Slack](https://openjs-foundation.slack.com/archives/C01QF9Q31QD) channel.
13
-
14
- Looking to contribute? Start by reading the [contributing guide](./CONTRIBUTING.md)
15
-
16
- ## Install
17
-
18
- ```
19
- npm i undici
20
- ```
21
-
22
- ## Benchmarks
23
-
24
- The benchmark is a simple getting data [example](https://github.com/nodejs/undici/blob/main/benchmarks/benchmark.js) using a
25
- 50 TCP connections with a pipelining depth of 10 running on Node 22.11.0.
26
-
27
- ```
28
- ┌────────────────────────┬─────────┬────────────────────┬────────────┬─────────────────────────┐
29
- │ Tests │ Samples │ Result │ Tolerance │ Difference with slowest │
30
- ├────────────────────────┼─────────┼────────────────────┼────────────┼─────────────────────────┤
31
- │ 'axios' │ 15 │ '5708.26 req/sec' │ '± 2.91 %' │ '-' │
32
- │ 'http - no keepalive' │ 10 │ '5809.80 req/sec' │ '± 2.30 %' │ '+ 1.78 %' │
33
- │ 'request' │ 30 │ '5828.80 req/sec' │ '± 2.91 %' │ '+ 2.11 %' │
34
- │ 'undici - fetch' │ 40 │ '5903.78 req/sec' │ '± 2.87 %' │ '+ 3.43 %' │
35
- │ 'node-fetch' │ 10 │ '5945.40 req/sec' │ '± 2.13 %' │ '+ 4.15 %' │
36
- │ 'got' │ 35 │ '6511.45 req/sec' │ '± 2.84 %' │ '+ 14.07 %' │
37
- │ 'http - keepalive' │ 65 │ '9193.24 req/sec' │ '± 2.92 %' │ '+ 61.05 %' │
38
- │ 'superagent' │ 35 │ '9339.43 req/sec' │ '± 2.95 %' │ '+ 63.61 %' │
39
- │ 'undici - pipeline' │ 50 │ '13364.62 req/sec' │ '± 2.93 %' │ '+ 134.13 %' │
40
- │ 'undici - stream' │ 95 │ '18245.36 req/sec' │ '± 2.99 %' │ '+ 219.63 %' │
41
- │ 'undici - request' │ 50 │ '18340.17 req/sec' │ '± 2.84 %' │ '+ 221.29 %' │
42
- │ 'undici - dispatch' │ 40 │ '22234.42 req/sec' │ '± 2.94 %' │ '+ 289.51 %' │
43
- └────────────────────────┴─────────┴────────────────────┴────────────┴─────────────────────────┘
44
- ```
45
-
46
- ## Quick Start
47
-
48
- ```js
49
- import { request } from 'undici'
50
-
51
- const {
52
- statusCode,
53
- headers,
54
- trailers,
55
- body
56
- } = await request('http://localhost:3000/foo')
57
-
58
- console.log('response received', statusCode)
59
- console.log('headers', headers)
60
-
61
- for await (const data of body) { console.log('data', data) }
62
-
63
- console.log('trailers', trailers)
64
- ```
65
-
66
- ## Body Mixins
67
-
68
- The `body` mixins are the most common way to format the request/response body. Mixins include:
69
-
70
- - [`.arrayBuffer()`](https://fetch.spec.whatwg.org/#dom-body-arraybuffer)
71
- - [`.blob()`](https://fetch.spec.whatwg.org/#dom-body-blob)
72
- - [`.bytes()`](https://fetch.spec.whatwg.org/#dom-body-bytes)
73
- - [`.json()`](https://fetch.spec.whatwg.org/#dom-body-json)
74
- - [`.text()`](https://fetch.spec.whatwg.org/#dom-body-text)
75
-
76
- > [!NOTE]
77
- > The body returned from `undici.request` does not implement `.formData()`.
78
-
79
- Example usage:
80
-
81
- ```js
82
- import { request } from 'undici'
83
-
84
- const {
85
- statusCode,
86
- headers,
87
- trailers,
88
- body
89
- } = await request('http://localhost:3000/foo')
90
-
91
- console.log('response received', statusCode)
92
- console.log('headers', headers)
93
- console.log('data', await body.json())
94
- console.log('trailers', trailers)
95
- ```
96
-
97
- _Note: Once a mixin has been called then the body cannot be reused, thus calling additional mixins on `.body`, e.g. `.body.json(); .body.text()` will result in an error `TypeError: unusable` being thrown and returned through the `Promise` rejection._
98
-
99
- Should you need to access the `body` in plain-text after using a mixin, the best practice is to use the `.text()` mixin first and then manually parse the text to the desired format.
100
-
101
- For more information about their behavior, please reference the body mixin from the [Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
102
-
103
- ## Common API Methods
104
-
105
- This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [docs](./docs/) folder and are accessible via the navigation list on the left side of the docs site.
106
-
107
- ### `undici.request([url, options]): Promise`
108
-
109
- Arguments:
110
-
111
- * **url** `string | URL | UrlObject`
112
- * **options** [`RequestOptions`](./docs/docs/api/Dispatcher.md#parameter-requestoptions)
113
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
114
- * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
115
-
116
- Returns a promise with the result of the `Dispatcher.request` method.
117
-
118
- Calls `options.dispatcher.request(options)`.
119
-
120
- See [Dispatcher.request](./docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback) for more details, and [request examples](./docs/examples/README.md) for examples.
121
-
122
- ### `undici.stream([url, options, ]factory): Promise`
123
-
124
- Arguments:
125
-
126
- * **url** `string | URL | UrlObject`
127
- * **options** [`StreamOptions`](./docs/docs/api/Dispatcher.md#parameter-streamoptions)
128
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
129
- * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
130
- * **factory** `Dispatcher.stream.factory`
131
-
132
- Returns a promise with the result of the `Dispatcher.stream` method.
133
-
134
- Calls `options.dispatcher.stream(options, factory)`.
135
-
136
- See [Dispatcher.stream](./docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback) for more details.
137
-
138
- ### `undici.pipeline([url, options, ]handler): Duplex`
139
-
140
- Arguments:
141
-
142
- * **url** `string | URL | UrlObject`
143
- * **options** [`PipelineOptions`](./docs/docs/api/Dispatcher.md#parameter-pipelineoptions)
144
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
145
- * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
146
- * **handler** `Dispatcher.pipeline.handler`
147
-
148
- Returns: `stream.Duplex`
149
-
150
- Calls `options.dispatch.pipeline(options, handler)`.
151
-
152
- See [Dispatcher.pipeline](./docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler) for more details.
153
-
154
- ### `undici.connect([url, options]): Promise`
155
-
156
- Starts two-way communications with the requested resource using [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).
157
-
158
- Arguments:
159
-
160
- * **url** `string | URL | UrlObject`
161
- * **options** [`ConnectOptions`](./docs/docs/api/Dispatcher.md#parameter-connectoptions)
162
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
163
- * **callback** `(err: Error | null, data: ConnectData | null) => void` (optional)
164
-
165
- Returns a promise with the result of the `Dispatcher.connect` method.
166
-
167
- Calls `options.dispatch.connect(options)`.
168
-
169
- See [Dispatcher.connect](./docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback) for more details.
170
-
171
- ### `undici.fetch(input[, init]): Promise`
172
-
173
- Implements [fetch](https://fetch.spec.whatwg.org/#fetch-method).
174
-
175
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
176
- * https://fetch.spec.whatwg.org/#fetch-method
177
-
178
- Basic usage example:
179
-
180
- ```js
181
- import { fetch } from 'undici'
182
-
183
-
184
- const res = await fetch('https://example.com')
185
- const json = await res.json()
186
- console.log(json)
187
- ```
188
-
189
- You can pass an optional dispatcher to `fetch` as:
190
-
191
- ```js
192
- import { fetch, Agent } from 'undici'
193
-
194
- const res = await fetch('https://example.com', {
195
- // Mocks are also supported
196
- dispatcher: new Agent({
197
- keepAliveTimeout: 10,
198
- keepAliveMaxTimeout: 10
199
- })
200
- })
201
- const json = await res.json()
202
- console.log(json)
203
- ```
204
-
205
- #### `request.body`
206
-
207
- A body can be of the following types:
208
-
209
- - ArrayBuffer
210
- - ArrayBufferView
211
- - AsyncIterables
212
- - Blob
213
- - Iterables
214
- - String
215
- - URLSearchParams
216
- - FormData
217
-
218
- In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard](https://fetch.spec.whatwg.org).
219
-
220
- ```js
221
- import { fetch } from 'undici'
222
-
223
- const data = {
224
- async *[Symbol.asyncIterator]() {
225
- yield 'hello'
226
- yield 'world'
227
- },
228
- }
229
-
230
- await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' })
231
- ```
232
-
233
- [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) besides text data and buffers can also utilize streams via [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects:
234
-
235
- ```js
236
- import { openAsBlob } from 'node:fs'
237
-
238
- const file = await openAsBlob('./big.csv')
239
- const body = new FormData()
240
- body.set('file', file, 'big.csv')
241
-
242
- await fetch('http://example.com', { method: 'POST', body })
243
- ```
244
-
245
- #### `request.duplex`
246
-
247
- - `'half'`
248
-
249
- In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`, however, even though the value must be set to `'half'`, it is actually a _full_ duplex. For more detail refer to the [Fetch Standard](https://fetch.spec.whatwg.org/#dom-requestinit-duplex).
250
-
251
- #### `response.body`
252
-
253
- Nodejs has two kinds of streams: [web streams](https://nodejs.org/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
254
-
255
- ```js
256
- import { fetch } from 'undici'
257
- import { Readable } from 'node:stream'
258
-
259
- const response = await fetch('https://example.com')
260
- const readableWebStream = response.body
261
- const readableNodeStream = Readable.fromWeb(readableWebStream)
262
- ```
263
-
264
- ## Specification Compliance
265
-
266
- This section documents parts of the [HTTP/1.1](https://www.rfc-editor.org/rfc/rfc9110.html) and [Fetch Standard](https://fetch.spec.whatwg.org) that Undici does
267
- not support or does not fully implement.
268
-
269
- #### CORS
270
-
271
- Unlike browsers, Undici does not implement CORS (Cross-Origin Resource Sharing) checks by default. This means:
272
-
273
- - No preflight requests are automatically sent for cross-origin requests
274
- - No validation of `Access-Control-Allow-Origin` headers is performed
275
- - Requests to any origin are allowed regardless of the source
276
-
277
- This behavior is intentional for server-side environments where CORS restrictions are typically unnecessary. If your application requires CORS-like protections, you will need to implement these checks manually.
278
-
279
- #### Garbage Collection
280
-
281
- * https://fetch.spec.whatwg.org/#garbage-collection
282
-
283
- The [Fetch Standard](https://fetch.spec.whatwg.org) allows users to skip consuming the response body by relying on
284
- [garbage collection](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management#garbage_collection) to release connection resources. Undici does not do the same. Therefore, it is important to always either consume or cancel the response body.
285
-
286
- Garbage collection in Node is less aggressive and deterministic
287
- (due to the lack of clear idle periods that browsers have through the rendering refresh rate)
288
- which means that leaving the release of connection resources to the garbage collector can lead
289
- to excessive connection usage, reduced performance (due to less connection re-use), and even
290
- stalls or deadlocks when running out of connections.
291
-
292
- ```js
293
- // Do
294
- const { body, headers } = await fetch(url);
295
- for await (const chunk of body) {
296
- // force consumption of body
297
- }
298
-
299
- // Do not
300
- const { headers } = await fetch(url);
301
- ```
302
-
303
- The same applies for `request` too:
304
- ```js
305
- // Do
306
- const { body, headers } = await request(url);
307
- await res.body.dump(); // force consumption of body
308
-
309
- // Do not
310
- const { headers } = await request(url);
311
- ```
312
-
313
- However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.
314
-
315
- ```js
316
- const headers = await fetch(url, { method: 'HEAD' })
317
- .then(res => res.headers)
318
- ```
319
-
320
- #### Forbidden and Safelisted Header Names
321
-
322
- * https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name
323
- * https://fetch.spec.whatwg.org/#forbidden-header-name
324
- * https://fetch.spec.whatwg.org/#forbidden-response-header-name
325
- * https://github.com/wintercg/fetch/issues/6
326
-
327
- The [Fetch Standard](https://fetch.spec.whatwg.org) requires implementations to exclude certain headers from requests and responses. In browser environments, some headers are forbidden so the user agent remains in full control over them. In Undici, these constraints are removed to give more control to the user.
328
-
329
- #### `undici.upgrade([url, options]): Promise`
330
-
331
- Upgrade to a different protocol. See [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details.
332
-
333
- Arguments:
334
-
335
- * **url** `string | URL | UrlObject`
336
- * **options** [`UpgradeOptions`](./docs/docs/api/Dispatcher.md#parameter-upgradeoptions)
337
- * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
338
- * **callback** `(error: Error | null, data: UpgradeData) => void` (optional)
339
-
340
- Returns a promise with the result of the `Dispatcher.upgrade` method.
341
-
342
- Calls `options.dispatcher.upgrade(options)`.
343
-
344
- See [Dispatcher.upgrade](./docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback) for more details.
345
-
346
- ### `undici.setGlobalDispatcher(dispatcher)`
347
-
348
- * dispatcher `Dispatcher`
349
-
350
- Sets the global dispatcher used by Common API Methods. Global dispatcher is shared among compatible undici modules,
351
- including undici that is bundled internally with node.js.
352
-
353
- ### `undici.getGlobalDispatcher()`
354
-
355
- Gets the global dispatcher used by Common API Methods.
356
-
357
- Returns: `Dispatcher`
358
-
359
- ### `undici.setGlobalOrigin(origin)`
360
-
361
- * origin `string | URL | undefined`
362
-
363
- Sets the global origin used in `fetch`.
364
-
365
- If `undefined` is passed, the global origin will be reset. This will cause `Response.redirect`, `new Request()`, and `fetch` to throw an error when a relative path is passed.
366
-
367
- ```js
368
- setGlobalOrigin('http://localhost:3000')
369
-
370
- const response = await fetch('/api/ping')
371
-
372
- console.log(response.url) // http://localhost:3000/api/ping
373
- ```
374
-
375
- ### `undici.getGlobalOrigin()`
376
-
377
- Gets the global origin used in `fetch`.
378
-
379
- Returns: `URL`
380
-
381
- ### `UrlObject`
382
-
383
- * **port** `string | number` (optional)
384
- * **path** `string` (optional)
385
- * **pathname** `string` (optional)
386
- * **hostname** `string` (optional)
387
- * **origin** `string` (optional)
388
- * **protocol** `string` (optional)
389
- * **search** `string` (optional)
390
-
391
- #### Expect
392
-
393
- Undici does not support the `Expect` request header field. The request
394
- body is always immediately sent and the `100 Continue` response will be
395
- ignored.
396
-
397
- Refs: https://tools.ietf.org/html/rfc7231#section-5.1.1
398
-
399
- #### Pipelining
400
-
401
- Undici will only use pipelining if configured with a `pipelining` factor
402
- greater than `1`. Also it is important to pass `blocking: false` to the
403
- request options to properly pipeline requests.
404
-
405
- Undici always assumes that connections are persistent and will immediately
406
- pipeline requests, without checking whether the connection is persistent.
407
- Hence, automatic fallback to HTTP/1.0 or HTTP/1.1 without pipelining is
408
- not supported.
409
-
410
- Undici will immediately pipeline when retrying requests after a failed
411
- connection. However, Undici will not retry the first remaining requests in
412
- the prior pipeline and instead error the corresponding callback/promise/stream.
413
-
414
- Undici will abort all running requests in the pipeline when any of them are
415
- aborted.
416
-
417
- * Refs: https://tools.ietf.org/html/rfc2616#section-8.1.2.2
418
- * Refs: https://tools.ietf.org/html/rfc7230#section-6.3.2
419
-
420
- #### Manual Redirect
421
-
422
- Since it is not possible to manually follow an HTTP redirect on the server-side,
423
- Undici returns the actual response instead of an `opaqueredirect` filtered one
424
- when invoked with a `manual` redirect. This aligns `fetch()` with the other
425
- implementations in Deno and Cloudflare Workers.
426
-
427
- Refs: https://fetch.spec.whatwg.org/#atomic-http-redirect-handling
428
-
429
- ### Workarounds
430
-
431
- #### Network address family autoselection.
432
-
433
- If you experience problem when connecting to a remote server that is resolved by your DNS servers to a IPv6 (AAAA record)
434
- first, there are chances that your local router or ISP might have problem connecting to IPv6 networks. In that case
435
- undici will throw an error with code `UND_ERR_CONNECT_TIMEOUT`.
436
-
437
- If the target server resolves to both a IPv6 and IPv4 (A records) address and you are using a compatible Node version
438
- (18.3.0 and above), you can fix the problem by providing the `autoSelectFamily` option (support by both `undici.request`
439
- and `undici.Agent`) which will enable the family autoselection algorithm when establishing the connection.
440
-
441
- ## Collaborators
442
-
443
- * [__Daniele Belardi__](https://github.com/dnlup), <https://www.npmjs.com/~dnlup>
444
- * [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
445
- * [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
446
- * [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
447
- * [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
448
- * [__Szymon Marczak__](https://github.com/szmarczak), <https://www.npmjs.com/~szmarczak>
449
-
450
- ## Past Collaborators
451
- * [__Tomas Della Vedova__](https://github.com/delvedor), <https://www.npmjs.com/~delvedor>
452
-
453
- ### Releasers
454
-
455
- * [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
456
- * [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
457
- * [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
458
- * [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
459
-
460
- ## Long Term Support
461
-
462
- Undici aligns with the Node.js LTS schedule. The following table shows the supported versions:
463
-
464
- | Version | Node.js | End of Life |
465
- |---------|-------------|-------------|
466
- | 5.x | v18.x | 2024-04-30 |
467
- | 6.x | v20.x v22.x | 2026-04-30 |
468
- | 7.x | v24.x | 2027-04-30 |
469
-
470
- ## License
471
-
472
- MIT