@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
|
@@ -4,21 +4,57 @@ import { shutdownDeadline, withinShutdown } from "@mininglamp-oss/octo-runtime-h
|
|
|
4
4
|
* 管理会话、排队、取消和交互归属;平台协议交给 connector,领域业务交给发起方。
|
|
5
5
|
*/
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
|
-
import { assertModelInputParts, failurePayload, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
|
7
|
+
import { assertModelInputParts, assertSessionName, failurePayload, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
|
8
8
|
import { ImImageInputError } from "../transport/image-input.js";
|
|
9
9
|
import { performance } from "node:perf_hooks";
|
|
10
10
|
import { imBotIdentity, validateImConfig } from "../lifecycle/configuration.js";
|
|
11
11
|
import { GatewayTransport } from "../transport/channel.js";
|
|
12
12
|
import { createImInvocation } from "../execution/dispatcher.js";
|
|
13
13
|
import { ImTask } from "../execution/task.js";
|
|
14
|
+
import { MODEL_WAIT_TIMEOUT_MESSAGE } from "../execution/model-wait.js";
|
|
15
|
+
import { ImDeliveryIdentity } from "../delivery/identity.js";
|
|
14
16
|
import { ImDeliveryDispatcher } from "../delivery/dispatcher.js";
|
|
15
17
|
import { ImRunProjector } from "../presentation/run-projector.js";
|
|
16
18
|
import { deliveryNotice } from "../presentation/delivery-notice.js";
|
|
17
19
|
import { MemoryImSessionStore } from "./session-store.js";
|
|
18
20
|
import { addRulesRecovery, selectRulesContext } from "./rules-context.js";
|
|
21
|
+
import { planStableContext } from "./stable-context.js";
|
|
19
22
|
import { groupScope } from "../transport/normalize.js";
|
|
20
23
|
import { connectionFailure, ImConnectionError } from "../transport/connection-error.js";
|
|
21
24
|
import { commitHistoryGap, gapMetadata, planHistoryGap, validMessageSeq } from "./context-gap.js";
|
|
25
|
+
function readableSessionName(message, current) {
|
|
26
|
+
if (current !== undefined) {
|
|
27
|
+
try {
|
|
28
|
+
assertSessionName(current);
|
|
29
|
+
return current;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// 修复旧版本已保存的非法展示名称,不触碰业务身份和原生恢复句柄。
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// 每个地址片段最多 80 个码点,最长群话题名称(含 UUID)不超过 215 个码点。
|
|
36
|
+
const displayPart = (value) => [...value]
|
|
37
|
+
.slice(0, 80)
|
|
38
|
+
.map((character) => {
|
|
39
|
+
const code = character.charCodeAt(0);
|
|
40
|
+
return code < 32 || (code >= 127 && code <= 159) ? "-" : character;
|
|
41
|
+
})
|
|
42
|
+
.join("") || "unknown";
|
|
43
|
+
const suffix = randomUUID();
|
|
44
|
+
const scope = groupScope(message.conversationId);
|
|
45
|
+
const name = message.conversationKind === "direct"
|
|
46
|
+
? `octo-dm-${displayPart(message.conversationId)}-${suffix}`
|
|
47
|
+
: message.conversationKind === "thread"
|
|
48
|
+
? `octo-group-${displayPart(scope.groupNo)}-topic-${displayPart(scope.shortId ?? message.conversationId)}-${suffix}`
|
|
49
|
+
: `octo-group-${displayPart(message.conversationId)}-${suffix}`;
|
|
50
|
+
assertSessionName(name);
|
|
51
|
+
return name;
|
|
52
|
+
}
|
|
53
|
+
// 仅精确匹配已定义的准备期原因;未知异常正文不得进入回复或新增诊断。
|
|
54
|
+
const preparationFailureMessages = new Map([
|
|
55
|
+
["IM_AGENT_WORKDIR_FIXED", "本轮工作目录与固定目录配置冲突,尚未发起执行。请检查工作目录配置。"],
|
|
56
|
+
["IM_RULE_PROTOCOL_INVALID", "规则数据格式不符合协议,尚未发起执行。请检查规则服务返回格式。"]
|
|
57
|
+
]);
|
|
22
58
|
export class ImRuntime {
|
|
23
59
|
dependencies;
|
|
24
60
|
#processEpoch = randomUUID();
|
|
@@ -27,6 +63,10 @@ export class ImRuntime {
|
|
|
27
63
|
config;
|
|
28
64
|
#connector;
|
|
29
65
|
#delivery;
|
|
66
|
+
#cardDelivery;
|
|
67
|
+
#deliveryIdentity;
|
|
68
|
+
// 宿主凭据来源是黑盒;沿原初始化/建联入口保存值,REST 不重新获取或等待 WS 核验。
|
|
69
|
+
#restToken;
|
|
30
70
|
#sessions = new Map();
|
|
31
71
|
#sessionStore;
|
|
32
72
|
#seen = new Map();
|
|
@@ -52,6 +92,8 @@ export class ImRuntime {
|
|
|
52
92
|
#failureNotifications = new Map();
|
|
53
93
|
#busyNotifiedAt = new Map();
|
|
54
94
|
#retry = 0;
|
|
95
|
+
#backoff = 0;
|
|
96
|
+
#fastRetriesRemaining = 0;
|
|
55
97
|
#disconnecting;
|
|
56
98
|
constructor(config, dependencies) {
|
|
57
99
|
this.dependencies = dependencies;
|
|
@@ -111,8 +153,14 @@ export class ImRuntime {
|
|
|
111
153
|
};
|
|
112
154
|
this.dependencies.signal?.addEventListener("abort", this.#ownerStopped, { once: true });
|
|
113
155
|
this.#delivery = new ImDeliveryDispatcher(this.#signal);
|
|
156
|
+
// 卡片/文件回执归 Bot,跨 WS 恢复复用同一有界缓存;与文本回执分开统计。
|
|
157
|
+
this.#cardDelivery = new ImDeliveryDispatcher(this.#signal);
|
|
158
|
+
this.#deliveryIdentity = new ImDeliveryIdentity();
|
|
159
|
+
this.#restToken = undefined;
|
|
114
160
|
}
|
|
115
161
|
this.#retry = 0;
|
|
162
|
+
this.#backoff = 0;
|
|
163
|
+
this.#fastRetriesRemaining = 0;
|
|
116
164
|
this.#error = undefined;
|
|
117
165
|
this.#state = "connecting";
|
|
118
166
|
this.#connecting = this.#connect(false);
|
|
@@ -129,6 +177,7 @@ export class ImRuntime {
|
|
|
129
177
|
this.#log(recovering ? "channel.retry_started" : "channel.connecting", {
|
|
130
178
|
attempt: this.#retry
|
|
131
179
|
});
|
|
180
|
+
// 只回收单次 WS;Bot 持有的 REST 凭据及任务展示不随连接清理暂停。
|
|
132
181
|
this.#connectionAbort?.abort();
|
|
133
182
|
try {
|
|
134
183
|
await this.#disconnecting;
|
|
@@ -147,7 +196,14 @@ export class ImRuntime {
|
|
|
147
196
|
const signal = AbortSignal.any([this.#signal, this.#connectionAbort.signal]);
|
|
148
197
|
let starting = true;
|
|
149
198
|
let disconnected;
|
|
150
|
-
const credentials =
|
|
199
|
+
const credentials = async (config, signal) => {
|
|
200
|
+
const token = await (this.dependencies.credentials
|
|
201
|
+
? this.dependencies.credentials(config, signal)
|
|
202
|
+
: Promise.resolve(config.bf_token));
|
|
203
|
+
signal.throwIfAborted();
|
|
204
|
+
this.#restToken = token?.trim();
|
|
205
|
+
return token;
|
|
206
|
+
};
|
|
151
207
|
const connector = new GatewayTransport(this.config, credentials, {
|
|
152
208
|
authorizeSpace: this.dependencies.authorizeSpace,
|
|
153
209
|
onPosition: (position) => {
|
|
@@ -176,6 +232,13 @@ export class ImRuntime {
|
|
|
176
232
|
if (!starting)
|
|
177
233
|
this.#lostConnection(connector, disconnected);
|
|
178
234
|
}
|
|
235
|
+
}, {
|
|
236
|
+
signal: this.#signal,
|
|
237
|
+
dispatcher: this.#cardDelivery,
|
|
238
|
+
identity: this.#deliveryIdentity,
|
|
239
|
+
token: () => this.#restToken,
|
|
240
|
+
// 只供旧任务选择本 Bot 当前连接;生命周期停止后旧 signal 不会随新 start 复活。
|
|
241
|
+
current: () => this.#connector
|
|
179
242
|
});
|
|
180
243
|
this.#connector = connector;
|
|
181
244
|
try {
|
|
@@ -191,12 +254,15 @@ export class ImRuntime {
|
|
|
191
254
|
this.#log("channel.connected", { state: "online" });
|
|
192
255
|
this.#error = undefined;
|
|
193
256
|
this.#retry = 0;
|
|
257
|
+
this.#backoff = 0;
|
|
258
|
+
this.#fastRetriesRemaining = 0;
|
|
194
259
|
}
|
|
195
260
|
catch (error) {
|
|
196
261
|
if (signal.aborted)
|
|
197
262
|
return;
|
|
198
263
|
starting = false;
|
|
199
264
|
const failure = connectionFailure(error);
|
|
265
|
+
// 注册/WS 握手失败只影响连接恢复,不撤销 Bot 已持有的 REST 凭据。
|
|
200
266
|
this.#connectionAbort.abort();
|
|
201
267
|
this.#error = failure.message;
|
|
202
268
|
// 首次离线与后续断线共用恢复;服务端断开不等于永久拒绝,由传输分类决定资格。
|
|
@@ -222,26 +288,37 @@ export class ImRuntime {
|
|
|
222
288
|
this.#state = retry ? "retrying" : "failed";
|
|
223
289
|
this.#log("channel.disconnected", { state: this.#state, code: failure.message });
|
|
224
290
|
this.#connectionAbort?.abort();
|
|
225
|
-
//
|
|
291
|
+
// 确认断线即退出 online;立即重连后追加最多十次 1 秒重试,覆盖换网恢复间隙。
|
|
292
|
+
// 关闭和旧回调不能再创建连接,回收失败须单独诊断,不能以加速为由重叠连接。
|
|
226
293
|
this.#disconnecting = connector.close();
|
|
227
294
|
void this.#disconnecting.then(() => {
|
|
228
|
-
if (retry)
|
|
229
|
-
this.#
|
|
295
|
+
if (retry) {
|
|
296
|
+
this.#fastRetriesRemaining = 10;
|
|
297
|
+
this.#scheduleReconnect(failure.retryAfterMs, true);
|
|
298
|
+
}
|
|
230
299
|
}, () => {
|
|
231
300
|
if (!this.#closed)
|
|
232
301
|
this.#state = "failed";
|
|
233
302
|
this.#diagnostic("IM_DISPOSE_FAILED");
|
|
234
303
|
});
|
|
235
304
|
}
|
|
236
|
-
#scheduleReconnect(retryAfterMs = 0) {
|
|
305
|
+
#scheduleReconnect(retryAfterMs = 0, immediate = false) {
|
|
237
306
|
if (this.#closed ||
|
|
238
307
|
this.#draining ||
|
|
239
308
|
this.#signal.aborted ||
|
|
240
309
|
this.#state !== "retrying" ||
|
|
241
310
|
this.#reconnect)
|
|
242
311
|
return;
|
|
243
|
-
|
|
312
|
+
// 快速重试仅用于上线后的断线恢复,不消耗常规退避档位;Retry-After 仍优先。
|
|
313
|
+
// 每次失败回收完成才安排下一次,慢握手或休眠恢复不会堆积并发连接。
|
|
314
|
+
const fast = !immediate && this.#fastRetriesRemaining > 0;
|
|
315
|
+
const baseDelayMs = immediate ? 0 : fast ? 1_000 : [5_000, 10_000, 15_000][this.#backoff];
|
|
316
|
+
const delayMs = Math.max(baseDelayMs, retryAfterMs);
|
|
244
317
|
this.#retry = Math.min(Number.MAX_SAFE_INTEGER, this.#retry + 1);
|
|
318
|
+
if (fast)
|
|
319
|
+
this.#fastRetriesRemaining--;
|
|
320
|
+
else if (!immediate)
|
|
321
|
+
this.#backoff = Math.min(2, this.#backoff + 1);
|
|
245
322
|
this.#log("channel.retry_scheduled", {
|
|
246
323
|
state: "retrying",
|
|
247
324
|
delay_ms: delayMs,
|
|
@@ -329,6 +406,24 @@ export class ImRuntime {
|
|
|
329
406
|
next.localOutputSeqs = [...new Set([...next.localOutputSeqs, position.messageSeq])]
|
|
330
407
|
.sort((left, right) => left - right)
|
|
331
408
|
.slice(-32);
|
|
409
|
+
const providerSessionId = position.turn?.providerSessionId;
|
|
410
|
+
if (position.own &&
|
|
411
|
+
position.outputFingerprint &&
|
|
412
|
+
providerSessionId &&
|
|
413
|
+
binding.providerSession?.sessionId === providerSessionId) {
|
|
414
|
+
const previous = next.assistantOutputs?.providerSessionId === providerSessionId
|
|
415
|
+
? next.assistantOutputs.messages
|
|
416
|
+
: [];
|
|
417
|
+
next.assistantOutputs = {
|
|
418
|
+
providerSessionId,
|
|
419
|
+
messages: [
|
|
420
|
+
...previous.filter((entry) => entry.seq !== position.messageSeq),
|
|
421
|
+
{ seq: position.messageSeq, fingerprint: position.outputFingerprint }
|
|
422
|
+
]
|
|
423
|
+
.sort((left, right) => left.seq - right.seq)
|
|
424
|
+
.slice(-32)
|
|
425
|
+
};
|
|
426
|
+
}
|
|
332
427
|
return next;
|
|
333
428
|
});
|
|
334
429
|
}
|
|
@@ -417,9 +512,11 @@ export class ImRuntime {
|
|
|
417
512
|
this.#finalDeliveries.get(key)?.abort();
|
|
418
513
|
this.#tasks.get(key)?.task.stopRetries();
|
|
419
514
|
session.id = binding.id;
|
|
515
|
+
session.sessionName = binding.sessionName;
|
|
420
516
|
session.generation = binding.generation;
|
|
421
517
|
session.providerSession = binding.providerSession;
|
|
422
518
|
session.initialization = { attempted: false };
|
|
519
|
+
session.stableContext = { turnCount: 0, refreshPending: true };
|
|
423
520
|
session.lastRunId = undefined;
|
|
424
521
|
void this.#reply(message, "会话已经重置", `control:${message.messageId}`, true).catch(() => {
|
|
425
522
|
this.#seen.delete(dedupe);
|
|
@@ -472,6 +569,7 @@ export class ImRuntime {
|
|
|
472
569
|
generation: 1,
|
|
473
570
|
...binding,
|
|
474
571
|
initialization: { attempted: binding?.initialContextPrepared === true },
|
|
572
|
+
stableContext: binding?.stableContext ?? { turnCount: 0, refreshPending: true },
|
|
475
573
|
pending: 0,
|
|
476
574
|
tail: Promise.resolve()
|
|
477
575
|
};
|
|
@@ -497,8 +595,6 @@ export class ImRuntime {
|
|
|
497
595
|
retry: (senderId, id) => {
|
|
498
596
|
if (!controls.failed)
|
|
499
597
|
return false;
|
|
500
|
-
if (!message.position)
|
|
501
|
-
return this.#enqueue({ ...message, senderId }, key, id);
|
|
502
598
|
const saved = this.#sessionStore.occurrence(key, message.messageId)?.snapshot;
|
|
503
599
|
if (!saved)
|
|
504
600
|
return false;
|
|
@@ -510,6 +606,8 @@ export class ImRuntime {
|
|
|
510
606
|
...message,
|
|
511
607
|
senderId,
|
|
512
608
|
historyRetry: true,
|
|
609
|
+
frozenArtifacts: this.#sessionStore.occurrence(key, message.messageId)?.artifacts,
|
|
610
|
+
runMetadata: saved.runMetadata,
|
|
513
611
|
buildContext: () => Promise.resolve(structuredClone(saved.contexts)),
|
|
514
612
|
...(images.length
|
|
515
613
|
? { buildInputs: () => Promise.resolve(structuredClone(images)) }
|
|
@@ -540,9 +638,10 @@ export class ImRuntime {
|
|
|
540
638
|
// Octospec F26: .octospec/tasks/gateway-august-feature-assessment/assessment.md
|
|
541
639
|
// 每个非空 session 占一个工作槽位;结束清理后原子交给同 session 的下一条。
|
|
542
640
|
// 排队另计四条,不把 Bot 的工作数与所有排队消息混加。
|
|
641
|
+
// 只有空闲 session 需要申请新槽;Bot 满载不阻止已有工作 session 排队。
|
|
543
642
|
const full = session.pending >= 5
|
|
544
643
|
? "IM_SESSION_QUEUE_FULL"
|
|
545
|
-
: this.#working >= 64
|
|
644
|
+
: session.pending === 0 && this.#working >= 64
|
|
546
645
|
? "IM_BOT_WORKING_FULL"
|
|
547
646
|
: undefined;
|
|
548
647
|
if (full) {
|
|
@@ -558,6 +657,13 @@ export class ImRuntime {
|
|
|
558
657
|
this.#sessionStore.save(key, binding);
|
|
559
658
|
session.id = binding.id;
|
|
560
659
|
}
|
|
660
|
+
if (message.text.trim() !== "/session") {
|
|
661
|
+
const name = readableSessionName(message, session.sessionName);
|
|
662
|
+
if (name !== session.sessionName) {
|
|
663
|
+
session.sessionName = name;
|
|
664
|
+
this.#saveBinding(key, session);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
561
667
|
const executionSession = { ...session };
|
|
562
668
|
const frozenMessage = {
|
|
563
669
|
...message,
|
|
@@ -607,7 +713,10 @@ export class ImRuntime {
|
|
|
607
713
|
};
|
|
608
714
|
const effect = `busy:${message.messageId}`;
|
|
609
715
|
const notification = Promise.allSettled([
|
|
610
|
-
Promise.resolve().then(() => message.replyFailure?.(event, effect
|
|
716
|
+
Promise.resolve().then(() => message.replyFailure?.(event, effect, {
|
|
717
|
+
signal: this.#signal,
|
|
718
|
+
obsolete: () => this.#closed || this.#signal.aborted
|
|
719
|
+
})),
|
|
611
720
|
this.#reply(message, `当前智能体繁忙,请稍后再试\n错误码:${payload.failure.code}`, `${effect}:text`)
|
|
612
721
|
])
|
|
613
722
|
.then((results) => {
|
|
@@ -620,7 +729,7 @@ export class ImRuntime {
|
|
|
620
729
|
this.#busyNotifications.set(key, notification);
|
|
621
730
|
}
|
|
622
731
|
/** 独立错误展示不复用已坏的 presentation;共享有界投递,迟到失败不触发再次执行或递归通知。 */
|
|
623
|
-
#notifyFailure(message, failure, identity, retry = false) {
|
|
732
|
+
#notifyFailure(message, failure, identity, retry = false, turnSignal) {
|
|
624
733
|
const data = {
|
|
625
734
|
code: failure.code,
|
|
626
735
|
reason_code: failure.reasonCode,
|
|
@@ -644,6 +753,16 @@ export class ImRuntime {
|
|
|
644
753
|
};
|
|
645
754
|
const delivery = this.#delivery;
|
|
646
755
|
const options = { transient: true, obsolete: () => this.#closed || performance.now() >= until };
|
|
756
|
+
const deliveryOptions = {
|
|
757
|
+
signal: AbortSignal.any([
|
|
758
|
+
this.#signal,
|
|
759
|
+
...(turnSignal ? [turnSignal] : []),
|
|
760
|
+
...(Number.isFinite(until)
|
|
761
|
+
? [AbortSignal.timeout(Math.max(0, Math.ceil(until - performance.now())))]
|
|
762
|
+
: [])
|
|
763
|
+
]),
|
|
764
|
+
obsolete: () => options.obsolete() || Boolean(turnSignal?.aborted)
|
|
765
|
+
};
|
|
647
766
|
const secondary = (code) => {
|
|
648
767
|
this.#diagnostic(code, identity?.runId, {
|
|
649
768
|
...data,
|
|
@@ -656,12 +775,16 @@ export class ImRuntime {
|
|
|
656
775
|
};
|
|
657
776
|
const send = async (operation, key) => {
|
|
658
777
|
const receipt = await delivery.deliver(key, operation, options);
|
|
778
|
+
if (turnSignal?.aborted)
|
|
779
|
+
return;
|
|
659
780
|
if (receipt.state !== "delivered")
|
|
660
781
|
secondary(receipt.code ?? "IM_DELIVERY_FAILED");
|
|
661
782
|
};
|
|
662
783
|
const notification = withinShutdown(Promise.allSettled([
|
|
663
|
-
...(message.replyFailure
|
|
664
|
-
|
|
784
|
+
...(message.replyFailure
|
|
785
|
+
? [send(() => message.replyFailure(event, effect, deliveryOptions), effect)]
|
|
786
|
+
: []),
|
|
787
|
+
send(() => message.reply(text, `${effect}:text`, deliveryOptions), `${effect}:text`)
|
|
665
788
|
]), until, "IM_DELIVERY_UNKNOWN")
|
|
666
789
|
.then(() => undefined)
|
|
667
790
|
.catch(() => secondary("IM_DELIVERY_UNKNOWN"))
|
|
@@ -674,7 +797,7 @@ export class ImRuntime {
|
|
|
674
797
|
return;
|
|
675
798
|
const receipt = await this.#delivery.deliver(effectKey, () => final && message.replyFinal
|
|
676
799
|
? message.replyFinal(text, effectKey, finalOptions)
|
|
677
|
-
: message.reply(text, effectKey), { obsolete: finalOptions ? () => finalOptions.obsolete() : undefined });
|
|
800
|
+
: message.reply(text, effectKey, finalOptions), { obsolete: finalOptions ? () => finalOptions.obsolete() : undefined });
|
|
678
801
|
if (finalOptions?.obsolete())
|
|
679
802
|
return;
|
|
680
803
|
if (receipt.state !== "delivered") {
|
|
@@ -687,8 +810,16 @@ export class ImRuntime {
|
|
|
687
810
|
!this.#closed &&
|
|
688
811
|
!this.#signal.aborted) {
|
|
689
812
|
const notice = deliveryNotice();
|
|
690
|
-
|
|
691
|
-
|
|
813
|
+
// 未知通知仍属于原轮最终投递;stop/reset 必须取消在途请求并阻止后续重试。
|
|
814
|
+
// 迟到 ACK 与代次过期共用发送边界检查,不能因 REST 独立于 WS 而脱离任务期限。
|
|
815
|
+
const noticeSignal = finalOptions
|
|
816
|
+
? AbortSignal.any([this.#signal, finalOptions.signal])
|
|
817
|
+
: this.#signal;
|
|
818
|
+
const obsolete = () => noticeSignal.aborted ||
|
|
819
|
+
Boolean(finalOptions?.obsolete()) ||
|
|
820
|
+
Boolean(message.isReplyDelivered?.(effectKey));
|
|
821
|
+
const result = await this.#delivery.deliver(`delivery-unknown:${effectKey}`, () => message.replyDeliveryUnknown(notice, `delivery-unknown:${effectKey}`, effectKey, noticeSignal, obsolete), { obsolete });
|
|
822
|
+
if (result.state !== "delivered" && !obsolete())
|
|
692
823
|
this.#diagnostic("IM_DELIVERY_NOTICE_FAILED");
|
|
693
824
|
}
|
|
694
825
|
if (requireDelivered)
|
|
@@ -770,6 +901,12 @@ export class ImRuntime {
|
|
|
770
901
|
let failureAfterSeq = null;
|
|
771
902
|
let rulesRevision = 0;
|
|
772
903
|
let rulesVersions;
|
|
904
|
+
const stableState = executionSession.stableContext;
|
|
905
|
+
const initialWasAttempted = executionSession.initialization.attempted;
|
|
906
|
+
const stablePlan = message.historyRetry
|
|
907
|
+
? { turn: stableState.turnCount, refresh: false }
|
|
908
|
+
: planStableContext(stableState, this.config.stable_context_refresh_interval_turns);
|
|
909
|
+
let stableRecovered = false;
|
|
773
910
|
const rulesEnabled = message.conversationKind !== "direct";
|
|
774
911
|
// Octospec F05: .octospec/tasks/gateway-august-feature-assessment/assessment.md
|
|
775
912
|
// 仅普通任务开始时回执;通知失败不阻断 Context 准备和模型执行。
|
|
@@ -784,9 +921,9 @@ export class ImRuntime {
|
|
|
784
921
|
executionSession.providerSession = session.providerSession;
|
|
785
922
|
const initialization = executionSession.initialization;
|
|
786
923
|
const initialSession = !initialization.attempted;
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
924
|
+
const refreshStableContext = stablePlan.refresh ||
|
|
925
|
+
!executionSession.providerSession?.sessionId ||
|
|
926
|
+
executionSession.providerSession.resumable === false;
|
|
790
927
|
const binding = this.#sessionStore.read(key);
|
|
791
928
|
const rulesCursor = !message.historyRetry &&
|
|
792
929
|
typeof this.#sessionStore.patchRules === "function" &&
|
|
@@ -805,6 +942,16 @@ export class ImRuntime {
|
|
|
805
942
|
binding.generation === executionSession.generation
|
|
806
943
|
? binding.gap
|
|
807
944
|
: undefined, this.#processEpoch, typeof this.#sessionStore.patchGap === "function");
|
|
945
|
+
const outputs = binding?.gap?.assistantOutputs;
|
|
946
|
+
// 补位/新建/恢复不明均保留;旧 ACK 与同 UID 不能代替当前 Provider 的归属证据。
|
|
947
|
+
if (!initialSession &&
|
|
948
|
+
gapPlan.mode === "delta" &&
|
|
949
|
+
binding?.gap?.pendingAfterSeq === undefined &&
|
|
950
|
+
!binding?.gap?.continuityUnknown &&
|
|
951
|
+
outputs?.providerSessionId === executionSession.providerSession?.sessionId &&
|
|
952
|
+
executionSession.providerSession?.resumable !== false &&
|
|
953
|
+
!["fresh_fallback", "compacted"].includes(executionSession.providerSession?.resumeOutcome ?? ""))
|
|
954
|
+
gapPlan.excludedOutputs = outputs?.messages;
|
|
808
955
|
message.bindHistoryTurn?.({
|
|
809
956
|
sessionId: executionSession.id,
|
|
810
957
|
generation: executionSession.generation,
|
|
@@ -816,8 +963,6 @@ export class ImRuntime {
|
|
|
816
963
|
? undefined
|
|
817
964
|
: await this.dependencies.prepareContexts?.(this.config, turnSignal),
|
|
818
965
|
initialSession,
|
|
819
|
-
// 逐轮提醒让升级前的 Provider binding 也收到新 mention 规则,不隐式 reset。
|
|
820
|
-
mentionGuidance: true,
|
|
821
966
|
...(gapEnabled
|
|
822
967
|
? {
|
|
823
968
|
historyGap: gapPlan,
|
|
@@ -827,13 +972,13 @@ export class ImRuntime {
|
|
|
827
972
|
}
|
|
828
973
|
: {})
|
|
829
974
|
});
|
|
830
|
-
const selection = selectRulesContext(fullContext, rulesCursor, executionSession.providerSession);
|
|
975
|
+
const selection = selectRulesContext(fullContext, rulesCursor, executionSession.providerSession, !message.historyRetry && refreshStableContext);
|
|
831
976
|
const context = selection.context;
|
|
832
977
|
rulesVersions = message.historyRetry ? undefined : selection.versions;
|
|
833
978
|
if (gapEnabled)
|
|
834
979
|
failureAfterSeq = gapPlan.afterSeq ?? null;
|
|
835
|
-
//
|
|
836
|
-
prepared = createImInvocation(this.config, message, context, key, executionSession, turnSignal, occurrenceId);
|
|
980
|
+
// 准备只计算发送计划;直到第一次执行尝试才消费轮次和首轮历史资格。
|
|
981
|
+
prepared = createImInvocation(this.config, message, context, key, executionSession, turnSignal, occurrenceId, refreshStableContext);
|
|
837
982
|
if (gapEnabled &&
|
|
838
983
|
context.items.some((item) => item.namespace === "extra.im" &&
|
|
839
984
|
item.name === "history" &&
|
|
@@ -849,7 +994,17 @@ export class ImRuntime {
|
|
|
849
994
|
throw new ImImageInputError("每条独立图片消息只接收一张图片。");
|
|
850
995
|
prepared.request.inputs = parts;
|
|
851
996
|
}
|
|
852
|
-
|
|
997
|
+
// 恢复补充只含主历史排除的消息,同一窗口/快照,不重复用户 gap 或另起读取。
|
|
998
|
+
addRulesRecovery(prepared.request, [
|
|
999
|
+
...selection.omitted,
|
|
1000
|
+
...prepared.recoveryContexts,
|
|
1001
|
+
...(prepared.historyContext && gapPlan.recoveryHistory ? [gapPlan.recoveryHistory] : [])
|
|
1002
|
+
]);
|
|
1003
|
+
if (!message.historyRetry)
|
|
1004
|
+
prepared.request.runMetadata = {
|
|
1005
|
+
...prepared.request.runMetadata,
|
|
1006
|
+
conversationTurn: stablePlan.turn
|
|
1007
|
+
};
|
|
853
1008
|
if (message.historyRetry) {
|
|
854
1009
|
const saved = this.#sessionStore.occurrence(key, message.messageId)?.snapshot;
|
|
855
1010
|
if (saved?.freshFallbackModelInput !== undefined)
|
|
@@ -871,7 +1026,8 @@ export class ImRuntime {
|
|
|
871
1026
|
text: message.text,
|
|
872
1027
|
sessionId: executionSession.id,
|
|
873
1028
|
runId: prepared.request.runId,
|
|
874
|
-
snapshot
|
|
1029
|
+
snapshot,
|
|
1030
|
+
artifacts: prepared.artifacts
|
|
875
1031
|
});
|
|
876
1032
|
}
|
|
877
1033
|
catch (error) {
|
|
@@ -879,14 +1035,17 @@ export class ImRuntime {
|
|
|
879
1035
|
this.#finishRules(key, executionSession, rulesRevision, undefined, false);
|
|
880
1036
|
if (turnSignal.aborted)
|
|
881
1037
|
return;
|
|
882
|
-
|
|
1038
|
+
const preparationMessage = error instanceof Error ? preparationFailureMessages.get(error.message) : undefined;
|
|
1039
|
+
if (error instanceof Error &&
|
|
1040
|
+
(preparationMessage || /^IM_CONTEXT_(?:LOADING|RESULT)_[A-Z_]+$/.test(error.message)))
|
|
883
1041
|
this.#diagnostic(error.message);
|
|
884
1042
|
this.#diagnostic("IM_CONTEXT_PREPARATION_FAILED");
|
|
885
|
-
await this.#reply(message,
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1043
|
+
await this.#reply(message, preparationMessage ??
|
|
1044
|
+
(error instanceof ImImageInputError
|
|
1045
|
+
? error.message
|
|
1046
|
+
: message.buildInputs
|
|
1047
|
+
? "图片输入准备失败,尚未发起执行。请检查图片或稍后重试。"
|
|
1048
|
+
: "本轮输入或执行配置准备失败,尚未发起执行。请检查配置、会话权限或稍后重试。"), `prepare:${occurrenceId ?? message.messageId}`);
|
|
890
1049
|
return;
|
|
891
1050
|
}
|
|
892
1051
|
finally {
|
|
@@ -905,14 +1064,24 @@ export class ImRuntime {
|
|
|
905
1064
|
let presentationSeq = 0;
|
|
906
1065
|
let projector = new ImRunProjector(rootRunId, message.conversationKind === "direct");
|
|
907
1066
|
let handedOff = false;
|
|
1067
|
+
let turnStarted = false;
|
|
908
1068
|
const task = new ImTask(this.dependencies.kernel, request, prepared.adapterType, this.config, { ...environment, signal: this.#signal }, (attempt) => {
|
|
1069
|
+
// 同代次排队共享状态;自动/卡片重试不增加用户轮数,reset 后旧任务仅更新旧对象。
|
|
1070
|
+
if (!turnStarted && !message.historyRetry) {
|
|
1071
|
+
turnStarted = true;
|
|
1072
|
+
stableState.turnCount = stablePlan.turn;
|
|
1073
|
+
stableState.refreshPending ||= prepared.stableContextIncluded;
|
|
1074
|
+
executionSession.initialization.attempted = true;
|
|
1075
|
+
}
|
|
909
1076
|
if (!handedOff &&
|
|
910
1077
|
message.position &&
|
|
911
1078
|
message.conversationKind !== "direct" &&
|
|
912
1079
|
!message.historyRetry) {
|
|
913
1080
|
handedOff = true;
|
|
914
1081
|
try {
|
|
915
|
-
this.#sessionStore.patchGap?.(key, { sessionId: executionSession.id, generation: executionSession.generation }, (previous) => commitHistoryGap(gapMetadata(this.#processEpoch, previous), message.position?.messageSeq, gapPlan, attempt.contexts.items.
|
|
1082
|
+
this.#sessionStore.patchGap?.(key, { sessionId: executionSession.id, generation: executionSession.generation }, (previous) => commitHistoryGap(gapMetadata(this.#processEpoch, previous), message.position?.messageSeq, gapPlan, attempt.contexts.items.some((item) => item.namespace === "extra.im" && item.name === "history")
|
|
1083
|
+
? prepared.historyContext
|
|
1084
|
+
: undefined));
|
|
916
1085
|
}
|
|
917
1086
|
catch {
|
|
918
1087
|
this.#finalizationFailed("IM_HISTORY_POSITION_UNAVAILABLE");
|
|
@@ -922,6 +1091,7 @@ export class ImRuntime {
|
|
|
922
1091
|
if (entry.invocationId === request.invocationId)
|
|
923
1092
|
this.#interactions.delete(id);
|
|
924
1093
|
request = attempt;
|
|
1094
|
+
projector.dispose();
|
|
925
1095
|
projector = new ImRunProjector(rootRunId, message.conversationKind === "direct");
|
|
926
1096
|
session.activeInvocationId = request.invocationId;
|
|
927
1097
|
if (session.id === request.sessionId) {
|
|
@@ -930,12 +1100,13 @@ export class ImRuntime {
|
|
|
930
1100
|
}
|
|
931
1101
|
else
|
|
932
1102
|
task.stopRetries();
|
|
933
|
-
});
|
|
1103
|
+
}, undefined, () => updatePresentation());
|
|
934
1104
|
this.#tasks.set(key, { rootInvocationId: request.invocationId, task });
|
|
935
1105
|
const snapshot = () => ({
|
|
936
1106
|
...projector.snapshot(),
|
|
937
1107
|
seq: ++presentationSeq,
|
|
938
1108
|
elapsedMs: Math.round(performance.now() - startedAt),
|
|
1109
|
+
modelWait: task.modelWait.snapshot,
|
|
939
1110
|
attempts: task.attempts.map((attempt) => ({ ...attempt }))
|
|
940
1111
|
});
|
|
941
1112
|
const controls = this.#runControls(message, key, request.invocationId);
|
|
@@ -944,231 +1115,292 @@ export class ImRuntime {
|
|
|
944
1115
|
let presentationFailed = false;
|
|
945
1116
|
let localFailure;
|
|
946
1117
|
const delivery = new AbortController();
|
|
1118
|
+
// 时钟和源事件走同一投影出口,保留原卡片的序号、预算与终态屏障。
|
|
1119
|
+
const updatePresentation = () => {
|
|
1120
|
+
if (presentationFailed || this.#closed || this.#signal.aborted)
|
|
1121
|
+
return;
|
|
1122
|
+
try {
|
|
1123
|
+
presentation?.update(snapshot());
|
|
1124
|
+
}
|
|
1125
|
+
catch {
|
|
1126
|
+
presentationFailed = true;
|
|
1127
|
+
this.#finalizationFailed("IM_PRESENTATION_FAILED", request.runId);
|
|
1128
|
+
if (!projector.snapshot().terminal)
|
|
1129
|
+
void task
|
|
1130
|
+
.cancelExecution("IM presentation failed")
|
|
1131
|
+
.catch(() => this.#diagnostic("IM_CANCEL_FAILED", request.runId));
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
947
1134
|
try {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
session.
|
|
957
|
-
|
|
958
|
-
|
|
1135
|
+
try {
|
|
1136
|
+
presentation = message.beginPresentation?.(rootRunId, (code) => this.#diagnostic(code, rootRunId), controls);
|
|
1137
|
+
presentation?.update(snapshot());
|
|
1138
|
+
session.activeInvocationId = request.invocationId;
|
|
1139
|
+
executionStarted = true;
|
|
1140
|
+
for await (const event of task.events()) {
|
|
1141
|
+
if (this.#closed || this.#signal.aborted)
|
|
1142
|
+
break;
|
|
1143
|
+
if (event.type === "session.update" && session.id === request.sessionId) {
|
|
1144
|
+
session.providerSession = event.payload.providerSession;
|
|
1145
|
+
this.#saveBinding(key, session);
|
|
1146
|
+
if (event.payload.providerSession?.resumeOutcome === "fresh_fallback") {
|
|
1147
|
+
stableRecovered = true;
|
|
1148
|
+
try {
|
|
1149
|
+
this.#sessionStore.patchGap?.(key, { sessionId: request.sessionId, generation: executionSession.generation }, (previous) => ({
|
|
1150
|
+
...gapMetadata(this.#processEpoch, previous),
|
|
1151
|
+
continuityUnknown: true,
|
|
1152
|
+
pendingAfterSeq: null
|
|
1153
|
+
}));
|
|
1154
|
+
}
|
|
1155
|
+
catch {
|
|
1156
|
+
this.#finalizationFailed("IM_HISTORY_POSITION_UNAVAILABLE");
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
// 只有执行策略与事件策略均为 full_access 的审批才是自动处理的审计记录。
|
|
1161
|
+
// 问题/elicitation 仍须展示并交回原交互入口,不能一并过滤。
|
|
1162
|
+
if (event.type === "interaction.requested" &&
|
|
1163
|
+
event.payload.kind === "approval" &&
|
|
1164
|
+
request.approvalMode === "full_access" &&
|
|
1165
|
+
event.payload.request.policy?.mode === "full_access")
|
|
1166
|
+
continue;
|
|
1167
|
+
if (event.type === "interaction.requested") {
|
|
1168
|
+
if (this.#draining)
|
|
1169
|
+
continue;
|
|
1170
|
+
// Octospec F09: .octospec/tasks/gateway-august-feature-assessment/assessment.md
|
|
1171
|
+
// 普通 IM 不提供秘密输入通道,禁止退回聊天命令收集凭据。
|
|
1172
|
+
if (Array.isArray(event.payload.request.questions) &&
|
|
1173
|
+
event.payload.request.questions.some((question) => question !== null &&
|
|
1174
|
+
typeof question === "object" &&
|
|
1175
|
+
"isSecret" in question &&
|
|
1176
|
+
question.isSecret === true)) {
|
|
1177
|
+
this.#diagnostic("IM_INTERACTION_SECRET_UNSUPPORTED", request.runId);
|
|
1178
|
+
await this.#reply(message, "本次执行需要安全输入,当前聊天不支持。请勿在聊天中发送密码或密钥;本次执行已请求停止。", `interaction:${event.payload.interactionId}`);
|
|
1179
|
+
await this.dependencies.kernel.cancelInvocation(request.invocationId, "IM secret input unsupported");
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
if (this.#interactions.size >= 64)
|
|
1183
|
+
throw new Error("IM_INTERACTION_CAPACITY_EXHAUSTED");
|
|
1184
|
+
this.#interactions.set(event.payload.interactionId, {
|
|
1185
|
+
invocationId: request.invocationId,
|
|
1186
|
+
sessionId: request.sessionId,
|
|
1187
|
+
key,
|
|
1188
|
+
senderId: message.senderId,
|
|
1189
|
+
request: structuredClone(event.payload)
|
|
1190
|
+
});
|
|
1191
|
+
const interaction = event.payload;
|
|
1192
|
+
let cardShown = false;
|
|
1193
|
+
try {
|
|
1194
|
+
cardShown =
|
|
1195
|
+
!presentationFailed && ((await presentation?.interaction?.(interaction)) ?? false);
|
|
1196
|
+
}
|
|
1197
|
+
catch {
|
|
1198
|
+
this.#diagnostic("IM_INTERACTION_CARD_FAILED", request.runId);
|
|
1199
|
+
}
|
|
1200
|
+
const display = interaction.request.operation;
|
|
1201
|
+
const summary = [
|
|
1202
|
+
display?.summary,
|
|
1203
|
+
interaction.request.question,
|
|
1204
|
+
interaction.request.message
|
|
1205
|
+
].find((value) => typeof value === "string");
|
|
1206
|
+
const instruction = interaction.kind === "approval"
|
|
1207
|
+
? `/approve ${interaction.interactionId} 或 /decline ${interaction.interactionId}`
|
|
1208
|
+
: `/respond ${interaction.interactionId} ${interaction.kind === "elicitation" ? "<JSON>" : "<回答>"}`;
|
|
1209
|
+
if (!cardShown)
|
|
1210
|
+
await this.#reply(message, `${summary?.slice(0, 1000) ?? "执行需要你的确认或输入。"}\n${Array.isArray(interaction.request.questions) ? JSON.stringify(interaction.request.questions).slice(0, 8000) + "\n请按问题 ID 提交 JSON 答案。\n" : ""}${instruction}`, `interaction:${interaction.interactionId}`, true);
|
|
1211
|
+
}
|
|
1212
|
+
if (event.type === "interaction.resolved") {
|
|
1213
|
+
this.#interactions.delete(event.payload.interactionId);
|
|
959
1214
|
try {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
continuityUnknown: true,
|
|
963
|
-
pendingAfterSeq: null
|
|
964
|
-
}));
|
|
1215
|
+
if (!presentationFailed)
|
|
1216
|
+
await presentation?.resolveInteraction?.(event.payload.interactionId, event.payload.status);
|
|
965
1217
|
}
|
|
966
1218
|
catch {
|
|
967
|
-
this.#
|
|
1219
|
+
this.#diagnostic("IM_INTERACTION_CARD_FAILED", request.runId);
|
|
968
1220
|
}
|
|
969
1221
|
}
|
|
1222
|
+
projector.accept(event);
|
|
1223
|
+
controls.failed =
|
|
1224
|
+
projector.snapshot().terminal === "failed" ||
|
|
1225
|
+
(projector.snapshot().terminal === "cancelled" &&
|
|
1226
|
+
task.modelWait.snapshot.timeout === "terminated");
|
|
1227
|
+
updatePresentation();
|
|
1228
|
+
}
|
|
1229
|
+
if (!projector.snapshot().terminal)
|
|
1230
|
+
throw new Error("IM_RUN_WITHOUT_TERMINAL");
|
|
1231
|
+
}
|
|
1232
|
+
catch {
|
|
1233
|
+
if (!executionStarted || task.notSubmittedFailure) {
|
|
1234
|
+
localFailure =
|
|
1235
|
+
task.notSubmittedFailure ??
|
|
1236
|
+
failurePayload({ code: "IM_PRESENTATION_INITIALIZATION_FAILED" }, {
|
|
1237
|
+
stage: "channel_presentation_initialize",
|
|
1238
|
+
defaultDomain: "runtime",
|
|
1239
|
+
runId: request.runId
|
|
1240
|
+
}).failure;
|
|
1241
|
+
controls.failed = false;
|
|
1242
|
+
// 未提交失败的错误卡也可能等待重连;先移交取消权,stop/reset 才能终止待发通知。
|
|
1243
|
+
this.#finalDeliveries.set(key, delivery);
|
|
1244
|
+
await this.#notifyFailure(message, localFailure, request, task.attempts.length > 1, delivery.signal);
|
|
970
1245
|
}
|
|
971
|
-
|
|
972
|
-
// 问题/elicitation 仍须展示并交回原交互入口,不能一并过滤。
|
|
973
|
-
if (event.type === "interaction.requested" &&
|
|
974
|
-
event.payload.kind === "approval" &&
|
|
975
|
-
request.approvalMode === "full_access" &&
|
|
976
|
-
event.payload.request.policy?.mode === "full_access")
|
|
977
|
-
continue;
|
|
978
|
-
if (event.type === "interaction.requested") {
|
|
1246
|
+
else {
|
|
979
1247
|
if (this.#draining)
|
|
980
|
-
|
|
981
|
-
//
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
sessionId: request.sessionId,
|
|
998
|
-
key,
|
|
999
|
-
senderId: message.senderId,
|
|
1000
|
-
request: structuredClone(event.payload)
|
|
1001
|
-
});
|
|
1002
|
-
const interaction = event.payload;
|
|
1003
|
-
let cardShown = false;
|
|
1004
|
-
try {
|
|
1005
|
-
cardShown =
|
|
1006
|
-
!presentationFailed && ((await presentation?.interaction?.(interaction)) ?? false);
|
|
1007
|
-
}
|
|
1008
|
-
catch {
|
|
1009
|
-
this.#diagnostic("IM_INTERACTION_CARD_FAILED", request.runId);
|
|
1248
|
+
this.#drainErrors.push(new Error("IM_EXECUTION_RESULT_UNKNOWN"));
|
|
1249
|
+
// 流断开无法证明执行失败;尽力取消并提示核查,不自动重跑潜在的业务副作用。
|
|
1250
|
+
await this.dependencies.kernel
|
|
1251
|
+
.cancelInvocation(request.invocationId, "IM execution stream failed")
|
|
1252
|
+
.catch(() => undefined);
|
|
1253
|
+
this.#diagnostic("IM_EXECUTION_RESULT_UNKNOWN", request.runId);
|
|
1254
|
+
// 原源流即使在终态后失败,也不能被展示层的终态掩盖。
|
|
1255
|
+
controls.failed = false;
|
|
1256
|
+
projector.dispose();
|
|
1257
|
+
projector = new ImRunProjector(rootRunId, message.conversationKind === "direct");
|
|
1258
|
+
if (!presentationFailed) {
|
|
1259
|
+
try {
|
|
1260
|
+
presentation?.update({ ...snapshot(), resultUnknown: true });
|
|
1261
|
+
}
|
|
1262
|
+
catch {
|
|
1263
|
+
this.#finalizationFailed("IM_PRESENTATION_FAILED", request.runId);
|
|
1264
|
+
}
|
|
1010
1265
|
}
|
|
1011
|
-
const display = interaction.request.operation;
|
|
1012
|
-
const summary = [
|
|
1013
|
-
display?.summary,
|
|
1014
|
-
interaction.request.question,
|
|
1015
|
-
interaction.request.message
|
|
1016
|
-
].find((value) => typeof value === "string");
|
|
1017
|
-
const instruction = interaction.kind === "approval"
|
|
1018
|
-
? `/approve ${interaction.interactionId} 或 /decline ${interaction.interactionId}`
|
|
1019
|
-
: `/respond ${interaction.interactionId} ${interaction.kind === "elicitation" ? "<JSON>" : "<回答>"}`;
|
|
1020
|
-
if (!cardShown)
|
|
1021
|
-
await this.#reply(message, `${summary?.slice(0, 1000) ?? "执行需要你的确认或输入。"}\n${Array.isArray(interaction.request.questions) ? JSON.stringify(interaction.request.questions).slice(0, 8000) + "\n请按问题 ID 提交 JSON 答案。\n" : ""}${instruction}`, `interaction:${interaction.interactionId}`, true);
|
|
1022
1266
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1267
|
+
}
|
|
1268
|
+
finally {
|
|
1269
|
+
let stableChanged = false;
|
|
1270
|
+
if (localFailure &&
|
|
1271
|
+
turnStarted &&
|
|
1272
|
+
task.attempts.every((attempt) => attempt.outcome === "not_submitted") &&
|
|
1273
|
+
session.id === executionSession.id &&
|
|
1274
|
+
session.generation === executionSession.generation) {
|
|
1275
|
+
// 可信未提交才允许回退轮次;已执行失败或结果未知不能当作从未执行。
|
|
1276
|
+
stableState.turnCount--;
|
|
1277
|
+
executionSession.initialization.attempted = initialWasAttempted;
|
|
1278
|
+
stableChanged = true;
|
|
1279
|
+
}
|
|
1280
|
+
if (session.id === executionSession.id &&
|
|
1281
|
+
session.generation === executionSession.generation &&
|
|
1282
|
+
projector.snapshot().terminal === "completed" &&
|
|
1283
|
+
(prepared.stableContextIncluded || stableRecovered)) {
|
|
1284
|
+
stableState.refreshPending = false;
|
|
1285
|
+
stableChanged = true;
|
|
1032
1286
|
}
|
|
1033
|
-
|
|
1034
|
-
controls.failed = projector.snapshot().terminal === "failed";
|
|
1035
|
-
if (!presentationFailed) {
|
|
1287
|
+
if (stableChanged)
|
|
1036
1288
|
try {
|
|
1037
|
-
|
|
1289
|
+
this.#saveBinding(key, session);
|
|
1038
1290
|
}
|
|
1039
1291
|
catch {
|
|
1040
|
-
|
|
1041
|
-
this.#finalizationFailed("IM_PRESENTATION_FAILED", request.runId);
|
|
1042
|
-
// 展示故障不关闭原迭代器;请求停止后仍由同一消费者确认真实终态。
|
|
1043
|
-
if (!projector.snapshot().terminal)
|
|
1044
|
-
void task
|
|
1045
|
-
.cancelExecution("IM presentation failed")
|
|
1046
|
-
.catch(() => this.#diagnostic("IM_CANCEL_FAILED", request.runId));
|
|
1292
|
+
this.#finalizationFailed("IM_SESSION_STORE_FAILED", rootRunId);
|
|
1047
1293
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
throw new Error("IM_RUN_WITHOUT_TERMINAL");
|
|
1052
|
-
}
|
|
1053
|
-
catch {
|
|
1054
|
-
if (!executionStarted || task.notSubmittedFailure) {
|
|
1055
|
-
localFailure =
|
|
1056
|
-
task.notSubmittedFailure ??
|
|
1057
|
-
failurePayload({ code: "IM_PRESENTATION_INITIALIZATION_FAILED" }, {
|
|
1058
|
-
stage: "channel_presentation_initialize",
|
|
1059
|
-
defaultDomain: "runtime",
|
|
1060
|
-
runId: request.runId
|
|
1061
|
-
}).failure;
|
|
1062
|
-
controls.failed = false;
|
|
1063
|
-
await this.#notifyFailure(message, localFailure, request, task.attempts.length > 1);
|
|
1064
|
-
}
|
|
1065
|
-
else {
|
|
1066
|
-
if (this.#draining)
|
|
1067
|
-
this.#drainErrors.push(new Error("IM_EXECUTION_RESULT_UNKNOWN"));
|
|
1068
|
-
// 流断开无法证明执行失败;尽力取消并提示核查,不自动重跑潜在的业务副作用。
|
|
1069
|
-
await this.dependencies.kernel
|
|
1070
|
-
.cancelInvocation(request.invocationId, "IM execution stream failed")
|
|
1071
|
-
.catch(() => undefined);
|
|
1072
|
-
this.#diagnostic("IM_EXECUTION_RESULT_UNKNOWN", request.runId);
|
|
1073
|
-
// 原源流即使在终态后失败,也不能被展示层的终态掩盖。
|
|
1074
|
-
controls.failed = false;
|
|
1075
|
-
projector = new ImRunProjector(rootRunId, message.conversationKind === "direct");
|
|
1076
|
-
if (!presentationFailed) {
|
|
1294
|
+
if (rulesEnabled)
|
|
1295
|
+
this.#finishRules(key, executionSession, rulesRevision, rulesVersions, projector.snapshot().terminal === "completed");
|
|
1296
|
+
if (!this.#closed && handedOff && projector.snapshot().terminal !== "completed") {
|
|
1077
1297
|
try {
|
|
1078
|
-
|
|
1298
|
+
this.#sessionStore.patchGap?.(key, { sessionId: executionSession.id, generation: executionSession.generation }, (previous) => {
|
|
1299
|
+
const next = gapMetadata(this.#processEpoch, previous);
|
|
1300
|
+
next.pendingAfterSeq =
|
|
1301
|
+
next.pendingAfterSeq === null || failureAfterSeq === null
|
|
1302
|
+
? null
|
|
1303
|
+
: Math.min(next.pendingAfterSeq ?? failureAfterSeq, failureAfterSeq);
|
|
1304
|
+
return next;
|
|
1305
|
+
});
|
|
1079
1306
|
}
|
|
1080
1307
|
catch {
|
|
1081
|
-
this.#finalizationFailed("
|
|
1308
|
+
this.#finalizationFailed("IM_HISTORY_POSITION_UNAVAILABLE");
|
|
1082
1309
|
}
|
|
1083
1310
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1311
|
+
if (task.stopReason)
|
|
1312
|
+
this.#diagnostic(task.stopReason, rootRunId);
|
|
1313
|
+
this.#log("agent_run.finished", {
|
|
1314
|
+
run_id: rootRunId,
|
|
1315
|
+
invocation_id: request.invocationId,
|
|
1316
|
+
session_id: request.sessionId,
|
|
1317
|
+
status: localFailure ? "not_submitted" : (projector.snapshot().terminal ?? "unknown")
|
|
1318
|
+
});
|
|
1319
|
+
// 移除执行身份前移交收尾/产物投递的取消权;finish 等待期间的 stop 不能落入空窗。
|
|
1320
|
+
if (!localFailure)
|
|
1321
|
+
this.#finalDeliveries.set(key, delivery);
|
|
1322
|
+
this.#tasks.delete(key);
|
|
1090
1323
|
try {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1324
|
+
// 长任务结束后重新开始终态去重窗口,保留有界尝试身份,避免立即重复执行。
|
|
1325
|
+
const saved = { ...prepared.request };
|
|
1326
|
+
if (!this.#closed)
|
|
1327
|
+
this.#sessionStore.remember(key, occurrenceId ?? message.messageId, {
|
|
1328
|
+
text: message.text,
|
|
1329
|
+
sessionId: request.sessionId,
|
|
1330
|
+
runId: rootRunId,
|
|
1331
|
+
snapshot: saved,
|
|
1332
|
+
artifacts: prepared.artifacts,
|
|
1333
|
+
attempts: task.attempts.map((attempt) => ({ ...attempt })),
|
|
1334
|
+
...(localFailure &&
|
|
1335
|
+
task.attempts.every((attempt) => attempt.outcome === "not_submitted")
|
|
1336
|
+
? { notSubmittedFailure: localFailure }
|
|
1337
|
+
: {})
|
|
1338
|
+
});
|
|
1099
1339
|
}
|
|
1100
1340
|
catch {
|
|
1101
|
-
this.#finalizationFailed("
|
|
1341
|
+
this.#finalizationFailed("IM_SESSION_STORE_FAILED", rootRunId);
|
|
1342
|
+
}
|
|
1343
|
+
session.activeInvocationId = undefined;
|
|
1344
|
+
for (const [id, entry] of this.#interactions)
|
|
1345
|
+
if (entry.invocationId === request.invocationId)
|
|
1346
|
+
this.#interactions.delete(id);
|
|
1347
|
+
try {
|
|
1348
|
+
if (!this.#closed)
|
|
1349
|
+
await withinShutdown(Promise.resolve().then(() => presentation?.finish()), shutdownDeadline(this.dependencies.signal), "IM_PRESENTATION_FINISH_INCOMPLETE");
|
|
1350
|
+
}
|
|
1351
|
+
catch (error) {
|
|
1352
|
+
// 截止只结束等待,不能证明尚未完成的展示资源已经释放。
|
|
1353
|
+
if (error instanceof Error && error.message === "IM_PRESENTATION_FINISH_INCOMPLETE")
|
|
1354
|
+
this.#finishIncomplete ??= error;
|
|
1355
|
+
this.#finalizationFailed("IM_PRESENTATION_FAILED", request.runId);
|
|
1102
1356
|
}
|
|
1103
1357
|
}
|
|
1104
|
-
if (task.stopReason)
|
|
1105
|
-
this.#diagnostic(task.stopReason, rootRunId);
|
|
1106
|
-
this.#log("agent_run.finished", {
|
|
1107
|
-
run_id: rootRunId,
|
|
1108
|
-
invocation_id: request.invocationId,
|
|
1109
|
-
session_id: request.sessionId,
|
|
1110
|
-
status: localFailure ? "not_submitted" : (projector.snapshot().terminal ?? "unknown")
|
|
1111
|
-
});
|
|
1112
|
-
// 移除执行身份前移交收尾/产物投递的取消权;finish 等待期间的 stop 不能落入空窗。
|
|
1113
|
-
if (!localFailure)
|
|
1114
|
-
this.#finalDeliveries.set(key, delivery);
|
|
1115
|
-
this.#tasks.delete(key);
|
|
1116
1358
|
try {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
text:
|
|
1359
|
+
if (localFailure || this.#closed || this.#signal.aborted || delivery.signal.aborted)
|
|
1360
|
+
return;
|
|
1361
|
+
const { text, allowMention } = task.modelWait.snapshot.timeout && projector.snapshot().terminal !== "completed"
|
|
1362
|
+
? {
|
|
1363
|
+
text: MODEL_WAIT_TIMEOUT_MESSAGE +
|
|
1364
|
+
(task.modelWait.snapshot.timeout === "terminated"
|
|
1365
|
+
? "已确认执行结束,可以重试。"
|
|
1366
|
+
: "尚未确认执行停止,请核查运行记录,避免重复执行。"),
|
|
1367
|
+
allowMention: false
|
|
1368
|
+
}
|
|
1369
|
+
: projector.finalReply;
|
|
1370
|
+
const obsolete = () => {
|
|
1371
|
+
const binding = this.#sessionStore.read(key);
|
|
1372
|
+
return (binding?.id !== request.sessionId || binding.generation !== request.sessionGeneration);
|
|
1373
|
+
};
|
|
1374
|
+
// reset 不取消原模型执行,但旧代次的结果不能启动上传或继续最终消息重试。
|
|
1375
|
+
if (allowMention && obsolete())
|
|
1376
|
+
return;
|
|
1377
|
+
const deliverySignal = AbortSignal.any([this.#signal, delivery.signal]);
|
|
1378
|
+
if (allowMention &&
|
|
1379
|
+
projector.snapshot().terminal === "completed" &&
|
|
1380
|
+
session.providerSession?.sessionId &&
|
|
1381
|
+
session.providerSession.resumable !== false)
|
|
1382
|
+
message.bindHistoryTurn?.({
|
|
1122
1383
|
sessionId: request.sessionId,
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
...(localFailure &&
|
|
1127
|
-
task.attempts.every((attempt) => attempt.outcome === "not_submitted")
|
|
1128
|
-
? { notSubmittedFailure: localFailure }
|
|
1129
|
-
: {})
|
|
1384
|
+
generation: executionSession.generation,
|
|
1385
|
+
processEpoch: this.#processEpoch,
|
|
1386
|
+
providerSessionId: session.providerSession.sessionId
|
|
1130
1387
|
});
|
|
1388
|
+
// 最终文本拥有独立投递身份,即使进度卡投递失败,也必须尝试回复用户。
|
|
1389
|
+
await this.#reply(message, text, `final:${rootRunId}`, false, allowMention, projector.snapshot().terminal !== "cancelled", {
|
|
1390
|
+
artifacts: prepared.artifacts,
|
|
1391
|
+
signal: deliverySignal,
|
|
1392
|
+
obsolete: () => deliverySignal.aborted || (allowMention && obsolete())
|
|
1393
|
+
});
|
|
1131
1394
|
}
|
|
1132
|
-
|
|
1133
|
-
this.#
|
|
1134
|
-
|
|
1135
|
-
session.activeInvocationId = undefined;
|
|
1136
|
-
for (const [id, entry] of this.#interactions)
|
|
1137
|
-
if (entry.invocationId === request.invocationId)
|
|
1138
|
-
this.#interactions.delete(id);
|
|
1139
|
-
try {
|
|
1140
|
-
if (!this.#closed)
|
|
1141
|
-
await withinShutdown(Promise.resolve().then(() => presentation?.finish()), shutdownDeadline(this.dependencies.signal), "IM_PRESENTATION_FINISH_INCOMPLETE");
|
|
1142
|
-
}
|
|
1143
|
-
catch (error) {
|
|
1144
|
-
// 截止只结束等待,不能证明尚未完成的展示资源已经释放。
|
|
1145
|
-
if (error instanceof Error && error.message === "IM_PRESENTATION_FINISH_INCOMPLETE")
|
|
1146
|
-
this.#finishIncomplete ??= error;
|
|
1147
|
-
this.#finalizationFailed("IM_PRESENTATION_FAILED", request.runId);
|
|
1395
|
+
finally {
|
|
1396
|
+
if (this.#finalDeliveries.get(key) === delivery)
|
|
1397
|
+
this.#finalDeliveries.delete(key);
|
|
1148
1398
|
}
|
|
1149
1399
|
}
|
|
1150
|
-
try {
|
|
1151
|
-
if (localFailure || this.#closed || this.#signal.aborted || delivery.signal.aborted)
|
|
1152
|
-
return;
|
|
1153
|
-
const { text, allowMention } = projector.finalReply;
|
|
1154
|
-
const obsolete = () => {
|
|
1155
|
-
const binding = this.#sessionStore.read(key);
|
|
1156
|
-
return (binding?.id !== request.sessionId || binding.generation !== request.sessionGeneration);
|
|
1157
|
-
};
|
|
1158
|
-
// reset 不取消原模型执行,但旧代次的结果不能启动上传或继续最终消息重试。
|
|
1159
|
-
if (allowMention && obsolete())
|
|
1160
|
-
return;
|
|
1161
|
-
const deliverySignal = AbortSignal.any([this.#signal, delivery.signal]);
|
|
1162
|
-
// 最终文本拥有独立投递身份,即使进度卡投递失败,也必须尝试回复用户。
|
|
1163
|
-
await this.#reply(message, text, `final:${rootRunId}`, false, allowMention, projector.snapshot().terminal !== "cancelled", {
|
|
1164
|
-
artifacts: prepared.artifacts,
|
|
1165
|
-
signal: deliverySignal,
|
|
1166
|
-
obsolete: () => deliverySignal.aborted || (allowMention && obsolete())
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
1400
|
finally {
|
|
1170
|
-
|
|
1171
|
-
|
|
1401
|
+
// 先保留 final 的读取与投递机会,再解除正文引用;取消/早退同样进入此收尾。
|
|
1402
|
+
projector.dispose();
|
|
1403
|
+
presentation = undefined;
|
|
1172
1404
|
}
|
|
1173
1405
|
}
|
|
1174
1406
|
#saveBinding(key, session) {
|
|
@@ -1177,11 +1409,13 @@ export class ImRuntime {
|
|
|
1177
1409
|
const binding = this.#sessionStore.read(key);
|
|
1178
1410
|
this.#sessionStore.save(key, {
|
|
1179
1411
|
id: session.id,
|
|
1412
|
+
sessionName: session.sessionName,
|
|
1180
1413
|
generation: session.generation,
|
|
1181
1414
|
providerSession: session.providerSession,
|
|
1182
1415
|
lastEventId: session.lastEventId,
|
|
1183
1416
|
lastRunId: session.lastRunId,
|
|
1184
1417
|
initialContextPrepared: session.initialization?.attempted === true,
|
|
1418
|
+
stableContext: session.stableContext,
|
|
1185
1419
|
...(binding?.id === session.id &&
|
|
1186
1420
|
binding?.generation === session.generation &&
|
|
1187
1421
|
binding.rulesContext
|