@tablestore/tablestore-agent-cli 0.2.1 → 0.2.4

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 (342) hide show
  1. package/dist/commands/kb/create.d.ts.map +1 -1
  2. package/dist/commands/kb/create.js +9 -0
  3. package/dist/commands/kb/create.js.map +1 -1
  4. package/dist/commands/kb/retrieve.d.ts.map +1 -1
  5. package/dist/commands/kb/retrieve.js +40 -3
  6. package/dist/commands/kb/retrieve.js.map +1 -1
  7. package/dist/dashboard-runtime/dashboard/.next/BUILD_ID +1 -1
  8. package/dist/dashboard-runtime/dashboard/.next/build-manifest.json +5 -5
  9. package/dist/dashboard-runtime/dashboard/.next/prerender-manifest.json +3 -3
  10. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page/build-manifest.json +2 -2
  11. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
  12. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
  13. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page/build-manifest.json +2 -2
  14. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page.js.nft.json +1 -1
  15. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page_client-reference-manifest.js +1 -1
  16. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page/build-manifest.json +2 -2
  17. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page.js.nft.json +1 -1
  18. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page_client-reference-manifest.js +1 -1
  19. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page/build-manifest.json +2 -2
  20. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page.js.nft.json +1 -1
  21. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page_client-reference-manifest.js +1 -1
  22. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page/build-manifest.json +2 -2
  23. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page.js.nft.json +1 -1
  24. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page_client-reference-manifest.js +1 -1
  25. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page/build-manifest.json +2 -2
  26. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page.js.nft.json +1 -1
  27. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page_client-reference-manifest.js +1 -1
  28. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/create/page/build-manifest.json +2 -2
  29. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/create/page.js.nft.json +1 -1
  30. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/create/page_client-reference-manifest.js +1 -1
  31. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page/build-manifest.json +2 -2
  32. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page.js.nft.json +1 -1
  33. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page_client-reference-manifest.js +1 -1
  34. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/[id]/page/build-manifest.json +2 -2
  35. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/[id]/page.js.nft.json +1 -1
  36. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/[id]/page_client-reference-manifest.js +1 -1
  37. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/new/page/build-manifest.json +2 -2
  38. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/new/page.js.nft.json +1 -1
  39. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/new/page_client-reference-manifest.js +1 -1
  40. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page/build-manifest.json +2 -2
  41. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page.js.nft.json +1 -1
  42. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page_client-reference-manifest.js +1 -1
  43. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page/build-manifest.json +2 -2
  44. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page.js.nft.json +1 -1
  45. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page_client-reference-manifest.js +1 -1
  46. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page/build-manifest.json +2 -2
  47. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page.js.nft.json +1 -1
  48. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page_client-reference-manifest.js +1 -1
  49. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page/build-manifest.json +2 -2
  50. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page.js.nft.json +1 -1
  51. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page_client-reference-manifest.js +1 -1
  52. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page/build-manifest.json +2 -2
  53. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page.js.nft.json +1 -1
  54. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page_client-reference-manifest.js +1 -1
  55. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page/build-manifest.json +2 -2
  56. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page.js.nft.json +1 -1
  57. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page_client-reference-manifest.js +1 -1
  58. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page/build-manifest.json +2 -2
  59. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page.js.nft.json +1 -1
  60. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page_client-reference-manifest.js +1 -1
  61. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/create/page/build-manifest.json +2 -2
  62. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/create/page.js.nft.json +1 -1
  63. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/create/page_client-reference-manifest.js +1 -1
  64. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page/build-manifest.json +2 -2
  65. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page.js.nft.json +1 -1
  66. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page_client-reference-manifest.js +1 -1
  67. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page/build-manifest.json +2 -2
  68. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page.js.nft.json +1 -1
  69. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page_client-reference-manifest.js +1 -1
  70. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error/page/build-manifest.json +2 -2
  71. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.html +1 -1
  72. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.rsc +1 -1
  73. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  74. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  75. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  76. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  77. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  78. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found/page/build-manifest.json +2 -2
  79. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  80. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.html +1 -1
  81. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.rsc +14 -14
  82. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  83. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +3 -3
  84. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
  85. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  86. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  87. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  88. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/auth/status/route.js.nft.json +1 -1
  89. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/auth/token/route.js.nft.json +1 -1
  90. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/[name]/route.js.nft.json +1 -1
  91. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/[name]/token/route.js.nft.json +1 -1
  92. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/[name]/use/route.js.nft.json +1 -1
  93. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/route.js.nft.json +1 -1
  94. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/chunks/route.js.nft.json +1 -1
  95. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/[docId]/chunks/route.js.nft.json +1 -1
  96. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/[docId]/route.js.nft.json +1 -1
  97. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/route.js.nft.json +1 -1
  98. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/upload/route.js.nft.json +1 -1
  99. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/retrieve/route.js.nft.json +1 -1
  100. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/route.js.nft.json +1 -1
  101. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/route.js.nft.json +1 -1
  102. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/chat/route.js.nft.json +1 -1
  103. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/[id]/models/route.js.nft.json +1 -1
  104. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/[id]/route.js.nft.json +1 -1
  105. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/[id]/test/route.js.nft.json +1 -1
  106. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/route.js.nft.json +1 -1
  107. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/logs/client/route.js.nft.json +1 -1
  108. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/messages/route.js.nft.json +1 -1
  109. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/requests/route.js.nft.json +1 -1
  110. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/route.js.nft.json +1 -1
  111. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/search/route.js.nft.json +1 -1
  112. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/units/[memoryId]/route.js.nft.json +1 -1
  113. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/units/route.js.nft.json +1 -1
  114. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/route.js.nft.json +1 -1
  115. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/oss/list/route.js.nft.json +1 -1
  116. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/runtime/context/route.js.nft.json +1 -1
  117. package/dist/dashboard-runtime/dashboard/.next/server/app/index.html +1 -1
  118. package/dist/dashboard-runtime/dashboard/.next/server/app/index.rsc +14 -14
  119. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  120. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_full.segment.rsc +14 -14
  121. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_head.segment.rsc +3 -3
  122. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_index.segment.rsc +10 -10
  123. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  124. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding/page/build-manifest.json +2 -2
  125. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  126. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.html +1 -1
  127. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.rsc +17 -17
  128. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_full.segment.rsc +17 -17
  129. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_head.segment.rsc +3 -3
  130. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_index.segment.rsc +10 -10
  131. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_tree.segment.rsc +2 -2
  132. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +4 -4
  133. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/onboarding.segment.rsc +4 -4
  134. package/dist/dashboard-runtime/dashboard/.next/server/app/page/build-manifest.json +2 -2
  135. package/dist/dashboard-runtime/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
  136. package/dist/dashboard-runtime/dashboard/.next/server/chunks/0p91_next_dist_esm_build_templates_app-route_0n~ec7s.js +9 -6
  137. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__02p1x3t._.js +1 -1
  138. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0fglxiw._.js +1 -1
  139. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0lvi0g-._.js +2 -2
  140. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0q8vcw8._.js +1 -1
  141. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/0b1r_app_(dashboard)_knowledge-base_[name]_documents_documents-client_tsx_0g2uxmt._.js +2 -2
  142. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/0e95_src_app_(dashboard)_knowledge-base_[name]_settings_settings-client_tsx_13312zk._.js +1 -1
  143. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__08faq-z._.js +3 -0
  144. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0c94d.y._.js +3 -0
  145. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0jb9ccl._.js +1 -1
  146. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{[root-of-the-server]__13ylf4x._.js → [root-of-the-server]__0lgg04c._.js} +2 -2
  147. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__10rkv6z._.js +1 -1
  148. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_01-2v37._.js +1 -1
  149. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_01ag-vl._.js +3 -0
  150. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_09yzbcp._.js +1 -1
  151. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0atzifq._.js +3 -0
  152. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0f4u0.1._.js +1 -1
  153. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0gbt~hy._.js +1 -1
  154. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0gl7kh7._.js +3 -0
  155. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0j-q~ro._.js +1 -1
  156. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0jghj2_._.js +1 -1
  157. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0jlyg05._.js +3 -0
  158. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0n4gd_6._.js +1 -1
  159. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_0l~-9i0._.js → _0tdjkbc._.js} +2 -2
  160. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0tej2s.._.js +1 -1
  161. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_10u~-xc._.js +3 -0
  162. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_12r9c8h._.js +1 -1
  163. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0.glq39._.js +3 -0
  164. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_00ofp7q._.js +1 -1
  165. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_05.qn9h._.js +3 -0
  166. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_065m1.j._.js +1 -1
  167. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0xf3ffa._.js +1 -1
  168. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0y49vhd._.js +1 -1
  169. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_10dsqx~._.js +1 -1
  170. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_knowledge-base_create_page_tsx_0916~g-._.js +1 -1
  171. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_settings_page_tsx_0y26.xu._.js +1 -1
  172. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_units_page_tsx_0.6xnei._.js +1 -1
  173. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_components_0ls1exu._.js +1 -1
  174. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_components_0ugdjlb._.js +1 -1
  175. package/dist/dashboard-runtime/dashboard/.next/server/middleware-build-manifest.js +5 -5
  176. package/dist/dashboard-runtime/dashboard/.next/server/pages/404.html +1 -1
  177. package/dist/dashboard-runtime/dashboard/.next/server/pages/500.html +1 -1
  178. package/dist/dashboard-runtime/dashboard/.next/server/server-reference-manifest.js +1 -1
  179. package/dist/dashboard-runtime/dashboard/.next/server/server-reference-manifest.json +1 -1
  180. package/dist/dashboard-runtime/dashboard/.next/static/chunks/00wmf85833643.js +1 -0
  181. package/dist/dashboard-runtime/dashboard/.next/static/chunks/02tj1_rhgobzv.js +1 -0
  182. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0mea2ylxe.umh.js → 02zf3qddfaw~u.js} +1 -1
  183. package/dist/dashboard-runtime/dashboard/.next/static/chunks/039i70t10axdd.css +1 -0
  184. package/dist/dashboard-runtime/dashboard/.next/static/chunks/04bfame9rk.3d.js +5 -0
  185. package/dist/dashboard-runtime/dashboard/.next/static/chunks/07rwb_uq9qcx4.js +1 -0
  186. package/dist/dashboard-runtime/dashboard/.next/static/chunks/07ygw8215kyvc.js +1 -0
  187. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0b5hr027rat4w.js +138 -0
  188. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0__g1ogrdh412.js → 0bkm-5yza5~d2.js} +1 -1
  189. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0lrw.bnws62y9.js → 0d7d.b.v9noym.js} +1 -1
  190. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0cto67_iw~p9z.js → 0fdofp-3kkc4g.js} +1 -1
  191. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0i8hdbek9j-fu.js +1 -0
  192. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0ioivx4pbmayb.js +1 -0
  193. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0j-v5f_oscvfu.js +1 -0
  194. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0lp2g_27uyhuz.js → 0je7fmsrz2vok.js} +1 -1
  195. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0jukioxtp1mn3.js +138 -0
  196. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0klidr2i6cd.g.js +1 -0
  197. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0k~bkh1586r2i.js +1 -0
  198. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0nakvv2p1kjnf.js +1 -0
  199. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0t5vdnq4s.2yv.js +1 -0
  200. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0un~rqes29pcr.js +1 -0
  201. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0v.u57bsjppd_.js +1 -0
  202. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0fagnytrt.3oe.js → 0veza1g0elxa7.js} +1 -1
  203. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0x3w~yxvm1xsq.js +4 -0
  204. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0x5gol39unrgb.js +1 -0
  205. package/dist/dashboard-runtime/dashboard/.next/static/chunks/12s59v_sk0q-z.js +1 -0
  206. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{06uuhz24tvdt..js → 14~eqof4660i3.js} +1 -1
  207. package/dist/dashboard-runtime/dashboard/.next/static/chunks/16y3764x-fh1n.js +1 -0
  208. package/dist/dashboard-runtime/dashboard/.next/static/chunks/17mcnyr~1j7ih.js +1 -0
  209. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{turbopack-0w.hw6u8qra5z.js → turbopack-0~gu0g2v-1f11.js} +1 -1
  210. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/chat/page.tsx +5 -0
  211. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/knowledge-base/[name]/documents/documents-client.tsx +4 -1
  212. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/knowledge-base/[name]/layout-client.tsx +62 -26
  213. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/messages/page.tsx +8 -4
  214. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/requests/page.tsx +6 -2
  215. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/requests/request-detail-dialog.tsx +9 -9
  216. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/requests/requests-table.tsx +2 -2
  217. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/search/page.tsx +5 -1
  218. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/settings/page.tsx +56 -17
  219. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/units/page.tsx +11 -7
  220. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/create/page.tsx +1 -1
  221. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/page.tsx +1 -1
  222. package/dist/dashboard-runtime/dashboard/src/app/api/v1/knowledge-bases/[name]/documents/[docId]/route.ts +67 -0
  223. package/dist/dashboard-runtime/dashboard/src/app/api/v1/llm/chat/memory-helpers.ts +45 -0
  224. package/dist/dashboard-runtime/dashboard/src/app/api/v1/llm/chat/route.ts +334 -16
  225. package/dist/dashboard-runtime/dashboard/src/app/api/v1/logs/client/route.ts +13 -0
  226. package/dist/dashboard-runtime/dashboard/src/app/api/v1/oss/list/route.ts +1 -0
  227. package/dist/dashboard-runtime/dashboard/src/app/globals.css +23 -0
  228. package/dist/dashboard-runtime/dashboard/src/components/chat/chat-config-context.tsx +116 -19
  229. package/dist/dashboard-runtime/dashboard/src/components/chat/chat-mount-config.tsx +5 -0
  230. package/dist/dashboard-runtime/dashboard/src/components/chat/memory-bind-section.tsx +372 -0
  231. package/dist/dashboard-runtime/dashboard/src/components/chat/mount-retrieval-dialog.tsx +360 -0
  232. package/dist/dashboard-runtime/dashboard/src/components/chat/mount-row.tsx +49 -5
  233. package/dist/dashboard-runtime/dashboard/src/components/chat/unified-retrieval-section.tsx +61 -26
  234. package/dist/dashboard-runtime/dashboard/src/components/documents/doc-chunks-dialog.tsx +72 -20
  235. package/dist/dashboard-runtime/dashboard/src/components/documents/doc-detail-panel.tsx +578 -76
  236. package/dist/dashboard-runtime/dashboard/src/components/documents/doc-upload-dialog.tsx +9 -81
  237. package/dist/dashboard-runtime/dashboard/src/components/documents/oss-browser.tsx +42 -26
  238. package/dist/dashboard-runtime/dashboard/src/components/instance/connect-instance-form.tsx +5 -0
  239. package/dist/dashboard-runtime/dashboard/src/components/knowledge-base/embedding-config-form.tsx +16 -2
  240. package/dist/dashboard-runtime/dashboard/src/components/knowledge-base/kb-card.tsx +37 -24
  241. package/dist/dashboard-runtime/dashboard/src/components/knowledge-base/kb-create-form.tsx +173 -86
  242. package/dist/dashboard-runtime/dashboard/src/components/knowledge-base/kb-settings-form.tsx +319 -280
  243. package/dist/dashboard-runtime/dashboard/src/components/layout/detail-sidebar.tsx +47 -18
  244. package/dist/dashboard-runtime/dashboard/src/components/layout/sidebar-instance-card.tsx +2 -2
  245. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-add-dialog.tsx +2 -2
  246. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-create-form.tsx +84 -56
  247. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-edit-dialog.tsx +2 -2
  248. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-messages-table.tsx +3 -3
  249. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-requests-table.tsx +12 -12
  250. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-scope-bar.tsx +20 -11
  251. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-search-form.tsx +7 -7
  252. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-search-results.tsx +6 -6
  253. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-settings-form.tsx +90 -21
  254. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-store-card.tsx +1 -1
  255. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-store-list.tsx +1 -1
  256. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-unit-detail-panel.tsx +4 -4
  257. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-unit-table.tsx +2 -2
  258. package/dist/dashboard-runtime/dashboard/src/components/qa/qa-message.tsx +216 -5
  259. package/dist/dashboard-runtime/dashboard/src/components/retrieval/retrieval-form.tsx +241 -24
  260. package/dist/dashboard-runtime/dashboard/src/components/retrieval/retrieval-rerank-fields.tsx +1 -0
  261. package/dist/dashboard-runtime/dashboard/src/components/retrieval/retrieval-result-card.tsx +52 -4
  262. package/dist/dashboard-runtime/dashboard/src/components/shared/metadata-field-input.tsx +54 -0
  263. package/dist/dashboard-runtime/dashboard/src/components/shared/status-badge.tsx +10 -5
  264. package/dist/dashboard-runtime/dashboard/src/components/ui/nav-tab-bar.tsx +1 -1
  265. package/dist/dashboard-runtime/dashboard/src/hooks/use-chat-history.ts +60 -5
  266. package/dist/dashboard-runtime/dashboard/src/hooks/use-document.ts +29 -0
  267. package/dist/dashboard-runtime/dashboard/src/hooks/use-oss-list.ts +7 -5
  268. package/dist/dashboard-runtime/dashboard/src/hooks/use-qa-chat.ts +65 -11
  269. package/dist/dashboard-runtime/dashboard/src/hooks/use-update-document.ts +15 -0
  270. package/dist/dashboard-runtime/dashboard/src/lib/api-error-toast.ts +62 -0
  271. package/dist/dashboard-runtime/dashboard/src/lib/constants.ts +8 -0
  272. package/dist/dashboard-runtime/dashboard/src/lib/metadata-form.ts +88 -0
  273. package/dist/dashboard-runtime/dashboard/src/lib/query-keys.ts +14 -0
  274. package/dist/dashboard-runtime/dashboard/src/lib/server/api-helpers.ts +18 -5
  275. package/dist/dashboard-runtime/dashboard/src/lib/server/llm-client.ts +19 -1
  276. package/dist/dashboard-runtime/dashboard/src/lib/server/oss-client.ts +45 -16
  277. package/dist/dashboard-runtime/dashboard/src/schemas/knowledge-base.ts +6 -0
  278. package/dist/dashboard-runtime/dashboard/src/schemas/llm-chat.ts +20 -0
  279. package/dist/dashboard-runtime/dashboard/src/schemas/retrieval.ts +46 -27
  280. package/dist/dashboard-runtime/dashboard/src/services/api-client.ts +31 -2
  281. package/dist/dashboard-runtime/dashboard/src/services/documents.ts +36 -3
  282. package/dist/dashboard-runtime/dashboard/src/types/knowledge-base.ts +10 -0
  283. package/dist/dashboard-runtime/dashboard/src/types/llm-chat.ts +33 -0
  284. package/dist/dashboard-runtime/dashboard/src/types/retrieval.ts +9 -4
  285. package/dist/dashboard-runtime/dashboard/tailwind.config.ts +4 -0
  286. package/dist/dashboard-runtime/dashboard/vitest.config.mjs +5 -2
  287. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.d.ts +1 -0
  288. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.d.ts.map +1 -1
  289. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.js +4 -0
  290. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.js.map +1 -1
  291. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-sdk/dist/tsconfig.tsbuildinfo +1 -1
  292. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-shared/dist/logging.js +1 -1
  293. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-shared/dist/tsconfig.tsbuildinfo +1 -1
  294. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-shared/dist/types.d.ts +21 -5
  295. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-shared/dist/types.d.ts.map +1 -1
  296. package/dist/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.d.ts +1 -0
  297. package/dist/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.d.ts.map +1 -1
  298. package/dist/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.js +4 -0
  299. package/dist/node_modules/@tablestore/tablestore-agent-sdk/dist/kb-client.js.map +1 -1
  300. package/dist/node_modules/@tablestore/tablestore-agent-sdk/dist/tsconfig.tsbuildinfo +1 -1
  301. package/dist/node_modules/@tablestore/tablestore-agent-shared/dist/logging.js +1 -1
  302. package/dist/node_modules/@tablestore/tablestore-agent-shared/dist/tsconfig.tsbuildinfo +1 -1
  303. package/dist/node_modules/@tablestore/tablestore-agent-shared/dist/types.d.ts +21 -5
  304. package/dist/node_modules/@tablestore/tablestore-agent-shared/dist/types.d.ts.map +1 -1
  305. package/dist/utils/read-image-input.d.ts +47 -0
  306. package/dist/utils/read-image-input.d.ts.map +1 -0
  307. package/dist/utils/read-image-input.js +89 -0
  308. package/dist/utils/read-image-input.js.map +1 -0
  309. package/package.json +2 -2
  310. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0aqzu8w._.js +0 -3
  311. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0hozzu6._.js +0 -3
  312. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0kd7szs._.js +0 -3
  313. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0tr8-3u._.js +0 -3
  314. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0xzh5yw._.js +0 -3
  315. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_12~3vfk._.js +0 -3
  316. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_13_lb.o._.js +0 -3
  317. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0ejgygh._.js +0 -3
  318. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_components_ui_0-tuf-h._.js +0 -3
  319. package/dist/dashboard-runtime/dashboard/.next/static/chunks/00tz~p479bdgl.js +0 -1
  320. package/dist/dashboard-runtime/dashboard/.next/static/chunks/02i9olo-312mq.js +0 -138
  321. package/dist/dashboard-runtime/dashboard/.next/static/chunks/062k9jbtd9.lv.js +0 -1
  322. package/dist/dashboard-runtime/dashboard/.next/static/chunks/069zf4m5f.se2.js +0 -1
  323. package/dist/dashboard-runtime/dashboard/.next/static/chunks/07cp19da_kfld.js +0 -5
  324. package/dist/dashboard-runtime/dashboard/.next/static/chunks/086esp1n941jl.js +0 -138
  325. package/dist/dashboard-runtime/dashboard/.next/static/chunks/09uxq~55qug8c.js +0 -1
  326. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0d29.l~3ip181.js +0 -1
  327. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0ewpzgu_qf0wf.js +0 -4
  328. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0jc31diex030o.js +0 -1
  329. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0k79upjc40aky.css +0 -1
  330. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0snnsfosp3~gq.js +0 -1
  331. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0t0yqi68~eil6.js +0 -1
  332. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0th7u6qvdy3x2.js +0 -1
  333. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0tmwptel_4y0o.js +0 -1
  334. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0u6_s-0w8.yr..js +0 -1
  335. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0u9wtl06_b72x.js +0 -1
  336. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0v9d5wl9nsva3.js +0 -1
  337. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0~kfzxrhgbkaz.js +0 -1
  338. package/dist/dashboard-runtime/dashboard/.next/static/chunks/14.dp0-y_mhjo.js +0 -1
  339. package/dist/dashboard-runtime/dashboard/.next/static/chunks/15bzqpm440jvz.js +0 -1
  340. /package/dist/dashboard-runtime/dashboard/.next/static/{doYIl-pd6Sqax3bfUgN3q → EIbKHHti0Z1ephKfJzCKH}/_buildManifest.js +0 -0
  341. /package/dist/dashboard-runtime/dashboard/.next/static/{doYIl-pd6Sqax3bfUgN3q → EIbKHHti0Z1ephKfJzCKH}/_clientMiddlewareManifest.js +0 -0
  342. /package/dist/dashboard-runtime/dashboard/.next/static/{doYIl-pd6Sqax3bfUgN3q → EIbKHHti0Z1ephKfJzCKH}/_ssgManifest.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { type NextRequest } from "next/server";
2
2
 
3
- import { chatCompletionStream } from "@/lib/server/llm-client";
3
+ import { chatCompletionStream, type LLMMessageContent, type ContentPart } from "@/lib/server/llm-client";
4
4
  import { getProviderWithSecret } from "@/lib/server/llm-provider-store";
5
5
  import { rewriteQuery } from "@/lib/server/query-rewriter";
6
6
  import {
@@ -19,7 +19,13 @@ import type {
19
19
  RetrievedChunk,
20
20
  RetrievalGroup,
21
21
  } from "@/types/llm-chat";
22
+ import type { MemorySearchHit } from "@/types/memory";
22
23
  import type { RetrievalResult } from "@/types/retrieval";
24
+ import {
25
+ deriveReadScope,
26
+ formatMemoryBlock,
27
+ type MemoryWriteScope,
28
+ } from "./memory-helpers";
23
29
 
24
30
  // Default aggregate cap when the client omits `rag.topK`.
25
31
  const DEFAULT_AGGREGATE_TOP_K = 20;
@@ -29,15 +35,80 @@ const DEFAULT_AGGREGATE_TOP_K = 20;
29
35
  export const runtime = "nodejs";
30
36
  export const dynamic = "force-dynamic";
31
37
 
32
- const DEFAULT_RAG_SYSTEM_PROMPT =
33
- "你是一个基于知识库检索结果回答问题的助手。请严格参考下面的「检索结果」回答用户问题;若检索结果未涵盖相关信息,请如实说明未在知识库中找到,不要编造。回答时可以在末尾用 `[1]` `[2]` 等编号标注引用来源。";
38
+ /**
39
+ * 默认 system preamble。仅在调用方没有自填 `systemPrompt` 时兜底。
40
+ *
41
+ * 之前是一段固定的「你是 RAG 助手」字符串,问题在于:
42
+ * 1. memory 在场时,prompt 里不会告诉模型「相关历史记忆」是什么、要怎么用;
43
+ * 2. 「若检索结果未涵盖请说明未在知识库中找到」这一句会把视野收敛到 KB,
44
+ * 哪怕记忆段已注入,模型也容易因为「不在 KB」=「无法回答」而忽略记忆。
45
+ *
46
+ * 现在按本轮请求实际拼出来的上下文段落(chunks / memoryBlock)动态分支,
47
+ * 让模型清楚地知道这次有哪些信源、各自该如何使用。
48
+ */
49
+ function buildDefaultPreamble(opts: {
50
+ hasRag: boolean;
51
+ hasMemory: boolean;
52
+ }): string {
53
+ const parts: string[] = [
54
+ "你是一个智能助手,请基于下方提供的上下文(如有)回答用户的问题。",
55
+ ];
56
+ if (opts.hasRag) {
57
+ parts.push(
58
+ "下方会给出从知识库检索出的「检索结果」,请优先参考其中内容回答;" +
59
+ "若检索结果未涵盖相关信息,请如实说明知识库中未找到,不要编造。" +
60
+ "引用时可在末尾用 `[1]` `[2]` 等编号标注来源。",
61
+ );
62
+ }
63
+ if (opts.hasMemory) {
64
+ parts.push(
65
+ "下方还会给出「相关历史记忆」,记录了你与该用户/场景过往的对话沉淀。" +
66
+ "请将这些记忆作为已知的用户偏好或上下文自然融入回答;" +
67
+ "无需显式引用编号,也不要因为某条记忆未涉及就拒绝回答。",
68
+ );
69
+ }
70
+ return parts.join("\n\n");
71
+ }
34
72
 
35
73
  // Maximum number of history messages (excluding system) forwarded to the LLM.
36
74
  // Matches the plan's simple "keep last 20 turns" policy; token-based trimming
37
75
  // can land later when we wire up `tiktoken`.
38
76
  const MAX_HISTORY_MESSAGES = 20;
77
+ /**
78
+ * 单个检索 chunk 拼入 system message 时的最大显示字符数。
79
+ * 用于控制 system 提示总长度,避免单个超长 chunk 把模型上下文挤爆。
80
+ */
81
+ const MAX_CHUNK_DISPLAY_LENGTH = 1200;
39
82
  const chatLogger = createLogger("dashboard.api.llm");
40
83
 
84
+ /**
85
+ * 判断一个检索 chunk 是否为图片类型。
86
+ *
87
+ * 服务端契约下 chunkType 共 4 种取值:text | table | formula | image。
88
+ * 大小写不敏感地比较,以兼容后端契约可能出现的大小写漂移。除 image 外的
89
+ * 3 种类型都按文本走 contextBlock 拼接,不进入多模态 image_url 部分。
90
+ */
91
+ function isImageChunk(chunk: { chunkType?: string }): boolean {
92
+ return chunk.chunkType?.toUpperCase() === "IMAGE";
93
+ }
94
+
95
+ // turnId 去重:客户端每个「逻辑轮次」生成一次 turnId(regenerate / edit-resend
96
+ // 复用同一个值)。我们仅在内存里维护一个 ~10 分钟过期的 set;不要求扛过进程重启。
97
+ const TURN_DEDUP_TTL_MS = 10 * 60 * 1000;
98
+ const seenTurnIds = new Map<string, number>();
99
+
100
+ function shouldSkipDuplicateTurn(turnId: string | undefined): boolean {
101
+ if (!turnId) return false;
102
+ const now = Date.now();
103
+ // 顺手清理过期键,避免无限增长。
104
+ for (const [key, expiry] of seenTurnIds) {
105
+ if (expiry <= now) seenTurnIds.delete(key);
106
+ }
107
+ if (seenTurnIds.has(turnId)) return true;
108
+ seenTurnIds.set(turnId, now + TURN_DEDUP_TTL_MS);
109
+ return false;
110
+ }
111
+
41
112
  /**
42
113
  * POST /api/v1/llm/chat
43
114
  *
@@ -118,6 +189,26 @@ export async function POST(request: NextRequest) {
118
189
  }
119
190
  }
120
191
 
192
+ type ResolvedMemoryClient = Awaited<ReturnType<typeof resolveMemoryClient>>;
193
+ let memoryClient: ResolvedMemoryClient | null = null;
194
+ if (body.memory) {
195
+ // memory 与 rag 都依赖同一份 Tablestore 凭据;如果 RAG 已经做过 project
196
+ // 上下文校验,这里就不再重复(同一个请求共享一份 cookie)。
197
+ if (!body.rag) {
198
+ const projectContext = validateChatProjectContext(
199
+ request,
200
+ activeInstanceProvided ? body.activeInstance ?? null : undefined,
201
+ );
202
+ if (!projectContext.ok) {
203
+ return jsonError(409, "PROJECT_CONTEXT_CHANGED", projectContext.message);
204
+ }
205
+ }
206
+ memoryClient = await resolveMemoryClient(request);
207
+ if (!memoryClient.ok) {
208
+ return jsonError(memoryClient.status, memoryClient.code, memoryClient.message);
209
+ }
210
+ }
211
+
121
212
  const upstreamAbort = new AbortController();
122
213
  const cleanup = () => {
123
214
  try {
@@ -155,6 +246,7 @@ export async function POST(request: NextRequest) {
155
246
  // ---- RAG retrieval ----
156
247
  let chunks: RetrievedChunk[] = [];
157
248
  let groupsForPrompt: RetrievalGroup[] = [];
249
+ let queryForMemory = lastUser.content;
158
250
  if (body.rag && kbClient?.ok) {
159
251
  // Decide retrieval query: on multi-turn (>=2 non-system messages),
160
252
  // condense the history into a standalone question; otherwise keep
@@ -196,6 +288,7 @@ export async function POST(request: NextRequest) {
196
288
  query: retrievalQuery,
197
289
  original: lastUser.content,
198
290
  });
291
+ queryForMemory = retrievalQuery;
199
292
  void rewritten;
200
293
 
201
294
  emit({ type: "retrieval.start" });
@@ -214,11 +307,50 @@ export async function POST(request: NextRequest) {
214
307
  });
215
308
  }
216
309
 
310
+ // ---- Memory 检索 ----
311
+ let memoryHits: MemorySearchHit[] = [];
312
+ if (body.memory && memoryClient?.ok) {
313
+ // 仅当 RAG 实际命中(chunks 非空)时才复用其 rewrite 后的 query;否则回退到原始用户输入,
314
+ // 避免在无召回时把 rewriter 的猜测当成记忆检索的输入。
315
+ const memoryQuery = chunks.length > 0 ? queryForMemory : lastUser.content;
316
+ emit({ type: "memory.start", query: memoryQuery });
317
+ const readScope = deriveReadScope(body.memory.scope as MemoryWriteScope);
318
+ try {
319
+ const resp = await memoryClient.client.searchMemories({
320
+ memoryStoreName: body.memory.memoryStoreName,
321
+ scope: readScope,
322
+ query: memoryQuery,
323
+ topK: body.memory.topK ?? 5,
324
+ });
325
+ if (resp.code === "SUCCESS") {
326
+ // SDK 真实字段名是 `results`(见 @tablestore/agent-storage 的
327
+ // SearchMemoriesResponse 类型);早期版本误读成 `hits` 会让
328
+ // memoryHits 永远为空,导致召回的记忆无法注入 system prompt。
329
+ const data = resp.data as { results?: MemorySearchHit[] } | undefined;
330
+ memoryHits = data?.results ?? [];
331
+ } else {
332
+ chatLogger.warn({
333
+ event: "api.memory.search_failed",
334
+ message: resp.message ?? "searchMemories returned non-SUCCESS",
335
+ details: { code: resp.code },
336
+ });
337
+ }
338
+ } catch (err) {
339
+ chatLogger.warn({
340
+ event: "api.memory.search_exception",
341
+ message: err instanceof Error ? err.message : String(err),
342
+ error: err,
343
+ });
344
+ }
345
+ emit({ type: "memory.done", hits: memoryHits });
346
+ }
347
+
217
348
  // ---- Build final messages ----
218
349
  const finalMessages = buildFinalMessages(
219
350
  body.systemPrompt ?? "",
220
351
  chunks,
221
352
  groupsForPrompt,
353
+ formatMemoryBlock(memoryHits),
222
354
  body.messages,
223
355
  );
224
356
 
@@ -231,14 +363,74 @@ export async function POST(request: NextRequest) {
231
363
  });
232
364
 
233
365
  const reader = upstream.getReader();
366
+ let assistantContent = "";
234
367
  while (true) {
235
368
  const { value, done } = await reader.read();
236
369
  if (done) break;
370
+ if (value.type === "content.delta") {
371
+ assistantContent += value.delta;
372
+ }
237
373
  emit(value);
238
374
  if (value.type === "done" || value.type === "error") {
239
375
  break;
240
376
  }
241
377
  }
378
+ // ---- Fire-and-forget 写回 ----
379
+ // 必须放在 close() 之前 schedule,但执行可以晚于 close():
380
+ // 我们用一个不 await 的 IIFE 让它脱离 SSE controller 的生命周期。
381
+ if (
382
+ body.memory &&
383
+ memoryClient?.ok &&
384
+ body.memory.autoSave !== false &&
385
+ assistantContent.length > 0 &&
386
+ !shouldSkipDuplicateTurn(body.memory.turnId)
387
+ ) {
388
+ const writeScope = body.memory.scope as MemoryWriteScope;
389
+ const storeName = body.memory.memoryStoreName;
390
+ const userText = lastUser.content;
391
+ const assistantText = assistantContent;
392
+ const client = memoryClient.client;
393
+ // 不 await:如果写回早于 close() 完成,就把 skip 原因 emit 回前端;
394
+ // 否则只走 chatLogger.warn 落盘 —— 因为此时 SSE 流已结束。
395
+ (async () => {
396
+ try {
397
+ const resp = await client.addMemories({
398
+ memoryStoreName: storeName,
399
+ scope: writeScope,
400
+ messages: [
401
+ { role: "user", content: userText },
402
+ { role: "assistant", content: assistantText },
403
+ ],
404
+ sync: false,
405
+ });
406
+ if (resp.code !== "SUCCESS") {
407
+ if (!closed) {
408
+ emit({
409
+ type: "memory.save.skipped",
410
+ reason: resp.message ?? `addMemories returned ${resp.code}`,
411
+ });
412
+ }
413
+ chatLogger.warn({
414
+ event: "api.memory.save_failed",
415
+ message: resp.message ?? "addMemories returned non-SUCCESS",
416
+ details: { code: resp.code },
417
+ });
418
+ }
419
+ } catch (err) {
420
+ if (!closed) {
421
+ emit({
422
+ type: "memory.save.skipped",
423
+ reason: err instanceof Error ? err.message : String(err),
424
+ });
425
+ }
426
+ chatLogger.warn({
427
+ event: "api.memory.save_exception",
428
+ message: err instanceof Error ? err.message : String(err),
429
+ error: err,
430
+ });
431
+ }
432
+ })();
433
+ }
242
434
  chatLogger.info({
243
435
  event: "api.stream_response",
244
436
  message: "LLM chat stream completed",
@@ -250,6 +442,7 @@ export async function POST(request: NextRequest) {
250
442
  status: 200,
251
443
  code: "SUCCESS",
252
444
  ragEnabled: Boolean(body.rag),
445
+ memoryEnabled: Boolean(body.memory),
253
446
  },
254
447
  });
255
448
  close();
@@ -265,6 +458,7 @@ export async function POST(request: NextRequest) {
265
458
  path: logContext?.path,
266
459
  code: "INTERNAL_SERVER_ERROR",
267
460
  ragEnabled: Boolean(body.rag),
461
+ memoryEnabled: Boolean(body.memory),
268
462
  },
269
463
  });
270
464
  emit({
@@ -325,6 +519,29 @@ async function resolveKbClient(request: NextRequest): Promise<
325
519
  return { ok: true, client: resolved.kb };
326
520
  }
327
521
 
522
+ /**
523
+ * Mirror of {@link resolveKbClient} but yielding the MemoryClient.
524
+ * Memory + RAG share the same Tablestore credential layer, so unwrap any
525
+ * NextResponse from `requireClients` the same way and surface a structured
526
+ * error descriptor instead of returning the Response directly.
527
+ */
528
+ async function resolveMemoryClient(request: NextRequest): Promise<
529
+ | { ok: true; client: import("@tablestore/tablestore-agent-sdk").MemoryClient }
530
+ | { ok: false; status: number; code: string; message: string }
531
+ > {
532
+ const resolved = requireClients(request);
533
+ if (resolved instanceof Response) {
534
+ const body = await resolved.json().catch(() => null);
535
+ return {
536
+ ok: false,
537
+ status: resolved.status,
538
+ code: body?.code ?? "UNAUTHORIZED",
539
+ message: body?.message ?? "Failed to resolve credentials",
540
+ };
541
+ }
542
+ return { ok: true, client: resolved.memory };
543
+ }
544
+
328
545
  /**
329
546
  * Compose the system prompt and cap the history window. The retrieval chunks
330
547
  * are appended *after* the user-supplied prompt so user instructions take
@@ -332,37 +549,138 @@ async function resolveKbClient(request: NextRequest): Promise<
332
549
  * cite back. The header mentions the KB count when multiple KBs were queried
333
550
  * so the model can reason about source diversity.
334
551
  */
335
- function buildFinalMessages(
552
+ /** @internal Exported for unit testing multimodal message construction. */
553
+ export function buildFinalMessages(
336
554
  userSystemPrompt: string,
337
555
  chunks: RetrievedChunk[],
338
556
  groups: RetrievalGroup[],
557
+ memoryBlock: string,
339
558
  history: Array<{ role: ChatRole; content: string }>,
340
- ): Array<{ role: ChatRole; content: string }> {
341
- const preamble = userSystemPrompt.trim() || DEFAULT_RAG_SYSTEM_PROMPT;
559
+ ): Array<{ role: ChatRole; content: LLMMessageContent }> {
560
+ const preamble =
561
+ userSystemPrompt.trim() ||
562
+ buildDefaultPreamble({
563
+ hasRag: chunks.length > 0,
564
+ hasMemory: memoryBlock.length > 0,
565
+ });
342
566
  const successfulKbCount = groups.filter((g) => !g.error).length;
343
567
  const header = successfulKbCount > 1
344
568
  ? `检索结果(共 ${chunks.length} 条,来自 ${successfulKbCount} 个知识库):`
345
569
  : `检索结果(共 ${chunks.length} 条):`;
570
+
571
+ // Strip any `system` messages the client sent — we own the system turn.
572
+ const nonSystem = history.filter((m) => m.role !== "system");
573
+ const clipped =
574
+ nonSystem.length > MAX_HISTORY_MESSAGES
575
+ ? nonSystem.slice(-MAX_HISTORY_MESSAGES)
576
+ : nonSystem;
577
+
578
+ // Collect image parts with numbered labels to preserve chunk order.
579
+ //
580
+ // ChunkType 服务端契约共 4 种:text | table | formula | image。
581
+ // 这 4 种里只有 image 需要走 `image_url` 部分注入到 user message;其他全部
582
+ // 作为文本,由下面的 `contextBlock` 直接以 chunk.content 形式拼进 system
583
+ // message。这里大小写不敏感地匹配 IMAGE,使后端 chunkType 字段大小写漂移
584
+ // 不会破坏多模态注入。
585
+ const imageParts: ContentPart[] = [];
586
+ chunks.forEach((c, i) => {
587
+ if (isImageChunk(c) && c.imageBase64) {
588
+ // Add numbered label so the model can correlate with system message [N].
589
+ // 编号 `i + 1` 与下方 contextBlock 中的 `[N]` 保持同源,确保模型能把
590
+ // 「检索图片 2」对应到 system 提示里的 `[2]` 引用。
591
+ imageParts.push({
592
+ type: "text",
593
+ text: `[检索图片 ${i + 1}]:`,
594
+ });
595
+ imageParts.push({
596
+ type: "image_url",
597
+ image_url: { url: c.imageBase64 },
598
+ });
599
+ }
600
+ });
601
+
602
+ // System message is always a plain string (works with all providers).
603
+ // Chunks 在 system 中按检索返回顺序展开,并保持与 imageParts 同一编号系统。
346
604
  const contextBlock = chunks.length
347
605
  ? `\n\n${header}\n${chunks
348
606
  .map((c, i) => {
349
607
  const src = c.knowledgeBaseName ? ` (${c.knowledgeBaseName})` : "";
350
- return `[${i + 1}]${src} ${truncate(c.content, 1200)}`;
608
+ // 仅在 IMAGE 且没有 caption/content 时用 "(图片)" 占位;其余 chunk
609
+ // 类型(text / table / formula)一律直接展开 content。
610
+ const body = truncate(
611
+ c.content || (isImageChunk(c) ? "(图片)" : ""),
612
+ MAX_CHUNK_DISPLAY_LENGTH,
613
+ );
614
+ return `[${i + 1}]${src} ${body}`;
351
615
  })
352
616
  .join("\n\n")}`
353
617
  : "";
354
618
 
355
- // Strip any `system` messages the client sent — we own the system turn.
356
- const nonSystem = history.filter((m) => m.role !== "system");
357
- const clipped =
358
- nonSystem.length > MAX_HISTORY_MESSAGES
359
- ? nonSystem.slice(-MAX_HISTORY_MESSAGES)
360
- : nonSystem;
619
+ const systemMessage = {
620
+ role: "system" as const,
621
+ content: preamble + contextBlock + memoryBlock,
622
+ };
361
623
 
362
- return [
363
- { role: "system", content: preamble + contextBlock },
364
- ...clipped,
624
+ // If no images, return plain text messages (backward compatible)
625
+ if (imageParts.length === 0) {
626
+ return [systemMessage, ...clipped];
627
+ }
628
+
629
+ // Enrich the last user message with image parts
630
+ const messages: Array<{ role: ChatRole; content: LLMMessageContent }> = [
631
+ systemMessage,
365
632
  ];
633
+
634
+ const imageFallbackMessage = {
635
+ role: "user" as const,
636
+ content: [
637
+ ...imageParts,
638
+ { type: "text" as const, text: "请根据以上图片回答。" },
639
+ ],
640
+ };
641
+
642
+ if (clipped.length > 0) {
643
+ const lastIndex = clipped.length - 1;
644
+ const lastMessage = clipped[lastIndex];
645
+
646
+ if (lastMessage.role === "user") {
647
+ // Replace last user message with multimodal version
648
+ messages.push(
649
+ ...clipped.slice(0, lastIndex),
650
+ {
651
+ role: "user",
652
+ content: [
653
+ ...imageParts,
654
+ { type: "text", text: lastMessage.content },
655
+ ],
656
+ }
657
+ );
658
+ } else {
659
+ // Last message isn't a plain-text user message (e.g. assistant) — append
660
+ // a synthetic user turn carrying the images. This path is rare in
661
+ // production (clients normally end on a user turn) but can happen if the
662
+ // upstream injected a trailing assistant message or replayed history.
663
+ // Log a warning so we can spot it in observability rather than silently
664
+ // produce a "user said: 请根据以上图片回答。" turn the user never typed.
665
+ chatLogger.warn({
666
+ event: "api.chat.multimodal_fallback_user_turn",
667
+ message:
668
+ "last history message is not a user turn; appending synthetic " +
669
+ "user message to carry retrieved images",
670
+ details: {
671
+ lastRole: lastMessage.role,
672
+ imageCount: imageParts.length / 2,
673
+ historyLength: clipped.length,
674
+ },
675
+ });
676
+ messages.push(...clipped, imageFallbackMessage);
677
+ }
678
+ } else {
679
+ // No history — create a user message with images
680
+ messages.push(imageFallbackMessage);
681
+ }
682
+
683
+ return messages;
366
684
  }
367
685
 
368
686
  function truncate(text: string, max: number): string {
@@ -47,6 +47,15 @@ export async function POST(request: NextRequest) {
47
47
  typeof body.message === "string" ? body.message : "Browser error captured";
48
48
  const level = body.level === "warn" || body.level === "info" ? body.level : "error";
49
49
 
50
+ const code = typeof body.code === "string" ? body.code : undefined;
51
+ const status = typeof body.status === "number" ? body.status : undefined;
52
+ const upstreamCode =
53
+ typeof body.upstreamCode === "string" ? body.upstreamCode : undefined;
54
+ const upstreamRequestId =
55
+ typeof body.upstreamRequestId === "string"
56
+ ? body.upstreamRequestId
57
+ : undefined;
58
+
50
59
  browserLogger.log({
51
60
  level,
52
61
  event,
@@ -63,6 +72,10 @@ export async function POST(request: NextRequest) {
63
72
  url: typeof body.url === "string" ? body.url : undefined,
64
73
  userAgent: request.headers.get("user-agent") ?? undefined,
65
74
  digest: typeof body.digest === "string" ? body.digest : undefined,
75
+ code,
76
+ status,
77
+ upstreamCode,
78
+ upstreamRequestId,
66
79
  },
67
80
  });
68
81
 
@@ -79,6 +79,7 @@ export async function GET(request: NextRequest | Request) {
79
79
  const mapped = mapOssError(error);
80
80
  return errorResponse(mapped.code, mapped.message, mapped.httpStatus, {
81
81
  errorSource: "service",
82
+ details: mapped.details,
82
83
  });
83
84
  }
84
85
 
@@ -1,6 +1,25 @@
1
1
  @import "tailwindcss";
2
2
  @import "katex/dist/katex.min.css";
3
3
 
4
+ /*
5
+ * Bridge the legacy Tailwind v3 style config (tailwind.config.ts) into
6
+ * Tailwind v4. Without @config, the JS config file is silently ignored,
7
+ * which means:
8
+ * 1. Theme tokens (success/warning/danger/info/purple) are never
9
+ * registered, so utilities like `bg-success-soft` don't exist.
10
+ * 2. `darkMode: ["class", ".dark"]` is not applied, so `dark:` falls
11
+ * back to `prefers-color-scheme`, which fights with next-themes'
12
+ * class-based toggle and bleeds dark styles into light mode.
13
+ */
14
+ @config "../../tailwind.config.ts";
15
+
16
+ /*
17
+ * Belt-and-suspenders: ensure `dark:` always resolves through the
18
+ * `.dark` class that next-themes toggles on <html>, regardless of OS
19
+ * preference. This must agree with the darkMode setting above.
20
+ */
21
+ @custom-variant dark (&:where(.dark, .dark *));
22
+
4
23
  @layer base {
5
24
  :root {
6
25
  /* Brand primary: webUI blue (hue 221, #2563eb) */
@@ -77,6 +96,8 @@
77
96
  --warning-soft: 48 100% 96%;
78
97
  --danger: 0 84% 60%;
79
98
  --danger-soft: 0 86% 97%;
99
+ --info: 217 91% 60%;
100
+ --info-soft: 214 100% 97%;
80
101
  --purple: 262 84% 58%;
81
102
  --purple-soft: 258 100% 97%;
82
103
 
@@ -174,6 +195,8 @@
174
195
  --warning-soft: 38 30% 18%;
175
196
  --danger: 0 84% 65%;
176
197
  --danger-soft: 0 30% 20%;
198
+ --info: 217 91% 70%;
199
+ --info-soft: 217 30% 18%;
177
200
  --purple: 262 84% 65%;
178
201
  --purple-soft: 262 30% 22%;
179
202
  }