maka-agent 0.2.2-dev.92.20261019 → 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 (364) hide show
  1. package/LICENSE +7 -7
  2. package/README.md +78 -18
  3. package/README.zh-CN.md +73 -15
  4. package/THIRD_PARTY_NOTICES.txt +12 -12
  5. package/dist/pi-goal.js +13 -0
  6. package/dist/pi-tui-runner.js +44 -1
  7. package/dist/run-command-core.js +111 -70
  8. package/dist/run-session-command.js +91 -15
  9. package/dist/run-turn-outcome.js +2 -33
  10. package/dist/runtime-host-session-channel.js +3 -1
  11. package/dist/runtime-host-session-driver.js +5 -0
  12. package/dist/tui-copy-catalog.js +24 -0
  13. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  14. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
  15. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
  16. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
  17. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
  18. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  19. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  20. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
  21. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  22. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
  23. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  24. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  25. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
  26. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
  27. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
  28. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
  29. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  30. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  31. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
  32. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
  33. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  34. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  35. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
  36. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
  37. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
  38. package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
  39. package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
  40. package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
  41. package/node_modules/@maka/core/dist/event-wait.js +28 -10
  42. package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
  43. package/node_modules/@maka/core/dist/model-catalog.js +19 -1
  44. package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
  45. package/node_modules/@maka/core/dist/model-metadata.js +42 -1
  46. package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
  47. package/node_modules/@maka/core/dist/provider-registry.js +16 -2
  48. package/node_modules/@maka/core/dist/runtime-event.js +8 -0
  49. package/node_modules/@maka/core/dist/session-checkin.js +31 -0
  50. package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
  51. package/node_modules/@maka/core/package.json +2 -0
  52. package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
  53. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  54. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
  55. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  56. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
  57. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  58. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  59. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  60. package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
  61. package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
  62. package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  63. package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  64. package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
  65. package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
  66. package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
  67. package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
  68. package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
  69. package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
  70. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
  71. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  72. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  73. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
  74. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  75. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  76. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  77. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  78. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
  79. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  80. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  81. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  82. package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
  83. package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  84. package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  85. package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
  86. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
  87. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
  88. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
  89. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
  90. package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
  91. package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
  92. package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
  93. package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
  94. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  95. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  96. package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
  97. package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
  98. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  99. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  100. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
  101. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  102. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
  103. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
  104. package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  105. package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  106. package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
  107. package/node_modules/@maka/mcp/package.json +1 -1
  108. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +22 -9
  109. package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
  110. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +101 -127
  111. package/node_modules/@maka/runtime/dist/event-wait-tool.js +2 -2
  112. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +32 -1
  113. package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
  114. package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
  115. package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
  116. package/node_modules/@maka/runtime/dist/model-history.js +16 -3
  117. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +7 -2
  118. package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
  119. package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
  120. package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
  121. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
  122. package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
  123. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
  124. package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
  125. package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
  126. package/node_modules/@maka/runtime/dist/tool-runtime.js +8 -0
  127. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
  128. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
  129. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
  130. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
  131. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
  132. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  133. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  134. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
  135. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  136. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
  137. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  138. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  139. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
  140. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
  141. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
  142. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
  143. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  144. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  145. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
  146. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
  147. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  148. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  149. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
  150. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
  151. package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
  152. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  153. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
  154. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  155. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
  156. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  157. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  158. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  159. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
  160. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
  161. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  162. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  163. package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
  164. package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
  165. package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
  166. package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
  167. package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
  168. package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
  169. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
  170. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  171. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  172. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
  173. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  174. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  175. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  176. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  177. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
  178. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  179. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  180. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  181. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
  182. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  183. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  184. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
  185. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
  186. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
  187. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
  188. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
  189. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
  190. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
  191. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
  192. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
  193. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  194. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  195. package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
  196. package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
  197. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  198. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  199. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
  200. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  201. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
  202. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
  203. package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  204. package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  205. package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
  206. package/node_modules/@maka/runtime/package.json +2 -0
  207. package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
  208. package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
  209. package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +64 -13
  210. package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
  211. package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
  212. package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
  213. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
  214. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
  215. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
  216. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
  217. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
  218. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
  219. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
  220. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +1 -1
  221. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
  222. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
  223. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
  224. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
  225. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +35 -5
  226. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
  227. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
  228. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
  229. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
  230. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +1 -1
  231. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
  232. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
  233. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +87 -23
  234. package/node_modules/@maka/runtime-host/dist/assistant/service.js +49 -5
  235. package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
  236. package/node_modules/@maka/runtime-host/dist/protocol/index.js +7 -1
  237. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
  238. package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
  239. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
  240. package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
  241. package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
  242. package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +63 -12
  243. package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
  244. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +123 -11
  245. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
  246. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +126 -4
  247. package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +58 -19
  248. package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
  249. package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
  250. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
  251. package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
  252. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
  253. package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
  254. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
  255. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
  256. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
  257. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
  258. package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
  259. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
  260. package/node_modules/@maka/storage/dist/execution-stores.js +36 -1
  261. package/node_modules/@maka/storage/dist/local-execution-persistence.js +26 -0
  262. package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
  263. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  264. package/node_modules/@maka/storage/dist/session-bundle-policy.js +86 -16
  265. package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
  266. package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
  267. package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
  268. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
  269. package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
  270. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +31 -0
  271. package/node_modules/@maka/storage/package.json +3 -0
  272. package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
  273. package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
  274. package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
  275. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
  276. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
  277. package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
  278. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
  279. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
  280. package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
  281. package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
  282. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
  283. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
  284. package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
  285. package/node_modules/@modelcontextprotocol/client/package.json +5 -5
  286. package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
  287. package/node_modules/fast-uri/README.md +8 -0
  288. package/node_modules/fast-uri/index.js +98 -18
  289. package/node_modules/fast-uri/lib/utils.js +52 -0
  290. package/node_modules/fast-uri/package.json +1 -1
  291. package/node_modules/follow-redirects/index.js +10 -1
  292. package/node_modules/follow-redirects/package.json +1 -1
  293. package/node_modules/ip-address/README.md +104 -104
  294. package/node_modules/ip-address/dist/ipv4.js +7 -0
  295. package/node_modules/ip-address/dist/ipv6.js +7 -4
  296. package/node_modules/ip-address/dist/v6/constants.js +3 -0
  297. package/node_modules/ip-address/package.json +2 -1
  298. package/node_modules/undici/README.md +25 -3
  299. package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  300. package/node_modules/undici/docs/docs/api/Client.md +11 -6
  301. package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  302. package/node_modules/undici/docs/docs/api/Errors.md +76 -1
  303. package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  304. package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  305. package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  306. package/node_modules/undici/docs/docs/index.md +12 -12
  307. package/node_modules/undici/docs/docs/type-map.json +66 -66
  308. package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  309. package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  310. package/node_modules/undici/lib/core/connect.js +10 -4
  311. package/node_modules/undici/lib/core/constants.js +12 -1
  312. package/node_modules/undici/lib/core/errors.js +38 -1
  313. package/node_modules/undici/lib/core/request.js +16 -1
  314. package/node_modules/undici/lib/core/symbols.js +2 -0
  315. package/node_modules/undici/lib/core/util.js +26 -1
  316. package/node_modules/undici/lib/dispatcher/agent.js +6 -2
  317. package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  318. package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  319. package/node_modules/undici/lib/dispatcher/client.js +4 -1
  320. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  321. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  322. package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  323. package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  324. package/node_modules/undici/lib/dispatcher/pool.js +11 -8
  325. package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  326. package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  327. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  328. package/node_modules/undici/lib/handler/cache-handler.js +153 -15
  329. package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  330. package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  331. package/node_modules/undici/lib/handler/retry-handler.js +44 -11
  332. package/node_modules/undici/lib/interceptor/cache.js +11 -3
  333. package/node_modules/undici/lib/interceptor/decompress.js +22 -9
  334. package/node_modules/undici/lib/interceptor/dns.js +11 -0
  335. package/node_modules/undici/lib/interceptor/response-error.js +72 -28
  336. package/node_modules/undici/lib/milo/LICENSE.md +7 -0
  337. package/node_modules/undici/lib/milo/no-simd.js +1002 -0
  338. package/node_modules/undici/lib/milo/simd.js +1002 -0
  339. package/node_modules/undici/lib/mock/mock-agent.js +11 -0
  340. package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  341. package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  342. package/node_modules/undici/lib/util/cache.js +11 -5
  343. package/node_modules/undici/lib/web/cookies/util.js +19 -2
  344. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  345. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  346. package/node_modules/undici/lib/web/fetch/body.js +47 -38
  347. package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  348. package/node_modules/undici/lib/web/fetch/headers.js +2 -2
  349. package/node_modules/undici/lib/web/fetch/index.js +8 -4
  350. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  351. package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  352. package/node_modules/undici/package.json +9 -7
  353. package/node_modules/zod/package.json +1 -1
  354. package/node_modules/zod/v4/core/compile.cjs +8 -0
  355. package/node_modules/zod/v4/core/compile.js +8 -0
  356. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  357. package/node_modules/zod/v4/core/schemas.js +30 -0
  358. package/node_modules/zod/v4/core/util.cjs +15 -0
  359. package/node_modules/zod/v4/core/util.js +14 -0
  360. package/node_modules/zod/v4/core/versions.cjs +1 -1
  361. package/node_modules/zod/v4/core/versions.js +1 -1
  362. package/package.json +2 -2
  363. package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
  364. package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
@@ -92,220 +92,221 @@ function parseSetCookie (header) {
92
92
  * @param {Object.<string, unknown>} [cookieAttributeList={}]
93
93
  */
94
94
  function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {}) {
95
- // 1. If the unparsed-attributes string is empty, skip the rest of
96
- // these steps.
97
- if (unparsedAttributes.length === 0) {
98
- return cookieAttributeList
99
- }
95
+ while (true) {
96
+ // 1. If the unparsed-attributes string is empty, skip the rest of
97
+ // these steps.
98
+ if (unparsedAttributes.length === 0) {
99
+ return cookieAttributeList
100
+ }
100
101
 
101
- // 2. Discard the first character of the unparsed-attributes (which
102
- // will be a %x3B (";") character).
103
- assert(unparsedAttributes[0] === ';')
104
- unparsedAttributes = unparsedAttributes.slice(1)
102
+ // 2. Discard the first character of the unparsed-attributes (which
103
+ // will be a %x3B (";") character).
104
+ assert(unparsedAttributes[0] === ';')
105
+ unparsedAttributes = unparsedAttributes.slice(1)
105
106
 
106
- let cookieAv = ''
107
+ let cookieAv = ''
107
108
 
108
- // 3. If the remaining unparsed-attributes contains a %x3B (";")
109
- // character:
110
- if (unparsedAttributes.includes(';')) {
109
+ // 3. If the remaining unparsed-attributes contains a %x3B (";")
110
+ // character:
111
+ if (unparsedAttributes.includes(';')) {
111
112
  // 1. Consume the characters of the unparsed-attributes up to, but
112
113
  // not including, the first %x3B (";") character.
113
- cookieAv = collectASequenceOfCodePointsFast(
114
- ';',
115
- unparsedAttributes,
116
- { position: 0 }
117
- )
118
- unparsedAttributes = unparsedAttributes.slice(cookieAv.length)
119
- } else {
114
+ cookieAv = collectASequenceOfCodePointsFast(
115
+ ';',
116
+ unparsedAttributes,
117
+ { position: 0 }
118
+ )
119
+ unparsedAttributes = unparsedAttributes.slice(cookieAv.length)
120
+ } else {
120
121
  // Otherwise:
121
122
 
122
- // 1. Consume the remainder of the unparsed-attributes.
123
- cookieAv = unparsedAttributes
124
- unparsedAttributes = ''
125
- }
123
+ // 1. Consume the remainder of the unparsed-attributes.
124
+ cookieAv = unparsedAttributes
125
+ unparsedAttributes = ''
126
+ }
126
127
 
127
- // Let the cookie-av string be the characters consumed in this step.
128
+ // Let the cookie-av string be the characters consumed in this step.
128
129
 
129
- let attributeName = ''
130
- let attributeValue = ''
130
+ let attributeName = ''
131
+ let attributeValue = ''
131
132
 
132
- // 4. If the cookie-av string contains a %x3D ("=") character:
133
- if (cookieAv.includes('=')) {
133
+ // 4. If the cookie-av string contains a %x3D ("=") character:
134
+ if (cookieAv.includes('=')) {
134
135
  // 1. The (possibly empty) attribute-name string consists of the
135
136
  // characters up to, but not including, the first %x3D ("=")
136
137
  // character, and the (possibly empty) attribute-value string
137
138
  // consists of the characters after the first %x3D ("=")
138
139
  // character.
139
- const position = { position: 0 }
140
-
141
- attributeName = collectASequenceOfCodePointsFast(
142
- '=',
143
- cookieAv,
144
- position
145
- )
146
- attributeValue = cookieAv.slice(position.position + 1)
147
- } else {
140
+ const position = { position: 0 }
141
+
142
+ attributeName = collectASequenceOfCodePointsFast(
143
+ '=',
144
+ cookieAv,
145
+ position
146
+ )
147
+ attributeValue = cookieAv.slice(position.position + 1)
148
+ } else {
148
149
  // Otherwise:
149
150
 
150
- // 1. The attribute-name string consists of the entire cookie-av
151
- // string, and the attribute-value string is empty.
152
- attributeName = cookieAv
153
- }
151
+ // 1. The attribute-name string consists of the entire cookie-av
152
+ // string, and the attribute-value string is empty.
153
+ attributeName = cookieAv
154
+ }
154
155
 
155
- // 5. Remove any leading or trailing WSP characters from the attribute-
156
- // name string and the attribute-value string.
157
- attributeName = attributeName.trim()
158
- attributeValue = attributeValue.trim()
156
+ // 5. Remove any leading or trailing WSP characters from the attribute-
157
+ // name string and the attribute-value string.
158
+ attributeName = attributeName.trim()
159
+ attributeValue = attributeValue.trim()
159
160
 
160
- // 6. If the attribute-value is longer than 1024 octets, ignore the
161
- // cookie-av string and return to Step 1 of this algorithm.
162
- if (attributeValue.length > maxAttributeValueSize) {
163
- return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList)
164
- }
161
+ // 6. If the attribute-value is longer than 1024 octets, ignore the
162
+ // cookie-av string and return to Step 1 of this algorithm.
163
+ if (attributeValue.length > maxAttributeValueSize) {
164
+ continue
165
+ }
165
166
 
166
- // 7. Process the attribute-name and attribute-value according to the
167
- // requirements in the following subsections. (Notice that
168
- // attributes with unrecognized attribute-names are ignored.)
169
- const attributeNameLowercase = attributeName.toLowerCase()
167
+ // 7. Process the attribute-name and attribute-value according to the
168
+ // requirements in the following subsections. (Notice that
169
+ // attributes with unrecognized attribute-names are ignored.)
170
+ const attributeNameLowercase = attributeName.toLowerCase()
170
171
 
171
- // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.1
172
- // If the attribute-name case-insensitively matches the string
173
- // "Expires", the user agent MUST process the cookie-av as follows.
174
- if (attributeNameLowercase === 'expires') {
172
+ // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.1
173
+ // If the attribute-name case-insensitively matches the string
174
+ // "Expires", the user agent MUST process the cookie-av as follows.
175
+ if (attributeNameLowercase === 'expires') {
175
176
  // 1. Let the expiry-time be the result of parsing the attribute-value
176
177
  // as cookie-date (see Section 5.1.1).
177
- const expiryTime = new Date(attributeValue)
178
+ const expiryTime = new Date(attributeValue)
178
179
 
179
- // 2. If the attribute-value failed to parse as a cookie date, ignore
180
- // the cookie-av.
180
+ // 2. If the attribute-value failed to parse as a cookie date, ignore
181
+ // the cookie-av.
181
182
 
182
- cookieAttributeList.expires = expiryTime
183
- } else if (attributeNameLowercase === 'max-age') {
183
+ cookieAttributeList.expires = expiryTime
184
+ } else if (attributeNameLowercase === 'max-age') {
184
185
  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.2
185
186
  // If the attribute-name case-insensitively matches the string "Max-
186
187
  // Age", the user agent MUST process the cookie-av as follows.
187
188
 
188
- // 1. If the first character of the attribute-value is not a DIGIT or a
189
- // "-" character, ignore the cookie-av.
190
- const charCode = attributeValue.charCodeAt(0)
189
+ // 1. If the first character of the attribute-value is not a DIGIT or a
190
+ // "-" character, ignore the cookie-av.
191
+ const charCode = attributeValue.charCodeAt(0)
191
192
 
192
- if ((charCode < 48 || charCode > 57) && attributeValue[0] !== '-') {
193
- return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList)
194
- }
193
+ if ((charCode < 48 || charCode > 57) && attributeValue[0] !== '-') {
194
+ continue
195
+ }
195
196
 
196
- // 2. If the remainder of attribute-value contains a non-DIGIT
197
- // character, ignore the cookie-av.
198
- if (!/^\d+$/.test(attributeValue)) {
199
- return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList)
200
- }
197
+ // 2. If the remainder of attribute-value contains a non-DIGIT
198
+ // character, ignore the cookie-av.
199
+ if (!/^\d+$/.test(attributeValue)) {
200
+ continue
201
+ }
201
202
 
202
- // 3. Let delta-seconds be the attribute-value converted to an integer.
203
- const deltaSeconds = Number(attributeValue)
203
+ // 3. Let delta-seconds be the attribute-value converted to an integer.
204
+ const deltaSeconds = Number(attributeValue)
204
205
 
205
- // 4. Let cookie-age-limit be the maximum age of the cookie (which
206
- // SHOULD be 400 days or less, see Section 4.1.2.2).
206
+ // 4. Let cookie-age-limit be the maximum age of the cookie (which
207
+ // SHOULD be 400 days or less, see Section 4.1.2.2).
207
208
 
208
- // 5. Set delta-seconds to the smaller of its present value and cookie-
209
- // age-limit.
210
- // deltaSeconds = Math.min(deltaSeconds * 1000, maxExpiresMs)
209
+ // 5. Set delta-seconds to the smaller of its present value and cookie-
210
+ // age-limit.
211
+ // deltaSeconds = Math.min(deltaSeconds * 1000, maxExpiresMs)
211
212
 
212
- // 6. If delta-seconds is less than or equal to zero (0), let expiry-
213
- // time be the earliest representable date and time. Otherwise, let
214
- // the expiry-time be the current date and time plus delta-seconds
215
- // seconds.
216
- // const expiryTime = deltaSeconds <= 0 ? Date.now() : Date.now() + deltaSeconds
213
+ // 6. If delta-seconds is less than or equal to zero (0), let expiry-
214
+ // time be the earliest representable date and time. Otherwise, let
215
+ // the expiry-time be the current date and time plus delta-seconds
216
+ // seconds.
217
+ // const expiryTime = deltaSeconds <= 0 ? Date.now() : Date.now() + deltaSeconds
217
218
 
218
- // 7. Append an attribute to the cookie-attribute-list with an
219
- // attribute-name of Max-Age and an attribute-value of expiry-time.
220
- cookieAttributeList.maxAge = deltaSeconds
221
- } else if (attributeNameLowercase === 'domain') {
219
+ // 7. Append an attribute to the cookie-attribute-list with an
220
+ // attribute-name of Max-Age and an attribute-value of expiry-time.
221
+ cookieAttributeList.maxAge = deltaSeconds
222
+ } else if (attributeNameLowercase === 'domain') {
222
223
  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.3
223
224
  // If the attribute-name case-insensitively matches the string "Domain",
224
225
  // the user agent MUST process the cookie-av as follows.
225
226
 
226
- // 1. Let cookie-domain be the attribute-value.
227
- let cookieDomain = attributeValue
227
+ // 1. Let cookie-domain be the attribute-value.
228
+ let cookieDomain = attributeValue
228
229
 
229
- // 2. If cookie-domain starts with %x2E ("."), let cookie-domain be
230
- // cookie-domain without its leading %x2E (".").
231
- if (cookieDomain[0] === '.') {
232
- cookieDomain = cookieDomain.slice(1)
233
- }
230
+ // 2. If cookie-domain starts with %x2E ("."), let cookie-domain be
231
+ // cookie-domain without its leading %x2E (".").
232
+ if (cookieDomain[0] === '.') {
233
+ cookieDomain = cookieDomain.slice(1)
234
+ }
234
235
 
235
- // 3. Convert the cookie-domain to lower case.
236
- cookieDomain = cookieDomain.toLowerCase()
236
+ // 3. Convert the cookie-domain to lower case.
237
+ cookieDomain = cookieDomain.toLowerCase()
237
238
 
238
- // 4. Append an attribute to the cookie-attribute-list with an
239
- // attribute-name of Domain and an attribute-value of cookie-domain.
240
- cookieAttributeList.domain = cookieDomain
241
- } else if (attributeNameLowercase === 'path') {
239
+ // 4. Append an attribute to the cookie-attribute-list with an
240
+ // attribute-name of Domain and an attribute-value of cookie-domain.
241
+ cookieAttributeList.domain = cookieDomain
242
+ } else if (attributeNameLowercase === 'path') {
242
243
  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.4
243
244
  // If the attribute-name case-insensitively matches the string "Path",
244
245
  // the user agent MUST process the cookie-av as follows.
245
246
 
246
- // 1. If the attribute-value is empty or if the first character of the
247
- // attribute-value is not %x2F ("/"):
248
- let cookiePath = ''
249
- if (attributeValue.length === 0 || attributeValue[0] !== '/') {
247
+ // 1. If the attribute-value is empty or if the first character of the
248
+ // attribute-value is not %x2F ("/"):
249
+ let cookiePath = ''
250
+ if (attributeValue.length === 0 || attributeValue[0] !== '/') {
250
251
  // 1. Let cookie-path be the default-path.
251
- cookiePath = '/'
252
- } else {
252
+ cookiePath = '/'
253
+ } else {
253
254
  // Otherwise:
254
255
 
255
- // 1. Let cookie-path be the attribute-value.
256
- cookiePath = attributeValue
257
- }
256
+ // 1. Let cookie-path be the attribute-value.
257
+ cookiePath = attributeValue
258
+ }
258
259
 
259
- // 2. Append an attribute to the cookie-attribute-list with an
260
- // attribute-name of Path and an attribute-value of cookie-path.
261
- cookieAttributeList.path = cookiePath
262
- } else if (attributeNameLowercase === 'secure') {
260
+ // 2. Append an attribute to the cookie-attribute-list with an
261
+ // attribute-name of Path and an attribute-value of cookie-path.
262
+ cookieAttributeList.path = cookiePath
263
+ } else if (attributeNameLowercase === 'secure') {
263
264
  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.5
264
265
  // If the attribute-name case-insensitively matches the string "Secure",
265
266
  // the user agent MUST append an attribute to the cookie-attribute-list
266
267
  // with an attribute-name of Secure and an empty attribute-value.
267
268
 
268
- cookieAttributeList.secure = true
269
- } else if (attributeNameLowercase === 'httponly') {
269
+ cookieAttributeList.secure = true
270
+ } else if (attributeNameLowercase === 'httponly') {
270
271
  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.6
271
272
  // If the attribute-name case-insensitively matches the string
272
273
  // "HttpOnly", the user agent MUST append an attribute to the cookie-
273
274
  // attribute-list with an attribute-name of HttpOnly and an empty
274
275
  // attribute-value.
275
276
 
276
- cookieAttributeList.httpOnly = true
277
- } else if (attributeNameLowercase === 'samesite') {
277
+ cookieAttributeList.httpOnly = true
278
+ } else if (attributeNameLowercase === 'samesite') {
278
279
  // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.7
279
280
  // If the attribute-name case-insensitively matches the string
280
281
  // "SameSite", the user agent MUST process the cookie-av as follows:
281
282
 
282
- const attributeValueLowercase = attributeValue.toLowerCase()
283
+ const attributeValueLowercase = attributeValue.toLowerCase()
283
284
 
284
- // 1. If cookie-av's attribute-value is a case-insensitive match for
285
- // "None", append an attribute to the cookie-attribute-list with an
286
- // attribute-name of "SameSite" and an attribute-value of "None".
287
- if (attributeValueLowercase === 'none') {
288
- cookieAttributeList.sameSite = 'None'
289
- } else if (attributeValueLowercase === 'strict') {
285
+ // 1. If cookie-av's attribute-value is a case-insensitive match for
286
+ // "None", append an attribute to the cookie-attribute-list with an
287
+ // attribute-name of "SameSite" and an attribute-value of "None".
288
+ if (attributeValueLowercase === 'none') {
289
+ cookieAttributeList.sameSite = 'None'
290
+ } else if (attributeValueLowercase === 'strict') {
290
291
  // 2. If cookie-av's attribute-value is a case-insensitive match for
291
292
  // "Strict", append an attribute to the cookie-attribute-list with
292
293
  // an attribute-name of "SameSite" and an attribute-value of
293
294
  // "Strict".
294
- cookieAttributeList.sameSite = 'Strict'
295
- } else if (attributeValueLowercase === 'lax') {
295
+ cookieAttributeList.sameSite = 'Strict'
296
+ } else if (attributeValueLowercase === 'lax') {
296
297
  // 3. If cookie-av's attribute-value is a case-insensitive match for
297
298
  // "Lax", append an attribute to the cookie-attribute-list with an
298
299
  // attribute-name of "SameSite" and an attribute-value of "Lax".
299
- cookieAttributeList.sameSite = 'Lax'
300
- }
301
- } else {
302
- cookieAttributeList.unparsed ??= []
300
+ cookieAttributeList.sameSite = 'Lax'
301
+ }
302
+ } else {
303
+ cookieAttributeList.unparsed ??= []
303
304
 
304
- cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`)
305
- }
305
+ cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`)
306
+ }
306
307
 
307
308
  // 8. Return to Step 1 of this algorithm.
308
- return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList)
309
+ }
309
310
  }
310
311
 
311
312
  module.exports = {
@@ -315,8 +315,27 @@ function stringify (cookie) {
315
315
  out.push(`Path=${cookie.path}`)
316
316
  }
317
317
 
318
- if (cookie.expires && cookie.expires.toString() !== 'Invalid Date') {
319
- out.push(`Expires=${toIMFDate(cookie.expires)}`)
318
+ // A numeric 0 is the Unix epoch, not an absent value -- the same reason the
319
+ // Max-Age check above tests the type rather than truthiness.
320
+ //
321
+ // expires is Date | number, so the "Invalid Date" check only guards the Date
322
+ // form. A number that is not a valid time value (NaN, +/-Infinity, or outside
323
+ // the Date range) would otherwise reach toIMFDate, which splices undefined and
324
+ // NaN into the header value instead of failing.
325
+ if (cookie.expires != null) {
326
+ const expiresMs = cookie.expires instanceof Date
327
+ ? cookie.expires.getTime()
328
+ : cookie.expires
329
+
330
+ // The largest time value a Date can represent, in milliseconds, i.e.
331
+ // 100,000,000 days either side of the epoch (ECMA-262 Date Time Values).
332
+ // Anything within it is safe for toIMFDate to format; anything beyond it
333
+ // produces an invalid Date and must be ignored instead.
334
+ const maxTimeValue = 8640000000000000
335
+
336
+ if (typeof expiresMs === 'number' && Number.isFinite(expiresMs) && Math.abs(expiresMs) <= maxTimeValue) {
337
+ out.push(`Expires=${toIMFDate(cookie.expires)}`)
338
+ }
320
339
  }
321
340
 
322
341
  if (cookie.sameSite) {
@@ -1,4 +1,5 @@
1
1
  'use strict'
2
+ const buffer = require('node:buffer')
2
3
  const { Transform } = require('node:stream')
3
4
  const { isASCIINumber, isValidLastEventId } = require('./util')
4
5
 
@@ -23,11 +24,19 @@ const COLON = 0x3A
23
24
  */
24
25
  const SPACE = 0x20
25
26
 
27
+ const defaultMaxEventSize = buffer.kStringMaxLength
28
+
26
29
  const DATA = Buffer.from('data')
27
30
  const EVENT = Buffer.from('event')
28
31
  const ID = Buffer.from('id')
29
32
  const RETRY = Buffer.from('retry')
30
33
 
34
+ // Each data field creates a string node, and each unconsumed input chunk keeps
35
+ // a Buffer wrapper. The absolute ceiling protects the large default byte limit.
36
+ const minParserItems = 1024
37
+ const maxParserItems = 131072
38
+ const bytesPerParserItem = 128
39
+
31
40
  function isASCIINumberBytes (buffer, start) {
32
41
  if (start >= buffer.length) {
33
42
  return false
@@ -66,6 +75,12 @@ function isFieldName (line, length, field) {
66
75
  return true
67
76
  }
68
77
 
78
+ function createMaxEventSizeExceededError () {
79
+ const error = new Error('EventSource message size exceeded')
80
+ error.aborted = false
81
+ return error
82
+ }
83
+
69
84
  /**
70
85
  * @typedef {object} EventSourceStreamEvent
71
86
  * @type {object}
@@ -114,6 +129,13 @@ class EventSourceStream extends Transform {
114
129
  pos = 0
115
130
  lineChunkIndex = 0
116
131
  linePos = 0
132
+ lineLength = 0
133
+ eventSize = 0
134
+ eventFieldSizes = { data: 0, event: 0, id: 0, retry: 0 }
135
+ dataLineCount = 0
136
+ maxEventSize
137
+ maxDataLines
138
+ maxBufferedChunks
117
139
 
118
140
  event = {
119
141
  data: undefined,
@@ -125,6 +147,7 @@ class EventSourceStream extends Transform {
125
147
  /**
126
148
  * @param {object} options
127
149
  * @param {boolean} [options.readableObjectMode]
150
+ * @param {number} [options.maxEventSize]
128
151
  * @param {eventSourceSettings} [options.eventSourceSettings]
129
152
  * @param {(chunk: any, encoding?: BufferEncoding | undefined) => boolean} [options.push]
130
153
  */
@@ -136,6 +159,12 @@ class EventSourceStream extends Transform {
136
159
  super(options)
137
160
 
138
161
  this.state = options.eventSourceSettings || {}
162
+ this.maxEventSize = options.maxEventSize ?? defaultMaxEventSize
163
+ const parserItemLimit = this.maxEventSize > 0
164
+ ? Math.min(maxParserItems, Math.max(minParserItems, Math.floor(this.maxEventSize / bytesPerParserItem)))
165
+ : 0
166
+ this.maxDataLines = parserItemLimit
167
+ this.maxBufferedChunks = parserItemLimit
139
168
  if (options.push) {
140
169
  this.push = options.push
141
170
  }
@@ -153,6 +182,14 @@ class EventSourceStream extends Transform {
153
182
  return
154
183
  }
155
184
 
185
+ // A leading line ending can immediately release the currently buffered
186
+ // line, even when it uses the final allowed chunk slot.
187
+ if (this.maxEventSize > 0 &&
188
+ this.chunks.length >= this.maxBufferedChunks &&
189
+ chunk[0] !== LF && chunk[0] !== CR) {
190
+ callback(createMaxEventSizeExceededError())
191
+ return
192
+ }
156
193
  this.chunks.push(chunk)
157
194
 
158
195
  // Strip leading byte-order-mark if we opened the stream and started
@@ -231,7 +268,12 @@ class EventSourceStream extends Transform {
231
268
 
232
269
  // In any case, we can process the line as we reached an
233
270
  // end-of-line character
234
- this.parseLine(this.readLine(), this.event)
271
+ try {
272
+ this.parseLine(this.readLine(), this.event)
273
+ } catch (error) {
274
+ callback(error)
275
+ return
276
+ }
235
277
  this.consumeCurrentByte()
236
278
  // A line was processed and this could be the end of the event. We need
237
279
  // to check if the next line is empty to determine if the event is
@@ -240,12 +282,25 @@ class EventSourceStream extends Transform {
240
282
  continue
241
283
  }
242
284
 
285
+ // readLine() is only called after CR or LF. Reject an unfinished line
286
+ // before it can retain an unbounded number of decoded chunks. The seven
287
+ // extra bytes allow the longest field prefix ("event: " or "retry: ").
288
+ if (this.maxEventSize > 0 && ++this.lineLength > this.maxEventSize + 7) {
289
+ callback(createMaxEventSizeExceededError())
290
+ return
291
+ }
243
292
  this.advanceCursor()
244
293
  }
245
294
 
246
295
  callback()
247
296
  }
248
297
 
298
+ _destroy (error, callback) {
299
+ this.chunks.length = 0
300
+ this.clearEvent()
301
+ super._destroy(error, callback)
302
+ }
303
+
249
304
  /**
250
305
  * @param {Buffer} line
251
306
  * @param {EventSourceStreamEvent} event
@@ -282,6 +337,13 @@ class EventSourceStream extends Transform {
282
337
  }
283
338
 
284
339
  if (isFieldName(line, fieldLength, DATA)) {
340
+ if (this.maxEventSize > 0 && this.dataLineCount >= this.maxDataLines) {
341
+ throw createMaxEventSizeExceededError()
342
+ }
343
+ const valueBytes = line.length - valueStart
344
+ const dataSize = this.eventFieldSizes.data + (event.data === undefined ? 0 : 1) + valueBytes
345
+ this.setEventFieldSize('data', dataSize)
346
+
285
347
  const value = line.toString('utf8', valueStart)
286
348
 
287
349
  if (event.data === undefined) {
@@ -289,11 +351,13 @@ class EventSourceStream extends Transform {
289
351
  } else {
290
352
  event.data += `\n${value}`
291
353
  }
354
+ this.dataLineCount++
292
355
  return
293
356
  }
294
357
 
295
358
  if (isFieldName(line, fieldLength, RETRY)) {
296
359
  if (isASCIINumberBytes(line, valueStart)) {
360
+ this.setEventFieldSize('retry', line.length - valueStart)
297
361
  event.retry = line.toString('utf8', valueStart)
298
362
  }
299
363
  return
@@ -301,20 +365,29 @@ class EventSourceStream extends Transform {
301
365
 
302
366
  if (isFieldName(line, fieldLength, ID)) {
303
367
  if (isValidLastEventIdBytes(line, valueStart)) {
368
+ this.setEventFieldSize('id', line.length - valueStart)
304
369
  event.id = line.toString('utf8', valueStart)
305
370
  }
306
371
  return
307
372
  }
308
373
 
309
374
  if (isFieldName(line, fieldLength, EVENT)) {
310
- const value = line.toString('utf8', valueStart)
311
-
312
- if (value.length > 0) {
313
- event.event = value
375
+ if (valueStart < line.length) {
376
+ this.setEventFieldSize('event', line.length - valueStart)
377
+ event.event = line.toString('utf8', valueStart)
314
378
  }
315
379
  }
316
380
  }
317
381
 
382
+ setEventFieldSize (field, size) {
383
+ const eventSize = this.eventSize - this.eventFieldSizes[field] + size
384
+ if (this.maxEventSize > 0 && eventSize > this.maxEventSize) {
385
+ throw createMaxEventSizeExceededError()
386
+ }
387
+ this.eventSize = eventSize
388
+ this.eventFieldSizes[field] = size
389
+ }
390
+
318
391
  /**
319
392
  * @param {EventSourceStreamEvent} event
320
393
  */
@@ -345,6 +418,12 @@ class EventSourceStream extends Transform {
345
418
  this.event.event = undefined
346
419
  this.event.id = undefined
347
420
  this.event.retry = undefined
421
+ this.eventSize = 0
422
+ this.dataLineCount = 0
423
+ this.eventFieldSizes.data = 0
424
+ this.eventFieldSizes.event = 0
425
+ this.eventFieldSizes.id = 0
426
+ this.eventFieldSizes.retry = 0
348
427
  }
349
428
 
350
429
  hasPendingEvent () {
@@ -380,14 +459,16 @@ class EventSourceStream extends Transform {
380
459
  syncLineStartToCursor () {
381
460
  this.lineChunkIndex = this.chunkIndex
382
461
  this.linePos = this.pos
462
+ this.lineLength = 0
383
463
  this.dropConsumedChunks()
384
464
  }
385
465
 
386
466
  dropConsumedChunks () {
387
- while (this.lineChunkIndex > 0) {
388
- this.chunks.shift()
389
- this.lineChunkIndex--
390
- this.chunkIndex--
467
+ if (this.lineChunkIndex > 0) {
468
+ const consumed = this.lineChunkIndex
469
+ this.chunks.splice(0, consumed)
470
+ this.lineChunkIndex = 0
471
+ this.chunkIndex -= consumed
391
472
  }
392
473
 
393
474
  if (this.chunkIndex === this.chunks.length) {
@@ -10,6 +10,7 @@ const { createFastMessageEvent } = require('../websocket/events')
10
10
  const { isNetworkError } = require('../fetch/response')
11
11
  const { kEnumerableProperty } = require('../../core/util')
12
12
  const { environmentSettingsObject } = require('../fetch/util')
13
+ const { getGlobalDispatcher } = require('../../global')
13
14
 
14
15
  let experimentalWarned = false
15
16
 
@@ -292,6 +293,7 @@ class EventSource extends EventTarget {
292
293
 
293
294
  const eventSourceStream = new EventSourceStream({
294
295
  eventSourceSettings: this.#state,
296
+ maxEventSize: this.#dispatcher.eventSourceOptions?.maxEventSize,
295
297
  push: (event) => {
296
298
  this.dispatchEvent(createFastMessageEvent(
297
299
  event.type,
@@ -476,7 +478,8 @@ webidl.converters.EventSourceInitDict = webidl.dictionaryConverter([
476
478
  },
477
479
  {
478
480
  key: 'dispatcher', // undici only
479
- converter: webidl.converters.any
481
+ converter: webidl.converters.any,
482
+ defaultValue: () => getGlobalDispatcher()
480
483
  },
481
484
  {
482
485
  key: 'node', // undici only
@@ -2215,8 +2215,6 @@ async function httpNetworkFetch (
2215
2215
  }
2216
2216
  const location = headersList.get('location', true)
2217
2217
 
2218
- this.body = new Readable({ read: resume })
2219
-
2220
2218
  const willFollow = location && request.redirect === 'follow' &&
2221
2219
  redirectStatusSet.has(status)
2222
2220
 
@@ -2234,7 +2232,7 @@ async function httpNetworkFetch (
2234
2232
  // CVE fix similar to urllib3 (GHSA-gm62-xv2j-4w53) and curl (CVE-2022-32206).
2235
2233
  const maxContentEncodings = 5
2236
2234
  if (codings.length > maxContentEncodings) {
2237
- reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`))
2235
+ this.abort(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`))
2238
2236
  return true
2239
2237
  }
2240
2238
 
@@ -2272,6 +2270,8 @@ async function httpNetworkFetch (
2272
2270
  }
2273
2271
  }
2274
2272
 
2273
+ this.body = new Readable({ read: resume })
2274
+
2275
2275
  const onError = this.onError.bind(this)
2276
2276
 
2277
2277
  resolve({