maka-agent 0.2.1-dev.91.20261018 → 0.2.2-dev.97.20261024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER-WIP +1 -1
- package/LICENSE +15 -11
- package/README.md +173 -1
- package/README.zh-CN.md +156 -0
- package/THIRD_PARTY_NOTICES.txt +12 -12
- package/dist/cli-core.js +1 -0
- package/dist/pi-goal.js +13 -0
- package/dist/pi-tui-runner.js +44 -1
- package/dist/run-command-core.js +256 -48
- package/dist/run-session-command.js +534 -0
- package/dist/run-session-result.js +38 -0
- package/dist/run-turn-outcome.js +174 -0
- package/dist/runtime-host-cli.js +32 -17
- package/dist/runtime-host-run-command.js +53 -165
- package/dist/runtime-host-run-mcp.js +3 -0
- package/dist/runtime-host-session-channel.js +3 -1
- package/dist/runtime-host-session-driver.js +5 -0
- package/dist/runtime-host-setup-command.js +114 -7
- package/dist/tui-copy-catalog.js +24 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
- package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
- package/node_modules/@maka/core/dist/bot-chat-settings.js +10 -1
- package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
- package/node_modules/@maka/core/dist/event-wait.js +75 -10
- package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
- package/node_modules/@maka/core/dist/goal.js +54 -2
- package/node_modules/@maka/core/dist/model-catalog.js +19 -1
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
- package/node_modules/@maka/core/dist/model-metadata.js +42 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
- package/node_modules/@maka/core/dist/provider-registry.js +16 -2
- package/node_modules/@maka/core/dist/runtime-event-store.js +0 -1
- package/node_modules/@maka/core/dist/runtime-event.js +24 -2
- package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
- package/node_modules/@maka/core/dist/session-checkin.js +31 -0
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
- package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
- package/node_modules/@maka/core/dist/turn-origin.js +14 -2
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +3 -0
- package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/mcp/package.json +1 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +5 -1
- package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +29 -15
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +125 -131
- package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
- package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
- package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
- package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
- package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +34 -4
- package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
- package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
- package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
- package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
- package/node_modules/@maka/runtime/dist/model-history.js +16 -3
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +15 -5
- package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +2 -0
- package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
- package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
- package/node_modules/@maka/runtime/dist/sandbox-boundary-path.js +79 -2
- package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +5 -1
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
- package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
- package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
- package/node_modules/@maka/runtime/dist/tool-runtime.js +11 -2
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/runtime/package.json +3 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +92 -22
- package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +203 -71
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +21 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +37 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +68 -14
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +93 -23
- package/node_modules/@maka/runtime-host/dist/assistant/service.js +72 -16
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
- package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
- package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -3
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
- package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-settings-tools.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +151 -20
- package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +127 -11
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +343 -53
- package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +457 -0
- package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
- package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
- package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
- package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +8 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
- package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
- package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
- package/node_modules/@maka/storage/dist/agent-run-store-contract.js +14 -3
- package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
- package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
- package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +39 -1
- package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
- package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
- package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +27 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
- package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +116 -16
- package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
- package/node_modules/@maka/storage/dist/session-store.js +37 -8
- package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
- package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
- package/node_modules/@maka/storage/dist/sqlite-event-wait-authority.js +81 -8
- package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
- package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +38 -162
- package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
- package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
- package/node_modules/@maka/storage/package.json +4 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
- package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/package.json +5 -5
- package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
- package/node_modules/fast-uri/README.md +8 -0
- package/node_modules/fast-uri/index.js +98 -18
- package/node_modules/fast-uri/lib/utils.js +52 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/ip-address/README.md +104 -104
- package/node_modules/ip-address/dist/ipv4.js +7 -0
- package/node_modules/ip-address/dist/ipv6.js +7 -4
- package/node_modules/ip-address/dist/v6/constants.js +3 -0
- package/node_modules/ip-address/package.json +2 -1
- package/node_modules/undici/README.md +25 -3
- package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/undici/package.json +9 -7
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
/**
|
|
20
|
+
* One AI SDK turn: request projection, provider steps, retries, tool
|
|
21
|
+
* settlement, steering, terminal events, and per-turn cleanup. Session-level
|
|
22
|
+
* construction and cross-turn routing remain in AiSdkBackend.
|
|
23
|
+
*/
|
|
24
|
+
import { EVENT_WAIT_TOOL_NAME, isEventWaitYieldReceipt } from './event-wait-tool.js';
|
|
19
25
|
import { DEFAULT_TOOL_MODE, isToolMode } from '@maka/core/tool-mode';
|
|
20
26
|
import { resolveEffectiveOrchestration, } from '@maka/core/orchestration';
|
|
21
27
|
import { stripUndefinedDeep } from '@maka/core/tool-args-identity';
|
|
@@ -39,6 +45,7 @@ import { portableApplyPatchTool } from './apply-patch-profile.js';
|
|
|
39
45
|
import { RunTrace } from './run-trace.js';
|
|
40
46
|
import { REQUEST_SANDBOX_BOUNDARY_TOOL_NAME, SANDBOX_BOUNDARY_DENIED_FOR_TURN, SANDBOX_BOUNDARY_FINALIZATION_PROMPT, requiredSandboxBoundaryToolNames, } from './sandbox-boundary-tool.js';
|
|
41
47
|
import { buildRuntimeEventModelReplayPlan, appendPriorUnknownToolResponses, buildSteeringEnvelope, collectToolActivityTurnIds, compatibleProviderReasoningReplayEventIds, formatTextWithInlineRefs, inspectPriorUnknownToolOutcomes, steeringMessagesMissingFromBase, steeringModelMessage, } from './model-history.js';
|
|
48
|
+
import { changedRuntimeContexts } from './runtime-context.js';
|
|
42
49
|
import { toolSchemaCharsForDiagnostics, requestCompositionToolSchemas, stableHash, toolCatalogHash, } from './request-shape.js';
|
|
43
50
|
import { toolAvailabilityHash } from './tool-availability.js';
|
|
44
51
|
import { hasFinalizedReasoning } from './ai-sdk-message-projection.js';
|
|
@@ -383,8 +390,8 @@ export class AiSdkTurn {
|
|
|
383
390
|
abortController = new AbortController();
|
|
384
391
|
activeTools;
|
|
385
392
|
aborted = false;
|
|
386
|
-
|
|
387
|
-
|
|
393
|
+
stopRequested = false;
|
|
394
|
+
turnYield;
|
|
388
395
|
handoffPaused = false;
|
|
389
396
|
watchdog = null;
|
|
390
397
|
runTrace = null;
|
|
@@ -424,8 +431,8 @@ export class AiSdkTurn {
|
|
|
424
431
|
await this.toolRuntime.endTurn(this.aborted ? 'aborted' : 'completed');
|
|
425
432
|
}
|
|
426
433
|
requestStop(reason, mode) {
|
|
434
|
+
this.stopRequested = true;
|
|
427
435
|
if (mode === 'after_step') {
|
|
428
|
-
this.loopStopRequested = true;
|
|
429
436
|
this.runTrace?.abortRequested(reason);
|
|
430
437
|
return;
|
|
431
438
|
}
|
|
@@ -433,6 +440,9 @@ export class AiSdkTurn {
|
|
|
433
440
|
this.abortController.abort();
|
|
434
441
|
this.runTrace?.abortRequested(reason);
|
|
435
442
|
}
|
|
443
|
+
get loopStopReason() {
|
|
444
|
+
return this.stopRequested ? 'user_stop' : this.turnYield;
|
|
445
|
+
}
|
|
436
446
|
async endAbortedTools() {
|
|
437
447
|
await this.toolRuntime.endTurn('aborted');
|
|
438
448
|
}
|
|
@@ -1086,6 +1096,24 @@ export class AiSdkTurn {
|
|
|
1086
1096
|
? currentTurnMessages
|
|
1087
1097
|
: [...priorReplay.messages, ...currentTurnMessages];
|
|
1088
1098
|
};
|
|
1099
|
+
const appendRuntimeContexts = async (history, contexts) => {
|
|
1100
|
+
const additions = changedRuntimeContexts(contexts, history).map((context) => ({
|
|
1101
|
+
context,
|
|
1102
|
+
id: this.deps.newId(),
|
|
1103
|
+
}));
|
|
1104
|
+
for (const { context, id } of additions) {
|
|
1105
|
+
queue.push({ type: 'runtime_context', id, turnId, ts: this.deps.now(), ...context });
|
|
1106
|
+
}
|
|
1107
|
+
if (additions.length === 0)
|
|
1108
|
+
return history;
|
|
1109
|
+
// Persist before dispatch; retries reuse the same snapshot. Context
|
|
1110
|
+
// removed by compaction is refreshed after that fold, not lost in it.
|
|
1111
|
+
await queue.waitUntilConsumedThroughCurrent();
|
|
1112
|
+
return [
|
|
1113
|
+
...history,
|
|
1114
|
+
...additions.map(({ context, id }) => this.deps.messageProjection.materializeRuntimeContext(context, id)),
|
|
1115
|
+
];
|
|
1116
|
+
};
|
|
1089
1117
|
// Tool Availability describes the provider-visible (active) subset. A
|
|
1090
1118
|
// group loaded this turn expands that subset on later requests, so the
|
|
1091
1119
|
// terminal trace is refined against the final active set below.
|
|
@@ -1120,7 +1148,7 @@ export class AiSdkTurn {
|
|
|
1120
1148
|
let finishFeedback;
|
|
1121
1149
|
let result;
|
|
1122
1150
|
let providerOutcome;
|
|
1123
|
-
let
|
|
1151
|
+
let terminalStopReason;
|
|
1124
1152
|
let terminalProviderError;
|
|
1125
1153
|
agentLoop: for (;;) {
|
|
1126
1154
|
({ plan, providerTools, modelTools, nestedTools } = snapshotStepTools());
|
|
@@ -1182,7 +1210,6 @@ export class AiSdkTurn {
|
|
|
1182
1210
|
activeTools,
|
|
1183
1211
|
};
|
|
1184
1212
|
};
|
|
1185
|
-
const dynamicContextMessages = (resolvedSystemPrompt.contexts ?? []).map(({ text }) => ({ role: 'user', content: text }));
|
|
1186
1213
|
const shaped = requestProjection
|
|
1187
1214
|
? await requestProjection({
|
|
1188
1215
|
completedSteps: completedProviderSteps,
|
|
@@ -1214,9 +1241,10 @@ export class AiSdkTurn {
|
|
|
1214
1241
|
})
|
|
1215
1242
|
: undefined;
|
|
1216
1243
|
providerRequestTracker?.setStep(runtimeSteps, requestCompositionId);
|
|
1217
|
-
let attemptMessages = projectedMessages;
|
|
1244
|
+
let attemptMessages = await appendRuntimeContexts(projectedMessages, resolvedSystemPrompt.contexts ?? []);
|
|
1218
1245
|
let overflowRecoveryMaxOutputTokens;
|
|
1219
1246
|
let providerAttempt = 0;
|
|
1247
|
+
let pendingRetryReason;
|
|
1220
1248
|
const returnedToolCalls = [];
|
|
1221
1249
|
const providerToolInputs = new Map();
|
|
1222
1250
|
let providerStepUsage;
|
|
@@ -1237,8 +1265,7 @@ export class AiSdkTurn {
|
|
|
1237
1265
|
let attemptSawReplayBarrier = false;
|
|
1238
1266
|
const attemptHasNoObservableOutput = () => !attemptSawVisibleContent && !attemptSawToolActivity && !attemptSawReplayBarrier;
|
|
1239
1267
|
const attemptCanReplay = () => !attemptSawToolActivity && !attemptSawReplayBarrier;
|
|
1240
|
-
|
|
1241
|
-
const dispatchMessages = [...attemptMessages, ...dynamicContextMessages];
|
|
1268
|
+
const dispatchMessages = attemptMessages;
|
|
1242
1269
|
this.memorySourceMessages = dispatchMessages;
|
|
1243
1270
|
this.memorySourceEventMessagePositions =
|
|
1244
1271
|
this.deps.messageProjection.memoryEventMessagePositions(dispatchMessages);
|
|
@@ -1261,6 +1288,24 @@ export class AiSdkTurn {
|
|
|
1261
1288
|
// rebuilt in place by overflow recovery, and the boundary it folded
|
|
1262
1289
|
// under must travel with that rebuild, not with the step.
|
|
1263
1290
|
const historyCompactBoundary = requestHistoryCompactBoundary();
|
|
1291
|
+
// Stop can arrive during handoff, retry backoff, or overflow recovery.
|
|
1292
|
+
if (this.loopStopReason) {
|
|
1293
|
+
terminalStopReason = this.loopStopReason;
|
|
1294
|
+
break agentLoop;
|
|
1295
|
+
}
|
|
1296
|
+
if (pendingRetryReason) {
|
|
1297
|
+
queue.push({
|
|
1298
|
+
type: 'provider_retry',
|
|
1299
|
+
id: this.deps.newId(),
|
|
1300
|
+
turnId,
|
|
1301
|
+
ts: this.deps.now(),
|
|
1302
|
+
phase: 'started',
|
|
1303
|
+
attempt: providerAttempt,
|
|
1304
|
+
maxAttempts: MAX_PROVIDER_ATTEMPTS_PER_STEP,
|
|
1305
|
+
reason: pendingRetryReason,
|
|
1306
|
+
});
|
|
1307
|
+
pendingRetryReason = undefined;
|
|
1308
|
+
}
|
|
1264
1309
|
result = await this.deps.modelAdapter.startStream({
|
|
1265
1310
|
model,
|
|
1266
1311
|
messages: dispatchMessages,
|
|
@@ -1590,7 +1635,7 @@ export class AiSdkTurn {
|
|
|
1590
1635
|
!attemptSawToolInput &&
|
|
1591
1636
|
returnedToolCalls.length === 0))
|
|
1592
1637
|
sawUnusableStepUsage = true;
|
|
1593
|
-
if (this.
|
|
1638
|
+
if (this.loopStopReason) {
|
|
1594
1639
|
terminalProviderError = failure;
|
|
1595
1640
|
terminalProviderErrorReason =
|
|
1596
1641
|
lastCompletedStepHadToolResult && failure.kind === 'timeout'
|
|
@@ -1627,7 +1672,7 @@ export class AiSdkTurn {
|
|
|
1627
1672
|
})
|
|
1628
1673
|
: undefined;
|
|
1629
1674
|
if (recovered) {
|
|
1630
|
-
attemptMessages = recovered.messages;
|
|
1675
|
+
attemptMessages = await appendRuntimeContexts(recovered.messages, resolvedSystemPrompt.contexts ?? []);
|
|
1631
1676
|
overflowRecoveryMaxOutputTokens = Math.min(this.deps.modelAdapter.maxOutputTokens() ?? CONTEXT_RECOVERY_MAX_OUTPUT_TOKENS, CONTEXT_RECOVERY_MAX_OUTPUT_TOKENS);
|
|
1632
1677
|
continue;
|
|
1633
1678
|
}
|
|
@@ -1710,16 +1755,7 @@ export class AiSdkTurn {
|
|
|
1710
1755
|
reason,
|
|
1711
1756
|
});
|
|
1712
1757
|
await this.deps.providerRetrySleep(delayMs, turnAbortController.signal);
|
|
1713
|
-
|
|
1714
|
-
type: 'provider_retry',
|
|
1715
|
-
id: this.deps.newId(),
|
|
1716
|
-
turnId,
|
|
1717
|
-
ts: this.deps.now(),
|
|
1718
|
-
phase: 'started',
|
|
1719
|
-
attempt: nextAttempt,
|
|
1720
|
-
maxAttempts,
|
|
1721
|
-
reason,
|
|
1722
|
-
});
|
|
1758
|
+
pendingRetryReason = reason;
|
|
1723
1759
|
continue;
|
|
1724
1760
|
}
|
|
1725
1761
|
// Unrecoverable (not context-length, this step's attempt spent,
|
|
@@ -1746,7 +1782,7 @@ export class AiSdkTurn {
|
|
|
1746
1782
|
const providerStepId = currentStepMessageId;
|
|
1747
1783
|
if (providerOutcome.kind !== 'completed')
|
|
1748
1784
|
throw providerOutcome.failure;
|
|
1749
|
-
finishReason = providerOutcome.finishReason;
|
|
1785
|
+
const finishReason = providerOutcome.finishReason;
|
|
1750
1786
|
await queue.waitUntilConsumedThroughCurrent();
|
|
1751
1787
|
let toolRequestedFinish = false;
|
|
1752
1788
|
if (returnedToolCalls.length > 0) {
|
|
@@ -1761,6 +1797,12 @@ export class AiSdkTurn {
|
|
|
1761
1797
|
await loadDurableTurnEvents();
|
|
1762
1798
|
}
|
|
1763
1799
|
const toolsByName = new Map(providerTools.map((tool) => [tool.name, tool]));
|
|
1800
|
+
// A wait controls the lifetime of the whole Turn. Refuse the entire
|
|
1801
|
+
// mixed step before dispatch, rather than letting the first call win
|
|
1802
|
+
// the ordinary exclusive-step gate and leaving a registered orphan.
|
|
1803
|
+
const mixedEventWait = returnedToolCalls.length > 1 &&
|
|
1804
|
+
toolsByName.has(EVENT_WAIT_TOOL_NAME) &&
|
|
1805
|
+
returnedToolCalls.some((call) => call.toolName === EVENT_WAIT_TOOL_NAME);
|
|
1764
1806
|
const settlementOutcomes = await Promise.allSettled(returnedToolCalls.map(async (toolCall) => {
|
|
1765
1807
|
if (toolCall.providerExecuted) {
|
|
1766
1808
|
throw new Error(`Provider-executed tool call "${toolCall.toolName}" is outside the main-agent tool loop`);
|
|
@@ -1771,18 +1813,20 @@ export class AiSdkTurn {
|
|
|
1771
1813
|
if (deniedBoundaryRequest) {
|
|
1772
1814
|
toolRuntime.forceSandboxBoundaryFinalization();
|
|
1773
1815
|
}
|
|
1774
|
-
const blockedToolCall = sandboxBoundaryFinalizationStep || deniedBoundaryRequest;
|
|
1816
|
+
const blockedToolCall = mixedEventWait || sandboxBoundaryFinalizationStep || deniedBoundaryRequest;
|
|
1775
1817
|
const requestedTool = blockedToolCall
|
|
1776
1818
|
? undefined
|
|
1777
1819
|
: toolsByName.get(toolCall.toolName);
|
|
1778
1820
|
const tool = requestedTool ?? toolsByName.get(INVALID_TOOL_NAME);
|
|
1779
1821
|
if (!tool)
|
|
1780
1822
|
throw new Error('Runtime invalid-tool fallback is unavailable');
|
|
1781
|
-
const unavailableError =
|
|
1782
|
-
? '
|
|
1783
|
-
:
|
|
1784
|
-
?
|
|
1785
|
-
:
|
|
1823
|
+
const unavailableError = mixedEventWait
|
|
1824
|
+
? 'WaitForEvent requires a step containing exactly one tool call. No tools in this mixed step ran.'
|
|
1825
|
+
: sandboxBoundaryFinalizationStep
|
|
1826
|
+
? 'Sandbox boundary finalization does not permit tool execution.'
|
|
1827
|
+
: deniedBoundaryRequest
|
|
1828
|
+
? SANDBOX_BOUNDARY_DENIED_FOR_TURN
|
|
1829
|
+
: 'returned tool is unavailable';
|
|
1786
1830
|
return await toolRuntime.settleToolCall({
|
|
1787
1831
|
tool,
|
|
1788
1832
|
turnId,
|
|
@@ -1826,6 +1870,11 @@ export class AiSdkTurn {
|
|
|
1826
1870
|
definition.finishTurnOnSuccess &&
|
|
1827
1871
|
!settlement.providerError)
|
|
1828
1872
|
toolRequestedFinish = true;
|
|
1873
|
+
if (returnedToolCalls.length === 1 &&
|
|
1874
|
+
!settlement.providerError &&
|
|
1875
|
+
isEventWaitYieldReceipt(settlement.result)) {
|
|
1876
|
+
this.turnYield = 'event_wait';
|
|
1877
|
+
}
|
|
1829
1878
|
if (isPlanToolResult(settlement.result)) {
|
|
1830
1879
|
this.handlePlanToolResult(settlement.result, queue);
|
|
1831
1880
|
}
|
|
@@ -1839,9 +1888,7 @@ export class AiSdkTurn {
|
|
|
1839
1888
|
// an entire completed batch across the next provider request.
|
|
1840
1889
|
settlementOutcomes.length = 0;
|
|
1841
1890
|
await queue.waitUntilConsumedThroughCurrent();
|
|
1842
|
-
const continuationWillRun = (maxSteps === undefined || runtimeSteps < maxSteps) &&
|
|
1843
|
-
!this.loopStopRequested &&
|
|
1844
|
-
!this.aborted;
|
|
1891
|
+
const continuationWillRun = (maxSteps === undefined || runtimeSteps < maxSteps) && !this.loopStopReason;
|
|
1845
1892
|
if (continuationWillRun && providerOutcome.continuation === 'pending') {
|
|
1846
1893
|
const persistedProjection = await loadDurableTurnProjection();
|
|
1847
1894
|
const responseMessages = persistedOpenAiResponsesStepMessages(attemptMessages, persistedProjection, returnedToolCalls.map((toolCall) => toolCall.toolCallId));
|
|
@@ -1858,119 +1905,72 @@ export class AiSdkTurn {
|
|
|
1858
1905
|
...(providerStepUsage ? { usage: providerStepUsage } : {}),
|
|
1859
1906
|
});
|
|
1860
1907
|
lastCompletedStepHadToolResult = returnedToolCalls.length > 0;
|
|
1861
|
-
// Finish only after the tool result is durably consumed. The Host can
|
|
1862
|
-
// veto completion (for example, new Inbox input raced with Sleep).
|
|
1863
|
-
if (toolRequestedFinish && !this.aborted && !this.loopStopRequested) {
|
|
1864
|
-
const decision = await this.deps.backend.beforeTurnFinish?.({
|
|
1865
|
-
sessionId: this.deps.backend.sessionId,
|
|
1866
|
-
turnId,
|
|
1867
|
-
signal: turnAbortController.signal,
|
|
1868
|
-
});
|
|
1869
|
-
if (!decision || decision.allow) {
|
|
1870
|
-
finishReason = 'stop';
|
|
1871
|
-
this.deps.modelAdapter.clearContinuation(this.turnId);
|
|
1872
|
-
break agentLoop;
|
|
1873
|
-
}
|
|
1874
|
-
finishFeedback = decision.feedback;
|
|
1875
|
-
}
|
|
1876
1908
|
const stepLimitReached = maxSteps !== undefined && runtimeSteps >= maxSteps;
|
|
1877
1909
|
if (sandboxBoundaryFinalizationStep ||
|
|
1878
1910
|
(stepLimitReached &&
|
|
1879
1911
|
(toolRuntime.shouldFinalizeSandboxBoundary() ||
|
|
1880
1912
|
toolRuntime.hasSandboxBoundaryDenial()))) {
|
|
1881
|
-
this.
|
|
1882
|
-
this.loopStopRequested = true;
|
|
1883
|
-
}
|
|
1884
|
-
const mayTakeAnotherStep = !stepLimitReached && !this.loopStopRequested && !this.aborted;
|
|
1885
|
-
if (returnedToolCalls.length > 0 && mayTakeAnotherStep) {
|
|
1886
|
-
if ((await input.handoffBoundary?.(turnAbortController.signal, maxSteps === undefined ? null : maxSteps - runtimeSteps)) === 'pause') {
|
|
1887
|
-
this.handoffPaused = true;
|
|
1888
|
-
break agentLoop;
|
|
1889
|
-
}
|
|
1890
|
-
if (this.aborted || this.loopStopRequested)
|
|
1891
|
-
break agentLoop;
|
|
1892
|
-
currentStepMessageId = this.deps.newId();
|
|
1893
|
-
continue agentLoop;
|
|
1913
|
+
this.turnYield = 'permission_handoff';
|
|
1894
1914
|
}
|
|
1915
|
+
let finishCandidateReason = returnedToolCalls.length > 0 && !toolRequestedFinish
|
|
1916
|
+
? undefined
|
|
1917
|
+
: toolRequestedFinish
|
|
1918
|
+
? 'end_turn'
|
|
1919
|
+
: this.deps.modelAdapter.mapFinishReason(finishReason);
|
|
1895
1920
|
// Enforce Host prerequisites locally: some providers reject required
|
|
1896
1921
|
// tool_choice in thinking mode. Never silently complete without the
|
|
1897
1922
|
// receipt; replay the draft and per-step reminder for bounded repair.
|
|
1898
1923
|
if (returnedToolCalls.length === 0 &&
|
|
1899
1924
|
resolvedSystemPrompt.requireToolCall &&
|
|
1900
|
-
!this.
|
|
1901
|
-
|
|
1902
|
-
if (!mayTakeAnotherStep ||
|
|
1925
|
+
!this.loopStopReason) {
|
|
1926
|
+
if (stepLimitReached ||
|
|
1903
1927
|
!this.deps.backend.loadTurnRuntimeEvents ||
|
|
1904
1928
|
++missingPrerequisiteAttempts > 2) {
|
|
1905
1929
|
throw new Error('Required turn prerequisite was not recorded; cannot complete this response.');
|
|
1906
1930
|
}
|
|
1907
|
-
|
|
1908
|
-
if ((await input.handoffBoundary?.(turnAbortController.signal, maxSteps === undefined ? null : maxSteps - runtimeSteps)) === 'pause') {
|
|
1909
|
-
this.handoffPaused = true;
|
|
1910
|
-
break agentLoop;
|
|
1911
|
-
}
|
|
1912
|
-
if (this.aborted || this.loopStopRequested)
|
|
1913
|
-
break agentLoop;
|
|
1914
|
-
currentStepMessageId = this.deps.newId();
|
|
1915
|
-
continue agentLoop;
|
|
1931
|
+
finishCandidateReason = undefined;
|
|
1916
1932
|
}
|
|
1917
|
-
//
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
// rather than throwing — the turn still completes and the Host folds
|
|
1924
|
-
// the message into the next Turn, which is today's behaviour.
|
|
1925
|
-
if (mayTakeAnotherStep && this.deps.backend.loadTurnRuntimeEvents) {
|
|
1926
|
-
// Last chance for a steer that landed after this turn's final
|
|
1927
|
-
// tool-call boundary — including the only boundary a tool-free
|
|
1928
|
-
// turn has, which precedes the model's first token. Without it the
|
|
1929
|
-
// message is never pulled at all, and whether Steer works would
|
|
1930
|
-
// depend on the model happening to call a tool afterwards (#3529).
|
|
1931
|
-
// A step-limited turn deliberately skips this: its budget is spent,
|
|
1932
|
-
// and the Host folds the message into the next Turn instead.
|
|
1933
|
+
// The Host carries steering left unconsumed here into the next Turn.
|
|
1934
|
+
if (finishCandidateReason !== undefined &&
|
|
1935
|
+
!toolRequestedFinish &&
|
|
1936
|
+
!stepLimitReached &&
|
|
1937
|
+
!this.loopStopReason &&
|
|
1938
|
+
this.deps.backend.loadTurnRuntimeEvents) {
|
|
1933
1939
|
const injectedBefore = this.injectedSteeringMessages.length;
|
|
1934
1940
|
await this.drainSteeringInto(input, queue);
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
// `mayTakeAnotherStep` is stale by now. Stop wins — the message is
|
|
1938
|
-
// already durable, so the Host folds it into the next Turn.
|
|
1939
|
-
if (this.injectedSteeringMessages.length > injectedBefore &&
|
|
1940
|
-
!this.loopStopRequested &&
|
|
1941
|
-
!this.aborted) {
|
|
1942
|
-
await queue.waitUntilConsumedThroughCurrent();
|
|
1943
|
-
if ((await input.handoffBoundary?.(turnAbortController.signal, maxSteps === undefined ? null : maxSteps - runtimeSteps)) === 'pause') {
|
|
1944
|
-
this.handoffPaused = true;
|
|
1945
|
-
break agentLoop;
|
|
1946
|
-
}
|
|
1947
|
-
if (this.aborted || this.loopStopRequested)
|
|
1948
|
-
break agentLoop;
|
|
1949
|
-
currentStepMessageId = this.deps.newId();
|
|
1950
|
-
continue agentLoop;
|
|
1951
|
-
}
|
|
1941
|
+
if (this.injectedSteeringMessages.length > injectedBefore)
|
|
1942
|
+
finishCandidateReason = undefined;
|
|
1952
1943
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
this.deps.backend.beforeTurnFinish
|
|
1956
|
-
this.deps.backend.loadTurnRuntimeEvents &&
|
|
1957
|
-
this.deps.modelAdapter.mapFinishReason(finishReason) === 'end_turn') {
|
|
1958
|
-
const decision = await this.deps.backend.beforeTurnFinish({
|
|
1944
|
+
// Finishing needs Host approval even when no continuation is possible.
|
|
1945
|
+
if (finishCandidateReason === 'end_turn' && !this.loopStopReason) {
|
|
1946
|
+
const finishDecision = await this.deps.backend.beforeTurnFinish?.({
|
|
1959
1947
|
sessionId: this.deps.backend.sessionId,
|
|
1960
1948
|
turnId,
|
|
1961
1949
|
signal: turnAbortController.signal,
|
|
1962
1950
|
});
|
|
1963
|
-
if (
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
break agentLoop;
|
|
1967
|
-
}
|
|
1968
|
-
finishFeedback = decision.feedback;
|
|
1969
|
-
currentStepMessageId = this.deps.newId();
|
|
1970
|
-
continue agentLoop;
|
|
1951
|
+
if (finishDecision && !finishDecision.allow) {
|
|
1952
|
+
finishFeedback = finishDecision.feedback;
|
|
1953
|
+
finishCandidateReason = undefined;
|
|
1971
1954
|
}
|
|
1955
|
+
else if (toolRequestedFinish) {
|
|
1956
|
+
this.deps.modelAdapter.clearContinuation(this.turnId);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
terminalStopReason =
|
|
1960
|
+
this.loopStopReason ??
|
|
1961
|
+
finishCandidateReason ??
|
|
1962
|
+
(stepLimitReached ? 'step_limit' : undefined);
|
|
1963
|
+
if (terminalStopReason)
|
|
1964
|
+
break agentLoop;
|
|
1965
|
+
if (!this.deps.backend.loadTurnRuntimeEvents) {
|
|
1966
|
+
throw new Error('durable current-run reader is required for turn continuation');
|
|
1972
1967
|
}
|
|
1973
|
-
|
|
1968
|
+
await queue.waitUntilConsumedThroughCurrent();
|
|
1969
|
+
if ((await input.handoffBoundary?.(turnAbortController.signal, maxSteps === undefined ? null : maxSteps - runtimeSteps)) === 'pause') {
|
|
1970
|
+
this.handoffPaused = true;
|
|
1971
|
+
break agentLoop;
|
|
1972
|
+
}
|
|
1973
|
+
currentStepMessageId = this.deps.newId();
|
|
1974
1974
|
}
|
|
1975
1975
|
// Refine Tool Availability against the final active set. Deferred
|
|
1976
1976
|
// loading may add tools, while boundary convergence may remove them;
|
|
@@ -1986,7 +1986,7 @@ export class AiSdkTurn {
|
|
|
1986
1986
|
// silently drop prior requests. An unusable sample in ANY request fails
|
|
1987
1987
|
// the whole record closed (#972).
|
|
1988
1988
|
try {
|
|
1989
|
-
const attemptTotalUsage = providerOutcome
|
|
1989
|
+
const attemptTotalUsage = providerOutcome?.usage;
|
|
1990
1990
|
tokenUsage = sawUnusableStepUsage ? undefined : (completedStepUsage ?? attemptTotalUsage);
|
|
1991
1991
|
if (tokenUsage) {
|
|
1992
1992
|
tokenUsageCostUsd = this.deps.providerTelemetry.normalizedUsageCostUsd(tokenUsage);
|
|
@@ -2090,10 +2090,9 @@ export class AiSdkTurn {
|
|
|
2090
2090
|
// seals the drained stream; no complete/abort event ends the logical Turn.
|
|
2091
2091
|
if (this.handoffPaused)
|
|
2092
2092
|
return;
|
|
2093
|
-
const stopReason = this.loopStopReason ??
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
: this.mapFinishReason(finishReason));
|
|
2093
|
+
const stopReason = this.loopStopReason ?? terminalStopReason;
|
|
2094
|
+
if (!stopReason)
|
|
2095
|
+
throw new Error('Turn ended without a terminal decision');
|
|
2097
2096
|
trace.modelStreamCompleted(stopReason);
|
|
2098
2097
|
const completeEvent = {
|
|
2099
2098
|
type: 'complete',
|
|
@@ -2261,7 +2260,7 @@ export class AiSdkTurn {
|
|
|
2261
2260
|
})),
|
|
2262
2261
|
isFatalToolError: isRuntimeCommitBoundaryError,
|
|
2263
2262
|
callTool: async (name, input, signal) => {
|
|
2264
|
-
if (this.
|
|
2263
|
+
if (this.loopStopReason)
|
|
2265
2264
|
throw new Error('The turn has yielded; no further tools may run.');
|
|
2266
2265
|
const tool = snapshot.get(name);
|
|
2267
2266
|
if (!tool)
|
|
@@ -2323,8 +2322,7 @@ export class AiSdkTurn {
|
|
|
2323
2322
|
revision: proposal.revision,
|
|
2324
2323
|
storeVersion: result.storeVersion,
|
|
2325
2324
|
});
|
|
2326
|
-
this.
|
|
2327
|
-
this.loopStopRequested = true;
|
|
2325
|
+
this.turnYield = 'plan_handoff';
|
|
2328
2326
|
return;
|
|
2329
2327
|
}
|
|
2330
2328
|
const traceType = result.kind;
|
|
@@ -2345,11 +2343,7 @@ export class AiSdkTurn {
|
|
|
2345
2343
|
liveOperatorCount: result.liveOperatorCount,
|
|
2346
2344
|
reason: result.reason,
|
|
2347
2345
|
});
|
|
2348
|
-
this.
|
|
2349
|
-
this.loopStopRequested = true;
|
|
2350
|
-
}
|
|
2351
|
-
mapFinishReason(reason) {
|
|
2352
|
-
return this.deps.modelAdapter.mapFinishReason(reason);
|
|
2346
|
+
this.turnYield = 'graph_yield';
|
|
2353
2347
|
}
|
|
2354
2348
|
makeErrorEvent(turnId, err, reasonOverride) {
|
|
2355
2349
|
return this.deps.modelAdapter.makeErrorEvent(turnId, err, reasonOverride);
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { resolveBotMessageHandling, } from '@maka/core/bot-chat-settings';
|
|
19
20
|
import { generalizedErrorMessage } from '@maka/core/redaction';
|
|
20
21
|
import { BOT_PROVIDERS } from '@maka/core/settings';
|
|
21
22
|
import { DingTalkBotBridge } from './dingtalk-bridge.js';
|
|
@@ -69,7 +70,19 @@ export class BotRegistry {
|
|
|
69
70
|
const bridge = this.bridges.get(platform);
|
|
70
71
|
if (!bridge || typeof bridge.sendTypingIndicator !== 'function')
|
|
71
72
|
return false;
|
|
72
|
-
return bridge.sendTypingIndicator(chatId);
|
|
73
|
+
return bridge.sendTypingIndicator(chatId).catch(() => false);
|
|
74
|
+
}
|
|
75
|
+
async cancelTypingIndicator(platform, chatId) {
|
|
76
|
+
const bridge = this.bridges.get(platform);
|
|
77
|
+
if (!bridge?.cancelTypingIndicator)
|
|
78
|
+
return false;
|
|
79
|
+
return bridge.cancelTypingIndicator(chatId).catch(() => false);
|
|
80
|
+
}
|
|
81
|
+
async getMessageReadStatus(platform, messageId, userId) {
|
|
82
|
+
const bridge = this.bridges.get(platform);
|
|
83
|
+
return ((await bridge
|
|
84
|
+
?.getMessageReadStatus?.(messageId, userId)
|
|
85
|
+
.catch(() => ({ state: 'unknown' }))) ?? { state: 'unknown' });
|
|
73
86
|
}
|
|
74
87
|
async stopAll() {
|
|
75
88
|
const next = this.applyQueue.then(() => this.stopAllNow(), () => this.stopAllNow());
|
|
@@ -77,7 +90,10 @@ export class BotRegistry {
|
|
|
77
90
|
return next;
|
|
78
91
|
}
|
|
79
92
|
async applySettingsNow(settings) {
|
|
80
|
-
await Promise.all(BOT_PROVIDERS.map((provider) => this.reconcileOne(provider,
|
|
93
|
+
await Promise.all(BOT_PROVIDERS.map((provider) => this.reconcileOne(provider, {
|
|
94
|
+
...settings.channels[provider],
|
|
95
|
+
messageHandling: resolveBotMessageHandling(settings, provider),
|
|
96
|
+
})));
|
|
81
97
|
}
|
|
82
98
|
async stopAllNow() {
|
|
83
99
|
await Promise.all([...this.bridges.values()].map((bridge) => bridge.stop().catch(() => { })));
|
|
@@ -116,7 +132,7 @@ export class BotRegistry {
|
|
|
116
132
|
}
|
|
117
133
|
this.statuses.delete(platform);
|
|
118
134
|
const bridge = platform === 'wechat'
|
|
119
|
-
? new WechatBridge(settings)
|
|
135
|
+
? new WechatBridge(settings, this.deps.wechatContextDirectory)
|
|
120
136
|
: platform === 'wecom'
|
|
121
137
|
? new WeComBotBridge(settings)
|
|
122
138
|
: platform === 'feishu'
|