@mininglamp-oss/octo-runtime 1.1.5 → 1.1.7
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/apps/cli/dist/adapter-configurations.d.ts +4 -0
- package/apps/cli/dist/adapter-configurations.js +102 -0
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +1 -1
- package/apps/cli/dist/logs.js +8 -4
- package/apps/cli/dist/main.js +11 -5
- package/apps/cli/dist/output.js +5 -0
- package/apps/cli/dist/playboard.js +3 -2
- package/dist/public/dsh.d.ts +1 -1
- package/dist/public/dsh.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +17 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +20 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +32 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +161 -26
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +8 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +32 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-DYOJCNWF.js → chunk-CFKMMCO6.js} +6 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-UOQRXV3Q.js → chunk-LO34KB7D.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-V5W6ZTYC.js +151 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +17 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +8 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +8 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +10 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.js +12 -40
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +22 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +422 -135
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +6 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +19 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +15 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +12 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +91 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log-worker.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +13 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +40 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +20 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +102 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/logs.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +11 -5
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.js +102 -52
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +8 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +9 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.js +9 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +47 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +79 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +22 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +12 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +131 -43
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.d.ts +17 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +22 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.js +27 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +462 -228
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.js +42 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.js +28 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +16 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +4 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +12 -9
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +7 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +39 -22
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.d.ts +29 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.js +171 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +48 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +7 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.js +265 -38
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +19 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.d.ts +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.js +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +8 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +27 -15
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +17 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +217 -50
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +2 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +41 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts +2 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +53 -82
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.d.ts +12 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.js +133 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.js +76 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.d.ts +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.js +74 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.js +19 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.js +90 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +39 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.js +60 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +20 -8
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +10 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/transport/channel.js +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +11 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +8 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +18 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +138 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +180 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/node_modules/iconv-lite/encodings/utf32.js +314 -0
- package/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/node_modules/iconv-lite/lib/index.d.ts +129 -0
- package/node_modules/iconv-lite/lib/index.js +182 -0
- package/node_modules/iconv-lite/lib/streams.js +105 -0
- package/node_modules/iconv-lite/package.json +70 -0
- package/node_modules/iconv-lite/types/encodings.d.ts +425 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +680 -0
- package/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/semver/classes/index.js +7 -0
- package/node_modules/semver/classes/range.js +577 -0
- package/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/semver/functions/major.js +5 -0
- package/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/semver/index.js +93 -0
- package/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/semver/internal/re.js +223 -0
- package/node_modules/semver/package.json +78 -0
- package/node_modules/semver/preload.js +4 -0
- package/node_modules/semver/range.bnf +17 -0
- package/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/semver/ranges/valid.js +13 -0
- package/package.json +33 -27
- package/packages/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +57 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-G5PWGRL5.js +0 -209
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.js +0 -16
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js
CHANGED
|
@@ -15,6 +15,7 @@ import { TypingController } from "../presentation/typing.js";
|
|
|
15
15
|
import { ImRunProjector } from "../presentation/run-projector.js";
|
|
16
16
|
import { buildReasoningFrame } from "./reasoning-frame.js";
|
|
17
17
|
import { ImDeliveryDispatcher } from "../delivery/dispatcher.js";
|
|
18
|
+
import { ImDeliveryScope } from "../delivery/identity.js";
|
|
18
19
|
import { fetchBotEvents, ackBotEvent } from "./api/events.js";
|
|
19
20
|
import { parseCardAction } from "./card-action.js";
|
|
20
21
|
import { setTimeout as delay } from "node:timers/promises";
|
|
@@ -27,20 +28,25 @@ import { connectionFailure, ImConnectionError } from "./connection-error.js";
|
|
|
27
28
|
import { sendReadReceipt } from "./api/messages.js";
|
|
28
29
|
import { deliveryNoticeCard } from "../presentation/delivery-notice.js";
|
|
29
30
|
import { ImSendError } from "../delivery/text-send.js";
|
|
31
|
+
import { assistantOutputFingerprint } from "../application/context-gap.js";
|
|
30
32
|
import { observesImScope } from "./normalize.js";
|
|
31
33
|
import { prepareArtifacts } from "../delivery/artifacts.js";
|
|
32
34
|
import { uploadChatAttachment } from "./api/files.js";
|
|
35
|
+
import { MessageIdentityCache } from "./message-identities.js";
|
|
33
36
|
/** Octo IM 平台连接器:WuKong 与 Octo REST 适配;不是 MCP 连接器。 */
|
|
34
37
|
export class GatewayTransport {
|
|
35
38
|
config;
|
|
36
39
|
credentials;
|
|
37
40
|
callbacks;
|
|
41
|
+
deliveryOwner;
|
|
38
42
|
identity;
|
|
39
43
|
botId;
|
|
40
44
|
#detachAbort;
|
|
41
45
|
#closing;
|
|
42
46
|
#connection;
|
|
43
47
|
#spaceId = "";
|
|
48
|
+
#token;
|
|
49
|
+
#deliveryScope = new ImDeliveryScope();
|
|
44
50
|
get scopedConfig() {
|
|
45
51
|
return { ...this.config, spaceId: this.#spaceId };
|
|
46
52
|
}
|
|
@@ -51,18 +57,22 @@ export class GatewayTransport {
|
|
|
51
57
|
#api;
|
|
52
58
|
#delivery;
|
|
53
59
|
#polling;
|
|
60
|
+
#messageIdentityCache = new MessageIdentityCache();
|
|
54
61
|
#bindings = new Map();
|
|
55
|
-
constructor(config, credentials, callbacks
|
|
62
|
+
constructor(config, credentials, callbacks,
|
|
63
|
+
// Bot 生命周期与单次 WS 分离,用于未发送的回复和任务 REST 进度展示。
|
|
64
|
+
deliveryOwner) {
|
|
56
65
|
this.config = config;
|
|
57
66
|
this.credentials = credentials;
|
|
58
67
|
this.callbacks = callbacks;
|
|
68
|
+
this.deliveryOwner = deliveryOwner;
|
|
59
69
|
this.identity = imBotIdentity(config);
|
|
60
70
|
this.botId = config.bot_id;
|
|
61
71
|
}
|
|
62
72
|
get status() {
|
|
63
73
|
return {
|
|
64
74
|
connected: this.#connected,
|
|
65
|
-
cardDeliveries: this.#delivery?.receiptCount ?? 0
|
|
75
|
+
cardDeliveries: (this.deliveryOwner?.dispatcher ?? this.#delivery)?.receiptCount ?? 0
|
|
66
76
|
};
|
|
67
77
|
}
|
|
68
78
|
async start(signal) {
|
|
@@ -74,11 +84,24 @@ export class GatewayTransport {
|
|
|
74
84
|
if (!/^bf_[A-Za-z0-9_-]+$/.test(token))
|
|
75
85
|
throw new Error("IM_BOT_TOKEN_INVALID");
|
|
76
86
|
const principal = await verifyBotIdentity(this.config.api_url, token, signal);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
try {
|
|
88
|
+
if (principal.bot_uid !== this.config.bot_id)
|
|
89
|
+
throw new Error("IM_BOT_IDENTITY_MISMATCH");
|
|
90
|
+
this.callbacks.authorizeSpace?.(principal.space_id);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
// REST 不等待 WS 验证;但目标已明确被拒绝时,不能继续把旧任务交给该凭据。
|
|
94
|
+
// 只在明确身份/空间拒绝后撤销,网络失败、单纯换 token 和握手失败不走此分支。
|
|
95
|
+
this.deliveryOwner?.identity.revoke();
|
|
96
|
+
this.#deliveryScope.revoke();
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
signal.throwIfAborted();
|
|
100
|
+
this.#token = token;
|
|
80
101
|
this.#spaceId = principal.space_id;
|
|
81
102
|
this.identity = `${imBotIdentity(this.config)}:${encodeURIComponent(this.#spaceId)}`;
|
|
103
|
+
// 必须在身份核验及空间准入成功后推进代次;连接失败/再次重连不能复活旧代次。
|
|
104
|
+
this.#deliveryScope = this.deliveryOwner?.identity.accept(this.identity) ?? this.#deliveryScope;
|
|
82
105
|
const registration = await registerBot(this.config.api_url, token, signal);
|
|
83
106
|
const toolEnvironment = octoCliEnvironment(this.config.api_url, token);
|
|
84
107
|
if (signal.aborted)
|
|
@@ -99,20 +122,45 @@ export class GatewayTransport {
|
|
|
99
122
|
if (!acceptsImMessage(this.scopedConfig, message))
|
|
100
123
|
return;
|
|
101
124
|
let finalReply;
|
|
125
|
+
let finalOutputCovered = false;
|
|
126
|
+
let replyConnection = connection;
|
|
127
|
+
const deliverySignal = AbortSignal.any([
|
|
128
|
+
this.deliveryOwner?.signal ?? signal,
|
|
129
|
+
this.#deliveryScope.signal
|
|
130
|
+
]);
|
|
131
|
+
// 所有跨 WS 的任务 REST 分支共用同一工厂,避免失败卡/通知另走旧连接期限。
|
|
132
|
+
const restDelivery = (turnSignal = deliverySignal, obsolete) => new OctoConnector(this.config, token, AbortSignal.any([deliverySignal, turnSignal]), async () => { }, (requestSignal, send) => this.#dispatchRestDelivery(requestSignal, (authorized, botToken) => {
|
|
133
|
+
if (obsolete?.())
|
|
134
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
135
|
+
return send(authorized, botToken);
|
|
136
|
+
}));
|
|
137
|
+
const finalDispatcher = this.#delivery;
|
|
138
|
+
const replyDelivered = (effectKey) => {
|
|
139
|
+
const key = stableEffectKey(this.identity, message, effectKey, "text");
|
|
140
|
+
return (this.#deliveryScope.isConfirmed(key) ||
|
|
141
|
+
connection.isDelivered(key) ||
|
|
142
|
+
replyConnection.isDelivered(key));
|
|
143
|
+
};
|
|
102
144
|
let historyTurn;
|
|
103
|
-
const outputObserver = () => {
|
|
145
|
+
const outputObserver = (payload) => {
|
|
104
146
|
const turn = historyTurn;
|
|
105
147
|
if (!turn || !observesImScope(this.scopedConfig, message.channelId, message.channelType))
|
|
106
148
|
return undefined;
|
|
107
149
|
return (messageSeq) => {
|
|
108
|
-
if (
|
|
150
|
+
if (deliverySignal.aborted)
|
|
151
|
+
return;
|
|
152
|
+
const current = this.#currentDeliveryTransport(false);
|
|
153
|
+
if (!current)
|
|
109
154
|
return;
|
|
110
|
-
|
|
155
|
+
current.callbacks.onPosition?.({
|
|
111
156
|
conversationId: message.channelId,
|
|
112
157
|
conversationKind: message.channelType === 5 ? "thread" : "group",
|
|
113
158
|
messageSeq,
|
|
114
159
|
own: true,
|
|
115
|
-
turn
|
|
160
|
+
turn,
|
|
161
|
+
...(payload && turn.providerSessionId
|
|
162
|
+
? { outputFingerprint: assistantOutputFingerprint(payload) }
|
|
163
|
+
: {})
|
|
116
164
|
});
|
|
117
165
|
};
|
|
118
166
|
};
|
|
@@ -161,22 +209,19 @@ export class GatewayTransport {
|
|
|
161
209
|
botId: this.config.bot_id,
|
|
162
210
|
channelType: message.channelType
|
|
163
211
|
},
|
|
164
|
-
isReplyDelivered:
|
|
165
|
-
replyDeliveryUnknown: async (event, effectKey, replyEffectKey, deliverySignal) => {
|
|
166
|
-
|
|
167
|
-
|
|
212
|
+
isReplyDelivered: replyDelivered,
|
|
213
|
+
replyDeliveryUnknown: async (event, effectKey, replyEffectKey, deliverySignal, obsolete) => {
|
|
214
|
+
const noticeObsolete = () => deliverySignal.aborted || Boolean(obsolete?.()) || replyDelivered(replyEffectKey);
|
|
215
|
+
if (noticeObsolete())
|
|
168
216
|
return;
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
if (!sent &&
|
|
173
|
-
!connection.isDelivered(stableEffectKey(this.identity, message, replyEffectKey, "text")))
|
|
217
|
+
const rest = restDelivery(deliverySignal, noticeObsolete);
|
|
218
|
+
const sent = await rest.displayCard(message, deliveryNoticeCard(event), stableEffectKey(this.identity, message, effectKey, "delivery"), noticeObsolete);
|
|
219
|
+
if (!sent && !noticeObsolete())
|
|
174
220
|
throw new ImSendError("IM_DELIVERY_NOTICE_UNSUPPORTED", "failed");
|
|
175
221
|
},
|
|
176
|
-
replyFailure: async (event, effectKey) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const template = await this.#api.reasoningTemplate();
|
|
222
|
+
replyFailure: async (event, effectKey, options) => {
|
|
223
|
+
const rest = restDelivery(options?.signal, options?.obsolete);
|
|
224
|
+
const template = await rest.reasoningTemplate();
|
|
180
225
|
if (!template)
|
|
181
226
|
return;
|
|
182
227
|
const projector = new ImRunProjector(`channel:${effectKey}`, message.channelType === 1);
|
|
@@ -184,29 +229,41 @@ export class GatewayTransport {
|
|
|
184
229
|
const frame = buildReasoningFrame(projector.snapshot(), template);
|
|
185
230
|
if (!frame)
|
|
186
231
|
throw Error("IM_CARD_BUDGET_EXCEEDED");
|
|
187
|
-
await
|
|
232
|
+
await rest.card(message, template, frame, stableEffectKey(this.identity, message, effectKey, "error"), undefined, 1, false);
|
|
188
233
|
},
|
|
189
|
-
reply: async (text, effectKey) => {
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
234
|
+
reply: async (text, effectKey, options) => {
|
|
235
|
+
// 地址、身份及凭据仍冻结在原消息;只允许同身份的新连接接管未发送的回复。
|
|
236
|
+
// 空回复/失败等终态提示也遵守该轮取消,不能在 stop 后从等待中恢复发送。
|
|
237
|
+
const replySignal = options
|
|
238
|
+
? AbortSignal.any([deliverySignal, options.signal])
|
|
239
|
+
: deliverySignal;
|
|
240
|
+
if (options?.obsolete())
|
|
241
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
242
|
+
const current = await this.#resolveDeliveryTransport(replySignal);
|
|
243
|
+
if (options?.obsolete())
|
|
244
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
245
|
+
replyConnection = current.#connection;
|
|
193
246
|
const key = stableEffectKey(this.identity, message, effectKey ?? message.messageId, "text");
|
|
194
|
-
|
|
247
|
+
if (this.#deliveryScope.isConfirmed(key))
|
|
248
|
+
return;
|
|
249
|
+
await replyConnection.sendText(message.channelId, message.channelType, text, key, this.#spaceId, undefined, replySignal, outputObserver());
|
|
195
250
|
},
|
|
196
251
|
replyFinal: async (text, effectKey, options) => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
252
|
+
const finalSignal = options
|
|
253
|
+
? AbortSignal.any([deliverySignal, options.signal])
|
|
254
|
+
: deliverySignal;
|
|
255
|
+
// 在准备上传前也核验归属;网络重连不取消交付,但停止/换账号不能继续。
|
|
256
|
+
await this.#resolveDeliveryTransport(finalSignal);
|
|
201
257
|
if (options?.obsolete())
|
|
202
258
|
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
203
259
|
if (finalReply?.key !== effectKey)
|
|
204
260
|
finalReply = {
|
|
205
261
|
key: effectKey,
|
|
206
262
|
// 整个准备按 effect 缓存,发送重试不再次上传;链接变化必须先于 mention 偏移计算。
|
|
263
|
+
// 普通上传/成员查询故障在各准备函数内降级为正文;取消或身份撤销不能重建准备而复活。
|
|
207
264
|
value: (async () => {
|
|
208
265
|
const delivered = options
|
|
209
|
-
? await prepareArtifacts(text, options.artifacts, finalSignal, (bytes, name, mime, uploadSignal) => uploadChatAttachment(this.config.api_url, token, bytes, name, mime, uploadSignal))
|
|
266
|
+
? await prepareArtifacts(text, options.artifacts, finalSignal, (bytes, name, mime, uploadSignal) => uploadChatAttachment(this.config.api_url, token, bytes, name, mime, uploadSignal, this.#dispatchRestDelivery))
|
|
210
267
|
: { text, files: [] };
|
|
211
268
|
const failures = [];
|
|
212
269
|
// 每张文件卡有独立回执;整段准备只执行一次,文本重试不重复卡片或上传。
|
|
@@ -215,7 +272,10 @@ export class GatewayTransport {
|
|
|
215
272
|
if (options?.obsolete())
|
|
216
273
|
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
217
274
|
const key = stableEffectKey(this.identity, message, effectKey, `file:${index}`);
|
|
218
|
-
const receipt = await
|
|
275
|
+
const receipt = await finalDispatcher.deliver(key, async () => {
|
|
276
|
+
const current = await this.#resolveDeliveryTransport(finalSignal);
|
|
277
|
+
return current.#connection.sendFile(message.channelId, message.channelType, file, key, this.#spaceId, finalSignal, outputObserver(delivered.incomplete ? undefined : { type: 8, ...file }));
|
|
278
|
+
}, { obsolete: () => finalSignal.aborted || Boolean(options?.obsolete()) });
|
|
219
279
|
if (receipt.state !== "delivered")
|
|
220
280
|
failures.push(`${file.name.replace(/[\r\n\x60[\]<>]/g, "_").slice(0, 120)} (${receipt.state}: ${receipt.code ?? "IM_DELIVERY_UNKNOWN"})`);
|
|
221
281
|
}
|
|
@@ -223,6 +283,8 @@ export class GatewayTransport {
|
|
|
223
283
|
(failures.length
|
|
224
284
|
? `\n\nFile card delivery unconfirmed: ${failures.join("; ")}. The attachment download links above remain available; generation was not rerun.`
|
|
225
285
|
: "");
|
|
286
|
+
// 新增失败事实不在先前 assistant 中,不能因它由本机发送而过滤。
|
|
287
|
+
finalOutputCovered = !delivered.incomplete && failures.length === 0;
|
|
226
288
|
finalSignal.throwIfAborted();
|
|
227
289
|
return prepareFinalMention(finalText, async () => {
|
|
228
290
|
if ([2, 5].includes(message.channelType))
|
|
@@ -230,39 +292,58 @@ export class GatewayTransport {
|
|
|
230
292
|
apiUrl: this.config.api_url,
|
|
231
293
|
botToken: token,
|
|
232
294
|
groupNo: groupScope(message.channelId).groupNo,
|
|
295
|
+
dispatchRequest: this.#dispatchRestDelivery,
|
|
233
296
|
signal: finalSignal
|
|
234
297
|
});
|
|
235
|
-
const peer = await getJson(this.config.api_url, token, `/v1/bot/user/info?uid=${encodeURIComponent(message.fromUid)}`, AbortSignal.any([finalSignal, AbortSignal.timeout(5000)]), {
|
|
298
|
+
const peer = await getJson(this.config.api_url, token, `/v1/bot/user/info?uid=${encodeURIComponent(message.fromUid)}`, AbortSignal.any([finalSignal, AbortSignal.timeout(5000)]), {
|
|
299
|
+
maxResponseBytes: 64 << 10,
|
|
300
|
+
logRateLimit: false,
|
|
301
|
+
dispatchRequest: this.#dispatchRestDelivery
|
|
302
|
+
});
|
|
236
303
|
return peer?.uid === message.fromUid ? [peer] : [];
|
|
237
304
|
});
|
|
238
305
|
})()
|
|
239
306
|
};
|
|
240
307
|
const result = await finalReply.value;
|
|
241
|
-
|
|
242
|
-
throw new Error("IM_CONNECTION_REPLACED");
|
|
243
|
-
finalSignal.throwIfAborted();
|
|
308
|
+
const current = await this.#resolveDeliveryTransport(finalSignal);
|
|
244
309
|
if (options?.obsolete())
|
|
245
310
|
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
246
|
-
|
|
311
|
+
if (replyDelivered(effectKey))
|
|
312
|
+
return;
|
|
313
|
+
replyConnection = current.#connection;
|
|
314
|
+
await replyConnection.sendText(message.channelId, message.channelType, result.text, stableEffectKey(this.identity, message, effectKey, "text"), this.#spaceId, result.mention, finalSignal, outputObserver(finalOutputCovered
|
|
315
|
+
? {
|
|
316
|
+
type: 1,
|
|
317
|
+
content: result.text,
|
|
318
|
+
...(result.mention ? { mention: result.mention } : {})
|
|
319
|
+
}
|
|
320
|
+
: undefined));
|
|
247
321
|
},
|
|
248
322
|
buildContext: async (turnSignal, options) => ({
|
|
249
323
|
schema: CONTEXT_SCHEMA,
|
|
250
|
-
items: await build_im_contexts(this.scopedConfig, message, token, AbortSignal.any([signal, turnSignal]),
|
|
324
|
+
items: await build_im_contexts(this.scopedConfig, message, token, AbortSignal.any([signal, turnSignal]), {
|
|
325
|
+
...options,
|
|
326
|
+
initialSession: options?.initialSession ?? false,
|
|
327
|
+
identityCache: this.#messageIdentityCache
|
|
328
|
+
})
|
|
251
329
|
}),
|
|
252
330
|
beginPresentation: (runId, onDiagnostic, controls) => {
|
|
331
|
+
// 卡片是 REST,不以 WS 存活为前提。保留同一 CardSession 的消息 ID/序号,
|
|
332
|
+
// 仅 Bot 停止取消其请求;重连不将旧连接 signal 传入客户端或投递器。
|
|
333
|
+
const progressApi = restDelivery();
|
|
253
334
|
const interactions = new Map();
|
|
254
335
|
const resolveInteraction = async (id, status) => {
|
|
255
336
|
const entry = interactions.get(id);
|
|
256
337
|
if (!entry)
|
|
257
338
|
return;
|
|
258
|
-
const messageId = await
|
|
339
|
+
const messageId = await progressApi.interactionCard(message, interactionCard(entry.request, status), stableEffectKey(this.identity, message, id, "interaction"), entry.messageId);
|
|
259
340
|
// 能力不可用会返回 undefined;已显示卡片只有确认编辑成功后才能移除。
|
|
260
341
|
if (messageId !== entry.messageId)
|
|
261
342
|
throw new Error("IM_INTERACTION_CARD_FINALIZATION_UNCONFIRMED");
|
|
262
343
|
interactions.delete(id);
|
|
263
344
|
};
|
|
264
345
|
const stopTyping = this.config.typing === false ? () => { } : this.#typing.acquire(message, runId);
|
|
265
|
-
const card = new CardSession(
|
|
346
|
+
const card = new CardSession(progressApi, finalDispatcher, message, runId, stopTyping, onDiagnostic);
|
|
266
347
|
this.#bindings.set(runId, {
|
|
267
348
|
card,
|
|
268
349
|
address: message,
|
|
@@ -271,7 +352,8 @@ export class GatewayTransport {
|
|
|
271
352
|
expires: Date.now() + 86_400_000 + 30 * 60_000,
|
|
272
353
|
active: true,
|
|
273
354
|
turn: historyTurn,
|
|
274
|
-
interactions
|
|
355
|
+
interactions,
|
|
356
|
+
resolveInteraction
|
|
275
357
|
});
|
|
276
358
|
if (this.#bindings.size > 128) {
|
|
277
359
|
const idle = [...this.#bindings].find(([, binding]) => !binding.active);
|
|
@@ -282,11 +364,15 @@ export class GatewayTransport {
|
|
|
282
364
|
this.#polling = this.#pollActions(token, signal);
|
|
283
365
|
return {
|
|
284
366
|
interaction: async (request) => {
|
|
367
|
+
// 旧按钮轮询不迁移;已失去绑定的连接不再创建无法响应的新交互。
|
|
368
|
+
// 已开始的发卡及已存在卡片的收尾则继续使用任务 REST 期限。
|
|
369
|
+
if (this.#closed || signal.aborted)
|
|
370
|
+
return false;
|
|
285
371
|
const document = interactionCard(request);
|
|
286
372
|
const effect = stableEffectKey(this.identity, message, request.interactionId, "interaction");
|
|
287
373
|
let messageId;
|
|
288
374
|
const receipt = await this.#delivery.deliver(effect, async () => {
|
|
289
|
-
messageId = await
|
|
375
|
+
messageId = await progressApi.interactionCard(message, document, effect);
|
|
290
376
|
if (!messageId)
|
|
291
377
|
throw Error("IM_INTERACTION_CARD_UNAVAILABLE");
|
|
292
378
|
return messageId;
|
|
@@ -297,7 +383,13 @@ export class GatewayTransport {
|
|
|
297
383
|
request: structuredClone(request),
|
|
298
384
|
messageId: receipt.messageId
|
|
299
385
|
});
|
|
300
|
-
|
|
386
|
+
// REST 发卡期间 WS 可能已退出并清除按钮绑定。保留回执用于收尾,
|
|
387
|
+
// 但仅仍可处理按钮的原绑定算可用,否则由 Runtime 发送文字交互命令。
|
|
388
|
+
const binding = this.#bindings.get(runId);
|
|
389
|
+
return (!this.#closed &&
|
|
390
|
+
!signal.aborted &&
|
|
391
|
+
binding?.active === true &&
|
|
392
|
+
binding.interactions === interactions);
|
|
301
393
|
},
|
|
302
394
|
resolveInteraction,
|
|
303
395
|
update: (snapshot) => card.update(snapshot),
|
|
@@ -323,6 +415,8 @@ export class GatewayTransport {
|
|
|
323
415
|
throw new AggregateError(errors, "IM_PRESENTATION_FAILED");
|
|
324
416
|
}
|
|
325
417
|
finally {
|
|
418
|
+
// 仅保留按钮所需的轻量关联,避免卡片回调继续引用本轮投影上下文。
|
|
419
|
+
card.release();
|
|
326
420
|
const binding = this.#bindings.get(runId);
|
|
327
421
|
if (binding) {
|
|
328
422
|
binding.active = false;
|
|
@@ -357,14 +451,16 @@ export class GatewayTransport {
|
|
|
357
451
|
own,
|
|
358
452
|
...(binding?.turn ? { turn: binding.turn } : {})
|
|
359
453
|
});
|
|
360
|
-
}
|
|
454
|
+
},
|
|
455
|
+
// ACK 写入身份代次账本,旧连接释放后不丢失中间连接已确认的 effect。
|
|
456
|
+
(key) => this.#deliveryScope.confirm(key));
|
|
361
457
|
this.#connection = connection;
|
|
362
458
|
this.#api = new OctoConnector(this.config, token, signal, async (address, text, effectKey) => {
|
|
363
459
|
if (this.#closed || signal.aborted)
|
|
364
460
|
throw new Error("IM_CONNECTION_REPLACED");
|
|
365
461
|
await connection.sendText(address.channelId, address.channelType, text, effectKey, this.#spaceId);
|
|
366
462
|
});
|
|
367
|
-
this.#delivery = new ImDeliveryDispatcher(signal);
|
|
463
|
+
this.#delivery = this.deliveryOwner?.dispatcher ?? new ImDeliveryDispatcher(signal);
|
|
368
464
|
this.#typing = new TypingController((address, typingSignal) => this.#api.typing(address, typingSignal), () => this.callbacks.onDiagnostic?.("IM_TYPING_FAILED"));
|
|
369
465
|
const abort = () => {
|
|
370
466
|
void connection.close();
|
|
@@ -382,6 +478,73 @@ export class GatewayTransport {
|
|
|
382
478
|
throw new ImConnectionError("IM_DISCONNECTED", true);
|
|
383
479
|
this.#connected = true;
|
|
384
480
|
}
|
|
481
|
+
/** REST 消费 Bot 已持有的凭据;WS 清理/鉴权/握手均不影响其准入。 */
|
|
482
|
+
#dispatchRestDelivery = async (signal, send) => {
|
|
483
|
+
const requestSignal = AbortSignal.any([
|
|
484
|
+
signal,
|
|
485
|
+
this.#deliveryScope.signal,
|
|
486
|
+
...(this.deliveryOwner ? [this.deliveryOwner.signal] : [])
|
|
487
|
+
]);
|
|
488
|
+
try {
|
|
489
|
+
requestSignal.throwIfAborted();
|
|
490
|
+
const owner = this.deliveryOwner;
|
|
491
|
+
const current = owner?.current();
|
|
492
|
+
if (current &&
|
|
493
|
+
(imBotIdentity(current.config) !== imBotIdentity(this.config) ||
|
|
494
|
+
(current.#token && current.identity !== this.identity)))
|
|
495
|
+
throw new ImSendError("IM_CONNECTION_IDENTITY_CHANGED", "failed");
|
|
496
|
+
const token = owner?.token ? owner.token()?.trim() : this.#token;
|
|
497
|
+
if (!token)
|
|
498
|
+
throw new Error("IM_CREDENTIALS_REQUIRED");
|
|
499
|
+
if (!/^bf_[A-Za-z0-9_-]+$/.test(token))
|
|
500
|
+
throw new Error("IM_BOT_TOKEN_INVALID");
|
|
501
|
+
// 只读取已注入的值,不触发宿主获取/刷新;检查、替换头与 fetch 同步完成。
|
|
502
|
+
return send(requestSignal, token);
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
this.#deliveryScope.signal.throwIfAborted();
|
|
506
|
+
if (signal.aborted || this.deliveryOwner?.signal.aborted)
|
|
507
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
508
|
+
throw error;
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
/** 只选择完成鉴权的同身份连接;临时离线可等待,账号或凭据变化必须拒绝转投。 */
|
|
512
|
+
#currentDeliveryTransport(rejectIdentityChange = true) {
|
|
513
|
+
if (this.#deliveryScope.signal.aborted) {
|
|
514
|
+
if (rejectIdentityChange)
|
|
515
|
+
this.#deliveryScope.signal.throwIfAborted();
|
|
516
|
+
return undefined;
|
|
517
|
+
}
|
|
518
|
+
const current = this.deliveryOwner ? this.deliveryOwner.current() : this;
|
|
519
|
+
if (!current || current.#closed || !current.#connected || !current.#connection?.connected)
|
|
520
|
+
return undefined;
|
|
521
|
+
if (current.identity !== this.identity || current.#token !== this.#token) {
|
|
522
|
+
if (rejectIdentityChange)
|
|
523
|
+
throw new ImSendError("IM_CONNECTION_IDENTITY_CHANGED", "failed");
|
|
524
|
+
return undefined;
|
|
525
|
+
}
|
|
526
|
+
return current;
|
|
527
|
+
}
|
|
528
|
+
async #resolveDeliveryTransport(signal) {
|
|
529
|
+
const deadline = performance.now() + 15_000;
|
|
530
|
+
while (!signal.aborted) {
|
|
531
|
+
const current = this.#currentDeliveryTransport();
|
|
532
|
+
if (current)
|
|
533
|
+
return current;
|
|
534
|
+
// 等待发生在首次发送之前;已开始发送的 unknown 由原确认窗口处理,不能跨连接重放。
|
|
535
|
+
const remaining = deadline - performance.now();
|
|
536
|
+
if (!this.deliveryOwner || remaining <= 0)
|
|
537
|
+
throw new ImSendError("IM_CONNECTION_UNAVAILABLE", "failed");
|
|
538
|
+
try {
|
|
539
|
+
await delay(Math.min(100, remaining), undefined, { signal });
|
|
540
|
+
}
|
|
541
|
+
catch {
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
this.#deliveryScope.signal.throwIfAborted();
|
|
546
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
547
|
+
}
|
|
385
548
|
async #pollActions(token, signal) {
|
|
386
549
|
if (this.config.cards === false)
|
|
387
550
|
return;
|
|
@@ -437,9 +600,8 @@ export class GatewayTransport {
|
|
|
437
600
|
if (!binding.active || !binding.controls.respond)
|
|
438
601
|
continue;
|
|
439
602
|
await binding.controls.respond(interactionAnswer(interaction.request, action));
|
|
440
|
-
binding.interactions.delete(interaction.request.interactionId);
|
|
441
603
|
try {
|
|
442
|
-
await
|
|
604
|
+
await binding.resolveInteraction(interaction.request.interactionId, "resolved");
|
|
443
605
|
}
|
|
444
606
|
catch {
|
|
445
607
|
this.callbacks.onDiagnostic?.("IM_INTERACTION_CARD_FAILED");
|
|
@@ -502,9 +664,14 @@ export class GatewayTransport {
|
|
|
502
664
|
const errors = results
|
|
503
665
|
.filter((result) => result.status === "rejected")
|
|
504
666
|
.map((result) => result.reason);
|
|
667
|
+
// WS 重连只移除按钮关联;仍在运行的 REST 卡片由任务 finish 负责释放。
|
|
668
|
+
// 没有 Bot 所有者、Bot 已停止或任务已结束时,保留连接清理的兜底回收。
|
|
669
|
+
for (const binding of this.#bindings.values())
|
|
670
|
+
if (!binding.active || !this.deliveryOwner || this.deliveryOwner.signal.aborted)
|
|
671
|
+
binding.card.release();
|
|
672
|
+
this.#bindings.clear();
|
|
505
673
|
if (errors.length)
|
|
506
674
|
throw new AggregateError(errors, "IM_TRANSPORT_DISPOSE_FAILED");
|
|
507
|
-
this.#bindings.clear();
|
|
508
675
|
});
|
|
509
676
|
return this.#closing;
|
|
510
677
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseRetryAfterMs } from "./retry-after.js";
|
|
1
2
|
/** 只携带连接协议事实;恢复策略由 Bot 编排决定,不保留响应正文或凭据。 */
|
|
2
3
|
export class ImConnectionError extends Error {
|
|
3
4
|
retryable;
|
|
@@ -66,10 +67,7 @@ export async function connectionFetch(url, init, phase) {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
export async function httpConnectionFailure(response, phase) {
|
|
69
|
-
const
|
|
70
|
-
const seconds = retryAfter && /^\d+$/.test(retryAfter) ? Number(retryAfter) : undefined;
|
|
71
|
-
const date = retryAfter ? Date.parse(retryAfter) : NaN;
|
|
72
|
-
const retryAfterMs = Math.max(0, seconds !== undefined ? seconds * 1000 : date - Date.now());
|
|
70
|
+
const retryAfterMs = parseRetryAfterMs(response.headers.get("retry-after")) ?? 0;
|
|
73
71
|
await response.body?.cancel();
|
|
74
72
|
// 仅明确认证、资源/请求或协议错误停止;服务超时、冲突、限流及未知服务故障默认重试。
|
|
75
73
|
// 禁止重定向仍是接入约束,不能自动把凭据带到另一个地址。
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { ImAddress, OctoBotConfig } from "../contracts.js";
|
|
2
2
|
import type { ReasoningFrame, ReasoningTemplate } from "./reasoning-frame.js";
|
|
3
|
+
import { type HttpRequestDispatch } from "./api/client.js";
|
|
3
4
|
export declare class OctoConnector {
|
|
4
5
|
#private;
|
|
5
6
|
readonly config: OctoBotConfig;
|
|
6
7
|
readonly token: string;
|
|
7
8
|
readonly signal: AbortSignal;
|
|
8
9
|
readonly sendWsText: (address: ImAddress, text: string, effectKey: string) => Promise<void>;
|
|
9
|
-
|
|
10
|
+
readonly dispatchRequest?: HttpRequestDispatch | undefined;
|
|
11
|
+
constructor(config: OctoBotConfig, token: string, signal: AbortSignal, sendWsText: (address: ImAddress, text: string, effectKey: string) => Promise<void>, dispatchRequest?: HttpRequestDispatch | undefined);
|
|
10
12
|
reasoningTemplate(): Promise<ReasoningTemplate | undefined>;
|
|
11
|
-
requestSignal(signal?: AbortSignal): AbortSignal;
|
|
12
13
|
typing(address: ImAddress, signal: AbortSignal): Promise<void>;
|
|
13
14
|
text(address: ImAddress, text: string, effectKey: string): Promise<void>;
|
|
14
15
|
notification(address: ImAddress, text: string, effectKey: string): Promise<string>;
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Octo 出站适配:统一文本、typing 和模板卡片发送,以及服务端能力发现。
|
|
3
|
-
*
|
|
3
|
+
* 持有调用方提供的凭据与取消期限;任务 REST 可使用 Bot 期限,不依赖单次 WS 存活。
|
|
4
4
|
*/
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { getCardProfile, sendTemplateCardMessage, editTemplateCardMessage } from "./api/cards.js";
|
|
7
7
|
import { sendMessage, sendTyping } from "./api/messages.js";
|
|
8
8
|
import { selectReasoningTemplate } from "./cards.js";
|
|
9
9
|
import { postJson } from "./api/client.js";
|
|
10
|
+
import { ImSendError } from "../delivery/text-send.js";
|
|
10
11
|
export class OctoConnector {
|
|
11
12
|
config;
|
|
12
13
|
token;
|
|
13
14
|
signal;
|
|
14
15
|
sendWsText;
|
|
16
|
+
dispatchRequest;
|
|
15
17
|
#profile;
|
|
16
|
-
constructor(config, token, signal, sendWsText
|
|
18
|
+
constructor(config, token, signal, sendWsText,
|
|
19
|
+
// 跨 WS 的 REST 使用 Bot 持有凭据及任务期限,不把 WS 状态当作 HTTP 准入。
|
|
20
|
+
dispatchRequest) {
|
|
17
21
|
this.config = config;
|
|
18
22
|
this.token = token;
|
|
19
23
|
this.signal = signal;
|
|
20
24
|
this.sendWsText = sendWsText;
|
|
25
|
+
this.dispatchRequest = dispatchRequest;
|
|
21
26
|
}
|
|
22
27
|
async reasoningTemplate() {
|
|
23
28
|
if (this.config.cards === false)
|
|
@@ -27,21 +32,27 @@ export class OctoConnector {
|
|
|
27
32
|
const profile = await getCardProfile({
|
|
28
33
|
apiUrl: this.config.api_url,
|
|
29
34
|
botToken: this.token,
|
|
30
|
-
signal: this.
|
|
35
|
+
signal: this.signal,
|
|
36
|
+
dispatchRequest: this.#dispatch
|
|
31
37
|
});
|
|
32
38
|
const template = selectReasoningTemplate(profile);
|
|
33
39
|
this.#profile = { expires: Date.now() + 300_000, template };
|
|
34
40
|
return template;
|
|
35
41
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
// 3 秒 HTTP 预算从获准发出请求起算;准入回调直接执行 fetch,不返回异步许可。
|
|
43
|
+
#dispatch = (signal, send) => {
|
|
44
|
+
const owner = AbortSignal.any([this.signal, signal]);
|
|
45
|
+
owner.throwIfAborted();
|
|
46
|
+
const dispatch = (authorized, botToken) => send(AbortSignal.any([authorized, AbortSignal.timeout(3_000)]), botToken);
|
|
47
|
+
return this.dispatchRequest ? this.dispatchRequest(owner, dispatch) : dispatch(owner);
|
|
48
|
+
};
|
|
39
49
|
async typing(address, signal) {
|
|
40
50
|
await sendTyping({
|
|
41
51
|
apiUrl: this.config.api_url,
|
|
42
52
|
botToken: this.token,
|
|
43
53
|
...address,
|
|
44
|
-
signal
|
|
54
|
+
signal,
|
|
55
|
+
dispatchRequest: this.#dispatch
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
58
|
async text(address, text, effectKey) {
|
|
@@ -54,7 +65,8 @@ export class OctoConnector {
|
|
|
54
65
|
...address,
|
|
55
66
|
content: text,
|
|
56
67
|
clientMsgNo: effectKey,
|
|
57
|
-
signal: this.
|
|
68
|
+
signal: this.signal,
|
|
69
|
+
dispatchRequest: this.#dispatch
|
|
58
70
|
});
|
|
59
71
|
if (!receipt?.message_id)
|
|
60
72
|
throw new Error("IM_DELIVERY_RECEIPT_UNKNOWN");
|
|
@@ -72,9 +84,12 @@ export class OctoConnector {
|
|
|
72
84
|
const profile = await getCardProfile({
|
|
73
85
|
apiUrl: this.config.api_url,
|
|
74
86
|
botToken: this.token,
|
|
75
|
-
signal: this.
|
|
87
|
+
signal: this.signal,
|
|
88
|
+
dispatchRequest: this.#dispatch
|
|
76
89
|
});
|
|
77
|
-
|
|
90
|
+
// 身份代次撤销不是能力不支持;保留取消原因供调用方区分已阻止的旧身份写入。
|
|
91
|
+
this.signal.throwIfAborted();
|
|
92
|
+
if (obsolete?.())
|
|
78
93
|
return;
|
|
79
94
|
if (!profile.available ||
|
|
80
95
|
!profile.enabled ||
|
|
@@ -97,7 +112,20 @@ export class OctoConnector {
|
|
|
97
112
|
...(messageId
|
|
98
113
|
? { message_id: messageId, content_edit: JSON.stringify(payload) }
|
|
99
114
|
: { payload, client_msg_no: effectKey })
|
|
100
|
-
}, this.
|
|
115
|
+
}, this.signal, {
|
|
116
|
+
retryOn429: false,
|
|
117
|
+
dispatchRequest: (signal, send) => this.#dispatch(signal, (authorized, botToken) => {
|
|
118
|
+
if (obsolete?.())
|
|
119
|
+
throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
|
|
120
|
+
return send(authorized, botToken);
|
|
121
|
+
})
|
|
122
|
+
}).catch((error) => {
|
|
123
|
+
if (obsolete?.())
|
|
124
|
+
return undefined;
|
|
125
|
+
throw error;
|
|
126
|
+
});
|
|
127
|
+
if (obsolete?.() && !result)
|
|
128
|
+
return;
|
|
101
129
|
if (!messageId && !result?.message_id)
|
|
102
130
|
throw Error("IM_DELIVERY_RECEIPT_UNKNOWN");
|
|
103
131
|
return messageId ?? String(result.message_id);
|
|
@@ -110,7 +138,8 @@ export class OctoConnector {
|
|
|
110
138
|
templateRef: template.ref,
|
|
111
139
|
state: frame.state,
|
|
112
140
|
data: frame,
|
|
113
|
-
signal: this.
|
|
141
|
+
signal: this.signal,
|
|
142
|
+
dispatchRequest: this.#dispatch,
|
|
114
143
|
retryOn429: false
|
|
115
144
|
};
|
|
116
145
|
if (messageId) {
|