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
|
@@ -0,0 +1,534 @@
|
|
|
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 { isInteractionAnswerValidForRequest } from '@maka/core/interaction';
|
|
20
|
+
import { abortable, readRuntimeHostConnectionCatalog, } from '@maka/runtime-host/client';
|
|
21
|
+
import { updateRuntimeHostSession } from './runtime-host-session-update.js';
|
|
22
|
+
import { RuntimeHostSessionChannel } from './runtime-host-session-channel.js';
|
|
23
|
+
import { RunSessionInterrupted } from './run-session-result.js';
|
|
24
|
+
import { TurnOutcomeClassifier, acceptStoredTurn } from './run-turn-outcome.js';
|
|
25
|
+
/** Session controls that must verify ownership before mutating a Host-owned Turn. */
|
|
26
|
+
export function sessionControlRequiresExecutionBoundary(options) {
|
|
27
|
+
return (options.prompt !== undefined ||
|
|
28
|
+
options.answers !== undefined ||
|
|
29
|
+
options.resumeExecution === true ||
|
|
30
|
+
options.sandboxDecision !== undefined ||
|
|
31
|
+
options.stop === true);
|
|
32
|
+
}
|
|
33
|
+
/** Session commands observe Host-owned execution; they never publish client MCP. */
|
|
34
|
+
export async function runMakaSessionCommand(connection, options, env, allowDetach = true) {
|
|
35
|
+
const sessionId = options.sessionId;
|
|
36
|
+
const executing = options.prompt !== undefined || options.answers !== undefined || options.resumeExecution;
|
|
37
|
+
const decidingSandbox = options.sandboxDecision !== undefined;
|
|
38
|
+
const controllingTurn = sessionControlRequiresExecutionBoundary(options);
|
|
39
|
+
if ((executing || decidingSandbox) && !allowDetach)
|
|
40
|
+
throw new Error('Session control execution requires a persistent installation; use the blocking legacy run path for temporary npx invocations');
|
|
41
|
+
// Never silently discard options that the old turn.start path supports.
|
|
42
|
+
if (options.graph || options.cwd || options.projectId || options.timeoutMs) {
|
|
43
|
+
throw new Error('Session workspace, timeout and Graph overrides require the blocking legacy --resume <id> path');
|
|
44
|
+
}
|
|
45
|
+
if (options.maxSteps !== undefined &&
|
|
46
|
+
(options.prompt === undefined || options.placement !== undefined)) {
|
|
47
|
+
throw new Error('--max-steps requires an idle Session prompt without --queue/--steer');
|
|
48
|
+
}
|
|
49
|
+
const cancelled = new AbortController();
|
|
50
|
+
const removeSigint = env.onSigint(() => cancelled.abort(new RunSessionInterrupted()));
|
|
51
|
+
const observer = await SessionRunObserver.open(connection, sessionId, cancelled.signal).catch((error) => {
|
|
52
|
+
removeSigint();
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
const assertActive = () => {
|
|
56
|
+
cancelled.signal.throwIfAborted();
|
|
57
|
+
observer.throwIfFailed();
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
assertActive();
|
|
61
|
+
const configured = options.model !== undefined ||
|
|
62
|
+
options.connection !== undefined ||
|
|
63
|
+
options.thinking !== undefined
|
|
64
|
+
? await configureSessionModel(connection, options, assertActive)
|
|
65
|
+
: undefined;
|
|
66
|
+
const configuration = configured
|
|
67
|
+
? {
|
|
68
|
+
connection: configured.llmConnectionSlug,
|
|
69
|
+
model: configured.model,
|
|
70
|
+
thinking: configured.thinkingLevel ?? null,
|
|
71
|
+
}
|
|
72
|
+
: undefined;
|
|
73
|
+
let target = observer.snapshot.rootTurn?.turnId;
|
|
74
|
+
if (options.recap) {
|
|
75
|
+
const result = await abortable(() => connection.request('session.recap.generate', {
|
|
76
|
+
sessionId,
|
|
77
|
+
effectId: env.newId(),
|
|
78
|
+
reason: 'manual',
|
|
79
|
+
}), cancelled.signal);
|
|
80
|
+
assertActive();
|
|
81
|
+
if (result.kind === 'failed')
|
|
82
|
+
throw new Error(`Session recap failed: ${result.errorClass}`);
|
|
83
|
+
const executionBoundary = options.status
|
|
84
|
+
? await connection.request('session.execution_boundary.query', { sessionId })
|
|
85
|
+
: undefined;
|
|
86
|
+
assertActive();
|
|
87
|
+
return {
|
|
88
|
+
...observer.status(),
|
|
89
|
+
recap: result.text,
|
|
90
|
+
...(configuration ? { configuration } : {}),
|
|
91
|
+
...(executionBoundary ? { executionBoundary } : {}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
let messageId;
|
|
95
|
+
let submission;
|
|
96
|
+
let admittedQueueRevision;
|
|
97
|
+
let admittedQueueEpoch;
|
|
98
|
+
let fullAccess = false;
|
|
99
|
+
if (controllingTurn) {
|
|
100
|
+
const boundary = await connection.request('session.execution_boundary.query', { sessionId });
|
|
101
|
+
assertActive();
|
|
102
|
+
if (boundary.kind === 'external')
|
|
103
|
+
throw new Error('This Session must be controlled by its owning harness');
|
|
104
|
+
fullAccess = boundary.kind === 'bypass';
|
|
105
|
+
}
|
|
106
|
+
const authorizeExecution = async () => {
|
|
107
|
+
assertActive();
|
|
108
|
+
if (!options.yolo || fullAccess)
|
|
109
|
+
return;
|
|
110
|
+
await updateRuntimeHostSession(connection, sessionId, (current) => connection.request('session.configuration.update', {
|
|
111
|
+
sessionId,
|
|
112
|
+
expectedRevision: current.revision,
|
|
113
|
+
patch: { permissionMode: 'bypass' },
|
|
114
|
+
}), { operation: 'session.configuration.update', assertRequestAllowed: assertActive });
|
|
115
|
+
assertActive();
|
|
116
|
+
};
|
|
117
|
+
assertActive();
|
|
118
|
+
if (options.stop) {
|
|
119
|
+
const root = observer.snapshot.rootTurn;
|
|
120
|
+
if (!root || terminal(root.status))
|
|
121
|
+
return observer.status();
|
|
122
|
+
const stopped = await connection.request('turn.stop', {
|
|
123
|
+
sessionId,
|
|
124
|
+
turnId: root.turnId,
|
|
125
|
+
runId: root.runId,
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
sessionId,
|
|
129
|
+
status: terminal(stopped.status)
|
|
130
|
+
? stopped.status === 'completed'
|
|
131
|
+
? 'completed'
|
|
132
|
+
: 'failed'
|
|
133
|
+
: 'running',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (decidingSandbox) {
|
|
137
|
+
const pending = observer.approvals();
|
|
138
|
+
if (pending.length !== 1)
|
|
139
|
+
throw new Error(`Expected one pending sandbox request, found ${pending.length}; no decision was submitted`);
|
|
140
|
+
const request = pending[0];
|
|
141
|
+
target = request.turnId;
|
|
142
|
+
assertActive();
|
|
143
|
+
// Submit only the identity observed by this invocation. Never retry an uncertain decision.
|
|
144
|
+
await connection.request('interaction.answer', {
|
|
145
|
+
sessionId,
|
|
146
|
+
interactionId: request.interactionId,
|
|
147
|
+
answer: { kind: 'sandbox_boundary', decision: options.sandboxDecision },
|
|
148
|
+
});
|
|
149
|
+
observer.ignoreAnswered(request.interactionId);
|
|
150
|
+
}
|
|
151
|
+
else if (options.answers !== undefined) {
|
|
152
|
+
const pending = observer.snapshot.interactions.pending.filter((p) => p.request.kind === 'question');
|
|
153
|
+
if (pending.length !== 1)
|
|
154
|
+
throw new Error(`Expected one pending AskUser batch, found ${pending.length}; no answer was submitted`);
|
|
155
|
+
const question = pending[0];
|
|
156
|
+
if (!isInteractionAnswerValidForRequest(question.request, {
|
|
157
|
+
kind: 'question',
|
|
158
|
+
answers: options.answers,
|
|
159
|
+
}))
|
|
160
|
+
throw new Error('Answers do not match the pending AskUser questions; no answer was submitted');
|
|
161
|
+
await authorizeExecution();
|
|
162
|
+
target = question.turnId;
|
|
163
|
+
// Use the observed identity exactly once. A dispatched answer is never retried here.
|
|
164
|
+
await connection.request('interaction.answer', {
|
|
165
|
+
sessionId,
|
|
166
|
+
interactionId: question.interactionId,
|
|
167
|
+
answer: { kind: 'question', answers: options.answers },
|
|
168
|
+
});
|
|
169
|
+
observer.ignoreAnswered(question.interactionId);
|
|
170
|
+
}
|
|
171
|
+
else if (options.resumeExecution) {
|
|
172
|
+
const plan = await connection.request('turn.resume.query', { sessionId });
|
|
173
|
+
assertActive();
|
|
174
|
+
if (plan.disposition !== 'ready')
|
|
175
|
+
throw new Error(`Execution cannot resume: ${plan.reason}`);
|
|
176
|
+
await authorizeExecution();
|
|
177
|
+
const resumed = await connection.request('turn.resume.start', {
|
|
178
|
+
sessionId,
|
|
179
|
+
turnId: env.newId(),
|
|
180
|
+
sourceRunId: plan.sourceRunId,
|
|
181
|
+
sourceRuntimeEventHighWater: plan.sourceRuntimeEventHighWater,
|
|
182
|
+
});
|
|
183
|
+
if (resumed.kind !== 'started')
|
|
184
|
+
throw new Error(`Execution cannot resume: ${resumed.plan.reason}`);
|
|
185
|
+
target = resumed.turn.turnId;
|
|
186
|
+
}
|
|
187
|
+
else if (options.prompt !== undefined) {
|
|
188
|
+
if (options.maxSteps !== undefined) {
|
|
189
|
+
const root = observer.snapshot.rootTurn;
|
|
190
|
+
if (root && !terminal(root.status))
|
|
191
|
+
throw new Error('--max-steps cannot be applied to a queued or active Turn');
|
|
192
|
+
await authorizeExecution();
|
|
193
|
+
const started = await connection.request('turn.start', {
|
|
194
|
+
sessionId,
|
|
195
|
+
turnId: env.newId(),
|
|
196
|
+
content: { text: options.prompt },
|
|
197
|
+
maxSteps: options.maxSteps,
|
|
198
|
+
});
|
|
199
|
+
if (started.kind !== 'started')
|
|
200
|
+
throw new Error('Turn did not start');
|
|
201
|
+
target = started.turn.turnId;
|
|
202
|
+
submission = 'started';
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
await authorizeExecution();
|
|
206
|
+
messageId = env.newId();
|
|
207
|
+
const originHostEpoch = connection.hostEpoch;
|
|
208
|
+
const submitted = await connection.request('turn.message.submit', {
|
|
209
|
+
originHostEpoch,
|
|
210
|
+
sessionId,
|
|
211
|
+
messageId,
|
|
212
|
+
content: { text: options.prompt },
|
|
213
|
+
placement: options.placement ?? 'next_turn',
|
|
214
|
+
});
|
|
215
|
+
if (submitted.disposition === 'blocked')
|
|
216
|
+
throw new Error('Message was blocked before execution');
|
|
217
|
+
if (submitted.disposition === 'turn_started') {
|
|
218
|
+
target = submitted.turnId;
|
|
219
|
+
submission = 'started';
|
|
220
|
+
}
|
|
221
|
+
else if (submitted.disposition === 'steering') {
|
|
222
|
+
submission = 'steering';
|
|
223
|
+
admittedQueueRevision = submitted.queueRevision;
|
|
224
|
+
admittedQueueEpoch = originHostEpoch;
|
|
225
|
+
// Steering targets the Turn selected on attachment; it does not own a new Turn.
|
|
226
|
+
if (!target)
|
|
227
|
+
throw new Error('Steering was admitted but its observed Turn is unavailable; query Session status before continuing');
|
|
228
|
+
messageId = undefined;
|
|
229
|
+
}
|
|
230
|
+
else if (submitted.disposition === 'inbox') {
|
|
231
|
+
// Inbox admission does not own a worker Turn or a queue revision.
|
|
232
|
+
// Return its receipt even with --wait; never reuse an older Turn's result.
|
|
233
|
+
assertActive();
|
|
234
|
+
const { queued: _queued, ...observed } = observer.status();
|
|
235
|
+
return { ...observed, submission: 'inbox' };
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
target = undefined;
|
|
239
|
+
submission = 'queued';
|
|
240
|
+
admittedQueueRevision = submitted.queueRevision;
|
|
241
|
+
admittedQueueEpoch = originHostEpoch;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
assertActive();
|
|
246
|
+
if (options.status || (!executing && !decidingSandbox && !options.wait && !options.result)) {
|
|
247
|
+
const executionBoundary = await connection.request('session.execution_boundary.query', {
|
|
248
|
+
sessionId,
|
|
249
|
+
});
|
|
250
|
+
assertActive();
|
|
251
|
+
return {
|
|
252
|
+
...observer.status(),
|
|
253
|
+
executionBoundary,
|
|
254
|
+
...(configuration ? { configuration } : {}),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if (options.noWait) {
|
|
258
|
+
if (submission !== 'queued' && submission !== 'steering')
|
|
259
|
+
return { sessionId, status: 'running', ...(submission ? { submission } : {}) };
|
|
260
|
+
const observed = observer.status();
|
|
261
|
+
// Admission can precede its projection frame. Never report an older queue count as current.
|
|
262
|
+
const { queued, ...withoutQueueCount } = observed;
|
|
263
|
+
const hasAdmittedRevision = admittedQueueRevision !== undefined &&
|
|
264
|
+
observer.snapshot.queue.hostEpoch === admittedQueueEpoch &&
|
|
265
|
+
observer.snapshot.queue.queueRevision >= admittedQueueRevision;
|
|
266
|
+
return { ...(hasAdmittedRevision ? observed : withoutQueueCount), submission };
|
|
267
|
+
}
|
|
268
|
+
if (!target && !messageId)
|
|
269
|
+
target = await observer.latestTurn();
|
|
270
|
+
if (!target && !messageId)
|
|
271
|
+
return { sessionId, status: 'idle' };
|
|
272
|
+
for (;;) {
|
|
273
|
+
const version = observer.version;
|
|
274
|
+
cancelled.signal.throwIfAborted();
|
|
275
|
+
observer.throwIfFailed();
|
|
276
|
+
if (messageId && !target) {
|
|
277
|
+
const execution = await connection.request('turn.message.execution.query', {
|
|
278
|
+
sessionId,
|
|
279
|
+
messageIds: [messageId],
|
|
280
|
+
});
|
|
281
|
+
const resolution = execution.resolutions[0];
|
|
282
|
+
if (resolution?.state === 'owned')
|
|
283
|
+
target = resolution.turnId;
|
|
284
|
+
else if (resolution?.state === 'cancelled' || resolution?.state === 'not_admitted') {
|
|
285
|
+
throw new Error(`Submitted message is ${resolution.state}; it has no execution result`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (target) {
|
|
289
|
+
const questions = observer.questions(target);
|
|
290
|
+
if (questions.length)
|
|
291
|
+
return observer.questionResult(questions);
|
|
292
|
+
const approvals = observer.approvals(target);
|
|
293
|
+
if (approvals.length)
|
|
294
|
+
return observer.approvalResult(approvals);
|
|
295
|
+
const turn = await connection.request('turn.query', { sessionId, turnId: target });
|
|
296
|
+
if (terminal(turn.status)) {
|
|
297
|
+
const result = await observer.result(target);
|
|
298
|
+
if (result)
|
|
299
|
+
return result;
|
|
300
|
+
if (options.result)
|
|
301
|
+
throw new Error('The terminal result is still being published; query it again');
|
|
302
|
+
await observer.changed(version);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
const unsupported = observer.snapshot.interactions.pending.find((p) => p.turnId === target &&
|
|
306
|
+
p.request.kind !== 'question' &&
|
|
307
|
+
p.request.kind !== 'sandbox_boundary');
|
|
308
|
+
if (unsupported)
|
|
309
|
+
throw new Error(`Pending ${unsupported.request.kind} interaction cannot be answered by maka run. The Host Turn is still waiting; use an interactive client on this Host or run maka run --session ${sessionId} --stop with the same Host selection to stop it explicitly.`);
|
|
310
|
+
if (options.result)
|
|
311
|
+
return { sessionId, status: 'running' };
|
|
312
|
+
}
|
|
313
|
+
await observer.changed(version);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
finally {
|
|
317
|
+
removeSigint();
|
|
318
|
+
await observer.close();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function terminal(status) {
|
|
322
|
+
return status === 'completed' || status === 'failed' || status === 'cancelled';
|
|
323
|
+
}
|
|
324
|
+
async function configureSessionModel(connection, options, assertActive) {
|
|
325
|
+
const selected = options.connection !== undefined
|
|
326
|
+
? (await readRuntimeHostConnectionCatalog(connection)).connections.find((candidate) => candidate.slug === options.connection)
|
|
327
|
+
: undefined;
|
|
328
|
+
if (options.connection !== undefined && !selected)
|
|
329
|
+
throw new Error(`Runtime Host model connection is unavailable: ${options.connection}`);
|
|
330
|
+
return updateRuntimeHostSession(connection, options.sessionId, (current) => {
|
|
331
|
+
const changesModel = options.model !== undefined || options.connection !== undefined;
|
|
332
|
+
let patch = options.thinking !== undefined ? { thinkingLevel: options.thinking } : {};
|
|
333
|
+
if (changesModel) {
|
|
334
|
+
if (current.executorId && !selected) {
|
|
335
|
+
patch = { ...patch, executorConfig: { model: options.model } };
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
const connectionId = selected?.connectionId ?? current.llmConnectionId;
|
|
339
|
+
if (!connectionId)
|
|
340
|
+
throw new Error('Model selection requires an explicit --connection');
|
|
341
|
+
const changesTarget = connectionId !== current.llmConnectionId ||
|
|
342
|
+
(options.model ?? current.model) !== current.model;
|
|
343
|
+
patch = {
|
|
344
|
+
...patch,
|
|
345
|
+
...(changesTarget && options.thinking === undefined ? { thinkingLevel: null } : {}),
|
|
346
|
+
modelTarget: {
|
|
347
|
+
kind: 'explicit',
|
|
348
|
+
connectionId,
|
|
349
|
+
connectionSlug: selected?.slug ?? current.llmConnectionSlug,
|
|
350
|
+
model: options.model ?? current.model,
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return connection.request('session.configuration.update', {
|
|
356
|
+
sessionId: options.sessionId,
|
|
357
|
+
expectedRevision: current.revision,
|
|
358
|
+
patch,
|
|
359
|
+
});
|
|
360
|
+
}, { operation: 'session.configuration.update', assertRequestAllowed: assertActive });
|
|
361
|
+
}
|
|
362
|
+
class SessionRunObserver {
|
|
363
|
+
#connection;
|
|
364
|
+
#sessionId;
|
|
365
|
+
#signal;
|
|
366
|
+
#channel;
|
|
367
|
+
#version = 0;
|
|
368
|
+
#failure;
|
|
369
|
+
#waiters = new Set();
|
|
370
|
+
#answered = new Set();
|
|
371
|
+
constructor(connection, sessionId, signal) {
|
|
372
|
+
this.#connection = connection;
|
|
373
|
+
this.#sessionId = sessionId;
|
|
374
|
+
this.#signal = signal;
|
|
375
|
+
}
|
|
376
|
+
static async open(connection, sessionId, signal) {
|
|
377
|
+
const observer = new SessionRunObserver(connection, sessionId, signal);
|
|
378
|
+
const changed = () => observer.#notify();
|
|
379
|
+
const opened = await RuntimeHostSessionChannel.open({
|
|
380
|
+
connection,
|
|
381
|
+
sessionId,
|
|
382
|
+
signal,
|
|
383
|
+
now: Date.now,
|
|
384
|
+
onTurnStarted: (turn) => {
|
|
385
|
+
// Drain live events so a long-running observation cannot back up the channel.
|
|
386
|
+
void (async () => {
|
|
387
|
+
for await (const _event of turn.events) {
|
|
388
|
+
/* results are reconciled from durable transcript */
|
|
389
|
+
}
|
|
390
|
+
})().catch((error) => {
|
|
391
|
+
observer.#failure = error;
|
|
392
|
+
changed();
|
|
393
|
+
});
|
|
394
|
+
},
|
|
395
|
+
onRuntimeResourceChanged: changed,
|
|
396
|
+
onInteractionPending: changed,
|
|
397
|
+
onInteractionResolved: changed,
|
|
398
|
+
onTranscriptSettlement: changed,
|
|
399
|
+
onTranscriptReplaced: changed,
|
|
400
|
+
onGoalChanged: changed,
|
|
401
|
+
onSnapshotChanged: changed,
|
|
402
|
+
onRecovered: changed,
|
|
403
|
+
onFailed: (error) => {
|
|
404
|
+
observer.#failure = error;
|
|
405
|
+
changed();
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
observer.#channel = opened.channel;
|
|
409
|
+
opened.channel.activate();
|
|
410
|
+
return observer;
|
|
411
|
+
}
|
|
412
|
+
get snapshot() {
|
|
413
|
+
return this.#channel.snapshot;
|
|
414
|
+
}
|
|
415
|
+
get version() {
|
|
416
|
+
return this.#version;
|
|
417
|
+
}
|
|
418
|
+
throwIfFailed() {
|
|
419
|
+
if (this.#failure)
|
|
420
|
+
throw this.#failure;
|
|
421
|
+
}
|
|
422
|
+
ignoreAnswered(id) {
|
|
423
|
+
this.#answered.add(id);
|
|
424
|
+
}
|
|
425
|
+
questions(turnId) {
|
|
426
|
+
return this.snapshot.interactions.pending.filter((p) => p.request.kind === 'question' &&
|
|
427
|
+
!this.#answered.has(p.interactionId) &&
|
|
428
|
+
(turnId === undefined || p.turnId === turnId));
|
|
429
|
+
}
|
|
430
|
+
questionResult(pending) {
|
|
431
|
+
return {
|
|
432
|
+
sessionId: this.#sessionId,
|
|
433
|
+
status: 'needs_input',
|
|
434
|
+
questions: pending.flatMap((p) => (p.request.kind === 'question' ? p.request.questions : [])),
|
|
435
|
+
...(pending.length > 1 ? { pendingQuestionCount: pending.length } : {}),
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
approvals(turnId) {
|
|
439
|
+
return this.snapshot.interactions.pending.filter((p) => p.request.kind === 'sandbox_boundary' &&
|
|
440
|
+
!this.#answered.has(p.interactionId) &&
|
|
441
|
+
(turnId === undefined || p.turnId === turnId));
|
|
442
|
+
}
|
|
443
|
+
approvalResult(pending) {
|
|
444
|
+
return {
|
|
445
|
+
sessionId: this.#sessionId,
|
|
446
|
+
status: 'needs_approval',
|
|
447
|
+
approvalRequests: pending.flatMap((p) => p.request.kind === 'sandbox_boundary' ? [p.request] : []),
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
status() {
|
|
451
|
+
const pending = this.questions();
|
|
452
|
+
if (pending.length)
|
|
453
|
+
return {
|
|
454
|
+
...this.questionResult(pending),
|
|
455
|
+
queued: this.snapshot.queue.followup.length + this.snapshot.queue.steering.length,
|
|
456
|
+
};
|
|
457
|
+
const approvals = this.approvals();
|
|
458
|
+
if (approvals.length)
|
|
459
|
+
return {
|
|
460
|
+
...this.approvalResult(approvals),
|
|
461
|
+
queued: this.snapshot.queue.followup.length + this.snapshot.queue.steering.length,
|
|
462
|
+
};
|
|
463
|
+
const root = this.snapshot.rootTurn;
|
|
464
|
+
return {
|
|
465
|
+
sessionId: this.#sessionId,
|
|
466
|
+
status: !root
|
|
467
|
+
? 'idle'
|
|
468
|
+
: root.status === 'completed'
|
|
469
|
+
? 'completed'
|
|
470
|
+
: terminal(root.status)
|
|
471
|
+
? 'failed'
|
|
472
|
+
: 'running',
|
|
473
|
+
queued: this.snapshot.queue.followup.length + this.snapshot.queue.steering.length,
|
|
474
|
+
...(root && 'providerRetry' in root && root.providerRetry
|
|
475
|
+
? { providerRetry: root.providerRetry }
|
|
476
|
+
: {}),
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
async latestTurn() {
|
|
480
|
+
const result = await this.#connection.request('session.turn_landmarks.query', {
|
|
481
|
+
sessionId: this.#sessionId,
|
|
482
|
+
maxLandmarks: 1,
|
|
483
|
+
turnId: null,
|
|
484
|
+
});
|
|
485
|
+
return result.landmarks.at(-1)?.turnId;
|
|
486
|
+
}
|
|
487
|
+
async result(turnId) {
|
|
488
|
+
const classifier = new TurnOutcomeClassifier(turnId);
|
|
489
|
+
await this.#channel.replayTranscript(async (messages) => {
|
|
490
|
+
acceptStoredTurn(classifier, messages, turnId);
|
|
491
|
+
}, this.#signal);
|
|
492
|
+
const outcome = classifier.outcome('pending');
|
|
493
|
+
if (!outcome)
|
|
494
|
+
return undefined;
|
|
495
|
+
if (outcome.status === 'completed') {
|
|
496
|
+
return {
|
|
497
|
+
sessionId: this.#sessionId,
|
|
498
|
+
status: 'completed',
|
|
499
|
+
finalOutput: outcome.finalOutput ?? '',
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
sessionId: this.#sessionId,
|
|
504
|
+
status: 'failed',
|
|
505
|
+
error: outcome.failure?.message ?? outcome.failure?.class ?? 'Turn failed',
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
changed(version) {
|
|
509
|
+
this.#signal.throwIfAborted();
|
|
510
|
+
if (this.#version !== version)
|
|
511
|
+
return Promise.resolve();
|
|
512
|
+
return new Promise((resolve, reject) => {
|
|
513
|
+
const done = () => {
|
|
514
|
+
this.#signal.removeEventListener('abort', abort);
|
|
515
|
+
this.#waiters.delete(done);
|
|
516
|
+
resolve();
|
|
517
|
+
};
|
|
518
|
+
const abort = () => {
|
|
519
|
+
this.#waiters.delete(done);
|
|
520
|
+
reject(this.#signal.reason);
|
|
521
|
+
};
|
|
522
|
+
this.#waiters.add(done);
|
|
523
|
+
this.#signal.addEventListener('abort', abort, { once: true });
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
#notify() {
|
|
527
|
+
this.#version++;
|
|
528
|
+
for (const wake of [...this.#waiters])
|
|
529
|
+
wake();
|
|
530
|
+
}
|
|
531
|
+
async close() {
|
|
532
|
+
await this.#channel.close();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
/** A normal handoff to the caller, not a failed or cancelled Host Turn. */
|
|
20
|
+
export class RunQuestionAvailable extends Error {
|
|
21
|
+
pending;
|
|
22
|
+
constructor(pending) {
|
|
23
|
+
super('The Turn is waiting for an answer');
|
|
24
|
+
this.pending = pending;
|
|
25
|
+
}
|
|
26
|
+
result() {
|
|
27
|
+
return {
|
|
28
|
+
sessionId: this.pending.sessionId,
|
|
29
|
+
status: 'needs_input',
|
|
30
|
+
questions: this.pending.request.kind === 'question' ? this.pending.request.questions : [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class RunSessionInterrupted extends Error {
|
|
35
|
+
constructor() {
|
|
36
|
+
super('Session observation interrupted; Host execution was not stopped');
|
|
37
|
+
}
|
|
38
|
+
}
|