@mininglamp-oss/octo-runtime 1.1.6 → 1.1.8

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.
Files changed (250) hide show
  1. package/apps/cli/dist/build-info.json +2 -2
  2. package/dist/public/dsh.d.ts +1 -1
  3. package/dist/public/dsh.js +1 -1
  4. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  5. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +9 -1
  6. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +17 -0
  7. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  8. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +20 -2
  9. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  10. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +32 -2
  11. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +3 -0
  12. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +16 -2
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +5 -0
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +32 -2
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-IW62UM3C.js → chunk-CFKMMCO6.js} +5 -3
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-FWAPYRV2.js → chunk-LO34KB7D.js} +1 -1
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-3GXX5VD5.js → chunk-V5W6ZTYC.js} +14 -6
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +4 -2
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +3 -1
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +17 -3
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +8 -6
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +1 -0
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +4 -3
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +9 -1
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +10 -6
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +9 -1
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +9 -1
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +9 -1
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.d.ts +2 -1
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.js +12 -40
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +22 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +422 -135
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +6 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +2 -0
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +9 -1
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +9 -1
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +19 -5
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +8 -5
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.d.ts +2 -0
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +22 -0
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +20 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +14 -1
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +20 -2
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  59. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  60. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
  61. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.d.ts +2 -1
  62. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.js +102 -52
  63. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +8 -3
  64. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +5 -3
  65. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +4 -3
  66. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +1 -1
  67. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +2 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.d.ts +1 -1
  69. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.js +9 -6
  70. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  71. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  72. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
  73. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.d.ts +17 -1
  74. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +22 -6
  75. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.d.ts +3 -0
  76. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.js +27 -0
  77. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +447 -241
  78. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.d.ts +5 -2
  79. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.js +42 -4
  80. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +5 -0
  81. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.d.ts +15 -0
  82. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.js +28 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +17 -7
  84. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +4 -5
  85. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +12 -9
  86. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +1 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +7 -5
  88. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.d.ts +4 -0
  89. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.js +29 -6
  90. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +15 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +36 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.d.ts +2 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.js +10 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.d.ts +6 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.js +10 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +5 -2
  97. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +36 -22
  98. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +14 -1
  99. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +4 -0
  100. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +5 -1
  101. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.js +265 -38
  102. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.d.ts +4 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +5 -5
  104. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +7 -0
  105. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +19 -2
  106. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.d.ts +3 -1
  107. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +4 -3
  108. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.d.ts +0 -12
  109. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.js +5 -3
  110. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +2 -1
  111. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +8 -6
  112. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.d.ts +3 -0
  113. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.js +2 -2
  114. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +5 -4
  115. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +76 -20
  116. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +19 -1
  117. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +197 -66
  118. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +2 -4
  119. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +5 -6
  120. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +52 -36
  121. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts +2 -6
  122. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +53 -82
  123. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.d.ts +12 -0
  124. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.js +133 -0
  125. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.d.ts +21 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.js +76 -0
  127. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.d.ts +0 -2
  128. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.js +0 -2
  129. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.d.ts +16 -0
  130. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.js +74 -0
  131. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.d.ts +4 -0
  132. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.js +19 -0
  133. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.d.ts +7 -0
  134. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.js +90 -0
  135. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +44 -9
  136. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.d.ts +6 -0
  137. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.js +60 -0
  138. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +0 -10
  139. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +19 -127
  140. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  141. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +10 -2
  142. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +14 -1
  143. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/transport/channel.js +2 -3
  144. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  145. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-CXTvRGim.js → index-B127MhT-.js} +10 -9
  146. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
  147. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  148. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.d.ts +3 -2
  149. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +11 -4
  150. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  151. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +8 -1
  152. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +9 -0
  153. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +3 -0
  154. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +6 -0
  155. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +14 -0
  156. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  157. package/node_modules/iconv-lite/LICENSE +21 -0
  158. package/node_modules/iconv-lite/README.md +138 -0
  159. package/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
  160. package/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
  161. package/node_modules/iconv-lite/encodings/index.js +23 -0
  162. package/node_modules/iconv-lite/encodings/internal.js +218 -0
  163. package/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
  164. package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  165. package/node_modules/iconv-lite/encodings/sbcs-data.js +180 -0
  166. package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  167. package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  168. package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  169. package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  170. package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  171. package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  172. package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  173. package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  174. package/node_modules/iconv-lite/encodings/utf16.js +187 -0
  175. package/node_modules/iconv-lite/encodings/utf32.js +314 -0
  176. package/node_modules/iconv-lite/encodings/utf7.js +283 -0
  177. package/node_modules/iconv-lite/lib/bom-handling.js +48 -0
  178. package/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  179. package/node_modules/iconv-lite/lib/index.d.ts +129 -0
  180. package/node_modules/iconv-lite/lib/index.js +182 -0
  181. package/node_modules/iconv-lite/lib/streams.js +105 -0
  182. package/node_modules/iconv-lite/package.json +70 -0
  183. package/node_modules/iconv-lite/types/encodings.d.ts +425 -0
  184. package/node_modules/safer-buffer/LICENSE +21 -0
  185. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  186. package/node_modules/safer-buffer/Readme.md +156 -0
  187. package/node_modules/safer-buffer/dangerous.js +58 -0
  188. package/node_modules/safer-buffer/package.json +34 -0
  189. package/node_modules/safer-buffer/safer.js +77 -0
  190. package/node_modules/safer-buffer/tests.js +406 -0
  191. package/node_modules/semver/LICENSE +15 -0
  192. package/node_modules/semver/README.md +680 -0
  193. package/node_modules/semver/bin/semver.js +195 -0
  194. package/node_modules/semver/classes/comparator.js +143 -0
  195. package/node_modules/semver/classes/index.js +7 -0
  196. package/node_modules/semver/classes/range.js +577 -0
  197. package/node_modules/semver/classes/semver.js +350 -0
  198. package/node_modules/semver/functions/clean.js +8 -0
  199. package/node_modules/semver/functions/cmp.js +54 -0
  200. package/node_modules/semver/functions/coerce.js +62 -0
  201. package/node_modules/semver/functions/compare-build.js +9 -0
  202. package/node_modules/semver/functions/compare-loose.js +5 -0
  203. package/node_modules/semver/functions/compare.js +7 -0
  204. package/node_modules/semver/functions/diff.js +60 -0
  205. package/node_modules/semver/functions/eq.js +5 -0
  206. package/node_modules/semver/functions/gt.js +5 -0
  207. package/node_modules/semver/functions/gte.js +5 -0
  208. package/node_modules/semver/functions/inc.js +21 -0
  209. package/node_modules/semver/functions/lt.js +5 -0
  210. package/node_modules/semver/functions/lte.js +5 -0
  211. package/node_modules/semver/functions/major.js +5 -0
  212. package/node_modules/semver/functions/minor.js +5 -0
  213. package/node_modules/semver/functions/neq.js +5 -0
  214. package/node_modules/semver/functions/parse.js +18 -0
  215. package/node_modules/semver/functions/patch.js +5 -0
  216. package/node_modules/semver/functions/prerelease.js +8 -0
  217. package/node_modules/semver/functions/rcompare.js +5 -0
  218. package/node_modules/semver/functions/rsort.js +5 -0
  219. package/node_modules/semver/functions/satisfies.js +12 -0
  220. package/node_modules/semver/functions/sort.js +5 -0
  221. package/node_modules/semver/functions/truncate.js +48 -0
  222. package/node_modules/semver/functions/valid.js +8 -0
  223. package/node_modules/semver/index.js +93 -0
  224. package/node_modules/semver/internal/constants.js +37 -0
  225. package/node_modules/semver/internal/debug.js +11 -0
  226. package/node_modules/semver/internal/identifiers.js +29 -0
  227. package/node_modules/semver/internal/lrucache.js +42 -0
  228. package/node_modules/semver/internal/parse-options.js +17 -0
  229. package/node_modules/semver/internal/re.js +223 -0
  230. package/node_modules/semver/package.json +78 -0
  231. package/node_modules/semver/preload.js +4 -0
  232. package/node_modules/semver/range.bnf +17 -0
  233. package/node_modules/semver/ranges/gtr.js +6 -0
  234. package/node_modules/semver/ranges/intersects.js +9 -0
  235. package/node_modules/semver/ranges/ltr.js +6 -0
  236. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  237. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  238. package/node_modules/semver/ranges/min-version.js +63 -0
  239. package/node_modules/semver/ranges/outside.js +82 -0
  240. package/node_modules/semver/ranges/simplify.js +49 -0
  241. package/node_modules/semver/ranges/subset.js +249 -0
  242. package/node_modules/semver/ranges/to-comparators.js +10 -0
  243. package/node_modules/semver/ranges/valid.js +13 -0
  244. package/package.json +33 -27
  245. package/packages/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
  246. package/packages/octo-runtime-protocol/schema/protocol.schema.json +43 -1
  247. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.d.ts +0 -19
  248. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.js +0 -86
  249. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.d.ts +0 -5
  250. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.js +0 -35
@@ -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";
@@ -25,22 +26,26 @@ import { getGroupMembers } from "./api/conversations.js";
25
26
  import { getJson } from "./api/client.js";
26
27
  import { connectionFailure, ImConnectionError } from "./connection-error.js";
27
28
  import { sendReadReceipt } from "./api/messages.js";
28
- import { deliveryNoticeCard } from "../presentation/delivery-notice.js";
29
- import { ImSendError } from "../delivery/text-send.js";
29
+ import { ImSendError } from "../delivery/send-error.js";
30
+ import { assistantOutputFingerprint } from "../application/context-gap.js";
30
31
  import { observesImScope } from "./normalize.js";
31
32
  import { prepareArtifacts } from "../delivery/artifacts.js";
32
33
  import { uploadChatAttachment } from "./api/files.js";
34
+ import { MessageIdentityCache } from "./message-identities.js";
33
35
  /** Octo IM 平台连接器:WuKong 与 Octo REST 适配;不是 MCP 连接器。 */
34
36
  export class GatewayTransport {
35
37
  config;
36
38
  credentials;
37
39
  callbacks;
40
+ deliveryOwner;
38
41
  identity;
39
42
  botId;
40
43
  #detachAbort;
41
44
  #closing;
42
45
  #connection;
43
46
  #spaceId = "";
47
+ #token;
48
+ #deliveryScope = new ImDeliveryScope();
44
49
  get scopedConfig() {
45
50
  return { ...this.config, spaceId: this.#spaceId };
46
51
  }
@@ -51,18 +56,22 @@ export class GatewayTransport {
51
56
  #api;
52
57
  #delivery;
53
58
  #polling;
59
+ #messageIdentityCache = new MessageIdentityCache();
54
60
  #bindings = new Map();
55
- constructor(config, credentials, callbacks) {
61
+ constructor(config, credentials, callbacks,
62
+ // Bot 持有任务准备与 REST 投递的期限、凭据及身份,接收 WS 不拥有这些资源。
63
+ deliveryOwner) {
56
64
  this.config = config;
57
65
  this.credentials = credentials;
58
66
  this.callbacks = callbacks;
67
+ this.deliveryOwner = deliveryOwner;
59
68
  this.identity = imBotIdentity(config);
60
69
  this.botId = config.bot_id;
61
70
  }
62
71
  get status() {
63
72
  return {
64
73
  connected: this.#connected,
65
- cardDeliveries: this.#delivery?.receiptCount ?? 0
74
+ cardDeliveries: (this.deliveryOwner?.dispatcher ?? this.#delivery)?.receiptCount ?? 0
66
75
  };
67
76
  }
68
77
  async start(signal) {
@@ -74,17 +83,37 @@ export class GatewayTransport {
74
83
  if (!/^bf_[A-Za-z0-9_-]+$/.test(token))
75
84
  throw new Error("IM_BOT_TOKEN_INVALID");
76
85
  const principal = await verifyBotIdentity(this.config.api_url, token, signal);
77
- if (principal.bot_uid !== this.config.bot_id)
78
- throw new Error("IM_BOT_IDENTITY_MISMATCH");
79
- this.callbacks.authorizeSpace?.(principal.space_id);
86
+ signal.throwIfAborted();
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 在核验期间继续使用旧凭据;明确拒绝目标后必须撤销旧任务权限。
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;
105
+ // 代次与凭据在同一同步段生效,不等待后续注册或 WS 握手。
106
+ this.deliveryOwner?.acceptToken?.(token);
82
107
  const registration = await registerBot(this.config.api_url, token, signal);
83
108
  const toolEnvironment = octoCliEnvironment(this.config.api_url, token);
84
109
  if (signal.aborted)
85
110
  return;
86
- if (registration.robot_id !== this.config.bot_id)
111
+ if (registration.robot_id !== this.config.bot_id) {
112
+ // 注册明确拒绝身份也属于授权撤销;网络/握手失败则保留已核验凭据和任务。
113
+ this.deliveryOwner?.identity.revoke();
114
+ this.#deliveryScope.revoke();
87
115
  throw new Error("IM_BOT_IDENTITY_MISMATCH");
116
+ }
88
117
  const connection = new WukongConnection((message) => {
89
118
  if (this.#closed)
90
119
  return;
@@ -99,23 +128,62 @@ export class GatewayTransport {
99
128
  if (!acceptsImMessage(this.scopedConfig, message))
100
129
  return;
101
130
  let finalReply;
131
+ let finalOutputCovered = false;
132
+ const deliverySignal = AbortSignal.any([
133
+ this.deliveryOwner?.signal ?? signal,
134
+ this.#deliveryScope.signal
135
+ ]);
136
+ // 任务的普通回复、final、进度及失败卡共用 REST 工厂和任务期限。
137
+ const restDelivery = (turnSignal = deliverySignal, obsolete) => new OctoConnector(this.config, token, AbortSignal.any([deliverySignal, turnSignal]), (requestSignal, send) => this.#dispatchRestDelivery(requestSignal, (authorized, botToken) => {
138
+ if (obsolete?.())
139
+ throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
140
+ return send(authorized, botToken);
141
+ }));
142
+ const finalDispatcher = this.#delivery;
102
143
  let historyTurn;
103
- const outputObserver = () => {
144
+ const outputObserver = (payload) => {
104
145
  const turn = historyTurn;
105
146
  if (!turn || !observesImScope(this.scopedConfig, message.channelId, message.channelType))
106
147
  return undefined;
107
148
  return (messageSeq) => {
108
- if (this.#closed || signal.aborted)
149
+ if (deliverySignal.aborted)
109
150
  return;
110
- this.callbacks.onPosition?.({
151
+ (this.callbacks.onTaskPosition ?? this.callbacks.onPosition)?.({
111
152
  conversationId: message.channelId,
112
153
  conversationKind: message.channelType === 5 ? "thread" : "group",
113
154
  messageSeq,
114
155
  own: true,
115
- turn
156
+ turn,
157
+ ...(payload && turn.providerSessionId
158
+ ? { outputFingerprint: assistantOutputFingerprint(payload) }
159
+ : {})
116
160
  });
117
161
  };
118
162
  };
163
+ // 同一次在途 HTTP 共用 Promise;失败交回当前投递器,只有收尾拥有三次重试预算。
164
+ const sends = new Map();
165
+ const sendMessage = (payload, key, turnSignal, obsolete, observe) => {
166
+ turnSignal.throwIfAborted();
167
+ if (obsolete?.())
168
+ throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
169
+ if (this.#deliveryScope.isConfirmed(key))
170
+ return Promise.resolve("");
171
+ const pending = sends.get(key);
172
+ if (pending)
173
+ return pending;
174
+ const sending = restDelivery(turnSignal, obsolete)
175
+ .message(message, payload, key, observe)
176
+ .then((id) => {
177
+ this.#deliveryScope.confirm(key);
178
+ sends.delete(key);
179
+ return id;
180
+ }, (error) => {
181
+ sends.delete(key);
182
+ throw error;
183
+ });
184
+ sends.set(key, sending);
185
+ return sending;
186
+ };
119
187
  this.callbacks.onMessage({
120
188
  messageId: message.messageId,
121
189
  ...(message.channelType === 2 || message.channelType === 5
@@ -128,11 +196,11 @@ export class GatewayTransport {
128
196
  : {}),
129
197
  markRead: (turnSignal) => sendReadReceipt({
130
198
  apiUrl: this.config.api_url,
131
- botToken: token,
199
+ botToken: this.#taskToken(deliverySignal),
132
200
  channelId: message.channelId,
133
201
  channelType: message.channelType,
134
202
  messageIds: [message.messageId],
135
- signal: AbortSignal.any([signal, turnSignal])
203
+ signal: AbortSignal.any([deliverySignal, turnSignal])
136
204
  }),
137
205
  senderId: message.fromUid,
138
206
  conversationId: message.channelId,
@@ -148,12 +216,11 @@ export class GatewayTransport {
148
216
  : String(message.payload.content),
149
217
  ...(message.payload.type === 2
150
218
  ? {
151
- buildInputs: (turnSignal) => downloadImageInput(message.payload.url, this.config.api_url, token, AbortSignal.any([signal, turnSignal]))
219
+ buildInputs: (turnSignal) => downloadImageInput(message.payload.url, this.config.api_url, this.#taskToken(deliverySignal), AbortSignal.any([deliverySignal, turnSignal]))
152
220
  }
153
221
  : {}),
154
222
  executionEnvironment: () => {
155
- if (this.#closed || signal.aborted)
156
- throw new Error("IM_CONNECTION_REPLACED");
223
+ deliverySignal.throwIfAborted();
157
224
  return { executionEnvOverrides: structuredClone(toolEnvironment) };
158
225
  },
159
226
  runMetadata: {
@@ -161,22 +228,9 @@ export class GatewayTransport {
161
228
  botId: this.config.bot_id,
162
229
  channelType: message.channelType
163
230
  },
164
- isReplyDelivered: (effectKey) => connection.isDelivered(stableEffectKey(this.identity, message, effectKey, "text")),
165
- replyDeliveryUnknown: async (event, effectKey, replyEffectKey, deliverySignal) => {
166
- if (deliverySignal.aborted ||
167
- connection.isDelivered(stableEffectKey(this.identity, message, replyEffectKey, "text")))
168
- return;
169
- // F27:REST 跟随 Bot/Extra 的投递期限,不跟随已断开的 WS 连接期限。
170
- const rest = new OctoConnector(this.config, token, deliverySignal, async () => { });
171
- const sent = await rest.displayCard(message, deliveryNoticeCard(event), stableEffectKey(this.identity, message, effectKey, "delivery"), () => connection.isDelivered(stableEffectKey(this.identity, message, replyEffectKey, "text")));
172
- if (!sent &&
173
- !connection.isDelivered(stableEffectKey(this.identity, message, replyEffectKey, "text")))
174
- throw new ImSendError("IM_DELIVERY_NOTICE_UNSUPPORTED", "failed");
175
- },
176
- replyFailure: async (event, effectKey) => {
177
- if (this.#closed || signal.aborted)
178
- return;
179
- const template = await this.#api.reasoningTemplate();
231
+ replyFailure: async (event, effectKey, options) => {
232
+ const rest = restDelivery(options?.signal, options?.obsolete);
233
+ const template = await rest.reasoningTemplate();
180
234
  if (!template)
181
235
  return;
182
236
  const projector = new ImRunProjector(`channel:${effectKey}`, message.channelType === 1);
@@ -184,38 +238,48 @@ export class GatewayTransport {
184
238
  const frame = buildReasoningFrame(projector.snapshot(), template);
185
239
  if (!frame)
186
240
  throw Error("IM_CARD_BUDGET_EXCEEDED");
187
- await this.#api.card(message, template, frame, stableEffectKey(this.identity, message, effectKey, "error"), undefined, 1, false);
241
+ await rest.card(message, template, frame, stableEffectKey(this.identity, message, effectKey, "error"), undefined, 1, false);
188
242
  },
189
- reply: async (text, effectKey) => {
190
- // 闭包绑定接收消息的连接和地址;配置替换后不把旧 Run 的回复转到新账号。
191
- if (this.#closed || signal.aborted)
192
- throw new Error("IM_CONNECTION_REPLACED");
243
+ reply: async (text, effectKey, options) => {
244
+ // 目标归属冻结在原消息,REST 使用 Bot 期限和持有凭据,不等待 WS 恢复。
245
+ const replySignal = options
246
+ ? AbortSignal.any([deliverySignal, options.signal])
247
+ : deliverySignal;
248
+ if (options?.obsolete())
249
+ throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
193
250
  const key = stableEffectKey(this.identity, message, effectKey ?? message.messageId, "text");
194
- await connection.sendText(message.channelId, message.channelType, text, key, this.#spaceId, undefined, undefined, outputObserver());
251
+ await sendMessage({ type: 1, content: text }, key, replySignal, options?.obsolete, outputObserver());
195
252
  },
196
253
  replyFinal: async (text, effectKey, options) => {
197
- if (this.#closed || signal.aborted)
198
- throw new Error("IM_CONNECTION_REPLACED");
199
- const finalSignal = options ? AbortSignal.any([signal, options.signal]) : signal;
200
- finalSignal.throwIfAborted();
254
+ const finalSignal = options
255
+ ? AbortSignal.any([deliverySignal, options.signal])
256
+ : deliverySignal;
257
+ // 准备与投递共用任务身份,切网不取消;停止/换账号不能继续。
258
+ this.#taskToken(finalSignal);
201
259
  if (options?.obsolete())
202
260
  throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
203
261
  if (finalReply?.key !== effectKey)
204
262
  finalReply = {
205
263
  key: effectKey,
206
264
  // 整个准备按 effect 缓存,发送重试不再次上传;链接变化必须先于 mention 偏移计算。
265
+ // 普通上传/成员查询故障在各准备函数内降级为正文;取消或身份撤销不能重建准备而复活。
207
266
  value: (async () => {
208
267
  const delivered = options
209
- ? await prepareArtifacts(text, options.artifacts, finalSignal, (bytes, name, mime, uploadSignal) => uploadChatAttachment(this.config.api_url, token, bytes, name, mime, uploadSignal))
268
+ ? await prepareArtifacts(text, options.artifacts, finalSignal, (bytes, name, mime, uploadSignal) => uploadChatAttachment(this.config.api_url, token, bytes, name, mime, uploadSignal, this.#dispatchRestDelivery))
210
269
  : { text, files: [] };
211
270
  const failures = [];
212
- // 每张文件卡有独立回执;整段准备只执行一次,文本重试不重复卡片或上传。
271
+ // 每张最终文件卡首发后最多重试三次;整段准备仅一次,文本重试不重开预算或上传。
213
272
  for (const [index, file] of delivered.files.entries()) {
214
273
  finalSignal.throwIfAborted();
215
274
  if (options?.obsolete())
216
275
  throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
217
276
  const key = stableEffectKey(this.identity, message, effectKey, `file:${index}`);
218
- const receipt = await this.#delivery.deliver(key, () => connection.sendFile(message.channelId, message.channelType, file, key, this.#spaceId, finalSignal, outputObserver()), { obsolete: () => finalSignal.aborted || Boolean(options?.obsolete()) });
277
+ const receipt = await finalDispatcher.deliver(key, async () => {
278
+ return sendMessage({ type: 8, ...file }, key, finalSignal, () => Boolean(options?.obsolete()), outputObserver(delivered.incomplete ? undefined : { type: 8, ...file }));
279
+ }, {
280
+ attempts: 4,
281
+ obsolete: () => finalSignal.aborted || Boolean(options?.obsolete())
282
+ });
219
283
  if (receipt.state !== "delivered")
220
284
  failures.push(`${file.name.replace(/[\r\n\x60[\]<>]/g, "_").slice(0, 120)} (${receipt.state}: ${receipt.code ?? "IM_DELIVERY_UNKNOWN"})`);
221
285
  }
@@ -223,6 +287,8 @@ export class GatewayTransport {
223
287
  (failures.length
224
288
  ? `\n\nFile card delivery unconfirmed: ${failures.join("; ")}. The attachment download links above remain available; generation was not rerun.`
225
289
  : "");
290
+ // 新增失败事实不在先前 assistant 中,不能因它由本机发送而过滤。
291
+ finalOutputCovered = !delivered.incomplete && failures.length === 0;
226
292
  finalSignal.throwIfAborted();
227
293
  return prepareFinalMention(finalText, async () => {
228
294
  if ([2, 5].includes(message.channelType))
@@ -230,39 +296,58 @@ export class GatewayTransport {
230
296
  apiUrl: this.config.api_url,
231
297
  botToken: token,
232
298
  groupNo: groupScope(message.channelId).groupNo,
299
+ dispatchRequest: this.#dispatchRestDelivery,
233
300
  signal: finalSignal
234
301
  });
235
- const peer = await getJson(this.config.api_url, token, `/v1/bot/user/info?uid=${encodeURIComponent(message.fromUid)}`, AbortSignal.any([finalSignal, AbortSignal.timeout(5000)]), { maxResponseBytes: 64 << 10, logRateLimit: false });
302
+ const peer = await getJson(this.config.api_url, token, `/v1/bot/user/info?uid=${encodeURIComponent(message.fromUid)}`, AbortSignal.any([finalSignal, AbortSignal.timeout(5000)]), {
303
+ maxResponseBytes: 64 << 10,
304
+ logRateLimit: false,
305
+ dispatchRequest: this.#dispatchRestDelivery
306
+ });
236
307
  return peer?.uid === message.fromUid ? [peer] : [];
237
308
  });
238
309
  })()
239
310
  };
240
311
  const result = await finalReply.value;
241
- if (this.#closed || signal.aborted)
242
- throw new Error("IM_CONNECTION_REPLACED");
243
- finalSignal.throwIfAborted();
244
312
  if (options?.obsolete())
245
313
  throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
246
- await connection.sendText(message.channelId, message.channelType, result.text, stableEffectKey(this.identity, message, effectKey, "text"), this.#spaceId, result.mention, finalSignal, outputObserver());
314
+ await sendMessage({
315
+ type: 1,
316
+ content: result.text,
317
+ ...(result.mention ? { mention: result.mention } : {})
318
+ }, stableEffectKey(this.identity, message, effectKey, "text"), finalSignal, () => Boolean(options?.obsolete()), outputObserver(finalOutputCovered
319
+ ? {
320
+ type: 1,
321
+ content: result.text,
322
+ ...(result.mention ? { mention: result.mention } : {})
323
+ }
324
+ : undefined));
247
325
  },
248
326
  buildContext: async (turnSignal, options) => ({
249
327
  schema: CONTEXT_SCHEMA,
250
- items: await build_im_contexts(this.scopedConfig, message, token, AbortSignal.any([signal, turnSignal]), options)
328
+ items: await build_im_contexts(this.scopedConfig, message, this.#taskToken(deliverySignal), AbortSignal.any([deliverySignal, turnSignal]), {
329
+ ...options,
330
+ initialSession: options?.initialSession ?? false,
331
+ identityCache: this.#messageIdentityCache
332
+ })
251
333
  }),
252
334
  beginPresentation: (runId, onDiagnostic, controls) => {
335
+ // 卡片是 REST,不以 WS 存活为前提。保留同一 CardSession 的消息 ID/序号,
336
+ // 仅 Bot 停止取消其请求;重连不将旧连接 signal 传入客户端或投递器。
337
+ const progressApi = restDelivery();
253
338
  const interactions = new Map();
254
339
  const resolveInteraction = async (id, status) => {
255
340
  const entry = interactions.get(id);
256
341
  if (!entry)
257
342
  return;
258
- const messageId = await this.#api.interactionCard(message, interactionCard(entry.request, status), stableEffectKey(this.identity, message, id, "interaction"), entry.messageId);
343
+ const messageId = await progressApi.interactionCard(message, interactionCard(entry.request, status), stableEffectKey(this.identity, message, id, "interaction"), entry.messageId);
259
344
  // 能力不可用会返回 undefined;已显示卡片只有确认编辑成功后才能移除。
260
345
  if (messageId !== entry.messageId)
261
346
  throw new Error("IM_INTERACTION_CARD_FINALIZATION_UNCONFIRMED");
262
347
  interactions.delete(id);
263
348
  };
264
349
  const stopTyping = this.config.typing === false ? () => { } : this.#typing.acquire(message, runId);
265
- const card = new CardSession(this.#api, this.#delivery, message, runId, stopTyping, onDiagnostic);
350
+ const card = new CardSession(progressApi, finalDispatcher, message, runId, stopTyping, onDiagnostic);
266
351
  this.#bindings.set(runId, {
267
352
  card,
268
353
  address: message,
@@ -271,7 +356,8 @@ export class GatewayTransport {
271
356
  expires: Date.now() + 86_400_000 + 30 * 60_000,
272
357
  active: true,
273
358
  turn: historyTurn,
274
- interactions
359
+ interactions,
360
+ resolveInteraction
275
361
  });
276
362
  if (this.#bindings.size > 128) {
277
363
  const idle = [...this.#bindings].find(([, binding]) => !binding.active);
@@ -282,11 +368,15 @@ export class GatewayTransport {
282
368
  this.#polling = this.#pollActions(token, signal);
283
369
  return {
284
370
  interaction: async (request) => {
371
+ // 旧按钮轮询不迁移;已失去绑定的连接不再创建无法响应的新交互。
372
+ // 已开始的发卡及已存在卡片的收尾则继续使用任务 REST 期限。
373
+ if (this.#closed || signal.aborted)
374
+ return false;
285
375
  const document = interactionCard(request);
286
376
  const effect = stableEffectKey(this.identity, message, request.interactionId, "interaction");
287
377
  let messageId;
288
378
  const receipt = await this.#delivery.deliver(effect, async () => {
289
- messageId = await this.#api.interactionCard(message, document, effect);
379
+ messageId = await progressApi.interactionCard(message, document, effect);
290
380
  if (!messageId)
291
381
  throw Error("IM_INTERACTION_CARD_UNAVAILABLE");
292
382
  return messageId;
@@ -297,7 +387,13 @@ export class GatewayTransport {
297
387
  request: structuredClone(request),
298
388
  messageId: receipt.messageId
299
389
  });
300
- return true;
390
+ // REST 发卡期间 WS 可能已退出并清除按钮绑定。保留回执用于收尾,
391
+ // 但仅仍可处理按钮的原绑定算可用,否则由 Runtime 发送文字交互命令。
392
+ const binding = this.#bindings.get(runId);
393
+ return (!this.#closed &&
394
+ !signal.aborted &&
395
+ binding?.active === true &&
396
+ binding.interactions === interactions);
301
397
  },
302
398
  resolveInteraction,
303
399
  update: (snapshot) => card.update(snapshot),
@@ -323,6 +419,8 @@ export class GatewayTransport {
323
419
  throw new AggregateError(errors, "IM_PRESENTATION_FAILED");
324
420
  }
325
421
  finally {
422
+ // 仅保留按钮所需的轻量关联,避免卡片回调继续引用本轮投影上下文。
423
+ card.release();
326
424
  const binding = this.#bindings.get(runId);
327
425
  if (binding) {
328
426
  binding.active = false;
@@ -359,12 +457,8 @@ export class GatewayTransport {
359
457
  });
360
458
  });
361
459
  this.#connection = connection;
362
- this.#api = new OctoConnector(this.config, token, signal, async (address, text, effectKey) => {
363
- if (this.#closed || signal.aborted)
364
- throw new Error("IM_CONNECTION_REPLACED");
365
- await connection.sendText(address.channelId, address.channelType, text, effectKey, this.#spaceId);
366
- });
367
- this.#delivery = new ImDeliveryDispatcher(signal);
460
+ this.#api = new OctoConnector(this.config, token, signal);
461
+ this.#delivery = this.deliveryOwner?.dispatcher ?? new ImDeliveryDispatcher(signal);
368
462
  this.#typing = new TypingController((address, typingSignal) => this.#api.typing(address, typingSignal), () => this.callbacks.onDiagnostic?.("IM_TYPING_FAILED"));
369
463
  const abort = () => {
370
464
  void connection.close();
@@ -382,6 +476,39 @@ export class GatewayTransport {
382
476
  throw new ImConnectionError("IM_DISCONNECTED", true);
383
477
  this.#connected = true;
384
478
  }
479
+ /** REST 消费 Bot 已持有的凭据;WS 清理/鉴权/握手均不影响其准入。 */
480
+ #dispatchRestDelivery = async (signal, send) => {
481
+ const requestSignal = AbortSignal.any([
482
+ signal,
483
+ this.#deliveryScope.signal,
484
+ ...(this.deliveryOwner ? [this.deliveryOwner.signal] : [])
485
+ ]);
486
+ try {
487
+ const token = this.#taskToken(requestSignal);
488
+ // 只读取已注入的值,不触发宿主获取/刷新;检查、替换头与 fetch 同步完成。
489
+ return send(requestSignal, token);
490
+ }
491
+ catch (error) {
492
+ this.#deliveryScope.signal.throwIfAborted();
493
+ if (signal.aborted || this.deliveryOwner?.signal.aborted)
494
+ throw new ImSendError("IM_DELIVERY_CANCELLED", "failed");
495
+ throw error;
496
+ }
497
+ };
498
+ /** 同步读取 Bot 已持有凭据并核验原任务归属;不检查或等待任何 WS 状态。 */
499
+ #taskToken(signal) {
500
+ signal.throwIfAborted();
501
+ this.#deliveryScope.signal.throwIfAborted();
502
+ this.deliveryOwner?.signal.throwIfAborted();
503
+ const owner = this.deliveryOwner;
504
+ // 身份撤销由 Bot 持有的 deliveryScope 保证,不读取当前 WS 或连接代次。
505
+ const token = owner?.token ? owner.token()?.trim() : this.#token;
506
+ if (!token)
507
+ throw new ImSendError("IM_CREDENTIALS_REQUIRED", "failed");
508
+ if (!/^bf_[A-Za-z0-9_-]+$/.test(token))
509
+ throw new ImSendError("IM_BOT_TOKEN_INVALID", "failed");
510
+ return token;
511
+ }
385
512
  async #pollActions(token, signal) {
386
513
  if (this.config.cards === false)
387
514
  return;
@@ -437,9 +564,8 @@ export class GatewayTransport {
437
564
  if (!binding.active || !binding.controls.respond)
438
565
  continue;
439
566
  await binding.controls.respond(interactionAnswer(interaction.request, action));
440
- binding.interactions.delete(interaction.request.interactionId);
441
567
  try {
442
- await this.#api.interactionCard(binding.address, interactionCard(interaction.request, "resolved"), stableEffectKey(this.identity, binding.address, interaction.request.interactionId, "interaction"), interaction.messageId);
568
+ await binding.resolveInteraction(interaction.request.interactionId, "resolved");
443
569
  }
444
570
  catch {
445
571
  this.callbacks.onDiagnostic?.("IM_INTERACTION_CARD_FAILED");
@@ -502,9 +628,14 @@ export class GatewayTransport {
502
628
  const errors = results
503
629
  .filter((result) => result.status === "rejected")
504
630
  .map((result) => result.reason);
631
+ // WS 重连只移除按钮关联;仍在运行的 REST 卡片由任务 finish 负责释放。
632
+ // 没有 Bot 所有者、Bot 已停止或任务已结束时,保留连接清理的兜底回收。
633
+ for (const binding of this.#bindings.values())
634
+ if (!binding.active || !this.deliveryOwner || this.deliveryOwner.signal.aborted)
635
+ binding.card.release();
636
+ this.#bindings.clear();
505
637
  if (errors.length)
506
638
  throw new AggregateError(errors, "IM_TRANSPORT_DISPOSE_FAILED");
507
- this.#bindings.clear();
508
639
  });
509
640
  return this.#closing;
510
641
  }
@@ -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 retryAfter = response.headers.get("retry-after");
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,19 +1,18 @@
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
- readonly sendWsText: (address: ImAddress, text: string, effectKey: string) => Promise<void>;
9
- constructor(config: OctoBotConfig, token: string, signal: AbortSignal, sendWsText: (address: ImAddress, text: string, effectKey: string) => Promise<void>);
9
+ readonly dispatchRequest?: HttpRequestDispatch | undefined;
10
+ constructor(config: OctoBotConfig, token: string, signal: AbortSignal, dispatchRequest?: HttpRequestDispatch | undefined);
10
11
  reasoningTemplate(): Promise<ReasoningTemplate | undefined>;
11
- requestSignal(signal?: AbortSignal): AbortSignal;
12
12
  typing(address: ImAddress, signal: AbortSignal): Promise<void>;
13
- text(address: ImAddress, text: string, effectKey: string): Promise<void>;
14
- notification(address: ImAddress, text: string, effectKey: string): Promise<string>;
13
+ /** 任务文本/文件经 REST 投递;返回真实消息 ID,位置可选,不以 WS ACK 确认。 */
14
+ message(address: ImAddress, payload: Record<string, unknown>, effectKey: string, onPosition?: (sequence: number) => void): Promise<string>;
15
15
  interactionCard(address: ImAddress, card: Record<string, unknown>, effectKey: string, messageId?: string): Promise<string | undefined>;
16
- displayCard(address: ImAddress, card: Record<string, unknown>, effectKey: string, obsolete?: () => boolean): Promise<string | undefined>;
17
16
  card(address: ImAddress, template: ReasoningTemplate, frame: ReasoningFrame, effectKey: string, messageId?: string, seq?: number, transient?: boolean): Promise<string>;
18
17
  }
19
18
  export declare function stableEffectKey(endpointId: string, address: ImAddress, runId: string, kind: string): string;