@mininglamp-oss/octo-runtime 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/apps/cli/dist/adapter-configurations.d.ts +4 -0
  2. package/apps/cli/dist/adapter-configurations.js +102 -0
  3. package/apps/cli/dist/build-info.json +2 -2
  4. package/apps/cli/dist/command-tree.js +1 -1
  5. package/apps/cli/dist/logs.js +8 -4
  6. package/apps/cli/dist/main.js +11 -5
  7. package/apps/cli/dist/output.js +5 -0
  8. package/apps/cli/dist/playboard.js +3 -2
  9. package/dist/public/dsh.d.ts +1 -1
  10. package/dist/public/dsh.js +1 -1
  11. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +5 -2
  12. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +9 -1
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +17 -0
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +20 -2
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +32 -2
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +3 -0
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -6
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +161 -26
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +8 -1
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +32 -2
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-DYOJCNWF.js → chunk-CFKMMCO6.js} +6 -4
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-UOQRXV3Q.js → chunk-LO34KB7D.js} +1 -1
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-V5W6ZTYC.js +151 -0
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +5 -3
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +3 -1
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +17 -3
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +8 -6
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +2 -1
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +4 -3
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +9 -1
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +8 -2
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +10 -6
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +9 -1
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +9 -1
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +9 -1
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.d.ts +2 -1
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.js +12 -40
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +22 -2
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +422 -135
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +6 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +2 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +9 -1
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +9 -1
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +19 -5
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +15 -8
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +12 -0
  63. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +91 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log-worker.js +2 -2
  65. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +13 -1
  66. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +9 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +40 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +3 -2
  69. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +20 -2
  70. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  71. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +4 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +102 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  74. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +1 -1
  75. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/logs.js +8 -4
  76. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +11 -5
  77. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +5 -0
  78. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +3 -2
  79. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
  80. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.d.ts +2 -1
  81. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.js +102 -52
  82. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +8 -3
  83. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +5 -3
  84. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +4 -3
  85. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +9 -4
  86. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +2 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.d.ts +1 -1
  88. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.js +9 -6
  89. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +47 -4
  90. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  91. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +4 -1
  93. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +7 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +79 -5
  95. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +3 -1
  96. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +22 -6
  97. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +2 -1
  98. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +5 -3
  99. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +12 -6
  100. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +4 -2
  101. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +131 -43
  102. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  103. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
  104. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.d.ts +17 -1
  105. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +22 -6
  106. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.d.ts +3 -0
  107. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.js +27 -0
  108. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +462 -228
  109. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.d.ts +5 -2
  110. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.js +42 -4
  111. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +5 -0
  112. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.d.ts +15 -0
  113. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.js +28 -0
  114. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +16 -5
  115. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +4 -5
  116. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +12 -9
  117. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +1 -0
  118. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +7 -5
  119. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +15 -0
  120. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +36 -0
  121. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.d.ts +2 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.js +10 -0
  123. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +5 -2
  124. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +39 -22
  125. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.d.ts +29 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.js +171 -0
  127. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.d.ts +4 -1
  128. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +48 -6
  129. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +14 -1
  130. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +4 -0
  131. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +7 -1
  132. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.js +265 -38
  133. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.d.ts +4 -0
  134. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +5 -5
  135. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +7 -0
  136. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +19 -2
  137. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.d.ts +3 -1
  138. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +4 -3
  139. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.d.ts +0 -12
  140. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.js +5 -3
  141. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +2 -1
  142. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +8 -6
  143. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.d.ts +3 -0
  144. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.js +2 -2
  145. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +2 -2
  146. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +27 -15
  147. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +17 -1
  148. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +217 -50
  149. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +2 -4
  150. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -2
  151. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +41 -12
  152. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts +2 -6
  153. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +53 -82
  154. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.d.ts +12 -0
  155. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.js +133 -0
  156. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.d.ts +21 -0
  157. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.js +76 -0
  158. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.d.ts +0 -2
  159. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.js +0 -2
  160. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.d.ts +16 -0
  161. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.js +74 -0
  162. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.d.ts +4 -0
  163. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.js +19 -0
  164. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.d.ts +7 -0
  165. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.js +90 -0
  166. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +39 -2
  167. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.d.ts +6 -0
  168. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.js +60 -0
  169. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +2 -1
  170. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +20 -8
  171. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  172. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +10 -2
  173. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +14 -1
  174. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/transport/channel.js +2 -3
  175. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  176. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  177. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.d.ts +3 -2
  178. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +11 -4
  179. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +2 -0
  180. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +5 -3
  181. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  182. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +8 -1
  183. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -1
  184. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +9 -1
  185. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +18 -0
  186. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +3 -0
  187. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +6 -0
  188. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +14 -0
  189. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  190. package/node_modules/iconv-lite/LICENSE +21 -0
  191. package/node_modules/iconv-lite/README.md +138 -0
  192. package/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
  193. package/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
  194. package/node_modules/iconv-lite/encodings/index.js +23 -0
  195. package/node_modules/iconv-lite/encodings/internal.js +218 -0
  196. package/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
  197. package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  198. package/node_modules/iconv-lite/encodings/sbcs-data.js +180 -0
  199. package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  200. package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  201. package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  202. package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  203. package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  204. package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  205. package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  206. package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  207. package/node_modules/iconv-lite/encodings/utf16.js +187 -0
  208. package/node_modules/iconv-lite/encodings/utf32.js +314 -0
  209. package/node_modules/iconv-lite/encodings/utf7.js +283 -0
  210. package/node_modules/iconv-lite/lib/bom-handling.js +48 -0
  211. package/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  212. package/node_modules/iconv-lite/lib/index.d.ts +129 -0
  213. package/node_modules/iconv-lite/lib/index.js +182 -0
  214. package/node_modules/iconv-lite/lib/streams.js +105 -0
  215. package/node_modules/iconv-lite/package.json +70 -0
  216. package/node_modules/iconv-lite/types/encodings.d.ts +425 -0
  217. package/node_modules/safer-buffer/LICENSE +21 -0
  218. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  219. package/node_modules/safer-buffer/Readme.md +156 -0
  220. package/node_modules/safer-buffer/dangerous.js +58 -0
  221. package/node_modules/safer-buffer/package.json +34 -0
  222. package/node_modules/safer-buffer/safer.js +77 -0
  223. package/node_modules/safer-buffer/tests.js +406 -0
  224. package/node_modules/semver/LICENSE +15 -0
  225. package/node_modules/semver/README.md +680 -0
  226. package/node_modules/semver/bin/semver.js +195 -0
  227. package/node_modules/semver/classes/comparator.js +143 -0
  228. package/node_modules/semver/classes/index.js +7 -0
  229. package/node_modules/semver/classes/range.js +577 -0
  230. package/node_modules/semver/classes/semver.js +350 -0
  231. package/node_modules/semver/functions/clean.js +8 -0
  232. package/node_modules/semver/functions/cmp.js +54 -0
  233. package/node_modules/semver/functions/coerce.js +62 -0
  234. package/node_modules/semver/functions/compare-build.js +9 -0
  235. package/node_modules/semver/functions/compare-loose.js +5 -0
  236. package/node_modules/semver/functions/compare.js +7 -0
  237. package/node_modules/semver/functions/diff.js +60 -0
  238. package/node_modules/semver/functions/eq.js +5 -0
  239. package/node_modules/semver/functions/gt.js +5 -0
  240. package/node_modules/semver/functions/gte.js +5 -0
  241. package/node_modules/semver/functions/inc.js +21 -0
  242. package/node_modules/semver/functions/lt.js +5 -0
  243. package/node_modules/semver/functions/lte.js +5 -0
  244. package/node_modules/semver/functions/major.js +5 -0
  245. package/node_modules/semver/functions/minor.js +5 -0
  246. package/node_modules/semver/functions/neq.js +5 -0
  247. package/node_modules/semver/functions/parse.js +18 -0
  248. package/node_modules/semver/functions/patch.js +5 -0
  249. package/node_modules/semver/functions/prerelease.js +8 -0
  250. package/node_modules/semver/functions/rcompare.js +5 -0
  251. package/node_modules/semver/functions/rsort.js +5 -0
  252. package/node_modules/semver/functions/satisfies.js +12 -0
  253. package/node_modules/semver/functions/sort.js +5 -0
  254. package/node_modules/semver/functions/truncate.js +48 -0
  255. package/node_modules/semver/functions/valid.js +8 -0
  256. package/node_modules/semver/index.js +93 -0
  257. package/node_modules/semver/internal/constants.js +37 -0
  258. package/node_modules/semver/internal/debug.js +11 -0
  259. package/node_modules/semver/internal/identifiers.js +29 -0
  260. package/node_modules/semver/internal/lrucache.js +42 -0
  261. package/node_modules/semver/internal/parse-options.js +17 -0
  262. package/node_modules/semver/internal/re.js +223 -0
  263. package/node_modules/semver/package.json +78 -0
  264. package/node_modules/semver/preload.js +4 -0
  265. package/node_modules/semver/range.bnf +17 -0
  266. package/node_modules/semver/ranges/gtr.js +6 -0
  267. package/node_modules/semver/ranges/intersects.js +9 -0
  268. package/node_modules/semver/ranges/ltr.js +6 -0
  269. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  270. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  271. package/node_modules/semver/ranges/min-version.js +63 -0
  272. package/node_modules/semver/ranges/outside.js +82 -0
  273. package/node_modules/semver/ranges/simplify.js +49 -0
  274. package/node_modules/semver/ranges/subset.js +249 -0
  275. package/node_modules/semver/ranges/to-comparators.js +10 -0
  276. package/node_modules/semver/ranges/valid.js +13 -0
  277. package/package.json +33 -27
  278. package/packages/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
  279. package/packages/octo-runtime-protocol/schema/protocol.schema.json +57 -1
  280. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-G5PWGRL5.js +0 -209
  281. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.d.ts +0 -1
  282. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.js +0 -16
@@ -1,12 +1,29 @@
1
1
  import { sanitizePublicValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
2
  import { fromMarkdown } from "mdast-util-from-markdown";
3
3
  const publicExposures = new Set(["public_reasoning", "public_summary", "public_plan"]);
4
+ const PROGRESS_WINDOW = 5;
5
+ const PREVIEW_RUNES = 180;
6
+ // 近期退役缓存只作辅助;未结束步骤的精确去重不能依赖其容量或滚动淘汰。
7
+ const RETIRED_WINDOW = 256;
4
8
  export class ImRunProjector {
5
9
  runId;
6
10
  allowToolPreview;
7
11
  #items = new Map();
8
12
  #messages = new Map();
9
13
  #toolInputs = new Map();
14
+ #steps = new Map();
15
+ #activeTools = new Map();
16
+ // 未结束步骤的身份与分类用于准确去重;不保存旧正文,步骤结束即释放。
17
+ #stepMessages = new Map();
18
+ #stepTools = new Map();
19
+ #unfinishedSteps = new Set();
20
+ #hasClosedStep = false;
21
+ #finalMessages = new Map();
22
+ #retired = new Set();
23
+ #reasoningCount = 0;
24
+ #toolCallCount = 0;
25
+ #modelStepCount = 0;
26
+ #disposed = false;
10
27
  #currentStep;
11
28
  #seq = 0;
12
29
  #phase = "accepted";
@@ -27,7 +44,7 @@ export class ImRunProjector {
27
44
  }
28
45
  accept(event, now = Date.now()) {
29
46
  // 终态后不再接纳迟到帧,防止完成卡片被旧进度改回执行中。
30
- if (this.#terminal)
47
+ if (this.#terminal || this.#disposed)
31
48
  return;
32
49
  this.#seq++;
33
50
  const p = event.payload;
@@ -43,26 +60,96 @@ export class ImRunProjector {
43
60
  this.#phase = "accepted";
44
61
  if (event.type === "model_step.started") {
45
62
  const p = event.payload;
63
+ if (this.#retired.has(`step:${p.stepId}`))
64
+ return;
46
65
  this.#currentStep = p.stepId;
47
- this.#item(`step:${p.stepId}`, "model_step", p.stepId).startedAtMs = p.startedAtMs;
66
+ this.#unfinishedSteps.add(p.stepId);
67
+ let step = this.#steps.get(p.stepId);
68
+ if (!step) {
69
+ step = {
70
+ id: `step:${p.stepId}`,
71
+ kind: "model_step",
72
+ stepId: p.stepId,
73
+ status: "running",
74
+ content: "",
75
+ ordinal: ++this.#modelStepCount
76
+ };
77
+ this.#steps.set(p.stepId, step);
78
+ }
79
+ step.startedAtMs = p.startedAtMs;
80
+ this.#pruneSteps();
48
81
  this.#phase = "model";
49
82
  this.#label = undefined;
50
83
  }
51
84
  if (event.type === "model_step.finished") {
52
85
  const p = event.payload;
53
- const item = this.#item(`step:${p.stepId}`, "model_step", p.stepId);
54
- item.status = p.status;
55
- item.finishReason = p.finishReason;
56
- if (item.startedAtMs !== undefined && p.endedAtMs !== undefined)
57
- item.durationMs = Math.max(0, p.endedAtMs - item.startedAtMs);
86
+ const item = this.#steps.get(p.stepId);
87
+ if (item) {
88
+ item.status = p.status;
89
+ item.finishReason = p.finishReason;
90
+ if (item.startedAtMs !== undefined && p.endedAtMs !== undefined)
91
+ item.durationMs = Math.max(0, p.endedAtMs - item.startedAtMs);
92
+ }
93
+ // 有的 Provider 只结束步骤、不逐条结束 reasoning;所属消息此时不再是在途资源。
94
+ this.#hasClosedStep = true;
95
+ this.#unfinishedSteps.delete(p.stepId);
96
+ for (const [id, message] of this.#stepMessages)
97
+ if (message.stepId === p.stepId) {
98
+ this.#stepMessages.delete(id);
99
+ this.#retire(`message:${id}`);
100
+ const detail = this.#items.get(`message:${id}`);
101
+ if (detail?.status === "running")
102
+ detail.status = p.status;
103
+ }
104
+ for (const [id, stepId] of this.#stepTools)
105
+ if (stepId === p.stepId && !this.#activeTools.has(id)) {
106
+ this.#stepTools.delete(id);
107
+ this.#retire(`tool:${id}`);
108
+ }
58
109
  }
59
110
  if (event.type.startsWith("message.")) {
60
111
  const id = p.messageId ??
61
112
  `unidentified:${p.stepId ?? this.#currentStep ?? "run"}:${p.channel ?? "final"}`;
62
- const previous = this.#messages.get(id);
63
- const channel = p.channel ?? previous?.channel ?? "final";
113
+ const hasStableId = typeof p.messageId === "string" && p.messageId.length > 0;
114
+ // 合成的匿名 key 不是源消息身份,不能借其碰巧命中的记录推断通道。
115
+ if (p.channel === undefined && !hasStableId)
116
+ return;
117
+ const storedIdentity = this.#stepMessages.get(id);
118
+ const identity = storedIdentity?.stableId === hasStableId ? storedIdentity : undefined;
119
+ const knownFinal = hasStableId && this.#finalMessages.get(id)?.stableId === true;
120
+ // 已淘汰进度的迟到 delta 可能省略 channel,不能按缺省 final 拼进最终回复。
121
+ if (this.#retired.has(`message:${id}`) && !identity && p.channel !== "final" && !knownFinal)
122
+ return;
123
+ const storedPrevious = this.#messages.get(id);
124
+ const previous = storedPrevious?.stableId === hasStableId ? storedPrevious : undefined;
125
+ const channel = p.channel ?? (knownFinal ? "final" : (previous?.channel ?? identity?.channel));
126
+ // 无法证明通道时不发布正文;匿名帧也不能借用另一个匿名 final 的身份。
127
+ if (channel === undefined)
128
+ return;
129
+ const scopedStepId = p.stepId ?? previous?.stepId ?? identity?.stepId;
130
+ // 步骤结束后,未知旧身份不能仅靠 currentStep 被补造成当前步骤的新记录。
131
+ if (this.#hasClosedStep &&
132
+ scopedStepId === undefined &&
133
+ !identity &&
134
+ !previous &&
135
+ channel !== "final" &&
136
+ event.type !== "message.create")
137
+ return;
138
+ const stepId = scopedStepId ?? this.#currentStep;
139
+ // 已结束步骤的非 final/未分类迟到帧不能因身份缓存滚动而重新进入当前步骤。
140
+ if (p.channel !== "final" && !knownFinal && this.#stepClosed(stepId))
141
+ return;
142
+ // update 也可能是流式替换快照(例如 OpenClaw),不能仅按事件名提前清除分类。
143
+ const running = event.type !== "message.update" || p.status === "streaming" || p.status === "running";
64
144
  // analysis 必须显式声明可公开;历史片段也清除,避免后续快照泄漏。
65
145
  if (channel === "analysis" && !publicExposures.has(p.exposure ?? "")) {
146
+ this.#stepMessages.set(id, {
147
+ channel,
148
+ stepId,
149
+ hidden: identity?.hidden ?? false,
150
+ counted: identity?.counted ?? false,
151
+ stableId: hasStableId
152
+ });
66
153
  this.#messages.delete(id);
67
154
  this.#items.delete(`message:${id}`);
68
155
  return;
@@ -70,23 +157,66 @@ export class ImRunProjector {
70
157
  if (!["analysis", "commentary", "final"].includes(channel) ||
71
158
  (p.role && p.role !== "assistant"))
72
159
  return;
73
- const text = typeof p.text !== "string"
74
- ? (previous?.text ?? "")
75
- : event.type === "message.delta"
76
- ? (previous?.text ?? "") + p.text
77
- : p.text;
78
- const stepId = p.stepId ?? previous?.stepId ?? this.#currentStep;
79
- this.#messages.set(id, { channel, text, stepId });
80
- if (channel !== "final") {
160
+ if (channel === "final") {
161
+ this.#stepMessages.delete(id);
162
+ const text = typeof p.text !== "string"
163
+ ? (this.#finalMessages.get(id)?.text ?? "")
164
+ : event.type === "message.delta"
165
+ ? (this.#finalMessages.get(id)?.text ?? "") + p.text
166
+ : p.text;
167
+ this.#finalMessages.set(id, { text, stableId: hasStableId });
168
+ const step = stepId && this.#steps.get(stepId);
169
+ if (step)
170
+ step.content = previewText(text);
171
+ }
172
+ else {
173
+ if (this.#retired.has(`message:${id}`) && !identity)
174
+ return;
175
+ // 同一步骤内的迟到更新仍使用原分类和计数;已淘汰正文不回窗。
176
+ if (identity?.hidden) {
177
+ if (channel === "analysis" && !identity.counted) {
178
+ this.#reasoningCount++;
179
+ identity.counted = true;
180
+ }
181
+ identity.channel = channel;
182
+ if (!running)
183
+ this.#retire(`message:${id}`);
184
+ return;
185
+ }
186
+ // 有步骤身份的迟到快照不能重新创建已离开窗口的旧阶段。
187
+ if (stepId && stepId !== this.#currentStep && !this.#steps.has(stepId)) {
188
+ // 首次公开但已不在近期阶段的摘要仍计数,不为了统计恢复旧正文。
189
+ if (channel === "analysis" && !identity?.counted)
190
+ this.#reasoningCount++;
191
+ this.#stepMessages.set(id, {
192
+ channel,
193
+ stepId,
194
+ hidden: true,
195
+ counted: channel === "analysis" || !!identity?.counted,
196
+ stableId: hasStableId
197
+ });
198
+ this.#retire(`message:${id}`);
199
+ return;
200
+ }
201
+ const text = typeof p.text !== "string"
202
+ ? (previous?.text ?? "")
203
+ : event.type === "message.delta"
204
+ ? appendPreview(previous?.text ?? "", p.text)
205
+ : previewText(p.text);
206
+ const existing = this.#items.get(`message:${id}`);
207
+ if (!existing && channel === "analysis" && !identity?.counted)
208
+ this.#reasoningCount++;
209
+ this.#stepMessages.set(id, {
210
+ channel,
211
+ stepId,
212
+ hidden: false,
213
+ counted: channel === "analysis" || !!identity?.counted,
214
+ stableId: hasStableId
215
+ });
81
216
  const item = this.#item(`message:${id}`, channel === "analysis" ? "reasoning" : "commentary", stepId);
82
217
  item.content = text;
83
218
  item.status = event.type === "message.update" ? "completed" : "running";
84
- }
85
- if (channel === "final" && stepId && this.#items.has(`step:${stepId}`)) {
86
- this.#items.get(`step:${stepId}`).content = [...this.#messages.values()]
87
- .filter((message) => message.channel === "final" && message.stepId === stepId)
88
- .map((message) => message.text)
89
- .join("\n\n");
219
+ this.#messages.set(id, { channel, text, stepId, stableId: hasStableId });
90
220
  }
91
221
  this.#phase =
92
222
  channel === "final" ? "answering" : channel === "analysis" ? "thinking" : "commentary";
@@ -94,7 +224,17 @@ export class ImRunProjector {
94
224
  }
95
225
  if (event.type === "tool_call.create") {
96
226
  const p = event.payload;
97
- const item = this.#item(`tool:${p.id}`, "tool", p.stepId ?? this.#currentStep);
227
+ if (this.#retired.has(`tool:${p.id}`) ||
228
+ this.#stepTools.has(p.id) ||
229
+ this.#activeTools.has(p.id) ||
230
+ this.#items.has(`tool:${p.id}`))
231
+ return;
232
+ const stepId = p.stepId ?? this.#currentStep;
233
+ if (this.#stepClosed(stepId))
234
+ return;
235
+ const item = this.#item(`tool:${p.id}`, "tool", stepId);
236
+ this.#toolCallCount++;
237
+ this.#stepTools.set(p.id, stepId);
98
238
  item.toolName = p.name;
99
239
  item.startedAtMs = now;
100
240
  if (this.allowToolPreview)
@@ -102,21 +242,50 @@ export class ImRunProjector {
102
242
  const command = stringArg(p.args.command ?? p.args.cmd);
103
243
  if (command.length <= 8192)
104
244
  this.#toolInputs.set(p.id, { command });
245
+ this.#activeTools.set(p.id, item);
105
246
  this.#phase = "tool";
106
247
  this.#label = undefined;
107
248
  }
108
249
  if (event.type === "tool_call.update") {
109
250
  const p = event.payload;
110
- const item = this.#item(`tool:${p.id}`, "tool", p.stepId ?? this.#currentStep);
251
+ let item = this.#activeTools.get(p.id) ?? this.#items.get(`tool:${p.id}`);
252
+ const args = p.args && typeof p.args === "object" && !Array.isArray(p.args)
253
+ ? p.args
254
+ : {};
255
+ if (!item) {
256
+ // 已有步骤完成时,缺少自身步骤的未知终态可能是旧工具迟到;不能补造归属。
257
+ if (this.#hasClosedStep && p.stepId === undefined)
258
+ return;
259
+ const stepId = p.stepId ?? this.#currentStep;
260
+ if (this.#stepTools.has(p.id) ||
261
+ this.#retired.has(`tool:${p.id}`) ||
262
+ this.#stepClosed(stepId))
263
+ return;
264
+ // ACP/OpenCode 支持仅终态工具;补建展示和计数,不虚构开始时间。
265
+ item = this.#item(`tool:${p.id}`, "tool", stepId);
266
+ this.#toolCallCount++;
267
+ this.#stepTools.set(p.id, stepId);
268
+ }
269
+ if (typeof p.name === "string") {
270
+ item.toolName = p.name;
271
+ if (this.allowToolPreview && item.summary === undefined)
272
+ item.summary = toolPreview(p.name, args);
273
+ }
111
274
  item.status = p.status;
112
275
  item.exitCode = p.exitCode;
113
276
  item.durationMs =
114
277
  p.durationMs ??
115
278
  (item.startedAtMs === undefined ? undefined : Math.max(0, now - item.startedAtMs));
116
- const input = this.#toolInputs.get(p.id);
279
+ const command = stringArg(args.command ?? args.cmd);
280
+ const input = this.#toolInputs.get(p.id) ?? (command.length <= 8192 ? { command } : undefined);
117
281
  if (p.status === "failed" && p.exitCode === 2 && input && detectorFindings(input, p.output))
118
282
  item.outcome = "check_findings";
119
283
  this.#toolInputs.delete(p.id);
284
+ this.#activeTools.delete(p.id);
285
+ if (this.#stepClosed(item.stepId))
286
+ this.#stepTools.delete(p.id);
287
+ if (!this.#items.has(item.id))
288
+ this.#retire(item.id);
120
289
  this.#phase = "tool";
121
290
  this.#label = "工具调用完成";
122
291
  }
@@ -192,31 +361,80 @@ export class ImRunProjector {
192
361
  : this.#failureMessage || detail;
193
362
  }
194
363
  this.#selectFinalReply();
195
- for (const item of this.#items.values())
364
+ for (const item of [...this.#items.values(), ...this.#steps.values()])
196
365
  if (item.status === "running")
197
366
  item.status = this.#terminal === "completed" ? "completed" : "cancelled";
367
+ this.#activeTools.clear();
368
+ this.#stepMessages.clear();
369
+ this.#stepTools.clear();
370
+ this.#unfinishedSteps.clear();
371
+ this.#toolInputs.clear();
198
372
  }
199
- if (this.#items.size > 512 ||
200
- this.#messages.size > 512 ||
201
- [...this.#messages.values()].reduce((size, message) => size + Buffer.byteLength(message.text), 0) >
202
- 256 * 1024)
203
- throw new Error("IM_RESULT_TOO_LARGE");
204
373
  }
205
374
  #item(id, kind, stepId) {
206
375
  let item = this.#items.get(id);
207
376
  if (!item) {
208
377
  item = { id, kind, stepId, status: "running", content: "" };
209
378
  this.#items.set(id, item);
379
+ if (this.#items.size > PROGRESS_WINDOW) {
380
+ const oldest = this.#items.keys().next().value;
381
+ this.#items.delete(oldest);
382
+ if (oldest.startsWith("message:")) {
383
+ const messageId = oldest.slice(8);
384
+ this.#messages.delete(messageId);
385
+ const identity = this.#stepMessages.get(messageId);
386
+ if (identity)
387
+ identity.hidden = true;
388
+ }
389
+ this.#retire(oldest);
390
+ }
391
+ this.#pruneSteps();
210
392
  }
211
393
  return item;
212
394
  }
213
395
  get finalText() {
214
- return [...this.#messages.values()]
215
- .filter((m) => m.channel === "final")
216
- .map((m) => m.text)
396
+ return [...this.#finalMessages.values()]
397
+ .map((message) => message.text)
217
398
  .filter(Boolean)
218
399
  .join("\n\n");
219
400
  }
401
+ #retire(id) {
402
+ this.#retired.add(id);
403
+ if (this.#retired.size > RETIRED_WINDOW)
404
+ this.#retired.delete(this.#retired.values().next().value);
405
+ }
406
+ #pruneSteps() {
407
+ const retained = new Set([...this.#items.values()].map((item) => item.stepId));
408
+ retained.add(this.#currentStep);
409
+ for (const [id] of this.#steps)
410
+ if (!retained.has(id)) {
411
+ this.#steps.delete(id);
412
+ this.#retire(`step:${id}`);
413
+ }
414
+ }
415
+ #stepClosed(stepId) {
416
+ // 无步骤事件沿用隐式单步,兼容旧归一化器;有步骤流以 started/finished 管理身份。
417
+ return (stepId !== undefined && this.#currentStep !== undefined && !this.#unfinishedSteps.has(stepId));
418
+ }
419
+ /** 最终文本已取出、卡片/投递收尾后调用;即使迟到回调仍引用对象,也不再持有正文。 */
420
+ dispose() {
421
+ this.#disposed = true;
422
+ this.#items.clear();
423
+ this.#messages.clear();
424
+ this.#steps.clear();
425
+ this.#activeTools.clear();
426
+ this.#stepMessages.clear();
427
+ this.#stepTools.clear();
428
+ this.#unfinishedSteps.clear();
429
+ this.#toolInputs.clear();
430
+ this.#finalMessages.clear();
431
+ this.#retired.clear();
432
+ this.#currentStep = undefined;
433
+ this.#finalReply = undefined;
434
+ this.#failure = undefined;
435
+ this.#failureDetail = this.#failureMessage = undefined;
436
+ this.#providerDiagnostic = undefined;
437
+ }
220
438
  // 只在终态选择一次;有故障证据的轮次才解析可见 Markdown 内容。
221
439
  #selectFinalReply() {
222
440
  let text;
@@ -261,9 +479,10 @@ export class ImRunProjector {
261
479
  ? undefined
262
480
  : Math.max(0, (this.#endedAt ?? now) - this.#startedAt),
263
481
  items,
264
- reasoningCount: items.filter((i) => i.kind === "reasoning").length,
265
- toolCallCount: items.filter((i) => i.kind === "tool").length,
266
- modelStepCount: items.filter((i) => i.kind === "model_step").length,
482
+ modelSteps: structuredClone([...this.#steps.values()]),
483
+ reasoningCount: this.#reasoningCount,
484
+ toolCallCount: this.#toolCallCount,
485
+ modelStepCount: this.#modelStepCount,
267
486
  failure: this.#failure,
268
487
  failureMessage: this.#failureMessage,
269
488
  failureDetail: this.#failureDetail,
@@ -273,6 +492,14 @@ export class ImRunProjector {
273
492
  };
274
493
  }
275
494
  }
495
+ // 预览仅取有限首尾片段,避免为展示截短而 Array.from 整段长正文。
496
+ function previewText(text) {
497
+ const edge = PREVIEW_RUNES * 2;
498
+ return compactRunes(text.length > edge * 2 ? text.slice(0, edge) + text.slice(-edge) : text, PREVIEW_RUNES);
499
+ }
500
+ function appendPreview(previous, delta) {
501
+ return previewText(previous + previewText(delta));
502
+ }
276
503
  function failureIdentity(failure) {
277
504
  return failure ? `\n错误码:${failure.code}\n诊断编号:${failure.diagnosticId}` : "";
278
505
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { ChannelType } from "./types.js";
6
6
  import { type SendMessageResult } from "./types.js";
7
+ import { type HttpRequestDispatch } from "./client.js";
7
8
  export interface CardTemplateRef {
8
9
  id: string;
9
10
  version: string;
@@ -50,6 +51,7 @@ export declare function sendTemplateCardMessage(params: {
50
51
  data: object;
51
52
  clientMsgNo?: string;
52
53
  signal?: AbortSignal;
54
+ dispatchRequest?: HttpRequestDispatch;
53
55
  /**
54
56
  * Forwarded to postJson. A transient progress frame passes false: it is discardable,
55
57
  * and holding the flush while we back off would block the frames behind it. A finalize
@@ -70,6 +72,7 @@ export declare function editTemplateCardMessage(params: {
70
72
  cardSeq: number;
71
73
  transient?: boolean;
72
74
  signal?: AbortSignal;
75
+ dispatchRequest?: HttpRequestDispatch;
73
76
  /**
74
77
  * Forwarded to postJson. A transient progress frame passes false: it is discardable,
75
78
  * and holding the flush while we back off would block the frames behind it. A finalize
@@ -125,4 +128,5 @@ export declare function getCardProfile(params: {
125
128
  apiUrl: string;
126
129
  botToken: string;
127
130
  signal?: AbortSignal;
131
+ dispatchRequest?: HttpRequestDispatch;
128
132
  }): Promise<CardProfileManifest>;
@@ -1,5 +1,5 @@
1
1
  import { MessageType } from "./types.js";
2
- import { postJson, generateClientMsgNo, DEFAULT_TIMEOUT_MS } from "./client.js";
2
+ import { postJson, generateClientMsgNo, DEFAULT_TIMEOUT_MS, fetchWithDispatch } from "./client.js";
3
3
  import { OctoApiError } from "./errors.js";
4
4
  import { trimTrailingSlashes } from "./url.js";
5
5
  function validateTemplateFrame(params) {
@@ -54,7 +54,7 @@ export async function sendTemplateCardMessage(params) {
54
54
  data: params.data
55
55
  },
56
56
  client_msg_no: params.clientMsgNo ?? generateClientMsgNo()
57
- }, params.signal, { retryOn429: params.retryOn429 ?? true });
57
+ }, params.signal, { retryOn429: params.retryOn429 ?? true, dispatchRequest: params.dispatchRequest });
58
58
  }
59
59
  /** Replace one Registry-authored card frame; raw content_edit is intentionally unavailable. */
60
60
  export async function editTemplateCardMessage(params) {
@@ -75,7 +75,7 @@ export async function editTemplateCardMessage(params) {
75
75
  data: params.data,
76
76
  card_seq: params.cardSeq,
77
77
  ...(params.transient ? { transient: true } : {})
78
- }, params.signal, { retryOn429: params.retryOn429 ?? true });
78
+ }, params.signal, { retryOn429: params.retryOn429 ?? true, dispatchRequest: params.dispatchRequest });
79
79
  }
80
80
  function stringArray(value) {
81
81
  return Array.isArray(value)
@@ -178,11 +178,11 @@ function parseBotCardConfig(value) {
178
178
  */
179
179
  export async function getCardProfile(params) {
180
180
  const url = `${trimTrailingSlashes(params.apiUrl)}/v1/bot/card/profile`;
181
- const resp = await fetch(url, {
181
+ const resp = await fetchWithDispatch(url, {
182
182
  method: "GET",
183
183
  headers: { Authorization: `Bearer ${params.botToken}` },
184
184
  signal: params.signal ?? AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
185
- });
185
+ }, params.dispatchRequest);
186
186
  // 端点尚未部署时 fail closed;不使用本地开关猜测服务端 Bot 策略。
187
187
  if (resp.status === 404)
188
188
  return { available: false, enabled: false };
@@ -1,4 +1,10 @@
1
1
  export declare const DEFAULT_TIMEOUT_MS = 30000;
2
+ /** 在发送边界检查生命周期,可用 Bot 持有值替换鉴权头;不返回异步许可。 */
3
+ export type HttpRequestDispatch = (signal: AbortSignal, send: (signal: AbortSignal, botToken?: string) => Promise<Response>) => Promise<Response>;
4
+ /** 每次尝试(含 429)使用生效凭据;无 Authorization 的签名 PUT 不附加 Bot Token。 */
5
+ export declare function fetchWithDispatch(url: string, options: RequestInit & {
6
+ signal: AbortSignal;
7
+ }, dispatch?: HttpRequestDispatch): Promise<Response>;
2
8
  /**
3
9
  * 生成出站消息的客户端幂等编号 client_msg_no(UUID)。
4
10
  *
@@ -43,6 +49,7 @@ export declare const DEFAULT_POST_TIMEOUT_MS = 30000;
43
49
  */
44
50
  export declare const POST_HARD_CEILING_MS = 60000;
45
51
  interface JsonRequestOptions {
52
+ dispatchRequest?: HttpRequestDispatch;
46
53
  retryOn429?: boolean;
47
54
  /** Receipt uploads use the caller's throttled diagnostic instead. */
48
55
  logRateLimit?: boolean;
@@ -7,6 +7,23 @@ import { randomUUID } from "node:crypto";
7
7
  import { OctoApiError, OctoApiStatusMismatchError, OctoApiProtocolError } from "./errors.js";
8
8
  import { trimTrailingSlashes } from "./url.js";
9
9
  export const DEFAULT_TIMEOUT_MS = 30_000;
10
+ /** 每次尝试(含 429)使用生效凭据;无 Authorization 的签名 PUT 不附加 Bot Token。 */
11
+ export function fetchWithDispatch(url, options, dispatch) {
12
+ const send = (signal, botToken) => {
13
+ signal.throwIfAborted();
14
+ const headers = new Headers(options.headers);
15
+ if (botToken !== undefined && headers.has("Authorization")) {
16
+ headers.delete("Authorization");
17
+ return fetch(url, {
18
+ ...options,
19
+ headers: { ...Object.fromEntries(headers), Authorization: `Bearer ${botToken}` },
20
+ signal
21
+ });
22
+ }
23
+ return fetch(url, { ...options, signal });
24
+ };
25
+ return dispatch ? dispatch(options.signal, send) : send(options.signal);
26
+ }
10
27
  /**
11
28
  * 生成出站消息的客户端幂等编号 client_msg_no(UUID)。
12
29
  *
@@ -126,7 +143,7 @@ async function requestJson(apiUrl, botToken, path, method, payload, signal, opts
126
143
  const fetchSignal = signal
127
144
  ? AbortSignal.any([signal, AbortSignal.timeout(POST_HARD_CEILING_MS)])
128
145
  : AbortSignal.timeout(DEFAULT_POST_TIMEOUT_MS);
129
- const response = await fetch(url, {
146
+ const response = await fetchWithDispatch(url, {
130
147
  method,
131
148
  headers: {
132
149
  ...(payload ? DEFAULT_HEADERS : {}),
@@ -136,7 +153,7 @@ async function requestJson(apiUrl, botToken, path, method, payload, signal, opts
136
153
  ...(payload ? { body: JSON.stringify(payload) } : {}),
137
154
  signal: fetchSignal,
138
155
  ...(opts.redirect ? { redirect: opts.redirect } : {})
139
- });
156
+ }, opts.dispatchRequest);
140
157
  if (response.ok) {
141
158
  if (opts.expectedStatus !== undefined && response.status !== opts.expectedStatus) {
142
159
  throw new OctoApiStatusMismatchError(path, response.status, opts.expectedStatus);
@@ -3,6 +3,7 @@
3
3
  * 读取权限由 IM Server 决定,调用方负责选择本轮材料,接口层不组装 prompt。
4
4
  */
5
5
  import type { ChannelType } from "./types.js";
6
+ import { type HttpRequestDispatch } from "./client.js";
6
7
  export declare function fetchBotGroups(params: {
7
8
  apiUrl: string;
8
9
  botToken: string;
@@ -28,6 +29,7 @@ export declare function getGroupMembers(params: {
28
29
  botToken: string;
29
30
  groupNo: string;
30
31
  signal?: AbortSignal;
32
+ dispatchRequest?: HttpRequestDispatch;
31
33
  log?: {
32
34
  info?: (msg: string) => void;
33
35
  error?: (msg: string) => void;
@@ -66,7 +68,7 @@ export declare function getChannelMessages(params: {
66
68
  }): Promise<Array<{
67
69
  from_uid: string;
68
70
  content: string;
69
- timestamp: number;
71
+ timestamp: number | null;
70
72
  message_id?: string;
71
73
  message_seq?: number;
72
74
  type?: number;
@@ -1,5 +1,6 @@
1
1
  import { DEFAULT_TIMEOUT_MS, postJson, getJson } from "./client.js";
2
2
  import { trimTrailingSlashes } from "./url.js";
3
+ import { messageDate } from "../message-time.js";
3
4
  // Fetch the groups the bot belongs to
4
5
  export async function fetchBotGroups(params) {
5
6
  const url = `${params.apiUrl}/v1/bot/groups`;
@@ -18,7 +19,7 @@ export async function fetchBotGroups(params) {
18
19
  return Array.isArray(data) ? data : [];
19
20
  }
20
21
  export async function getGroupMembers(params) {
21
- const data = await getJson(params.apiUrl, params.botToken, `/v1/bot/groups/${encodeURIComponent(params.groupNo)}/members`, AbortSignal.any([AbortSignal.timeout(5000), ...(params.signal ? [params.signal] : [])]), { maxResponseBytes: 1 << 20, logRateLimit: false });
22
+ const data = await getJson(params.apiUrl, params.botToken, `/v1/bot/groups/${encodeURIComponent(params.groupNo)}/members`, AbortSignal.any([AbortSignal.timeout(5000), ...(params.signal ? [params.signal] : [])]), { maxResponseBytes: 1 << 20, logRateLimit: false, dispatchRequest: params.dispatchRequest });
22
23
  // Normalize to strict array to prevent silent failures
23
24
  const members = !Array.isArray(data) && Array.isArray(data?.members)
24
25
  ? data.members
@@ -77,8 +78,8 @@ export async function getChannelMessagePage(params) {
77
78
  name: payload.name ?? undefined,
78
79
  content: payload.content ?? "",
79
80
  payload, // preserve full payload for types that need nested data (e.g. MultipleForward)
80
- // Convert seconds to milliseconds (API returns seconds, internal standard is ms)
81
- timestamp: (m.timestamp ?? Math.floor(Date.now() / 1000)) * 1000
81
+ // API 秒转内部毫秒;未知保留 null,不能伪造为处理时刻。
82
+ timestamp: messageDate(m.timestamp, "seconds")?.getTime() ?? null
82
83
  };
83
84
  });
84
85
  return { messages: decoded, ...(data.more !== undefined ? { more: Boolean(data.more) } : {}) };
@@ -1,15 +1,3 @@
1
- /**
2
- * 结构化 API 错误:保留 HTTP 状态与限流提示,使投递层能判断是否重试。
3
- * 区分明确拒绝与传输结果未知,避免把所有异常都当作消息未发送。
4
- */
5
- /**
6
- * Structured error for the Octo REST helpers.
7
- *
8
- * The status code and the server's rate-limit hints used to survive only as text inside
9
- * the message, so every caller that needed them re-parsed the string. This carries them
10
- * as fields while keeping the historical message wording, which an existing regex parser
11
- * and its callers still depend on.
12
- */
13
1
  /** Fallback wait when the server rate-limits without a usable hint. */
14
2
  export declare const DEFAULT_RETRY_AFTER_MS = 1000;
15
3
  /**
@@ -10,6 +10,7 @@
10
10
  * as fields while keeping the historical message wording, which an existing regex parser
11
11
  * and its callers still depend on.
12
12
  */
13
+ import { parseRetryAfterMs } from "../retry-after.js";
13
14
  /** Fallback wait when the server rate-limits without a usable hint. */
14
15
  export const DEFAULT_RETRY_AFTER_MS = 1_000;
15
16
  /**
@@ -85,13 +86,14 @@ export class OctoApiError extends Error {
85
86
  const text = body || resp.statusText || "";
86
87
  const scope = header(resp, "X-RateLimit-Scope");
87
88
  const remaining = header(resp, "X-RateLimit-Remaining");
89
+ const headerDelayMs = parseRetryAfterMs(header(resp, "Retry-After"));
88
90
  return new OctoApiError({
89
91
  status: resp.status,
90
92
  path,
91
93
  body: text.length > MAX_ERROR_BODY_CHARS ? `${text.slice(0, MAX_ERROR_BODY_CHARS)}…` : text,
92
- // Parsed from the untruncated body: a hint sitting past the cap must not be lost
93
- // to a display concern.
94
- retryAfterMs: secondsToMs(header(resp, "Retry-After")) ??
94
+ // 正数 header 不裁剪;零等待沿用 body/default 兜底,避免连续立即重试。
95
+ // body 提示仍从未截断正文解析,展示长度限制不能丢失限流事实。
96
+ retryAfterMs: (headerDelayMs !== undefined && headerDelayMs > 0 ? headerDelayMs : undefined) ??
95
97
  retryAfterFromBody(body) ??
96
98
  DEFAULT_RETRY_AFTER_MS,
97
99
  ...(scope !== undefined ? { rateLimitScope: scope } : {}),
@@ -1,7 +1,8 @@
1
+ import { type HttpRequestDispatch } from "./client.js";
1
2
  /** 校验服务端返回的长期下载地址;不把 PUT 地址、签名有效期或 Bot 鉴权路由冒充附件。 */
2
3
  export declare function attachmentUrl(raw: unknown, apiUrl: string): string;
3
4
  /** 当前 Bot 获取聊天上传凭据后直传;只交付独立 downloadUrl,绝不转发 Bot Token。 */
4
- export declare function uploadChatAttachment(apiUrl: string, token: string, bytes: Uint8Array, filename: string, mime: string, signal: AbortSignal): Promise<string>;
5
+ export declare function uploadChatAttachment(apiUrl: string, token: string, bytes: Uint8Array, filename: string, mime: string, signal: AbortSignal, dispatchRequest?: HttpRequestDispatch): Promise<string>;
5
6
  /**
6
7
  * Infer MIME type from filename extension. Returns a sensible default if unknown.
7
8
  */