maka-agent 0.2.2-dev.92.20261019 → 0.2.2-dev.97.20261024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -7
- package/README.md +78 -18
- package/README.zh-CN.md +73 -15
- package/THIRD_PARTY_NOTICES.txt +12 -12
- package/dist/pi-goal.js +13 -0
- package/dist/pi-tui-runner.js +44 -1
- package/dist/run-command-core.js +111 -70
- package/dist/run-session-command.js +91 -15
- package/dist/run-turn-outcome.js +2 -33
- package/dist/runtime-host-session-channel.js +3 -1
- package/dist/runtime-host-session-driver.js +5 -0
- 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/event-wait.js +28 -10
- package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
- 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.js +8 -0
- package/node_modules/@maka/core/dist/session-checkin.js +31 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +2 -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/ai-sdk-compaction.js +22 -9
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +101 -127
- package/node_modules/@maka/runtime/dist/event-wait-tool.js +2 -2
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +32 -1
- package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
- 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 +7 -2
- 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/runtime-context.js +53 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
- 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/shell-run-manager.js +34 -0
- package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
- package/node_modules/@maka/runtime/dist/tool-runtime.js +8 -0
- 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 +2 -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 +64 -13
- 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 +1 -1
- 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 +35 -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 +1 -1
- 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 +87 -23
- package/node_modules/@maka/runtime-host/dist/assistant/service.js +49 -5
- package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +7 -1
- 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/canonical-session-projection.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +63 -12
- 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 +123 -11
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +126 -4
- package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +58 -19
- package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
- 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/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/context-offload-snapshot.js +2 -1
- package/node_modules/@maka/storage/dist/execution-stores.js +36 -1
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +26 -0
- 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 +86 -16
- package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
- 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-reclamation-checkpoint.js +37 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +31 -0
- package/node_modules/@maka/storage/package.json +3 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
- package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/package.json +5 -5
- package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
- package/node_modules/fast-uri/README.md +8 -0
- package/node_modules/fast-uri/index.js +98 -18
- package/node_modules/fast-uri/lib/utils.js +52 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/ip-address/README.md +104 -104
- package/node_modules/ip-address/dist/ipv4.js +7 -0
- package/node_modules/ip-address/dist/ipv6.js +7 -4
- package/node_modules/ip-address/dist/v6/constants.js +3 -0
- package/node_modules/ip-address/package.json +2 -1
- package/node_modules/undici/README.md +25 -3
- package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/undici/package.json +9 -7
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
|
@@ -16,6 +16,7 @@ const { failWebsocketConnection } = require('./connection')
|
|
|
16
16
|
const { WebsocketFrameSend } = require('./frame')
|
|
17
17
|
const { PerMessageDeflate } = require('./permessage-deflate')
|
|
18
18
|
const { MessageSizeExceededError } = require('../../core/errors')
|
|
19
|
+
const { defaultWebSocketMaxFragments, defaultWebSocketMaxPayloadSize } = require('../../core/constants')
|
|
19
20
|
|
|
20
21
|
// This code was influenced by ws released under the MIT license.
|
|
21
22
|
// Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
@@ -48,18 +49,25 @@ class ByteParser extends Writable {
|
|
|
48
49
|
/**
|
|
49
50
|
* @param {import('./websocket').Handler} handler
|
|
50
51
|
* @param {Map<string, string>|null} extensions
|
|
51
|
-
* @param {{ maxPayloadSize?: number }} [options]
|
|
52
|
+
* @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
|
|
53
|
+
* A missing value uses the default limit; `0` disables the limit.
|
|
52
54
|
*/
|
|
53
55
|
constructor (handler, extensions, options = {}) {
|
|
54
56
|
super()
|
|
55
57
|
|
|
56
58
|
this.#handler = handler
|
|
57
59
|
this.#extensions = extensions == null ? new Map() : extensions
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
// Options come from the dispatcher's `webSocketOptions`, which only
|
|
61
|
+
// DispatcherBase provides. Fall back to the defaults rather than to no
|
|
62
|
+
// limit, so RetryAgent, MockAgent or a custom dispatcher can't turn off
|
|
63
|
+
// the payload and decompression limits by accident.
|
|
64
|
+
this.#maxFragments = options.maxFragments ?? defaultWebSocketMaxFragments
|
|
65
|
+
this.#maxPayloadSize = options.maxPayloadSize ?? defaultWebSocketMaxPayloadSize
|
|
60
66
|
|
|
61
67
|
if (this.#extensions.has('permessage-deflate')) {
|
|
62
|
-
this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions,
|
|
68
|
+
this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions, {
|
|
69
|
+
maxPayloadSize: this.#maxPayloadSize
|
|
70
|
+
}))
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
|
|
@@ -244,6 +252,19 @@ class ByteParser extends Writable {
|
|
|
244
252
|
if (isControlFrame(this.#info.opcode)) {
|
|
245
253
|
this.#loop = this.parseControlFrame(body)
|
|
246
254
|
this.#state = parserStates.INFO
|
|
255
|
+
|
|
256
|
+
// If the automatic PONG/CLOSE reply filled the socket's write buffer,
|
|
257
|
+
// stop parsing and resume on drain so a PING flood cannot grow the
|
|
258
|
+
// outbound queue without bound.
|
|
259
|
+
if (this.#loop && this.#handler.socket.writableNeedDrain) {
|
|
260
|
+
this.#loop = false
|
|
261
|
+
this.#handler.socket.once('drain', () => {
|
|
262
|
+
if (this.destroyed) return
|
|
263
|
+
this.#loop = true
|
|
264
|
+
this.run(callback)
|
|
265
|
+
})
|
|
266
|
+
return
|
|
267
|
+
}
|
|
247
268
|
} else {
|
|
248
269
|
if (!this.#info.compressed) {
|
|
249
270
|
if (!this.writeFragments(body)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "undici",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.12.3",
|
|
4
4
|
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
|
5
5
|
"homepage": "https://undici.nodejs.org",
|
|
6
6
|
"bugs": {
|
|
@@ -63,13 +63,15 @@
|
|
|
63
63
|
"types": "index.d.ts",
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build:node": "esbuild index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names && node scripts/strip-comments.js",
|
|
66
|
-
"build:
|
|
66
|
+
"build:milo": "node build/milo.js",
|
|
67
|
+
"build:llhttp": "node build/llhttp.js --docker",
|
|
68
|
+
"build:wasm": "node build/llhttp.js --docker",
|
|
67
69
|
"generate-pem": "node scripts/generate-pem.js",
|
|
68
70
|
"lint": "eslint --cache",
|
|
69
71
|
"lint:fix": "eslint --fix --cache",
|
|
70
72
|
"test": "npm run test:javascript && cross-env NODE_V8_COVERAGE= npm run test:typescript",
|
|
71
73
|
"test:javascript": "npm run test:javascript:no-jest && npm run test:jest",
|
|
72
|
-
"test:javascript:no-jest": "npm run generate-pem && npm run test:unit && npm run test:fetch && npm run test:node-fetch && npm run test:infra && npm run test:cache && npm run test:cache-interceptor && npm run test:interceptors && npm run test:cookies && npm run test:eventsource && npm run test:subresource-integrity && npm run test:
|
|
74
|
+
"test:javascript:no-jest": "npm run generate-pem && npm run test:unit && npm run test:fetch && npm run test:node-fetch && npm run test:infra && npm run test:cache && npm run test:cache-interceptor && npm run test:interceptors && npm run test:cookies && npm run test:eventsource && npm run test:subresource-integrity && npm run test:websocket && npm run test:node-test && npm run test:cache-tests",
|
|
73
75
|
"test:javascript:without-intl": "npm run test:javascript:no-jest",
|
|
74
76
|
"test:busboy": "borp --timeout 180000 -p \"test/busboy/*.js\"",
|
|
75
77
|
"test:cache": "borp --timeout 180000 -p \"test/cache/*.js\"",
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
"test:websocket:autobahn": "node test/autobahn/client.js",
|
|
98
100
|
"test:websocket:autobahn:report": "node test/autobahn/report.js",
|
|
99
101
|
"test:wpt:setup": "node test/web-platform-tests/wpt-runner.mjs setup",
|
|
100
|
-
"test:wpt": "npm run test:wpt:setup && node test/web-platform-tests/wpt-runner.mjs run /fetch /mimesniff /xhr /websockets /eventsource",
|
|
102
|
+
"test:wpt": "npm run test:wpt:setup && node test/web-platform-tests/wpt-runner.mjs run /fetch /mimesniff /xhr /websockets /eventsource /service-workers",
|
|
101
103
|
"test:cache-tests": "node test/cache-interceptor/cache-tests.mjs --ci",
|
|
102
104
|
"coverage": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report",
|
|
103
105
|
"coverage:ci": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report:ci",
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
"prepare": "husky && node ./scripts/platform-shell.js"
|
|
110
112
|
},
|
|
111
113
|
"devDependencies": {
|
|
112
|
-
"@fastify/busboy": "3.2.
|
|
114
|
+
"@fastify/busboy": "3.2.3",
|
|
113
115
|
"@matteo.collina/tspl": "^0.2.0",
|
|
114
116
|
"@metcoder95/https-pem": "^1.0.0",
|
|
115
117
|
"@sinonjs/fake-timers": "^12.0.0",
|
|
@@ -120,12 +122,12 @@
|
|
|
120
122
|
"cross-env": "^10.0.0",
|
|
121
123
|
"dns-packet": "^5.4.0",
|
|
122
124
|
"esbuild": "^0.28.0",
|
|
123
|
-
"eslint": "^
|
|
125
|
+
"eslint": "^10.12.0",
|
|
124
126
|
"fast-check": "^4.1.1",
|
|
125
127
|
"husky": "^9.0.7",
|
|
126
128
|
"jest": "^30.0.5",
|
|
127
129
|
"jsondiffpatch": "^0.7.3",
|
|
128
|
-
"neostandard": "^0.
|
|
130
|
+
"neostandard": "^0.14.0",
|
|
129
131
|
"node-forge": "^1.3.1",
|
|
130
132
|
"proxy": "^4.0.0",
|
|
131
133
|
"tsd": "^0.33.0",
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
|
+
"./code-mode": "./dist/code-mode.js",
|
|
8
9
|
"./admission-limiter": "./dist/admission-limiter.js",
|
|
9
10
|
"./ask-user-question-tool": "./dist/ask-user-question-tool.js",
|
|
10
11
|
"./ai-sdk-backend": "./dist/ai-sdk-backend.js",
|
|
@@ -115,6 +116,7 @@
|
|
|
115
116
|
"./runtime-read-model": "./dist/runtime-read-model.js",
|
|
116
117
|
"./sandbox-boundary-tool": "./dist/sandbox-boundary-tool.js",
|
|
117
118
|
"./scheduled-task-tools": "./dist/scheduled-task-tools.js",
|
|
119
|
+
"./session-checkin": "./dist/session-checkin.js",
|
|
118
120
|
"./session-recap": "./dist/session-recap.js",
|
|
119
121
|
"./session-export": "./dist/session-export.js",
|
|
120
122
|
"./session-trace-projection": "./dist/session-trace-projection.js",
|
|
@@ -43,6 +43,14 @@ export class AssistantBotBridge {
|
|
|
43
43
|
await this.endpoint.receive(id, content, origin);
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
|
+
discoveryContext(owner) {
|
|
47
|
+
if (!this.isConversation(owner))
|
|
48
|
+
throw Error('Assistant conversation unavailable');
|
|
49
|
+
return {
|
|
50
|
+
deliveries: this.endpoint.discoveryDeliveries?.() ?? [],
|
|
51
|
+
feedback: this.endpoint.discoveryFeedback?.() ?? [],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
46
54
|
post(owner, input) {
|
|
47
55
|
if (!this.isConversation(owner))
|
|
48
56
|
return false;
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
20
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
21
21
|
import { ASSISTANT_BACKGROUND_SESSION_LABEL } from '@maka/core/session';
|
|
22
|
+
import { executionFailure } from '../execution-outcome.js';
|
|
23
|
+
import { assistantErrorOutputTurnId, assistantInputTurnId } from './turn-ids.js';
|
|
22
24
|
const UNREAD_SLEEP_FEEDBACK = '本次未能休眠:你读取 Inbox 后又收到新消息,或上一批还有未投递消息。请调用 InboxCheck 接收正文,再自行决定如何处理;不要求回复或完成每件事,之后可再次调用 Sleep。';
|
|
23
25
|
export class BotController {
|
|
24
26
|
ctx;
|
|
@@ -96,7 +98,7 @@ export class BotController {
|
|
|
96
98
|
type: 'user',
|
|
97
99
|
...(origin ? { origin } : {}),
|
|
98
100
|
id,
|
|
99
|
-
turnId:
|
|
101
|
+
turnId: assistantInputTurnId(id),
|
|
100
102
|
ts: Date.now(),
|
|
101
103
|
});
|
|
102
104
|
await this.flush();
|
|
@@ -153,14 +155,26 @@ export class BotController {
|
|
|
153
155
|
}
|
|
154
156
|
const attemptedThrough = this.store.head();
|
|
155
157
|
this.running = this.run()
|
|
156
|
-
.catch((error) => {
|
|
158
|
+
.catch(async (error) => {
|
|
157
159
|
if (!this.abort.signal.aborted) {
|
|
158
160
|
this.store.transaction(() => {
|
|
159
161
|
this.store.set('error', String(error));
|
|
160
162
|
// Mail arriving during a failed execution must still trigger a new
|
|
161
163
|
// attempt. Do not latch the failure against that newer input.
|
|
162
164
|
this.store.set('errorThrough', attemptedThrough);
|
|
165
|
+
const id = randomUUID();
|
|
166
|
+
this.store.queueVisible({
|
|
167
|
+
type: 'assistant',
|
|
168
|
+
id: `bot-error:${id}`,
|
|
169
|
+
turnId: assistantErrorOutputTurnId(id),
|
|
170
|
+
ts: Date.now(),
|
|
171
|
+
text: '助手消息处理暂时停止。消息已保留;请检查当前模型和连接,发送新消息可重试。',
|
|
172
|
+
modelId: 'assistant-bot',
|
|
173
|
+
});
|
|
163
174
|
});
|
|
175
|
+
// A publication may have committed before its response was lost.
|
|
176
|
+
// Keep the outbox entry for the next tick without replacing the failure.
|
|
177
|
+
await this.flush().catch(() => { });
|
|
164
178
|
}
|
|
165
179
|
})
|
|
166
180
|
.finally(() => {
|
|
@@ -168,7 +182,17 @@ export class BotController {
|
|
|
168
182
|
});
|
|
169
183
|
}
|
|
170
184
|
async run() {
|
|
171
|
-
|
|
185
|
+
try {
|
|
186
|
+
await this.flush();
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
// Pending publication is retried independently of model execution. A
|
|
190
|
+
// delivery failure cannot consume the retry triggered by fresh Inbox mail.
|
|
191
|
+
if (!this.abort.signal.aborted)
|
|
192
|
+
this.store.set('wakeError', String(error));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this.store.set('wakeError', null);
|
|
172
196
|
if (this.store.get('error')) {
|
|
173
197
|
const errorThrough = this.store.get('errorThrough');
|
|
174
198
|
if (errorThrough !== undefined && this.store.head() <= errorThrough)
|
|
@@ -211,7 +235,19 @@ export class BotController {
|
|
|
211
235
|
let resolution;
|
|
212
236
|
try {
|
|
213
237
|
resolution = await agent.messageExecution(wake.messageId);
|
|
214
|
-
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
this.store.set('wakeError', String(error));
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (resolution?.state === 'not_admitted') {
|
|
244
|
+
// Only a new admission may change the execution model. Recovering
|
|
245
|
+
// an owned or pending wake must keep observing that execution.
|
|
246
|
+
const prepared = await this.ctx.prepareBotWake(this.owner(), this.worker());
|
|
247
|
+
if (prepared === 'deferred')
|
|
248
|
+
return;
|
|
249
|
+
this.ready();
|
|
250
|
+
try {
|
|
215
251
|
const admitted = await agent.followup(wake.text, { messageId: wake.messageId });
|
|
216
252
|
if (!['turn_started', 'followup'].includes(admitted?.disposition))
|
|
217
253
|
throw Error('Bot wake was not admitted');
|
|
@@ -220,11 +256,11 @@ export class BotController {
|
|
|
220
256
|
break;
|
|
221
257
|
}
|
|
222
258
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
259
|
+
catch (error) {
|
|
260
|
+
// Retry reconciliation on the next scheduler tick, keeping the submission identity.
|
|
261
|
+
this.store.set('wakeError', String(error));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
228
264
|
}
|
|
229
265
|
this.store.set('wakeError', null);
|
|
230
266
|
if (resolution?.state === 'owned') {
|
|
@@ -270,10 +306,25 @@ export class BotController {
|
|
|
270
306
|
}
|
|
271
307
|
const finalStatus = (await agent.snapshot())?.agent?.status;
|
|
272
308
|
this.store.set('wake', null);
|
|
273
|
-
if (['aborted', 'blocked', 'waiting_for_user'].includes(finalStatus)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
309
|
+
if (['aborted', 'blocked', 'waiting_for_user'].includes(finalStatus) ||
|
|
310
|
+
!this.store.get('sleepTurn')) {
|
|
311
|
+
let message = ['aborted', 'blocked', 'waiting_for_user'].includes(finalStatus)
|
|
312
|
+
? 'Bot stopped: ' + finalStatus
|
|
313
|
+
: 'Bot ended without Sleep; send a new message to retry';
|
|
314
|
+
// A contained provider failure can settle whenIdle normally. Resolve
|
|
315
|
+
// this wake's latest execution rather than reporting a stale turn error.
|
|
316
|
+
if (wake) {
|
|
317
|
+
const execution = await agent
|
|
318
|
+
.messageExecution(wake.messageId)
|
|
319
|
+
.catch(() => undefined);
|
|
320
|
+
if (execution?.state === 'owned' && execution.turnId) {
|
|
321
|
+
const failure = await executionFailure(agent, execution.turnId).catch(() => undefined);
|
|
322
|
+
if (failure)
|
|
323
|
+
message = failure.message;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
throw Error(message);
|
|
327
|
+
}
|
|
277
328
|
}
|
|
278
329
|
finally {
|
|
279
330
|
this.activeAgent = undefined;
|
|
@@ -26,7 +26,7 @@ Inbox 中 source=external_connector 的文本来自外部连接器,不是主
|
|
|
26
26
|
|
|
27
27
|
用户消息、主动发现、任务和索引的后台反馈通过 Inbox 送达。你需要将每一条消息都处理,按你的判断选择合适的方式处理,
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
你需要向用户传达重要发现和进展。后台的失败、阻塞和澄清请求也由你接住,处理或向用户寻求帮助。用户回应已发送的主动发现时,用 DiscoveryFeedback 关联这条回复与对应消息;普通聊天不是主动发现反馈。
|
|
30
30
|
|
|
31
31
|
你负责索引的创建、来源和维护配置,以及主动发现的启停和周期。委派的工作由执行者推进和等待,结果返回给你,由你与用户交流。
|
|
32
32
|
|
|
@@ -49,6 +49,8 @@ export function initializeBot(ctx, directory, binding) {
|
|
|
49
49
|
}),
|
|
50
50
|
receive: (id, content, origin) => bot.receive(id, content, origin),
|
|
51
51
|
post: (input) => bot.post(input),
|
|
52
|
+
discoveryDeliveries: () => store.discoveryDeliveries(),
|
|
53
|
+
discoveryFeedback: () => store.discoveryFeedback(),
|
|
52
54
|
});
|
|
53
55
|
ctx.backgroundSessions.register(() => (bot.worker() ? [bot.worker()] : []));
|
|
54
56
|
ctx.onClose(() => store.close());
|
|
@@ -84,12 +86,13 @@ export function initializeBot(ctx, directory, binding) {
|
|
|
84
86
|
offset: z.number().int().nonnegative().default(0),
|
|
85
87
|
limit: z.number().int().min(1).max(48000).default(24000),
|
|
86
88
|
}), (input) => store.read(input.id, input.offset, input.limit), true);
|
|
87
|
-
register('SendUser', '向用户发送一批聊天消息,messages 按顺序显示为独立气泡。每项填写 text(完整正文);summary
|
|
89
|
+
register('SendUser', '向用户发送一批聊天消息,messages 按顺序显示为独立气泡。每项填写 text(完整正文);summary(简短摘要)可选。短消息直接发正文,不必写摘要。较长消息需要填写独立摘要,用户默认看到摘要,点击展开正文;摘要由你概括,不是截断正文。需要你从用户的观看体验来看需不需要摘要。转达主动发现时,在该项 discoveryIds 填对应的 discovery 类型 Inbox 消息 ID,记录实际送达关系;普通聊天留空。messageId 标识这批发送,重试时复用。发送后循环继续。', z
|
|
88
90
|
.object({
|
|
89
91
|
messageId: z.string().min(1).max(200),
|
|
90
92
|
messages: z
|
|
91
93
|
.array(z
|
|
92
94
|
.object({
|
|
95
|
+
discoveryIds: z.array(z.string().min(1)).min(1).max(100).optional(),
|
|
93
96
|
summary: z.string().trim().min(1).max(2000).optional(),
|
|
94
97
|
text: z.string().trim().min(1).max(48000),
|
|
95
98
|
})
|
|
@@ -103,6 +106,12 @@ export function initializeBot(ctx, directory, binding) {
|
|
|
103
106
|
await bot.flush();
|
|
104
107
|
return { sent: true, messageIds };
|
|
105
108
|
});
|
|
109
|
+
register('DiscoveryFeedback', '仅当用户在回应已发送的主动发现时,关联用户的 Inbox 消息 ID 和 SendUser 返回的实际消息 ID。根据交流内容判断关联,不把普通聊天或新任务当反馈;无需改写用户原话。可以回查 Inbox 和 AssistantConversation。', z
|
|
110
|
+
.object({
|
|
111
|
+
userMessageId: z.string().min(1),
|
|
112
|
+
messageId: z.string().min(1),
|
|
113
|
+
})
|
|
114
|
+
.strict(), (input) => store.linkDiscoveryFeedback(input.userMessageId, input.messageId));
|
|
106
115
|
register('Sleep', '结束本轮并休眠,新 Inbox 消息自动唤醒,不支持设置唤醒时间。还有未投递消息时返回 sleeping=false 和原因,循环继续;成功休眠不要求先发送消息,也不代表后台任务已完成。', z.object({}), (_, call) => bot.sleep(call.turnId), false, true);
|
|
107
116
|
register('AssistantConversation', '读取用户可见的助手交流历史,理解既有约定、避免重复。内部工具执行不等于用户已经收到消息。', z.object({
|
|
108
117
|
offset: z.number().int().nonnegative().default(0),
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { DatabaseSync } from 'node:sqlite';
|
|
20
20
|
import { mkdirSync, chmodSync } from 'node:fs';
|
|
21
21
|
import { join } from 'node:path';
|
|
22
|
+
import { assistantBatchOutputTurnId, assistantOutputTurnId } from './turn-ids.js';
|
|
22
23
|
/** Durable incoming messages; delivery cursors are not task completion state. */
|
|
23
24
|
export class BotStore {
|
|
24
25
|
db;
|
|
@@ -32,6 +33,9 @@ export class BotStore {
|
|
|
32
33
|
type TEXT NOT NULL, source TEXT NOT NULL, at INTEGER NOT NULL, task TEXT,
|
|
33
34
|
content TEXT NOT NULL);
|
|
34
35
|
CREATE TABLE IF NOT EXISTS metadata(key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
36
|
+
CREATE TABLE IF NOT EXISTS discovery_messages(message_id TEXT PRIMARY KEY, discovery_ids TEXT NOT NULL, delivered_at INTEGER);
|
|
37
|
+
CREATE TABLE IF NOT EXISTS discovery_feedback(user_id TEXT NOT NULL, message_id TEXT NOT NULL,
|
|
38
|
+
PRIMARY KEY(user_id,message_id));
|
|
35
39
|
CREATE TABLE IF NOT EXISTS outbox_batches(id TEXT PRIMARY KEY, payload TEXT NOT NULL);
|
|
36
40
|
CREATE TABLE IF NOT EXISTS outbox(id TEXT PRIMARY KEY, payload TEXT NOT NULL, delivered INTEGER NOT NULL DEFAULT 0);`);
|
|
37
41
|
}
|
|
@@ -175,7 +179,14 @@ export class BotStore {
|
|
|
175
179
|
const serialize = (items) => JSON.stringify(items.map((entry) => ({
|
|
176
180
|
text: entry.text,
|
|
177
181
|
...(entry.summary !== undefined ? { summary: entry.summary } : {}),
|
|
182
|
+
...(entry.discoveryIds?.length
|
|
183
|
+
? { discoveryIds: [...new Set(entry.discoveryIds)].sort() }
|
|
184
|
+
: {}),
|
|
178
185
|
})));
|
|
186
|
+
for (const entry of texts)
|
|
187
|
+
for (const id of entry.discoveryIds ?? [])
|
|
188
|
+
if (!this.db.prepare("SELECT 1 FROM inbox WHERE id=? AND type='discovery'").get(id))
|
|
189
|
+
throw Error('discoveryIds must reference discovery messages in Inbox');
|
|
179
190
|
const payload = serialize(texts);
|
|
180
191
|
const old = this.db.prepare('SELECT payload FROM outbox_batches WHERE id=?').get(batchId);
|
|
181
192
|
if (old && serialize(JSON.parse(String(old.payload))) !== payload)
|
|
@@ -195,12 +206,18 @@ export class BotStore {
|
|
|
195
206
|
this.queueVisible({
|
|
196
207
|
type: 'assistant',
|
|
197
208
|
id,
|
|
198
|
-
turnId: texts.length === 1
|
|
209
|
+
turnId: texts.length === 1
|
|
210
|
+
? assistantOutputTurnId(batchId)
|
|
211
|
+
: assistantBatchOutputTurnId(batchId, index),
|
|
199
212
|
ts: timestamp,
|
|
200
213
|
text,
|
|
201
214
|
...(summary !== undefined ? { summary } : {}),
|
|
202
215
|
modelId: 'assistant-bot',
|
|
203
216
|
});
|
|
217
|
+
if (entry.discoveryIds?.length)
|
|
218
|
+
this.db
|
|
219
|
+
.prepare('INSERT OR IGNORE INTO discovery_messages(message_id,discovery_ids) VALUES(?,?)')
|
|
220
|
+
.run(id, JSON.stringify([...new Set(entry.discoveryIds)].sort()));
|
|
204
221
|
return id;
|
|
205
222
|
});
|
|
206
223
|
if (!old)
|
|
@@ -208,6 +225,53 @@ export class BotStore {
|
|
|
208
225
|
return ids;
|
|
209
226
|
});
|
|
210
227
|
}
|
|
228
|
+
discoveryDeliveries() {
|
|
229
|
+
return this.db
|
|
230
|
+
.prepare(`SELECT o.id,o.payload,d.discovery_ids,d.delivered_at FROM outbox o
|
|
231
|
+
JOIN discovery_messages d ON d.message_id=o.id WHERE o.delivered=1 ORDER BY o.rowid`)
|
|
232
|
+
.all()
|
|
233
|
+
.map((row) => {
|
|
234
|
+
const m = JSON.parse(String(row.payload));
|
|
235
|
+
return {
|
|
236
|
+
messageId: String(row.id),
|
|
237
|
+
discoveryIds: JSON.parse(String(row.discovery_ids)),
|
|
238
|
+
text: m.text,
|
|
239
|
+
at: new Date(Number(row.delivered_at)).toISOString(),
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
linkDiscoveryFeedback(userMessageId, messageId) {
|
|
244
|
+
// Both sides must be real messages. The Bot supplies the semantic relationship,
|
|
245
|
+
// never replacement user text or an inferred reply based on adjacency.
|
|
246
|
+
const user = this.db
|
|
247
|
+
.prepare("SELECT * FROM inbox WHERE id=? AND type='user_message' AND source='user'")
|
|
248
|
+
.get(userMessageId);
|
|
249
|
+
const visible = this.db.prepare('SELECT payload FROM outbox WHERE id=?').get(userMessageId);
|
|
250
|
+
const delivery = this.discoveryDeliveries().find((d) => d.messageId === messageId);
|
|
251
|
+
if (!user || !visible || JSON.parse(String(visible.payload)).origin || !delivery)
|
|
252
|
+
throw Error('Feedback requires an owner user message and a delivered discovery message');
|
|
253
|
+
if (Number(user.at) < Date.parse(delivery.at))
|
|
254
|
+
throw Error('Feedback must follow the delivered discovery message');
|
|
255
|
+
this.db
|
|
256
|
+
.prepare('INSERT OR IGNORE INTO discovery_feedback VALUES(?,?)')
|
|
257
|
+
.run(userMessageId, messageId);
|
|
258
|
+
return { recorded: true, userMessageId, messageId };
|
|
259
|
+
}
|
|
260
|
+
discoveryFeedback() {
|
|
261
|
+
return this.db
|
|
262
|
+
.prepare(`SELECT f.user_id,f.message_id,o.payload,i.at FROM discovery_feedback f
|
|
263
|
+
JOIN outbox o ON o.id=f.user_id JOIN inbox i ON i.id=f.user_id ORDER BY f.rowid`)
|
|
264
|
+
.all()
|
|
265
|
+
.map((row) => {
|
|
266
|
+
const m = JSON.parse(String(row.payload));
|
|
267
|
+
return {
|
|
268
|
+
id: String(row.user_id),
|
|
269
|
+
messageId: String(row.message_id),
|
|
270
|
+
text: m.displayText ?? m.text,
|
|
271
|
+
at: new Date(Number(row.at)).toISOString(),
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
}
|
|
211
275
|
pendingVisible() {
|
|
212
276
|
return this.db
|
|
213
277
|
.prepare('SELECT payload FROM outbox WHERE delivered=0 ORDER BY rowid')
|
|
@@ -215,7 +279,12 @@ export class BotStore {
|
|
|
215
279
|
.map((row) => JSON.parse(String(row.payload)));
|
|
216
280
|
}
|
|
217
281
|
delivered(id) {
|
|
218
|
-
this.
|
|
282
|
+
this.transaction(() => {
|
|
283
|
+
this.db.prepare('UPDATE outbox SET delivered=1 WHERE id=?').run(id);
|
|
284
|
+
this.db
|
|
285
|
+
.prepare('UPDATE discovery_messages SET delivered_at=COALESCE(delivered_at,?) WHERE message_id=?')
|
|
286
|
+
.run(Date.now(), id);
|
|
287
|
+
});
|
|
219
288
|
}
|
|
220
289
|
close() {
|
|
221
290
|
this.db.close();
|
|
@@ -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
|
+
import { createHash } from 'node:crypto';
|
|
20
|
+
/**
|
|
21
|
+
* Turn ids for the assistant conversation's bot-delivered messages.
|
|
22
|
+
*
|
|
23
|
+
* The Runtime Host admits a turn id only when it matches
|
|
24
|
+
* `^[A-Za-z0-9_-]{1,128}$` (`requireEntityId`), and the desktop can branch
|
|
25
|
+
* from any turn whose id it can read. The ids below therefore use dashes, and
|
|
26
|
+
* the caller-supplied parts (an external connector message id, or the model's
|
|
27
|
+
* batch `messageId`) are hashed rather than embedded as text.
|
|
28
|
+
*
|
|
29
|
+
* Legacy transcript rows were written with colon separators. Readers must
|
|
30
|
+
* accept both forms.
|
|
31
|
+
*/
|
|
32
|
+
const digest = (value) => createHash('sha256').update(value).digest('hex').slice(0, 48);
|
|
33
|
+
export const assistantInputTurnId = (messageId) => `assistant-input-${digest(messageId)}`;
|
|
34
|
+
export const legacyAssistantInputTurnId = (messageId) => `assistant-input:${messageId}`;
|
|
35
|
+
export const assistantOutputTurnId = (batchId) => `assistant-output-${digest(batchId)}`;
|
|
36
|
+
export const assistantBatchOutputTurnId = (batchId, index) => `assistant-output-batch-${digest(batchId)}-${index}`;
|
|
37
|
+
// The id is a fresh UUID minted by the bot, so it needs no hashing.
|
|
38
|
+
export const assistantErrorOutputTurnId = (id) => `assistant-output-error-${id}`;
|
|
@@ -184,6 +184,13 @@ export function registerAssistant(ctx, store, controller) {
|
|
|
184
184
|
totalCharacters: text.length,
|
|
185
185
|
};
|
|
186
186
|
});
|
|
187
|
+
ctx.api.register('assistant.allocate-workspace', async (input) => {
|
|
188
|
+
z.object({}).strict().parse(input);
|
|
189
|
+
controller.ready();
|
|
190
|
+
if (!ctx.allocateWorkspace)
|
|
191
|
+
throw Error('Assistant workspace allocation is unavailable');
|
|
192
|
+
return ctx.allocateWorkspace();
|
|
193
|
+
});
|
|
187
194
|
ctx.api.register('assistant.binding', () => ({ state: store.get(), bot: ctx.bot.status() }));
|
|
188
195
|
ctx.api.register('assistant.status', summary);
|
|
189
196
|
ctx.api.register('assistant.bind', async (input) => {
|