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
@@ -23,11 +23,11 @@ const receipts = new WeakSet();
23
23
  export function isEventWaitYieldReceipt(value) {
24
24
  return typeof value === 'object' && value !== null && receipts.has(value);
25
25
  }
26
- /** Internal composition seam. Never added to the production builtin tool catalog. */
26
+ /** Host composition seam; exposed only with supported sources and valid Goal control. */
27
27
  export function buildEventWaitTool(register) {
28
28
  return {
29
29
  name: EVENT_WAIT_TOOL_NAME,
30
- description: 'Register a supported condition on an authorized resource and end this Turn. Host continues the Goal once a result or timeout is available.',
30
+ description: 'Wait for a background Bash task in this Session and end this Turn. Requires an active Goal and direct tools. Use resource {providerId: "shell_run", connectionId: null, resourceType: "background_task", resourceId: the canonical maka://runtime/background-tasks/... ref}, condition {typeId: "terminal", version: 1, parameters: {}} and an explicit timeoutMs. Host continues the existing Goal when the task becomes terminal or the wait expires. Terminal does not mean command success or Goal achievement: inspect the result with Read. Expiry or cancelling the wait does not stop the task.',
31
31
  parameters: z
32
32
  .object({
33
33
  resource: z
@@ -329,6 +329,27 @@ export function canReplaceHistoryCompactCheckpoint(current, candidate) {
329
329
  (!current.source || sameHistoryCompactSourceCoverage(current.source, candidate.source)));
330
330
  }
331
331
  export function matchHistoryCompactCheckpointPrefix(checkpoint, events) {
332
+ const match = matchHistoryCompactCheckpointPrefixExactly(checkpoint, events);
333
+ if (match.reason === undefined ||
334
+ match.reason === 'invalid_checkpoint' ||
335
+ checkpoint.source?.policyVersion !== 'maka.compactable_runtime_event_projection.v3')
336
+ return match;
337
+ // v3 checkpoints written before #6263 did not count encrypted-only thinking.
338
+ // Locate that sealed boundary by identity, then verify the historical source
339
+ // exactly. Never trim the successor tail using the historical event count.
340
+ const throughIndex = events.findIndex((event) => event.id === checkpoint.coverage.through.runtimeEventId);
341
+ if (throughIndex < 0)
342
+ return match;
343
+ const prefix = events.slice(0, throughIndex + 1);
344
+ const historical = prefix.filter((event) => event.content?.kind !== 'thinking' || event.content.text.length > 0);
345
+ if (historical.length === prefix.length)
346
+ return match;
347
+ const historicalMatch = matchHistoryCompactCheckpointPrefixExactly(checkpoint, historical);
348
+ return historicalMatch.reason === undefined
349
+ ? { ...historicalMatch, successorRuntimeEvents: events.slice(throughIndex + 1) }
350
+ : match;
351
+ }
352
+ function matchHistoryCompactCheckpointPrefixExactly(checkpoint, events) {
332
353
  if (!validateHistoryCompactCheckpointShape(checkpoint)) {
333
354
  return {
334
355
  coveredEventCount: 0,
@@ -542,7 +563,17 @@ function effectiveDigestEvent(event) {
542
563
  }
543
564
  /** True when the event carries model-visible content the compact projection counts. */
544
565
  export function isHistoryCompactContentEvent(event) {
545
- return event.modelVisibility !== 'hidden' && estimateRuntimeEventChars(event) > 0;
566
+ if (event.modelVisibility === 'hidden')
567
+ return false;
568
+ // A Responses reasoning item can carry only encrypted content. Text sizing
569
+ // does not decide whether that payload exists; route admission still runs
570
+ // when the compacted history is materialized for the selected model.
571
+ if (event.content?.kind === 'thinking') {
572
+ const openai = event.content.providerOptions?.openai;
573
+ if (nonEmpty(openai?.itemId) && nonEmpty(openai?.reasoningEncryptedContent))
574
+ return true;
575
+ }
576
+ return estimateRuntimeEventChars(event) > 0;
546
577
  }
547
578
  function validHistoryCompactProviderState(value) {
548
579
  if (!value || typeof value !== 'object')
@@ -180,6 +180,13 @@ export async function planHistoryCompaction(input) {
180
180
  if (!boundary.ok || !hasSafeCoverage)
181
181
  return noSafeSpan();
182
182
  const coveredRuntimeEvents = input.orderedEvents.slice(0, boundary.coveredCount);
183
+ // The live context is reattached after a fold. Summarizing just that
184
+ // metadata and the pinned user anchor cannot free useful history.
185
+ if (phase === 'mid_turn' &&
186
+ !coveredRuntimeEvents.some((event) => event.id !== input.headAnchor?.runtimeEventId &&
187
+ !(event.content?.kind === 'text' && event.content.runtimeContextName !== undefined))) {
188
+ return noSafeSpan();
189
+ }
183
190
  const tailRuntimeEvents = input.orderedEvents.slice(boundary.coveredCount);
184
191
  // One transition view per pass: the same loaded snapshot judges the
185
192
  // previous checkpoint's currency and produces the effective view the
@@ -337,12 +337,13 @@ function claudeThinkingOptions(modelId, level) {
337
337
  * those paths an omitted parameter already means no extended thinking, while
338
338
  * the lowest effort would switch adaptive thinking on. That holds for Claude,
339
339
  * not for every Anthropic Messages route: Kimi's K3 and kimi-for-coding think
340
- * by default when no level is sent.
340
+ * by default when no level is sent. K3 can declare an explicit `none` effort;
341
+ * when it does, the provider builder maps `'off'` to disabled thinking.
341
342
  *
342
- * Everywhere else a dropped `'off'` omits the effort parameter, and the
343
- * provider then runs its default reasoning (medium on GPT-5, GPT-6 and o3,
344
- * dynamic on Gemini 3). So this returns the model's lowest declared level
345
- * instead, which the wire builders send explicitly.
343
+ * When a model declares effort levels but no `none`, a dropped `'off'` omits
344
+ * the effort parameter and the provider runs its default reasoning (medium on
345
+ * GPT-5, GPT-6 and o3, dynamic on Gemini 3). So this returns the model's
346
+ * lowest declared level instead, which the wire builders send explicitly.
346
347
  */
347
348
  export function leastReasoningThinkingLevel(connection, modelId, runtime = resolveModelRuntime(connection, modelId)) {
348
349
  const variants = thinkingVariantsForConnection(connection, modelId);
@@ -376,8 +377,18 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtim
376
377
  }
377
378
  return buildFamilyWire(connection, modelId, level, thinkingOptions, runtime);
378
379
  case 'kimi-coding-plan': {
379
- if (!level || level === 'off' || level === 'on')
380
+ if (!level || level === 'on')
380
381
  return {};
382
+ if (level === 'off') {
383
+ // A refreshed Kimi Code catalog may declare `none`. Omitting the
384
+ // control leaves K3 at its default reasoning level, so send the
385
+ // provider's explicit disabled-thinking wire when that choice exists.
386
+ if (!thinkingOptions?.efforts?.includes('none'))
387
+ return {};
388
+ return runtime.wire === 'openai-chat'
389
+ ? { kimiCodingPlan: { reasoningEffort: 'none' } }
390
+ : { anthropic: { thinking: { type: 'disabled' } } };
391
+ }
381
392
  if (runtime.wire === 'openai-chat') {
382
393
  // The kimiCodingPlan provider-options namespace is the
383
394
  // openai-compatible adapter name; ai-sdk resolves its camelCase
@@ -418,6 +429,15 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtim
418
429
  if (level === 'off' && thinkingOptions?.offBehavior === 'anthropic-thinking-disabled') {
419
430
  reasoning = { thinking: { type: 'disabled' } };
420
431
  }
432
+ else if ((connection.providerType === 'MiniMax' || connection.providerType === 'MiniMax-cn') &&
433
+ (modelId === 'MiniMax-M3.1-Flash' || (modelId === 'MiniMax-M3' && level === 'on'))) {
434
+ reasoning = {
435
+ thinking: { type: 'adaptive' },
436
+ ...(modelId === 'MiniMax-M3.1-Flash'
437
+ ? { effort: level && level !== 'off' && level !== 'on' ? level : 'max' }
438
+ : {}),
439
+ };
440
+ }
421
441
  else if (summarizedThinking) {
422
442
  reasoning = summarizedThinking;
423
443
  }
@@ -550,9 +550,10 @@ function toModelInfo(model) {
550
550
  assertOptionalArray(model.input_modalities, 'model input_modalities');
551
551
  assertOptionalArray(model.output_modalities, 'model output_modalities');
552
552
  assertOptionalArray(model.tags, 'model tags');
553
+ assertOptionalArray(model.supported_features, 'model supported_features');
553
554
  const providers = providerObjectArray(model.providers, 'model providers');
554
555
  const contextWindow = providerTokenLimit(model.context_length) ?? providerTokenLimit(model.context_window);
555
- const maxOutputTokens = providerTokenLimit(model.max_tokens);
556
+ const maxOutputTokens = providerTokenLimit(model.max_output_length) ?? providerTokenLimit(model.max_tokens);
556
557
  const capabilities = {};
557
558
  if (model.input_modalities?.includes('image'))
558
559
  capabilities.vision = true;
@@ -568,6 +569,9 @@ function toModelInfo(model) {
568
569
  capabilities.reasoning = true;
569
570
  if (model.tags?.includes('tool-use'))
570
571
  capabilities.functionCalling = true;
572
+ if (model.supported_features) {
573
+ capabilities.functionCalling = model.supported_features.includes('tools');
574
+ }
571
575
  // `output_modalities` was validated above and then dropped, so a relay that
572
576
  // advertised an image-only model handed back a row indistinguishable from a
573
577
  // chat model's. Declared output that names modalities but not text is the
@@ -593,6 +597,9 @@ function toModelInfo(model) {
593
597
  ...(model.display_name || model.name ? { displayName: model.display_name ?? model.name } : {}),
594
598
  ...(contextWindow === undefined ? {} : { contextWindow }),
595
599
  ...(maxOutputTokens === undefined ? {} : { maxOutputTokens }),
600
+ ...(model.supported_features
601
+ ? { structuredOutput: model.supported_features.includes('structured_outputs') }
602
+ : {}),
596
603
  ...(Object.keys(capabilities).length ? { capabilities } : {}),
597
604
  };
598
605
  }
@@ -611,13 +611,16 @@ export function buildRuntimeEventModelReplayPlan(events, options = {}) {
611
611
  diagnostics.push(diagnostic(event, 'unsupported_content', 'RuntimeEvent content kind is not model-replayable', { kind: event.content.kind }));
612
612
  continue;
613
613
  }
614
- if (event.role === 'system' && !includeSystemEvents) {
614
+ const runtimeContextName = event.role === 'system' && event.author === 'host' && event.content.kind === 'text'
615
+ ? event.content.runtimeContextName
616
+ : undefined;
617
+ if (event.role === 'system' && !includeSystemEvents && runtimeContextName === undefined) {
615
618
  diagnostics.push(diagnostic(event, 'system_runtime_fact_diagnostic_only', 'system RuntimeEvent content is diagnostic-only unless system replay is enabled'));
616
619
  continue;
617
620
  }
618
621
  switch (event.content.kind) {
619
622
  case 'text': {
620
- const role = modelTextRole(event.role);
623
+ const role = runtimeContextName !== undefined ? 'user' : modelTextRole(event.role);
621
624
  if (!role) {
622
625
  diagnostics.push(diagnostic(event, 'unsupported_role', 'text RuntimeEvent role is not model-replayable', {
623
626
  role: event.role,
@@ -636,6 +639,7 @@ export function buildRuntimeEventModelReplayPlan(events, options = {}) {
636
639
  ? buildSteeringEnvelope(formatTextWithInlineRefs(event.content))
637
640
  : formatTextWithInlineRefs(event.content),
638
641
  ...(steeringReplay ? { steering: { eventId: event.id } } : {}),
642
+ ...(runtimeContextName !== undefined ? { runtimeContextName } : {}),
639
643
  ...(event.content.attachments ? { attachments: event.content.attachments } : {}),
640
644
  ...(event.content.providerOptions !== undefined
641
645
  ? {
@@ -807,7 +811,13 @@ export function buildRuntimeEventModelReplayPlan(events, options = {}) {
807
811
  content: item.content,
808
812
  providerOptions: steeringProviderOptions(item.steering.eventId),
809
813
  }
810
- : { role: item.role, content: item.content });
814
+ : {
815
+ role: item.role,
816
+ content: item.content,
817
+ ...(item.runtimeContextName !== undefined
818
+ ? { providerOptions: runtimeContextProviderOptions(item.runtimeContextName) }
819
+ : {}),
820
+ });
811
821
  return {
812
822
  items,
813
823
  textMessages,
@@ -815,6 +825,9 @@ export function buildRuntimeEventModelReplayPlan(events, options = {}) {
815
825
  hasProviderNativeSemantics: items.some((item) => item.kind !== 'text'),
816
826
  };
817
827
  }
828
+ export function runtimeContextProviderOptions(name) {
829
+ return { makaRuntimeContext: { name } };
830
+ }
818
831
  function modelTextRole(role) {
819
832
  switch (role) {
820
833
  case 'user':
@@ -48,7 +48,10 @@ export function buildOpenAiCodexHistoryCompactor(options) {
48
48
  // Codex: summarize the portable checkpoint plus its tail, without
49
49
  // resurrecting the already-folded source history (#6154).
50
50
  const replayEvents = canContinuePrevious && !isProviderHistoryCompactCheckpoint(previous)
51
- ? projectHistoryCompactCheckpointReplay(previous, input.source.foldedRuntimeEvents.slice(0, previous.coverage.eventCount), events)
51
+ ? projectHistoryCompactCheckpointReplay(previous,
52
+ // The projection finds a mid-turn head anchor by identity. A
53
+ // historical event count can cut it off after reasoning admission.
54
+ input.source.foldedRuntimeEvents, events)
52
55
  : events;
53
56
  const providerReasoningReplayEventIds = compatibleProviderReasoningReplayEventIds(events, input.source.invocations, options.providerStateIdentity, options.modelId, input.runId);
54
57
  const projectedMessages = openAiCodexCompactionMessages(replayEvents, providerReasoningReplayEventIds);
@@ -127,7 +130,9 @@ export function shouldFallbackFromOpenAiCodexHistoryCompaction(error, abortSigna
127
130
  return false;
128
131
  if (!(error instanceof HistoryCompactSummarizerError))
129
132
  return false;
130
- if (error.reason === 'input_too_large' || error.reason === 'invalid_provider_state')
133
+ // Capacity errors must reach the planner's same-route accepted-prefix
134
+ // retry, which preserves native compaction and the uncovered tail.
135
+ if (error.reason === 'invalid_provider_state')
131
136
  return true;
132
137
  if (error.reason !== 'provider_error')
133
138
  return false;
@@ -17,8 +17,10 @@
17
17
  * under the License.
18
18
  */
19
19
  import { randomUUID } from 'node:crypto';
20
+ import { truncateUtf8 } from '@maka/core/diagnostic-log';
20
21
  import { redactSecrets } from '@maka/core/redaction';
21
22
  import { AsyncEventQueue } from './async-queue.js';
23
+ import { MAX_EXECUTOR_COMPLETION_TEXT_BYTES } from './plugin-executor-service.js';
22
24
  /** Converts a small plugin executor contract into Maka's existing Run event stream. */
23
25
  export class PluginExecutorBackend {
24
26
  kind = 'plugin-executor';
@@ -51,7 +53,7 @@ export class PluginExecutorBackend {
51
53
  const queue = new AsyncEventQueue();
52
54
  const messageId = this.#newId();
53
55
  const producer = this.#produce(input, messageId, abort.signal, queue).finally(() => queue.close());
54
- const active = { abort, settled: producer.then(() => undefined) };
56
+ const active = { abort, settled: producer.then(() => undefined), queue };
55
57
  this.#active.add(active);
56
58
  let acknowledged = false;
57
59
  try {
@@ -90,11 +92,22 @@ export class PluginExecutorBackend {
90
92
  this.#active.delete(active);
91
93
  }
92
94
  }
95
+ /**
96
+ * Cancel execution and wait for its queued events to be consumed or the consumer
97
+ * to detach. Keep consuming send() while stopping: awaiting stop() inside that
98
+ * consumer loop prevents progress. Start it without awaiting in the loop, then
99
+ * await it after the loop exits.
100
+ */
93
101
  async stop(reason) {
94
102
  const active = [...this.#active];
95
103
  for (const execution of active)
96
104
  execution.abort.abort(new Error(reason));
97
- await Promise.allSettled(active.map((execution) => execution.settled));
105
+ await Promise.allSettled(active.map(async (execution) => {
106
+ await execution.settled;
107
+ // Runtime may seal the ledger when stop returns. Provider settlement
108
+ // alone does not mean its queued final updates have been persisted.
109
+ await execution.queue.waitUntilConsumedThroughCurrent();
110
+ }));
98
111
  }
99
112
  async respondToSandboxBoundary(_response) {
100
113
  throw new Error('Plugin executor does not expose Maka sandbox-boundary requests');
@@ -111,6 +124,9 @@ export class PluginExecutorBackend {
111
124
  async #produce(input, messageId, signal, queue) {
112
125
  const turnId = input.turnId;
113
126
  let thinkingText = '';
127
+ let outputText = '';
128
+ let outputBytes = 0;
129
+ let outputTruncated = false;
114
130
  const toolUseIds = new Map();
115
131
  const toolOutputSequences = new Map();
116
132
  let result;
@@ -140,6 +156,21 @@ export class PluginExecutorBackend {
140
156
  onEvent: (event) => {
141
157
  if (event.type === 'thinking_delta')
142
158
  thinkingText += event.text;
159
+ if (event.type === 'output_delta' && !outputTruncated) {
160
+ // Bound even a single oversized delta before retaining it. Live
161
+ // delivery and the provider's final result remain authoritative.
162
+ const chunk = event.text.slice(0, MAX_EXECUTOR_COMPLETION_TEXT_BYTES + 1);
163
+ outputText += chunk;
164
+ outputBytes += Buffer.byteLength(chunk, 'utf8');
165
+ if (outputBytes > MAX_EXECUTOR_COMPLETION_TEXT_BYTES) {
166
+ // A surrogate pair split across deltas uses fewer bytes joined.
167
+ outputBytes = Buffer.byteLength(outputText, 'utf8');
168
+ if (outputBytes > MAX_EXECUTOR_COMPLETION_TEXT_BYTES) {
169
+ outputText = truncateUtf8(outputText, MAX_EXECUTOR_COMPLETION_TEXT_BYTES, '\n[Response truncated]');
170
+ outputTruncated = true;
171
+ }
172
+ }
173
+ }
143
174
  this.#publishOutputEvent(turnId, messageId, event, toolUseIds, toolOutputSequences, queue);
144
175
  },
145
176
  onPermissionRequest: (request) => this.#requestPermission(input, request, signal, toolUseIds, queue),
@@ -150,6 +181,22 @@ export class PluginExecutorBackend {
150
181
  failure = error;
151
182
  }
152
183
  this.#closeOptionalOutput(turnId, messageId, thinkingText, toolUseIds, queue);
184
+ // Deltas are only live presentation. Close the interrupted text before the
185
+ // terminal event seals the ledger, including updates drained during cancel.
186
+ // Successful results keep their provider-authoritative completion text.
187
+ // Like successful completions, history stores one text block after tool
188
+ // results; it does not preserve the live text/tool interleaving.
189
+ if (outputText && (failed || result?.status !== 'completed')) {
190
+ queue.push({
191
+ type: 'text_complete',
192
+ id: this.#newId(),
193
+ turnId,
194
+ ts: this.#now(),
195
+ messageId,
196
+ text: outputText,
197
+ interrupted: true,
198
+ });
199
+ }
153
200
  if (failed) {
154
201
  if (signal.aborted)
155
202
  this.#publishCancellation(turnId, { status: 'cancelled', source: 'caller' }, queue);
@@ -23,7 +23,7 @@ import { isExecutorId } from '@maka/core/executor-id';
23
23
  import { Service } from './plugin-kernel.js';
24
24
  import { MakaPluginRuntimeError, pluginIdentity, registerPluginContribution, } from './plugin-runtime.js';
25
25
  import { PluginScopeRegistry } from './plugin-scope-registry.js';
26
- const MAX_EXECUTOR_COMPLETION_TEXT_BYTES = 256 * 1024;
26
+ export const MAX_EXECUTOR_COMPLETION_TEXT_BYTES = 256 * 1024;
27
27
  class ExecutorRetiredAbort extends Error {
28
28
  constructor(executorId) {
29
29
  super(`Executor was retired: ${executorId}`);
@@ -127,6 +127,15 @@ export class PluginExecutorService extends Service {
127
127
  ? [...this.registry.visible(scopeSessionId).values()]
128
128
  : [...this.registry.entries('profile')];
129
129
  const selected = entries.filter((entry) => !entry.retired && (!input.executorId || entry.provider.id === input.executorId));
130
+ if (input.listOnly)
131
+ return selected.map(({ provider }) => ({
132
+ id: provider.id,
133
+ displayName: provider.displayName?.trim() || provider.id,
134
+ readiness: 'unavailable',
135
+ models: [],
136
+ supportsAttachments: false,
137
+ supportsModelChange: false,
138
+ }));
130
139
  if (input.executorId && !selected.length)
131
140
  return [
132
141
  {
@@ -170,9 +179,9 @@ export class PluginExecutorService extends Service {
170
179
  }
171
180
  })));
172
181
  }
173
- invalidateCatalog() {
182
+ invalidateCatalog(executorId) {
174
183
  for (const entry of this.registry.entries('profile')) {
175
- if (!entry.retired)
184
+ if (!entry.retired && (!executorId || entry.provider.id === executorId))
176
185
  entry.provider.invalidateCatalog?.();
177
186
  }
178
187
  }
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { runtimeContextProviderOptions } from './model-history.js';
20
+ /** Compare only host-tagged context still present in the effective model history.
21
+ * Compaction may remove a snapshot; in that case the current value is sent again.
22
+ */
23
+ export function changedRuntimeContexts(contexts, messages) {
24
+ const latest = new Map();
25
+ for (const message of messages) {
26
+ const name = message.providerOptions?.makaRuntimeContext?.name;
27
+ if (message.role !== 'user' || typeof name !== 'string')
28
+ continue;
29
+ const text = typeof message.content === 'string'
30
+ ? message.content
31
+ : message.content
32
+ .filter((part) => part.type === 'text')
33
+ .map((part) => part.text)
34
+ .join('');
35
+ latest.set(name, text);
36
+ }
37
+ const changes = [];
38
+ for (const context of contexts) {
39
+ const text = `Runtime context (${context.name}; host metadata, not a user request; later updates supersede earlier values):\n${context.text}`;
40
+ if (latest.get(context.name) === text)
41
+ continue;
42
+ changes.push({ name: context.name, text });
43
+ latest.set(context.name, text);
44
+ }
45
+ return changes;
46
+ }
47
+ export function runtimeContextMessage(context) {
48
+ return {
49
+ role: 'user',
50
+ content: context.text,
51
+ providerOptions: runtimeContextProviderOptions(context.name),
52
+ };
53
+ }
@@ -638,6 +638,9 @@ export function classifyRuntimeEventTerminalFact(invocation, events) {
638
638
  function projectText(event, state, messages) {
639
639
  if (event.content?.kind !== 'text')
640
640
  return false;
641
+ // Claimed by model replay only; internal context has no transcript row.
642
+ if (event.role === 'system' && event.content.runtimeContextName !== undefined)
643
+ return true;
641
644
  if (event.role === 'user') {
642
645
  const message = projectRuntimeEventUserMessage(event, stableMessageId(event, state, 'user'));
643
646
  if (!message)