@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
@@ -0,0 +1,16 @@
1
+ /** 当前 Bot 的展示身份查询;不替代准入、权限或出站 mention 成员核验。 */
2
+ import type { ScopedOctoBotConfig } from "../contracts.js";
3
+ export interface MessageIdentity {
4
+ uid: string;
5
+ name: string | null;
6
+ type: "human" | "bot" | "unknown";
7
+ }
8
+ /** 每个 Transport 独立持有,固定 10 分钟 TTL;无定时器、不落盘、容量有界。 */
9
+ export declare class MessageIdentityCache {
10
+ #private;
11
+ get(config: ScopedOctoBotConfig, uid: string): MessageIdentity | undefined;
12
+ set(config: ScopedOctoBotConfig, value: MessageIdentity): void;
13
+ }
14
+ export declare function unknownIdentity(uid: string): MessageIdentity;
15
+ /** 只补查缓存未命中项;失败保留已命中身份,取消仍传播,不重试或换接口。 */
16
+ export declare function resolveMessageIdentities(config: ScopedOctoBotConfig, requested: string[], token: string, signal: AbortSignal, cache?: MessageIdentityCache, deadline?: AbortSignal): Promise<Map<string, MessageIdentity>>;
@@ -0,0 +1,74 @@
1
+ import { postJson } from "./api/client.js";
2
+ /** 每个 Transport 独立持有,固定 10 分钟 TTL;无定时器、不落盘、容量有界。 */
3
+ export class MessageIdentityCache {
4
+ #entries = new Map();
5
+ #key(config, uid) {
6
+ return JSON.stringify([config.api_url, config.bot_id, config.spaceId, uid]);
7
+ }
8
+ get(config, uid) {
9
+ const key = this.#key(config, uid);
10
+ const entry = this.#entries.get(key);
11
+ if (!entry)
12
+ return undefined;
13
+ if (entry.expiresAt <= Date.now()) {
14
+ this.#entries.delete(key);
15
+ return undefined;
16
+ }
17
+ return { ...entry.value };
18
+ }
19
+ set(config, value) {
20
+ if (value.name === null && value.type === "unknown")
21
+ return;
22
+ const key = this.#key(config, value.uid);
23
+ this.#entries.delete(key);
24
+ this.#entries.set(key, { value: { ...value }, expiresAt: Date.now() + 600_000 });
25
+ while (this.#entries.size > 2000)
26
+ this.#entries.delete(this.#entries.keys().next().value);
27
+ }
28
+ }
29
+ export function unknownIdentity(uid) {
30
+ return { uid, name: null, type: "unknown" };
31
+ }
32
+ /** 只补查缓存未命中项;失败保留已命中身份,取消仍传播,不重试或换接口。 */
33
+ export async function resolveMessageIdentities(config, requested, token, signal, cache, deadline = AbortSignal.any([signal, AbortSignal.timeout(5_000)])) {
34
+ signal.throwIfAborted();
35
+ const result = new Map();
36
+ const missing = [];
37
+ for (const uid of new Set(requested)) {
38
+ const hit = cache?.get(config, uid);
39
+ if (hit)
40
+ result.set(uid, hit);
41
+ else if (uid && Buffer.byteLength(uid) <= 64 && missing.length < 200)
42
+ missing.push(uid);
43
+ }
44
+ if (!missing.length)
45
+ return result;
46
+ try {
47
+ const response = await postJson(config.api_url, token, "/v1/bot/users/batch", { uids: missing }, deadline, { retryOn429: false, logRateLimit: false, maxResponseBytes: 1_048_576 });
48
+ const wanted = new Set(missing);
49
+ for (const value of (Array.isArray(response?.users) ? response.users : [])) {
50
+ if (!value || typeof value !== "object" || Array.isArray(value))
51
+ continue;
52
+ const row = value;
53
+ if (typeof row.uid !== "string" || !wanted.has(row.uid))
54
+ continue;
55
+ const identity = {
56
+ uid: row.uid,
57
+ name: typeof row.name === "string" && row.name.trim() && Array.from(row.name).length <= 256
58
+ ? row.name
59
+ : null,
60
+ type: row.robot === true || row.robot === 1
61
+ ? "bot"
62
+ : row.robot === false || row.robot === 0
63
+ ? "human"
64
+ : "unknown"
65
+ };
66
+ result.set(identity.uid, identity);
67
+ cache?.set(config, identity);
68
+ }
69
+ }
70
+ catch {
71
+ signal.throwIfAborted();
72
+ }
73
+ return result;
74
+ }
@@ -0,0 +1,4 @@
1
+ /** API/WS 时间为秒,已解码历史为毫秒;单位由调用方明确,缺失或无效时间不补为当前时间。 */
2
+ export declare function messageDate(timestamp: unknown, unit: "seconds" | "milliseconds"): Date | undefined;
3
+ /** 按该消息时刻的系统时区输出 ISO 8601,保留显式偏移(含夏令时),不转换为 UTC Z。 */
4
+ export declare function messageSentAt(timestamp: unknown, unit: "seconds" | "milliseconds"): string | null;
@@ -0,0 +1,19 @@
1
+ /** API/WS 时间为秒,已解码历史为毫秒;单位由调用方明确,缺失或无效时间不补为当前时间。 */
2
+ export function messageDate(timestamp, unit) {
3
+ if (typeof timestamp !== "number" || !Number.isSafeInteger(timestamp) || timestamp <= 0)
4
+ return undefined;
5
+ const milliseconds = unit === "seconds" ? timestamp * 1000 : timestamp;
6
+ if (milliseconds > 0xffffffff * 1000)
7
+ return undefined;
8
+ return new Date(milliseconds);
9
+ }
10
+ /** 按该消息时刻的系统时区输出 ISO 8601,保留显式偏移(含夏令时),不转换为 UTC Z。 */
11
+ export function messageSentAt(timestamp, unit) {
12
+ const date = messageDate(timestamp, unit);
13
+ if (!date)
14
+ return null;
15
+ const pad = (value, width = 2) => String(value).padStart(width, "0");
16
+ const offset = -date.getTimezoneOffset();
17
+ const zone = `${offset >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(offset) / 60))}:${pad(Math.abs(offset) % 60)}`;
18
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${zone}`;
19
+ }
@@ -0,0 +1,7 @@
1
+ /** 本轮触发事实:只补查已准入消息的会话和身份,缺失信息不从正文或 UID 猜测。 */
2
+ import type { ContextItem } from "@mininglamp-oss/octo-runtime-protocol";
3
+ import type { ScopedOctoBotConfig } from "../contracts.js";
4
+ import type { ImMessage } from "./wukong.js";
5
+ import { type MessageIdentityCache } from "./message-identities.js";
6
+ /** 返回模型可读 JSON;外部取消继续传播,补充信息失败只留下真实 ID 和未知值。 */
7
+ export declare function buildMessageTrigger(config: ScopedOctoBotConfig, message: ImMessage, token: string, signal: AbortSignal, cache?: MessageIdentityCache): Promise<ContextItem | undefined>;
@@ -0,0 +1,90 @@
1
+ import { getJson } from "./api/client.js";
2
+ import { groupScope } from "./normalize.js";
3
+ import { messageSentAt } from "./message-time.js";
4
+ import { resolveMessageIdentities, unknownIdentity } from "./message-identities.js";
5
+ const requestOptions = { retryOn429: false, logRateLimit: false, maxResponseBytes: 1_048_576 };
6
+ function object(value) {
7
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
8
+ }
9
+ function name(value) {
10
+ return typeof value === "string" && value.trim() ? value : null;
11
+ }
12
+ /** 返回模型可读 JSON;外部取消继续传播,补充信息失败只留下真实 ID 和未知值。 */
13
+ export async function buildMessageTrigger(config, message, token, signal, cache) {
14
+ if (typeof message.channelId !== "string" || typeof message.messageId !== "string")
15
+ return undefined;
16
+ signal.throwIfAborted();
17
+ const mention = object(message.payload?.mention);
18
+ const targets = [
19
+ ...new Set(Array.isArray(mention.uids)
20
+ ? mention.uids.filter((uid) => typeof uid === "string" && !!uid)
21
+ : [])
22
+ ];
23
+ const senderUid = typeof message.fromUid === "string" ? message.fromUid : "";
24
+ // 批量 API 上限 200;超过查询上限的 @ 目标仍保留 UID,名称和类型标未知。
25
+ const uids = [...new Set([senderUid, config.bot_id, ...targets])].filter((uid) => uid && Buffer.byteLength(uid) <= 64);
26
+ const scope = groupScope(message.channelId);
27
+ const inGroup = [2, 5].includes(message.channelType);
28
+ const inTopic = message.channelType === 5 && !!scope.shortId;
29
+ const deadline = AbortSignal.any([signal, AbortSignal.timeout(5_000)]);
30
+ const optional = async (read) => {
31
+ try {
32
+ return await read();
33
+ }
34
+ catch {
35
+ signal.throwIfAborted();
36
+ return undefined;
37
+ }
38
+ };
39
+ const groupPath = `/v1/bot/groups/${encodeURIComponent(scope.groupNo)}`;
40
+ const [users, detail] = await Promise.all([
41
+ resolveMessageIdentities(config, uids, token, signal, cache, deadline),
42
+ inGroup
43
+ ? optional(() => getJson(config.api_url, token, inTopic ? `${groupPath}/threads/${encodeURIComponent(scope.shortId)}` : groupPath, deadline, requestOptions))
44
+ : undefined
45
+ ]);
46
+ signal.throwIfAborted();
47
+ const data = object(detail);
48
+ const matchingGroup = data.group_no === scope.groupNo;
49
+ const matchingTopic = matchingGroup && data.short_id === scope.shortId;
50
+ const known = (uid) => users.get(uid) ?? unknownIdentity(uid);
51
+ const sentAt = messageSentAt(message.timestamp, "seconds");
52
+ const enabled = (value) => value === true || value === 1;
53
+ return {
54
+ namespace: "extra.im",
55
+ name: "message-trigger",
56
+ guidance: "Current message: conversation=channel ID/type, sender=actor, recipient=this Bot, sentAt=system-zone time, mentions=actual @ targets; null=unknown.",
57
+ payload: {
58
+ messageId: message.messageId,
59
+ sentAt,
60
+ conversation: {
61
+ id: message.channelId,
62
+ type: inTopic ? "group_topic" : inGroup ? "group" : "dm",
63
+ ...(inGroup
64
+ ? {
65
+ group: {
66
+ id: scope.groupNo,
67
+ name: matchingGroup ? name(inTopic ? data.group_name : data.name) : null
68
+ }
69
+ }
70
+ : {}),
71
+ ...(inTopic
72
+ ? {
73
+ topic: {
74
+ id: scope.shortId,
75
+ name: matchingTopic ? name(data.name) : null
76
+ }
77
+ }
78
+ : {})
79
+ },
80
+ sender: senderUid ? known(senderUid) : { uid: null, name: null, type: "unknown" },
81
+ recipient: { botId: config.bot_id, name: known(config.bot_id).name },
82
+ mentions: {
83
+ targets: targets.map(known),
84
+ ...(enabled(mention.ais) ? { allBots: true } : {}),
85
+ ...(enabled(mention.all) ? { allMembers: true } : {}),
86
+ ...(enabled(mention.humans) ? { allHumans: true } : {})
87
+ }
88
+ }
89
+ };
90
+ }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  // Port of octo-agent-app-channel/internal/transport/progress.go display rules.
6
6
  import { failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
7
+ import { fromMarkdown } from "mdast-util-from-markdown";
7
8
  import { MODEL_WAIT_TIMEOUT_MESSAGE } from "../execution/model-wait.js";
8
9
  import { clampRunes, compactRunes } from "../presentation/run-projector.js";
9
10
  export function formatDuration(ms) {
@@ -14,8 +15,32 @@ export function formatDuration(ms) {
14
15
  return `${(ms / 1000).toFixed(1).replace(/\.0$/, "")}s`;
15
16
  return `${Math.floor(ms / 60_000)}m ${Math.floor((ms % 60_000) / 1000)}s`;
16
17
  }
18
+ /** 进度只展示文字;产物链接与图片由独立 final 交付,不能进入服务端卡片的 URL 校验面。 */
19
+ function plainText(text) {
20
+ const read = (node) => {
21
+ if (node.type === "definition")
22
+ return "";
23
+ if (node.type === "break")
24
+ return "\n";
25
+ return (node.value ??
26
+ node.alt ??
27
+ node.children
28
+ ?.map(read)
29
+ .join(["root", "list", "blockquote"].includes(node.type) ? "\n" : "") ??
30
+ "");
31
+ };
32
+ return read(fromMarkdown(text));
33
+ }
34
+ function literalText(text) {
35
+ // code/HTML/标签本身也可能含 Markdown;还原可读文字后转义,避免再次被模板解释为链接。
36
+ return (plainText(text)
37
+ .trim()
38
+ .replace(/[\\`*[\]<>]/g, "\\$&")
39
+ // 单词内部的下划线不是 emphasis;保留诊断编号等标识的原样表达。
40
+ .replace(/(?<![\p{L}\p{N}])_|_(?![\p{L}\p{N}])/gu, "\\$&") || "—");
41
+ }
17
42
  function thought(text) {
18
- text = text.replace(/\s+/g, " ").trim();
43
+ text = plainText(text).replace(/\s+/g, " ").trim();
19
44
  if (/OPENCLAW_INTERNAL/i.test(text))
20
45
  return "Reasoning summary hidden";
21
46
  return text ? compactRunes(text, 180) : "—";
@@ -74,7 +99,7 @@ function action(item) {
74
99
  };
75
100
  }
76
101
  export function reasoningPhases(snapshot) {
77
- const steps = snapshot.items.filter((i) => i.kind === "model_step");
102
+ const steps = snapshot.modelSteps ?? snapshot.items.filter((i) => i.kind === "model_step");
78
103
  let phases;
79
104
  if (steps.length) {
80
105
  phases = steps.flatMap((step, index) => {
@@ -97,7 +122,7 @@ export function reasoningPhases(snapshot) {
97
122
  : ["stop", "end_turn", "completed"].includes(step.finishReason ?? "")
98
123
  ? "整理回答"
99
124
  : "模型处理";
100
- let heading = `第 ${index + 1} 轮 · ${label}${step.durationMs === undefined ? "" : " · " + formatDuration(step.durationMs)}`;
125
+ let heading = `第 ${step.ordinal ?? index + 1} 轮 · ${label}${step.durationMs === undefined ? "" : " · " + formatDuration(step.durationMs)}`;
101
126
  if (segments.length > 1)
102
127
  heading += ` · 阶段 ${segmentIndex + 1}`;
103
128
  const failed = children.some((i) => i.kind === "tool" && i.status === "failed" && i.outcome !== "check_findings");
@@ -199,6 +224,7 @@ export function buildReasoningFrame(snapshot, template) {
199
224
  progressText: (snapshot.label ?? label) + (elapsed ? " · 已耗时 " + elapsed : ""),
200
225
  phases: reasoningPhases(snapshot)
201
226
  };
227
+ let errorIdentity = "";
202
228
  if (snapshot.phase === "accepted" && !snapshot.terminal) {
203
229
  // 第一帧立即显示思考中,只展示状态,不伪造 reasoning 内容或计数。
204
230
  frame.title = "思考中";
@@ -276,11 +302,10 @@ export function buildReasoningFrame(snapshot, template) {
276
302
  ]
277
303
  }
278
304
  ];
279
- const identity = snapshot.failure
280
- ? `\n错误码:${snapshot.failure.code}\n诊断编号:${snapshot.failure.diagnosticId}`
305
+ errorIdentity = snapshot.failure
306
+ ? "\n" +
307
+ literalText(`错误码:${snapshot.failure.code}\n诊断编号:${snapshot.failure.diagnosticId}`)
281
308
  : "";
282
- frame.errorMessage =
283
- clampRunes(frame.errorMessage, Math.max(1, 121 - Array.from(identity).length)) + identity;
284
309
  }
285
310
  }
286
311
  const thoughtMax = template.ref.version === "0.4.0" ? 4000 : 280;
@@ -347,6 +372,7 @@ export function buildReasoningFrame(snapshot, template) {
347
372
  if (confirmed) {
348
373
  frame.errorTitle = "请求超时";
349
374
  frame.errorMessage = MODEL_WAIT_TIMEOUT_MESSAGE + detail;
375
+ errorIdentity = "";
350
376
  delete frame.progressText;
351
377
  }
352
378
  else if (!snapshot.resultUnknown) {
@@ -357,8 +383,17 @@ export function buildReasoningFrame(snapshot, template) {
357
383
  else
358
384
  frame.collapsedSummary += detail;
359
385
  }
360
- for (const phase of frame.phases)
361
- phase.thought = clampRunes(phase.thought, thoughtMax);
386
+ // 转换发生在展示副本上,并先于字符/字节预算;不改 projector 的原正文或附件交付输入。
387
+ for (const phase of frame.phases) {
388
+ phase.thought = clampRunes(literalText(phase.thought), thoughtMax);
389
+ for (const action of phase.actions) {
390
+ action.tool = clampRunes(literalText(action.tool), 81);
391
+ action.detail = clampRunes(literalText(action.detail), 192);
392
+ }
393
+ }
394
+ if (frame.errorMessage)
395
+ frame.errorMessage =
396
+ clampRunes(literalText(frame.errorMessage), Math.max(1, 121 - Array.from(errorIdentity).length)) + errorIdentity;
362
397
  let total = frame.phases.reduce((size, phase) => size + Array.from(phase.thought).length, 0);
363
398
  for (const phase of frame.phases) {
364
399
  if (total <= 540)
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 解析 HTTP Retry-After 的秒数或日期,返回相对 nowMs 的非负毫秒数。
3
+ * 无效值返回 undefined,过去日期返回零;默认退避和等待预算由调用方决定。
4
+ * 有限秒数换算溢出时保留 Infinity,使 REST 仍能按超预算拒绝,不能退回短等待。
5
+ */
6
+ export declare function parseRetryAfterMs(raw: string | null | undefined, nowMs?: number): number | undefined;
@@ -0,0 +1,60 @@
1
+ const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2
+ const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
3
+ const imfFixdate = /^(?<weekday>Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?<day>\d{2}) (?<month>[A-Z][a-z]{2}) (?<year>\d{4}) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) GMT$/;
4
+ const rfc850Date = /^(?<weekday>Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?<day>\d{2})-(?<month>[A-Z][a-z]{2})-(?<year>\d{2}) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) GMT$/;
5
+ const asctimeDate = /^(?<weekday>Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?<month>[A-Z][a-z]{2}) (?<day>\d{2}| \d) (?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}) (?<year>\d{4})$/;
6
+ /**
7
+ * 解析 HTTP Retry-After 的秒数或日期,返回相对 nowMs 的非负毫秒数。
8
+ * 无效值返回 undefined,过去日期返回零;默认退避和等待预算由调用方决定。
9
+ * 有限秒数换算溢出时保留 Infinity,使 REST 仍能按超预算拒绝,不能退回短等待。
10
+ */
11
+ export function parseRetryAfterMs(raw, nowMs = Date.now()) {
12
+ // 先限制字符集,trim 才只会移除 HTTP 的 SP/HTAB;避免空白正则在长畸形值上重复回溯。
13
+ if (raw == null || /[^\t\x20-\x7e]/.test(raw))
14
+ return undefined;
15
+ const value = raw.trim();
16
+ if (!value)
17
+ return undefined;
18
+ // HTTP 秒数只接受十进制;保留 REST 的普通小数兼容,不接收 Number 的进制、符号或指数语法。
19
+ if (/^(?:\d+(?:\.\d*)?|\.\d+)$/.test(value)) {
20
+ const seconds = Number(value);
21
+ if (!Number.isFinite(seconds))
22
+ return undefined;
23
+ return Math.round(seconds * 1000);
24
+ }
25
+ const fields = (imfFixdate.exec(value) ?? rfc850Date.exec(value) ?? asctimeDate.exec(value))
26
+ ?.groups;
27
+ if (!fields)
28
+ return undefined;
29
+ let year = Number(fields.year);
30
+ const month = months.indexOf(fields.month);
31
+ const day = Number(fields.day);
32
+ const hour = Number(fields.hour);
33
+ const minute = Number(fields.minute);
34
+ const second = Number(fields.second);
35
+ if (month < 0 || day < 1 || day > 31 || hour > 23 || minute > 59 || second > 60)
36
+ return undefined;
37
+ // 三种 HTTP-date 均为 UTC。先保留第 59 秒以校验日历,闰秒最后映射到下一秒。
38
+ const date = new Date(0);
39
+ const leapSecondMs = second === 60 ? 1000 : 0;
40
+ if (fields.year.length === 2) {
41
+ const limit = new Date(nowMs);
42
+ limit.setUTCFullYear(limit.getUTCFullYear() + 50);
43
+ year += Math.floor(limit.getUTCFullYear() / 100) * 100;
44
+ date.setUTCFullYear(year, month, day);
45
+ date.setUTCHours(hour, minute, Math.min(second, 59), 0);
46
+ // 比较完整 UTC 时间戳:恰好 50 年保留,超过才回到最近的过去世纪。
47
+ if (date.getTime() + leapSecondMs > limit.getTime())
48
+ year -= 100;
49
+ }
50
+ date.setUTCFullYear(year, month, day);
51
+ date.setUTCHours(hour, minute, Math.min(second, 59), 0);
52
+ // Date 的分量 API 会自动顺延无效日期,必须回读校验;星期按最终展开的年份校验。
53
+ if (year < 1900 ||
54
+ date.getUTCFullYear() !== year ||
55
+ date.getUTCMonth() !== month ||
56
+ date.getUTCDate() !== day ||
57
+ weekdays[date.getUTCDay()] !== fields.weekday.slice(0, 3))
58
+ return undefined;
59
+ return Math.max(0, date.getTime() + leapSecondMs - nowMs);
60
+ }
@@ -1,4 +1,3 @@
1
- import type { ImTextMention } from "./mentions.js";
2
1
  export interface ImMessage {
3
2
  messageId: string;
4
3
  messageSeq: number;
@@ -41,14 +40,5 @@ export declare class WukongConnection {
41
40
  }) => void) | undefined);
42
41
  get connected(): boolean;
43
42
  connect(registration: BotRegistration): Promise<void>;
44
- sendText(channelId: string, channelType: number, text: string, clientMsgNo?: string, spaceId?: string, mention?: ImTextMention, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
45
- /** 原生文件消息复用文本的加密、稳定编号、ACK/迟到确认和取消窗口;不使用互动卡服务。 */
46
- sendFile(channelId: string, channelType: number, file: {
47
- url: string;
48
- name: string;
49
- size: number;
50
- extension: string;
51
- }, clientMsgNo: string, spaceId?: string, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
52
- isDelivered(clientMsgNo: string): boolean;
53
43
  close(): Promise<void>;
54
44
  }
@@ -1,16 +1,17 @@
1
1
  /**
2
- * WuKong 传输:负责 Bot 注册、加密握手、二进制帧编解码和收发确认。
3
- * 保留原通道的协议兼容性;授权、Context 和执行策略由上层处理。
2
+ * WuKong 接收传输:负责 Bot 注册、加密握手、入站消息、接收 ACK 及 PING/PONG。
3
+ * 业务消息统一由上层通过 REST 发送;本层不持有结果投递、发送重试或迟到确认状态。
4
4
  */
5
5
  import { createCipheriv, createDecipheriv, createHash, createPublicKey, diffieHellman, generateKeyPairSync, randomUUID } from "node:crypto";
6
6
  import WebSocket from "ws";
7
- import { ImSendError, ImTextSend } from "../delivery/text-send.js";
8
7
  import { isRulesNotification } from "./normalize.js";
8
+ import { trimTrailingSlashes } from "./api/url.js";
9
9
  import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError, wukongConnectionFailure } from "./connection-error.js";
10
10
  const LIMIT = 1 << 20;
11
11
  const md5 = (value) => createHash("md5").update(value).digest("hex");
12
12
  export async function registerBot(apiUrl, token, signal) {
13
- const response = await connectionFetch(`${apiUrl.replace(/\/$/, "")}/v1/bot/register`, {
13
+ // 与鉴权及其他 REST 请求共用尾斜杠处理,保留 API 路径前缀。
14
+ const response = await connectionFetch(`${trimTrailingSlashes(apiUrl)}/v1/bot/register`, {
14
15
  method: "POST",
15
16
  // 返回重定向状态供统一分类,不跟随到新地址,也不将其折叠成网络暂态。
16
17
  redirect: "manual",
@@ -64,10 +65,6 @@ class Writer {
64
65
  this.chunks.push(h, b);
65
66
  return this;
66
67
  }
67
- bytes(b) {
68
- this.chunks.push(b);
69
- return this;
70
- }
71
68
  finish() {
72
69
  return Buffer.concat(this.chunks);
73
70
  }
@@ -124,16 +121,10 @@ export class WukongConnection {
124
121
  #iv;
125
122
  #version = 0;
126
123
  #buffer = Buffer.alloc(0);
127
- #seq = 0;
128
124
  #heartbeat;
129
- #lastPacket = Date.now();
125
+ #awaitingPong = false;
130
126
  #closed = false;
131
127
  #ready = false;
132
- #sends = new Map();
133
- #active = new Set();
134
- #confirmed = new Set();
135
- #retained = new Map();
136
- #abort = new AbortController();
137
128
  constructor(onMessage, onDisconnect = () => { }, onPosition) {
138
129
  this.onMessage = onMessage;
139
130
  this.onDisconnect = onDisconnect;
@@ -185,12 +176,6 @@ export class WukongConnection {
185
176
  clearTimeout(timeout);
186
177
  if (this.#heartbeat)
187
178
  clearInterval(this.#heartbeat);
188
- for (const pending of [...this.#active])
189
- pending.disconnected();
190
- this.#sends.clear();
191
- for (const timer of this.#retained.values())
192
- clearTimeout(timer);
193
- this.#retained.clear();
194
179
  const error = failure ?? new ImConnectionError("IM_DISCONNECTED", true);
195
180
  if (!ready)
196
181
  reject(error);
@@ -210,9 +195,10 @@ export class WukongConnection {
210
195
  const header = this.#buffer[0], kind = header >> 4;
211
196
  if (kind === 7 || kind === 8) {
212
197
  this.#buffer = this.#buffer.subarray(1);
213
- this.#lastPacket = Date.now();
214
198
  if (kind === 7)
215
199
  socket.send(Buffer.from([8 << 4]));
200
+ else
201
+ this.#awaitingPong = false;
216
202
  continue;
217
203
  }
218
204
  let length = 0, multiplier = 1, offset = 1, complete = false;
@@ -237,7 +223,6 @@ export class WukongConnection {
237
223
  break;
238
224
  const reader = new Reader(this.#buffer.subarray(offset, offset + length));
239
225
  this.#buffer = this.#buffer.subarray(offset + length);
240
- this.#lastPacket = Date.now();
241
226
  if (kind === 2 && !ready) {
242
227
  if (header & 1)
243
228
  this.#version = reader.byte();
@@ -263,14 +248,22 @@ export class WukongConnection {
263
248
  ready = true;
264
249
  this.#ready = true;
265
250
  clearTimeout(timeout);
251
+ // 切网不一定触发 TCP close,必须主动确认这条连接的双向协议链路。
252
+ // 每 10 秒 PING,下一次检查仍无 PONG 即关闭;推送或服务端 PING 不能续命。
253
+ // 此探测只恢复入站连接,不取消已受理任务,也不阻塞其 REST 投递。
254
+ // 单连接最多一个在途探测,回调延迟时不补发积压 PING;close 负责通知上层重连。
266
255
  this.#heartbeat = setInterval(() => {
267
- if (Date.now() - this.#lastPacket > 90_000) {
256
+ if (this.#awaitingPong) {
257
+ this.#ready = false;
258
+ clearInterval(this.#heartbeat);
268
259
  failure = new ImConnectionError("IM_HEARTBEAT_TIMEOUT", true);
269
260
  socket.terminate();
270
261
  }
271
- else if (socket.readyState === WebSocket.OPEN)
262
+ else if (socket.readyState === WebSocket.OPEN) {
263
+ this.#awaitingPong = true;
272
264
  socket.send(Buffer.from([7 << 4]));
273
- }, 25_000);
265
+ }
266
+ }, 10_000);
274
267
  this.#heartbeat.unref();
275
268
  resolve();
276
269
  }
@@ -282,23 +275,6 @@ export class WukongConnection {
282
275
  throw new Error("IM_HANDSHAKE_REQUIRED");
283
276
  else if (kind === 5)
284
277
  this.#receive(reader, registration.robot_id);
285
- else if (kind === 4) {
286
- const id = reader.u64().toString();
287
- const seq = reader.u32();
288
- const messageSeq = reader.u32();
289
- const reason = reader.byte();
290
- const pending = this.#sends.get(seq);
291
- if (pending) {
292
- if (reason === 1) {
293
- pending.onPosition?.(messageSeq);
294
- this.#confirmed.add(pending.key);
295
- if (this.#confirmed.size > 512)
296
- this.#confirmed.delete(this.#confirmed.values().next().value);
297
- this.#forget(pending.operation);
298
- }
299
- pending.operation.ack(id, reason);
300
- }
301
- }
302
278
  }
303
279
  }
304
280
  catch (error) {
@@ -338,13 +314,6 @@ export class WukongConnection {
338
314
  const payload = JSON.parse(plain.toString());
339
315
  if (!payload || typeof payload !== "object" || Array.isArray(payload))
340
316
  throw new Error("IM_PAYLOAD_INVALID");
341
- if (fromUid === ownUid) {
342
- const pending = [...this.#sends.values()].find((entry) => entry.key === clientNo &&
343
- entry.channelId === channelId &&
344
- entry.channelType === channelType &&
345
- (!payload.space_id || payload.space_id === entry.spaceId));
346
- pending?.onPosition?.(messageSeq);
347
- }
348
317
  this.onPosition?.({
349
318
  channelId,
350
319
  channelType,
@@ -368,87 +337,10 @@ export class WukongConnection {
368
337
  // 此 ACK 仅确认 IM 消息已接收,不代表 AgentRun 已执行完成。
369
338
  this.#socket?.send(frame(6, new Writer().u64(messageId).u32(messageSeq).finish()));
370
339
  }
371
- sendText(channelId, channelType, text, clientMsgNo = randomUUID(), spaceId, mention, signal, onPosition) {
372
- return this.#sendPayload(channelId, channelType, { type: 1, content: text, ...(mention ? { mention } : {}) }, clientMsgNo, spaceId, signal, onPosition);
373
- }
374
- /** 原生文件消息复用文本的加密、稳定编号、ACK/迟到确认和取消窗口;不使用互动卡服务。 */
375
- sendFile(channelId, channelType, file, clientMsgNo, spaceId, signal, onPosition) {
376
- return this.#sendPayload(channelId, channelType, { type: 8, url: file.url, name: file.name, size: file.size, extension: file.extension }, clientMsgNo, spaceId, signal, onPosition);
377
- }
378
- #sendPayload(channelId, channelType, payload, clientMsgNo, spaceId, signal, onPosition) {
379
- if (this.#socket?.readyState !== WebSocket.OPEN || !this.#key)
380
- return Promise.reject(new ImSendError("IM_NOT_READY", "failed"));
381
- const serialized = JSON.stringify({ ...payload, ...(spaceId ? { space_id: spaceId } : {}) });
382
- if (Buffer.byteLength(serialized) > 256 * 1024 ||
383
- this.#active.size >= 64 ||
384
- this.#socket.bufferedAmount > LIMIT)
385
- return Promise.reject(new ImSendError("IM_SEND_CAPACITY_EXHAUSTED", "failed"));
386
- const encrypted = this.#encrypt(serialized);
387
- const operation = new ImTextSend(() => {
388
- if (!this.connected)
389
- throw new ImSendError("IM_NOT_READY", "failed");
390
- if (this.#socket.bufferedAmount > LIMIT)
391
- throw new ImSendError("IM_SEND_CAPACITY_EXHAUSTED", "failed");
392
- const seq = ++this.#seq;
393
- const body = new Writer()
394
- .byte(0)
395
- .u32(seq)
396
- .string(clientMsgNo)
397
- .string(channelId)
398
- .byte(channelType);
399
- if (this.#version >= 3)
400
- body.u32(0);
401
- body
402
- .string(md5(this.#encrypt(`${seq}${clientMsgNo}${channelId}${channelType}${encrypted}`)))
403
- .bytes(Buffer.from(encrypted));
404
- this.#sends.set(seq, {
405
- operation,
406
- key: clientMsgNo,
407
- channelId,
408
- channelType,
409
- spaceId,
410
- onPosition
411
- });
412
- this.#socket.send(frame(3, body.finish(), 2), (error) => {
413
- if (error)
414
- operation.disconnected();
415
- });
416
- }, (state) => {
417
- this.#active.delete(operation);
418
- if (state === "unknown" && !this.#closed) {
419
- // 留出 REST 降级窗口关联迟到 ACK;映射与计时器均有界。
420
- while (this.#retained.size >= 64)
421
- this.#forget(this.#retained.keys().next().value);
422
- const timer = setTimeout(() => this.#forget(operation), 30_000);
423
- timer.unref();
424
- this.#retained.set(operation, timer);
425
- }
426
- else
427
- this.#forget(operation);
428
- }, signal ? AbortSignal.any([this.#abort.signal, signal]) : this.#abort.signal);
429
- this.#active.add(operation);
430
- operation.start();
431
- return operation.result;
432
- }
433
- isDelivered(clientMsgNo) {
434
- return this.#confirmed.has(clientMsgNo);
435
- }
436
- #forget(operation) {
437
- clearTimeout(this.#retained.get(operation));
438
- this.#retained.delete(operation);
439
- for (const [seq, pending] of this.#sends)
440
- if (pending.operation === operation)
441
- this.#sends.delete(seq);
442
- }
443
340
  close() {
444
341
  if (this.#closing)
445
342
  return this.#closing;
446
343
  this.#closed = true;
447
- this.#abort.abort();
448
- for (const timer of this.#retained.values())
449
- clearTimeout(timer);
450
- this.#retained.clear();
451
- this.#sends.clear();
452
344
  this.#ready = false;
453
345
  if (this.#heartbeat)
454
346
  clearInterval(this.#heartbeat);