@allbluecn/web-app 0.27.40 → 0.28.0

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 (299) hide show
  1. package/package.json +1 -1
  2. package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  3. package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  4. package/public/pdfjs/cmaps/78-H.bcmap +0 -0
  5. package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  6. package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  7. package/public/pdfjs/cmaps/78-V.bcmap +0 -0
  8. package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  9. package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  10. package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  11. package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  12. package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  13. package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  14. package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  15. package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  16. package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  17. package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
  18. package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  19. package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  20. package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
  21. package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  22. package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  23. package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  24. package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  25. package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  26. package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  27. package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  28. package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  29. package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  30. package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  31. package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  32. package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  33. package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  34. package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  35. package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  36. package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  37. package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  38. package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  39. package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  40. package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  41. package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  42. package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  43. package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  44. package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  45. package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  46. package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  47. package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  48. package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
  49. package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
  50. package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  51. package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  52. package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  53. package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  54. package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  55. package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  56. package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  57. package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  58. package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  59. package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  60. package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  61. package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  62. package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  63. package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  64. package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
  65. package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
  66. package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
  67. package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  68. package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  69. package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
  70. package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  71. package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  72. package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
  73. package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
  74. package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  75. package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  76. package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  77. package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  78. package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  79. package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  80. package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  81. package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  82. package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
  83. package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
  84. package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  85. package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  86. package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  87. package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  88. package/public/pdfjs/cmaps/H.bcmap +0 -0
  89. package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  90. package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  91. package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  92. package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  93. package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  94. package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  95. package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  96. package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  97. package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  98. package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  99. package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  100. package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  101. package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
  102. package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
  103. package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  104. package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  105. package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
  106. package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  107. package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  108. package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
  109. package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  110. package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  111. package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  112. package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  113. package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  114. package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  115. package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
  116. package/public/pdfjs/cmaps/LICENSE +36 -0
  117. package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
  118. package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
  119. package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  120. package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  121. package/public/pdfjs/cmaps/Roman.bcmap +0 -0
  122. package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  123. package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  124. package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  125. package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  126. package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  127. package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  128. package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  129. package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  130. package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  131. package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  132. package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  133. package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  134. package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  135. package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  136. package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  137. package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  138. package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  139. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  140. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  141. package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  142. package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  143. package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  144. package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  145. package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  146. package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  147. package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  148. package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  149. package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  150. package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  151. package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  152. package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  153. package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  154. package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  155. package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  156. package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  157. package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  158. package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  159. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  160. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  161. package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  162. package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  163. package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  164. package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  165. package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  166. package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  167. package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  168. package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  169. package/public/pdfjs/cmaps/V.bcmap +0 -0
  170. package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  171. package/src/components/ai/ai-prompt-input/index.tsx +3 -87
  172. package/src/components/ai-elements/__tests__/context.test.tsx +167 -0
  173. package/src/components/ai-elements/context.tsx +182 -94
  174. package/src/components/ai-elements/prompt-input.tsx +6 -104
  175. package/src/components/harness/__tests__/composer-attachments.test.tsx +17 -9
  176. package/src/components/harness/__tests__/composer-click-focus.test.tsx +175 -0
  177. package/src/components/harness/__tests__/composer-focus.test.tsx +7 -0
  178. package/src/components/harness/__tests__/composer-keymap.test.ts +57 -0
  179. package/src/components/harness/__tests__/composer-paste.test.tsx +7 -0
  180. package/src/components/harness/__tests__/composer-pending-guard.test.tsx +207 -0
  181. package/src/components/harness/__tests__/composer-placeholder.test.ts +7 -6
  182. package/src/components/harness/__tests__/composer-plus-menu.test.tsx +202 -0
  183. package/src/components/harness/__tests__/composer-primary-button.test.tsx +7 -0
  184. package/src/components/harness/__tests__/composer-send.test.tsx +12 -4
  185. package/src/components/harness/__tests__/composer-undo.test.tsx +7 -0
  186. package/src/components/harness/__tests__/dock-registry.test.ts +3 -0
  187. package/src/components/harness/__tests__/harness-workbench-auth-error.test.tsx +42 -4
  188. package/src/components/harness/__tests__/mention-kbid.test.ts +69 -0
  189. package/src/components/harness/__tests__/undo-last-turn.test.ts +134 -0
  190. package/src/components/harness/__tests__/voice-activity.test.tsx +2 -2
  191. package/src/components/harness/conversation-panel/composer/__tests__/file-chip-open.test.tsx +195 -0
  192. package/src/components/harness/conversation-panel/composer/__tests__/menu-view.test.tsx +107 -0
  193. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-attachments.test.tsx +271 -0
  194. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-client-submit.test.tsx +291 -0
  195. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-guard.test.tsx +275 -0
  196. package/src/components/harness/conversation-panel/composer/command/__tests__/command-permission.test.tsx +286 -0
  197. package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx +344 -0
  198. package/src/components/harness/conversation-panel/composer/command/__tests__/command-popup.test.tsx +193 -0
  199. package/src/components/harness/conversation-panel/composer/command/__tests__/command-server-source.test.tsx +235 -0
  200. package/src/components/harness/conversation-panel/composer/command/__tests__/command-suggestion-menu.test.tsx +151 -1
  201. package/src/components/harness/conversation-panel/composer/command/__tests__/command-undo.test.tsx +168 -0
  202. package/src/components/harness/conversation-panel/composer/command/__tests__/exclude-composer-seat.test.ts +106 -0
  203. package/src/components/harness/conversation-panel/composer/command/__tests__/menu-view.test.tsx +55 -2
  204. package/src/components/harness/conversation-panel/composer/command/__tests__/skill-source.test.tsx +336 -0
  205. package/src/components/harness/conversation-panel/composer/command/claim.ts +7 -1
  206. package/src/components/harness/conversation-panel/composer/command/command-popup.tsx +140 -0
  207. package/src/components/harness/conversation-panel/composer/command/command-suggestion-menu.tsx +261 -75
  208. package/src/components/harness/conversation-panel/composer/command/menu-view.tsx +188 -50
  209. package/src/components/harness/conversation-panel/composer/command/popup-panel.tsx +106 -0
  210. package/src/components/harness/conversation-panel/composer/command/skill-source.ts +231 -0
  211. package/src/components/harness/conversation-panel/composer/composer-editor.tsx +216 -14
  212. package/src/components/harness/conversation-panel/composer/composer-keymap.ts +26 -0
  213. package/src/components/harness/conversation-panel/composer/extension/__tests__/command-menu.test.ts +128 -12
  214. package/src/components/harness/conversation-panel/composer/extension/command-menu.ts +303 -44
  215. package/src/components/harness/conversation-panel/composer/extension/index.ts +8 -0
  216. package/src/components/harness/conversation-panel/composer/harness-composer.tsx +551 -83
  217. package/src/components/harness/conversation-panel/composer/mention/__tests__/file-mention.test.tsx +517 -0
  218. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-source-registration.test.tsx +5 -2
  219. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-suggestion-menu.test.tsx +120 -0
  220. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-trigger-source.test.ts +52 -9
  221. package/src/components/harness/conversation-panel/composer/mention/__tests__/story-mention.test.tsx +356 -0
  222. package/src/components/harness/conversation-panel/composer/mention/__tests__/thread-mention.test.tsx +377 -0
  223. package/src/components/harness/conversation-panel/composer/mention/file-mention.ts +162 -0
  224. package/src/components/harness/conversation-panel/composer/mention/mention-resolvers.ts +6 -0
  225. package/src/components/harness/conversation-panel/composer/mention/mention-suggestion-menu.tsx +212 -107
  226. package/src/components/harness/conversation-panel/composer/mention/mention-trigger-source.ts +71 -8
  227. package/src/components/harness/conversation-panel/composer/mention/story-mention.ts +131 -0
  228. package/src/components/harness/conversation-panel/composer/mention/thread-mention.ts +159 -0
  229. package/src/components/harness/conversation-panel/composer/mention/use-mention-sources.ts +9 -1
  230. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/model-selector.test.tsx +401 -0
  231. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/wiring.test.ts +117 -0
  232. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-panel.tsx +411 -0
  233. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-trigger.tsx +254 -0
  234. package/src/components/harness/conversation-panel/composer/model-selector/wiring.ts +112 -0
  235. package/src/components/harness/conversation-panel/composer/permission/__tests__/permission-select.test.tsx +264 -0
  236. package/src/components/harness/conversation-panel/composer/permission/permission-policy.ts +76 -0
  237. package/src/components/harness/conversation-panel/composer/permission/permission-popup.tsx +302 -0
  238. package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx +140 -0
  239. package/src/components/harness/conversation-panel/composer/workspace/__tests__/workspace-select.test.tsx +390 -0
  240. package/src/components/harness/conversation-panel/composer/workspace/workspace-select-button.tsx +367 -0
  241. package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
  242. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +26 -6
  243. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +21 -3
  244. package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
  245. package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
  246. package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
  247. package/src/components/harness/extension-panel/dock/dock-registry.ts +35 -14
  248. package/src/components/harness/extension-panel/dock/dock-surface.tsx +2 -0
  249. package/src/components/harness/extension-panel/dock/guide-page.tsx +75 -45
  250. package/src/components/harness/extension-panel/panels/browser/__tests__/webview-frame.test.tsx +5 -2
  251. package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
  252. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
  253. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
  254. package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
  255. package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
  256. package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
  257. package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
  258. package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
  259. package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
  260. package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
  261. package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
  262. package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
  263. package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
  264. package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
  265. package/src/components/harness/workbench/provider-model-groups.ts +140 -0
  266. package/src/components/harness/workbench/undo-last-turn.ts +79 -0
  267. package/src/components/harness/workbench/workbench-context.tsx +53 -3
  268. package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
  269. package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
  270. package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
  271. package/src/components/tiptap/node/mention-extension.ts +33 -0
  272. package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
  273. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
  274. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
  275. package/src/lib/changelog/sdk-versions.ts +2 -2
  276. package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
  277. package/src/lib/queries/harness.ts +50 -0
  278. package/src/paraglide/messages/_index.js +1574 -311
  279. package/src/paraglide/messages/en.js +513 -103
  280. package/src/paraglide/messages/zh.js +514 -104
  281. package/src/routeTree.gen.ts +31 -0
  282. package/src/routes/_nav/harness/route.lazy.tsx +13 -0
  283. package/src/server/ai-gateway/sandbox/policy.ts +6 -6
  284. package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
  285. package/src/server/harness/__tests__/define-expose.test.ts +17 -0
  286. package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
  287. package/src/server/harness/define.server.ts +21 -3
  288. package/src/server/harness/thread-reference.server.ts +446 -0
  289. package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
  290. package/src/server/serverFns/chat/conversations.ts +18 -3
  291. package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
  292. package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
  293. package/src/shared/harness/thread-reference-format.ts +98 -0
  294. package/LICENSE +0 -661
  295. package/src/components/agents/slash-skill-menu.tsx +0 -75
  296. package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
  297. package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
  298. package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
  299. package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
@@ -49,6 +49,7 @@ import { Route as ApiHealthRouteImport } from './routes/api/health'
49
49
  import { Route as ApiSearchRouteImport } from './routes/api/search'
50
50
  import { Route as ApiStoryAiRouteImport } from './routes/api/story-ai'
51
51
  import { Route as CollectTokenRouteRouteImport } from './routes/collect/$token/route'
52
+ import { Route as DevGalleryRouteImport } from './routes/dev/gallery'
52
53
  import { Route as InviteTokenRouteRouteImport } from './routes/invite/$token/route'
53
54
  import { Route as ServerAiStreamRouteImport } from './routes/server/ai-stream'
54
55
  import { Route as ServerWsRouteImport } from './routes/server/ws'
@@ -406,6 +407,11 @@ const CollectTokenRouteRoute = CollectTokenRouteRouteImport.update({
406
407
  } as any).lazy(() =>
407
408
  import('./routes/collect/$token/route.lazy').then((d) => d.Route),
408
409
  )
410
+ const DevGalleryRoute = DevGalleryRouteImport.update({
411
+ id: '/dev/gallery',
412
+ path: '/dev/gallery',
413
+ getParentRoute: () => rootRouteImport,
414
+ } as any)
409
415
  const InviteTokenRouteRoute = InviteTokenRouteRouteImport.update({
410
416
  id: '/invite/$token',
411
417
  path: '/invite/$token',
@@ -1197,6 +1203,7 @@ export interface FileRoutesByFullPath {
1197
1203
  '/api/health': typeof ApiHealthRoute
1198
1204
  '/api/search': typeof ApiSearchRoute
1199
1205
  '/api/story-ai': typeof ApiStoryAiRoute
1206
+ '/dev/gallery': typeof DevGalleryRoute
1200
1207
  '/server/ai-stream': typeof ServerAiStreamRoute
1201
1208
  '/server/ws': typeof ServerWsRoute
1202
1209
  '/$lang/docs/$': typeof LangDocsSplatRouteRoute
@@ -1336,6 +1343,7 @@ export interface FileRoutesByTo {
1336
1343
  '/api/health': typeof ApiHealthRoute
1337
1344
  '/api/search': typeof ApiSearchRoute
1338
1345
  '/api/story-ai': typeof ApiStoryAiRoute
1346
+ '/dev/gallery': typeof DevGalleryRoute
1339
1347
  '/server/ai-stream': typeof ServerAiStreamRoute
1340
1348
  '/server/ws': typeof ServerWsRoute
1341
1349
  '/$lang/docs/$': typeof LangDocsSplatRouteRoute
@@ -1478,6 +1486,7 @@ export interface FileRoutesById {
1478
1486
  '/api/health': typeof ApiHealthRoute
1479
1487
  '/api/search': typeof ApiSearchRoute
1480
1488
  '/api/story-ai': typeof ApiStoryAiRoute
1489
+ '/dev/gallery': typeof DevGalleryRoute
1481
1490
  '/server/ai-stream': typeof ServerAiStreamRoute
1482
1491
  '/server/ws': typeof ServerWsRoute
1483
1492
  '/$lang/docs/$': typeof LangDocsSplatRouteRoute
@@ -1626,6 +1635,7 @@ export interface FileRouteTypes {
1626
1635
  | '/api/health'
1627
1636
  | '/api/search'
1628
1637
  | '/api/story-ai'
1638
+ | '/dev/gallery'
1629
1639
  | '/server/ai-stream'
1630
1640
  | '/server/ws'
1631
1641
  | '/$lang/docs/$'
@@ -1765,6 +1775,7 @@ export interface FileRouteTypes {
1765
1775
  | '/api/health'
1766
1776
  | '/api/search'
1767
1777
  | '/api/story-ai'
1778
+ | '/dev/gallery'
1768
1779
  | '/server/ai-stream'
1769
1780
  | '/server/ws'
1770
1781
  | '/$lang/docs/$'
@@ -1906,6 +1917,7 @@ export interface FileRouteTypes {
1906
1917
  | '/api/health'
1907
1918
  | '/api/search'
1908
1919
  | '/api/story-ai'
1920
+ | '/dev/gallery'
1909
1921
  | '/server/ai-stream'
1910
1922
  | '/server/ws'
1911
1923
  | '/$lang/docs/$'
@@ -2030,6 +2042,7 @@ export interface RootRouteChildren {
2030
2042
  ApiHealthRoute: typeof ApiHealthRoute
2031
2043
  ApiSearchRoute: typeof ApiSearchRoute
2032
2044
  ApiStoryAiRoute: typeof ApiStoryAiRoute
2045
+ DevGalleryRoute: typeof DevGalleryRoute
2033
2046
  ServerAiStreamRoute: typeof ServerAiStreamRoute
2034
2047
  ServerWsRoute: typeof ServerWsRoute
2035
2048
  LangDocsSplatRouteRoute: typeof LangDocsSplatRouteRoute
@@ -2337,6 +2350,13 @@ declare module '@tanstack/react-router' {
2337
2350
  preLoaderRoute: typeof CollectTokenRouteRouteImport
2338
2351
  parentRoute: typeof rootRouteImport
2339
2352
  }
2353
+ '/dev/gallery': {
2354
+ id: '/dev/gallery'
2355
+ path: '/dev/gallery'
2356
+ fullPath: '/dev/gallery'
2357
+ preLoaderRoute: typeof DevGalleryRouteImport
2358
+ parentRoute: typeof rootRouteImport
2359
+ }
2340
2360
  '/invite/$token': {
2341
2361
  id: '/invite/$token'
2342
2362
  path: '/invite/$token'
@@ -3590,6 +3610,7 @@ const rootRouteChildren: RootRouteChildren = {
3590
3610
  ApiHealthRoute: ApiHealthRoute,
3591
3611
  ApiSearchRoute: ApiSearchRoute,
3592
3612
  ApiStoryAiRoute: ApiStoryAiRoute,
3613
+ DevGalleryRoute: DevGalleryRoute,
3593
3614
  ServerAiStreamRoute: ServerAiStreamRoute,
3594
3615
  ServerWsRoute: ServerWsRoute,
3595
3616
  LangDocsSplatRouteRoute: LangDocsSplatRouteRoute,
@@ -3632,3 +3653,13 @@ const rootRouteChildren: RootRouteChildren = {
3632
3653
  export const routeTree = rootRouteImport
3633
3654
  ._addFileChildren(rootRouteChildren)
3634
3655
  ._addFileTypes<FileRouteTypes>()
3656
+
3657
+ import type { getRouter } from './router.tsx'
3658
+ import type { startInstance } from './start.ts'
3659
+ declare module '@tanstack/react-start' {
3660
+ interface Register {
3661
+ ssr: true
3662
+ router: Awaited<ReturnType<typeof getRouter>>
3663
+ config: Awaited<ReturnType<typeof startInstance.getOptions>>
3664
+ }
3665
+ }
@@ -15,8 +15,10 @@
15
15
  // You should have received a copy of the GNU Affero General Public License
16
16
  // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
 
18
+ import { useEffect } from "react"
18
19
  import { createLazyFileRoute, Outlet, useLocation } from "@tanstack/react-router"
19
20
  import HarnessWorkbenchPage from "@/components/harness/workbench/harness-workbench-page"
21
+ import { dockRegistry } from "@/components/harness/extension-panel/dock/dock-registry"
20
22
 
21
23
  export const Route = createLazyFileRoute('/_nav/harness')({
22
24
  component: HarnessPage,
@@ -24,5 +26,16 @@ export const Route = createLazyFileRoute('/_nav/harness')({
24
26
 
25
27
  function HarnessPage() {
26
28
  const pathname = useLocation({ select: (location) => location.pathname })
29
+
30
+ // 进入 harness 模块(本 layout 挂载 = 自其他模块/页面切入)→ 右侧面板强制收起
31
+ // (2026-11-19 用户裁决:进入 Harness 右侧面板默认关闭,打开见开始页)。
32
+ // 放 layout 层而非 WorkbenchCenter:$threadId 以 key={threadId} 强制重建页面,模块内
33
+ // 切线程会重跑页面级 effect 而误收起刚展开的面板;index ↔ $threadId ↔ gallery 互切
34
+ // 本 layout 恒挂载,effect 不重跑。时序:子路由 switchThread 先恢复线程存档 expanded,
35
+ // 本 effect 后跑 → 进入模块最终态恒收起。
36
+ useEffect(() => {
37
+ dockRegistry.setExpanded(false)
38
+ }, [])
39
+
27
40
  return pathname.replace(/\/$/, "") === "/harness" ? <HarnessWorkbenchPage /> : <Outlet />
28
41
  }
@@ -24,13 +24,13 @@ export { SANDBOX_POLICY_LEVELS, type SandboxPolicyLevel } from "./policy-levels"
24
24
  * 「full」档需用户显式确认(serverFn 要求 confirmFull: true)——装配侧统一走
25
25
  * SANDBOX_DEFAULT_POLICY_LEVEL 兜底。
26
26
  *
27
- * 默认档 = workspace-write(F4-7 对齐 DSH 出厂值):映射 harness permissions
28
- * mode 'default',policy default 恒 'ask'——未命中白名单的命令仍逐次审批,
29
- * 写盘/网络能力不静默放行。全部建线路径显式写本常量落库(conversations /
30
- * fork-thread / chat-handler / persistence stores);DB 列默认 'readonly' 保持
31
- * 不动,仅作未覆盖路径的 fail-closed 兜底(schema.prisma ChatThread.sandboxPolicy)。
27
+ * 默认档 = **readonly**(用户裁决 2026-11-21:新会话默认只读权限,写盘/命令需用户
28
+ * 显式切档):映射 harness permissions mode 'plan'(edit/execute/ask 全拒)。
29
+ * 全部建线路径显式写本常量落库(conversations / fork-thread / chat-handler /
30
+ * persistence stores);DB 列默认 'readonly' 与本常量同值(schema.prisma
31
+ * ChatThread.sandboxPolicy)。历史:F4-7 曾对齐 DSH 出厂值 workspace-write。
32
32
  */
33
- export const SANDBOX_DEFAULT_POLICY_LEVEL: SandboxPolicyLevel = "workspace-write"
33
+ export const SANDBOX_DEFAULT_POLICY_LEVEL: SandboxPolicyLevel = "readonly"
34
34
 
35
35
  export function isSandboxPolicyLevel(v: unknown): v is SandboxPolicyLevel {
36
36
  return typeof v === "string" && (SANDBOX_POLICY_LEVELS as readonly string[]).includes(v)
@@ -0,0 +1,46 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // /compact 手动压缩装配测试(任务 1:server 命令源首条真实命令):
6
+ // 官方 first-party session-tools 的 compact() 插件挂入 harnessPlugins 工厂 +
7
+ // expose.commands 白名单放行 'compact'。断言读 buildHarnessDefinition 返回的
8
+ // 定义对象(Readonly<HarnessConfig>):plugins 是工厂(调用取插件数组,插件
9
+ // name 单一来源)、expose.commands 是白名单只读数组。compact 的命令定义由插件
10
+ // setup 贡献(无 input schema,回合外 command control op),命令 run 的执行
11
+ // 体(transcript 摘要 + replaceTranscript)属官方插件行为,不在本层重复覆盖。
12
+
13
+ import { describe, expect, it } from 'vitest'
14
+
15
+ import { buildHarnessDefinition } from '../define.server'
16
+
17
+ /** 插件名集合(plugins 工厂调用产物;HarnessPlugin.name 单一来源)。 */
18
+ function mountedPluginNames(): string[] {
19
+ const harness = buildHarnessDefinition()
20
+ const plugins = harness.plugins?.() ?? []
21
+ return plugins.map((p) => p.name)
22
+ }
23
+
24
+ describe('/compact 官方插件装配(任务 1:server 命令源首条真实命令)', () => {
25
+ it('expose.commands 白名单含 compact(客户端可调面)', () => {
26
+ const harness = buildHarnessDefinition()
27
+ const commands = harness.expose?.commands ?? []
28
+ expect(commands).toContain('compact')
29
+ })
30
+
31
+ it('plugins 工厂含 tanstack/compact(官方 first-party session-tools)', () => {
32
+ expect(mountedPluginNames()).toContain('tanstack/compact')
33
+ })
34
+
35
+ it('undo 通行证保留(Checkpoint Restore / Retry 依赖,官方 protocol 校验)', () => {
36
+ const harness = buildHarnessDefinition()
37
+ expect(harness.expose?.commands ?? []).toContain('undo')
38
+ })
39
+
40
+ it('compact 与既有系统插件并存(permissions/todos/usage 等零丢失)', () => {
41
+ const names = mountedPluginNames()
42
+ for (const expected of ['tanstack/permissions', 'tanstack/todos', 'tanstack/usage']) {
43
+ expect(names).toContain(expected)
44
+ }
45
+ })
46
+ })
@@ -0,0 +1,17 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // harness expose 白名单断言(P2 composer 控制,任务 1 / P0-1):configure op 逐
6
+ // key 校验 expose.settings,settings 白名单必须同时覆盖 model 与 reasoning——
7
+ // 缺 'reasoning' 时 composer reasoning 档位写入被 not_exposed 拒绝。
8
+ // 复审 P2-3:buildHarnessDefinition 已导出且测试可直连 import(先例
9
+ // define-registry-subagents.test.ts,unit project 无需 mock)。
10
+
11
+ import { expect, test } from 'vitest'
12
+
13
+ import { buildHarnessDefinition } from '../define.server'
14
+
15
+ test('expose.settings 覆盖 model 与 reasoning(P0-1:configure op 每 key 校验白名单)', () => {
16
+ expect(buildHarnessDefinition().expose?.settings).toEqual(expect.arrayContaining(['model', 'reasoning']))
17
+ })
@@ -0,0 +1,258 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // @thread host 注入 middleware(P2 任务 4)单测。
6
+ //
7
+ // 以 transform 纯函数 `threadReferenceTransform(messages, deps)` 为主(deps mock
8
+ // 注入 IO:requireOwned / resolveTranscript / loadLegacyMessages / 可读引文格式化),
9
+ // 不依赖真实 host / prisma / paraglide。覆盖:标记替换、多引用、超 3 拒、自引用拒、
10
+ // 跨用户拒、字节预算截断、双通路(transcript 空 → legacy)、都空降级(仅标题)、
11
+ // 幂等重入(已注入特征的消息表再跑一遍不变)、JSON 无裸 `<`(stringifySafe)。
12
+ // 另含 define 层挂载断言(照 compact-plugin.server.test 模式)。
13
+
14
+ import { describe, expect, it } from 'vitest'
15
+ import type { ModelMessage } from '@tanstack/ai'
16
+
17
+ import {
18
+ THREAD_REFERENCE_MAX_BYTES,
19
+ REFERENCED_THREADS_SENTINEL,
20
+ threadReferenceTransform,
21
+ stringifySafe,
22
+ type ThreadReferenceDeps,
23
+ } from '../thread-reference.server'
24
+
25
+ /** 可读引文格式化 fake(生产用 paraglide m.harness_mention_threadRef)。 */
26
+ const readable = (title: string) => `参考会话《${title}》`
27
+
28
+ /** 构造 deps(可逐字段覆盖)。 */
29
+ function makeDeps(over: Partial<ThreadReferenceDeps> = {}): ThreadReferenceDeps {
30
+ return {
31
+ userId: 'u1',
32
+ currentThreadId: 't-current',
33
+ requireOwned: async () => ({}),
34
+ resolveTranscript: async () => [],
35
+ loadLegacyMessages: async () => [],
36
+ formatThreadRefReadable: readable,
37
+ ...over,
38
+ }
39
+ }
40
+
41
+ function userMsg(text: string, id = 'm-user'): ModelMessage {
42
+ return { id, role: 'user', content: text }
43
+ }
44
+
45
+ /** 含某 marker 的 user 消息文本。 */
46
+ const marker = (label: string, id: string) => `@[${label}](allblue-thread:${id})`
47
+
48
+ /** 取全部含注入特征的 recall 消息。 */
49
+ function recallMessages(msgs: ModelMessage[]): ModelMessage[] {
50
+ return msgs.filter(
51
+ (m) => typeof m.content === 'string' && m.content.includes(REFERENCED_THREADS_SENTINEL),
52
+ )
53
+ }
54
+
55
+ describe('threadReferenceTransform(纯函数,deps 注入)', () => {
56
+ it('标记替换:accepted 引用改写为可读文本 + 紧随注入 recall', async () => {
57
+ const deps = makeDeps({
58
+ resolveTranscript: async () => [
59
+ { role: 'user', content: '你好' },
60
+ { role: 'assistant', content: '世界' },
61
+ ],
62
+ })
63
+ const input = [userMsg(`看看 ${marker('会话甲', 't-acc')} 的内容`)]
64
+ const out = await threadReferenceTransform(input, deps)
65
+
66
+ // 改写:标记消失、可读引文出现
67
+ const rewritten = out[0]
68
+ expect(rewritten.role).toBe('user')
69
+ expect(String(rewritten.content)).toContain(readable('会话甲'))
70
+ expect(String(rewritten.content)).not.toContain('allblue-thread:')
71
+
72
+ // 注入:紧随其后的 recall 消息
73
+ const recalls = recallMessages(out)
74
+ expect(recalls).toHaveLength(1)
75
+ expect(out.indexOf(recalls[0]!)).toBe(1)
76
+ const recallText = String(recalls[0]!.content)
77
+ expect(recallText).toContain(REFERENCED_THREADS_SENTINEL)
78
+ expect(recallText).toContain('t-acc')
79
+ // 投影:user/assistant 文本进入 JSON
80
+ expect(recallText).toContain('你好')
81
+ expect(recallText).toContain('世界')
82
+ // 不可信警告
83
+ expect(recallText).toContain('只读快照')
84
+ })
85
+
86
+ it('多引用:两个 accepted 引用都改写 + 单条 recall 含两个 thread', async () => {
87
+ const deps = makeDeps({
88
+ resolveTranscript: async (tid) => [{ role: 'user', content: `内容-${tid}` }],
89
+ })
90
+ const input = [userMsg(`${marker('甲', 't-a')} 和 ${marker('乙', 't-b')}`)]
91
+ const out = await threadReferenceTransform(input, deps)
92
+
93
+ expect(String(out[0]!.content)).toContain(readable('甲'))
94
+ expect(String(out[0]!.content)).toContain(readable('乙'))
95
+ const recalls = recallMessages(out)
96
+ expect(recalls).toHaveLength(1)
97
+ expect(String(recalls[0]!.content)).toContain('t-a')
98
+ expect(String(recalls[0]!.content)).toContain('t-b')
99
+ })
100
+
101
+ it('超 3 拒:第 4 个引用保留标记原文 + omission 说明', async () => {
102
+ const deps = makeDeps({
103
+ resolveTranscript: async (tid) => [{ role: 'user', content: `c-${tid}` }],
104
+ })
105
+ const text = [1, 2, 3, 4].map((i) => marker(`会话${i}`, `t-${i}`)).join(' ')
106
+ const out = await threadReferenceTransform([userMsg(text)], deps)
107
+
108
+ // 前 3 改写,第 4 保留标记
109
+ const rewritten = String(out[0]!.content)
110
+ expect(rewritten).toContain(readable('会话1'))
111
+ expect(rewritten).toContain(readable('会话2'))
112
+ expect(rewritten).toContain(readable('会话3'))
113
+ expect(rewritten).toContain(marker('会话4', 't-4'))
114
+ // omission 说明(recall 内)
115
+ const recallText = String(recallMessages(out)[0]!.content)
116
+ expect(recallText).toContain('t-4')
117
+ expect(recallText).toContain('3')
118
+ })
119
+
120
+ it('自引用拒:threadId == 当前线程 → 保留标记 + omission', async () => {
121
+ const deps = makeDeps()
122
+ const input = [userMsg(`self ${marker('当前', 't-current')}`)]
123
+ const out = await threadReferenceTransform(input, deps)
124
+
125
+ expect(String(out[0]!.content)).toContain(marker('当前', 't-current'))
126
+ const recallText = String(recallMessages(out)[0]!.content)
127
+ expect(recallText).toContain('t-current')
128
+ // 无 accepted thread 注入
129
+ expect(recallText).not.toContain('"messages":[{"role"')
130
+ })
131
+
132
+ it('跨用户拒:requireOwned 抛 → 保留标记 + omission', async () => {
133
+ const deps = makeDeps({
134
+ requireOwned: async (tid) => {
135
+ if (tid === 't-other') throw new Error('Unauthorized')
136
+ return {}
137
+ },
138
+ })
139
+ const input = [userMsg(`x ${marker('他人', 't-other')}`)]
140
+ const out = await threadReferenceTransform(input, deps)
141
+
142
+ expect(String(out[0]!.content)).toContain(marker('他人', 't-other'))
143
+ const recallText = String(recallMessages(out)[0]!.content)
144
+ expect(recallText).toContain('t-other')
145
+ })
146
+
147
+ it('双通路:transcript 空 → legacy chat_messages', async () => {
148
+ const deps = makeDeps({
149
+ resolveTranscript: async () => [],
150
+ loadLegacyMessages: async () => [{ role: 'user', content: 'legacy内容' }],
151
+ })
152
+ const out = await threadReferenceTransform([userMsg(marker('旧', 't-old'))], deps)
153
+ const recallText = String(recallMessages(out)[0]!.content)
154
+ expect(recallText).toContain('legacy内容')
155
+ expect(recallText).toContain('legacy')
156
+ })
157
+
158
+ it('都空降级:仅标题(threads 内 messages 为空)', async () => {
159
+ const deps = makeDeps()
160
+ const out = await threadReferenceTransform([userMsg(marker('空会话', 't-empty'))], deps)
161
+ // 标记仍改写为可读引文(accepted,只是内容降级为仅标题)
162
+ expect(String(out[0]!.content)).toContain(readable('空会话'))
163
+ const recallText = String(recallMessages(out)[0]!.content)
164
+ expect(recallText).toContain('t-empty')
165
+ expect(recallText).toContain('空会话')
166
+ // 无投影正文
167
+ expect(recallText).toContain('"messages":[]')
168
+ })
169
+
170
+ it('预算截断:>64KiB 单条投影被 head/tail 截断并标注', async () => {
171
+ const big = 'A'.repeat(THREAD_REFERENCE_MAX_BYTES + 40_000)
172
+ const deps = makeDeps({
173
+ resolveTranscript: async () => [{ role: 'assistant', content: big }],
174
+ })
175
+ const out = await threadReferenceTransform([userMsg(marker('大', 't-big'))], deps)
176
+ const recallText = String(recallMessages(out)[0]!.content)
177
+ // recall 总体不超预算(留出 envelope 余量)
178
+ expect(Buffer.byteLength(recallText, 'utf8')).toBeLessThan(THREAD_REFERENCE_MAX_BYTES + 4096)
179
+ // 截断标注
180
+ expect(recallText).toContain('省略')
181
+ })
182
+
183
+ it('notice(notice-N id 前缀)排除、tool 角色排除', async () => {
184
+ const deps = makeDeps({
185
+ resolveTranscript: async () => [
186
+ { id: 'notice-1', role: 'user', content: 'notice正文' },
187
+ { role: 'tool', content: 'tool正文' },
188
+ { role: 'assistant', content: '可见正文' },
189
+ ],
190
+ })
191
+ const out = await threadReferenceTransform([userMsg(marker('n', 't-n'))], deps)
192
+ const recallText = String(recallMessages(out)[0]!.content)
193
+ expect(recallText).toContain('可见正文')
194
+ expect(recallText).not.toContain('notice正文')
195
+ expect(recallText).not.toContain('tool正文')
196
+ })
197
+
198
+ it('幂等重入:已注入特征的消息表再跑一遍不变(迭代重入守卫)', async () => {
199
+ const deps = makeDeps({
200
+ resolveTranscript: async () => [{ role: 'user', content: '你好' }],
201
+ })
202
+ // 第一遍
203
+ const first = await threadReferenceTransform([userMsg(marker('甲', 't-a'))], deps)
204
+ expect(recallMessages(first)).toHaveLength(1)
205
+ // 第二遍:把第一遍产物(已改写、已含 recall)再喂回去
206
+ const second = await threadReferenceTransform(first, deps)
207
+ expect(second).toBe(first) // 无变化返回同一引用(no-op)
208
+ expect(recallMessages(second)).toHaveLength(1) // 未重复追加
209
+ })
210
+
211
+ it('幂等:标记与 sentinel 并存的病态输入不重复追加 recall', async () => {
212
+ const deps = makeDeps({
213
+ resolveTranscript: async () => [{ role: 'user', content: 'c' }],
214
+ })
215
+ const withSentinel: ModelMessage = {
216
+ role: 'user',
217
+ content: `x\n${REFERENCED_THREADS_SENTINEL}\n`,
218
+ }
219
+ const input = [userMsg(marker('甲', 't-a'), 'm2'), withSentinel]
220
+ const out = await threadReferenceTransform(input, deps)
221
+ expect(recallMessages(out)).toHaveLength(1)
222
+ })
223
+
224
+ it('无标记:原样返回(no-op,返回同一引用)', async () => {
225
+ const deps = makeDeps()
226
+ const input = [userMsg('普通消息,无标记')]
227
+ const out = await threadReferenceTransform(input, deps)
228
+ expect(out).toBe(input)
229
+ })
230
+ })
231
+
232
+ describe('stringifySafe(防伪造标签注入)', () => {
233
+ it('< 转义为 \\u003c,无裸 <', () => {
234
+ const s = stringifySafe({ x: '<script>alert(1)</script>' })
235
+ expect(s).not.toContain('<')
236
+ expect(s).toContain('\\u003c')
237
+ })
238
+
239
+ it('注入 recall 内投影正文含 < 时被转义(仅 envelope 标签保留尖括号)', async () => {
240
+ const deps = makeDeps({
241
+ resolveTranscript: async () => [{ role: 'assistant', content: '<b>hi</b>' }],
242
+ })
243
+ const out = await threadReferenceTransform([userMsg(marker('x', 't-x'))], deps)
244
+ const recallText = String(recallMessages(out)[0]!.content)
245
+ expect(recallText).not.toContain('<b>')
246
+ expect(recallText).not.toContain('</b>')
247
+ expect(recallText).toContain('\\u003cb\\u003e')
248
+ })
249
+ })
250
+
251
+ describe('define 层挂载(thread-reference middleware 进 harnessMiddleware)', () => {
252
+ it('middleware 数组含 allblue/thread-reference', async () => {
253
+ const { buildHarnessDefinition } = await import('../define.server')
254
+ const harness = buildHarnessDefinition()
255
+ const names = (harness.middleware ?? []).map((mw) => (mw as { name?: string }).name)
256
+ expect(names).toContain('allblue/thread-reference')
257
+ })
258
+ })
@@ -27,6 +27,7 @@ import { otelMiddleware } from '@tanstack/ai/middlewares/otel'
27
27
  import { trace } from '@opentelemetry/api'
28
28
  import { defineHarness, type AnyHarness, type HarnessPlugin } from '@tanstack/ai-harness'
29
29
  import {
30
+ compact,
30
31
  permissions,
31
32
  todos,
32
33
  question,
@@ -40,6 +41,7 @@ import path from 'node:path'
40
41
  import { createAiOutputGuardMiddleware } from '@/server/ai-gateway/ai-output-guard'
41
42
  import { createToolBudgetMiddleware } from '@/server/ai-gateway/middlewares/tool-budget'
42
43
  import { createUsageLogMiddleware } from '@/server/ai-gateway/middlewares/usage-log'
44
+ import { createThreadReferenceMiddleware } from '@/server/harness/thread-reference.server'
43
45
  import { getIdentityFromContext } from '@/server/agents/context.server'
44
46
  import { chatSubagentsBag } from '@/server/ai-gateway/chat-subagents.server'
45
47
  import { assembleAppPlugins } from '@/server/harness/plugins/assemble-app'
@@ -133,6 +135,11 @@ function harnessMiddleware(
133
135
  otelMiddleware({ tracer, captureContent: false }),
134
136
  createAiOutputGuardMiddleware(),
135
137
  createToolBudgetMiddleware(),
138
+ // @thread host 注入(P2 任务 4):onConfig beforeModel 扫描 config.messages 中的
139
+ // `allblue-thread:` 标记 → 就地改写为可读引文 + 紧随注入 recall 快照(入转录、字节
140
+ // 预算投影、双通路读取)。置于 compaction 之前,使注入的 recall 参与压缩计数
141
+ // (已知边界 #4)。无标记时 onConfig 快速返回 undefined(hot path 零开销)。
142
+ createThreadReferenceMiddleware(),
136
143
  // Phase 3 compaction 调优(T3.5):clearToolResults → summarizeOldest +
137
144
  // countTokens:'usage'。装配细节(含 env-key 摘要 adapter 与回落)见
138
145
  // compaction.server.ts。
@@ -271,6 +278,12 @@ function harnessPlugins(
271
278
  // 时正常挂载,行为与改动前一致。
272
279
  ...(titleAdapter ? [title({ adapter: titleAdapter })] : []),
273
280
  usage(),
281
+ // /compact(任务 1,P1):官方 first-party session-tools 插件——手动压缩上下文
282
+ // 命令(server 命令源首条真实命令)。命令 run 执行体 = transcript 摘要(经
283
+ // adapter 发模型)→ replaceTranscript,属官方插件行为。adapter 与 title 同源
284
+ // (defaultAdapter 用户路由门面,命令 run 的身份经 ALS/chat context 解析
285
+ // per-user key),挂载守卫同 title:无 adapter 时命令无从摘要,跳过挂载。
286
+ ...(titleAdapter ? [compact({ adapter: titleAdapter })] : []),
274
287
  boundToolOutput({ retentionDays: 7 }),
275
288
  // 撤销/快照(D10,T2.6):仅 git 探测通过时加入(桌面;云端沙箱文件系统非
276
289
  // 本机 git 仓库,MVP 不挂——D10 降级 UI 明示)。snapshots 置于 workspaceTools
@@ -378,11 +391,16 @@ export function buildHarnessDefinition(overrides?: {
378
391
  // 只能经模型 turn 调用。businessTools F2-2b 起退役为插件贡献后即退出 expose.tools
379
392
  // 可及范围(如需客户端直调某业务工具,须显式挂回顶层 tools 面)。
380
393
  expose: {
381
- settings: ['model'],
394
+ // P0-1(任务 1):configure op 逐 key 校验白名单——composer reasoning 档位经
395
+ // settings.reasoning 写入,缺 'reasoning' 即 not_exposed 拒绝(R5-A 诚实
396
+ // 白名单:仅 openai/anthropic/openrouter 三 kind 适配器消费该参数)。
397
+ settings: ['model', 'reasoning'],
382
398
  // undo 是 revert/unrevert control op 的通行证(官方 protocol.js 校验
383
399
  // expose.commands 含 "undo",缺即 not_exposed 拒绝——Checkpoint Restore/
384
- // Retry 依赖)。插件贡献的命令名与其合并去重。
385
- commands: [...new Set([...commandNames, 'undo'])],
400
+ // Retry 依赖)。compact(任务 1,P1):官方 tanstack/compact 插件贡献的
401
+ // 手动压缩命令('/' 菜单 server 源首条真实命令)。插件贡献的命令名与其
402
+ // 合并去重。
403
+ commands: [...new Set([...commandNames, 'compact', 'undo'])],
386
404
  },
387
405
  })
388
406
  }