@mininglamp-oss/octo-runtime 1.1.6 → 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 (236) 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 +18 -4
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +7 -4
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +20 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  56. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
  57. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.d.ts +2 -1
  58. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.js +102 -52
  59. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +8 -3
  60. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +5 -3
  61. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +4 -3
  62. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +1 -1
  63. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +2 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.d.ts +1 -1
  65. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.js +9 -6
  66. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  67. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  68. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
  69. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.d.ts +17 -1
  70. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +22 -6
  71. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.d.ts +3 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.js +27 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +444 -226
  74. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.d.ts +5 -2
  75. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.js +42 -4
  76. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +5 -0
  77. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.d.ts +15 -0
  78. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.js +28 -0
  79. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +16 -5
  80. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +4 -5
  81. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +12 -9
  82. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +1 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +7 -5
  84. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +15 -0
  85. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +36 -0
  86. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.d.ts +2 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.js +10 -0
  88. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +5 -2
  89. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +36 -22
  90. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +14 -1
  91. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +4 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +5 -1
  93. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.js +265 -38
  94. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.d.ts +4 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +5 -5
  96. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +7 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +19 -2
  98. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.d.ts +3 -1
  99. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +4 -3
  100. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.d.ts +0 -12
  101. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.js +5 -3
  102. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +2 -1
  103. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +8 -6
  104. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.d.ts +3 -0
  105. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.js +2 -2
  106. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +2 -2
  107. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +27 -15
  108. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +17 -1
  109. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +217 -50
  110. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +2 -4
  111. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -2
  112. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +41 -12
  113. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts +2 -6
  114. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +53 -82
  115. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.d.ts +12 -0
  116. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.js +133 -0
  117. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.d.ts +21 -0
  118. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.js +76 -0
  119. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.d.ts +0 -2
  120. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.js +0 -2
  121. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.d.ts +16 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.js +74 -0
  123. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.d.ts +4 -0
  124. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.js +19 -0
  125. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.d.ts +7 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.js +90 -0
  127. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +2 -2
  128. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.d.ts +6 -0
  129. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.js +60 -0
  130. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +2 -1
  131. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +20 -8
  132. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  133. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +10 -2
  134. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +14 -1
  135. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/transport/channel.js +2 -3
  136. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  137. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  138. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.d.ts +3 -2
  139. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +11 -4
  140. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  141. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +8 -1
  142. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +9 -0
  143. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +3 -0
  144. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +6 -0
  145. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +14 -0
  146. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  147. package/node_modules/iconv-lite/LICENSE +21 -0
  148. package/node_modules/iconv-lite/README.md +138 -0
  149. package/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
  150. package/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
  151. package/node_modules/iconv-lite/encodings/index.js +23 -0
  152. package/node_modules/iconv-lite/encodings/internal.js +218 -0
  153. package/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
  154. package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  155. package/node_modules/iconv-lite/encodings/sbcs-data.js +180 -0
  156. package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  157. package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  158. package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  159. package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  160. package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  161. package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  162. package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  163. package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  164. package/node_modules/iconv-lite/encodings/utf16.js +187 -0
  165. package/node_modules/iconv-lite/encodings/utf32.js +314 -0
  166. package/node_modules/iconv-lite/encodings/utf7.js +283 -0
  167. package/node_modules/iconv-lite/lib/bom-handling.js +48 -0
  168. package/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  169. package/node_modules/iconv-lite/lib/index.d.ts +129 -0
  170. package/node_modules/iconv-lite/lib/index.js +182 -0
  171. package/node_modules/iconv-lite/lib/streams.js +105 -0
  172. package/node_modules/iconv-lite/package.json +70 -0
  173. package/node_modules/iconv-lite/types/encodings.d.ts +425 -0
  174. package/node_modules/safer-buffer/LICENSE +21 -0
  175. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  176. package/node_modules/safer-buffer/Readme.md +156 -0
  177. package/node_modules/safer-buffer/dangerous.js +58 -0
  178. package/node_modules/safer-buffer/package.json +34 -0
  179. package/node_modules/safer-buffer/safer.js +77 -0
  180. package/node_modules/safer-buffer/tests.js +406 -0
  181. package/node_modules/semver/LICENSE +15 -0
  182. package/node_modules/semver/README.md +680 -0
  183. package/node_modules/semver/bin/semver.js +195 -0
  184. package/node_modules/semver/classes/comparator.js +143 -0
  185. package/node_modules/semver/classes/index.js +7 -0
  186. package/node_modules/semver/classes/range.js +577 -0
  187. package/node_modules/semver/classes/semver.js +350 -0
  188. package/node_modules/semver/functions/clean.js +8 -0
  189. package/node_modules/semver/functions/cmp.js +54 -0
  190. package/node_modules/semver/functions/coerce.js +62 -0
  191. package/node_modules/semver/functions/compare-build.js +9 -0
  192. package/node_modules/semver/functions/compare-loose.js +5 -0
  193. package/node_modules/semver/functions/compare.js +7 -0
  194. package/node_modules/semver/functions/diff.js +60 -0
  195. package/node_modules/semver/functions/eq.js +5 -0
  196. package/node_modules/semver/functions/gt.js +5 -0
  197. package/node_modules/semver/functions/gte.js +5 -0
  198. package/node_modules/semver/functions/inc.js +21 -0
  199. package/node_modules/semver/functions/lt.js +5 -0
  200. package/node_modules/semver/functions/lte.js +5 -0
  201. package/node_modules/semver/functions/major.js +5 -0
  202. package/node_modules/semver/functions/minor.js +5 -0
  203. package/node_modules/semver/functions/neq.js +5 -0
  204. package/node_modules/semver/functions/parse.js +18 -0
  205. package/node_modules/semver/functions/patch.js +5 -0
  206. package/node_modules/semver/functions/prerelease.js +8 -0
  207. package/node_modules/semver/functions/rcompare.js +5 -0
  208. package/node_modules/semver/functions/rsort.js +5 -0
  209. package/node_modules/semver/functions/satisfies.js +12 -0
  210. package/node_modules/semver/functions/sort.js +5 -0
  211. package/node_modules/semver/functions/truncate.js +48 -0
  212. package/node_modules/semver/functions/valid.js +8 -0
  213. package/node_modules/semver/index.js +93 -0
  214. package/node_modules/semver/internal/constants.js +37 -0
  215. package/node_modules/semver/internal/debug.js +11 -0
  216. package/node_modules/semver/internal/identifiers.js +29 -0
  217. package/node_modules/semver/internal/lrucache.js +42 -0
  218. package/node_modules/semver/internal/parse-options.js +17 -0
  219. package/node_modules/semver/internal/re.js +223 -0
  220. package/node_modules/semver/package.json +78 -0
  221. package/node_modules/semver/preload.js +4 -0
  222. package/node_modules/semver/range.bnf +17 -0
  223. package/node_modules/semver/ranges/gtr.js +6 -0
  224. package/node_modules/semver/ranges/intersects.js +9 -0
  225. package/node_modules/semver/ranges/ltr.js +6 -0
  226. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  227. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  228. package/node_modules/semver/ranges/min-version.js +63 -0
  229. package/node_modules/semver/ranges/outside.js +82 -0
  230. package/node_modules/semver/ranges/simplify.js +49 -0
  231. package/node_modules/semver/ranges/subset.js +249 -0
  232. package/node_modules/semver/ranges/to-comparators.js +10 -0
  233. package/node_modules/semver/ranges/valid.js +13 -0
  234. package/package.json +33 -27
  235. package/packages/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
  236. package/packages/octo-runtime-protocol/schema/protocol.schema.json +43 -1
@@ -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
+ }
@@ -74,7 +74,7 @@ function action(item) {
74
74
  };
75
75
  }
76
76
  export function reasoningPhases(snapshot) {
77
- const steps = snapshot.items.filter((i) => i.kind === "model_step");
77
+ const steps = snapshot.modelSteps ?? snapshot.items.filter((i) => i.kind === "model_step");
78
78
  let phases;
79
79
  if (steps.length) {
80
80
  phases = steps.flatMap((step, index) => {
@@ -97,7 +97,7 @@ export function reasoningPhases(snapshot) {
97
97
  : ["stop", "end_turn", "completed"].includes(step.finishReason ?? "")
98
98
  ? "整理回答"
99
99
  : "模型处理";
100
- let heading = `第 ${index + 1} 轮 · ${label}${step.durationMs === undefined ? "" : " · " + formatDuration(step.durationMs)}`;
100
+ let heading = `第 ${step.ordinal ?? index + 1} 轮 · ${label}${step.durationMs === undefined ? "" : " · " + formatDuration(step.durationMs)}`;
101
101
  if (segments.length > 1)
102
102
  heading += ` · 阶段 ${segmentIndex + 1}`;
103
103
  const failed = children.some((i) => i.kind === "tool" && i.status === "failed" && i.outcome !== "check_findings");
@@ -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
+ }
@@ -30,6 +30,7 @@ export declare class WukongConnection {
30
30
  clientMsgNo: string;
31
31
  spaceId?: unknown;
32
32
  }) => void) | undefined;
33
+ readonly onDelivered?: ((clientMsgNo: string) => void) | undefined;
33
34
  constructor(onMessage: (message: ImMessage) => void, onDisconnect?: (error: Error) => void, onPosition?: ((position: {
34
35
  channelId: string;
35
36
  channelType: number;
@@ -38,7 +39,7 @@ export declare class WukongConnection {
38
39
  messageId: string;
39
40
  clientMsgNo: string;
40
41
  spaceId?: unknown;
41
- }) => void) | undefined);
42
+ }) => void) | undefined, onDelivered?: ((clientMsgNo: string) => void) | undefined);
42
43
  get connected(): boolean;
43
44
  connect(registration: BotRegistration): Promise<void>;
44
45
  sendText(channelId: string, channelType: number, text: string, clientMsgNo?: string, spaceId?: string, mention?: ImTextMention, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
@@ -6,11 +6,13 @@ import { createCipheriv, createDecipheriv, createHash, createPublicKey, diffieHe
6
6
  import WebSocket from "ws";
7
7
  import { ImSendError, ImTextSend } from "../delivery/text-send.js";
8
8
  import { isRulesNotification } from "./normalize.js";
9
+ import { trimTrailingSlashes } from "./api/url.js";
9
10
  import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError, wukongConnectionFailure } from "./connection-error.js";
10
11
  const LIMIT = 1 << 20;
11
12
  const md5 = (value) => createHash("md5").update(value).digest("hex");
12
13
  export async function registerBot(apiUrl, token, signal) {
13
- const response = await connectionFetch(`${apiUrl.replace(/\/$/, "")}/v1/bot/register`, {
14
+ // 与鉴权及其他 REST 请求共用尾斜杠处理,保留 API 路径前缀。
15
+ const response = await connectionFetch(`${trimTrailingSlashes(apiUrl)}/v1/bot/register`, {
14
16
  method: "POST",
15
17
  // 返回重定向状态供统一分类,不跟随到新地址,也不将其折叠成网络暂态。
16
18
  redirect: "manual",
@@ -118,6 +120,7 @@ export class WukongConnection {
118
120
  onMessage;
119
121
  onDisconnect;
120
122
  onPosition;
123
+ onDelivered;
121
124
  #socket;
122
125
  #closing;
123
126
  #key;
@@ -126,7 +129,7 @@ export class WukongConnection {
126
129
  #buffer = Buffer.alloc(0);
127
130
  #seq = 0;
128
131
  #heartbeat;
129
- #lastPacket = Date.now();
132
+ #awaitingPong = false;
130
133
  #closed = false;
131
134
  #ready = false;
132
135
  #sends = new Map();
@@ -134,10 +137,11 @@ export class WukongConnection {
134
137
  #confirmed = new Set();
135
138
  #retained = new Map();
136
139
  #abort = new AbortController();
137
- constructor(onMessage, onDisconnect = () => { }, onPosition) {
140
+ constructor(onMessage, onDisconnect = () => { }, onPosition, onDelivered) {
138
141
  this.onMessage = onMessage;
139
142
  this.onDisconnect = onDisconnect;
140
143
  this.onPosition = onPosition;
144
+ this.onDelivered = onDelivered;
141
145
  }
142
146
  get connected() {
143
147
  return this.#ready && this.#socket?.readyState === WebSocket.OPEN;
@@ -210,9 +214,10 @@ export class WukongConnection {
210
214
  const header = this.#buffer[0], kind = header >> 4;
211
215
  if (kind === 7 || kind === 8) {
212
216
  this.#buffer = this.#buffer.subarray(1);
213
- this.#lastPacket = Date.now();
214
217
  if (kind === 7)
215
218
  socket.send(Buffer.from([8 << 4]));
219
+ else
220
+ this.#awaitingPong = false;
216
221
  continue;
217
222
  }
218
223
  let length = 0, multiplier = 1, offset = 1, complete = false;
@@ -237,7 +242,6 @@ export class WukongConnection {
237
242
  break;
238
243
  const reader = new Reader(this.#buffer.subarray(offset, offset + length));
239
244
  this.#buffer = this.#buffer.subarray(offset + length);
240
- this.#lastPacket = Date.now();
241
245
  if (kind === 2 && !ready) {
242
246
  if (header & 1)
243
247
  this.#version = reader.byte();
@@ -263,14 +267,21 @@ export class WukongConnection {
263
267
  ready = true;
264
268
  this.#ready = true;
265
269
  clearTimeout(timeout);
270
+ // 切网不一定触发 TCP close,必须主动确认这条连接的双向协议链路。
271
+ // 每 5 秒 PING,下一次检查仍无 PONG 即关闭;推送或服务端 PING 不能续命。
272
+ // 单连接最多一个在途探测,回调延迟时不补发积压 PING;close 负责通知上层重连。
266
273
  this.#heartbeat = setInterval(() => {
267
- if (Date.now() - this.#lastPacket > 90_000) {
274
+ if (this.#awaitingPong) {
275
+ this.#ready = false;
276
+ clearInterval(this.#heartbeat);
268
277
  failure = new ImConnectionError("IM_HEARTBEAT_TIMEOUT", true);
269
278
  socket.terminate();
270
279
  }
271
- else if (socket.readyState === WebSocket.OPEN)
280
+ else if (socket.readyState === WebSocket.OPEN) {
281
+ this.#awaitingPong = true;
272
282
  socket.send(Buffer.from([7 << 4]));
273
- }, 25_000);
283
+ }
284
+ }, 5_000);
274
285
  this.#heartbeat.unref();
275
286
  resolve();
276
287
  }
@@ -294,6 +305,7 @@ export class WukongConnection {
294
305
  this.#confirmed.add(pending.key);
295
306
  if (this.#confirmed.size > 512)
296
307
  this.#confirmed.delete(this.#confirmed.values().next().value);
308
+ this.onDelivered?.(pending.key);
297
309
  this.#forget(pending.operation);
298
310
  }
299
311
  pending.operation.ack(id, reason);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-extra-channel-gateway",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -22,11 +22,11 @@
22
22
  "docs"
23
23
  ],
24
24
  "dependencies": {
25
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.6",
26
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6",
27
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.6",
28
- "@mininglamp-oss/octo-runtime-host-sdk": "1.1.6",
29
- "@mininglamp-oss/octo-runtime-protocol": "1.1.6",
25
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.7",
26
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.7",
27
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.7",
28
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.7",
29
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.7",
30
30
  "mdast-util-from-markdown": "2.1.0",
31
31
  "ws": "8.22.0"
32
32
  }
@@ -13,6 +13,11 @@ import { createImInvocation } from "../execution/dispatcher.js";
13
13
  import { ImDeliveryDispatcher } from "../delivery/dispatcher.js";
14
14
  import { ImRunProjector } from "../presentation/run-projector.js";
15
15
  import { MemoryImSessionStore } from "./session-store.js";
16
+ // 仅精确匹配已定义的准备期原因;未知异常正文不得进入回复或新增诊断。
17
+ const preparationFailureMessages = new Map([
18
+ ["IM_AGENT_WORKDIR_FIXED", "本轮工作目录与固定目录配置冲突,尚未发起执行。请检查工作目录配置。"],
19
+ ["IM_RULE_PROTOCOL_INVALID", "规则数据格式不符合协议,尚未发起执行。请检查规则服务返回格式。"]
20
+ ]);
16
21
  export class ImRuntime {
17
22
  dependencies;
18
23
  #preparing = new Map();
@@ -500,10 +505,13 @@ export class ImRuntime {
500
505
  catch (error) {
501
506
  if (turnSignal.aborted)
502
507
  return;
503
- if (error instanceof Error && /^IM_CONTEXT_(?:LOADING|RESULT)_[A-Z_]+$/.test(error.message))
508
+ const preparationMessage = error instanceof Error ? preparationFailureMessages.get(error.message) : undefined;
509
+ if (error instanceof Error &&
510
+ (preparationMessage || /^IM_CONTEXT_(?:LOADING|RESULT)_[A-Z_]+$/.test(error.message)))
504
511
  this.#diagnostic(error.message);
505
512
  this.#diagnostic("IM_CONTEXT_PREPARATION_FAILED");
506
- await this.#reply(message, "本轮输入或执行配置准备失败,尚未发起执行。请检查配置、会话权限或稍后重试。", `prepare:${occurrenceId ?? message.messageId}`);
513
+ await this.#reply(message, preparationMessage ??
514
+ "本轮输入或执行配置准备失败,尚未发起执行。请检查配置、会话权限或稍后重试。", `prepare:${occurrenceId ?? message.messageId}`);
507
515
  return;
508
516
  }
509
517
  finally {
@@ -31,7 +31,20 @@ async function initialize(context, config, dependencies) {
31
31
  signal: context.signal,
32
32
  log: context.log,
33
33
  // 与 Gateway 共用逐轮合同:宿主数据可变,连接与 manager 仍由 Extra 整体封装。
34
- prepareContexts: (bot, signal) => contexts.load(bot, signal),
34
+ prepareContexts: async (bot, signal) => {
35
+ let ignored = 0;
36
+ const business = await contexts.load(bot, signal, (items) => {
37
+ const selected = items.filter((item) => item.namespace !== "extra.im");
38
+ ignored += items.length - selected.length;
39
+ return selected;
40
+ });
41
+ // 保留命名空间误配只记数量,不输出内容或阻断当前任务。
42
+ if (ignored)
43
+ context.log("warn", "channel.context.reserved_ignored", {
44
+ ignored_items: ignored
45
+ });
46
+ return business;
47
+ },
35
48
  credentials: (bot) => Promise.resolve(configuredCredential(bot)),
36
49
  ...(allowed
37
50
  ? {
@@ -76,9 +76,8 @@ export class WecomTransport {
76
76
  text: body.text.content,
77
77
  buildContext: (_signal, options) => Promise.resolve({
78
78
  schema: CONTEXT_SCHEMA,
79
- items: structuredClone([
80
- ...(options?.configuredItems ?? this.config.context?.items ?? [])
81
- ])
79
+ // extra.im 由本渠道构造;宿主业务材料须使用其他命名空间。
80
+ items: structuredClone((options?.configuredItems ?? this.config.context?.items ?? []).filter((item) => item.namespace !== "extra.im"))
82
81
  }),
83
82
  beginPresentation: (_runId, onDiagnostic) => {
84
83
  this.#streams.add(stream);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-extra-channel-wecom",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -22,10 +22,10 @@
22
22
  "docs"
23
23
  ],
24
24
  "dependencies": {
25
- "@mininglamp-oss/octo-runtime-host-sdk": "1.1.6",
26
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.6",
27
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.6",
25
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.7",
26
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.7",
27
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.7",
28
28
  "ws": "8.22.0",
29
- "@mininglamp-oss/octo-runtime-protocol": "1.1.6"
29
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.7"
30
30
  }
31
31
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-extra-webui",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Local Runtime workbench with canonical SSE presentation",
@@ -23,6 +23,6 @@
23
23
  "porting-map.md"
24
24
  ],
25
25
  "dependencies": {
26
- "@mininglamp-oss/octo-runtime-protocol": "1.1.6"
26
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.7"
27
27
  }
28
28
  }
@@ -17,14 +17,15 @@ export interface ChannelDependencies {
17
17
  * 只合并本轮数据,不保留历史。动态同 key 整项替换且保留静态位置,新项按返回顺序追加。
18
18
  * instructions.entries 也不拼接:覆盖方须显式保留需要的固定人设;空动态列表不删除静态项。
19
19
  * 两个来源先分别校验,避免同源重复 key 被覆盖掩盖;返回副本隔离宿主与插件的后续修改。
20
+ * 调用方可在来源校验后显式选择有效项,选择策略归调用方;最终合并预算仍强制校验。
20
21
  */
21
- export declare function mergeConfiguredContexts(base: readonly ContextItem[], dynamic: readonly ContextItem[]): ContextItem[];
22
+ export declare function mergeConfiguredContexts(base: readonly ContextItem[], dynamic: readonly ContextItem[], selectItems?: (items: readonly ContextItem[]) => readonly ContextItem[]): ContextItem[];
22
23
  /**
23
24
  * 每个 Extra 共用一个有界回调池,而非每个 Bot 各建一份额度。
24
25
  * 超时只结束本轮等待,不能强制结束外部 Promise;实际操作结束前仍须占额,防止挂起 IO 累积。
25
26
  */
26
27
  export declare function createContextLoader(callback: LoadContexts | undefined, settings: JsonValue | undefined, owner: AbortSignal): {
27
- load(config: JsonObject, signal: AbortSignal): Promise<ContextItem[]>;
28
+ load(config: JsonObject, signal: AbortSignal, selectItems?: (items: readonly ContextItem[]) => readonly ContextItem[]): Promise<ContextItem[]>;
28
29
  close(): Promise<void>;
29
30
  readonly inFlight: number;
30
31
  };
@@ -3,10 +3,17 @@ import { CONTEXT_SCHEMA, assertContextEnvelope } from "@mininglamp-oss/octo-runt
3
3
  * 只合并本轮数据,不保留历史。动态同 key 整项替换且保留静态位置,新项按返回顺序追加。
4
4
  * instructions.entries 也不拼接:覆盖方须显式保留需要的固定人设;空动态列表不删除静态项。
5
5
  * 两个来源先分别校验,避免同源重复 key 被覆盖掩盖;返回副本隔离宿主与插件的后续修改。
6
+ * 调用方可在来源校验后显式选择有效项,选择策略归调用方;最终合并预算仍强制校验。
6
7
  */
7
- export function mergeConfiguredContexts(base, dynamic) {
8
+ export function mergeConfiguredContexts(base, dynamic, selectItems) {
8
9
  assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: base });
9
10
  assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: dynamic });
11
+ if (selectItems) {
12
+ base = selectItems(base);
13
+ dynamic = selectItems(dynamic);
14
+ assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: base });
15
+ assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: dynamic });
16
+ }
10
17
  const items = [...base];
11
18
  const positions = new Map(items.map((item, index) => [`${item.namespace}/${item.name}`, index]));
12
19
  for (const item of dynamic) {
@@ -48,12 +55,12 @@ export function createContextLoader(callback, settings, owner) {
48
55
  const pending = new Set();
49
56
  const stop = new AbortController();
50
57
  return {
51
- async load(config, signal) {
58
+ async load(config, signal, selectItems) {
52
59
  const base = config.context?.items ?? [];
53
60
  if (!Array.isArray(base))
54
61
  throw new Error("IM_CONTEXT_INVALID");
55
62
  if (!callback)
56
- return mergeConfiguredContexts(base, []);
63
+ return mergeConfiguredContexts(base, [], selectItems);
57
64
  owner.throwIfAborted();
58
65
  stop.signal.throwIfAborted();
59
66
  signal.throwIfAborted();
@@ -74,7 +81,7 @@ export function createContextLoader(callback, settings, owner) {
74
81
  // 超时或取消后的迟到结果不能再校验、复制或进入本轮模型输入。
75
82
  combined.throwIfAborted();
76
83
  assertBoundedJson(items);
77
- return mergeConfiguredContexts(base, items);
84
+ return mergeConfiguredContexts(base, items, selectItems);
78
85
  });
79
86
  pending.add(operation);
80
87
  // 跟踪真实操作,而非 race 的等待结果;迟到 reject 也必须被消费,避免未处理拒绝。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-host-sdk",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,9 +23,9 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6",
27
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.6",
28
- "@mininglamp-oss/octo-runtime-protocol": "1.1.6"
26
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.7",
27
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.7",
28
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.7"
29
29
  },
30
30
  "types": "./dist/index.d.ts",
31
31
  "files": [
@@ -28,7 +28,7 @@ export function assertContextEnvelope(value) {
28
28
  const keys = new Set();
29
29
  for (const item of value.items) {
30
30
  object(item, "CONTEXT_SCHEMA_INVALID");
31
- fields(item, ["namespace", "name", "guidance", "payload"]);
31
+ fields(item, ["namespace", "name", "guidance", "data_format", "payload"]);
32
32
  for (const property of ["namespace", "name"]) {
33
33
  const text = item[property];
34
34
  if (typeof text !== "string" || text.length > 96 || !/^[a-z0-9][a-z0-9._-]*$/.test(text))
@@ -45,6 +45,13 @@ export function assertContextEnvelope(value) {
45
45
  throw new TypeError("CONTEXT_GUIDANCE_FORBIDDEN");
46
46
  }
47
47
  object(item.payload, "CONTEXT_SCHEMA_INVALID");
48
+ if (item.data_format !== undefined) {
49
+ if (item.data_format !== "text" || !String(item.namespace).startsWith("extra."))
50
+ throw new TypeError("CONTEXT_SCHEMA_INVALID");
51
+ fields(item.payload, ["text"]);
52
+ if (typeof item.payload.text !== "string")
53
+ throw new TypeError("CONTEXT_SCHEMA_INVALID");
54
+ }
48
55
  publicPayload(item.namespace, item.name, item.payload);
49
56
  }
50
57
  if (new TextEncoder().encode(JSON.stringify(value)).length > CONTEXT_MAX_BYTES)
@@ -87,6 +87,7 @@ export type ContextItem = {
87
87
  namespace: string;
88
88
  name: string;
89
89
  guidance?: string;
90
+ data_format?: "text";
90
91
  payload: Record<string, unknown>;
91
92
  };
92
93
  /**
@@ -2610,6 +2611,10 @@ export interface InvokeRequestWire {
2610
2611
  * Long-lived Agent Worker session identifier for this execution context.
2611
2612
  */
2612
2613
  agentSessionId: string;
2614
+ /**
2615
+ * Caller-owned nonblank display name of 1-256 Unicode code points, without C0/DEL/C1 controls; independent of business identity and opaque provider recovery handles.
2616
+ */
2617
+ sessionName?: string;
2613
2618
  /**
2614
2619
  * Run identifier for this execution.
2615
2620
  */
@@ -2842,6 +2847,10 @@ export interface IssuedToolAuthorization {
2842
2847
  expires_at: string;
2843
2848
  }
2844
2849
  export interface InvokeInputWire {
2850
+ /**
2851
+ * Optional caller-owned nonblank display name of 1-256 Unicode code points, without C0/DEL/C1 controls; Core supplies a random UUID default without business naming policy.
2852
+ */
2853
+ sessionName?: string;
2845
2854
  sessionId?: string;
2846
2855
  invocationId?: string;
2847
2856
  runId?: string;
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { assertSessionName } from "./invoke-input.js";
2
3
  export { assertJsonByteLimit } from "./json-size.js";
3
4
  export { INVOKE_REQUEST_MAX_BYTES, assertInvokeRequestSize } from "./invoke-size.js";
4
5
  export * from "./stream-limits.js";
@@ -532,6 +533,8 @@ export function assertFailureEnvelope(value) {
532
533
  export function assertInvokeRequest(request) {
533
534
  if (!isRecord(request))
534
535
  throw new TypeError("InvokeRequest must be an object");
536
+ if (request.sessionName !== undefined)
537
+ assertSessionName(request.sessionName);
535
538
  if (request.protocolVersion !== PROTOCOL_VERSION)
536
539
  throw new TypeError("InvokeRequest.protocolVersion must be 2");
537
540
  if ("appendInstructions" in request)
@@ -13,6 +13,8 @@ export declare class InvokeInput {
13
13
  contexts: ContextEnvelope;
14
14
  /** Business session identity; generated if omitted. Does not imply provider resume. */
15
15
  sessionId?: string;
16
+ /** 调用方拥有的展示名称;省略时由 Core 提供 UUID,不参与会话恢复。 */
17
+ sessionName?: string;
16
18
  /** Output view of the same execution stream; defaults to native. */
17
19
  protocol_mode?: "native" | "canonical";
18
20
  /** Cancellation identity for this invocation; generated if omitted. */
@@ -72,6 +74,8 @@ export declare function identifyInvokeInput(input: InvokeInput): {
72
74
  inputs: ModelInputPart[];
73
75
  /** Caller-owned Context v3 snapshot; an empty items array is valid. */
74
76
  contexts: ContextEnvelope;
77
+ /** 调用方拥有的展示名称;省略时由 Core 提供 UUID,不参与会话恢复。 */
78
+ sessionName?: string;
75
79
  /** Output view of the same execution stream; defaults to native. */
76
80
  protocol_mode?: "native" | "canonical";
77
81
  /** Caller-owned session generation, used to fence stale updates; no inferred default. */
@@ -119,5 +123,7 @@ export interface InputInvoke {
119
123
  (input: InvokeInput, environment?: InvokeEnvironment): AsyncGenerator<CanonicalEvent | HostFrame>;
120
124
  }
121
125
  export declare function assertInvokeInput(value: unknown): asserts value is InvokeInput;
126
+ /** 校验可读名称,不解析业务身份;同一约束用于公开输入与内部 Adapter wire。 */
127
+ export declare function assertSessionName(value: unknown): asserts value is string;
122
128
  /** Lossless field reorganization of a validated prepared execution, excluding its local signal. */
123
129
  export declare function invocationInput(request: InvokeRequest, protocol_mode?: "native" | "canonical", adapterType?: string): InvokeInput;
@@ -52,6 +52,8 @@ export function assertInvokeInput(value) {
52
52
  throw new TypeError("executionEnvOverrides belongs to the local invoke environment");
53
53
  assertModelInputParts(input.inputs);
54
54
  assertContextEnvelope(input.contexts);
55
+ if (input.sessionName !== undefined)
56
+ assertSessionName(input.sessionName);
55
57
  for (const key of [
56
58
  "sessionId",
57
59
  "invocationId",
@@ -128,6 +130,18 @@ export function assertInvokeInput(value) {
128
130
  throw new TypeError("providerSession.contextInputVariant is invalid");
129
131
  }
130
132
  }
133
+ /** 校验可读名称,不解析业务身份;同一约束用于公开输入与内部 Adapter wire。 */
134
+ export function assertSessionName(value) {
135
+ if (typeof value !== "string" ||
136
+ !value.trim() ||
137
+ value.length > 512 ||
138
+ [...value].length > 256 ||
139
+ [...value].some((character) => {
140
+ const code = character.charCodeAt(0);
141
+ return code < 32 || (code >= 127 && code <= 159);
142
+ }))
143
+ throw new TypeError("sessionName must contain 1-256 characters, not only whitespace, without control characters");
144
+ }
131
145
  /** Lossless field reorganization of a validated prepared execution, excluding its local signal. */
132
146
  export function invocationInput(request, protocol_mode = "native", adapterType) {
133
147
  const { protocolVersion: _version, signal: _signal, executionEnvOverrides: _executionEnvOverrides, agentSessionId, context, modelInputParts, ...fields } = request;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-protocol",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {