maka-agent 0.2.1-dev.91.20261018 → 0.2.2-dev.97.20261024

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 (418) hide show
  1. package/DISCLAIMER-WIP +1 -1
  2. package/LICENSE +15 -11
  3. package/README.md +173 -1
  4. package/README.zh-CN.md +156 -0
  5. package/THIRD_PARTY_NOTICES.txt +12 -12
  6. package/dist/cli-core.js +1 -0
  7. package/dist/pi-goal.js +13 -0
  8. package/dist/pi-tui-runner.js +44 -1
  9. package/dist/run-command-core.js +256 -48
  10. package/dist/run-session-command.js +534 -0
  11. package/dist/run-session-result.js +38 -0
  12. package/dist/run-turn-outcome.js +174 -0
  13. package/dist/runtime-host-cli.js +32 -17
  14. package/dist/runtime-host-run-command.js +53 -165
  15. package/dist/runtime-host-run-mcp.js +3 -0
  16. package/dist/runtime-host-session-channel.js +3 -1
  17. package/dist/runtime-host-session-driver.js +5 -0
  18. package/dist/runtime-host-setup-command.js +114 -7
  19. package/dist/tui-copy-catalog.js +24 -0
  20. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  21. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
  22. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
  23. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
  24. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
  25. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  26. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  27. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
  28. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  29. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
  30. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  31. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  32. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
  33. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
  34. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
  35. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
  36. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  37. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  38. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
  39. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
  40. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  41. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  42. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
  43. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
  44. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
  45. package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
  46. package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
  47. package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
  48. package/node_modules/@maka/core/dist/bot-chat-settings.js +10 -1
  49. package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
  50. package/node_modules/@maka/core/dist/event-wait.js +75 -10
  51. package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
  52. package/node_modules/@maka/core/dist/goal.js +54 -2
  53. package/node_modules/@maka/core/dist/model-catalog.js +19 -1
  54. package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
  55. package/node_modules/@maka/core/dist/model-metadata.js +42 -1
  56. package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
  57. package/node_modules/@maka/core/dist/provider-registry.js +16 -2
  58. package/node_modules/@maka/core/dist/runtime-event-store.js +0 -1
  59. package/node_modules/@maka/core/dist/runtime-event.js +24 -2
  60. package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
  61. package/node_modules/@maka/core/dist/session-checkin.js +31 -0
  62. package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
  63. package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
  64. package/node_modules/@maka/core/dist/turn-origin.js +14 -2
  65. package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
  66. package/node_modules/@maka/core/package.json +3 -0
  67. package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
  68. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  69. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
  70. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  71. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
  72. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  73. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  74. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  75. package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
  76. package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
  77. package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  78. package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  79. package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
  80. package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
  81. package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
  82. package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
  83. package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
  84. package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
  85. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
  86. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  87. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  88. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
  89. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  90. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  91. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  92. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  93. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
  94. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  95. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  96. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  97. package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
  98. package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  99. package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  100. package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
  101. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
  102. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
  103. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
  104. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
  105. package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
  106. package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
  107. package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
  108. package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
  109. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  110. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  111. package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
  112. package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
  113. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  114. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  115. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
  116. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  117. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
  118. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
  119. package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  120. package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  121. package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
  122. package/node_modules/@maka/mcp/package.json +1 -1
  123. package/node_modules/@maka/runtime/dist/agent-run.js +5 -1
  124. package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
  125. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +29 -15
  126. package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
  127. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +125 -131
  128. package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
  129. package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
  130. package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
  131. package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
  132. package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
  133. package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
  134. package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
  135. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +34 -4
  136. package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
  137. package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
  138. package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
  139. package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
  140. package/node_modules/@maka/runtime/dist/model-history.js +16 -3
  141. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +15 -5
  142. package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
  143. package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
  144. package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
  145. package/node_modules/@maka/runtime/dist/provider-error-classification.js +2 -0
  146. package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
  147. package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
  148. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
  149. package/node_modules/@maka/runtime/dist/sandbox-boundary-path.js +79 -2
  150. package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
  151. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
  152. package/node_modules/@maka/runtime/dist/session-manager.js +5 -1
  153. package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
  154. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
  155. package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
  156. package/node_modules/@maka/runtime/dist/tool-runtime.js +11 -2
  157. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
  158. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
  159. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
  160. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
  161. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
  162. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  163. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  164. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
  165. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  166. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
  167. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  168. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  169. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
  170. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
  171. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
  172. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
  173. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  174. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  175. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
  176. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
  177. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  178. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  179. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
  180. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
  181. package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
  182. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  183. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
  184. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  185. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
  186. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  187. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  188. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  189. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
  190. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
  191. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  192. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  193. package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
  194. package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
  195. package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
  196. package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
  197. package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
  198. package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
  199. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
  200. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  201. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  202. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
  203. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  204. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  205. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  206. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  207. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
  208. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  209. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  210. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  211. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
  212. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  213. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  214. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
  215. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
  216. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
  217. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
  218. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
  219. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
  220. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
  221. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
  222. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
  223. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  224. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  225. package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
  226. package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
  227. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  228. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  229. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
  230. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  231. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
  232. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
  233. package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  234. package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  235. package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
  236. package/node_modules/@maka/runtime/package.json +3 -0
  237. package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
  238. package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
  239. package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +92 -22
  240. package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
  241. package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
  242. package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
  243. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
  244. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
  245. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
  246. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
  247. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
  248. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
  249. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
  250. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +203 -71
  251. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +21 -5
  252. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
  253. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
  254. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
  255. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
  256. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +37 -5
  257. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
  258. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
  259. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
  260. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
  261. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +68 -14
  262. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
  263. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
  264. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +93 -23
  265. package/node_modules/@maka/runtime-host/dist/assistant/service.js +72 -16
  266. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
  267. package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
  268. package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
  269. package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -3
  270. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
  271. package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
  272. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
  273. package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
  274. package/node_modules/@maka/runtime-host/dist/server/agent-settings-tools.js +0 -1
  275. package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
  276. package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +151 -20
  277. package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
  278. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +127 -11
  279. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
  280. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
  281. package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
  282. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +343 -53
  283. package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +457 -0
  284. package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
  285. package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
  286. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
  287. package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
  288. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
  289. package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
  290. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +8 -0
  291. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
  292. package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
  293. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
  294. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
  295. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
  296. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
  297. package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
  298. package/node_modules/@maka/storage/dist/agent-run-store-contract.js +14 -3
  299. package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
  300. package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
  301. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
  302. package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
  303. package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
  304. package/node_modules/@maka/storage/dist/execution-stores.js +39 -1
  305. package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
  306. package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
  307. package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
  308. package/node_modules/@maka/storage/dist/local-execution-persistence.js +27 -1
  309. package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
  310. package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
  311. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  312. package/node_modules/@maka/storage/dist/session-bundle-policy.js +116 -16
  313. package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
  314. package/node_modules/@maka/storage/dist/session-store.js +37 -8
  315. package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
  316. package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
  317. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
  318. package/node_modules/@maka/storage/dist/sqlite-event-wait-authority.js +81 -8
  319. package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
  320. package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
  321. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
  322. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +38 -162
  323. package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
  324. package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
  325. package/node_modules/@maka/storage/package.json +4 -0
  326. package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
  327. package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
  328. package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
  329. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
  330. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
  331. package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
  332. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
  333. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
  334. package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
  335. package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
  336. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
  337. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
  338. package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
  339. package/node_modules/@modelcontextprotocol/client/package.json +5 -5
  340. package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
  341. package/node_modules/fast-uri/README.md +8 -0
  342. package/node_modules/fast-uri/index.js +98 -18
  343. package/node_modules/fast-uri/lib/utils.js +52 -0
  344. package/node_modules/fast-uri/package.json +1 -1
  345. package/node_modules/follow-redirects/index.js +10 -1
  346. package/node_modules/follow-redirects/package.json +1 -1
  347. package/node_modules/ip-address/README.md +104 -104
  348. package/node_modules/ip-address/dist/ipv4.js +7 -0
  349. package/node_modules/ip-address/dist/ipv6.js +7 -4
  350. package/node_modules/ip-address/dist/v6/constants.js +3 -0
  351. package/node_modules/ip-address/package.json +2 -1
  352. package/node_modules/undici/README.md +25 -3
  353. package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  354. package/node_modules/undici/docs/docs/api/Client.md +11 -6
  355. package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  356. package/node_modules/undici/docs/docs/api/Errors.md +76 -1
  357. package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  358. package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  359. package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  360. package/node_modules/undici/docs/docs/index.md +12 -12
  361. package/node_modules/undici/docs/docs/type-map.json +66 -66
  362. package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  363. package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  364. package/node_modules/undici/lib/core/connect.js +10 -4
  365. package/node_modules/undici/lib/core/constants.js +12 -1
  366. package/node_modules/undici/lib/core/errors.js +38 -1
  367. package/node_modules/undici/lib/core/request.js +16 -1
  368. package/node_modules/undici/lib/core/symbols.js +2 -0
  369. package/node_modules/undici/lib/core/util.js +26 -1
  370. package/node_modules/undici/lib/dispatcher/agent.js +6 -2
  371. package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  372. package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  373. package/node_modules/undici/lib/dispatcher/client.js +4 -1
  374. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  375. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  376. package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  377. package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  378. package/node_modules/undici/lib/dispatcher/pool.js +11 -8
  379. package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  380. package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  381. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  382. package/node_modules/undici/lib/handler/cache-handler.js +153 -15
  383. package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  384. package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  385. package/node_modules/undici/lib/handler/retry-handler.js +44 -11
  386. package/node_modules/undici/lib/interceptor/cache.js +11 -3
  387. package/node_modules/undici/lib/interceptor/decompress.js +22 -9
  388. package/node_modules/undici/lib/interceptor/dns.js +11 -0
  389. package/node_modules/undici/lib/interceptor/response-error.js +72 -28
  390. package/node_modules/undici/lib/milo/LICENSE.md +7 -0
  391. package/node_modules/undici/lib/milo/no-simd.js +1002 -0
  392. package/node_modules/undici/lib/milo/simd.js +1002 -0
  393. package/node_modules/undici/lib/mock/mock-agent.js +11 -0
  394. package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  395. package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  396. package/node_modules/undici/lib/util/cache.js +11 -5
  397. package/node_modules/undici/lib/web/cookies/util.js +19 -2
  398. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  399. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  400. package/node_modules/undici/lib/web/fetch/body.js +47 -38
  401. package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  402. package/node_modules/undici/lib/web/fetch/headers.js +2 -2
  403. package/node_modules/undici/lib/web/fetch/index.js +8 -4
  404. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  405. package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  406. package/node_modules/undici/package.json +9 -7
  407. package/node_modules/zod/package.json +1 -1
  408. package/node_modules/zod/v4/core/compile.cjs +8 -0
  409. package/node_modules/zod/v4/core/compile.js +8 -0
  410. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  411. package/node_modules/zod/v4/core/schemas.js +30 -0
  412. package/node_modules/zod/v4/core/util.cjs +15 -0
  413. package/node_modules/zod/v4/core/util.js +14 -0
  414. package/node_modules/zod/v4/core/versions.cjs +1 -1
  415. package/node_modules/zod/v4/core/versions.js +1 -1
  416. package/package.json +2 -2
  417. package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
  418. package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
@@ -17,6 +17,7 @@ const {
17
17
  InformationalError,
18
18
  BodyTimeoutError,
19
19
  HTTPParserError,
20
+ WebAssemblyNotSupportedError,
20
21
  ResponseExceededMaxSizeError
21
22
  } = require('../core/errors.js')
22
23
  const {
@@ -51,10 +52,15 @@ const {
51
52
  kOnError,
52
53
  kResume,
53
54
  kHTTPContext,
54
- kClosed
55
+ kClosed,
56
+ kUseMilo
55
57
  } = require('../core/symbols.js')
56
58
 
57
59
  const constants = require('../llhttp/constants.js')
60
+ // Node.js core bundles only llhttp; experimental Milo remains available in npm builds.
61
+ const { H1Parser, getMiloEnabled } = typeof esbuildDetection === 'undefined'
62
+ ? require('./parser-h1.js')
63
+ : {}
58
64
  const EMPTY_BUF = Buffer.alloc(0)
59
65
  const FastBuffer = Buffer[Symbol.species]
60
66
  const removeAllListeners = util.removeAllListeners
@@ -66,6 +72,11 @@ const kTypeOfService = Symbol('kTypeOfService')
66
72
  let extractBody
67
73
 
68
74
  function lazyllhttp () {
75
+ // Check only when HTTP/1 needs the parser, so other APIs remain usable without WASM.
76
+ if (typeof WebAssembly === 'undefined') {
77
+ throw new WebAssemblyNotSupportedError()
78
+ }
79
+
69
80
  const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined
70
81
 
71
82
  let mod
@@ -88,8 +99,7 @@ function lazyllhttp () {
88
99
  if (useWasmSIMD) {
89
100
  try {
90
101
  mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js'))
91
- } catch {
92
- }
102
+ } catch {}
93
103
  }
94
104
 
95
105
  if (!mod) {
@@ -126,7 +136,7 @@ function lazyllhttp () {
126
136
  * @param {number} p
127
137
  * @returns {number}
128
138
  */
129
- wasm_on_message_begin: (p) => {
139
+ wasm_on_message_begin: p => {
130
140
  assert(currentParser.ptr === p)
131
141
  return currentParser.onMessageBegin()
132
142
  },
@@ -178,11 +188,10 @@ function lazyllhttp () {
178
188
  * @param {number} p
179
189
  * @returns {number}
180
190
  */
181
- wasm_on_message_complete: (p) => {
191
+ wasm_on_message_complete: p => {
182
192
  assert(currentParser.ptr === p)
183
193
  return currentParser.onMessageComplete()
184
194
  }
185
-
186
195
  }
187
196
  })
188
197
  }
@@ -215,10 +224,10 @@ const TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER
215
224
 
216
225
  class Parser {
217
226
  /**
218
- * @param {import('./client.js')} client
219
- * @param {import('net').Socket} socket
220
- * @param {*} llhttp
221
- */
227
+ * @param {import('./client.js')} client
228
+ * @param {import('net').Socket} socket
229
+ * @param {*} llhttp
230
+ */
222
231
  constructor (client, socket, { exports }) {
223
232
  this.llhttp = exports
224
233
  this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE)
@@ -245,7 +254,8 @@ class Parser {
245
254
 
246
255
  this.keepAlive = ''
247
256
  this.contentLength = -1
248
- this.connectionKeepAlive = false
257
+ this.hasTransferEncoding = false
258
+ this.connection = ''
249
259
  this.maxResponseSize = client[kMaxResponseSize]
250
260
  }
251
261
 
@@ -253,10 +263,7 @@ class Parser {
253
263
  // If the existing timer and the new timer are of different timer type
254
264
  // (fast or native) or have different delay, we need to clear the existing
255
265
  // timer and set a new one.
256
- if (
257
- delay !== this.timeoutValue ||
258
- (type & USE_FAST_TIMER) ^ (this.timeoutType & USE_FAST_TIMER)
259
- ) {
266
+ if (delay !== this.timeoutValue || (type & USE_FAST_TIMER) ^ (this.timeoutType & USE_FAST_TIMER)) {
260
267
  // If a timeout is already set, clear it with clearTimeout of the fast
261
268
  // timer implementation, as it can clear fast and native timers.
262
269
  if (this.timeout) {
@@ -441,9 +448,7 @@ class Parser {
441
448
  if (ptr) {
442
449
  const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
443
450
  message =
444
- 'Response does not match the HTTP/1.1 protocol (' +
445
- Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
446
- ')'
451
+ 'Response does not match the HTTP/1.1 protocol (' + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ')'
447
452
  }
448
453
 
449
454
  return new HTTPParserError(message, constants.ERROR[ret], data)
@@ -521,6 +526,7 @@ class Parser {
521
526
  */
522
527
  onHeaderValue (buf) {
523
528
  let len = this.headers.length
529
+ const isContinuation = (len & 1) === 0
524
530
 
525
531
  if ((len & 1) === 1) {
526
532
  this.headers.push(buf)
@@ -533,19 +539,19 @@ class Parser {
533
539
  if (key.length === 10) {
534
540
  const headerName = util.bufferToLowerCasedHeaderName(key)
535
541
  if (headerName === 'keep-alive') {
536
- this.keepAlive += buf.toString()
542
+ this.keepAlive += (isContinuation || this.keepAlive.length === 0 ? '' : ',') + buf.toString()
537
543
  } else if (headerName === 'connection') {
538
- this.connectionKeepAlive =
539
- this.headers[len - 1].length === 10 &&
540
- util.bufferToLowerCasedHeaderName(this.headers[len - 1]) === 'keep-alive'
544
+ this.connection += (isContinuation || this.connection.length === 0 ? '' : ',') + buf.toString()
541
545
  }
542
546
  } else if (key.length === 14 && util.bufferToLowerCasedHeaderName(key) === 'content-length') {
543
547
  if (this.contentLength === -1) {
544
548
  this.contentLength = 0
545
549
  }
546
550
  for (let i = 0; i < buf.length; i++) {
547
- this.contentLength = (this.contentLength * 10) + (buf[i] - 0x30)
551
+ this.contentLength = this.contentLength * 10 + (buf[i] - 0x30)
548
552
  }
553
+ } else if (key.length === 17 && util.bufferToLowerCasedHeaderName(key) === 'transfer-encoding') {
554
+ this.hasTransferEncoding = true
549
555
  }
550
556
 
551
557
  this.trackHeader(buf.length)
@@ -652,16 +658,27 @@ class Parser {
652
658
  assert(this.timeoutType === TIMEOUT_HEADERS)
653
659
 
654
660
  this.statusCode = statusCode
655
- this.shouldKeepAlive = (
661
+ this.shouldKeepAlive =
656
662
  shouldKeepAlive ||
657
663
  // Override llhttp value which does not allow keepAlive for HEAD.
658
- (request.method === 'HEAD' && !socket[kReset] && this.connectionKeepAlive)
659
- )
664
+ (request.method === 'HEAD' && !socket[kReset] &&
665
+ /(?:^|,)[\t ]*keep-alive[\t ]*(?:,|$)/i.test(this.connection) &&
666
+ !/(?:^|,)[\t ]*close[\t ]*(?:,|$)/i.test(this.connection))
667
+
668
+ // Responses to HEAD and 204/304 responses never carry content
669
+ if (request.method === 'HEAD' || statusCode === 204 || statusCode === 304) {
670
+ // A non-zero Content-Length or Transfer-Encoding on a 204/304 means the
671
+ // server may also have sent content inappropriately, which would then be
672
+ // parsed as the next response on this connection. Accept it, but do not
673
+ // reuse the connection. HEAD requests are fine tho.
674
+ if (request.method !== 'HEAD' && (this.contentLength > 0 || this.hasTransferEncoding)) {
675
+ this.shouldKeepAlive = false
676
+ }
677
+ this.contentLength = -1
678
+ }
660
679
 
661
680
  if (this.statusCode >= 200) {
662
- const bodyTimeout = request.bodyTimeout != null
663
- ? request.bodyTimeout
664
- : client[kBodyTimeout]
681
+ const bodyTimeout = request.bodyTimeout != null ? request.bodyTimeout : client[kBodyTimeout]
665
682
  this.setTimeout(bodyTimeout, TIMEOUT_BODY)
666
683
  } else if (this.timeout) {
667
684
  if (this.timeout.refresh) {
@@ -689,10 +706,7 @@ class Parser {
689
706
  const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null
690
707
 
691
708
  if (keepAliveTimeout != null) {
692
- const timeout = Math.min(
693
- keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
694
- client[kKeepAliveMaxTimeout]
695
- )
709
+ const timeout = Math.min(keepAliveTimeout - client[kKeepAliveTimeoutThreshold], client[kKeepAliveMaxTimeout])
696
710
  if (timeout <= 0) {
697
711
  socket[kReset] = true
698
712
  } else {
@@ -789,8 +803,9 @@ class Parser {
789
803
  this.statusText = ''
790
804
  this.bytesRead = 0
791
805
  this.contentLength = -1
806
+ this.hasTransferEncoding = false
792
807
  this.keepAlive = ''
793
- this.connectionKeepAlive = false
808
+ this.connection = ''
794
809
 
795
810
  this.headers = []
796
811
  this.headersSize = 0
@@ -799,7 +814,7 @@ class Parser {
799
814
  return 0
800
815
  }
801
816
 
802
- if (request.method !== 'HEAD' && contentLength !== -1 && bytesRead !== contentLength) {
817
+ if (contentLength !== -1 && bytesRead !== contentLength) {
803
818
  util.destroy(socket, new ResponseContentLengthMismatchError())
804
819
  return -1
805
820
  }
@@ -887,7 +902,9 @@ function connectH1 (client, socket) {
887
902
  socket[kIdleSocketValidation] = 0
888
903
  socket[kIdleSocketValidationTimeout] = null
889
904
  socket[kSocketUsed] = false
890
- socket[kParser] = new Parser(client, socket, llhttpInstance)
905
+ socket[kParser] = typeof esbuildDetection === 'undefined' && (client[kUseMilo] ?? getMiloEnabled())
906
+ ? new H1Parser(client, socket)
907
+ : new Parser(client, socket, llhttpInstance)
891
908
 
892
909
  util.addListener(socket, 'error', onHttpSocketError)
893
910
  util.addListener(socket, 'readable', onHttpSocketReadable)
@@ -948,8 +965,11 @@ function connectH1 (client, socket) {
948
965
  return true
949
966
  }
950
967
 
951
- if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
952
- (util.isStream(request.body) || util.isAsyncIterable(request.body) || util.isFormDataLike(request.body))) {
968
+ if (
969
+ client[kRunning] > 0 &&
970
+ util.bodyLength(request.body) !== 0 &&
971
+ (util.isStream(request.body) || util.isAsyncIterable(request.body) || util.isFormDataLike(request.body))
972
+ ) {
953
973
  // Request with stream or iterator body can error while other requests
954
974
  // are inflight and indirectly error those as well.
955
975
  // Ensure this doesn't happen by waiting for inflight
@@ -968,8 +988,6 @@ function connectH1 (client, socket) {
968
988
  }
969
989
 
970
990
  function onHttpSocketError (err) {
971
- assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
972
-
973
991
  const parser = this[kParser]
974
992
 
975
993
  // On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
@@ -1137,9 +1155,7 @@ function resumeH1 (client) {
1137
1155
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
1138
1156
  if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) {
1139
1157
  const request = client[kQueue][client[kRunningIdx]]
1140
- const headersTimeout = request.headersTimeout != null
1141
- ? request.headersTimeout
1142
- : client[kHeadersTimeout]
1158
+ const headersTimeout = request.headersTimeout != null ? request.headersTimeout : client[kHeadersTimeout]
1143
1159
  socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS)
1144
1160
  }
1145
1161
  }
@@ -1196,14 +1212,13 @@ function writeH1 (client, request) {
1196
1212
  // servers and corrupt connection state. Do not
1197
1213
  // re-use the connection for further requests.
1198
1214
 
1199
- const expectsPayload = (
1215
+ const expectsPayload =
1200
1216
  method === 'PUT' ||
1201
1217
  method === 'POST' ||
1202
1218
  method === 'PATCH' ||
1203
1219
  method === 'QUERY' ||
1204
1220
  method === 'PROPFIND' ||
1205
1221
  method === 'PROPPATCH'
1206
- )
1207
1222
 
1208
1223
  if (util.isFormDataLike(body)) {
1209
1224
  if (!extractBody) {
@@ -1252,7 +1267,12 @@ function writeH1 (client, request) {
1252
1267
 
1253
1268
  // https://github.com/nodejs/undici/issues/2046
1254
1269
  // A user agent may send a Content-Length header with 0 value, this should be allowed.
1255
- if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
1270
+ if (
1271
+ shouldSendContentLength(method) &&
1272
+ contentLength > 0 &&
1273
+ request.contentLength !== null &&
1274
+ request.contentLength !== contentLength
1275
+ ) {
1256
1276
  if (client[kStrictContentLength]) {
1257
1277
  util.errorRequest(client, request, new RequestContentLengthMismatchError())
1258
1278
  return false
@@ -1268,7 +1288,7 @@ function writeH1 (client, request) {
1268
1288
  * @param {Error} [err]
1269
1289
  * @returns {void}
1270
1290
  */
1271
- const abort = (err) => {
1291
+ const abort = err => {
1272
1292
  if (request.aborted || request.completed) {
1273
1293
  return
1274
1294
  }
@@ -1453,14 +1473,9 @@ function writeStream (abort, body, client, request, socket, contentLength, heade
1453
1473
 
1454
1474
  assert(socket.destroyed || (socket[kWriting] && client[kRunning] <= 1))
1455
1475
 
1456
- socket
1457
- .off('drain', onDrain)
1458
- .off('error', onFinished)
1476
+ socket.off('drain', onDrain).off('error', onFinished)
1459
1477
 
1460
- body
1461
- .removeListener('data', onData)
1462
- .removeListener('end', onFinished)
1463
- .removeListener('close', onClose)
1478
+ body.removeListener('data', onData).removeListener('end', onFinished).removeListener('close', onClose)
1464
1479
 
1465
1480
  if (!err) {
1466
1481
  try {
@@ -1479,19 +1494,13 @@ function writeStream (abort, body, client, request, socket, contentLength, heade
1479
1494
  }
1480
1495
  }
1481
1496
 
1482
- body
1483
- .on('data', onData)
1484
- .on('end', onFinished)
1485
- .on('error', onFinished)
1486
- .on('close', onClose)
1497
+ body.on('data', onData).on('end', onFinished).on('error', onFinished).on('close', onClose)
1487
1498
 
1488
1499
  if (body.resume) {
1489
1500
  body.resume()
1490
1501
  }
1491
1502
 
1492
- socket
1493
- .on('drain', onDrain)
1494
- .on('error', onFinished)
1503
+ socket.on('drain', onDrain).on('error', onFinished)
1495
1504
 
1496
1505
  if (body.errorEmitted ?? body.errored) {
1497
1506
  setImmediate(onFinished, body.errored)
@@ -1612,19 +1621,18 @@ async function writeIterable (abort, body, client, request, socket, contentLengt
1612
1621
  }
1613
1622
  }
1614
1623
 
1615
- const waitForDrain = () => new Promise((resolve, reject) => {
1616
- assert(callback === null)
1624
+ const waitForDrain = () =>
1625
+ new Promise((resolve, reject) => {
1626
+ assert(callback === null)
1617
1627
 
1618
- if (socket[kError]) {
1619
- reject(socket[kError])
1620
- } else {
1621
- callback = resolve
1622
- }
1623
- })
1628
+ if (socket[kError]) {
1629
+ reject(socket[kError])
1630
+ } else {
1631
+ callback = resolve
1632
+ }
1633
+ })
1624
1634
 
1625
- socket
1626
- .on('close', onDrain)
1627
- .on('drain', onDrain)
1635
+ socket.on('close', onDrain).on('drain', onDrain)
1628
1636
 
1629
1637
  const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
1630
1638
  try {
@@ -1643,9 +1651,7 @@ async function writeIterable (abort, body, client, request, socket, contentLengt
1643
1651
  } catch (err) {
1644
1652
  writer.destroy(err)
1645
1653
  } finally {
1646
- socket
1647
- .off('close', onDrain)
1648
- .off('drain', onDrain)
1654
+ socket.off('close', onDrain).off('drain', onDrain)
1649
1655
  }
1650
1656
  }
1651
1657
 
@@ -1670,10 +1676,27 @@ class AsyncWriter {
1670
1676
  this.expectsPayload = expectsPayload
1671
1677
  this.header = header
1672
1678
  this.abort = abort
1679
+ this.lengthMismatch = false
1673
1680
 
1674
1681
  socket[kWriting] = true
1675
1682
  }
1676
1683
 
1684
+ /**
1685
+ * The body doesn't match the declared content-length and strictContentLength
1686
+ * is off. Warn once, and mark the socket so it isn't reused: on the wire this
1687
+ * request's body no longer ends where the server expects, so anything sent
1688
+ * after it on the same connection would be misread.
1689
+ * @returns {void}
1690
+ */
1691
+ onLengthMismatch () {
1692
+ this.socket[kReset] = true
1693
+
1694
+ if (!this.lengthMismatch) {
1695
+ this.lengthMismatch = true
1696
+ process.emitWarning(new RequestContentLengthMismatchError())
1697
+ }
1698
+ }
1699
+
1677
1700
  /**
1678
1701
  * @param {string|Uint8Array} chunk
1679
1702
  * @returns
@@ -1689,7 +1712,7 @@ class AsyncWriter {
1689
1712
  return false
1690
1713
  }
1691
1714
 
1692
- const len = chunk instanceof Uint8Array ? chunk.byteLength : Buffer.byteLength(chunk)
1715
+ let len = chunk instanceof Uint8Array ? chunk.byteLength : Buffer.byteLength(chunk)
1693
1716
  if (!len) {
1694
1717
  return true
1695
1718
  }
@@ -1700,7 +1723,17 @@ class AsyncWriter {
1700
1723
  throw new RequestContentLengthMismatchError()
1701
1724
  }
1702
1725
 
1703
- process.emitWarning(new RequestContentLengthMismatchError())
1726
+ this.onLengthMismatch()
1727
+
1728
+ // Never write past the declared content-length. The server treats any
1729
+ // extra bytes as the start of the next request, so a body could inject
1730
+ // a request of its own (request smuggling).
1731
+ const remaining = contentLength - bytesWritten
1732
+ if (remaining === 0) {
1733
+ return true
1734
+ }
1735
+ chunk = (typeof chunk === 'string' ? Buffer.from(chunk) : chunk).subarray(0, remaining)
1736
+ len = remaining
1704
1737
  }
1705
1738
 
1706
1739
  socket.cork()
@@ -1775,9 +1808,12 @@ class AsyncWriter {
1775
1808
  if (contentLength !== null && bytesWritten !== contentLength) {
1776
1809
  if (client[kStrictContentLength]) {
1777
1810
  throw new RequestContentLengthMismatchError()
1778
- } else {
1779
- process.emitWarning(new RequestContentLengthMismatchError())
1780
1811
  }
1812
+
1813
+ // The body is shorter than declared, so the server is still waiting for
1814
+ // the rest. Don't let the next request's bytes on this connection be
1815
+ // read as the missing part of this body.
1816
+ this.onLengthMismatch()
1781
1817
  }
1782
1818
 
1783
1819
  if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
@@ -61,6 +61,12 @@ const kRefusedStreamRetry = Symbol('refused stream retry')
61
61
  // event loop.
62
62
  const MAX_GOAWAY_REPLAY_ATTEMPTS = 1
63
63
 
64
+ // Lower bound on how long a liveness PING may take to be acked. Stream
65
+ // timeouts can be tiny (tens of ms), while an ack on a live connection can take
66
+ // longer than that on a loaded event loop; without a floor a slow but healthy
67
+ // connection would be torn down.
68
+ const MIN_PROBE_TIMEOUT = 1e3
69
+
64
70
  let extractBody
65
71
 
66
72
  /** @type {import('http2')} */
@@ -277,6 +283,9 @@ function connectH2 (client, socket) {
277
283
  // Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
278
284
  // work that cannot start. See setNoStreamsTimeout.
279
285
  noStreamsTimeout: null,
286
+ // Armed while a PING checks whether the peer is still there after a
287
+ // stream timed out. See probeHttp2Session.
288
+ probeTimeout: null,
280
289
  // Sockets start out ref'd. Session ref/unref proxies to the socket, so a
281
290
  // single cached flag lets us skip redundant uv ref/unref calls, provided
282
291
  // every ref/unref of the session or its socket goes through
@@ -361,6 +370,11 @@ function connectH2 (client, socket) {
361
370
  return true
362
371
  }
363
372
 
373
+ // Do not open streams on a connection that may be dead.
374
+ if (session[kHTTP2SessionState].probeTimeout != null) {
375
+ return true
376
+ }
377
+
364
378
  if (client[kRunning] >= client[kMaxConcurrentStreams]) {
365
379
  return true
366
380
  }
@@ -494,6 +508,60 @@ function onNoStreamsTimeout (session) {
494
508
  resetHttp2Session(session, err)
495
509
  }
496
510
 
511
+ // A stream timeout only resets that stream, unlike HTTP/1.1 which destroys the
512
+ // socket. If the connection itself silently died (dropped by a NAT or load
513
+ // balancer, a hung peer), every new stream would time out in turn and the
514
+ // session would never be replaced. Ask the peer for a PING ack within the
515
+ // timeout that just fired (but at least MIN_PROBE_TIMEOUT): if it answers, only
516
+ // that request was slow; if not, drop the session so queued requests move to a
517
+ // fresh connection.
518
+ function probeHttp2Session (session, timeout) {
519
+ const state = session[kHTTP2SessionState]
520
+
521
+ if (state.probeTimeout != null || session.closed || session.destroyed) {
522
+ return
523
+ }
524
+
525
+ try {
526
+ session.ping(onHttp2ProbeAck.bind(session))
527
+ } catch {
528
+ // The session is going away on its own.
529
+ return
530
+ }
531
+
532
+ state.probeTimeout = setTimeout(onHttp2ProbeTimeout, Math.max(timeout, MIN_PROBE_TIMEOUT), session).unref()
533
+ }
534
+
535
+ function clearHttp2ProbeTimeout (session) {
536
+ const state = session[kHTTP2SessionState]
537
+
538
+ if (state?.probeTimeout != null) {
539
+ clearTimeout(state.probeTimeout)
540
+ state.probeTimeout = null
541
+ }
542
+ }
543
+
544
+ function onHttp2ProbeAck () {
545
+ if (this[kHTTP2SessionState].probeTimeout == null) {
546
+ return
547
+ }
548
+
549
+ clearHttp2ProbeTimeout(this)
550
+ this[kClient][kResume]()
551
+ }
552
+
553
+ function onHttp2ProbeTimeout (session) {
554
+ session[kHTTP2SessionState].probeTimeout = null
555
+
556
+ if (session.closed || session.destroyed) {
557
+ return
558
+ }
559
+
560
+ const err = new SocketError('HTTP/2: connection unresponsive', util.getSocketInfo(session[kSocket]))
561
+ session[kError] = err
562
+ resetHttp2Session(session, err)
563
+ }
564
+
497
565
  function clearHttp2IdleTimeout (session) {
498
566
  const state = session[kHTTP2SessionState]
499
567
 
@@ -548,8 +616,14 @@ function applyConnectionWindowSize (connectionWindowSize) {
548
616
  }
549
617
 
550
618
  function onHttp2RemoteSettings (settings) {
551
- // Fallbacks are a safe bet, remote setting will always override
552
- this[kClient][kMaxConcurrentStreams] = settings.maxConcurrentStreams ?? this[kClient][kMaxConcurrentStreams]
619
+ const client = this[kClient]
620
+
621
+ // The configured maxConcurrentStreams (default 100) is the client's own
622
+ // ceiling. The server's SETTINGS_MAX_CONCURRENT_STREAMS can lower it, but
623
+ // must not raise it: a default Node.js server advertises 2^32-1.
624
+ const localMaxConcurrentStreams = client[kHTTP2Options].maxConcurrentStreams
625
+ const remoteMaxConcurrentStreams = settings.maxConcurrentStreams ?? client[kMaxConcurrentStreams] ?? localMaxConcurrentStreams
626
+ client[kMaxConcurrentStreams] = Math.min(remoteMaxConcurrentStreams, localMaxConcurrentStreams)
553
627
  /**
554
628
  * From RFC-8441
555
629
  * A sender MUST NOT send a SETTINGS_ENABLE_CONNECT_PROTOCOL parameter
@@ -594,8 +668,6 @@ function onHttp2SendPing (session) {
594
668
  }
595
669
 
596
670
  function onHttp2SessionError (err) {
597
- assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
598
-
599
671
  this[kSocket][kError] = err
600
672
 
601
673
  if (this[kReceivedGoAway]) {
@@ -676,8 +748,13 @@ function onHttp2SessionGoAway (errorCode, lastStreamID) {
676
748
  client[kHTTP2Session] = null
677
749
  }
678
750
 
751
+ if (this[kOpenStreams] === 0) {
752
+ unrefH2Session(this)
753
+ }
754
+
679
755
  clearHttp2IdleTimeout(this)
680
756
  clearNoStreamsTimeout(this)
757
+ clearHttp2ProbeTimeout(this)
681
758
 
682
759
  if (!this.closed && !this.destroyed) {
683
760
  this.close()
@@ -703,6 +780,7 @@ function onHttp2SessionClose () {
703
780
 
704
781
  clearHttp2IdleTimeout(this)
705
782
  clearNoStreamsTimeout(this)
783
+ clearHttp2ProbeTimeout(this)
706
784
 
707
785
  if (state.ping.interval != null) {
708
786
  clearInterval(state.ping.interval)
@@ -757,8 +835,6 @@ function onHttp2SocketClose () {
757
835
  }
758
836
 
759
837
  function onHttp2SocketError (err) {
760
- assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
761
-
762
838
  this[kError] = err
763
839
 
764
840
  if (this[kHTTP2Session]?.[kReceivedGoAway]) {
@@ -844,25 +920,27 @@ function buildRequestHeaders (reqHeaders) {
844
920
  for (let n = 0; n < reqHeaders.length; n += 2) {
845
921
  const key = reqHeaders[n + 0]
846
922
  const val = reqHeaders[n + 1]
847
- const current = headers[key]
923
+ // Reading headers[key] directly resolves `__proto__` through the prototype
924
+ // chain instead of reporting the header as absent.
925
+ const current = Object.hasOwn(headers, key) ? headers[key] : undefined
848
926
 
849
927
  if (key === 'cookie') {
850
928
  if (current != null) {
851
- headers[key] = Array.isArray(current) ? (current.push(val), current) : [current, val]
929
+ util.setHeader(headers, key, Array.isArray(current) ? (current.push(val), current) : [current, val])
852
930
  } else {
853
- headers[key] = val
931
+ util.setHeader(headers, key, val)
854
932
  }
855
933
 
856
934
  continue
857
935
  }
858
936
 
859
937
  if (typeof val === 'string') {
860
- headers[key] = current ? `${current}, ${val}` : val
938
+ util.setHeader(headers, key, current ? `${current}, ${val}` : val)
861
939
  continue
862
940
  }
863
941
 
864
942
  for (let i = 0; i < val.length; i++) {
865
- headers[key] = headers[key] ? `${headers[key]}, ${val[i]}` : val[i]
943
+ util.setHeader(headers, key, Object.hasOwn(headers, key) ? `${headers[key]}, ${val[i]}` : val[i])
866
944
  }
867
945
  }
868
946
 
@@ -1368,10 +1446,34 @@ function onData (chunk) {
1368
1446
  state.bytesRead += chunk.length
1369
1447
 
1370
1448
  if (request.onResponseData(chunk) === false) {
1371
- stream.pause()
1449
+ pauseResponseStream(stream, state)
1450
+ }
1451
+ }
1452
+
1453
+ // The body timeout measures how long the peer takes to send data. While the
1454
+ // consumer applies backpressure the peer can't send (it's out of flow-control
1455
+ // window), and Http2Stream's timer, which counts stream activity, would fire.
1456
+ // Stop it while paused and start a fresh one on resume, like HTTP/1.1, which
1457
+ // ignores the body timeout while its parser is paused.
1458
+ function pauseResponseStream (stream, state) {
1459
+ stream.pause()
1460
+ if (state.bodyTimeout) {
1461
+ stream.setTimeout(0)
1372
1462
  }
1373
1463
  }
1374
1464
 
1465
+ // Passed to the handler as its resume callback, bound to the stream.
1466
+ function resumeResponseStream () {
1467
+ const stream = this
1468
+ const state = stream[kRequestStreamState]
1469
+
1470
+ if (state != null && state.bodyTimeout && stream.isPaused()) {
1471
+ stream.setTimeout(state.bodyTimeout)
1472
+ }
1473
+
1474
+ stream.resume()
1475
+ }
1476
+
1375
1477
  function onInterimResponse (headers) {
1376
1478
  const stream = this
1377
1479
  const state = stream[kRequestStreamState]
@@ -1446,8 +1548,8 @@ function onResponse (headers) {
1446
1548
  return
1447
1549
  }
1448
1550
 
1449
- if (request.onResponseStart(statusCode, headers, stream.resume.bind(stream), '') === false) {
1450
- stream.pause()
1551
+ if (request.onResponseStart(statusCode, headers, resumeResponseStream.bind(stream), '') === false) {
1552
+ pauseResponseStream(stream, state)
1451
1553
  }
1452
1554
 
1453
1555
  stream.on('data', onData)
@@ -1578,9 +1680,14 @@ function onTimeout () {
1578
1680
  // Remove self so timeout doesn't fire again after we handle it
1579
1681
  stream.off('timeout', onTimeout)
1580
1682
 
1581
- const err = state.responseReceived
1582
- ? new BodyTimeoutError(`HTTP/2: "stream timeout after ${state.bodyTimeout}"`)
1583
- : new HeadersTimeoutError(`HTTP/2: "headers timeout after ${state.headersTimeout}"`)
1683
+ const { responseReceived, session, bodyTimeout, headersTimeout } = state
1684
+ const err = responseReceived
1685
+ ? new BodyTimeoutError(`HTTP/2: "stream timeout after ${bodyTimeout}"`)
1686
+ : new HeadersTimeoutError(`HTTP/2: "headers timeout after ${headersTimeout}"`)
1687
+
1688
+ // Probe before aborting: completing the request resumes the queue, which
1689
+ // must not open new streams until the peer has proven it is alive.
1690
+ probeHttp2Session(session, responseReceived ? bodyTimeout : headersTimeout)
1584
1691
  state.abort(err)
1585
1692
  }
1586
1693