maka-agent 0.2.1-dev.91.20261018 → 0.2.2-dev.97.20261024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER-WIP +1 -1
- package/LICENSE +15 -11
- package/README.md +173 -1
- package/README.zh-CN.md +156 -0
- package/THIRD_PARTY_NOTICES.txt +12 -12
- package/dist/cli-core.js +1 -0
- package/dist/pi-goal.js +13 -0
- package/dist/pi-tui-runner.js +44 -1
- package/dist/run-command-core.js +256 -48
- package/dist/run-session-command.js +534 -0
- package/dist/run-session-result.js +38 -0
- package/dist/run-turn-outcome.js +174 -0
- package/dist/runtime-host-cli.js +32 -17
- package/dist/runtime-host-run-command.js +53 -165
- package/dist/runtime-host-run-mcp.js +3 -0
- package/dist/runtime-host-session-channel.js +3 -1
- package/dist/runtime-host-session-driver.js +5 -0
- package/dist/runtime-host-setup-command.js +114 -7
- package/dist/tui-copy-catalog.js +24 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
- package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
- package/node_modules/@maka/core/dist/bot-chat-settings.js +10 -1
- package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
- package/node_modules/@maka/core/dist/event-wait.js +75 -10
- package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
- package/node_modules/@maka/core/dist/goal.js +54 -2
- package/node_modules/@maka/core/dist/model-catalog.js +19 -1
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
- package/node_modules/@maka/core/dist/model-metadata.js +42 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
- package/node_modules/@maka/core/dist/provider-registry.js +16 -2
- package/node_modules/@maka/core/dist/runtime-event-store.js +0 -1
- package/node_modules/@maka/core/dist/runtime-event.js +24 -2
- package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
- package/node_modules/@maka/core/dist/session-checkin.js +31 -0
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
- package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
- package/node_modules/@maka/core/dist/turn-origin.js +14 -2
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +3 -0
- package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/mcp/package.json +1 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +5 -1
- package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +29 -15
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +125 -131
- package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
- package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
- package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
- package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
- package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +34 -4
- package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
- package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
- package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
- package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
- package/node_modules/@maka/runtime/dist/model-history.js +16 -3
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +15 -5
- package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +2 -0
- package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
- package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
- package/node_modules/@maka/runtime/dist/sandbox-boundary-path.js +79 -2
- package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +5 -1
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
- package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
- package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
- package/node_modules/@maka/runtime/dist/tool-runtime.js +11 -2
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/runtime/package.json +3 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +92 -22
- package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +203 -71
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +21 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +37 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +68 -14
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +93 -23
- package/node_modules/@maka/runtime-host/dist/assistant/service.js +72 -16
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
- package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
- package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -3
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
- package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-settings-tools.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +151 -20
- package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +127 -11
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +343 -53
- package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +457 -0
- package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
- package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
- package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
- package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +8 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
- package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
- package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
- package/node_modules/@maka/storage/dist/agent-run-store-contract.js +14 -3
- package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
- package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
- package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +39 -1
- package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
- package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
- package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +27 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
- package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +116 -16
- package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
- package/node_modules/@maka/storage/dist/session-store.js +37 -8
- package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
- package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
- package/node_modules/@maka/storage/dist/sqlite-event-wait-authority.js +81 -8
- package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
- package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +38 -162
- package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
- package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
- package/node_modules/@maka/storage/package.json +4 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
- package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/package.json +5 -5
- package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
- package/node_modules/fast-uri/README.md +8 -0
- package/node_modules/fast-uri/index.js +98 -18
- package/node_modules/fast-uri/lib/utils.js +52 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/ip-address/README.md +104 -104
- package/node_modules/ip-address/dist/ipv4.js +7 -0
- package/node_modules/ip-address/dist/ipv6.js +7 -4
- package/node_modules/ip-address/dist/v6/constants.js +3 -0
- package/node_modules/ip-address/package.json +2 -1
- package/node_modules/undici/README.md +25 -3
- package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/undici/package.json +9 -7
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
|
@@ -16,9 +16,23 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { createHash } from 'node:crypto';
|
|
19
20
|
import { createRequire } from 'node:module';
|
|
20
21
|
import { BaseBotAdapter, botReadinessFromSettings } from './base-adapter.js';
|
|
21
22
|
const HANDSHAKE_TIMEOUT_MS = 15_000;
|
|
23
|
+
/** Bound network requests only; this does not limit Agent execution time. */
|
|
24
|
+
export function feishuHttpTransport(base) {
|
|
25
|
+
return {
|
|
26
|
+
...base,
|
|
27
|
+
request(options) {
|
|
28
|
+
const auxiliary = /\/(reactions|read_users)(?:\/|$)/.test(options.url ?? '');
|
|
29
|
+
return base.request({
|
|
30
|
+
...options,
|
|
31
|
+
timeout: options.timeout ?? (auxiliary ? 3_000 : 15_000),
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
22
36
|
/**
|
|
23
37
|
* `LarkChannel.disconnect()` is a no-op until its first handshake marks the
|
|
24
38
|
* channel connected. Close the raw socket first so a failed or cancelled
|
|
@@ -34,26 +48,89 @@ export async function closeLarkChannel(channel) {
|
|
|
34
48
|
await channel.disconnect().catch(() => { });
|
|
35
49
|
}
|
|
36
50
|
export function feishuMessageToEvent(message, receivedAt) {
|
|
37
|
-
|
|
51
|
+
const resource = message.resources?.[0];
|
|
52
|
+
const mediaOnly = ['image', 'file', 'audio', 'media', 'sticker'].includes(message.rawContentType);
|
|
53
|
+
if ((!message.content.trim() && !resource) || !message.senderId || !message.chatId)
|
|
38
54
|
return null;
|
|
55
|
+
const kinds = {
|
|
56
|
+
image: 'photo',
|
|
57
|
+
file: 'document',
|
|
58
|
+
audio: 'voice',
|
|
59
|
+
video: 'video',
|
|
60
|
+
sticker: 'sticker',
|
|
61
|
+
};
|
|
39
62
|
return {
|
|
40
63
|
platform: 'feishu',
|
|
41
64
|
userId: message.senderId,
|
|
42
65
|
userName: message.senderName ?? message.senderId,
|
|
43
66
|
chatId: message.chatId,
|
|
44
67
|
isGroup: message.chatType === 'group',
|
|
45
|
-
text: message.content,
|
|
68
|
+
text: mediaOnly ? '' : message.content,
|
|
46
69
|
sourceMessageId: message.messageId,
|
|
47
70
|
receivedAt,
|
|
71
|
+
...(resource ? { attachmentKind: kinds[resource.type] } : {}),
|
|
48
72
|
};
|
|
49
73
|
}
|
|
74
|
+
/** Only summaries use cards; ordinary replies use Markdown posts. Retry IDs stay stable. */
|
|
75
|
+
export function feishuAssistantMessages(text, options) {
|
|
76
|
+
const chunks = [];
|
|
77
|
+
let chunk = '', bytes = 0;
|
|
78
|
+
for (const char of text) {
|
|
79
|
+
const size = Buffer.byteLength(JSON.stringify(char));
|
|
80
|
+
if (bytes + size > 12_000 && chunk) {
|
|
81
|
+
chunks.push(chunk);
|
|
82
|
+
chunk = '';
|
|
83
|
+
bytes = 0;
|
|
84
|
+
}
|
|
85
|
+
chunk += char;
|
|
86
|
+
bytes += size;
|
|
87
|
+
}
|
|
88
|
+
if (chunk || !chunks.length)
|
|
89
|
+
chunks.push(chunk);
|
|
90
|
+
return chunks.map((content, index) => {
|
|
91
|
+
const body = { tag: 'markdown', content };
|
|
92
|
+
const summary = options.summary?.trim();
|
|
93
|
+
// Oversize summaries fall back to the complete body, never truncated text.
|
|
94
|
+
const elements = summary && Buffer.byteLength(JSON.stringify(summary)) < 6_000
|
|
95
|
+
? [
|
|
96
|
+
{ tag: 'markdown', content: summary },
|
|
97
|
+
{
|
|
98
|
+
tag: 'collapsible_panel',
|
|
99
|
+
expanded: false,
|
|
100
|
+
header: {
|
|
101
|
+
title: {
|
|
102
|
+
tag: 'plain_text',
|
|
103
|
+
content: chunks.length > 1 ? `详情 ${index + 1}/${chunks.length}` : '详情',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
elements: [body],
|
|
107
|
+
},
|
|
108
|
+
]
|
|
109
|
+
: [body];
|
|
110
|
+
return {
|
|
111
|
+
msg_type: summary ? 'interactive' : 'post',
|
|
112
|
+
content: JSON.stringify(summary
|
|
113
|
+
? { schema: '2.0', body: { elements } }
|
|
114
|
+
: { zh_cn: { title: '', content: [[{ tag: 'md', text: content }]] } }),
|
|
115
|
+
uuid: createHash('sha256')
|
|
116
|
+
.update(`${options.clientMessageId}:${index}`)
|
|
117
|
+
.digest('hex')
|
|
118
|
+
.slice(0, 50),
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
50
122
|
/** Feishu/Lark long-connection bridge backed by the official Channel API. */
|
|
51
123
|
export class FeishuBotBridge extends BaseBotAdapter {
|
|
124
|
+
loadSdk;
|
|
52
125
|
channel = null;
|
|
53
126
|
unsubscribe = [];
|
|
54
127
|
explicitlyStopped = false;
|
|
55
|
-
|
|
128
|
+
lastMessage = new Map();
|
|
129
|
+
reactions = new Map();
|
|
130
|
+
reactionQueue = Promise.resolve();
|
|
131
|
+
constructor(settings, loadSdk = () => createRequire(import.meta.url)('@larksuiteoapi/node-sdk')) {
|
|
56
132
|
super('feishu', settings);
|
|
133
|
+
this.loadSdk = loadSdk;
|
|
57
134
|
}
|
|
58
135
|
async start() {
|
|
59
136
|
if (this.running)
|
|
@@ -75,13 +152,15 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
75
152
|
let channel;
|
|
76
153
|
try {
|
|
77
154
|
// Keep lazy loading synchronous so stop() cannot race a module-loading await.
|
|
78
|
-
const { Domain, LoggerLevel, createLarkChannel } =
|
|
155
|
+
const { Domain, LoggerLevel, createLarkChannel, defaultHttpInstance } = this.loadSdk();
|
|
79
156
|
const isLark = this.settings.domain?.trim() === 'larksuite.com';
|
|
80
157
|
channel = createLarkChannel({
|
|
81
158
|
appId,
|
|
82
159
|
appSecret,
|
|
83
160
|
domain: isLark ? Domain.Lark : Domain.Feishu,
|
|
84
161
|
transport: 'websocket',
|
|
162
|
+
// The SDK transport unwraps Axios responses in its response interceptor.
|
|
163
|
+
httpInstance: feishuHttpTransport(defaultHttpInstance),
|
|
85
164
|
source: 'maka',
|
|
86
165
|
loggerLevel: LoggerLevel.error,
|
|
87
166
|
handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS,
|
|
@@ -113,6 +192,9 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
113
192
|
async stop() {
|
|
114
193
|
this.explicitlyStopped = true;
|
|
115
194
|
this.running = false;
|
|
195
|
+
await this.reactionQueue;
|
|
196
|
+
await Promise.all([...this.reactions.keys()].map((chat) => this.cancelTypingIndicator(chat)));
|
|
197
|
+
this.lastMessage.clear();
|
|
116
198
|
const channel = this.channel;
|
|
117
199
|
this.channel = null;
|
|
118
200
|
this.clearSubscriptions();
|
|
@@ -127,12 +209,34 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
127
209
|
if (!channel || !this.running || !chatId.trim())
|
|
128
210
|
return null;
|
|
129
211
|
try {
|
|
130
|
-
|
|
212
|
+
let messageId;
|
|
213
|
+
if (options?.clientMessageId) {
|
|
214
|
+
let firstId;
|
|
215
|
+
for (const message of feishuAssistantMessages(text, options)) {
|
|
216
|
+
const result = await channel.rawClient.im.v1.message.create({
|
|
217
|
+
params: { receive_id_type: chatId.startsWith('ou_') ? 'open_id' : 'chat_id' },
|
|
218
|
+
data: {
|
|
219
|
+
receive_id: chatId,
|
|
220
|
+
msg_type: message.msg_type,
|
|
221
|
+
content: message.content,
|
|
222
|
+
uuid: message.uuid,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
if (result.code !== 0 || !result.data?.message_id)
|
|
226
|
+
throw Error(`Feishu send failed: ${result.code}`);
|
|
227
|
+
firstId ??= result.data.message_id;
|
|
228
|
+
}
|
|
229
|
+
messageId = firstId;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const result = await channel.send(chatId, { markdown: text }, options?.replyToMessageId ? { replyTo: options.replyToMessageId } : undefined);
|
|
233
|
+
messageId = result.messageId;
|
|
234
|
+
}
|
|
131
235
|
this.readiness = 'operational';
|
|
132
236
|
this.reason = undefined;
|
|
133
237
|
this.lastEventAt = Date.now();
|
|
134
238
|
this.emitStatusChange();
|
|
135
|
-
return
|
|
239
|
+
return messageId;
|
|
136
240
|
}
|
|
137
241
|
catch (error) {
|
|
138
242
|
this.readiness = this.readiness === 'operational' ? 'degraded' : 'credentials_valid';
|
|
@@ -141,6 +245,61 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
141
245
|
return null;
|
|
142
246
|
}
|
|
143
247
|
}
|
|
248
|
+
/** Feishu has message reactions rather than a native chat typing API. */
|
|
249
|
+
sendTypingIndicator(chatId) {
|
|
250
|
+
return this.queueReaction(async () => {
|
|
251
|
+
const channel = this.channel;
|
|
252
|
+
const message = this.lastMessage.get(chatId);
|
|
253
|
+
if (!channel || !this.running || !message)
|
|
254
|
+
return false;
|
|
255
|
+
const current = this.reactions.get(chatId);
|
|
256
|
+
if (current?.message === message)
|
|
257
|
+
return true;
|
|
258
|
+
if (current) {
|
|
259
|
+
await channel.removeReaction(current.message, current.reaction);
|
|
260
|
+
this.reactions.delete(chatId);
|
|
261
|
+
}
|
|
262
|
+
const reaction = await channel.addReaction(message, 'Typing');
|
|
263
|
+
this.reactions.set(chatId, { message, reaction });
|
|
264
|
+
return true;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
cancelTypingIndicator(chatId) {
|
|
268
|
+
return this.queueReaction(async () => {
|
|
269
|
+
const current = this.reactions.get(chatId);
|
|
270
|
+
if (!current)
|
|
271
|
+
return true;
|
|
272
|
+
if (!this.channel)
|
|
273
|
+
return false;
|
|
274
|
+
await this.channel.removeReaction(current.message, current.reaction);
|
|
275
|
+
this.reactions.delete(chatId);
|
|
276
|
+
return true;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
queueReaction(work) {
|
|
280
|
+
const next = this.reactionQueue.then(work).catch(() => false);
|
|
281
|
+
this.reactionQueue = next;
|
|
282
|
+
return next;
|
|
283
|
+
}
|
|
284
|
+
async getMessageReadStatus(messageId, userId) {
|
|
285
|
+
if (!this.channel || !this.running)
|
|
286
|
+
return { state: 'unknown' };
|
|
287
|
+
try {
|
|
288
|
+
const result = await this.channel.rawClient.im.v1.message.readUsers({
|
|
289
|
+
path: { message_id: messageId },
|
|
290
|
+
params: { user_id_type: 'open_id', page_size: 100 },
|
|
291
|
+
});
|
|
292
|
+
if (result.code !== 0)
|
|
293
|
+
return { state: 'unknown' };
|
|
294
|
+
const user = result.data?.items?.find((entry) => entry.user_id === userId);
|
|
295
|
+
if (user)
|
|
296
|
+
return { state: 'read' };
|
|
297
|
+
return { state: result.data?.has_more || !result.data ? 'unknown' : 'unread' };
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return { state: 'unknown' };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
144
303
|
updateSettings(next) {
|
|
145
304
|
const needsRestart = next.enabled !== this.settings.enabled ||
|
|
146
305
|
next.appId !== this.settings.appId ||
|
|
@@ -165,6 +324,19 @@ export class FeishuBotBridge extends BaseBotAdapter {
|
|
|
165
324
|
const event = feishuMessageToEvent(message, receivedAt);
|
|
166
325
|
if (!event || this.channel !== channel)
|
|
167
326
|
return;
|
|
327
|
+
const assistant = this.settings.messageHandling === 'assistant';
|
|
328
|
+
if (assistant &&
|
|
329
|
+
(event.isGroup ||
|
|
330
|
+
this.settings.allowedUserIds?.length !== 1 ||
|
|
331
|
+
this.settings.allowedUserIds[0] !== event.userId))
|
|
332
|
+
return;
|
|
333
|
+
if (this.settings.allowedUserIds?.length &&
|
|
334
|
+
!this.settings.allowedUserIds.includes(event.userId))
|
|
335
|
+
return;
|
|
336
|
+
// DM sends use open_id; task-mode replies use chat_id.
|
|
337
|
+
this.lastMessage.set(assistant ? event.userId : event.chatId, event.sourceMessageId);
|
|
338
|
+
if (this.lastMessage.size > 500)
|
|
339
|
+
this.lastMessage.delete(this.lastMessage.keys().next().value);
|
|
168
340
|
if (!this.emitIncomingMessage(event))
|
|
169
341
|
return;
|
|
170
342
|
this.readiness = 'operational';
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { generalizedErrorMessage } from '@maka/core/redaction';
|
|
20
|
-
import { randomBytes, randomUUID } from 'node:crypto';
|
|
20
|
+
import { createHash, randomBytes, randomUUID } from 'node:crypto';
|
|
21
|
+
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
22
|
+
import { join } from 'node:path';
|
|
21
23
|
import { createRequire } from 'node:module';
|
|
22
24
|
import { BaseBotAdapter, botDiagnosticMessage, botReadinessFromSettings } from './base-adapter.js';
|
|
23
25
|
import { proxiedFetch } from './proxied-fetch.js';
|
|
@@ -73,9 +75,15 @@ export function normalizeWechatSendTarget(value) {
|
|
|
73
75
|
return target.length > 0 ? target : null;
|
|
74
76
|
}
|
|
75
77
|
export class WechatBridge extends BaseBotAdapter {
|
|
78
|
+
contextDirectory;
|
|
76
79
|
abortController = null;
|
|
77
|
-
|
|
80
|
+
contextTokens = new Map();
|
|
81
|
+
typingTickets = new Map();
|
|
82
|
+
typingQueue = Promise.resolve();
|
|
83
|
+
lifecycleStart = Promise.resolve();
|
|
84
|
+
constructor(settings, contextDirectory) {
|
|
78
85
|
super('wechat', settings);
|
|
86
|
+
this.contextDirectory = contextDirectory;
|
|
79
87
|
}
|
|
80
88
|
async start() {
|
|
81
89
|
if (this.running)
|
|
@@ -116,6 +124,8 @@ export class WechatBridge extends BaseBotAdapter {
|
|
|
116
124
|
this.emitStatusChange();
|
|
117
125
|
};
|
|
118
126
|
if (isWechatIlinkChannel(this.settings)) {
|
|
127
|
+
this.lifecycleStart = this.notifyLifecycle('start');
|
|
128
|
+
await this.restoreContexts();
|
|
119
129
|
void this.streamIlinkMessages('').catch(fail);
|
|
120
130
|
}
|
|
121
131
|
else {
|
|
@@ -123,13 +133,76 @@ export class WechatBridge extends BaseBotAdapter {
|
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
135
|
async stop() {
|
|
136
|
+
const wasRunning = this.running;
|
|
126
137
|
this.running = false;
|
|
127
138
|
this.abortController?.abort();
|
|
128
139
|
this.abortController = null;
|
|
140
|
+
await this.typingQueue;
|
|
141
|
+
await Promise.all([...this.typingTickets.keys()].map((id) => this.cancelTypingIndicator(id)));
|
|
142
|
+
this.contextTokens.clear();
|
|
143
|
+
this.typingTickets.clear();
|
|
144
|
+
if (wasRunning && isWechatIlinkChannel(this.settings)) {
|
|
145
|
+
await this.lifecycleStart;
|
|
146
|
+
await this.notifyLifecycle('stop');
|
|
147
|
+
}
|
|
129
148
|
this.reason = 'stopped';
|
|
130
149
|
this.readiness = botReadinessFromSettings(this.settings);
|
|
131
150
|
this.emitStatusChange();
|
|
132
151
|
}
|
|
152
|
+
async notifyLifecycle(kind) {
|
|
153
|
+
try {
|
|
154
|
+
const response = await wechatIlinkPost(this.settings.webhookUrl, `/ilink/bot/msg/notify${kind}`, { base_info: WECHAT_ILINK_BASE_INFO }, this.settings.token, undefined, 3000);
|
|
155
|
+
assertIlinkSuccess(response);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Presence is advisory: it must not disable an otherwise working channel.
|
|
159
|
+
console.warn(`[bots:wechat] notify${kind} failed`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
sendTypingIndicator(chatId) {
|
|
163
|
+
return this.setTyping(chatId, true);
|
|
164
|
+
}
|
|
165
|
+
cancelTypingIndicator(chatId) {
|
|
166
|
+
return this.setTyping(chatId, false);
|
|
167
|
+
}
|
|
168
|
+
setTyping(chatId, active) {
|
|
169
|
+
// Serialize start/cancel so a slow start request cannot land after cancellation.
|
|
170
|
+
const pending = this.typingQueue.then(async () => {
|
|
171
|
+
if (!isWechatIlinkChannel(this.settings) || (active && !this.running))
|
|
172
|
+
return false;
|
|
173
|
+
if (this.settings.allowedUserIds?.length && !this.settings.allowedUserIds.includes(chatId))
|
|
174
|
+
return false;
|
|
175
|
+
try {
|
|
176
|
+
const context = this.contextTokens.get(chatId);
|
|
177
|
+
let cached = this.typingTickets.get(chatId);
|
|
178
|
+
if (active && (!cached || cached.context !== context || Date.now() - cached.at > 300000)) {
|
|
179
|
+
const response = await wechatIlinkPost(this.settings.webhookUrl, '/ilink/bot/getconfig', { ilink_user_id: chatId, context_token: context, base_info: WECHAT_ILINK_BASE_INFO }, this.settings.token, undefined, 3000);
|
|
180
|
+
if (response.ret !== 0 ||
|
|
181
|
+
typeof response.typing_ticket !== 'string' ||
|
|
182
|
+
!response.typing_ticket)
|
|
183
|
+
return false;
|
|
184
|
+
cached = { context, ticket: response.typing_ticket, at: Date.now() };
|
|
185
|
+
this.typingTickets.set(chatId, cached);
|
|
186
|
+
}
|
|
187
|
+
if (!cached || (active && !this.running))
|
|
188
|
+
return false;
|
|
189
|
+
const response = await wechatIlinkPost(this.settings.webhookUrl, '/ilink/bot/sendtyping', {
|
|
190
|
+
ilink_user_id: chatId,
|
|
191
|
+
typing_ticket: cached.ticket,
|
|
192
|
+
status: active ? 1 : 2,
|
|
193
|
+
base_info: WECHAT_ILINK_BASE_INFO,
|
|
194
|
+
}, this.settings.token, undefined, 3000);
|
|
195
|
+
assertIlinkSuccess(response);
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
this.typingTickets.delete(chatId);
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
this.typingQueue = pending.catch(() => false);
|
|
204
|
+
return pending;
|
|
205
|
+
}
|
|
133
206
|
async sendMessage(chatId, text, _options) {
|
|
134
207
|
if (!this.running)
|
|
135
208
|
return null;
|
|
@@ -257,9 +330,21 @@ export class WechatBridge extends BaseBotAdapter {
|
|
|
257
330
|
cursor = nextCursor;
|
|
258
331
|
const messages = Array.isArray(response.msgs) ? response.msgs : [];
|
|
259
332
|
for (const message of messages) {
|
|
333
|
+
if (!this.running)
|
|
334
|
+
break;
|
|
260
335
|
const event = mapWechatIlinkMessage(message);
|
|
261
336
|
if (!event)
|
|
262
337
|
continue;
|
|
338
|
+
if (this.settings.allowedUserIds?.length &&
|
|
339
|
+
!this.settings.allowedUserIds.includes(event.userId))
|
|
340
|
+
continue;
|
|
341
|
+
const contextToken = stringField(message.context_token);
|
|
342
|
+
if (contextToken) {
|
|
343
|
+
this.contextTokens.set(event.userId, contextToken);
|
|
344
|
+
while (this.contextTokens.size > 1000)
|
|
345
|
+
this.contextTokens.delete(this.contextTokens.keys().next().value);
|
|
346
|
+
await this.saveContexts();
|
|
347
|
+
}
|
|
263
348
|
if (!this.emitIncomingMessage(event))
|
|
264
349
|
continue;
|
|
265
350
|
this.readiness = 'operational';
|
|
@@ -284,29 +369,77 @@ export class WechatBridge extends BaseBotAdapter {
|
|
|
284
369
|
}
|
|
285
370
|
}
|
|
286
371
|
}
|
|
372
|
+
contextPath() {
|
|
373
|
+
if (!this.contextDirectory)
|
|
374
|
+
return undefined;
|
|
375
|
+
const key = createHash('sha256')
|
|
376
|
+
.update(JSON.stringify([this.settings.webhookUrl, this.settings.botUserId, this.settings.token]))
|
|
377
|
+
.digest('hex');
|
|
378
|
+
return join(this.contextDirectory, `${key}.json`);
|
|
379
|
+
}
|
|
380
|
+
async restoreContexts() {
|
|
381
|
+
const path = this.contextPath();
|
|
382
|
+
if (!path)
|
|
383
|
+
return;
|
|
384
|
+
try {
|
|
385
|
+
const value = JSON.parse(await readFile(path, 'utf8'));
|
|
386
|
+
if (!Array.isArray(value))
|
|
387
|
+
throw Error('Invalid context cache');
|
|
388
|
+
this.contextTokens = new Map(value
|
|
389
|
+
.filter((v) => Array.isArray(v) && v.length === 2 && v.every((s) => typeof s === 'string'))
|
|
390
|
+
.slice(-1000));
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
if (error.code !== 'ENOENT')
|
|
394
|
+
console.warn('[bots:wechat] Could not restore reply context; waiting for a new message');
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
async saveContexts() {
|
|
398
|
+
const path = this.contextPath();
|
|
399
|
+
if (!path)
|
|
400
|
+
return;
|
|
401
|
+
try {
|
|
402
|
+
await mkdir(this.contextDirectory, { recursive: true, mode: 0o700 });
|
|
403
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
404
|
+
await writeFile(temporary, JSON.stringify([...this.contextTokens]), { mode: 0o600 });
|
|
405
|
+
await rename(temporary, path);
|
|
406
|
+
}
|
|
407
|
+
catch {
|
|
408
|
+
console.warn('[bots:wechat] Could not persist reply context; using in-memory context');
|
|
409
|
+
}
|
|
410
|
+
}
|
|
287
411
|
async sendIlinkMessage(chatId, text) {
|
|
288
412
|
const baseUrl = normalizeWechatIlinkBaseUrl(this.settings.webhookUrl);
|
|
289
413
|
const token = this.settings.token.trim();
|
|
290
414
|
if (!baseUrl || !token)
|
|
291
415
|
return null;
|
|
292
416
|
const clientId = randomUUID();
|
|
293
|
-
await wechatIlinkPost(baseUrl, '/ilink/bot/sendmessage', {
|
|
417
|
+
const response = await wechatIlinkPost(baseUrl, '/ilink/bot/sendmessage', {
|
|
294
418
|
msg: {
|
|
295
419
|
to_user_id: chatId,
|
|
296
420
|
from_user_id: '',
|
|
297
421
|
client_id: clientId,
|
|
298
422
|
message_type: 2,
|
|
299
423
|
message_state: 2,
|
|
300
|
-
context_token:
|
|
424
|
+
context_token: this.contextTokens.get(chatId),
|
|
301
425
|
item_list: [{ type: 1, text_item: { text: stripMarkdownForWechat(text) } }],
|
|
302
426
|
},
|
|
303
427
|
base_info: WECHAT_ILINK_BASE_INFO,
|
|
304
428
|
}, token);
|
|
429
|
+
if ((typeof response.ret === 'number' && response.ret !== 0) ||
|
|
430
|
+
(typeof response.errcode === 'number' && response.errcode !== 0)) {
|
|
431
|
+
throw new Error(`WeChat send failed: ret=${response.ret}, errcode=${response.errcode}`);
|
|
432
|
+
}
|
|
305
433
|
this.readiness = 'operational';
|
|
306
434
|
this.reason = undefined;
|
|
307
435
|
this.lastEventAt = Date.now();
|
|
308
436
|
this.emitStatusChange();
|
|
309
|
-
|
|
437
|
+
// Submission acknowledgement only; this is not a delivery/read receipt.
|
|
438
|
+
return typeof response.message_id === 'string' && response.message_id
|
|
439
|
+
? response.message_id
|
|
440
|
+
: Number.isSafeInteger(response.message_id)
|
|
441
|
+
? String(response.message_id)
|
|
442
|
+
: clientId;
|
|
310
443
|
}
|
|
311
444
|
}
|
|
312
445
|
export async function getWechatBridgeQrCode(channel) {
|
|
@@ -372,6 +505,8 @@ export function mapWechatIlinkMessage(raw) {
|
|
|
372
505
|
if (!raw || typeof raw !== 'object')
|
|
373
506
|
return null;
|
|
374
507
|
const message = raw;
|
|
508
|
+
if (message.message_type === 2 || message.group_id)
|
|
509
|
+
return null;
|
|
375
510
|
const itemList = Array.isArray(message.item_list) ? message.item_list : [];
|
|
376
511
|
const textParts = [];
|
|
377
512
|
let hasMedia = false;
|
|
@@ -403,7 +538,12 @@ export function mapWechatIlinkMessage(raw) {
|
|
|
403
538
|
if (!userId)
|
|
404
539
|
return null;
|
|
405
540
|
const messageId = firstStringField(message, ['msg_id', 'message_id', 'client_id', 'id']) ?? randomUUID();
|
|
406
|
-
const timestamp = firstNumberField(message, [
|
|
541
|
+
const timestamp = firstNumberField(message, [
|
|
542
|
+
'create_time_ms',
|
|
543
|
+
'create_time',
|
|
544
|
+
'timestamp',
|
|
545
|
+
'createdAt',
|
|
546
|
+
]);
|
|
407
547
|
return {
|
|
408
548
|
platform: 'wechat',
|
|
409
549
|
userId,
|
|
@@ -561,7 +701,7 @@ export async function testWechatIlinkCredentials(channel) {
|
|
|
561
701
|
function isWechatIlinkChannel(channel) {
|
|
562
702
|
return Boolean(normalizeWechatIlinkBaseUrl(channel.webhookUrl));
|
|
563
703
|
}
|
|
564
|
-
async function wechatIlinkPost(baseUrl, path, body, token, signal) {
|
|
704
|
+
async function wechatIlinkPost(baseUrl, path, body, token, signal, timeoutMs = WECHAT_ILINK_TIMEOUT_MS) {
|
|
565
705
|
const response = await proxiedFetch(`${baseUrl}${path}`, {
|
|
566
706
|
method: 'POST',
|
|
567
707
|
headers: {
|
|
@@ -573,12 +713,26 @@ async function wechatIlinkPost(baseUrl, path, body, token, signal) {
|
|
|
573
713
|
},
|
|
574
714
|
body: JSON.stringify(body),
|
|
575
715
|
signal,
|
|
576
|
-
timeoutMs: path.includes('getupdates') ? 0 :
|
|
716
|
+
timeoutMs: path.includes('getupdates') ? 0 : timeoutMs,
|
|
577
717
|
});
|
|
578
718
|
const text = await response.text();
|
|
579
719
|
if (!response.ok)
|
|
580
720
|
throw new Error(`HTTP ${response.status}: ${text}`);
|
|
581
|
-
|
|
721
|
+
// iLink IDs are uint64: preserve their original digits before Number rounding.
|
|
722
|
+
// sendTyping may acknowledge with an empty body.
|
|
723
|
+
if (!text.trim() && path.endsWith('/sendtyping'))
|
|
724
|
+
return {};
|
|
725
|
+
return JSON.parse(text, (key, value, context) => key === 'message_id' &&
|
|
726
|
+
typeof value === 'number' &&
|
|
727
|
+
context?.source &&
|
|
728
|
+
/^\d+$/.test(context.source)
|
|
729
|
+
? context.source
|
|
730
|
+
: value);
|
|
731
|
+
}
|
|
732
|
+
function assertIlinkSuccess(response) {
|
|
733
|
+
if ((typeof response.ret === 'number' && response.ret !== 0) ||
|
|
734
|
+
(typeof response.errcode === 'number' && response.errcode !== 0))
|
|
735
|
+
throw Error('WeChat request rejected');
|
|
582
736
|
}
|
|
583
737
|
function randomWechatUinHeader() {
|
|
584
738
|
return Buffer.from(String(randomBytes(4).readUInt32LE(0)), 'utf8').toString('base64');
|
|
@@ -20,20 +20,27 @@ import { declaredContextWindow, resolveModelLimits, modelLimitsConflict, } from
|
|
|
20
20
|
/**
|
|
21
21
|
* The shipped context-budget policy. It carries no history budget and no
|
|
22
22
|
* reserve: whether a request fits is the provider's answer, and the only
|
|
23
|
-
* proactive threshold is the
|
|
23
|
+
* default proactive threshold is the one the user declared for the model
|
|
24
24
|
* (see `resolveDeclaredContextWindow`), read by the compaction seam itself.
|
|
25
|
+
* A Host may opt a long-lived surface into a fallback target.
|
|
25
26
|
* What remains here are content policies — how one oversized Tool Result
|
|
26
27
|
* enters the request — and the compaction switches (#4559).
|
|
27
28
|
*/
|
|
28
29
|
export function buildDefaultContextBudgetPolicy(options = {}) {
|
|
29
30
|
const surfaceName = (options.name ?? 'default-history-budget').replace(/-default-history-budget$/, '');
|
|
31
|
+
const fallback = options.fallbackCompactionThresholdTokens;
|
|
30
32
|
return {
|
|
31
33
|
name: options.name ?? 'default-history-budget',
|
|
32
34
|
toolResultPrune: { enabled: true },
|
|
33
35
|
historyCompact: {
|
|
34
36
|
enabled: true,
|
|
35
37
|
highWaterName: `${surfaceName}-history-compact`,
|
|
36
|
-
midTurn: {
|
|
38
|
+
midTurn: {
|
|
39
|
+
enabled: true,
|
|
40
|
+
...(typeof fallback === 'number' && Number.isFinite(fallback) && fallback > 0
|
|
41
|
+
? { fallbackThresholdTokens: fallback }
|
|
42
|
+
: {}),
|
|
43
|
+
},
|
|
37
44
|
},
|
|
38
45
|
};
|
|
39
46
|
}
|
|
@@ -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
|
+
import { z } from 'zod';
|
|
20
|
+
export const EVENT_WAIT_TOOL_NAME = 'WaitForEvent';
|
|
21
|
+
const receipts = new WeakSet();
|
|
22
|
+
/** Only the internal tool can produce a live yield capability. Persisted JSON is not authority. */
|
|
23
|
+
export function isEventWaitYieldReceipt(value) {
|
|
24
|
+
return typeof value === 'object' && value !== null && receipts.has(value);
|
|
25
|
+
}
|
|
26
|
+
/** Host composition seam; exposed only with supported sources and valid Goal control. */
|
|
27
|
+
export function buildEventWaitTool(register) {
|
|
28
|
+
return {
|
|
29
|
+
name: EVENT_WAIT_TOOL_NAME,
|
|
30
|
+
description: 'Wait for a background Bash task in this Session and end this Turn. Requires an active Goal and direct tools. Use resource {providerId: "shell_run", connectionId: null, resourceType: "background_task", resourceId: the canonical maka://runtime/background-tasks/... ref}, condition {typeId: "terminal", version: 1, parameters: {}} and an explicit timeoutMs. Host continues the existing Goal when the task becomes terminal or the wait expires. Terminal does not mean command success or Goal achievement: inspect the result with Read. Expiry or cancelling the wait does not stop the task.',
|
|
31
|
+
parameters: z
|
|
32
|
+
.object({
|
|
33
|
+
resource: z
|
|
34
|
+
.object({
|
|
35
|
+
providerId: z.string(),
|
|
36
|
+
connectionId: z.string().nullable(),
|
|
37
|
+
resourceType: z.string(),
|
|
38
|
+
resourceId: z.string(),
|
|
39
|
+
})
|
|
40
|
+
.strict(),
|
|
41
|
+
condition: z
|
|
42
|
+
.object({
|
|
43
|
+
typeId: z.string(),
|
|
44
|
+
version: z.number().int().positive(),
|
|
45
|
+
parameters: z.record(z.string(), z.unknown()),
|
|
46
|
+
})
|
|
47
|
+
.strict(),
|
|
48
|
+
reason: z.string().min(1).max(500),
|
|
49
|
+
timeoutMs: z
|
|
50
|
+
.number()
|
|
51
|
+
.int()
|
|
52
|
+
.positive()
|
|
53
|
+
.max(7 * 24 * 60 * 60_000),
|
|
54
|
+
})
|
|
55
|
+
.strict(),
|
|
56
|
+
executionSemantics: 'exclusive_step',
|
|
57
|
+
nesting: 'direct_only',
|
|
58
|
+
recoveryMode: 'never_auto_retry',
|
|
59
|
+
impl: async (input, context) => {
|
|
60
|
+
const result = await register(input, context);
|
|
61
|
+
const receipt = Object.freeze({
|
|
62
|
+
kind: 'event_wait_registered',
|
|
63
|
+
...result,
|
|
64
|
+
});
|
|
65
|
+
receipts.add(receipt);
|
|
66
|
+
return receipt;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|