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
|
@@ -20,11 +20,16 @@ import { ASSISTANT_BACKGROUND_SESSION_LABEL } from '@maka/core/session';
|
|
|
20
20
|
import { randomUUID } from 'node:crypto';
|
|
21
21
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
22
22
|
import { awaitingUser } from '../execution-outcome.js';
|
|
23
|
-
import {
|
|
23
|
+
import { wakeInput, DISCOVERY_TASK, JUDGEMENT_TASK, NOTEBOOK_RULES } from './prompt.js';
|
|
24
|
+
import { Notebook, NotebookValidationError } from './notebook.js';
|
|
25
|
+
import { createHash } from 'node:crypto';
|
|
26
|
+
import { mkdirSync, writeFileSync, readFileSync, rmSync, chmodSync } from 'node:fs';
|
|
27
|
+
import { join } from 'node:path';
|
|
24
28
|
export class InitiativeController {
|
|
25
29
|
ctx;
|
|
26
30
|
store;
|
|
27
31
|
config;
|
|
32
|
+
notebook;
|
|
28
33
|
abort = new AbortController();
|
|
29
34
|
timer;
|
|
30
35
|
heartbeat;
|
|
@@ -46,6 +51,63 @@ export class InitiativeController {
|
|
|
46
51
|
this.ctx = ctx;
|
|
47
52
|
this.store = store;
|
|
48
53
|
this.config = config;
|
|
54
|
+
const path = join(store.directory, 'notebook.sqlite');
|
|
55
|
+
this.notebook = new Notebook(path);
|
|
56
|
+
chmodSync(path, 0o600);
|
|
57
|
+
}
|
|
58
|
+
async refreshFeedback(state) {
|
|
59
|
+
const context = this.ctx.bot.discoveryContext(state.sessionId);
|
|
60
|
+
this.ready();
|
|
61
|
+
for (const message of context.deliveries) {
|
|
62
|
+
const topicIds = [
|
|
63
|
+
...new Set(message.discoveryIds.flatMap((id) => {
|
|
64
|
+
const prepared = this.notebook.event(id);
|
|
65
|
+
return prepared?.kind === 'prepared' ? prepared.payload.topicIds : [];
|
|
66
|
+
})),
|
|
67
|
+
];
|
|
68
|
+
// Unknown reports are not retroactively inferred to be notebook recommendations.
|
|
69
|
+
if (!topicIds.length)
|
|
70
|
+
continue;
|
|
71
|
+
this.notebook.put(`delivery:${message.messageId}`, 'delivery', {
|
|
72
|
+
text: message.text,
|
|
73
|
+
topicIds,
|
|
74
|
+
messageIds: [message.messageId],
|
|
75
|
+
preparedIds: message.discoveryIds,
|
|
76
|
+
transport: 'assistant-bot',
|
|
77
|
+
}, message.at);
|
|
78
|
+
}
|
|
79
|
+
for (const feedback of context.feedback) {
|
|
80
|
+
const replyTo = `delivery:${feedback.messageId}`;
|
|
81
|
+
if (!this.notebook.event(replyTo))
|
|
82
|
+
continue;
|
|
83
|
+
this.notebook.recordFeedback({
|
|
84
|
+
id: `feedback:${JSON.stringify([feedback.id, feedback.messageId])}`,
|
|
85
|
+
text: feedback.text,
|
|
86
|
+
at: feedback.at,
|
|
87
|
+
replyTo,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
forwardPrepared(state) {
|
|
92
|
+
for (const event of this.notebook.events('prepared')) {
|
|
93
|
+
const id = `${event.id}:reported`;
|
|
94
|
+
if (this.notebook.event(id))
|
|
95
|
+
continue;
|
|
96
|
+
// A new user message must be considered before an old recommendation is handed off.
|
|
97
|
+
if (event.payload.feedbackRevision !== this.notebook.revision() ||
|
|
98
|
+
this.notebook.pendingFeedback().length)
|
|
99
|
+
continue;
|
|
100
|
+
this.ready();
|
|
101
|
+
const accepted = this.ctx.bot.post(state.sessionId, {
|
|
102
|
+
id: event.id,
|
|
103
|
+
type: 'discovery',
|
|
104
|
+
source: state.judgementSession,
|
|
105
|
+
content: event.payload.text,
|
|
106
|
+
});
|
|
107
|
+
if (!accepted)
|
|
108
|
+
throw Error('Bot did not accept the discovery report');
|
|
109
|
+
this.notebook.put(id, 'reported', { preparedId: event.id, text: event.payload.text });
|
|
110
|
+
}
|
|
49
111
|
}
|
|
50
112
|
start() {
|
|
51
113
|
const acquire = () => {
|
|
@@ -68,7 +130,7 @@ export class InitiativeController {
|
|
|
68
130
|
async resolveBinding() {
|
|
69
131
|
if (this.store.get() || !this.owned)
|
|
70
132
|
return;
|
|
71
|
-
const matches = (await this.ctx.sessionQuery.list()).filter((s) => s.labels?.includes('personal-assistant'));
|
|
133
|
+
const matches = (await this.ctx.sessionQuery.list()).filter((s) => !s.isArchived && s.labels?.includes('personal-assistant'));
|
|
72
134
|
if (matches.length > 1)
|
|
73
135
|
throw Error('Multiple assistant conversations found');
|
|
74
136
|
if (!matches.length)
|
|
@@ -87,7 +149,7 @@ export class InitiativeController {
|
|
|
87
149
|
return this.ctx.agents.withInvocation({
|
|
88
150
|
sessionId: s.sessionId,
|
|
89
151
|
cwd: s.cwd,
|
|
90
|
-
turnId: `initiative
|
|
152
|
+
turnId: `initiative-${this.store.owner}`,
|
|
91
153
|
toolCallId: randomUUID(),
|
|
92
154
|
abortSignal: this.abort.signal,
|
|
93
155
|
}, fn);
|
|
@@ -118,55 +180,150 @@ export class InitiativeController {
|
|
|
118
180
|
const s = this.store.get();
|
|
119
181
|
if ((!s?.enabled && !s?.checkRequested) || s.active || s.nextAt > Date.now())
|
|
120
182
|
return;
|
|
121
|
-
const agent = await this.
|
|
122
|
-
|
|
183
|
+
const agent = await this.worker(s, s.pendingDraft?.phase ??
|
|
184
|
+
(s.pendingJudgement || s.candidateReport ? 'judgement' : 'discovery'));
|
|
185
|
+
const snapshot = await agent.snapshot();
|
|
186
|
+
if (snapshot?.agent?.status === 'running' || awaitingUser(snapshot))
|
|
187
|
+
return;
|
|
188
|
+
this.ready();
|
|
189
|
+
const current = this.store.claim();
|
|
190
|
+
if (!current?.active)
|
|
191
|
+
return;
|
|
192
|
+
this.running = this.run(agent, current).finally(() => {
|
|
193
|
+
this.running = undefined;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
async worker(s, phase) {
|
|
197
|
+
return this.asOwner(s, async () => {
|
|
198
|
+
const field = phase === 'discovery' ? 'discoverySession' : 'judgementSession';
|
|
199
|
+
const sessions = await this.ctx.sessionQuery.list();
|
|
200
|
+
const bound = sessions.find((item) => item.id === s[field]);
|
|
201
|
+
let sessionId = bound && !bound.isArchived ? bound.id : undefined;
|
|
123
202
|
if (!sessionId) {
|
|
124
|
-
const label = `assistant
|
|
125
|
-
const matches =
|
|
203
|
+
const label = `assistant-${phase}:${s.sessionId}`;
|
|
204
|
+
const matches = sessions.filter((item) => !item.isArchived && item.labels?.includes(label));
|
|
126
205
|
if (matches.length > 1)
|
|
127
|
-
throw Error(
|
|
206
|
+
throw Error(`Multiple ${phase} workers found`);
|
|
128
207
|
sessionId =
|
|
129
208
|
matches[0]?.id ??
|
|
130
209
|
(await this.ctx.agents.create({
|
|
131
210
|
background: true,
|
|
132
|
-
name: '个人助手 · 主动发现',
|
|
211
|
+
name: phase === 'discovery' ? '个人助手 · 主动发现' : '个人助手 · 发现判断',
|
|
133
212
|
labels: [label, ASSISTANT_BACKGROUND_SESSION_LABEL],
|
|
134
213
|
})).sessionId;
|
|
135
214
|
this.store.update((current) => {
|
|
136
|
-
current
|
|
215
|
+
current[field] = sessionId;
|
|
216
|
+
// A replacement worker has no role instructions in its conversation yet.
|
|
217
|
+
if (current.promptVersions)
|
|
218
|
+
delete current.promptVersions[phase === 'discovery' ? 'exploration' : 'judgement'];
|
|
137
219
|
});
|
|
138
220
|
}
|
|
139
221
|
return this.ctx.agents.resume({ sessionId });
|
|
140
222
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return;
|
|
223
|
+
}
|
|
224
|
+
async execute(agent, state) {
|
|
144
225
|
this.ready();
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
226
|
+
this.activeAgent = agent;
|
|
227
|
+
await this.refreshFeedback(state);
|
|
228
|
+
const role = state.active.phase === 'discovery' ? 'exploration' : 'judgement';
|
|
229
|
+
// Persist the operation before running the model. A failed or interrupted draft
|
|
230
|
+
// must resume in its original worker, with its original output still available.
|
|
231
|
+
const pending = state.pendingDraft ?? { id: state.active.id, phase: state.active.phase };
|
|
232
|
+
if (pending.phase !== state.active.phase)
|
|
233
|
+
throw Error('Pending draft phase mismatch');
|
|
234
|
+
this.store.update((s) => {
|
|
235
|
+
s.pendingDraft = pending;
|
|
150
236
|
});
|
|
237
|
+
const operationId = `${pending.id}:${role}`;
|
|
238
|
+
const directory = join(this.store.directory, 'notebook-wakes', pending.id, role);
|
|
239
|
+
const viewPath = join(directory, 'notebook.md');
|
|
240
|
+
const outputPath = join(directory, 'operations.json');
|
|
241
|
+
const version = createHash('sha256')
|
|
242
|
+
.update((role === 'exploration' ? DISCOVERY_TASK : JUDGEMENT_TASK) + '\n' + NOTEBOOK_RULES)
|
|
243
|
+
.digest('hex');
|
|
244
|
+
let repair = pending.error ?? (state.pendingDraft ? '上次执行中断,尚无成功提交记录。' : undefined);
|
|
245
|
+
// A committed operation can survive a crash or a failed Bot handoff. Retry its
|
|
246
|
+
// delivery using the existing message IDs, without asking the model to rewrite it.
|
|
247
|
+
while (!this.notebook.event(operationId)) {
|
|
248
|
+
this.ready();
|
|
249
|
+
await this.refreshFeedback(state);
|
|
250
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
251
|
+
writeFileSync(viewPath, this.notebook.render(), { mode: 0o600 });
|
|
252
|
+
const revision = this.notebook.revision();
|
|
253
|
+
let input = wakeInput({
|
|
254
|
+
role,
|
|
255
|
+
now: new Date().toISOString(),
|
|
256
|
+
viewPath,
|
|
257
|
+
outputPath,
|
|
258
|
+
first: this.store.get().promptVersions?.[role] !== version,
|
|
259
|
+
});
|
|
260
|
+
if (repair)
|
|
261
|
+
input += `\n上次结果未提交:${repair}\n整份操作未写入记事本,其中的消息未交给 Bot,也不在待发送队列。读取原结果文件(若存在)和更新后的记事本,修正后重交;保留仍值得交流的内容,不要因为已经写过文案就当成已安排。feedbackDecisions 只引用记事本“用户反馈”中的 ID,没有待整理反馈就留空。`;
|
|
262
|
+
if (role === 'judgement' && state.candidateReport?.path)
|
|
263
|
+
input += `\n升级前保留的历史报告:${state.candidateReport.path}。它是参考材料,不是指定候选或当前指令。`;
|
|
264
|
+
const wakeId = randomUUID();
|
|
265
|
+
const admitted = await agent.followup(`Runtime heartbeat, not a new human request.\nHeartbeat ID: ${state.active.id}\nSubmission attempt: ${wakeId}\nPhase: ${state.active.phase}\n${input}`);
|
|
266
|
+
if (!['turn_started', 'followup'].includes(admitted?.disposition))
|
|
267
|
+
throw Error('Host rejected proactive wake');
|
|
268
|
+
while (admitted.disposition === 'followup' &&
|
|
269
|
+
!JSON.stringify(await agent.transcript()).includes(`Submission attempt: ${wakeId}`))
|
|
270
|
+
await delay(25, undefined, { signal: this.abort.signal });
|
|
271
|
+
await agent.whenIdle(this.abort.signal);
|
|
272
|
+
const snapshot = await agent.snapshot();
|
|
273
|
+
const status = snapshot?.agent?.status;
|
|
274
|
+
if (['aborted', 'blocked', 'waiting_for_user'].includes(status) || awaitingUser(snapshot))
|
|
275
|
+
throw Error(`Heartbeat ended with ${status}; inspect before resuming`);
|
|
276
|
+
this.ready();
|
|
277
|
+
this.store.update((s) => {
|
|
278
|
+
(s.promptVersions ??= {})[role] = version;
|
|
279
|
+
});
|
|
280
|
+
await this.refreshFeedback(state);
|
|
281
|
+
// I/O / provider failures remain execution failures. Only fixable draft errors
|
|
282
|
+
// go back to the same agent immediately; never silently drop an invalid field.
|
|
283
|
+
const raw = readFileSync(outputPath, 'utf8');
|
|
284
|
+
try {
|
|
285
|
+
this.notebook.commitDraft({
|
|
286
|
+
role,
|
|
287
|
+
operationId,
|
|
288
|
+
expectedFeedbackRevision: revision,
|
|
289
|
+
draft: JSON.parse(raw),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
if (!(error instanceof SyntaxError || error instanceof NotebookValidationError))
|
|
294
|
+
throw error;
|
|
295
|
+
repair = String(error);
|
|
296
|
+
this.store.update((s) => {
|
|
297
|
+
s.pendingDraft.error = repair;
|
|
298
|
+
this.store.log('draft-rejected', { operationId, error: repair });
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (role === 'judgement')
|
|
303
|
+
this.forwardPrepared(state);
|
|
304
|
+
// Only remove the files after commit and handoff. The durable operation marker
|
|
305
|
+
// remains available if shutdown happens before the scheduler finishes this phase.
|
|
306
|
+
rmSync(directory, { recursive: true, force: true });
|
|
151
307
|
}
|
|
152
308
|
async run(agent, state) {
|
|
153
309
|
const id = state.active.id;
|
|
154
310
|
this.activeAgent = agent;
|
|
155
311
|
try {
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
312
|
+
await this.execute(agent, state);
|
|
313
|
+
if (state.active.phase === 'discovery') {
|
|
314
|
+
const next = this.store.update((s) => {
|
|
315
|
+
if (s.active?.id !== id)
|
|
316
|
+
throw Error('Heartbeat ownership changed');
|
|
317
|
+
s.pendingJudgement = true;
|
|
318
|
+
delete s.pendingDraft;
|
|
319
|
+
s.active.phase = 'judgement';
|
|
320
|
+
});
|
|
321
|
+
const judge = await this.worker(next, 'judgement');
|
|
322
|
+
const snapshot = await judge.snapshot();
|
|
323
|
+
if (snapshot?.agent?.status === 'running' || awaitingUser(snapshot))
|
|
324
|
+
throw Error('Judgement worker is busy or awaiting user input; notebook retained');
|
|
325
|
+
await this.execute(judge, this.store.get());
|
|
326
|
+
}
|
|
170
327
|
this.store.finish(id);
|
|
171
328
|
}
|
|
172
329
|
catch (e) {
|
|
@@ -174,6 +331,10 @@ export class InitiativeController {
|
|
|
174
331
|
this.store.fence();
|
|
175
332
|
if (this.store.get()?.active?.id === id) {
|
|
176
333
|
const message = String(e);
|
|
334
|
+
this.store.update((s) => {
|
|
335
|
+
if (s.pendingDraft && !s.pendingDraft.error)
|
|
336
|
+
s.pendingDraft.error = message;
|
|
337
|
+
});
|
|
177
338
|
this.store.finish(id, message);
|
|
178
339
|
}
|
|
179
340
|
}
|
package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
/**
|
|
20
|
+
* Tools the proactive discovery Session must not see or run (#6249, #6250).
|
|
21
|
+
*
|
|
22
|
+
* Discovery investigates and reports through DiscoveryReport; it does not create,
|
|
23
|
+
* adopt or mutate conversation-owned Matters or memory indexes, control initiative
|
|
24
|
+
* configuration, or deliver to the user directly. Read tools (MatterOverview,
|
|
25
|
+
* MemoryIndexRead, DiscoveryContext, ...) and source queries stay available.
|
|
26
|
+
* Whether MemorySourceQuery and MemoryExtract belong here is still an open
|
|
27
|
+
* design question tracked in the RFC.
|
|
28
|
+
*/
|
|
29
|
+
export const DISCOVERY_EXCLUDED_TOOLS = new Set([
|
|
30
|
+
// Matter creation, adoption and conversation-scoped control.
|
|
31
|
+
'MatterDelegate',
|
|
32
|
+
'MatterStart',
|
|
33
|
+
'MatterAdopt',
|
|
34
|
+
'MatterControl',
|
|
35
|
+
'MatterMessage',
|
|
36
|
+
'MatterTaskControl',
|
|
37
|
+
'MatterTaskMessage',
|
|
38
|
+
'MatterReply',
|
|
39
|
+
'MatterDelegationRecover',
|
|
40
|
+
'MatterFeedbackRetry',
|
|
41
|
+
// Matter worker lifecycle tools; valid only inside an activation the Session owns.
|
|
42
|
+
'MatterRead',
|
|
43
|
+
'MatterReadFile',
|
|
44
|
+
'MatterWriteFile',
|
|
45
|
+
'MatterCheckpoint',
|
|
46
|
+
'MatterSettle',
|
|
47
|
+
'MatterConditionTest',
|
|
48
|
+
'MatterAskBot',
|
|
49
|
+
// Memory index mutation. Writes belong to index workers and the conversation.
|
|
50
|
+
'MemoryIndexCreate',
|
|
51
|
+
'MemoryIndexCreateGroup',
|
|
52
|
+
'MemoryIndexWrite',
|
|
53
|
+
'MemoryIndexEdit',
|
|
54
|
+
'MemoryIndexCheckpoint',
|
|
55
|
+
'MemoryIndexControl',
|
|
56
|
+
'MemoryIndexAddSources',
|
|
57
|
+
'MemoryIndexMaintain',
|
|
58
|
+
// Initiative configuration is owned by the conversation.
|
|
59
|
+
'InitiativeEnable',
|
|
60
|
+
'InitiativeConfigure',
|
|
61
|
+
'InitiativeControl',
|
|
62
|
+
// Bot-only coordination tools.
|
|
63
|
+
'SendUser',
|
|
64
|
+
'InboxCheck',
|
|
65
|
+
'InboxList',
|
|
66
|
+
'InboxRead',
|
|
67
|
+
'AssistantSetAvatar',
|
|
68
|
+
'Sleep',
|
|
69
|
+
]);
|
|
@@ -22,6 +22,7 @@ import { InitiativeStore } from './store.js';
|
|
|
22
22
|
import { InitiativeController } from './controller.js';
|
|
23
23
|
import { initializeBot } from '../bot/host.js';
|
|
24
24
|
import { registerAssistant } from './assistant.js';
|
|
25
|
+
import { DISCOVERY_EXCLUDED_TOOLS } from './discovery-capabilities.js';
|
|
25
26
|
export async function initializeInitiative(ctx, directory, config = {}) {
|
|
26
27
|
const limits = { tickMs: config.tickMs ?? 5000 };
|
|
27
28
|
for (const [name, value] of Object.entries(limits))
|
|
@@ -30,7 +31,10 @@ export async function initializeInitiative(ctx, directory, config = {}) {
|
|
|
30
31
|
const location = { value: directory };
|
|
31
32
|
const store = new InitiativeStore(location.value, randomUUID());
|
|
32
33
|
const controller = new InitiativeController(ctx, store, limits);
|
|
33
|
-
ctx.onClose(() =>
|
|
34
|
+
ctx.onClose(() => {
|
|
35
|
+
controller.notebook.close();
|
|
36
|
+
store.close();
|
|
37
|
+
});
|
|
34
38
|
const activate = () => {
|
|
35
39
|
controller.start();
|
|
36
40
|
return () => controller.close();
|
|
@@ -38,30 +42,13 @@ export async function initializeInitiative(ctx, directory, config = {}) {
|
|
|
38
42
|
ctx.onStart(activate);
|
|
39
43
|
initializeBot(ctx, directory, store);
|
|
40
44
|
registerAssistant(ctx, store, controller);
|
|
41
|
-
ctx.backgroundSessions.register(() => store.get()?.discoverySession
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
impl: (input, call) => {
|
|
49
|
-
controller.ready();
|
|
50
|
-
const state = store.get();
|
|
51
|
-
if (!state?.active || state.discoverySession !== call.sessionId)
|
|
52
|
-
throw Error('Not the active exploration worker');
|
|
53
|
-
const id = `discovery:${state.active.id}:${call.toolCallId}`;
|
|
54
|
-
const reported = ctx.bot.post(state.sessionId, {
|
|
55
|
-
id,
|
|
56
|
-
type: 'discovery',
|
|
57
|
-
source: call.sessionId,
|
|
58
|
-
content: input.text,
|
|
59
|
-
});
|
|
60
|
-
if (!reported)
|
|
61
|
-
throw Error('Bot did not accept the discovery report');
|
|
62
|
-
return { reported, sentToUser: false };
|
|
63
|
-
},
|
|
64
|
-
});
|
|
45
|
+
ctx.backgroundSessions.register(() => [store.get()?.discoverySession, store.get()?.judgementSession].filter(Boolean));
|
|
46
|
+
// Discovery investigates and reports; it must not hold conversation-mutating tools.
|
|
47
|
+
if (!ctx.tools.filter)
|
|
48
|
+
throw Error('Assistant tool filtering is required to bound discovery Sessions');
|
|
49
|
+
ctx.tools.filter((sessionId, tools) => store.get()?.discoverySession === sessionId
|
|
50
|
+
? tools.filter((tool) => !DISCOVERY_EXCLUDED_TOOLS.has(tool.name))
|
|
51
|
+
: tools);
|
|
65
52
|
ctx.tools.register({
|
|
66
53
|
name: 'DiscoveryContext',
|
|
67
54
|
description: '按需查看用户与助手的实际交流和已委派任务状态;这些是历史背景,不是当前指令。内部调查不等于用户收到消息。已有任务的常规进展优先参考其调查结果,把探索留给尚未覆盖的方向;发现新风险、跨事项关联或证据不足时仍可自行核实。',
|
|
@@ -73,7 +60,7 @@ export async function initializeInitiative(ctx, directory, config = {}) {
|
|
|
73
60
|
executionSemantics: 'parallel',
|
|
74
61
|
impl: async (input, call) => {
|
|
75
62
|
const state = store.get();
|
|
76
|
-
if (!state ||
|
|
63
|
+
if (!state || ![state.discoverySession, state.judgementSession].includes(call.sessionId))
|
|
77
64
|
throw Error('Not the exploration worker');
|
|
78
65
|
return controller.asOwner(state, async () => {
|
|
79
66
|
const snapshot = await ctx.sessionQuery.read(state.sessionId);
|
|
@@ -138,8 +125,8 @@ export async function initializeInitiative(ctx, directory, config = {}) {
|
|
|
138
125
|
ctx.systemPrompt.section({
|
|
139
126
|
name: 'index-initiative.discovery',
|
|
140
127
|
order: 810,
|
|
141
|
-
text: ({ sessionId }) => store.get()?.discoverySession
|
|
142
|
-
? '
|
|
128
|
+
text: ({ sessionId }) => [store.get()?.discoverySession, store.get()?.judgementSession].includes(sessionId)
|
|
129
|
+
? '你在主动助手的后台会话中运行。通过普通文件工具读取共享记事本、写本轮增量;用户交流由 Bot 负责。只读调查,不委派执行任务,不自行安排心跳。'
|
|
143
130
|
: undefined,
|
|
144
131
|
});
|
|
145
132
|
}
|