@tablestore/tablestore-agent-cli 0.4.0 → 0.4.1

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 (371) hide show
  1. package/dist/dashboard-runtime/dashboard/.next/BUILD_ID +1 -1
  2. package/dist/dashboard-runtime/dashboard/.next/build-manifest.json +3 -3
  3. package/dist/dashboard-runtime/dashboard/.next/prerender-manifest.json +3 -3
  4. package/dist/dashboard-runtime/dashboard/.next/required-server-files.json +4 -4
  5. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/api-keys/page.js.nft.json +1 -1
  6. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/api-keys/page_client-reference-manifest.js +1 -1
  7. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
  8. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
  9. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page.js.nft.json +1 -1
  10. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page_client-reference-manifest.js +1 -1
  11. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page.js.nft.json +1 -1
  12. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page_client-reference-manifest.js +1 -1
  13. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page.js.nft.json +1 -1
  14. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page_client-reference-manifest.js +1 -1
  15. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page.js.nft.json +1 -1
  16. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page_client-reference-manifest.js +1 -1
  17. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page.js.nft.json +1 -1
  18. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page_client-reference-manifest.js +1 -1
  19. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/create/page.js.nft.json +1 -1
  20. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/create/page_client-reference-manifest.js +1 -1
  21. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page.js.nft.json +1 -1
  22. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page_client-reference-manifest.js +1 -1
  23. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/[id]/page.js.nft.json +1 -1
  24. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/[id]/page_client-reference-manifest.js +1 -1
  25. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/new/page.js.nft.json +1 -1
  26. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/new/page_client-reference-manifest.js +1 -1
  27. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page.js.nft.json +1 -1
  28. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page_client-reference-manifest.js +1 -1
  29. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/dream/[dreamId]/page.js.nft.json +1 -1
  30. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/dream/[dreamId]/page_client-reference-manifest.js +1 -1
  31. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/dream/page.js.nft.json +1 -1
  32. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/dream/page_client-reference-manifest.js +1 -1
  33. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page.js.nft.json +1 -1
  34. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page_client-reference-manifest.js +1 -1
  35. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page.js.nft.json +1 -1
  36. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page_client-reference-manifest.js +1 -1
  37. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page.js.nft.json +1 -1
  38. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page_client-reference-manifest.js +1 -1
  39. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/scope/page.js.nft.json +1 -1
  40. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/scope/page_client-reference-manifest.js +1 -1
  41. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page.js.nft.json +1 -1
  42. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page_client-reference-manifest.js +1 -1
  43. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page.js.nft.json +1 -1
  44. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page_client-reference-manifest.js +1 -1
  45. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/tasks/page.js.nft.json +1 -1
  46. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/tasks/page_client-reference-manifest.js +1 -1
  47. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page.js.nft.json +1 -1
  48. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page_client-reference-manifest.js +1 -1
  49. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/wiki/page.js.nft.json +1 -1
  50. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/wiki/page_client-reference-manifest.js +1 -1
  51. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/create/page.js.nft.json +1 -1
  52. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/create/page_client-reference-manifest.js +1 -1
  53. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page.js.nft.json +1 -1
  54. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page_client-reference-manifest.js +1 -1
  55. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page.js.nft.json +1 -1
  56. package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page_client-reference-manifest.js +1 -1
  57. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.html +1 -1
  58. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.rsc +1 -1
  59. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  60. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  61. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  62. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  63. package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  64. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found/page.js.nft.json +1 -1
  65. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  66. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.html +1 -1
  67. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.rsc +16 -16
  68. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +16 -16
  69. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +3 -3
  70. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
  71. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
  72. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  73. package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  74. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/api-keys/[id]/custom-policy/route.js.nft.json +1 -1
  75. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/api-keys/[id]/effective-permissions/route.js.nft.json +1 -1
  76. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/api-keys/[id]/policies/route.js.nft.json +1 -1
  77. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/api-keys/[id]/route.js.nft.json +1 -1
  78. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/api-keys/filter-by-permission/route.js.nft.json +1 -1
  79. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/api-keys/route.js.nft.json +1 -1
  80. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/auth/status/route.js.nft.json +1 -1
  81. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/auth/token/route.js.nft.json +1 -1
  82. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/[name]/route.js.nft.json +1 -1
  83. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/[name]/token/route.js.nft.json +1 -1
  84. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/[name]/use/route.js.nft.json +1 -1
  85. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/connectivity/route.js.nft.json +1 -1
  86. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/instances/route.js.nft.json +1 -1
  87. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/chunks/route.js.nft.json +1 -1
  88. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/[docId]/chunks/route.js.nft.json +1 -1
  89. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/[docId]/route.js.nft.json +1 -1
  90. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/route.js.nft.json +1 -1
  91. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/upload/route.js.nft.json +1 -1
  92. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/retrieve/route.js.nft.json +1 -1
  93. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/route.js.nft.json +1 -1
  94. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/route.js.nft.json +1 -1
  95. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/chat/route.js +3 -3
  96. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/chat/route.js.nft.json +1 -1
  97. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/[id]/models/route.js.nft.json +1 -1
  98. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/[id]/route.js.nft.json +1 -1
  99. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/[id]/test/route.js.nft.json +1 -1
  100. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/llm/providers/route.js.nft.json +1 -1
  101. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/logs/client/route.js.nft.json +1 -1
  102. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/dream-kb-sync/route.js.nft.json +1 -1
  103. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/dream-tasks/[dreamId]/actions/apply/route.js.nft.json +1 -1
  104. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/dream-tasks/[dreamId]/actions/route.js.nft.json +1 -1
  105. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/dream-tasks/[dreamId]/cancel/route.js.nft.json +1 -1
  106. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/dream-tasks/[dreamId]/route.js.nft.json +1 -1
  107. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/dream-tasks/route.js.nft.json +1 -1
  108. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/file-memory/[action]/route.js.nft.json +1 -1
  109. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/messages/route.js.nft.json +1 -1
  110. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/requests/route.js.nft.json +1 -1
  111. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/route.js +1 -1
  112. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/route.js.nft.json +1 -1
  113. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/scopes/route.js +1 -1
  114. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/scopes/route.js.nft.json +1 -1
  115. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/search/route.js +1 -1
  116. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/search/route.js.nft.json +1 -1
  117. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/tasks/[requestId]/route.js.nft.json +1 -1
  118. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/tasks/route.js.nft.json +1 -1
  119. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/units/[memoryId]/route.js.nft.json +1 -1
  120. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/units/route.js.nft.json +1 -1
  121. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/artifacts/route.js.nft.json +1 -1
  122. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/ingest/route.js.nft.json +1 -1
  123. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/page/route.js.nft.json +1 -1
  124. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/pages/route.js.nft.json +1 -1
  125. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/route.js.nft.json +1 -1
  126. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/search/route.js.nft.json +1 -1
  127. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/source/route.js.nft.json +1 -1
  128. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/[store]/wikis/sources/route.js.nft.json +1 -1
  129. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/route.js +1 -1
  130. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/memory/stores/route.js.nft.json +1 -1
  131. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/oss/list/route.js.nft.json +1 -1
  132. package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/runtime/context/route.js.nft.json +1 -1
  133. package/dist/dashboard-runtime/dashboard/.next/server/app/index.html +1 -1
  134. package/dist/dashboard-runtime/dashboard/.next/server/app/index.rsc +15 -15
  135. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  136. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_full.segment.rsc +15 -15
  137. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_head.segment.rsc +3 -3
  138. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_index.segment.rsc +11 -11
  139. package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  140. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding/page.js.nft.json +1 -1
  141. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  142. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.html +1 -1
  143. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.rsc +18 -18
  144. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_full.segment.rsc +18 -18
  145. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_head.segment.rsc +3 -3
  146. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_index.segment.rsc +11 -11
  147. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_tree.segment.rsc +2 -2
  148. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +4 -4
  149. package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/onboarding.segment.rsc +4 -4
  150. package/dist/dashboard-runtime/dashboard/.next/server/app/page.js.nft.json +1 -1
  151. package/dist/dashboard-runtime/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
  152. package/dist/dashboard-runtime/dashboard/.next/server/chunks/0p91_next_dist_esm_build_templates_app-route_0n~ec7s.js +11 -11
  153. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0-e5iv2._.js +3 -0
  154. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__03j_ekh._.js +3 -0
  155. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__07k_8vo._.js +3 -0
  156. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0esucs7._.js +3 -0
  157. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0z19yd0._.js +3 -0
  158. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__07er-7t._.js +3 -0
  159. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__09556l4._.js +3 -0
  160. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0ejd~qu._.js +3 -0
  161. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0hbevlv._.js +3 -0
  162. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0xqm21n._.js +3 -0
  163. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0-yhfok._.js +3 -0
  164. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0.eh64w._.js +3 -0
  165. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_06umrt-._.js +3 -0
  166. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0a-deba._.js +3 -0
  167. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0au8umj._.js +3 -0
  168. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0f3_q1r._.js +3 -0
  169. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0fz3kge._.js +1 -1
  170. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0gt9qp0._.js +3 -0
  171. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0ih5--w._.js +3 -0
  172. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0j4mfzx._.js +3 -0
  173. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_06ofr7j._.js → _0j_44th._.js} +2 -2
  174. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_06.3nzk._.js → _0mn4dgd._.js} +2 -2
  175. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_0d_nd-j._.js → _0nc~.w2._.js} +2 -2
  176. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0p-bup8._.js +3 -0
  177. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0psdvqq._.js +3 -0
  178. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0rd1b-.._.js +3 -0
  179. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0t_-u16._.js +3 -0
  180. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0u0~-~-._.js +3 -0
  181. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0vw3mzw._.js +3 -0
  182. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0ww5s91._.js +1 -1
  183. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0xm2tp8._.js +3 -0
  184. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0xutx8t._.js +3 -0
  185. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0ggq95f._.js +3 -0
  186. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0x60pxf._.js +1 -1
  187. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0xaihln._.js +1 -1
  188. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_api-keys_page_tsx_0lb6fu7._.js +1 -1
  189. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_dream_[dreamId]_page_tsx_0wy3tv6._.js +1 -1
  190. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_dream_page_tsx_0uzzpvs._.js +1 -1
  191. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_layout_tsx_0rbi41w._.js +1 -1
  192. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_scope_page_tsx_01rq2zq._.js +3 -0
  193. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_search_page_tsx_0rj3dkc._.js +3 -0
  194. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_tasks_page_tsx_0a_bgx4._.js +1 -1
  195. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_memory_[store]_units_page_tsx_0.6xnei._.js +1 -1
  196. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_components_memory_memory-files-browser_tsx_0o2~94-._.js +1 -1
  197. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_i18n_i18n-context_tsx_0c39ewr._.js +1 -1
  198. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_03py6n-._.js +3 -0
  199. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_08hzj0f._.js +3 -0
  200. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_0_mks~s._.js +3 -0
  201. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_0xbb09m._.js +3 -0
  202. package/dist/dashboard-runtime/dashboard/.next/server/middleware-build-manifest.js +3 -3
  203. package/dist/dashboard-runtime/dashboard/.next/server/pages/404.html +1 -1
  204. package/dist/dashboard-runtime/dashboard/.next/server/pages/500.html +1 -1
  205. package/dist/dashboard-runtime/dashboard/.next/server/server-reference-manifest.js +1 -1
  206. package/dist/dashboard-runtime/dashboard/.next/server/server-reference-manifest.json +1 -1
  207. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0-b36b4si6az5.js +1 -0
  208. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0-q4fucd6l5ip.js +1 -0
  209. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{14t.r5~ls3k0x.js → 03qrjs4w.7yz3.js} +1 -1
  210. package/dist/dashboard-runtime/dashboard/.next/static/chunks/04uxooijjqs-9.js +1 -0
  211. package/dist/dashboard-runtime/dashboard/.next/static/chunks/08tm8srceyz1j.js +1 -0
  212. package/dist/dashboard-runtime/dashboard/.next/static/chunks/08tpejw1f.2jd.js +1 -0
  213. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0b_~fcwy9vo2r.js +1 -0
  214. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0crw5ciecbvir.js +1 -0
  215. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0cy7y~ef_6m-s.js +1 -0
  216. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0dl5t6e508o8k.js +1 -0
  217. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0expqv.~8a3wr.js +1 -0
  218. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0gdmaffoezvcu.js +1 -0
  219. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0hoybc7spk4vg.js +1 -0
  220. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0k6m5~gmu0f8w.js → 0k9my4lhyvwbd.js} +1 -1
  221. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0lfx3ykqc9uiy.js +1 -0
  222. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0m2j5ne9j7dft.js +1 -0
  223. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0m50djlkcegw9.js +1 -0
  224. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0mg.g5g33nh.~.js +1 -0
  225. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0mit8g2.vh7a9.js +1 -0
  226. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0o9quk2z~1ez0.js +1 -0
  227. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0o~zjik9-6a1f.js +1 -0
  228. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0p6zd_ss6.14_.js +1 -0
  229. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0qccdw9ussvne.js +1 -0
  230. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{1204oli3aouy7.js → 0teq2sa-33s3g.js} +1 -1
  231. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0upl.e~taktf9.js +1 -0
  232. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0v1ulq51wmrto.js +5 -0
  233. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0v5mmaebktnw1.css +1 -0
  234. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0vp-dv9_z334e.js +1 -0
  235. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0w9eqc5ya-oai.js +1 -0
  236. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0x0ppjv_4yap7.js +1 -0
  237. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0xbqtv-jcph-2.js +1 -0
  238. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0~m6ml547qzpo.js +1 -0
  239. package/dist/dashboard-runtime/dashboard/.next/static/chunks/10s~90qej98.b.js +1 -0
  240. package/dist/dashboard-runtime/dashboard/.next/static/chunks/12vri~chu44bu.js +9 -0
  241. package/dist/dashboard-runtime/dashboard/.next/static/chunks/13jqvu~hww3b4.js +1 -0
  242. package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0idn9fvygbi9d.js → 13wh4v_j6tlns.js} +1 -1
  243. package/dist/dashboard-runtime/dashboard/.next/static/chunks/16.18mrzg-4wl.js +1 -0
  244. package/dist/dashboard-runtime/dashboard/.next/static/chunks/162doi8c0o5ot.js +1 -0
  245. package/dist/dashboard-runtime/dashboard/server.js +1 -1
  246. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/dream/[dreamId]/page.tsx +6 -1
  247. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/dream/page.tsx +3 -2
  248. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/layout.tsx +5 -2
  249. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/scope/page.tsx +24 -16
  250. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/search/page.tsx +77 -21
  251. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/settings/page.tsx +18 -2
  252. package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/memory/[store]/units/page.tsx +89 -47
  253. package/dist/dashboard-runtime/dashboard/src/app/api/v1/llm/chat/memory-retrieval.ts +72 -4
  254. package/dist/dashboard-runtime/dashboard/src/app/api/v1/memory/stores/[store]/route.ts +19 -2
  255. package/dist/dashboard-runtime/dashboard/src/app/api/v1/memory/stores/[store]/scopes/route.ts +123 -8
  256. package/dist/dashboard-runtime/dashboard/src/app/api/v1/memory/stores/[store]/search/route.ts +21 -8
  257. package/dist/dashboard-runtime/dashboard/src/app/api/v1/memory/stores/route.ts +11 -4
  258. package/dist/dashboard-runtime/dashboard/src/components/chat/chat-config-context.tsx +2 -5
  259. package/dist/dashboard-runtime/dashboard/src/components/chat/wiki-bind-section.tsx +2 -4
  260. package/dist/dashboard-runtime/dashboard/src/components/layout/language-toggle.tsx +19 -16
  261. package/dist/dashboard-runtime/dashboard/src/components/layout/sidebar-mobile.tsx +1 -1
  262. package/dist/dashboard-runtime/dashboard/src/components/memory/file-details-panel.tsx +32 -10
  263. package/dist/dashboard-runtime/dashboard/src/components/memory/file-mutation-dialogs.tsx +14 -2
  264. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-add-dialog.tsx +21 -3
  265. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-create-form.tsx +50 -38
  266. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-files-browser.tsx +46 -10
  267. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-requests-table.tsx +7 -6
  268. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-scope-bar.tsx +13 -4
  269. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-search-form.tsx +384 -70
  270. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-search-results.tsx +238 -57
  271. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-settings-form.tsx +88 -1
  272. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-store-card.tsx +4 -1
  273. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-tasks-table.tsx +3 -2
  274. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-unit-detail-panel.tsx +19 -4
  275. package/dist/dashboard-runtime/dashboard/src/components/memory/memory-unit-table.tsx +8 -5
  276. package/dist/dashboard-runtime/dashboard/src/components/memory/scope-directory-explorer.tsx +384 -0
  277. package/dist/dashboard-runtime/dashboard/src/components/memory/scope-filter-builder.tsx +393 -0
  278. package/dist/dashboard-runtime/dashboard/src/components/memory/scope-workspace.tsx +6 -2
  279. package/dist/dashboard-runtime/dashboard/src/components/shared/copyable-id.tsx +69 -0
  280. package/dist/dashboard-runtime/dashboard/src/hooks/use-chat-history.ts +2 -3
  281. package/dist/dashboard-runtime/dashboard/src/i18n/locales/en.ts +121 -14
  282. package/dist/dashboard-runtime/dashboard/src/i18n/locales/zh.ts +116 -12
  283. package/dist/dashboard-runtime/dashboard/src/lib/memory-storage-mode.ts +140 -33
  284. package/dist/dashboard-runtime/dashboard/src/lib/memory-units-view.ts +9 -0
  285. package/dist/dashboard-runtime/dashboard/src/lib/memory.ts +2 -7
  286. package/dist/dashboard-runtime/dashboard/src/lib/query-keys.ts +13 -0
  287. package/dist/dashboard-runtime/dashboard/src/lib/scope-directory.ts +97 -0
  288. package/dist/dashboard-runtime/dashboard/src/lib/server/memory-store-contract.ts +41 -0
  289. package/dist/dashboard-runtime/dashboard/src/lib/server/scope-filter-validation.ts +186 -0
  290. package/dist/dashboard-runtime/dashboard/src/schemas/llm-chat.ts +5 -2
  291. package/dist/dashboard-runtime/dashboard/src/services/memory.ts +16 -6
  292. package/dist/dashboard-runtime/dashboard/src/types/memory.ts +95 -4
  293. package/dist/dashboard-runtime/node_modules/@img/{sharp-libvips-darwin-arm64 → sharp-libvips-linux-x64}/README.md +2 -2
  294. package/dist/dashboard-runtime/node_modules/@img/{sharp-libvips-darwin-arm64 → sharp-libvips-linux-x64}/lib/glib-2.0/include/glibconfig.h +9 -8
  295. package/dist/dashboard-runtime/node_modules/@img/{sharp-libvips-darwin-arm64/lib/libvips-cpp.8.17.3.dylib → sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3} +0 -0
  296. package/dist/dashboard-runtime/node_modules/@img/{sharp-libvips-darwin-arm64 → sharp-libvips-linux-x64}/package.json +11 -5
  297. package/dist/dashboard-runtime/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
  298. package/dist/dashboard-runtime/node_modules/@img/{sharp-darwin-arm64 → sharp-linux-x64}/package.json +13 -7
  299. package/dist/dashboard-runtime/node_modules/@tablestore/tablestore-agent-sdk/dist/tsconfig.tsbuildinfo +1 -1
  300. package/dist/node_modules/@tablestore/tablestore-agent-sdk/dist/tsconfig.tsbuildinfo +1 -1
  301. package/package.json +1 -1
  302. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0is6qso._.js +0 -3
  303. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0q9fgt6._.js +0 -3
  304. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0w_ig2a._.js +0 -3
  305. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__0zmo~nd._.js +0 -3
  306. package/dist/dashboard-runtime/dashboard/.next/server/chunks/[root-of-the-server]__13g_f9w._.js +0 -3
  307. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__05kcz99._.js +0 -3
  308. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__06l7w~r._.js +0 -3
  309. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__07fsbff._.js +0 -3
  310. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0_6myqa._.js +0 -3
  311. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0d-z.x1._.js +0 -3
  312. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_00.la1c._.js +0 -3
  313. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_01r6jx1._.js +0 -3
  314. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_04rasxw._.js +0 -3
  315. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_05__-74._.js +0 -3
  316. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_05wwgdw._.js +0 -3
  317. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0f.xs7l._.js +0 -3
  318. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0jt60z2._.js +0 -3
  319. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0k7q0ug._.js +0 -3
  320. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0kaclzw._.js +0 -3
  321. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0lstkpb._.js +0 -3
  322. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0qw41co._.js +0 -3
  323. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0vfgz-v._.js +0 -3
  324. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0y4mxf8._.js +0 -3
  325. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_119lxvo._.js +0 -3
  326. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_079nj-_._.js +0 -3
  327. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_0bhjp9s._.js +0 -3
  328. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_0..ymrl._.js +0 -3
  329. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_00arje5._.js +0 -3
  330. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_08h.f_8._.js +0 -3
  331. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_0pf30rh._.js +0 -3
  332. package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/node_modules__pnpm_12_d6fg._.js +0 -3
  333. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0-88a30l.a1sg.js +0 -1
  334. package/dist/dashboard-runtime/dashboard/.next/static/chunks/01nixb3ddw4hy.js +0 -1
  335. package/dist/dashboard-runtime/dashboard/.next/static/chunks/01u9hj_9~5-vg.js +0 -1
  336. package/dist/dashboard-runtime/dashboard/.next/static/chunks/02q3tpry1ajx9.js +0 -1
  337. package/dist/dashboard-runtime/dashboard/.next/static/chunks/057-rg6~0wki8.css +0 -1
  338. package/dist/dashboard-runtime/dashboard/.next/static/chunks/05d8-45s941bx.js +0 -1
  339. package/dist/dashboard-runtime/dashboard/.next/static/chunks/07q8af71w17xl.js +0 -1
  340. package/dist/dashboard-runtime/dashboard/.next/static/chunks/07v6llp0fv6iq.js +0 -1
  341. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0a9.rr50h5ypa.js +0 -1
  342. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0axnv6wy1_hr7.js +0 -1
  343. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0bbcwyy.xvpd0.js +0 -1
  344. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0cfrd_r4jr_ip.js +0 -9
  345. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0dpj.6wcf.qn8.js +0 -1
  346. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0gt8u.o_c_nix.js +0 -1
  347. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0hh2728tmgrdk.js +0 -1
  348. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0jjiw-agnutux.js +0 -1
  349. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0nw7q~w~vg.-y.js +0 -1
  350. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0o-j8g9gp_c1r.js +0 -1
  351. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0pm6vv5wntle..js +0 -1
  352. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0qr499bd44k.g.js +0 -1
  353. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0sx_fx5r7nq4b.js +0 -1
  354. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0tbu6y0a22ok8.js +0 -1
  355. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0u6c8q4k~6aiy.js +0 -1
  356. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0u7fh6be6noif.js +0 -1
  357. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0wcf_hdt9arma.js +0 -5
  358. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0xash~4j8pl87.js +0 -1
  359. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0xi6y8g4l~vzr.js +0 -1
  360. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0y45-~ia9sqr0.js +0 -1
  361. package/dist/dashboard-runtime/dashboard/.next/static/chunks/0yvc~t7p88wsf.js +0 -1
  362. package/dist/dashboard-runtime/dashboard/.next/static/chunks/10684vn7g6wln.js +0 -1
  363. package/dist/dashboard-runtime/dashboard/.next/static/chunks/14rpr3z1.lmgj.js +0 -1
  364. package/dist/dashboard-runtime/dashboard/.next/static/chunks/15043qe~kvq-v.js +0 -1
  365. package/dist/dashboard-runtime/dashboard/tsconfig.tsbuildinfo +0 -1
  366. package/dist/dashboard-runtime/node_modules/@img/sharp-darwin-arm64/lib/sharp-darwin-arm64.node +0 -0
  367. /package/dist/dashboard-runtime/dashboard/.next/static/{bKUtNfKb47TOc1cpUk74A → mCNgeSYc3Dx3KiZXWf-5A}/_buildManifest.js +0 -0
  368. /package/dist/dashboard-runtime/dashboard/.next/static/{bKUtNfKb47TOc1cpUk74A → mCNgeSYc3Dx3KiZXWf-5A}/_clientMiddlewareManifest.js +0 -0
  369. /package/dist/dashboard-runtime/dashboard/.next/static/{bKUtNfKb47TOc1cpUk74A → mCNgeSYc3Dx3KiZXWf-5A}/_ssgManifest.js +0 -0
  370. /package/dist/dashboard-runtime/node_modules/@img/{sharp-libvips-darwin-arm64 → sharp-libvips-linux-x64}/lib/index.js +0 -0
  371. /package/dist/dashboard-runtime/node_modules/@img/{sharp-libvips-darwin-arm64 → sharp-libvips-linux-x64}/versions.json +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[722424,a=>{"use strict";var b=a.i(634020),c=a.i(971938),d=a.i(163426),e=a.i(25825),f=a.i(750053);let g=(0,f.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var h=a.i(776192),i=a.i(604395),j=a.i(310215),k=a.i(502482),l=a.i(263265),m=a.i(342210);let n=(0,f.default)("brain-circuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);var o=a.i(881619);let p=(0,f.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var q=a.i(655295),r=a.i(223301),s=a.i(674024),t=a.i(521989),u=a.i(865271),v=a.i(543320),w=a.i(933596),x=a.i(895487),y=a.i(353141);async function z(){return(await (0,y.apiGet)("/api/v1/api-keys")).apiKeys}async function A(a){let b={};return a?.serviceCredentialName&&(b.serviceCredentialName=a.serviceCredentialName),a?.credentialAgeDays&&a.credentialAgeDays>0&&(b.credentialAgeDays=a.credentialAgeDays),(await (0,y.apiPost)("/api/v1/api-keys",Object.keys(b).length>0?b:void 0)).apiKey}async function B(a){await (0,y.apiDelete)(`/api/v1/api-keys/${encodeURIComponent(a.serviceCredentialId)}`,{userPrincipalName:a.userPrincipalName,deleteCustomPolicy:a.deleteCustomPolicy??!0,deleteRamUser:a.deleteRamUser??!0})}async function C(a){await (0,y.apiPatch)(`/api/v1/api-keys/${encodeURIComponent(a.serviceCredentialId)}`,{userPrincipalName:a.userPrincipalName,status:a.status})}async function D(a,b){return(await (0,y.apiGet)(`/api/v1/api-keys/${encodeURIComponent(a)}/policies?userName=${encodeURIComponent(b)}`)).policies}async function E(a,b){await (0,y.apiPost)(`/api/v1/api-keys/${encodeURIComponent(a)}/policies`,b)}async function F(a,b){await (0,y.apiDelete)(`/api/v1/api-keys/${encodeURIComponent(a)}/policies`,b)}async function G(a,b){return(0,y.apiGet)(`/api/v1/api-keys/${encodeURIComponent(a)}/custom-policy?userName=${encodeURIComponent(b)}`)}async function H(a,b){await (0,y.apiPut)(`/api/v1/api-keys/${encodeURIComponent(a)}/custom-policy`,b)}async function I(a,b){return(0,y.apiGet)(`/api/v1/api-keys/${encodeURIComponent(a)}/effective-permissions?userName=${encodeURIComponent(b)}`)}async function J(a){let b=new URLSearchParams({resourceType:a.resourceType,resourceName:a.resourceName,operationGroup:a.operationGroup});return(0,y.apiGet)(`/api/v1/api-keys/filter-by-permission?${b.toString()}`)}async function K(a,b){await (0,y.apiDelete)(`/api/v1/api-keys/${encodeURIComponent(a)}/custom-policy`,b)}var L=a.i(225377),M=a.i(983366),N=a.i(739096);function O(a,b){let{context:c,ready:d}=(0,N.useRuntimeContext)();return(0,M.useQuery)({queryKey:L.queryKeys.effectivePermissions(c.dataScopeKey,a??""),queryFn:()=>I(a,b),enabled:d&&!!a&&!!b,staleTime:15e3})}function P({apiKeys:a,onDelete:c,onDetail:d}){let{t:e}=(0,v.useI18n)();return(0,b.jsx)("div",{className:"rounded-lg border border-[hsl(var(--border))]",children:(0,b.jsxs)(r.Table,{children:[(0,b.jsx)(r.TableHeader,{children:(0,b.jsxs)(r.TableRow,{children:[(0,b.jsx)(r.TableHead,{children:e("apiKeys.table.credentialName")}),(0,b.jsx)(r.TableHead,{className:"w-[8rem]",children:e("apiKeys.table.status")}),(0,b.jsx)(r.TableHead,{children:e("apiKeys.table.accessibleKnowledgeBase")}),(0,b.jsx)(r.TableHead,{children:e("apiKeys.table.accessibleMemoryStore")}),(0,b.jsx)(r.TableHead,{className:"w-[10rem]",children:e("apiKeys.table.createdAt")}),(0,b.jsx)(r.TableHead,{className:"w-[11rem] text-right",children:e("apiKeys.table.actions")})]})}),(0,b.jsx)(r.TableBody,{children:a.map(a=>(0,b.jsx)(Q,{apiKey:a,onDelete:c,onDetail:d},a.serviceCredentialId))})]})})}function Q({apiKey:a,onDelete:d,onDetail:e}){let f,{t:g}=(0,v.useI18n)(),i=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>C(a),onSuccess:()=>{(0,L.invalidateApiKeyQueries)(f)}})),[j,k]=(0,c.useState)(null),m=j??"Active"===a.status,n=Number.isFinite(Date.parse(a.createTime))?Date.parse(a.createTime):null;async function t(b){k(b);try{await i.mutateAsync({serviceCredentialId:a.serviceCredentialId,userPrincipalName:a.userPrincipalName,status:b?"Active":"Inactive"}),l.toast.success(b?g("apiKeys.table.enabled"):g("apiKeys.table.disabled"))}catch(a){k(null),l.toast.error(a instanceof Error?a.message:g("apiKeys.table.operationFailed"))}}return(0,b.jsxs)(r.TableRow,{className:"cursor-pointer",onClick:()=>e(a),children:[(0,b.jsx)(r.TableCell,{children:(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("span",{className:"text-sm font-medium text-foreground",children:a.serviceCredentialName}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:a.userPrincipalName})]})}),(0,b.jsx)(r.TableCell,{onClick:a=>a.stopPropagation(),children:(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)(s.Switch,{checked:m,onCheckedChange:t,disabled:i.isPending,"aria-label":m?g("apiKeys.table.disable"):g("apiKeys.table.enable")}),(0,b.jsx)("span",{className:m?"text-xs font-medium text-success":"text-xs font-medium text-muted-foreground",children:i.isPending?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,b.jsx)(o.Loader2,{className:"h-3 w-3 animate-spin"}),g("apiKeys.table.toggling")]}):m?g("apiKeys.table.statusActive"):g("apiKeys.table.statusInactive")})]})}),(0,b.jsx)(r.TableCell,{onClick:a=>a.stopPropagation(),children:(0,b.jsx)(R,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,resourceType:"knowledgebase"})}),(0,b.jsx)(r.TableCell,{onClick:a=>a.stopPropagation(),children:(0,b.jsx)(R,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,resourceType:"memorystore"})}),(0,b.jsx)(r.TableCell,{children:n?(0,b.jsx)(u.RelativeTime,{timestamp:n}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"})}),(0,b.jsxs)(r.TableCell,{className:"text-right",children:[(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"h-8",onClick:b=>{b.stopPropagation(),e(a)},children:[(0,b.jsx)(p,{className:"mr-1 h-3.5 w-3.5"}),g("apiKeys.table.permission")]}),(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:`h-8 text-[hsl(var(--destructive))] hover:bg-[hsl(var(--destructive))/0.08] hover:text-[hsl(var(--destructive))] ${m?"opacity-50 cursor-not-allowed":""}`,onClick:b=>{b.stopPropagation(),m?l.toast.info(g("apiKeys.table.disableBeforeDelete")):d(a)},children:[(0,b.jsx)(q.Trash2,{className:"mr-1 h-3.5 w-3.5"}),g("common.delete")]})]})]})}function R({serviceCredentialId:a,userName:c,resourceType:d}){let{t:e}=(0,v.useI18n)(),{data:f,isLoading:g,isError:h}=O(a,c);if(g)return(0,b.jsx)(o.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"});if(h)return(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"});let i=(f?.resources?.filter(a=>a.resourceType===d)??[]).filter(a=>a.permissions.read||a.permissions.write||a.permissions.manage);if(0===i.length)return(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:e("apiKeys.table.none")});let j="knowledgebase"===d?m.BookOpen:n;return(0,b.jsx)("div",{className:"flex flex-wrap gap-1",children:i.map(a=>(0,b.jsxs)(t.Badge,{variant:"secondary",className:"gap-1 text-[11px] font-normal",children:[(0,b.jsx)(j,{className:"h-3 w-3"}),a.resourceName]},a.resourceName))})}var S=a.i(637102),T=a.i(172518),U=a.i(962491),V=a.i(843836);function W({open:a,onOpenChange:d,onCreated:e}){let f,{t:g}=(0,v.useI18n)(),i=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>A(a),onSuccess:()=>{(0,L.invalidateApiKeyQueries)(f)}})),[j,k]=(0,c.useState)(""),[m,n]=(0,c.useState)("");async function o(){let a=j.trim();if(!a)return void l.toast.error(g("apiKeys.create.nameRequired"));let b=m?Number(m):void 0;if(void 0!==b&&(b<1||b>365||!Number.isInteger(b)))return void l.toast.error(g("apiKeys.create.ageDaysInvalid"));try{let c=await i.mutateAsync({serviceCredentialName:a,credentialAgeDays:b});d(!1),e(c)}catch(a){l.toast.error(a instanceof Error?a.message:g("apiKeys.create.createFailed"))}}return(0,c.useEffect)(()=>{a&&(k("ots_apikey_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,6)),n(""))},[a]),(0,b.jsx)(V.Dialog,{open:a,onOpenChange:a=>{d(a)},children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsx)(V.DialogHeader,{children:(0,b.jsx)(V.DialogTitle,{className:"text-xl",children:g("apiKeys.create.title")})}),(0,b.jsxs)("div",{className:"space-y-3 py-1 text-sm leading-relaxed text-muted-foreground",children:[(0,b.jsxs)("p",{children:[g("apiKeys.create.introPrefix"),(0,b.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"ots.aliyuncs.com"}),g("apiKeys.create.introSuffix")]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-foreground",children:g("apiKeys.create.credentialName")}),(0,b.jsx)(T.Input,{value:j,onChange:a=>k(a.target.value),placeholder:g("apiKeys.create.credentialNamePlaceholder"),className:"h-9"}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:g("apiKeys.create.credentialNameHelp")})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-foreground",children:g("apiKeys.create.ageDays")}),(0,b.jsx)(T.Input,{type:"number",min:1,max:365,value:m,onChange:a=>n(a.target.value),placeholder:g("apiKeys.create.ageDaysPlaceholder"),className:"h-9"}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:g("apiKeys.create.ageDaysHelp")})]}),(0,b.jsx)("div",{className:"rounded-md border border-[hsl(var(--warning))/0.5] bg-[hsl(var(--warning))/0.08] px-4 py-3 text-sm",children:(0,b.jsxs)("p",{className:"text-foreground",children:[(0,b.jsx)(S.AlertTriangle,{className:"mr-1 -mt-0.5 inline h-4 w-4 text-warning"}),g("apiKeys.create.secretWarning")]})})]}),(0,b.jsxs)(V.DialogFooter,{children:[(0,b.jsx)(h.Button,{variant:"outline",onClick:()=>d(!1),disabled:i.isPending,children:g("common.cancel")}),(0,b.jsx)(h.Button,{onClick:o,disabled:i.isPending,children:i.isPending?g("common.creating"):g("apiKeys.create.confirm")})]})]})})}var X=a.i(36890);function Y({apiKey:a,open:d,onOpenChange:e}){let f,{t:g}=(0,v.useI18n)(),i=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>B(a),onSuccess:()=>{(0,L.invalidateApiKeyQueries)(f)}})),[j,k]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!0);async function o(){if(a)try{await i.mutateAsync({serviceCredentialId:a.serviceCredentialId,userPrincipalName:a.userPrincipalName,deleteCustomPolicy:j,deleteRamUser:m}),l.toast.success(g("apiKeys.delete.deleteSuccess")),e(!1)}catch(a){l.toast.error(a instanceof Error?a.message:g("apiKeys.delete.deleteFailed"))}}return(0,c.useEffect)(()=>{d&&(k(!0),n(!0))},[d]),(0,b.jsx)(V.Dialog,{open:d,onOpenChange:e,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsx)(V.DialogHeader,{children:(0,b.jsx)(V.DialogTitle,{className:"text-xl",children:g("apiKeys.delete.title")})}),(0,b.jsxs)("div",{className:"rounded-md border border-[hsl(var(--destructive))] bg-[hsl(var(--destructive))/0.06] px-4 py-3 text-sm leading-relaxed",children:[(0,b.jsxs)("p",{children:[(0,b.jsx)(S.AlertTriangle,{className:"mr-1 -mt-0.5 inline h-4 w-4 text-destructive"}),g("apiKeys.delete.warning")]}),a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"mt-3",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:g("apiKeys.delete.credentialNameLabel")}),(0,b.jsx)("code",{className:"font-mono text-xs",children:a.serviceCredentialName})]}),"Active"===a.status?(0,b.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("apiKeys.delete.activeHint")}):null]}):null]}),(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g("apiKeys.delete.cleanupHint")}),(0,b.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,b.jsx)(X.Checkbox,{checked:j,onCheckedChange:a=>k(!!a),className:"mt-0.5"}),(0,b.jsxs)("div",{children:[(0,b.jsx)(U.Label,{className:"text-sm cursor-pointer",children:g("apiKeys.delete.deleteCustomPolicy")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g("apiKeys.delete.deleteCustomPolicyDesc")})]})]}),(0,b.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,b.jsx)(X.Checkbox,{checked:m,onCheckedChange:a=>n(!!a),className:"mt-0.5"}),(0,b.jsxs)("div",{children:[(0,b.jsx)(U.Label,{className:"text-sm cursor-pointer",children:g("apiKeys.delete.deleteRamUser")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g("apiKeys.delete.deleteRamUserDesc")})]})]})]}),(0,b.jsxs)(V.DialogFooter,{children:[(0,b.jsx)(h.Button,{variant:"outline",onClick:()=>e(!1),disabled:i.isPending,children:g("common.cancel")}),(0,b.jsx)(h.Button,{variant:"destructive",disabled:i.isPending,onClick:o,children:i.isPending?g("common.deleting"):g("apiKeys.delete.confirm")})]})]})})}var Z=a.i(16772),$=a.i(770550),_=a.i(109734);async function aa(a){if(navigator.clipboard&&window.isSecureContext)return void await navigator.clipboard.writeText(a);let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b)}function ab(){let a=(0,x.useQueryClient)();return(0,w.useMutation)({mutationFn:a=>E(a.serviceCredentialId,{userName:a.userName,policyName:a.policyName,policyType:a.policyType}),onSuccess:()=>{(0,L.invalidateApiKeyPolicyQueries)(a),(0,L.invalidateEffectivePermissionsQueries)(a)}})}function ac(){let a=(0,x.useQueryClient)();return(0,w.useMutation)({mutationFn:a=>F(a.serviceCredentialId,{userName:a.userName,policyName:a.policyName,policyType:a.policyType}),onSuccess:()=>{(0,L.invalidateApiKeyPolicyQueries)(a),(0,L.invalidateEffectivePermissionsQueries)(a)}})}let ad="ts-ots-bearer-token-access";function ae({serviceCredentialId:a,userName:d,policies:e}){let{t:f}=(0,v.useI18n)(),g=ab(),h=ac(),[i,j]=(0,c.useState)(!1),k=e?.some(a=>a.policyName===ad)??!1;async function m(b){j(!0);try{b?(await g.mutateAsync({serviceCredentialId:a,userName:d,policyName:ad,policyType:"Custom"}),l.toast.success(f("apiKeys.bearer.enableSuccess"))):(await h.mutateAsync({serviceCredentialId:a,userName:d,policyName:ad,policyType:"Custom"}),l.toast.success(f("apiKeys.bearer.disableSuccess")))}catch(a){l.toast.error(a instanceof Error?a.message:f("apiKeys.bearer.operationFailed"))}finally{j(!1)}}return(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-[hsl(var(--border))] px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)("div",{className:"text-sm font-medium",children:f("apiKeys.bearer.title")}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:f("apiKeys.bearer.description")})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 shrink-0 ml-3",children:[i?(0,b.jsx)(o.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}):null,(0,b.jsx)(s.Switch,{checked:k,onCheckedChange:m,disabled:i||!e})]})]})}var af=a.i(147845),ag=a.i(112537),ah=a.i(126211),ai=a.i(663525),aj=a.i(909367),ak=a.i(610220),al=a.i(421347);let am=["ots:DescribeKnowledgeBase","ots:ListKnowledgeBase","ots:GetDocument","ots:ListDocuments","ots:ListChunks","ots:Retrieve"],an=["ots:AddDocuments","ots:UpdateDocument","ots:UpdateChunks","ots:DeleteDocuments","ots:UploadDocuments"],ao=["ots:CreateKnowledgeBase","ots:DeleteKnowledgeBase","ots:UpdateKnowledgeBase"],ap=["ots:GetMemoryStore","ots:ListMemoryStores","ots:SearchMemories","ots:ListMemories","ots:GetMemory","ots:ListMemoryStoreMessages","ots:ListMemoryStoreRequests","ots:ListMemoryStoreScopes","ots:GetMemoryTask","ots:ListMemoryTasks","ots:GetMemoryDreamTask","ots:ListMemoryDreamTasks","ots:ListMemoryDreamActions"],aq=["ots:AddMemories","ots:UpdateMemory","ots:DeleteMemory","ots:ApplyMemoryDreamActions","ots:CreateMemoryDreamTask","ots:CancelMemoryDreamTask"],ar=["ots:CreateMemoryStore","ots:DeleteMemoryStore","ots:UpdateMemoryStore"];function as(a,b){return"knowledgebase"===a?"read"===b?am:"write"===b?an:ao:"read"===b?ap:"write"===b?aq:ar}[...am,...an,...ao],[...ap,...aq,...ar];let at={read:"apiKeys.operations.read",write:"apiKeys.operations.write",manage:"apiKeys.operations.manage"},au={knowledgebase:{read:"apiKeys.operations.knowledgeBaseReadDesc",write:"apiKeys.operations.knowledgeBaseWriteDesc",manage:"apiKeys.operations.knowledgeBaseManageDesc"},memorystore:{read:"apiKeys.operations.memoryStoreReadDesc",write:"apiKeys.operations.memoryStoreWriteDesc",manage:"apiKeys.operations.memoryStoreManageDesc"}};function av(a){return[a.appId??"",a.tenantId??"",a.agentId??"",a.runId??""].join("|")}function aw({open:a,onOpenChange:d,onSave:e,initial:f}){let{t:g}=(0,v.useI18n)(),[i,j]=(0,c.useState)(f?.resourceType??"knowledgebase"),[k,l]=(0,c.useState)(f?.resourceName??"*"),[n,p]=(0,c.useState)(new Set(f?.operationGroups??["read"])),[q,r]=(0,c.useState)(f?.scope??{}),[s,t]=(0,c.useState)(f?.condition?.sourceIp?.join(", ")??""),[u,w]=(0,c.useState)(!!(f?.scope&&(f.scope.appId||f.scope.tenantId||f.scope.agentId||f.scope.runId))),[x,y]=(0,c.useState)("manual"),{data:z}=(0,aj.useKnowledgeBases)(),{data:A}=(0,ak.useMemoryStores)(),B=a&&"memorystore"===i&&"*"!==k&&u,{data:C,isLoading:D}=(0,M.useQuery)({queryKey:["memory-store-scopes-for-rule",k],queryFn:()=>(0,al.listMemoryStoreScopesUnfiltered)(k),enabled:B,staleTime:3e4}),E=C?.items??[];(0,c.useEffect)(()=>{a&&(j(f?.resourceType??"knowledgebase"),l(f?.resourceName??"*"),p(new Set(f?.operationGroups??["read"])),r(f?.scope??{}),t(f?.condition?.sourceIp?.join(", ")??""),w(!!(f?.scope&&(f.scope.appId||f.scope.tenantId||f.scope.agentId||f.scope.runId))),y("manual"))},[a,f]);let F="knowledgebase"===i?(z?.items??[]).map(a=>a.knowledgeBaseName):(A?.items??[]).map(a=>a.memoryStoreName);return(0,b.jsx)(V.Dialog,{open:a,onOpenChange:d,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,b.jsx)(V.DialogHeader,{children:(0,b.jsx)(V.DialogTitle,{children:f?g("apiKeys.rule.editTitle"):g("apiKeys.rule.addTitle")})}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.resourceType")}),(0,b.jsxs)(ai.Select,{value:i,onValueChange:a=>{j(a),l("*"),w(!1),r({})},children:[(0,b.jsx)(ai.SelectTrigger,{children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsxs)(ai.SelectContent,{children:[(0,b.jsx)(ai.SelectItem,{value:"knowledgebase",children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(m.BookOpen,{className:"h-3.5 w-3.5"}),g("common.knowledgeBase")]})}),(0,b.jsx)(ai.SelectItem,{value:"memorystore",children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(af.Brain,{className:"h-3.5 w-3.5"}),g("common.memory")]})})]})]})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.resourceName")}),(0,b.jsxs)(ai.Select,{value:k,onValueChange:a=>{l(a),w(!1),r({})},children:[(0,b.jsx)(ai.SelectTrigger,{children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsxs)(ai.SelectContent,{children:[(0,b.jsx)(ai.SelectItem,{value:"*",children:g("apiKeys.rule.allResource",{resource:"knowledgebase"===i?g("common.knowledgeBase"):g("common.memory")})}),F.map(a=>(0,b.jsx)(ai.SelectItem,{value:a,children:a},a))]})]})]}),"memorystore"===i&&"*"!==k&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(X.Checkbox,{checked:u,onCheckedChange:a=>{w(!!a),a||r({})}}),(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.scopeConfig")})]}),u&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(h.Button,{variant:"select"===x?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>y("select"),children:g("apiKeys.rule.selectFromExisting")}),(0,b.jsx)(h.Button,{variant:"manual"===x?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>y("manual"),children:g("apiKeys.rule.manualInput")})]}),"select"===x?(0,b.jsx)("div",{className:"rounded-md border border-[hsl(var(--border))] p-3 space-y-1.5",children:D?(0,b.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,b.jsx)(o.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),g("apiKeys.rule.loadingScopes")]}):0===E.length?(0,b.jsx)("p",{className:"py-2 text-xs text-muted-foreground",children:g("apiKeys.rule.noScopes")}):(0,b.jsx)("div",{className:"max-h-40 overflow-y-auto space-y-1",children:E.map(a=>{let c,d=av(a),e=av(q)===d;return(0,b.jsxs)("label",{className:`flex items-center gap-2 rounded px-2 py-1.5 cursor-pointer hover:bg-muted/50 ${e?"bg-muted":""}`,children:[(0,b.jsx)(X.Checkbox,{checked:e,onCheckedChange:()=>{if(e)r({});else r({appId:a.appId||void 0,tenantId:a.tenantId||void 0,agentId:a.agentId||void 0,runId:a.runId||void 0})}}),(0,b.jsx)("span",{className:"text-xs font-mono truncate",children:(c=[],a.appId&&c.push(`app:${a.appId}`),a.tenantId&&c.push(`tenant:${a.tenantId}`),a.agentId&&c.push(`agent:${a.agentId}`),a.runId&&c.push(`${g("memory.scopeField.run")}:${a.runId}`),c.join(", "))})]},d)})})}):(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-2 rounded-md border border-[hsl(var(--border))] p-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:"App ID"}),(0,b.jsx)(T.Input,{value:q.appId??"",onChange:a=>r(b=>({...b,appId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:"Tenant ID"}),(0,b.jsx)(T.Input,{value:q.tenantId??"",onChange:a=>r(b=>({...b,tenantId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:"Agent ID"}),(0,b.jsx)(T.Input,{value:q.agentId??"",onChange:a=>r(b=>({...b,agentId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:g("apiKeys.rule.sessionId")}),(0,b.jsx)(T.Input,{value:q.runId??"",onChange:a=>r(b=>({...b,runId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]})]})]})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.operationPermission")}),(0,b.jsx)("div",{className:"space-y-2",children:["read","write","manage"].map(a=>{let c;return(0,b.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-[hsl(var(--border))] px-3 py-2 cursor-pointer hover:bg-muted/30",children:[(0,b.jsx)(X.Checkbox,{checked:n.has(a),onCheckedChange:()=>{p(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},className:"mt-0.5"}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("div",{className:"text-sm font-medium",children:g(at[a])}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:(c=au[i]?.[a])?g(c):null}),(0,b.jsx)("div",{className:"mt-1 text-[11px] text-muted-foreground/60",children:as(i,a).map(a=>a.replace("ots:","")).join(", ")})]})]},a)})})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.ipWhitelist")}),(0,b.jsx)(T.Input,{value:s,onChange:a=>t(a.target.value),placeholder:g("apiKeys.rule.ipPlaceholder"),className:"text-xs"}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:g("apiKeys.rule.ipHelp")})]})]}),(0,b.jsxs)(V.DialogFooter,{children:[(0,b.jsx)(h.Button,{variant:"outline",onClick:()=>d(!1),children:g("common.cancel")}),(0,b.jsx)(h.Button,{disabled:0===n.size,onClick:function(){var a;let b=Array.from(n),c=function(a,b){let c=[];for(let d of b)c.push(...as(a,d));return[...new Set(c)]}(i,b),f=s.split(/[,,\s]+/).map(a=>a.trim()).filter(Boolean);e({resourceType:i,resourceName:k,operationGroups:b,actions:c,..."memorystore"===i&&u&&((a=q).appId||a.tenantId||a.agentId||a.runId)?{scope:q}:{},...f.length>0?{condition:{sourceIp:f}}:{}}),d(!1)},children:f?g("apiKeys.rule.saveChanges"):g("apiKeys.rule.add")})]})]})})}let ax={read:"apiKeys.operations.read",write:"apiKeys.operations.write",manage:"apiKeys.operations.manage"};function ay({serviceCredentialId:a,userName:d}){let f,g,{t:j}=(0,v.useI18n)(),{data:k,isLoading:m}=function(a,b){let{context:c,ready:d}=(0,N.useRuntimeContext)();return(0,M.useQuery)({queryKey:L.queryKeys.customPolicy(c.dataScopeKey,a??""),queryFn:()=>G(a,b),enabled:d&&!!a&&!!b,staleTime:15e3})}(a,d),n=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>H(a.serviceCredentialId,{userName:a.userName,rules:a.rules}),onSuccess:()=>{(0,L.invalidateCustomPolicyQueries)(f),(0,L.invalidateApiKeyPolicyQueries)(f),(0,L.invalidateEffectivePermissionsQueries)(f)}})),p=(g=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>K(a.serviceCredentialId,{userName:a.userName}),onSuccess:()=>{(0,L.invalidateCustomPolicyQueries)(g),(0,L.invalidateApiKeyPolicyQueries)(g),(0,L.invalidateEffectivePermissionsQueries)(g)}})),[r,s]=(0,c.useState)([]),[t,u]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)(null);async function C(){try{await n.mutateAsync({serviceCredentialId:a,userName:d,rules:r}),u(!1),l.toast.success(j("apiKeys.customPolicy.saveSuccess"))}catch(a){l.toast.error(a instanceof Error?a.message:j("apiKeys.customPolicy.saveFailed"))}}async function D(){try{await p.mutateAsync({serviceCredentialId:a,userName:d}),s([]),u(!1),l.toast.success(j("apiKeys.customPolicy.deleteSuccess"))}catch(a){l.toast.error(a instanceof Error?a.message:j("apiKeys.customPolicy.deleteFailed"))}}return(0,c.useEffect)(()=>{k&&(s(k.rules),u(!1))},[k]),m?(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(i.Skeleton,{className:"h-8 w-full"}),(0,b.jsx)(i.Skeleton,{className:"h-8 w-full"})]}):(0,b.jsxs)("div",{className:"space-y-3",children:[0===r.length?(0,b.jsx)("p",{className:"py-3 text-center text-sm text-muted-foreground",children:j("apiKeys.customPolicy.empty")}):(0,b.jsx)("div",{className:"space-y-1.5",children:r.map((a,c)=>(0,b.jsx)(az,{rule:a,t:j,onEdit:()=>{B(c),z(!0)},onRemove:()=>{s(a=>a.filter((a,b)=>b!==c)),u(!0)}},c))}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(h.Button,{variant:"outline",size:"sm",className:"h-8",onClick:()=>{B(null),z(!0)},children:[(0,b.jsx)(e.Plus,{className:"mr-1 h-3.5 w-3.5"}),j("apiKeys.customPolicy.addRule")]}),t&&(0,b.jsxs)(h.Button,{size:"sm",className:"h-8",disabled:n.isPending,onClick:C,children:[n.isPending?(0,b.jsx)(o.Loader2,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(ah.Save,{className:"mr-1 h-3.5 w-3.5"}),j("common.save")]}),k&&k.rules.length>0&&(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"h-8 text-destructive hover:text-destructive",disabled:p.isPending,onClick:D,children:[p.isPending?(0,b.jsx)(o.Loader2,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(q.Trash2,{className:"mr-1 h-3.5 w-3.5"}),j("apiKeys.customPolicy.clearAll")]})]}),(0,b.jsx)(aw,{open:y,onOpenChange:z,onSave:function(a){null!==A?(s(b=>{let c=[...b];return c[A]=a,c}),B(null)):s(b=>[...b,a]),u(!0)},initial:null!==A?r[A]:void 0})]})}function az({rule:a,t:c,onEdit:d,onRemove:e}){let f="knowledgebase"===a.resourceType?m.BookOpen:af.Brain,g="knowledgebase"===a.resourceType?c("common.knowledgeBase"):c("common.memory"),i="*"===a.resourceName?c("apiKeys.rule.allResource",{resource:g}):a.resourceName,j="";if(a.scope){let b=[];a.scope.appId&&b.push(`app:${a.scope.appId}`),a.scope.tenantId&&b.push(`tenant:${a.scope.tenantId}`),a.scope.agentId&&b.push(`agent:${a.scope.agentId}`),a.scope.runId&&b.push(`${c("memory.scopeField.run")}:${a.scope.runId}`),b.length>0&&(j=` (${b.join(", ")})`)}return(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-[hsl(var(--border))] px-3 py-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)(f,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,b.jsxs)("span",{className:"truncate text-sm font-medium",children:[i,j&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:j})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[a.operationGroups.map(a=>(0,b.jsx)(t.Badge,{variant:"secondary",className:"text-[10px]",children:ax[a]?c(ax[a]):a},a)),a.condition?.sourceIp&&a.condition.sourceIp.length>0&&(0,b.jsx)(t.Badge,{variant:"outline",className:"text-[10px]",children:c("apiKeys.customPolicy.ipLimit")})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:d,children:(0,b.jsx)(ag.Pencil,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:e,children:(0,b.jsx)(q.Trash2,{className:"h-3.5 w-3.5"})})]})]})}var aA=a.i(53520),aB=a.i(414151);function aC({serviceCredentialId:a,userName:c}){let{t:d}=(0,v.useI18n)(),{data:e,isLoading:f,error:g}=O(a,c);if(f)return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(i.Skeleton,{className:"h-10 w-full"}),(0,b.jsx)(i.Skeleton,{className:"h-10 w-full"}),(0,b.jsx)(i.Skeleton,{className:"h-10 w-full"})]});if(g)return(0,b.jsx)("p",{className:"py-3 text-center text-sm text-destructive",children:d("apiKeys.overview.loadFailed")});if(!e||0===e.resources.length)return(0,b.jsx)("p",{className:"py-3 text-center text-sm text-muted-foreground",children:d("apiKeys.overview.empty")});let h=e.resources.filter(a=>"knowledgebase"===a.resourceType),j=e.resources.filter(a=>"memorystore"===a.resourceType);return(0,b.jsxs)("div",{className:"space-y-4",children:[h.length>0&&(0,b.jsx)(aD,{icon:(0,b.jsx)(m.BookOpen,{className:"h-3.5 w-3.5"}),label:d("common.knowledgeBase"),resources:h}),j.length>0&&(0,b.jsx)(aD,{icon:(0,b.jsx)(af.Brain,{className:"h-3.5 w-3.5"}),label:d("common.memory"),resources:j})]})}function aD({icon:a,label:c,resources:d}){let{t:e}=(0,v.useI18n)();return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[a,c]}),(0,b.jsx)("div",{className:"rounded-md border border-[hsl(var(--border))]",children:(0,b.jsxs)(r.Table,{children:[(0,b.jsx)(r.TableHeader,{children:(0,b.jsxs)(r.TableRow,{children:[(0,b.jsx)(r.TableHead,{className:"text-xs",children:e("apiKeys.overview.name")}),(0,b.jsx)(r.TableHead,{className:"w-16 text-center text-xs",children:e("apiKeys.overview.read")}),(0,b.jsx)(r.TableHead,{className:"w-16 text-center text-xs",children:e("apiKeys.overview.write")}),(0,b.jsx)(r.TableHead,{className:"w-16 text-center text-xs",children:e("apiKeys.overview.manage")})]})}),(0,b.jsx)(r.TableBody,{children:d.map(a=>(0,b.jsxs)(r.TableRow,{children:[(0,b.jsx)(r.TableCell,{className:"py-1.5",children:(0,b.jsx)("code",{className:"font-mono text-xs",children:a.resourceName})}),(0,b.jsx)(r.TableCell,{className:"py-1.5 text-center",children:(0,b.jsx)(aE,{allowed:a.permissions.read})}),(0,b.jsx)(r.TableCell,{className:"py-1.5 text-center",children:(0,b.jsx)(aE,{allowed:a.permissions.write})}),(0,b.jsx)(r.TableCell,{className:"py-1.5 text-center",children:(0,b.jsx)(aE,{allowed:a.permissions.manage})})]},a.resourceName))})]})})]})}function aE({allowed:a}){return a?(0,b.jsx)(aA.Check,{className:"mx-auto h-4 w-4 text-success"}):(0,b.jsx)(aB.X,{className:"mx-auto h-4 w-4 text-muted-foreground/40"})}var aF=a.i(87491),aG=a.i(547259);let aH=["AliyunOTSFullAccess","AliyunOTSReadOnlyAccess","AliyunOTSWriteOnlyAccess"],aI=[{key:"readonly",labelKey:"apiKeys.presets.readonlyLabel",descriptionKey:"apiKeys.presets.readonlyDesc",icon:aF.Eye,attach:["AliyunOTSReadOnlyAccess"]},{key:"full",labelKey:"apiKeys.presets.fullLabel",descriptionKey:"apiKeys.presets.fullDesc",icon:p,attach:["AliyunOTSFullAccess"]}];function aJ({serviceCredentialId:a,userName:d,policies:e}){let{t:f}=(0,v.useI18n)(),g=ab(),i=ac(),[j,k]=(0,c.useState)(null),m=function(a){if(!a)return null;let b=new Set(a.filter(a=>aH.includes(a.policyName)).map(a=>a.policyName));return b.has("AliyunOTSFullAccess")?"full":b.has("AliyunOTSReadOnlyAccess")&&!b.has("AliyunOTSWriteOnlyAccess")?"readonly":null}(e);async function n(b){if(m===b.key)return void await p();k(b.key);try{let c=(e??[]).filter(a=>aH.includes(a.policyName));for(let e of c)b.attach.includes(e.policyName)||await i.mutateAsync({serviceCredentialId:a,userName:d,policyName:e.policyName,policyType:e.policyType});let h=new Set(c.map(a=>a.policyName));for(let c of b.attach)h.has(c)||await g.mutateAsync({serviceCredentialId:a,userName:d,policyName:c,policyType:"System"});l.toast.success(f("apiKeys.presets.applySuccess",{preset:f(b.labelKey)}))}catch(a){l.toast.error(a instanceof Error?a.message:f("apiKeys.presets.applyFailed"))}finally{k(null)}}async function p(){k("cancel");try{for(let b of(e??[]).filter(a=>aH.includes(a.policyName)))await i.mutateAsync({serviceCredentialId:a,userName:d,policyName:b.policyName,policyType:b.policyType});l.toast.success(f("apiKeys.presets.cancelSuccess"))}catch(a){l.toast.error(a instanceof Error?a.message:f("apiKeys.presets.cancelFailed"))}finally{k(null)}}return(0,b.jsx)("div",{className:"grid grid-cols-2 gap-2",children:aI.map(a=>{let c=m===a.key,d=j===a.key,e=a.icon;return(0,b.jsxs)(h.Button,{variant:"outline",className:`relative flex h-auto flex-col items-center gap-1.5 px-3 py-3 text-center ${c?"border-[hsl(var(--primary))] bg-[hsl(var(--primary))/0.06]":""}`,disabled:null!==j,onClick:()=>n(a),children:[d||"cancel"===j&&c?(0,b.jsx)(o.Loader2,{className:"h-5 w-5 animate-spin text-primary"}):c?(0,b.jsx)(aA.Check,{className:"h-5 w-5 text-primary"}):(0,b.jsx)(e,{className:"h-5 w-5 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-xs font-medium",children:f(a.labelKey)}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground leading-tight",children:f(a.descriptionKey)}),c?(0,b.jsx)(aG.Lock,{className:"absolute right-1.5 top-1.5 h-3 w-3 text-primary"}):null]},a.key)})})}function aK({apiKey:a,onClose:c}){let{t:d}=(0,v.useI18n)(),e=!!a,{data:f}=function(a,b){let{context:c,ready:d}=(0,N.useRuntimeContext)();return(0,M.useQuery)({queryKey:L.queryKeys.apiKeyPolicies(c.dataScopeKey,a??""),queryFn:()=>D(a,b),enabled:d&&!!a&&!!b,staleTime:15e3})}(a?.serviceCredentialId,a?.userPrincipalName);async function g(a,b){try{await aa(a),l.toast.success(`${d("common.copied")} ${b}`)}catch{l.toast.error(d("common.copyFailed"))}}let i=a&&Number.isFinite(Date.parse(a.createTime))?Date.parse(a.createTime):null;return(0,b.jsx)(_.Sheet,{open:e,onOpenChange:a=>!a&&c(),children:(0,b.jsxs)(_.SheetContent,{side:"right",className:"w-full max-w-xl overflow-y-auto",children:[(0,b.jsxs)(_.SheetHeader,{children:[(0,b.jsx)(_.SheetTitle,{children:d("apiKeys.detail.title")}),(0,b.jsx)(_.SheetDescription,{children:d("apiKeys.detail.description")})]}),a?(0,b.jsxs)("div",{className:"space-y-5 mt-2",children:[(0,b.jsxs)("section",{className:"space-y-2.5",children:[(0,b.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:d("apiKeys.detail.basicInfo")}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aL,{label:d("apiKeys.detail.credentialId"),children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("code",{className:"break-all font-mono text-xs",children:a.serviceCredentialId}),(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",onClick:()=>g(a.serviceCredentialId,d("apiKeys.detail.credentialId")),children:(0,b.jsx)(Z.Copy,{className:"h-3 w-3"})})]})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.credentialName"),children:(0,b.jsx)("span",{className:"text-sm",children:a.serviceCredentialName})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.status"),children:(0,b.jsx)(t.Badge,{variant:"Active"===a.status?"success":"secondary",children:a.status})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.ramUser"),children:(0,b.jsx)("span",{className:"break-all font-mono text-xs text-muted-foreground",children:a.userPrincipalName})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.createdAt"),children:i?(0,b.jsx)(u.RelativeTime,{timestamp:i}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"})})]})]}),(0,b.jsx)($.Separator,{}),(0,b.jsxs)("section",{className:"space-y-2.5",children:[(0,b.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:d("apiKeys.detail.permissionOverview")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("apiKeys.detail.permissionOverviewDesc")}),(0,b.jsx)(aC,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName})]}),(0,b.jsx)($.Separator,{}),(0,b.jsxs)("section",{className:"space-y-4",children:[(0,b.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:d("apiKeys.detail.permissionConfig")}),(0,b.jsx)(ae,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,policies:f}),(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)("h4",{className:"text-xs font-medium text-foreground",children:d("apiKeys.detail.defaultAuth")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("apiKeys.detail.defaultAuthDesc")}),(0,b.jsx)(aJ,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,policies:f})]}),(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)("h4",{className:"text-xs font-medium text-foreground",children:d("apiKeys.detail.customAuth")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("apiKeys.detail.customAuthDesc")}),(0,b.jsx)(ay,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName})]})]})]}):null]})})}function aL({label:a,children:c}){return(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)(U.Label,{className:"w-20 shrink-0 pt-0.5 text-xs text-muted-foreground",children:a}),(0,b.jsx)("div",{className:"min-w-0 flex-1",children:c})]})}let aM=(0,f.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]),aN={read:"apiKeys.operations.read",write:"apiKeys.operations.write",manage:"apiKeys.operations.manage"};function aO({onFilterResults:a}){let{t:d}=(0,v.useI18n)(),[e,f]=(0,c.useState)(!1),[g,i]=(0,c.useState)("knowledgebase"),[j,k]=(0,c.useState)(""),[l,n]=(0,c.useState)("read"),{data:p}=(0,aj.useKnowledgeBases)(),{data:q}=(0,ak.useMemoryStores)(),r="knowledgebase"===g?(p?.items??[]).map(a=>a.knowledgeBaseName):(q?.items??[]).map(a=>a.memoryStoreName),s=!!j,{data:u,isFetching:w,refetch:x}=(0,M.useQuery)({queryKey:["api-keys-filter-by-permission",g,j,l],queryFn:()=>J({resourceType:g,resourceName:j,operationGroup:l}),enabled:!1});return e?(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-3 space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:d("apiKeys.filter.title")}),(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:function(){f(!1),k(""),a(null)},children:(0,b.jsx)(aB.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,b.jsxs)("div",{className:"space-y-1 min-w-[120px]",children:[(0,b.jsx)("label",{className:"text-[11px] text-muted-foreground",children:d("apiKeys.common.resourceType")}),(0,b.jsxs)(ai.Select,{value:g,onValueChange:b=>{i(b),k(""),a(null)},children:[(0,b.jsx)(ai.SelectTrigger,{className:"h-8 text-xs",children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsxs)(ai.SelectContent,{children:[(0,b.jsx)(ai.SelectItem,{value:"knowledgebase",children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(m.BookOpen,{className:"h-3 w-3"}),d("common.knowledgeBase")]})}),(0,b.jsx)(ai.SelectItem,{value:"memorystore",children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(af.Brain,{className:"h-3 w-3"}),d("common.memory")]})})]})]})]}),(0,b.jsxs)("div",{className:"space-y-1 min-w-[160px] flex-1",children:[(0,b.jsx)("label",{className:"text-[11px] text-muted-foreground",children:d("apiKeys.common.resourceName")}),(0,b.jsxs)(ai.Select,{value:j,onValueChange:b=>{k(b),a(null)},children:[(0,b.jsx)(ai.SelectTrigger,{className:"h-8 text-xs",children:(0,b.jsx)(ai.SelectValue,{placeholder:d("apiKeys.filter.selectResource")})}),(0,b.jsx)(ai.SelectContent,{children:r.map(a=>(0,b.jsx)(ai.SelectItem,{value:a,children:a},a))})]})]}),(0,b.jsxs)("div",{className:"space-y-1 min-w-[100px]",children:[(0,b.jsx)("label",{className:"text-[11px] text-muted-foreground",children:d("apiKeys.common.operationPermission")}),(0,b.jsxs)(ai.Select,{value:l,onValueChange:b=>{n(b),a(null)},children:[(0,b.jsx)(ai.SelectTrigger,{className:"h-8 text-xs",children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsx)(ai.SelectContent,{children:["read","write","manage"].map(a=>(0,b.jsx)(ai.SelectItem,{value:a,children:d(aN[a])},a))})]})]}),(0,b.jsxs)(h.Button,{size:"sm",className:"h-8",disabled:!s||w,onClick:function(){s&&x().then(b=>{b.data&&a(new Set(b.data.apiKeys.map(a=>a.serviceCredentialId)))})},children:[w?(0,b.jsx)(o.Loader2,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(aM,{className:"mr-1.5 h-3.5 w-3.5"}),d("apiKeys.filter.filter")]}),u?(0,b.jsx)(h.Button,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:function(){k(""),a(null)},children:d("common.clearSearch")}):null]}),u?(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[d("apiKeys.filter.resultPrefix")," ",(0,b.jsx)(t.Badge,{variant:"secondary",className:"px-1.5 py-0 text-xs",children:u.apiKeys.length})," ",d("apiKeys.filter.resultSuffix",{resource:"knowledgebase"===g?d("common.knowledgeBase"):d("common.memory"),name:j,operation:d(aN[l])})]}):null]}):(0,b.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>f(!0),children:[(0,b.jsx)(aM,{className:"mr-2 h-3.5 w-3.5"}),d("apiKeys.filter.byPermission")]})}let aP=(0,f.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);function aQ({apiKey:a,onClose:d}){let{t:e}=(0,v.useI18n)(),[f,i]=(0,c.useState)(!1);(0,c.useEffect)(()=>{a&&i(!1)},[a]);let j=!!a;async function k(a,b){try{await aa(a),l.toast.success(`${e("common.copied")} ${b}`)}catch{l.toast.error(e("common.copyFailed"))}}return(0,b.jsx)(V.Dialog,{open:j,onOpenChange:function(a){(a||f)&&(a||d())},children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-lg",onEscapeKeyDown:a=>{f||a.preventDefault()},onPointerDownOutside:a=>{f||a.preventDefault()},children:[(0,b.jsxs)(V.DialogHeader,{children:[(0,b.jsx)(V.DialogTitle,{className:"text-xl",children:e("apiKeys.secret.title")}),(0,b.jsx)(V.DialogDescription,{children:e("apiKeys.secret.description")})]}),a?(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:e("apiKeys.secret.credentialIdLabel")}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 break-all rounded border border-[hsl(var(--border))] bg-muted/40 px-3 py-2 font-mono text-[13px]",children:a.serviceCredentialId}),(0,b.jsx)(h.Button,{variant:"outline",size:"icon",onClick:()=>k(a.serviceCredentialId,e("apiKeys.common.credentialId")),"aria-label":e("apiKeys.secret.copyCredentialId"),children:(0,b.jsx)(Z.Copy,{className:"h-4 w-4"})})]})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:e("apiKeys.secret.secretLabel")}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 break-all rounded border border-[hsl(var(--warning))/0.5] bg-[hsl(var(--warning))/0.06] px-3 py-2 font-mono text-[13px]",children:a.serviceCredentialSecret}),(0,b.jsx)(h.Button,{variant:"outline",size:"icon",onClick:()=>k(a.serviceCredentialSecret,"Secret"),"aria-label":e("apiKeys.secret.copySecret"),children:(0,b.jsx)(Z.Copy,{className:"h-4 w-4"})})]})]}),(0,b.jsxs)(h.Button,{variant:"outline",className:"w-full",onClick:function(){if(!a)return;let b=a.serviceCredentialId.slice(-6),c=new Date().toISOString().replace(/[:.]/g,"-"),d=new Blob([`ServiceCredentialId: ${a.serviceCredentialId}
1
+ module.exports=[722424,a=>{"use strict";var b=a.i(634020),c=a.i(971938),d=a.i(163426),e=a.i(25825),f=a.i(750053);let g=(0,f.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var h=a.i(776192),i=a.i(604395),j=a.i(310215),k=a.i(502482),l=a.i(263265),m=a.i(342210);let n=(0,f.default)("brain-circuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);var o=a.i(881619);let p=(0,f.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var q=a.i(655295),r=a.i(223301),s=a.i(674024),t=a.i(521989),u=a.i(865271),v=a.i(543320),w=a.i(933596),x=a.i(895487),y=a.i(353141);async function z(){return(await (0,y.apiGet)("/api/v1/api-keys")).apiKeys}async function A(a){let b={};return a?.serviceCredentialName&&(b.serviceCredentialName=a.serviceCredentialName),a?.credentialAgeDays&&a.credentialAgeDays>0&&(b.credentialAgeDays=a.credentialAgeDays),(await (0,y.apiPost)("/api/v1/api-keys",Object.keys(b).length>0?b:void 0)).apiKey}async function B(a){await (0,y.apiDelete)(`/api/v1/api-keys/${encodeURIComponent(a.serviceCredentialId)}`,{userPrincipalName:a.userPrincipalName,deleteCustomPolicy:a.deleteCustomPolicy??!0,deleteRamUser:a.deleteRamUser??!0})}async function C(a){await (0,y.apiPatch)(`/api/v1/api-keys/${encodeURIComponent(a.serviceCredentialId)}`,{userPrincipalName:a.userPrincipalName,status:a.status})}async function D(a,b){return(await (0,y.apiGet)(`/api/v1/api-keys/${encodeURIComponent(a)}/policies?userName=${encodeURIComponent(b)}`)).policies}async function E(a,b){await (0,y.apiPost)(`/api/v1/api-keys/${encodeURIComponent(a)}/policies`,b)}async function F(a,b){await (0,y.apiDelete)(`/api/v1/api-keys/${encodeURIComponent(a)}/policies`,b)}async function G(a,b){return(0,y.apiGet)(`/api/v1/api-keys/${encodeURIComponent(a)}/custom-policy?userName=${encodeURIComponent(b)}`)}async function H(a,b){await (0,y.apiPut)(`/api/v1/api-keys/${encodeURIComponent(a)}/custom-policy`,b)}async function I(a,b){return(0,y.apiGet)(`/api/v1/api-keys/${encodeURIComponent(a)}/effective-permissions?userName=${encodeURIComponent(b)}`)}async function J(a){let b=new URLSearchParams({resourceType:a.resourceType,resourceName:a.resourceName,operationGroup:a.operationGroup});return(0,y.apiGet)(`/api/v1/api-keys/filter-by-permission?${b.toString()}`)}async function K(a,b){await (0,y.apiDelete)(`/api/v1/api-keys/${encodeURIComponent(a)}/custom-policy`,b)}var L=a.i(225377),M=a.i(983366),N=a.i(739096);function O(a,b){let{context:c,ready:d}=(0,N.useRuntimeContext)();return(0,M.useQuery)({queryKey:L.queryKeys.effectivePermissions(c.dataScopeKey,a??""),queryFn:()=>I(a,b),enabled:d&&!!a&&!!b,staleTime:15e3})}function P({apiKeys:a,onDelete:c,onDetail:d}){let{t:e}=(0,v.useI18n)();return(0,b.jsx)("div",{className:"rounded-lg border border-[hsl(var(--border))]",children:(0,b.jsxs)(r.Table,{children:[(0,b.jsx)(r.TableHeader,{children:(0,b.jsxs)(r.TableRow,{children:[(0,b.jsx)(r.TableHead,{children:e("apiKeys.table.credentialName")}),(0,b.jsx)(r.TableHead,{className:"w-[8rem]",children:e("apiKeys.table.status")}),(0,b.jsx)(r.TableHead,{children:e("apiKeys.table.accessibleKnowledgeBase")}),(0,b.jsx)(r.TableHead,{children:e("apiKeys.table.accessibleMemoryStore")}),(0,b.jsx)(r.TableHead,{className:"w-[10rem]",children:e("apiKeys.table.createdAt")}),(0,b.jsx)(r.TableHead,{className:"w-[11rem] text-right",children:e("apiKeys.table.actions")})]})}),(0,b.jsx)(r.TableBody,{children:a.map(a=>(0,b.jsx)(Q,{apiKey:a,onDelete:c,onDetail:d},a.serviceCredentialId))})]})})}function Q({apiKey:a,onDelete:d,onDetail:e}){let f,{t:g}=(0,v.useI18n)(),i=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>C(a),onSuccess:()=>{(0,L.invalidateApiKeyQueries)(f)}})),[j,k]=(0,c.useState)(null),m=j??"Active"===a.status,n=Number.isFinite(Date.parse(a.createTime))?Date.parse(a.createTime):null;async function t(b){k(b);try{await i.mutateAsync({serviceCredentialId:a.serviceCredentialId,userPrincipalName:a.userPrincipalName,status:b?"Active":"Inactive"}),l.toast.success(b?g("apiKeys.table.enabled"):g("apiKeys.table.disabled"))}catch(a){k(null),l.toast.error(a instanceof Error?a.message:g("apiKeys.table.operationFailed"))}}return(0,b.jsxs)(r.TableRow,{className:"cursor-pointer",onClick:()=>e(a),children:[(0,b.jsx)(r.TableCell,{children:(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("span",{className:"text-sm font-medium text-foreground",children:a.serviceCredentialName}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:a.userPrincipalName})]})}),(0,b.jsx)(r.TableCell,{onClick:a=>a.stopPropagation(),children:(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)(s.Switch,{checked:m,onCheckedChange:t,disabled:i.isPending,"aria-label":m?g("apiKeys.table.disable"):g("apiKeys.table.enable")}),(0,b.jsx)("span",{className:m?"text-xs font-medium text-success":"text-xs font-medium text-muted-foreground",children:i.isPending?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,b.jsx)(o.Loader2,{className:"h-3 w-3 animate-spin"}),g("apiKeys.table.toggling")]}):m?g("apiKeys.table.statusActive"):g("apiKeys.table.statusInactive")})]})}),(0,b.jsx)(r.TableCell,{onClick:a=>a.stopPropagation(),children:(0,b.jsx)(R,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,resourceType:"knowledgebase"})}),(0,b.jsx)(r.TableCell,{onClick:a=>a.stopPropagation(),children:(0,b.jsx)(R,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,resourceType:"memorystore"})}),(0,b.jsx)(r.TableCell,{children:n?(0,b.jsx)(u.RelativeTime,{timestamp:n}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"})}),(0,b.jsxs)(r.TableCell,{className:"text-right",children:[(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"h-8",onClick:b=>{b.stopPropagation(),e(a)},children:[(0,b.jsx)(p,{className:"mr-1 h-3.5 w-3.5"}),g("apiKeys.table.permission")]}),(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:`h-8 text-[hsl(var(--destructive))] hover:bg-[hsl(var(--destructive))/0.08] hover:text-[hsl(var(--destructive))] ${m?"opacity-50 cursor-not-allowed":""}`,onClick:b=>{b.stopPropagation(),m?l.toast.info(g("apiKeys.table.disableBeforeDelete")):d(a)},children:[(0,b.jsx)(q.Trash2,{className:"mr-1 h-3.5 w-3.5"}),g("common.delete")]})]})]})}function R({serviceCredentialId:a,userName:c,resourceType:d}){let{t:e}=(0,v.useI18n)(),{data:f,isLoading:g,isError:h}=O(a,c);if(g)return(0,b.jsx)(o.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"});if(h)return(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"});let i=(f?.resources?.filter(a=>a.resourceType===d)??[]).filter(a=>a.permissions.read||a.permissions.write||a.permissions.manage);if(0===i.length)return(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:e("apiKeys.table.none")});let j="knowledgebase"===d?m.BookOpen:n;return(0,b.jsx)("div",{className:"flex flex-wrap gap-1",children:i.map(a=>(0,b.jsxs)(t.Badge,{variant:"secondary",className:"gap-1 text-[11px] font-normal",children:[(0,b.jsx)(j,{className:"h-3 w-3"}),a.resourceName]},a.resourceName))})}var S=a.i(637102),T=a.i(172518),U=a.i(962491),V=a.i(843836);function W({open:a,onOpenChange:d,onCreated:e}){let f,{t:g}=(0,v.useI18n)(),i=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>A(a),onSuccess:()=>{(0,L.invalidateApiKeyQueries)(f)}})),[j,k]=(0,c.useState)(""),[m,n]=(0,c.useState)("");async function o(){let a=j.trim();if(!a)return void l.toast.error(g("apiKeys.create.nameRequired"));let b=m?Number(m):void 0;if(void 0!==b&&(b<1||b>365||!Number.isInteger(b)))return void l.toast.error(g("apiKeys.create.ageDaysInvalid"));try{let c=await i.mutateAsync({serviceCredentialName:a,credentialAgeDays:b});d(!1),e(c)}catch(a){l.toast.error(a instanceof Error?a.message:g("apiKeys.create.createFailed"))}}return(0,c.useEffect)(()=>{a&&(k("ots_apikey_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,6)),n(""))},[a]),(0,b.jsx)(V.Dialog,{open:a,onOpenChange:a=>{d(a)},children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsx)(V.DialogHeader,{children:(0,b.jsx)(V.DialogTitle,{className:"text-xl",children:g("apiKeys.create.title")})}),(0,b.jsxs)("div",{className:"space-y-3 py-1 text-sm leading-relaxed text-muted-foreground",children:[(0,b.jsxs)("p",{children:[g("apiKeys.create.introPrefix"),(0,b.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"ots.aliyuncs.com"}),g("apiKeys.create.introSuffix")]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-foreground",children:g("apiKeys.create.credentialName")}),(0,b.jsx)(T.Input,{value:j,onChange:a=>k(a.target.value),placeholder:g("apiKeys.create.credentialNamePlaceholder"),className:"h-9"}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:g("apiKeys.create.credentialNameHelp")})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-foreground",children:g("apiKeys.create.ageDays")}),(0,b.jsx)(T.Input,{type:"number",min:1,max:365,value:m,onChange:a=>n(a.target.value),placeholder:g("apiKeys.create.ageDaysPlaceholder"),className:"h-9"}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:g("apiKeys.create.ageDaysHelp")})]}),(0,b.jsx)("div",{className:"rounded-md border border-[hsl(var(--warning))/0.5] bg-[hsl(var(--warning))/0.08] px-4 py-3 text-sm",children:(0,b.jsxs)("p",{className:"text-foreground",children:[(0,b.jsx)(S.AlertTriangle,{className:"mr-1 -mt-0.5 inline h-4 w-4 text-warning"}),g("apiKeys.create.secretWarning")]})})]}),(0,b.jsxs)(V.DialogFooter,{children:[(0,b.jsx)(h.Button,{variant:"outline",onClick:()=>d(!1),disabled:i.isPending,children:g("common.cancel")}),(0,b.jsx)(h.Button,{onClick:o,disabled:i.isPending,children:i.isPending?g("common.creating"):g("apiKeys.create.confirm")})]})]})})}var X=a.i(36890);function Y({apiKey:a,open:d,onOpenChange:e}){let f,{t:g}=(0,v.useI18n)(),i=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>B(a),onSuccess:()=>{(0,L.invalidateApiKeyQueries)(f)}})),[j,k]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!0);async function o(){if(a)try{await i.mutateAsync({serviceCredentialId:a.serviceCredentialId,userPrincipalName:a.userPrincipalName,deleteCustomPolicy:j,deleteRamUser:m}),l.toast.success(g("apiKeys.delete.deleteSuccess")),e(!1)}catch(a){l.toast.error(a instanceof Error?a.message:g("apiKeys.delete.deleteFailed"))}}return(0,c.useEffect)(()=>{d&&(k(!0),n(!0))},[d]),(0,b.jsx)(V.Dialog,{open:d,onOpenChange:e,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsx)(V.DialogHeader,{children:(0,b.jsx)(V.DialogTitle,{className:"text-xl",children:g("apiKeys.delete.title")})}),(0,b.jsxs)("div",{className:"rounded-md border border-[hsl(var(--destructive))] bg-[hsl(var(--destructive))/0.06] px-4 py-3 text-sm leading-relaxed",children:[(0,b.jsxs)("p",{children:[(0,b.jsx)(S.AlertTriangle,{className:"mr-1 -mt-0.5 inline h-4 w-4 text-destructive"}),g("apiKeys.delete.warning")]}),a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"mt-3",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:g("apiKeys.delete.credentialNameLabel")}),(0,b.jsx)("code",{className:"font-mono text-xs",children:a.serviceCredentialName})]}),"Active"===a.status?(0,b.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("apiKeys.delete.activeHint")}):null]}):null]}),(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g("apiKeys.delete.cleanupHint")}),(0,b.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,b.jsx)(X.Checkbox,{checked:j,onCheckedChange:a=>k(!!a),className:"mt-0.5"}),(0,b.jsxs)("div",{children:[(0,b.jsx)(U.Label,{className:"text-sm cursor-pointer",children:g("apiKeys.delete.deleteCustomPolicy")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g("apiKeys.delete.deleteCustomPolicyDesc")})]})]}),(0,b.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,b.jsx)(X.Checkbox,{checked:m,onCheckedChange:a=>n(!!a),className:"mt-0.5"}),(0,b.jsxs)("div",{children:[(0,b.jsx)(U.Label,{className:"text-sm cursor-pointer",children:g("apiKeys.delete.deleteRamUser")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g("apiKeys.delete.deleteRamUserDesc")})]})]})]}),(0,b.jsxs)(V.DialogFooter,{children:[(0,b.jsx)(h.Button,{variant:"outline",onClick:()=>e(!1),disabled:i.isPending,children:g("common.cancel")}),(0,b.jsx)(h.Button,{variant:"destructive",disabled:i.isPending,onClick:o,children:i.isPending?g("common.deleting"):g("apiKeys.delete.confirm")})]})]})})}var Z=a.i(16772),$=a.i(770550),_=a.i(109734),aa=a.i(383530);function ab(){let a=(0,x.useQueryClient)();return(0,w.useMutation)({mutationFn:a=>E(a.serviceCredentialId,{userName:a.userName,policyName:a.policyName,policyType:a.policyType}),onSuccess:()=>{(0,L.invalidateApiKeyPolicyQueries)(a),(0,L.invalidateEffectivePermissionsQueries)(a)}})}function ac(){let a=(0,x.useQueryClient)();return(0,w.useMutation)({mutationFn:a=>F(a.serviceCredentialId,{userName:a.userName,policyName:a.policyName,policyType:a.policyType}),onSuccess:()=>{(0,L.invalidateApiKeyPolicyQueries)(a),(0,L.invalidateEffectivePermissionsQueries)(a)}})}let ad="ts-ots-bearer-token-access";function ae({serviceCredentialId:a,userName:d,policies:e}){let{t:f}=(0,v.useI18n)(),g=ab(),h=ac(),[i,j]=(0,c.useState)(!1),k=e?.some(a=>a.policyName===ad)??!1;async function m(b){j(!0);try{b?(await g.mutateAsync({serviceCredentialId:a,userName:d,policyName:ad,policyType:"Custom"}),l.toast.success(f("apiKeys.bearer.enableSuccess"))):(await h.mutateAsync({serviceCredentialId:a,userName:d,policyName:ad,policyType:"Custom"}),l.toast.success(f("apiKeys.bearer.disableSuccess")))}catch(a){l.toast.error(a instanceof Error?a.message:f("apiKeys.bearer.operationFailed"))}finally{j(!1)}}return(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-[hsl(var(--border))] px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)("div",{className:"text-sm font-medium",children:f("apiKeys.bearer.title")}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:f("apiKeys.bearer.description")})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 shrink-0 ml-3",children:[i?(0,b.jsx)(o.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"}):null,(0,b.jsx)(s.Switch,{checked:k,onCheckedChange:m,disabled:i||!e})]})]})}var af=a.i(147845),ag=a.i(112537),ah=a.i(126211),ai=a.i(663525),aj=a.i(909367),ak=a.i(610220),al=a.i(421347);let am=["ots:DescribeKnowledgeBase","ots:ListKnowledgeBase","ots:GetDocument","ots:ListDocuments","ots:ListChunks","ots:Retrieve"],an=["ots:AddDocuments","ots:UpdateDocument","ots:UpdateChunks","ots:DeleteDocuments","ots:UploadDocuments"],ao=["ots:CreateKnowledgeBase","ots:DeleteKnowledgeBase","ots:UpdateKnowledgeBase"],ap=["ots:GetMemoryStore","ots:ListMemoryStores","ots:SearchMemories","ots:ListMemories","ots:GetMemory","ots:ListMemoryStoreMessages","ots:ListMemoryStoreRequests","ots:ListMemoryStoreScopes","ots:GetMemoryTask","ots:ListMemoryTasks","ots:GetMemoryDreamTask","ots:ListMemoryDreamTasks","ots:ListMemoryDreamActions"],aq=["ots:AddMemories","ots:UpdateMemory","ots:DeleteMemory","ots:ApplyMemoryDreamActions","ots:CreateMemoryDreamTask","ots:CancelMemoryDreamTask"],ar=["ots:CreateMemoryStore","ots:DeleteMemoryStore","ots:UpdateMemoryStore"];function as(a,b){return"knowledgebase"===a?"read"===b?am:"write"===b?an:ao:"read"===b?ap:"write"===b?aq:ar}[...am,...an,...ao],[...ap,...aq,...ar];let at={read:"apiKeys.operations.read",write:"apiKeys.operations.write",manage:"apiKeys.operations.manage"},au={knowledgebase:{read:"apiKeys.operations.knowledgeBaseReadDesc",write:"apiKeys.operations.knowledgeBaseWriteDesc",manage:"apiKeys.operations.knowledgeBaseManageDesc"},memorystore:{read:"apiKeys.operations.memoryStoreReadDesc",write:"apiKeys.operations.memoryStoreWriteDesc",manage:"apiKeys.operations.memoryStoreManageDesc"}};function av(a){return[a.appId??"",a.tenantId??"",a.agentId??"",a.runId??""].join("|")}function aw({open:a,onOpenChange:d,onSave:e,initial:f}){let{t:g}=(0,v.useI18n)(),[i,j]=(0,c.useState)(f?.resourceType??"knowledgebase"),[k,l]=(0,c.useState)(f?.resourceName??"*"),[n,p]=(0,c.useState)(new Set(f?.operationGroups??["read"])),[q,r]=(0,c.useState)(f?.scope??{}),[s,t]=(0,c.useState)(f?.condition?.sourceIp?.join(", ")??""),[u,w]=(0,c.useState)(!!(f?.scope&&(f.scope.appId||f.scope.tenantId||f.scope.agentId||f.scope.runId))),[x,y]=(0,c.useState)("manual"),{data:z}=(0,aj.useKnowledgeBases)(),{data:A}=(0,ak.useMemoryStores)(),B=a&&"memorystore"===i&&"*"!==k&&u,{data:C,isLoading:D}=(0,M.useQuery)({queryKey:["memory-store-scopes-for-rule",k],queryFn:()=>(0,al.listMemoryStoreScopesUnfiltered)(k),enabled:B,staleTime:3e4}),E=C?.items??[];(0,c.useEffect)(()=>{a&&(j(f?.resourceType??"knowledgebase"),l(f?.resourceName??"*"),p(new Set(f?.operationGroups??["read"])),r(f?.scope??{}),t(f?.condition?.sourceIp?.join(", ")??""),w(!!(f?.scope&&(f.scope.appId||f.scope.tenantId||f.scope.agentId||f.scope.runId))),y("manual"))},[a,f]);let F="knowledgebase"===i?(z?.items??[]).map(a=>a.knowledgeBaseName):(A?.items??[]).map(a=>a.memoryStoreName);return(0,b.jsx)(V.Dialog,{open:a,onOpenChange:d,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,b.jsx)(V.DialogHeader,{children:(0,b.jsx)(V.DialogTitle,{children:f?g("apiKeys.rule.editTitle"):g("apiKeys.rule.addTitle")})}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.resourceType")}),(0,b.jsxs)(ai.Select,{value:i,onValueChange:a=>{j(a),l("*"),w(!1),r({})},children:[(0,b.jsx)(ai.SelectTrigger,{children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsxs)(ai.SelectContent,{children:[(0,b.jsx)(ai.SelectItem,{value:"knowledgebase",children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(m.BookOpen,{className:"h-3.5 w-3.5"}),g("common.knowledgeBase")]})}),(0,b.jsx)(ai.SelectItem,{value:"memorystore",children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(af.Brain,{className:"h-3.5 w-3.5"}),g("common.memory")]})})]})]})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.resourceName")}),(0,b.jsxs)(ai.Select,{value:k,onValueChange:a=>{l(a),w(!1),r({})},children:[(0,b.jsx)(ai.SelectTrigger,{children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsxs)(ai.SelectContent,{children:[(0,b.jsx)(ai.SelectItem,{value:"*",children:g("apiKeys.rule.allResource",{resource:"knowledgebase"===i?g("common.knowledgeBase"):g("common.memory")})}),F.map(a=>(0,b.jsx)(ai.SelectItem,{value:a,children:a},a))]})]})]}),"memorystore"===i&&"*"!==k&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(X.Checkbox,{checked:u,onCheckedChange:a=>{w(!!a),a||r({})}}),(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.scopeConfig")})]}),u&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(h.Button,{variant:"select"===x?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>y("select"),children:g("apiKeys.rule.selectFromExisting")}),(0,b.jsx)(h.Button,{variant:"manual"===x?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>y("manual"),children:g("apiKeys.rule.manualInput")})]}),"select"===x?(0,b.jsx)("div",{className:"rounded-md border border-[hsl(var(--border))] p-3 space-y-1.5",children:D?(0,b.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,b.jsx)(o.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),g("apiKeys.rule.loadingScopes")]}):0===E.length?(0,b.jsx)("p",{className:"py-2 text-xs text-muted-foreground",children:g("apiKeys.rule.noScopes")}):(0,b.jsx)("div",{className:"max-h-40 overflow-y-auto space-y-1",children:E.map(a=>{let c,d=av(a),e=av(q)===d;return(0,b.jsxs)("label",{className:`flex items-center gap-2 rounded px-2 py-1.5 cursor-pointer hover:bg-muted/50 ${e?"bg-muted":""}`,children:[(0,b.jsx)(X.Checkbox,{checked:e,onCheckedChange:()=>{if(e)r({});else r({appId:a.appId||void 0,tenantId:a.tenantId||void 0,agentId:a.agentId||void 0,runId:a.runId||void 0})}}),(0,b.jsx)("span",{className:"text-xs font-mono truncate",children:(c=[],a.appId&&c.push(`app:${a.appId}`),a.tenantId&&c.push(`tenant:${a.tenantId}`),a.agentId&&c.push(`agent:${a.agentId}`),a.runId&&c.push(`${g("memory.scopeField.run")}:${a.runId}`),c.join(", "))})]},d)})})}):(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-2 rounded-md border border-[hsl(var(--border))] p-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:"App ID"}),(0,b.jsx)(T.Input,{value:q.appId??"",onChange:a=>r(b=>({...b,appId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:"Tenant ID"}),(0,b.jsx)(T.Input,{value:q.tenantId??"",onChange:a=>r(b=>({...b,tenantId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:"Agent ID"}),(0,b.jsx)(T.Input,{value:q.agentId??"",onChange:a=>r(b=>({...b,agentId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(U.Label,{className:"text-[11px] text-muted-foreground",children:g("apiKeys.rule.sessionId")}),(0,b.jsx)(T.Input,{value:q.runId??"",onChange:a=>r(b=>({...b,runId:a.target.value||void 0})),placeholder:g("apiKeys.rule.optional"),className:"h-8 text-xs"})]})]})]})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.operationPermission")}),(0,b.jsx)("div",{className:"space-y-2",children:["read","write","manage"].map(a=>{let c;return(0,b.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-[hsl(var(--border))] px-3 py-2 cursor-pointer hover:bg-muted/30",children:[(0,b.jsx)(X.Checkbox,{checked:n.has(a),onCheckedChange:()=>{p(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},className:"mt-0.5"}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("div",{className:"text-sm font-medium",children:g(at[a])}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:(c=au[i]?.[a])?g(c):null}),(0,b.jsx)("div",{className:"mt-1 text-[11px] text-muted-foreground/60",children:as(i,a).map(a=>a.replace("ots:","")).join(", ")})]})]},a)})})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:g("apiKeys.rule.ipWhitelist")}),(0,b.jsx)(T.Input,{value:s,onChange:a=>t(a.target.value),placeholder:g("apiKeys.rule.ipPlaceholder"),className:"text-xs"}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:g("apiKeys.rule.ipHelp")})]})]}),(0,b.jsxs)(V.DialogFooter,{children:[(0,b.jsx)(h.Button,{variant:"outline",onClick:()=>d(!1),children:g("common.cancel")}),(0,b.jsx)(h.Button,{disabled:0===n.size,onClick:function(){var a;let b=Array.from(n),c=function(a,b){let c=[];for(let d of b)c.push(...as(a,d));return[...new Set(c)]}(i,b),f=s.split(/[,,\s]+/).map(a=>a.trim()).filter(Boolean);e({resourceType:i,resourceName:k,operationGroups:b,actions:c,..."memorystore"===i&&u&&((a=q).appId||a.tenantId||a.agentId||a.runId)?{scope:q}:{},...f.length>0?{condition:{sourceIp:f}}:{}}),d(!1)},children:f?g("apiKeys.rule.saveChanges"):g("apiKeys.rule.add")})]})]})})}let ax={read:"apiKeys.operations.read",write:"apiKeys.operations.write",manage:"apiKeys.operations.manage"};function ay({serviceCredentialId:a,userName:d}){let f,g,{t:j}=(0,v.useI18n)(),{data:k,isLoading:m}=function(a,b){let{context:c,ready:d}=(0,N.useRuntimeContext)();return(0,M.useQuery)({queryKey:L.queryKeys.customPolicy(c.dataScopeKey,a??""),queryFn:()=>G(a,b),enabled:d&&!!a&&!!b,staleTime:15e3})}(a,d),n=(f=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>H(a.serviceCredentialId,{userName:a.userName,rules:a.rules}),onSuccess:()=>{(0,L.invalidateCustomPolicyQueries)(f),(0,L.invalidateApiKeyPolicyQueries)(f),(0,L.invalidateEffectivePermissionsQueries)(f)}})),p=(g=(0,x.useQueryClient)(),(0,w.useMutation)({mutationFn:a=>K(a.serviceCredentialId,{userName:a.userName}),onSuccess:()=>{(0,L.invalidateCustomPolicyQueries)(g),(0,L.invalidateApiKeyPolicyQueries)(g),(0,L.invalidateEffectivePermissionsQueries)(g)}})),[r,s]=(0,c.useState)([]),[t,u]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)(null);async function C(){try{await n.mutateAsync({serviceCredentialId:a,userName:d,rules:r}),u(!1),l.toast.success(j("apiKeys.customPolicy.saveSuccess"))}catch(a){l.toast.error(a instanceof Error?a.message:j("apiKeys.customPolicy.saveFailed"))}}async function D(){try{await p.mutateAsync({serviceCredentialId:a,userName:d}),s([]),u(!1),l.toast.success(j("apiKeys.customPolicy.deleteSuccess"))}catch(a){l.toast.error(a instanceof Error?a.message:j("apiKeys.customPolicy.deleteFailed"))}}return(0,c.useEffect)(()=>{k&&(s(k.rules),u(!1))},[k]),m?(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(i.Skeleton,{className:"h-8 w-full"}),(0,b.jsx)(i.Skeleton,{className:"h-8 w-full"})]}):(0,b.jsxs)("div",{className:"space-y-3",children:[0===r.length?(0,b.jsx)("p",{className:"py-3 text-center text-sm text-muted-foreground",children:j("apiKeys.customPolicy.empty")}):(0,b.jsx)("div",{className:"space-y-1.5",children:r.map((a,c)=>(0,b.jsx)(az,{rule:a,t:j,onEdit:()=>{B(c),z(!0)},onRemove:()=>{s(a=>a.filter((a,b)=>b!==c)),u(!0)}},c))}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(h.Button,{variant:"outline",size:"sm",className:"h-8",onClick:()=>{B(null),z(!0)},children:[(0,b.jsx)(e.Plus,{className:"mr-1 h-3.5 w-3.5"}),j("apiKeys.customPolicy.addRule")]}),t&&(0,b.jsxs)(h.Button,{size:"sm",className:"h-8",disabled:n.isPending,onClick:C,children:[n.isPending?(0,b.jsx)(o.Loader2,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(ah.Save,{className:"mr-1 h-3.5 w-3.5"}),j("common.save")]}),k&&k.rules.length>0&&(0,b.jsxs)(h.Button,{variant:"ghost",size:"sm",className:"h-8 text-destructive hover:text-destructive",disabled:p.isPending,onClick:D,children:[p.isPending?(0,b.jsx)(o.Loader2,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(q.Trash2,{className:"mr-1 h-3.5 w-3.5"}),j("apiKeys.customPolicy.clearAll")]})]}),(0,b.jsx)(aw,{open:y,onOpenChange:z,onSave:function(a){null!==A?(s(b=>{let c=[...b];return c[A]=a,c}),B(null)):s(b=>[...b,a]),u(!0)},initial:null!==A?r[A]:void 0})]})}function az({rule:a,t:c,onEdit:d,onRemove:e}){let f="knowledgebase"===a.resourceType?m.BookOpen:af.Brain,g="knowledgebase"===a.resourceType?c("common.knowledgeBase"):c("common.memory"),i="*"===a.resourceName?c("apiKeys.rule.allResource",{resource:g}):a.resourceName,j="";if(a.scope){let b=[];a.scope.appId&&b.push(`app:${a.scope.appId}`),a.scope.tenantId&&b.push(`tenant:${a.scope.tenantId}`),a.scope.agentId&&b.push(`agent:${a.scope.agentId}`),a.scope.runId&&b.push(`${c("memory.scopeField.run")}:${a.scope.runId}`),b.length>0&&(j=` (${b.join(", ")})`)}return(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-[hsl(var(--border))] px-3 py-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)(f,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,b.jsxs)("span",{className:"truncate text-sm font-medium",children:[i,j&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:j})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[a.operationGroups.map(a=>(0,b.jsx)(t.Badge,{variant:"secondary",className:"text-[10px]",children:ax[a]?c(ax[a]):a},a)),a.condition?.sourceIp&&a.condition.sourceIp.length>0&&(0,b.jsx)(t.Badge,{variant:"outline",className:"text-[10px]",children:c("apiKeys.customPolicy.ipLimit")})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:d,children:(0,b.jsx)(ag.Pencil,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:e,children:(0,b.jsx)(q.Trash2,{className:"h-3.5 w-3.5"})})]})]})}var aA=a.i(53520),aB=a.i(414151);function aC({serviceCredentialId:a,userName:c}){let{t:d}=(0,v.useI18n)(),{data:e,isLoading:f,error:g}=O(a,c);if(f)return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(i.Skeleton,{className:"h-10 w-full"}),(0,b.jsx)(i.Skeleton,{className:"h-10 w-full"}),(0,b.jsx)(i.Skeleton,{className:"h-10 w-full"})]});if(g)return(0,b.jsx)("p",{className:"py-3 text-center text-sm text-destructive",children:d("apiKeys.overview.loadFailed")});if(!e||0===e.resources.length)return(0,b.jsx)("p",{className:"py-3 text-center text-sm text-muted-foreground",children:d("apiKeys.overview.empty")});let h=e.resources.filter(a=>"knowledgebase"===a.resourceType),j=e.resources.filter(a=>"memorystore"===a.resourceType);return(0,b.jsxs)("div",{className:"space-y-4",children:[h.length>0&&(0,b.jsx)(aD,{icon:(0,b.jsx)(m.BookOpen,{className:"h-3.5 w-3.5"}),label:d("common.knowledgeBase"),resources:h}),j.length>0&&(0,b.jsx)(aD,{icon:(0,b.jsx)(af.Brain,{className:"h-3.5 w-3.5"}),label:d("common.memory"),resources:j})]})}function aD({icon:a,label:c,resources:d}){let{t:e}=(0,v.useI18n)();return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[a,c]}),(0,b.jsx)("div",{className:"rounded-md border border-[hsl(var(--border))]",children:(0,b.jsxs)(r.Table,{children:[(0,b.jsx)(r.TableHeader,{children:(0,b.jsxs)(r.TableRow,{children:[(0,b.jsx)(r.TableHead,{className:"text-xs",children:e("apiKeys.overview.name")}),(0,b.jsx)(r.TableHead,{className:"w-16 text-center text-xs",children:e("apiKeys.overview.read")}),(0,b.jsx)(r.TableHead,{className:"w-16 text-center text-xs",children:e("apiKeys.overview.write")}),(0,b.jsx)(r.TableHead,{className:"w-16 text-center text-xs",children:e("apiKeys.overview.manage")})]})}),(0,b.jsx)(r.TableBody,{children:d.map(a=>(0,b.jsxs)(r.TableRow,{children:[(0,b.jsx)(r.TableCell,{className:"py-1.5",children:(0,b.jsx)("code",{className:"font-mono text-xs",children:a.resourceName})}),(0,b.jsx)(r.TableCell,{className:"py-1.5 text-center",children:(0,b.jsx)(aE,{allowed:a.permissions.read})}),(0,b.jsx)(r.TableCell,{className:"py-1.5 text-center",children:(0,b.jsx)(aE,{allowed:a.permissions.write})}),(0,b.jsx)(r.TableCell,{className:"py-1.5 text-center",children:(0,b.jsx)(aE,{allowed:a.permissions.manage})})]},a.resourceName))})]})})]})}function aE({allowed:a}){return a?(0,b.jsx)(aA.Check,{className:"mx-auto h-4 w-4 text-success"}):(0,b.jsx)(aB.X,{className:"mx-auto h-4 w-4 text-muted-foreground/40"})}var aF=a.i(87491),aG=a.i(547259);let aH=["AliyunOTSFullAccess","AliyunOTSReadOnlyAccess","AliyunOTSWriteOnlyAccess"],aI=[{key:"readonly",labelKey:"apiKeys.presets.readonlyLabel",descriptionKey:"apiKeys.presets.readonlyDesc",icon:aF.Eye,attach:["AliyunOTSReadOnlyAccess"]},{key:"full",labelKey:"apiKeys.presets.fullLabel",descriptionKey:"apiKeys.presets.fullDesc",icon:p,attach:["AliyunOTSFullAccess"]}];function aJ({serviceCredentialId:a,userName:d,policies:e}){let{t:f}=(0,v.useI18n)(),g=ab(),i=ac(),[j,k]=(0,c.useState)(null),m=function(a){if(!a)return null;let b=new Set(a.filter(a=>aH.includes(a.policyName)).map(a=>a.policyName));return b.has("AliyunOTSFullAccess")?"full":b.has("AliyunOTSReadOnlyAccess")&&!b.has("AliyunOTSWriteOnlyAccess")?"readonly":null}(e);async function n(b){if(m===b.key)return void await p();k(b.key);try{let c=(e??[]).filter(a=>aH.includes(a.policyName));for(let e of c)b.attach.includes(e.policyName)||await i.mutateAsync({serviceCredentialId:a,userName:d,policyName:e.policyName,policyType:e.policyType});let h=new Set(c.map(a=>a.policyName));for(let c of b.attach)h.has(c)||await g.mutateAsync({serviceCredentialId:a,userName:d,policyName:c,policyType:"System"});l.toast.success(f("apiKeys.presets.applySuccess",{preset:f(b.labelKey)}))}catch(a){l.toast.error(a instanceof Error?a.message:f("apiKeys.presets.applyFailed"))}finally{k(null)}}async function p(){k("cancel");try{for(let b of(e??[]).filter(a=>aH.includes(a.policyName)))await i.mutateAsync({serviceCredentialId:a,userName:d,policyName:b.policyName,policyType:b.policyType});l.toast.success(f("apiKeys.presets.cancelSuccess"))}catch(a){l.toast.error(a instanceof Error?a.message:f("apiKeys.presets.cancelFailed"))}finally{k(null)}}return(0,b.jsx)("div",{className:"grid grid-cols-2 gap-2",children:aI.map(a=>{let c=m===a.key,d=j===a.key,e=a.icon;return(0,b.jsxs)(h.Button,{variant:"outline",className:`relative flex h-auto flex-col items-center gap-1.5 px-3 py-3 text-center ${c?"border-[hsl(var(--primary))] bg-[hsl(var(--primary))/0.06]":""}`,disabled:null!==j,onClick:()=>n(a),children:[d||"cancel"===j&&c?(0,b.jsx)(o.Loader2,{className:"h-5 w-5 animate-spin text-primary"}):c?(0,b.jsx)(aA.Check,{className:"h-5 w-5 text-primary"}):(0,b.jsx)(e,{className:"h-5 w-5 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-xs font-medium",children:f(a.labelKey)}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground leading-tight",children:f(a.descriptionKey)}),c?(0,b.jsx)(aG.Lock,{className:"absolute right-1.5 top-1.5 h-3 w-3 text-primary"}):null]},a.key)})})}function aK({apiKey:a,onClose:c}){let{t:d}=(0,v.useI18n)(),e=!!a,{data:f}=function(a,b){let{context:c,ready:d}=(0,N.useRuntimeContext)();return(0,M.useQuery)({queryKey:L.queryKeys.apiKeyPolicies(c.dataScopeKey,a??""),queryFn:()=>D(a,b),enabled:d&&!!a&&!!b,staleTime:15e3})}(a?.serviceCredentialId,a?.userPrincipalName);async function g(a,b){try{await (0,aa.copyToClipboard)(a),l.toast.success(`${d("common.copied")} ${b}`)}catch{l.toast.error(d("common.copyFailed"))}}let i=a&&Number.isFinite(Date.parse(a.createTime))?Date.parse(a.createTime):null;return(0,b.jsx)(_.Sheet,{open:e,onOpenChange:a=>!a&&c(),children:(0,b.jsxs)(_.SheetContent,{side:"right",className:"w-full max-w-xl overflow-y-auto",children:[(0,b.jsxs)(_.SheetHeader,{children:[(0,b.jsx)(_.SheetTitle,{children:d("apiKeys.detail.title")}),(0,b.jsx)(_.SheetDescription,{children:d("apiKeys.detail.description")})]}),a?(0,b.jsxs)("div",{className:"space-y-5 mt-2",children:[(0,b.jsxs)("section",{className:"space-y-2.5",children:[(0,b.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:d("apiKeys.detail.basicInfo")}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aL,{label:d("apiKeys.detail.credentialId"),children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("code",{className:"break-all font-mono text-xs",children:a.serviceCredentialId}),(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",onClick:()=>g(a.serviceCredentialId,d("apiKeys.detail.credentialId")),children:(0,b.jsx)(Z.Copy,{className:"h-3 w-3"})})]})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.credentialName"),children:(0,b.jsx)("span",{className:"text-sm",children:a.serviceCredentialName})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.status"),children:(0,b.jsx)(t.Badge,{variant:"Active"===a.status?"success":"secondary",children:a.status})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.ramUser"),children:(0,b.jsx)("span",{className:"break-all font-mono text-xs text-muted-foreground",children:a.userPrincipalName})}),(0,b.jsx)(aL,{label:d("apiKeys.detail.createdAt"),children:i?(0,b.jsx)(u.RelativeTime,{timestamp:i}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"})})]})]}),(0,b.jsx)($.Separator,{}),(0,b.jsxs)("section",{className:"space-y-2.5",children:[(0,b.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:d("apiKeys.detail.permissionOverview")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("apiKeys.detail.permissionOverviewDesc")}),(0,b.jsx)(aC,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName})]}),(0,b.jsx)($.Separator,{}),(0,b.jsxs)("section",{className:"space-y-4",children:[(0,b.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:d("apiKeys.detail.permissionConfig")}),(0,b.jsx)(ae,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,policies:f}),(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)("h4",{className:"text-xs font-medium text-foreground",children:d("apiKeys.detail.defaultAuth")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("apiKeys.detail.defaultAuthDesc")}),(0,b.jsx)(aJ,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName,policies:f})]}),(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)("h4",{className:"text-xs font-medium text-foreground",children:d("apiKeys.detail.customAuth")}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("apiKeys.detail.customAuthDesc")}),(0,b.jsx)(ay,{serviceCredentialId:a.serviceCredentialId,userName:a.userPrincipalName})]})]})]}):null]})})}function aL({label:a,children:c}){return(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)(U.Label,{className:"w-20 shrink-0 pt-0.5 text-xs text-muted-foreground",children:a}),(0,b.jsx)("div",{className:"min-w-0 flex-1",children:c})]})}let aM=(0,f.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]),aN={read:"apiKeys.operations.read",write:"apiKeys.operations.write",manage:"apiKeys.operations.manage"};function aO({onFilterResults:a}){let{t:d}=(0,v.useI18n)(),[e,f]=(0,c.useState)(!1),[g,i]=(0,c.useState)("knowledgebase"),[j,k]=(0,c.useState)(""),[l,n]=(0,c.useState)("read"),{data:p}=(0,aj.useKnowledgeBases)(),{data:q}=(0,ak.useMemoryStores)(),r="knowledgebase"===g?(p?.items??[]).map(a=>a.knowledgeBaseName):(q?.items??[]).map(a=>a.memoryStoreName),s=!!j,{data:u,isFetching:w,refetch:x}=(0,M.useQuery)({queryKey:["api-keys-filter-by-permission",g,j,l],queryFn:()=>J({resourceType:g,resourceName:j,operationGroup:l}),enabled:!1});return e?(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-3 space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:d("apiKeys.filter.title")}),(0,b.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:function(){f(!1),k(""),a(null)},children:(0,b.jsx)(aB.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,b.jsxs)("div",{className:"space-y-1 min-w-[120px]",children:[(0,b.jsx)("label",{className:"text-[11px] text-muted-foreground",children:d("apiKeys.common.resourceType")}),(0,b.jsxs)(ai.Select,{value:g,onValueChange:b=>{i(b),k(""),a(null)},children:[(0,b.jsx)(ai.SelectTrigger,{className:"h-8 text-xs",children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsxs)(ai.SelectContent,{children:[(0,b.jsx)(ai.SelectItem,{value:"knowledgebase",children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(m.BookOpen,{className:"h-3 w-3"}),d("common.knowledgeBase")]})}),(0,b.jsx)(ai.SelectItem,{value:"memorystore",children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(af.Brain,{className:"h-3 w-3"}),d("common.memory")]})})]})]})]}),(0,b.jsxs)("div",{className:"space-y-1 min-w-[160px] flex-1",children:[(0,b.jsx)("label",{className:"text-[11px] text-muted-foreground",children:d("apiKeys.common.resourceName")}),(0,b.jsxs)(ai.Select,{value:j,onValueChange:b=>{k(b),a(null)},children:[(0,b.jsx)(ai.SelectTrigger,{className:"h-8 text-xs",children:(0,b.jsx)(ai.SelectValue,{placeholder:d("apiKeys.filter.selectResource")})}),(0,b.jsx)(ai.SelectContent,{children:r.map(a=>(0,b.jsx)(ai.SelectItem,{value:a,children:a},a))})]})]}),(0,b.jsxs)("div",{className:"space-y-1 min-w-[100px]",children:[(0,b.jsx)("label",{className:"text-[11px] text-muted-foreground",children:d("apiKeys.common.operationPermission")}),(0,b.jsxs)(ai.Select,{value:l,onValueChange:b=>{n(b),a(null)},children:[(0,b.jsx)(ai.SelectTrigger,{className:"h-8 text-xs",children:(0,b.jsx)(ai.SelectValue,{})}),(0,b.jsx)(ai.SelectContent,{children:["read","write","manage"].map(a=>(0,b.jsx)(ai.SelectItem,{value:a,children:d(aN[a])},a))})]})]}),(0,b.jsxs)(h.Button,{size:"sm",className:"h-8",disabled:!s||w,onClick:function(){s&&x().then(b=>{b.data&&a(new Set(b.data.apiKeys.map(a=>a.serviceCredentialId)))})},children:[w?(0,b.jsx)(o.Loader2,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(aM,{className:"mr-1.5 h-3.5 w-3.5"}),d("apiKeys.filter.filter")]}),u?(0,b.jsx)(h.Button,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:function(){k(""),a(null)},children:d("common.clearSearch")}):null]}),u?(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[d("apiKeys.filter.resultPrefix")," ",(0,b.jsx)(t.Badge,{variant:"secondary",className:"px-1.5 py-0 text-xs",children:u.apiKeys.length})," ",d("apiKeys.filter.resultSuffix",{resource:"knowledgebase"===g?d("common.knowledgeBase"):d("common.memory"),name:j,operation:d(aN[l])})]}):null]}):(0,b.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>f(!0),children:[(0,b.jsx)(aM,{className:"mr-2 h-3.5 w-3.5"}),d("apiKeys.filter.byPermission")]})}let aP=(0,f.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);function aQ({apiKey:a,onClose:d}){let{t:e}=(0,v.useI18n)(),[f,i]=(0,c.useState)(!1);(0,c.useEffect)(()=>{a&&i(!1)},[a]);let j=!!a;async function k(a,b){try{await (0,aa.copyToClipboard)(a),l.toast.success(`${e("common.copied")} ${b}`)}catch{l.toast.error(e("common.copyFailed"))}}return(0,b.jsx)(V.Dialog,{open:j,onOpenChange:function(a){(a||f)&&(a||d())},children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-lg",onEscapeKeyDown:a=>{f||a.preventDefault()},onPointerDownOutside:a=>{f||a.preventDefault()},children:[(0,b.jsxs)(V.DialogHeader,{children:[(0,b.jsx)(V.DialogTitle,{className:"text-xl",children:e("apiKeys.secret.title")}),(0,b.jsx)(V.DialogDescription,{children:e("apiKeys.secret.description")})]}),a?(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:e("apiKeys.secret.credentialIdLabel")}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 break-all rounded border border-[hsl(var(--border))] bg-muted/40 px-3 py-2 font-mono text-[13px]",children:a.serviceCredentialId}),(0,b.jsx)(h.Button,{variant:"outline",size:"icon",onClick:()=>k(a.serviceCredentialId,e("apiKeys.common.credentialId")),"aria-label":e("apiKeys.secret.copyCredentialId"),children:(0,b.jsx)(Z.Copy,{className:"h-4 w-4"})})]})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.Label,{className:"text-xs text-muted-foreground",children:e("apiKeys.secret.secretLabel")}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 break-all rounded border border-[hsl(var(--warning))/0.5] bg-[hsl(var(--warning))/0.06] px-3 py-2 font-mono text-[13px]",children:a.serviceCredentialSecret}),(0,b.jsx)(h.Button,{variant:"outline",size:"icon",onClick:()=>k(a.serviceCredentialSecret,"Secret"),"aria-label":e("apiKeys.secret.copySecret"),children:(0,b.jsx)(Z.Copy,{className:"h-4 w-4"})})]})]}),(0,b.jsxs)(h.Button,{variant:"outline",className:"w-full",onClick:function(){if(!a)return;let b=a.serviceCredentialId.slice(-6),c=new Date().toISOString().replace(/[:.]/g,"-"),d=new Blob([`ServiceCredentialId: ${a.serviceCredentialId}
2
2
  ServiceCredentialSecret: ${a.serviceCredentialSecret}
3
3
  ServiceCredentialName: ${a.serviceCredentialName}
4
4
  ServiceName: ${a.serviceName}
@@ -1,3 +1,3 @@
1
- module.exports=[909598,a=>{"use strict";var b=a.i(634020),c=a.i(971938),d=a.i(412583),e=a.i(880470),f=a.i(263265),g=a.i(700623),h=a.i(637102),i=a.i(776192),j=a.i(604395),k=a.i(843836),l=a.i(887617),m=a.i(324567),n=a.i(865271),o=a.i(983366),p=a.i(421347),q=a.i(225377),r=a.i(739096),s=a.i(80024),t=a.i(933596),u=a.i(895487),v=a.i(1078),w=a.i(36890),x=a.i(663525),y=a.i(350681),z=a.i(109734),A=a.i(223301),B=a.i(434841),C=a.i(726436),D=a.i(364565),E=a.i(543320);let F={ADD:"bg-success-soft text-success",UPDATE:"bg-info-soft text-info",DELETE:"bg-danger-soft text-danger",MERGE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]",NOOP:"bg-muted text-muted-foreground",EMIT_SKILL:"bg-success-soft text-success",EMIT_PROFILE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"};function G({open:a,onOpenChange:c,memoryStoreName:d,selected:e,onConfirm:f,busy:g}){let{t:h}=(0,E.useI18n)(),j={};for(let a of e)j[a.action]=(j[a.action]??0)+1;let l=(j.DELETE??0)>0,m=e.slice(0,6),n=e.length-m.length;return(0,b.jsx)(k.Dialog,{open:a,onOpenChange:c,children:(0,b.jsxs)(k.DialogContent,{className:"max-w-xl",children:[(0,b.jsxs)(k.DialogHeader,{children:[(0,b.jsx)(k.DialogTitle,{children:h("memory.dream.apply.title")}),(0,b.jsxs)(k.DialogDescription,{children:[h("memory.dream.apply.descPrefix")," ",(0,b.jsx)("span",{className:"font-mono",children:d})," ",h("memory.dream.apply.descSuffix",{count:e.length})]})]}),(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)("div",{className:"flex flex-wrap items-center gap-2 rounded border border-[hsl(var(--border-light))] bg-[hsl(var(--muted)/0.3)] p-2",children:Object.keys(j).map(a=>(0,b.jsxs)("span",{className:(0,D.cn)("inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono font-semibold",F[a]??"bg-muted text-muted-foreground"),children:[a," ",(0,b.jsxs)("span",{className:"font-normal opacity-80",children:["×",j[a]]})]},a))}),l&&(0,b.jsx)("p",{className:"rounded border border-[hsl(var(--destructive)/0.3)] bg-danger-soft/40 px-3 py-2 text-xs text-danger",children:h("memory.dream.apply.hasDestructive")}),(0,b.jsxs)("ul",{className:"max-h-72 space-y-1.5 overflow-auto rounded border border-[hsl(var(--border-light))] p-2",children:[m.map(a=>(0,b.jsxs)("li",{className:"flex items-start gap-2 text-xs",children:[(0,b.jsx)("span",{className:(0,D.cn)("mt-0.5 shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",F[a.action]??"bg-muted text-muted-foreground"),children:a.action}),(0,b.jsx)("span",{className:"line-clamp-2 flex-1 text-foreground/85",children:a.newMemory?.text??a.reason??`(${a.actionId.slice(0,12)}…)`})]},a.actionId)),n>0&&(0,b.jsxs)("li",{className:"pt-1 text-center text-[11px] italic text-muted-foreground",children:[(0,b.jsx)(v.Sparkles,{className:"mr-1 inline-block h-3 w-3"}),h("memory.dream.apply.remaining",{count:n})]})]})]}),(0,b.jsxs)(k.DialogFooter,{children:[(0,b.jsx)(i.Button,{variant:"outline",onClick:()=>c(!1),disabled:g,children:h("common.cancel")}),(0,b.jsx)(i.Button,{variant:l?"destructive":"default",onClick:f,disabled:g,children:g?h("memory.dream.apply.applying"):h("memory.dream.apply.confirm",{count:e.length})})]})]})})}let H={proposed:"bg-info-soft text-info",applied:"bg-success-soft text-success",skipped:"bg-muted text-muted-foreground",failed:"bg-danger-soft text-danger"},I={proposed:"memory.actionStatus.proposed",applied:"memory.actionStatus.applied",skipped:"memory.actionStatus.skipped",failed:"memory.actionStatus.failed"},J={ADD:"bg-success-soft text-success",UPDATE:"bg-info-soft text-info",DELETE:"bg-danger-soft text-danger",MERGE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]",NOOP:"bg-muted text-muted-foreground",EMIT_SKILL:"bg-success-soft text-success",EMIT_PROFILE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"};function K({action:a}){return(0,b.jsx)("span",{className:(0,D.cn)("inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono font-semibold",J[a]??"bg-muted text-muted-foreground"),children:a})}function L({action:a,memoryStoreName:c,t:d}){let{action:e,newMemory:f,newExtract:g,targetMemoryId:h,targetScope:i,reason:j}=a;if("EMIT_SKILL"===e||"EMIT_PROFILE"===e)return g?(0,b.jsxs)("span",{className:"line-clamp-2 text-xs",children:[(0,b.jsx)("span",{className:(0,D.cn)("mr-1 rounded px-1 py-px text-[10px] font-medium","EMIT_SKILL"===e?"bg-success-soft text-success":"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"),children:d("EMIT_SKILL"===e?"memory.dream.actions.skill":"memory.dream.actions.profile")}),g.name,g.description&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:[" ","— ",g.description]})]}):(0,b.jsx)("span",{className:"text-muted-foreground",children:"—"});if("ADD"===e||"UPDATE"===e){let a=f?.text;return a?(0,b.jsxs)("span",{className:"line-clamp-2 text-xs",children:["UPDATE"===e&&(0,b.jsx)("span",{className:"mr-1 rounded bg-info-soft px-1 py-px text-[10px] text-info",children:d("memory.dream.actions.new")}),a]}):(0,b.jsx)("span",{className:"text-muted-foreground",children:"—"})}return"NOOP"===e?(0,b.jsx)("span",{className:"line-clamp-2 text-xs italic text-muted-foreground",children:j||d("memory.dream.actions.noop")}):(0,b.jsx)(M,{memoryStoreName:c,memoryId:h,scope:i,verbPrefix:d("DELETE"===e?"memory.dream.actions.delete":"memory.dream.actions.merge"),t:d})}function M({memoryStoreName:a,memoryId:c,scope:d,verbPrefix:e,t:f}){let g=(0,C.useMemoryUnit)(a,c,d);if(!c)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"—"});if(g.isLoading)return(0,b.jsx)(j.Skeleton,{className:"h-3 w-32"});let h=g.data?.memory?.text;return h?(0,b.jsxs)("span",{className:"line-clamp-2 text-xs",children:[(0,b.jsx)("span",{className:"mr-1 rounded bg-warning-soft px-1 py-px text-[10px] text-warning",children:e}),h]}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:f("memory.dream.actions.memoryUnreadable",{verb:e})})}function N({status:a,t:c}){let d=I[a];return(0,b.jsx)("span",{className:(0,D.cn)("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium select-none whitespace-nowrap",H[a]??"bg-muted text-muted-foreground"),children:d?c(d):a})}function O(a){return a&&[a.appId,a.tenantId,a.agentId,a.runId].filter(Boolean).join(" / ")||"-"}function P({memoryStoreName:a,dreamId:e,taskType:g,artifactWikiHref:h}){let k,{t:l}=(0,E.useI18n)(),m=(0,c.useMemo)(()=>[{value:"all",label:l("memory.dream.actions.allStatus")},{value:"proposed",label:l("memory.actionStatus.proposed")},{value:"applied",label:l("memory.actionStatus.applied")},{value:"skipped",label:l("memory.actionStatus.skipped")},{value:"failed",label:l("memory.actionStatus.failed")}],[l]),n=(0,c.useMemo)(()=>[{value:"all",label:l("memory.dream.actions.allTypes")},{value:"ADD",label:"ADD"},{value:"UPDATE",label:"UPDATE"},{value:"DELETE",label:"DELETE"},{value:"MERGE",label:"MERGE"},{value:"NOOP",label:"NOOP"},{value:"EMIT_SKILL",label:"EMIT_SKILL"},{value:"EMIT_PROFILE",label:"EMIT_PROFILE"}],[l]),s=(0,c.useMemo)(()=>[{value:"created_at_asc",label:l("memory.dream.actions.orderCreatedAsc")},{value:"created_at_desc",label:l("memory.dream.actions.orderCreatedDesc")},{value:"confidence_desc",label:l("memory.dream.actions.orderConfidenceDesc")}],[l]),C="skill"===g||"profile"===g,[D,F]=(0,c.useState)("all"),[H,I]=(0,c.useState)("all"),[J,M]=(0,c.useState)("created_at_asc"),[Q,S]=(0,c.useState)(0),T=function(a,b,c,d){let{context:e,ready:f}=(0,r.useRuntimeContext)();return(0,o.useQuery)({queryKey:q.queryKeys.dreamActions(e.dataScopeKey,a,b,c,d?.nextToken,d?.limit),queryFn:()=>(0,p.listDreamActions)(a,b,c,d),enabled:f&&!!a&&!!b})}(a,e,(0,c.useMemo)(()=>{let a={orderBy:J};return"all"!==D&&(a.status=D),"all"!==H&&(a.action=H),Q>0&&(a.minConfidence=Q),a},[D,H,J,Q]),{limit:100}),U=T.data?.items??[],[V,W]=(0,c.useState)(new Set),[X,Y]=(0,c.useState)(null),[Z,$]=(0,c.useState)(!1),_=(k=(0,u.useQueryClient)(),(0,t.useMutation)({mutationFn:({actionIds:b,applier:c})=>(0,p.applyDreamActions)(a,e,b,c),onSuccess:()=>{k.invalidateQueries({queryKey:["memory"],predicate:b=>Array.isArray(b.queryKey)&&b.queryKey.includes(a)&&b.queryKey.includes(e)}),k.invalidateQueries({queryKey:["memory"],predicate:b=>Array.isArray(b.queryKey)&&b.queryKey.includes(a)&&(b.queryKey.includes("units")||b.queryKey.includes("scopes"))})}})),aa=a=>"proposed"===a.status&&"EMIT_SKILL"!==a.action&&"EMIT_PROFILE"!==a.action,ab=U.filter(aa).length,ac=ab>0&&U.every(a=>!aa(a)||V.has(a.actionId)),ad=async()=>{try{let a=await _.mutateAsync({actionIds:Array.from(V)});f.toast.success(l("memory.dream.actions.applyResult",{applied:a.applied,failed:a.failed})),W(new Set),$(!1)}catch(b){let a=b instanceof Error?b.message:l("memory.dream.actions.applyFailed");f.toast.error(a)}};return(0,b.jsx)(B.TooltipProvider,{children:(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-md border border-[hsl(var(--border-light))] p-3",children:[(0,b.jsxs)(x.Select,{value:D,onValueChange:F,children:[(0,b.jsx)(x.SelectTrigger,{className:"h-8 w-32 text-sm",children:(0,b.jsx)(x.SelectValue,{})}),(0,b.jsx)(x.SelectContent,{children:m.map(a=>(0,b.jsx)(x.SelectItem,{value:a.value,children:a.label},a.value))})]}),!C&&(0,b.jsxs)(x.Select,{value:H,onValueChange:I,children:[(0,b.jsx)(x.SelectTrigger,{className:"h-8 w-32 text-sm",children:(0,b.jsx)(x.SelectValue,{})}),(0,b.jsx)(x.SelectContent,{children:n.map(a=>(0,b.jsx)(x.SelectItem,{value:a.value,children:a.label},a.value))})]}),(0,b.jsxs)(x.Select,{value:J,onValueChange:a=>M(a),children:[(0,b.jsx)(x.SelectTrigger,{className:"h-8 w-32 text-sm",children:(0,b.jsx)(x.SelectValue,{})}),(0,b.jsx)(x.SelectContent,{children:s.map(a=>(0,b.jsx)(x.SelectItem,{value:a.value,children:a.label},a.value))})]}),!C&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:l("memory.dream.actions.minConfidence")}),(0,b.jsx)(y.Slider,{value:[Q],max:1,step:.05,onValueChange:a=>S(a[0]??0),className:"w-32"}),(0,b.jsx)("span",{className:"font-mono text-xs",children:Q.toFixed(2)})]}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:l("memory.dream.actions.selectedCount",{count:V.size})}),(0,b.jsx)(i.Button,{size:"sm",disabled:0===V.size||_.isPending,onClick:()=>$(!0),children:_.isPending?l("memory.dream.actions.applying"):l("memory.dream.actions.applySelected",{count:V.size})})]})]})]}),T.isLoading?(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(j.Skeleton,{className:"h-10 w-full"}),(0,b.jsx)(j.Skeleton,{className:"h-10 w-full"})]}):0===U.length?(0,b.jsxs)("div",{className:"rounded-lg border border-dashed border-[hsl(var(--border))] py-10 text-center text-sm text-muted-foreground",children:[(0,b.jsx)(v.Sparkles,{className:"mx-auto mb-2 h-6 w-6 text-muted-foreground/60"}),C?l("memory.dream.actions.emptyExtract"):l("memory.dream.actions.emptyFiltered")]}):(0,b.jsx)("div",{className:"rounded-lg border border-[hsl(var(--border))]",children:(0,b.jsxs)(A.Table,{children:[(0,b.jsx)(A.TableHeader,{children:(0,b.jsxs)(A.TableRow,{children:[!C&&(0,b.jsx)(A.TableHead,{className:"w-8",children:(0,b.jsx)(w.Checkbox,{checked:ac,onCheckedChange:()=>{ac?W(new Set):W(new Set(U.filter(aa).map(a=>a.actionId)))},disabled:0===ab,"aria-label":l("memory.dream.actions.selectAll")})}),(0,b.jsx)(A.TableHead,{children:C?l("memory.dream.actions.colOutputType"):l("memory.dream.actions.colType")}),(0,b.jsx)(A.TableHead,{children:l("memory.dream.actions.colStatus")}),(0,b.jsx)(A.TableHead,{children:l("memory.common.targetScope")}),(0,b.jsx)(A.TableHead,{children:C?l("memory.dream.actions.colContent"):l("memory.dream.actions.colImpact")}),!C&&(0,b.jsx)(A.TableHead,{className:"text-right",children:l("memory.dream.actions.colConfidence")})]})}),(0,b.jsx)(A.TableBody,{children:U.map(c=>{let e=aa(c),f=h?.(c);return(0,b.jsxs)(A.TableRow,{className:"cursor-pointer hover:bg-[hsl(var(--accent))]",onClick:()=>Y(c),children:[!C&&(0,b.jsx)(A.TableCell,{onClick:a=>a.stopPropagation(),children:e?(0,b.jsx)(w.Checkbox,{checked:V.has(c.actionId),onCheckedChange:()=>{var a;return a=c.actionId,void W(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},"aria-label":l("memory.dream.actions.selectAction")}):(0,b.jsxs)(B.Tooltip,{children:[(0,b.jsx)(B.TooltipTrigger,{asChild:!0,children:(0,b.jsx)("span",{children:(0,b.jsx)(w.Checkbox,{checked:!1,disabled:!0,"aria-label":l("memory.dream.actions.notSelectable")})})}),(0,b.jsx)(B.TooltipContent,{children:l("memory.dream.actions.onlyProposedApply")})]})}),(0,b.jsx)(A.TableCell,{children:(0,b.jsx)(K,{action:c.action})}),(0,b.jsx)(A.TableCell,{children:(0,b.jsx)(N,{status:c.status,t:l})}),(0,b.jsx)(A.TableCell,{className:"text-xs",children:O(c.targetScope)}),(0,b.jsxs)(A.TableCell,{className:"max-w-md",children:[(0,b.jsx)(L,{action:c,memoryStoreName:a,t:l}),f?(0,b.jsx)(d.default,{href:f,className:"mt-1 inline-block text-xs text-primary hover:underline",onClick:a=>a.stopPropagation(),children:l("memory.dream.actions.openInWiki")}):null]}),!C&&(0,b.jsx)(A.TableCell,{className:"text-right font-mono text-xs",children:void 0!==c.confidence?c.confidence.toFixed(2):"-"})]},c.actionId)})})]})}),(0,b.jsx)(z.Sheet,{open:null!==X,onOpenChange:a=>!a&&Y(null),children:(0,b.jsx)(z.SheetContent,{className:"w-[560px] sm:max-w-[560px]",children:X&&(0,b.jsx)(R,{detail:X,memoryStoreName:a,t:l})})}),(0,b.jsx)(G,{open:Z,onOpenChange:$,memoryStoreName:a,selected:U.filter(a=>V.has(a.actionId)),onConfirm:ad,busy:_.isPending})]})})}function Q({detail:a,memoryStoreName:c,t:d}){let e="EMIT_SKILL"===a.action||"EMIT_PROFILE"===a.action,f=!e&&("UPDATE"===a.action||"DELETE"===a.action||"MERGE"===a.action),g=(0,C.useMemoryUnit)(c,f?a.targetMemoryId:void 0,f?a.targetScope:null,f),h=a.newMemory?.text;if(e){let c=a.newExtract;if(!c)return(0,b.jsx)("div",{className:"rounded border border-dashed border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.2)] p-3 text-xs italic text-muted-foreground",children:d("memory.dream.actions.noExtractResult")});let e="EMIT_SKILL"===a.action||"skill"===c.kind;return(0,b.jsxs)("div",{className:"space-y-2 rounded border border-[hsl(var(--border-light))] p-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:(0,D.cn)("rounded px-1.5 py-px text-[10px] font-semibold",e?"bg-success-soft text-success":"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"),children:d(e?"memory.dream.actions.skill":"memory.dream.actions.profile")}),(0,b.jsx)("span",{className:"text-sm font-medium",children:c.name})]}),c.description&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:c.description}),c.instructions&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("memory.dream.actions.instructions")}),(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:c.instructions})]})]})}if("NOOP"===a.action)return(0,b.jsx)("div",{className:"rounded border border-dashed border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.2)] p-3 text-xs italic text-muted-foreground",children:d("memory.dream.actions.noopNoChange")});let i=g.data?.memory?.text,k=g.data?.memory?.unit_type;return(0,b.jsxs)("div",{className:"space-y-3",children:[f&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"rounded bg-warning-soft px-1.5 py-px text-[10px] font-semibold text-warning",children:d("memory.dream.actions.beforeModify")}),d("memory.dream.actions.targetMemory"),k&&(0,b.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["· ",k]})]}),g.isLoading?(0,b.jsx)(j.Skeleton,{className:"h-16 w-full"}):i?(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:i}):(0,b.jsx)("p",{className:"rounded border border-dashed border-[hsl(var(--border))] p-2 text-xs italic text-muted-foreground",children:d("memory.dream.actions.originalUnreadable")})]}),h&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:(0,D.cn)("rounded px-1.5 py-px text-[10px] font-semibold","ADD"===a.action?"bg-success-soft text-success":"bg-info-soft text-info"),children:d("ADD"===a.action?"memory.dream.actions.willAdd":"memory.dream.actions.afterModify")}),d("memory.dream.actions.newMemory"),a.newMemory?.unitType&&(0,b.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["· ",a.newMemory.unitType]})]}),(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:h})]}),"DELETE"===a.action&&(0,b.jsx)("p",{className:"rounded border border-dashed border-[hsl(var(--destructive)/0.3)] bg-danger-soft/40 p-2 text-xs text-danger",children:d("memory.dream.actions.willDelete")}),"MERGE"===a.action&&(0,b.jsx)("p",{className:"rounded border border-dashed border-[hsl(var(--border))] p-2 text-xs text-muted-foreground",children:d("memory.dream.actions.willMerge")})]})}function R({detail:a,memoryStoreName:c,t:d}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(z.SheetHeader,{children:[(0,b.jsxs)(z.SheetTitle,{children:[(0,b.jsx)(K,{action:a.action})," ",d("memory.dream.actions.detailTitle")]}),(0,b.jsx)(z.SheetDescription,{className:"font-mono text-xs break-all",children:a.actionId})]}),(0,b.jsxs)("div",{className:"space-y-4 overflow-auto py-4 text-sm",children:[(0,b.jsx)(Q,{detail:a,memoryStoreName:c,t:d}),(0,b.jsxs)("div",{className:"space-y-2 rounded border border-[hsl(var(--border-light))] p-3",children:[(0,b.jsx)(S,{label:d("memory.dream.actions.detailStatus"),children:(0,b.jsx)(N,{status:a.status,t:d})}),(0,b.jsx)(S,{label:d("memory.dream.actions.detailConfidence"),value:void 0!==a.confidence?a.confidence.toFixed(2):"-"}),(0,b.jsx)(S,{label:d("memory.common.targetScope"),value:O(a.targetScope)}),a.targetMemoryId&&(0,b.jsx)(S,{label:d("memory.dream.actions.detailTargetMemoryId"),value:a.targetMemoryId,mono:!0}),a.resultMemoryId&&(0,b.jsx)(S,{label:d("memory.dream.actions.detailResultMemoryId"),value:a.resultMemoryId,mono:!0})]}),a.reason&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("memory.dream.actions.reason")}),(0,b.jsx)("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:a.reason})]}),a.skippedReason&&(0,b.jsx)(S,{label:d("memory.dream.actions.skippedReason"),value:a.skippedReasonDetail?d("memory.dream.actions.skippedReasonWithDetail",{reason:a.skippedReason,detail:a.skippedReasonDetail}):a.skippedReason}),a.error&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("memory.dream.actions.error")}),(0,b.jsx)("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-danger-soft p-2 text-xs text-danger",children:a.error})]})]})]})}function S({label:a,value:c,mono:d,children:e}){return(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("p",{className:"w-28 shrink-0 text-xs text-muted-foreground",children:a}),e?(0,b.jsx)("div",{children:e}):(0,b.jsx)("p",{className:(0,D.cn)("flex-1 text-sm",d&&"font-mono"),children:c??"-"})]})}var T=a.i(601170),U=a.i(172518),V=a.i(962491);function W(a,b,c){if("awaiting_plan_approval"!==a.status)throw Error(`Dream task must be awaiting_plan_approval; current status is ${a.status}`);if("reject"===b)return{kind:"cancel",dreamId:a.dreamId};if(!a.plan||"string"!=typeof a.plan.summary||""===a.plan.summary.trim()||!Array.isArray(a.plan.deleteMemoryIds)||!a.plan.deleteMemoryIds.every(a=>"string"==typeof a&&""!==a.trim()))throw Error("Dream task does not contain a valid plan");let d=c?.trim()??"";if(""===d)throw Error("Approver is required");return{kind:"approve",dreamId:a.dreamId,approver:d}}function X({memoryStoreName:a,task:d,open:e,onOpenChange:g}){let h,{t:j}=(0,E.useI18n)(),l=(h=(0,u.useQueryClient)(),(0,t.useMutation)({mutationFn:({dreamId:b,approver:c})=>(0,p.approveDreamPlan)(a,b,c),onSuccess:()=>{h.invalidateQueries({queryKey:["memory"],predicate:b=>Array.isArray(b.queryKey)&&b.queryKey.includes("dream-tasks")&&b.queryKey.includes(a)})}})),[m,n]=(0,c.useState)(""),o=a=>{a||n(""),g(a)},q=async()=>{try{let a=W(d,"approve",m);if("approve"!==a.kind)return;await l.mutateAsync({dreamId:a.dreamId,approver:a.approver}),f.toast.success(j("memory.dream.planApprovalSuccess")),o(!1)}catch(a){f.toast.error(a instanceof Error?a.message:j("memory.dream.planApprovalFailed"))}},r=d.plan;return(0,b.jsx)(k.Dialog,{open:e,onOpenChange:o,children:(0,b.jsxs)(k.DialogContent,{className:"max-w-2xl",children:[(0,b.jsxs)(k.DialogHeader,{children:[(0,b.jsx)(k.DialogTitle,{children:j("memory.dream.planApprovalTitle")}),(0,b.jsx)(k.DialogDescription,{children:j("memory.dream.planApprovalDescription")})]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-[hsl(var(--border))] p-3",children:[(0,b.jsx)("h4",{className:"mb-1 text-xs font-semibold uppercase text-muted-foreground",children:j("memory.dream.planSummary")}),(0,b.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:r?.summary})]}),(0,b.jsxs)("section",{className:"rounded-md border border-[hsl(var(--border))] p-3",children:[(0,b.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase text-muted-foreground",children:j("memory.dream.planDeletionWhitelist")}),r?.deleteMemoryIds.length?(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:r.deleteMemoryIds.map(a=>(0,b.jsx)("li",{className:"break-all",children:a},a))}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j("memory.dream.planNoDeletions")})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(V.Label,{htmlFor:"dream-plan-approver",children:j("memory.dream.planApprover")}),(0,b.jsx)(U.Input,{id:"dream-plan-approver",value:m,onChange:a=>n(a.target.value),placeholder:j("memory.dream.planApproverPlaceholder")})]})]}),(0,b.jsxs)(k.DialogFooter,{children:[(0,b.jsx)(i.Button,{variant:"outline",onClick:()=>o(!1),children:j("common.cancel")}),(0,b.jsx)(i.Button,{onClick:q,disabled:l.isPending||""===m.trim(),children:l.isPending?j("memory.dream.planApproving"):j("memory.dream.planApprove")})]})]})})}var Y=a.i(870307);function Z(a,b){var c;let d="EMIT_SKILL"===b.action?"skill":"EMIT_PROFILE"===b.action?"profile":void 0;if("applied"!==b.status||!d||b.newExtract?.kind!==d||![(c=b.targetScope).appId,c.tenantId,c.agentId,c.runId].every(a=>"string"==typeof a&&a.length>0&&"*"!==a))return;let e=new URLSearchParams([["appId",b.targetScope.appId],["tenantId",b.targetScope.tenantId],["agentId",b.targetScope.agentId],["runId",b.targetScope.runId],["dreamId",b.dreamId],["actionId",b.actionId]]);return`/memory/${encodeURIComponent(a)}/wiki?${e.toString()}`}let $={queued:"bg-info-soft text-info",running:"bg-info-soft text-info",planning:"bg-info-soft text-info",awaiting_plan_approval:"bg-warning-soft text-warning",applying:"bg-info-soft text-info",completed:"bg-success-soft text-success",completed_with_failures:"bg-warning-soft text-warning",failed:"bg-danger-soft text-danger",cancelled:"bg-muted text-muted-foreground"},_={queued:"memory.dreamStatus.queued",running:"memory.dreamStatus.running",planning:"memory.dreamStatus.planning",awaiting_plan_approval:"memory.dreamStatus.awaitingPlanApproval",applying:"memory.dreamStatus.applying",completed:"memory.dreamStatus.completed",completed_with_failures:"memory.dreamStatus.completedWithFailures",failed:"memory.dreamStatus.failed",cancelled:"memory.dreamStatus.cancelled"};function aa({status:a,t:c}){let d=!s.DREAM_TERMINAL_STATUSES.has(a),e=_[a];return(0,b.jsxs)("span",{className:(0,D.cn)("inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium select-none whitespace-nowrap",$[a]??"bg-muted text-muted-foreground"),children:[d&&(0,b.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-60"}),(0,b.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),e?c(e):a]})}let ab={memory:"memory.dreamType.consolidate",skill:"memory.dreamType.skill",profile:"memory.dreamType.profile"},ac={memory:"bg-info-soft text-info",skill:"bg-success-soft text-success",profile:"bg-[hsl(var(--primary-soft,_220_90%_96%))] text-[hsl(var(--primary))]"};function ad({label:a,value:c}){return(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"text-base font-semibold tabular-nums",children:c})]})}function ae({label:a,value:c}){return(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{className:"text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"mt-0.5 break-all font-mono text-foreground",children:c??"—"})]})}a.s(["buildDreamArtifactWikiHref",0,Z,"default",0,function(){let a,v,{t:w}=(0,E.useI18n)(),x=(0,e.useParams)(),y=(0,e.useRouter)(),z=decodeURIComponent(x.store),A=decodeURIComponent(x.dreamId),B=function(a,b){let{context:c,ready:d}=(0,r.useRuntimeContext)();return(0,o.useQuery)({queryKey:q.queryKeys.dreamTask(c.dataScopeKey,a,b),queryFn:()=>(0,p.getDreamTask)(a,b),enabled:d&&!!a&&!!b,refetchInterval:a=>{let b=a.state.data;return b?!s.DREAM_TERMINAL_STATUSES.has(b.status)&&5e3:5e3},refetchIntervalInBackground:!1})}(z,A),C=(a=(0,u.useQueryClient)(),(0,t.useMutation)({mutationFn:a=>(0,p.cancelDreamTask)(z,a),onSuccess:()=>{a.invalidateQueries({queryKey:["memory"],predicate:a=>Array.isArray(a.queryKey)&&a.queryKey.includes("dream-tasks")&&a.queryKey.includes(z)})}})),[F,G]=(0,c.useState)(!1),[H,I]=(0,c.useState)(!1),[J,K]=(0,c.useState)(!1),[L,M]=(0,c.useState)(!1);if(B.error instanceof Error&&"code"in B.error&&"DREAMING_DISABLED"===B.error.code)return(0,b.jsx)(T.MemoryDreamDisabled,{});let N=B.data,O=N?.input.scopes??[],Q=1===O.length?(0,Y.toExactScope)(O[0]):null,R=N&&s.DREAM_TERMINAL_STATUSES.has(N.status),S=N?.taskType==="skill"||N?.taskType==="profile",U=N?.status==="awaiting_plan_approval",V=async()=>{try{await C.mutateAsync(A),f.toast.success(w("memory.dream.cancelSuccess")),G(!1)}catch(b){let a=b instanceof Error?b.message:w("memory.dream.cancelFailed");f.toast.error(a)}},$=async()=>{if(N)try{let a=W(N,"reject");if("cancel"!==a.kind)return;await C.mutateAsync(a.dreamId),f.toast.success(w("memory.dream.rejectPlanSuccess")),K(!1)}catch(b){let a=b instanceof Error?b.message:w("memory.dream.rejectPlanFailed");f.toast.error(a)}};return(0,b.jsxs)("div",{className:"space-y-5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(i.Button,{variant:"ghost",size:"sm",onClick:()=>y.push(`/memory/${encodeURIComponent(z)}/dream`),children:[(0,b.jsx)(g.ArrowLeft,{className:"mr-1 h-3.5 w-3.5"}),w("memory.dream.backToTaskList")]}),Q?(0,b.jsx)(i.Button,{asChild:!0,variant:"ghost",size:"sm",children:(0,b.jsxs)(d.default,{href:(0,Y.buildScopeWorkspaceHref)(z,Q),children:[(0,b.jsx)(g.ArrowLeft,{className:"mr-1 h-3.5 w-3.5"}),w("memory.dream.backToScope")]})}):null]}),B.isLoading?(0,b.jsx)(j.Skeleton,{className:"h-32 w-full"}):N?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-5",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("h2",{className:"font-mono text-base",children:N.dreamId}),(v=N.taskType||"memory",(0,b.jsx)("span",{className:(0,D.cn)("inline-flex rounded-full px-2 py-0.5 text-xs font-medium whitespace-nowrap",ac[v]??"bg-muted text-muted-foreground"),children:ab[v]?w(ab[v]):v}))]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)(aa,{status:N.status,t:w}),(!N.taskType||"memory"===N.taskType)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{children:"safe_auto"===N.applyMode?w("memory.dream.applyModeAutoDetail"):"plan"===N.applyMode?w("memory.dream.applyModePlanDetail"):w("memory.dream.applyModeProposalDetail")}),(0,b.jsx)("span",{children:"·"})]}),(0,b.jsx)("span",{children:w("memory.dream.effortDetail",{value:N.effort})}),(!N.taskType||"memory"===N.taskType)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{children:"·"}),(0,b.jsx)("span",{children:w("memory.dream.scopeOutput",{value:"promote_scope"===N.scopeOutputMode?w("memory.dream.scopeOutputPromote"):w("memory.dream.scopeOutputPreserve")})})]}),!R&&(0,b.jsx)("span",{className:"ml-1 italic",children:w("memory.dream.autoRefresh")})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(l.RefreshButton,{onClick:()=>B.refetch(),loading:B.isRefetching}),N.lastError&&(0,b.jsxs)(i.Button,{size:"sm",variant:"outline",onClick:()=>M(!0),className:"text-[hsl(var(--destructive))]",children:[(0,b.jsx)(h.AlertTriangle,{className:"mr-1 h-3.5 w-3.5"}),w("memory.dream.viewError")]}),U&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Button,{size:"sm",onClick:()=>I(!0),children:w("memory.dream.approvePlan")}),(0,b.jsx)(i.Button,{size:"sm",variant:"destructive",onClick:()=>K(!0),disabled:C.isPending,children:w("memory.dream.rejectPlan")})]}),!R&&!U&&(0,b.jsx)(i.Button,{size:"sm",variant:"outline",onClick:()=>G(!0),disabled:C.isPending,children:w("memory.dream.cancelTask")})]})]}),(0,b.jsxs)("div",{className:"mt-5 grid grid-cols-2 gap-4 sm:grid-cols-4",children:[(0,b.jsx)(ad,{label:w("memory.dream.statSessions"),value:N.input.sessionCount}),(0,b.jsx)(ad,{label:w("memory.dream.statMessages"),value:N.input.messageCount}),(!N.taskType||"memory"===N.taskType)&&(0,b.jsx)(ad,{label:w("memory.dream.statMemories"),value:N.input.memoryCount}),(0,b.jsx)(ad,{label:S?w("memory.dream.statOutput"):w("memory.dream.statActionTotal"),value:N.actions.total}),S?(0,b.jsx)(ad,{label:w("memory.dream.statApplied"),value:N.actions.applied}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ad,{label:w("memory.dream.statProposed"),value:N.actions.proposed}),(0,b.jsx)(ad,{label:w("memory.dream.statAppliedShort"),value:N.actions.applied}),(0,b.jsx)(ad,{label:w("memory.dream.statSkipped"),value:N.actions.skipped})]}),N.actions.failed>0&&(0,b.jsx)(ad,{label:w("memory.dream.statFailed"),value:N.actions.failed})]}),(0,b.jsxs)("div",{className:"mt-5 flex flex-wrap gap-x-6 gap-y-1 text-xs text-muted-foreground",children:[(0,b.jsxs)("span",{children:[w("memory.dream.metaCreated"),(0,b.jsx)(n.RelativeTime,{timestamp:new Date(N.createdAt).getTime()})]}),(0,b.jsxs)("span",{children:[w("memory.dream.metaUpdated"),(0,b.jsx)(n.RelativeTime,{timestamp:new Date(N.updatedAt).getTime()})]}),N.finishedAt&&(0,b.jsxs)("span",{children:[w("memory.dream.metaFinished"),(0,b.jsx)(n.RelativeTime,{timestamp:new Date(N.finishedAt).getTime()})]}),N.input.scopes&&N.input.scopes.length>0&&(0,b.jsxs)("span",{children:[w("memory.dream.metaInputScopes"),N.input.scopes.map(a=>[a.appId,a.tenantId,a.agentId,a.runId].filter(Boolean).join(" / ")||"-").slice(0,3).join(" | "),N.input.scopes.length>3&&` +${N.input.scopes.length-3}`]})]})]}),(N.stage||void 0!==N.processedThroughMs||N.plan?.approvedAt||N.plan?.executionExpiresAt)&&(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-4",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:w("memory.dream.publicRuntimeTitle")}),(0,b.jsxs)("dl",{className:"grid gap-3 text-xs sm:grid-cols-2 lg:grid-cols-4",children:[(0,b.jsx)(ae,{label:w("memory.dream.detailStage"),value:N.stage}),(0,b.jsx)(ae,{label:w("memory.dream.detailProcessedThrough"),value:N.processedThroughMs}),(0,b.jsx)(ae,{label:w("memory.dream.detailPlanApproved"),value:N.plan?.approvedAt}),(0,b.jsx)(ae,{label:w("memory.dream.detailExecutionExpires"),value:N.plan?.executionExpiresAt})]})]}),N.plan&&(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-4",children:[(0,b.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:w("memory.dream.planSummary")}),(0,b.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:N.plan.summary}),(0,b.jsx)("h4",{className:"mb-2 mt-4 text-xs font-semibold uppercase text-muted-foreground",children:w("memory.dream.planDeletionWhitelist")}),N.plan.deleteMemoryIds.length>0?(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:N.plan.deleteMemoryIds.map(a=>(0,b.jsx)("li",{className:"break-all",children:a},a))}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:w("memory.dream.planNoDeletions")})]}),N.instructions&&(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-4",children:[(0,b.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:"profile"===N.taskType?w("memory.dream.instructionsProfile"):"skill"===N.taskType?w("memory.dream.instructionsSkill"):w("memory.dream.instructionsMemory")}),(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-3 text-xs",children:N.instructions})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:S?w("memory.dream.resultsExtract"):w("memory.dream.resultsActions")}),(0,b.jsx)(P,{memoryStoreName:z,dreamId:A,taskType:N.taskType,artifactWikiHref:a=>Z(z,a)})]}),(0,b.jsx)(m.ConfirmDialog,{open:F,onOpenChange:G,title:w("memory.dream.cancelConfirmTitle"),description:w("memory.dream.cancelConfirmDesc"),variant:"danger",onConfirm:V}),U&&(0,b.jsx)(X,{memoryStoreName:z,task:N,open:H,onOpenChange:I}),(0,b.jsx)(m.ConfirmDialog,{open:J,onOpenChange:K,title:w("memory.dream.rejectPlanConfirmTitle"),description:w("memory.dream.rejectPlanConfirmDesc"),confirmText:w("memory.dream.rejectPlan"),variant:"danger",onConfirm:$}),(0,b.jsx)(k.Dialog,{open:L,onOpenChange:M,children:(0,b.jsxs)(k.DialogContent,{className:"max-w-2xl",children:[(0,b.jsx)(k.DialogHeader,{children:(0,b.jsx)(k.DialogTitle,{children:w("memory.dream.lastError")})}),(0,b.jsx)("pre",{className:"max-h-96 overflow-auto rounded bg-danger-soft p-3 text-xs text-danger",children:N.lastError})]})})]}):(0,b.jsx)("div",{className:"rounded-lg border border-dashed py-10 text-center text-sm text-muted-foreground",children:w("memory.dream.taskNotFound")})]})}],909598)}];
1
+ module.exports=[909598,a=>{"use strict";var b=a.i(634020),c=a.i(971938),d=a.i(412583),e=a.i(880470),f=a.i(263265),g=a.i(69088),h=a.i(700623),i=a.i(637102),j=a.i(776192),k=a.i(604395),l=a.i(843836),m=a.i(887617),n=a.i(324567),o=a.i(865271),p=a.i(983366),q=a.i(421347),r=a.i(225377),s=a.i(739096),t=a.i(80024),u=a.i(933596),v=a.i(895487),w=a.i(1078),x=a.i(36890),y=a.i(663525),z=a.i(350681),A=a.i(109734),B=a.i(223301),C=a.i(434841),D=a.i(726436),E=a.i(364565),F=a.i(543320);let G={ADD:"bg-success-soft text-success",UPDATE:"bg-info-soft text-info",DELETE:"bg-danger-soft text-danger",MERGE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]",NOOP:"bg-muted text-muted-foreground",EMIT_SKILL:"bg-success-soft text-success",EMIT_PROFILE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"};function H({open:a,onOpenChange:c,memoryStoreName:d,selected:e,onConfirm:f,busy:g}){let{t:h}=(0,F.useI18n)(),i={};for(let a of e)i[a.action]=(i[a.action]??0)+1;let k=(i.DELETE??0)>0,m=e.slice(0,6),n=e.length-m.length;return(0,b.jsx)(l.Dialog,{open:a,onOpenChange:c,children:(0,b.jsxs)(l.DialogContent,{className:"max-w-xl",children:[(0,b.jsxs)(l.DialogHeader,{children:[(0,b.jsx)(l.DialogTitle,{children:h("memory.dream.apply.title")}),(0,b.jsxs)(l.DialogDescription,{children:[h("memory.dream.apply.descPrefix")," ",(0,b.jsx)("span",{className:"font-mono",children:d})," ",h("memory.dream.apply.descSuffix",{count:e.length})]})]}),(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)("div",{className:"flex flex-wrap items-center gap-2 rounded border border-[hsl(var(--border-light))] bg-[hsl(var(--muted)/0.3)] p-2",children:Object.keys(i).map(a=>(0,b.jsxs)("span",{className:(0,E.cn)("inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono font-semibold",G[a]??"bg-muted text-muted-foreground"),children:[a," ",(0,b.jsxs)("span",{className:"font-normal opacity-80",children:["×",i[a]]})]},a))}),k&&(0,b.jsx)("p",{className:"rounded border border-[hsl(var(--destructive)/0.3)] bg-danger-soft/40 px-3 py-2 text-xs text-danger",children:h("memory.dream.apply.hasDestructive")}),(0,b.jsxs)("ul",{className:"max-h-72 space-y-1.5 overflow-auto rounded border border-[hsl(var(--border-light))] p-2",children:[m.map(a=>(0,b.jsxs)("li",{className:"flex items-start gap-2 text-xs",children:[(0,b.jsx)("span",{className:(0,E.cn)("mt-0.5 shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",G[a.action]??"bg-muted text-muted-foreground"),children:a.action}),(0,b.jsx)("span",{className:"line-clamp-2 flex-1 text-foreground/85",children:a.newMemory?.text??a.reason??`(${a.actionId.slice(0,12)}…)`})]},a.actionId)),n>0&&(0,b.jsxs)("li",{className:"pt-1 text-center text-[11px] italic text-muted-foreground",children:[(0,b.jsx)(w.Sparkles,{className:"mr-1 inline-block h-3 w-3"}),h("memory.dream.apply.remaining",{count:n})]})]})]}),(0,b.jsxs)(l.DialogFooter,{children:[(0,b.jsx)(j.Button,{variant:"outline",onClick:()=>c(!1),disabled:g,children:h("common.cancel")}),(0,b.jsx)(j.Button,{variant:k?"destructive":"default",onClick:f,disabled:g,children:g?h("memory.dream.apply.applying"):h("memory.dream.apply.confirm",{count:e.length})})]})]})})}let I={proposed:"bg-info-soft text-info",applied:"bg-success-soft text-success",skipped:"bg-muted text-muted-foreground",failed:"bg-danger-soft text-danger"},J={proposed:"memory.actionStatus.proposed",applied:"memory.actionStatus.applied",skipped:"memory.actionStatus.skipped",failed:"memory.actionStatus.failed"},K={ADD:"bg-success-soft text-success",UPDATE:"bg-info-soft text-info",DELETE:"bg-danger-soft text-danger",MERGE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]",NOOP:"bg-muted text-muted-foreground",EMIT_SKILL:"bg-success-soft text-success",EMIT_PROFILE:"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"};function L({action:a}){return(0,b.jsx)("span",{className:(0,E.cn)("inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono font-semibold",K[a]??"bg-muted text-muted-foreground"),children:a})}function M({action:a,memoryStoreName:c,t:d}){let{action:e,newMemory:f,newExtract:g,targetMemoryId:h,targetScope:i,reason:j}=a;if("EMIT_SKILL"===e||"EMIT_PROFILE"===e)return g?(0,b.jsxs)("span",{className:"line-clamp-2 text-xs",children:[(0,b.jsx)("span",{className:(0,E.cn)("mr-1 rounded px-1 py-px text-[10px] font-medium","EMIT_SKILL"===e?"bg-success-soft text-success":"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"),children:d("EMIT_SKILL"===e?"memory.dream.actions.skill":"memory.dream.actions.profile")}),g.name,g.description&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:[" ","— ",g.description]})]}):(0,b.jsx)("span",{className:"text-muted-foreground",children:"—"});if("ADD"===e||"UPDATE"===e){let a=f?.text;return a?(0,b.jsxs)("span",{className:"line-clamp-2 text-xs",children:["UPDATE"===e&&(0,b.jsx)("span",{className:"mr-1 rounded bg-info-soft px-1 py-px text-[10px] text-info",children:d("memory.dream.actions.new")}),a]}):(0,b.jsx)("span",{className:"text-muted-foreground",children:"—"})}return"NOOP"===e?(0,b.jsx)("span",{className:"line-clamp-2 text-xs italic text-muted-foreground",children:j||d("memory.dream.actions.noop")}):(0,b.jsx)(N,{memoryStoreName:c,memoryId:h,scope:i,verbPrefix:d("DELETE"===e?"memory.dream.actions.delete":"memory.dream.actions.merge"),t:d})}function N({memoryStoreName:a,memoryId:c,scope:d,verbPrefix:e,t:f}){let g=(0,D.useMemoryUnit)(a,c,d);if(!c)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"—"});if(g.isLoading)return(0,b.jsx)(k.Skeleton,{className:"h-3 w-32"});let h=g.data?.memory?.text;return h?(0,b.jsxs)("span",{className:"line-clamp-2 text-xs",children:[(0,b.jsx)("span",{className:"mr-1 rounded bg-warning-soft px-1 py-px text-[10px] text-warning",children:e}),h]}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:f("memory.dream.actions.memoryUnreadable",{verb:e})})}function O({status:a,t:c}){let d=J[a];return(0,b.jsx)("span",{className:(0,E.cn)("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium select-none whitespace-nowrap",I[a]??"bg-muted text-muted-foreground"),children:d?c(d):a})}function P(a){return a&&[a.appId,a.tenantId,a.agentId,a.runId].filter(Boolean).join(" / ")||"-"}function Q({memoryStoreName:a,dreamId:e,taskType:g,artifactWikiHref:h}){let i,{t:l}=(0,F.useI18n)(),m=(0,c.useMemo)(()=>[{value:"all",label:l("memory.dream.actions.allStatus")},{value:"proposed",label:l("memory.actionStatus.proposed")},{value:"applied",label:l("memory.actionStatus.applied")},{value:"skipped",label:l("memory.actionStatus.skipped")},{value:"failed",label:l("memory.actionStatus.failed")}],[l]),n=(0,c.useMemo)(()=>[{value:"all",label:l("memory.dream.actions.allTypes")},{value:"ADD",label:"ADD"},{value:"UPDATE",label:"UPDATE"},{value:"DELETE",label:"DELETE"},{value:"MERGE",label:"MERGE"},{value:"NOOP",label:"NOOP"},{value:"EMIT_SKILL",label:"EMIT_SKILL"},{value:"EMIT_PROFILE",label:"EMIT_PROFILE"}],[l]),o=(0,c.useMemo)(()=>[{value:"created_at_asc",label:l("memory.dream.actions.orderCreatedAsc")},{value:"created_at_desc",label:l("memory.dream.actions.orderCreatedDesc")},{value:"confidence_desc",label:l("memory.dream.actions.orderConfidenceDesc")}],[l]),t="skill"===g||"profile"===g,[D,E]=(0,c.useState)("all"),[G,I]=(0,c.useState)("all"),[J,K]=(0,c.useState)("created_at_asc"),[N,R]=(0,c.useState)(0),T=function(a,b,c,d){let{context:e,ready:f}=(0,s.useRuntimeContext)();return(0,p.useQuery)({queryKey:r.queryKeys.dreamActions(e.dataScopeKey,a,b,c,d?.nextToken,d?.limit),queryFn:()=>(0,q.listDreamActions)(a,b,c,d),enabled:f&&!!a&&!!b})}(a,e,(0,c.useMemo)(()=>{let a={orderBy:J};return"all"!==D&&(a.status=D),"all"!==G&&(a.action=G),N>0&&(a.minConfidence=N),a},[D,G,J,N]),{limit:100}),U=T.data?.items??[],[V,W]=(0,c.useState)(new Set),[X,Y]=(0,c.useState)(null),[Z,$]=(0,c.useState)(!1),_=(i=(0,v.useQueryClient)(),(0,u.useMutation)({mutationFn:({actionIds:b,applier:c})=>(0,q.applyDreamActions)(a,e,b,c),onSuccess:()=>{i.invalidateQueries({queryKey:["memory"],predicate:b=>Array.isArray(b.queryKey)&&b.queryKey.includes(a)&&b.queryKey.includes(e)}),i.invalidateQueries({queryKey:["memory"],predicate:b=>Array.isArray(b.queryKey)&&b.queryKey.includes(a)&&(b.queryKey.includes("units")||b.queryKey.includes("scopes"))})}})),aa=a=>"proposed"===a.status&&"EMIT_SKILL"!==a.action&&"EMIT_PROFILE"!==a.action,ab=U.filter(aa).length,ac=ab>0&&U.every(a=>!aa(a)||V.has(a.actionId)),ad=async()=>{try{let a=await _.mutateAsync({actionIds:Array.from(V)});f.toast.success(l("memory.dream.actions.applyResult",{applied:a.applied,failed:a.failed})),W(new Set),$(!1)}catch(b){let a=b instanceof Error?b.message:l("memory.dream.actions.applyFailed");f.toast.error(a)}};return(0,b.jsx)(C.TooltipProvider,{children:(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-md border border-[hsl(var(--border-light))] p-3",children:[(0,b.jsxs)(y.Select,{value:D,onValueChange:E,children:[(0,b.jsx)(y.SelectTrigger,{className:"h-8 w-32 text-sm",children:(0,b.jsx)(y.SelectValue,{})}),(0,b.jsx)(y.SelectContent,{children:m.map(a=>(0,b.jsx)(y.SelectItem,{value:a.value,children:a.label},a.value))})]}),!t&&(0,b.jsxs)(y.Select,{value:G,onValueChange:I,children:[(0,b.jsx)(y.SelectTrigger,{className:"h-8 w-32 text-sm",children:(0,b.jsx)(y.SelectValue,{})}),(0,b.jsx)(y.SelectContent,{children:n.map(a=>(0,b.jsx)(y.SelectItem,{value:a.value,children:a.label},a.value))})]}),(0,b.jsxs)(y.Select,{value:J,onValueChange:a=>K(a),children:[(0,b.jsx)(y.SelectTrigger,{className:"h-8 w-32 text-sm",children:(0,b.jsx)(y.SelectValue,{})}),(0,b.jsx)(y.SelectContent,{children:o.map(a=>(0,b.jsx)(y.SelectItem,{value:a.value,children:a.label},a.value))})]}),!t&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:l("memory.dream.actions.minConfidence")}),(0,b.jsx)(z.Slider,{value:[N],max:1,step:.05,onValueChange:a=>R(a[0]??0),className:"w-32"}),(0,b.jsx)("span",{className:"font-mono text-xs",children:N.toFixed(2)})]}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:l("memory.dream.actions.selectedCount",{count:V.size})}),(0,b.jsx)(j.Button,{size:"sm",disabled:0===V.size||_.isPending,onClick:()=>$(!0),children:_.isPending?l("memory.dream.actions.applying"):l("memory.dream.actions.applySelected",{count:V.size})})]})]})]}),T.isLoading?(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(k.Skeleton,{className:"h-10 w-full"}),(0,b.jsx)(k.Skeleton,{className:"h-10 w-full"})]}):0===U.length?(0,b.jsxs)("div",{className:"rounded-lg border border-dashed border-[hsl(var(--border))] py-10 text-center text-sm text-muted-foreground",children:[(0,b.jsx)(w.Sparkles,{className:"mx-auto mb-2 h-6 w-6 text-muted-foreground/60"}),t?l("memory.dream.actions.emptyExtract"):l("memory.dream.actions.emptyFiltered")]}):(0,b.jsx)("div",{className:"rounded-lg border border-[hsl(var(--border))]",children:(0,b.jsxs)(B.Table,{children:[(0,b.jsx)(B.TableHeader,{children:(0,b.jsxs)(B.TableRow,{children:[!t&&(0,b.jsx)(B.TableHead,{className:"w-8",children:(0,b.jsx)(x.Checkbox,{checked:ac,onCheckedChange:()=>{ac?W(new Set):W(new Set(U.filter(aa).map(a=>a.actionId)))},disabled:0===ab,"aria-label":l("memory.dream.actions.selectAll")})}),(0,b.jsx)(B.TableHead,{children:t?l("memory.dream.actions.colOutputType"):l("memory.dream.actions.colType")}),(0,b.jsx)(B.TableHead,{children:l("memory.dream.actions.colStatus")}),(0,b.jsx)(B.TableHead,{children:l("memory.common.targetScope")}),(0,b.jsx)(B.TableHead,{children:t?l("memory.dream.actions.colContent"):l("memory.dream.actions.colImpact")}),!t&&(0,b.jsx)(B.TableHead,{className:"text-right",children:l("memory.dream.actions.colConfidence")})]})}),(0,b.jsx)(B.TableBody,{children:U.map(c=>{let e=aa(c),f=h?.(c);return(0,b.jsxs)(B.TableRow,{className:"cursor-pointer hover:bg-[hsl(var(--accent))]",onClick:()=>Y(c),children:[!t&&(0,b.jsx)(B.TableCell,{onClick:a=>a.stopPropagation(),children:e?(0,b.jsx)(x.Checkbox,{checked:V.has(c.actionId),onCheckedChange:()=>{var a;return a=c.actionId,void W(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},"aria-label":l("memory.dream.actions.selectAction")}):(0,b.jsxs)(C.Tooltip,{children:[(0,b.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,b.jsx)("span",{children:(0,b.jsx)(x.Checkbox,{checked:!1,disabled:!0,"aria-label":l("memory.dream.actions.notSelectable")})})}),(0,b.jsx)(C.TooltipContent,{children:l("memory.dream.actions.onlyProposedApply")})]})}),(0,b.jsx)(B.TableCell,{children:(0,b.jsx)(L,{action:c.action})}),(0,b.jsx)(B.TableCell,{children:(0,b.jsx)(O,{status:c.status,t:l})}),(0,b.jsx)(B.TableCell,{className:"text-xs",children:P(c.targetScope)}),(0,b.jsxs)(B.TableCell,{className:"max-w-md",children:[(0,b.jsx)(M,{action:c,memoryStoreName:a,t:l}),f?(0,b.jsx)(d.default,{href:f,className:"mt-1 inline-block text-xs text-primary hover:underline",onClick:a=>a.stopPropagation(),children:l("memory.dream.actions.openInWiki")}):null]}),!t&&(0,b.jsx)(B.TableCell,{className:"text-right font-mono text-xs",children:void 0!==c.confidence?c.confidence.toFixed(2):"-"})]},c.actionId)})})]})}),(0,b.jsx)(A.Sheet,{open:null!==X,onOpenChange:a=>!a&&Y(null),children:(0,b.jsx)(A.SheetContent,{className:"w-[560px] sm:max-w-[560px]",children:X&&(0,b.jsx)(S,{detail:X,memoryStoreName:a,t:l})})}),(0,b.jsx)(H,{open:Z,onOpenChange:$,memoryStoreName:a,selected:U.filter(a=>V.has(a.actionId)),onConfirm:ad,busy:_.isPending})]})})}function R({detail:a,memoryStoreName:c,t:d}){let e="EMIT_SKILL"===a.action||"EMIT_PROFILE"===a.action,f=!e&&("UPDATE"===a.action||"DELETE"===a.action||"MERGE"===a.action),g=(0,D.useMemoryUnit)(c,f?a.targetMemoryId:void 0,f?a.targetScope:null,f),h=a.newMemory?.text;if(e){let c=a.newExtract;if(!c)return(0,b.jsx)("div",{className:"rounded border border-dashed border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.2)] p-3 text-xs italic text-muted-foreground",children:d("memory.dream.actions.noExtractResult")});let e="EMIT_SKILL"===a.action||"skill"===c.kind;return(0,b.jsxs)("div",{className:"space-y-2 rounded border border-[hsl(var(--border-light))] p-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:(0,E.cn)("rounded px-1.5 py-px text-[10px] font-semibold",e?"bg-success-soft text-success":"bg-[hsl(var(--primary-soft))] text-[hsl(var(--primary))]"),children:d(e?"memory.dream.actions.skill":"memory.dream.actions.profile")}),(0,b.jsx)("span",{className:"text-sm font-medium",children:c.name})]}),c.description&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:c.description}),c.instructions&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("memory.dream.actions.instructions")}),(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:c.instructions})]})]})}if("NOOP"===a.action)return(0,b.jsx)("div",{className:"rounded border border-dashed border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.2)] p-3 text-xs italic text-muted-foreground",children:d("memory.dream.actions.noopNoChange")});let i=g.data?.memory?.text,j=g.data?.memory?.unit_type;return(0,b.jsxs)("div",{className:"space-y-3",children:[f&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"rounded bg-warning-soft px-1.5 py-px text-[10px] font-semibold text-warning",children:d("memory.dream.actions.beforeModify")}),d("memory.dream.actions.targetMemory"),j&&(0,b.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["· ",j]})]}),g.isLoading?(0,b.jsx)(k.Skeleton,{className:"h-16 w-full"}):i?(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:i}):(0,b.jsx)("p",{className:"rounded border border-dashed border-[hsl(var(--border))] p-2 text-xs italic text-muted-foreground",children:d("memory.dream.actions.originalUnreadable")})]}),h&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:(0,E.cn)("rounded px-1.5 py-px text-[10px] font-semibold","ADD"===a.action?"bg-success-soft text-success":"bg-info-soft text-info"),children:d("ADD"===a.action?"memory.dream.actions.willAdd":"memory.dream.actions.afterModify")}),d("memory.dream.actions.newMemory"),a.newMemory?.unitType&&(0,b.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["· ",a.newMemory.unitType]})]}),(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:h})]}),"DELETE"===a.action&&(0,b.jsx)("p",{className:"rounded border border-dashed border-[hsl(var(--destructive)/0.3)] bg-danger-soft/40 p-2 text-xs text-danger",children:d("memory.dream.actions.willDelete")}),"MERGE"===a.action&&(0,b.jsx)("p",{className:"rounded border border-dashed border-[hsl(var(--border))] p-2 text-xs text-muted-foreground",children:d("memory.dream.actions.willMerge")})]})}function S({detail:a,memoryStoreName:c,t:d}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(A.SheetHeader,{children:[(0,b.jsxs)(A.SheetTitle,{children:[(0,b.jsx)(L,{action:a.action})," ",d("memory.dream.actions.detailTitle")]}),(0,b.jsx)(A.SheetDescription,{className:"font-mono text-xs break-all",children:a.actionId})]}),(0,b.jsxs)("div",{className:"space-y-4 overflow-auto py-4 text-sm",children:[(0,b.jsx)(R,{detail:a,memoryStoreName:c,t:d}),(0,b.jsxs)("div",{className:"space-y-2 rounded border border-[hsl(var(--border-light))] p-3",children:[(0,b.jsx)(T,{label:d("memory.dream.actions.detailStatus"),children:(0,b.jsx)(O,{status:a.status,t:d})}),(0,b.jsx)(T,{label:d("memory.dream.actions.detailConfidence"),value:void 0!==a.confidence?a.confidence.toFixed(2):"-"}),(0,b.jsx)(T,{label:d("memory.common.targetScope"),value:P(a.targetScope)}),a.targetMemoryId&&(0,b.jsx)(T,{label:d("memory.dream.actions.detailTargetMemoryId"),value:a.targetMemoryId,mono:!0}),a.resultMemoryId&&(0,b.jsx)(T,{label:d("memory.dream.actions.detailResultMemoryId"),value:a.resultMemoryId,mono:!0})]}),a.reason&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("memory.dream.actions.reason")}),(0,b.jsx)("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-2 text-xs",children:a.reason})]}),a.skippedReason&&(0,b.jsx)(T,{label:d("memory.dream.actions.skippedReason"),value:a.skippedReasonDetail?d("memory.dream.actions.skippedReasonWithDetail",{reason:a.skippedReason,detail:a.skippedReasonDetail}):a.skippedReason}),a.error&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d("memory.dream.actions.error")}),(0,b.jsx)("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-danger-soft p-2 text-xs text-danger",children:a.error})]})]})]})}function T({label:a,value:c,mono:d,children:e}){return(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("p",{className:"w-28 shrink-0 text-xs text-muted-foreground",children:a}),e?(0,b.jsx)("div",{children:e}):(0,b.jsx)("p",{className:(0,E.cn)("flex-1 text-sm",d&&"font-mono"),children:c??"-"})]})}var U=a.i(601170),V=a.i(172518),W=a.i(962491);function X(a,b,c){if("awaiting_plan_approval"!==a.status)throw Error(`Dream task must be awaiting_plan_approval; current status is ${a.status}`);if("reject"===b)return{kind:"cancel",dreamId:a.dreamId};if(!a.plan||"string"!=typeof a.plan.summary||""===a.plan.summary.trim()||!Array.isArray(a.plan.deleteMemoryIds)||!a.plan.deleteMemoryIds.every(a=>"string"==typeof a&&""!==a.trim()))throw Error("Dream task does not contain a valid plan");let d=c?.trim()??"";if(""===d)throw Error("Approver is required");return{kind:"approve",dreamId:a.dreamId,approver:d}}function Y({memoryStoreName:a,task:d,open:e,onOpenChange:g}){let h,{t:i}=(0,F.useI18n)(),k=(h=(0,v.useQueryClient)(),(0,u.useMutation)({mutationFn:({dreamId:b,approver:c})=>(0,q.approveDreamPlan)(a,b,c),onSuccess:()=>{h.invalidateQueries({queryKey:["memory"],predicate:b=>Array.isArray(b.queryKey)&&b.queryKey.includes("dream-tasks")&&b.queryKey.includes(a)})}})),[m,n]=(0,c.useState)(""),o=a=>{a||n(""),g(a)},p=async()=>{try{let a=X(d,"approve",m);if("approve"!==a.kind)return;await k.mutateAsync({dreamId:a.dreamId,approver:a.approver}),f.toast.success(i("memory.dream.planApprovalSuccess")),o(!1)}catch(a){f.toast.error(a instanceof Error?a.message:i("memory.dream.planApprovalFailed"))}},r=d.plan;return(0,b.jsx)(l.Dialog,{open:e,onOpenChange:o,children:(0,b.jsxs)(l.DialogContent,{className:"max-w-2xl",children:[(0,b.jsxs)(l.DialogHeader,{children:[(0,b.jsx)(l.DialogTitle,{children:i("memory.dream.planApprovalTitle")}),(0,b.jsx)(l.DialogDescription,{children:i("memory.dream.planApprovalDescription")})]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-[hsl(var(--border))] p-3",children:[(0,b.jsx)("h4",{className:"mb-1 text-xs font-semibold uppercase text-muted-foreground",children:i("memory.dream.planSummary")}),(0,b.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:r?.summary})]}),(0,b.jsxs)("section",{className:"rounded-md border border-[hsl(var(--border))] p-3",children:[(0,b.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase text-muted-foreground",children:i("memory.dream.planDeletionWhitelist")}),r?.deleteMemoryIds.length?(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:r.deleteMemoryIds.map(a=>(0,b.jsx)("li",{className:"break-all",children:a},a))}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:i("memory.dream.planNoDeletions")})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(W.Label,{htmlFor:"dream-plan-approver",children:i("memory.dream.planApprover")}),(0,b.jsx)(V.Input,{id:"dream-plan-approver",value:m,onChange:a=>n(a.target.value),placeholder:i("memory.dream.planApproverPlaceholder")})]})]}),(0,b.jsxs)(l.DialogFooter,{children:[(0,b.jsx)(j.Button,{variant:"outline",onClick:()=>o(!1),children:i("common.cancel")}),(0,b.jsx)(j.Button,{onClick:p,disabled:k.isPending||""===m.trim(),children:k.isPending?i("memory.dream.planApproving"):i("memory.dream.planApprove")})]})]})})}var Z=a.i(870307);function $(a,b){var c;let d="EMIT_SKILL"===b.action?"skill":"EMIT_PROFILE"===b.action?"profile":void 0;if("applied"!==b.status||!d||b.newExtract?.kind!==d||![(c=b.targetScope).appId,c.tenantId,c.agentId,c.runId].every(a=>"string"==typeof a&&a.length>0&&"*"!==a))return;let e=new URLSearchParams([["appId",b.targetScope.appId],["tenantId",b.targetScope.tenantId],["agentId",b.targetScope.agentId],["runId",b.targetScope.runId],["dreamId",b.dreamId],["actionId",b.actionId]]);return`/memory/${encodeURIComponent(a)}/wiki?${e.toString()}`}let _={queued:"bg-info-soft text-info",running:"bg-info-soft text-info",planning:"bg-info-soft text-info",awaiting_plan_approval:"bg-warning-soft text-warning",applying:"bg-info-soft text-info",completed:"bg-success-soft text-success",completed_with_failures:"bg-warning-soft text-warning",failed:"bg-danger-soft text-danger",cancelled:"bg-muted text-muted-foreground"},aa={queued:"memory.dreamStatus.queued",running:"memory.dreamStatus.running",planning:"memory.dreamStatus.planning",awaiting_plan_approval:"memory.dreamStatus.awaitingPlanApproval",applying:"memory.dreamStatus.applying",completed:"memory.dreamStatus.completed",completed_with_failures:"memory.dreamStatus.completedWithFailures",failed:"memory.dreamStatus.failed",cancelled:"memory.dreamStatus.cancelled"};function ab({status:a,t:c}){let d=!t.DREAM_TERMINAL_STATUSES.has(a),e=aa[a];return(0,b.jsxs)("span",{className:(0,E.cn)("inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium select-none whitespace-nowrap",_[a]??"bg-muted text-muted-foreground"),children:[d&&(0,b.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-60"}),(0,b.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),e?c(e):a]})}let ac={memory:"memory.dreamType.consolidate",skill:"memory.dreamType.skill",profile:"memory.dreamType.profile"},ad={memory:"bg-info-soft text-info",skill:"bg-success-soft text-success",profile:"bg-[hsl(var(--primary-soft,_220_90%_96%))] text-[hsl(var(--primary))]"};function ae({label:a,value:c}){return(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"text-base font-semibold tabular-nums",children:c})]})}function af({label:a,value:c}){return(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{className:"text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"mt-0.5 break-all font-mono text-foreground",children:c??"—"})]})}a.s(["buildDreamArtifactWikiHref",0,$,"default",0,function(){let a,w,{t:x}=(0,F.useI18n)(),y=(0,e.useParams)(),z=(0,e.useRouter)(),A=decodeURIComponent(y.store),B=decodeURIComponent(y.dreamId),C=function(a,b){let{context:c,ready:d}=(0,s.useRuntimeContext)();return(0,p.useQuery)({queryKey:r.queryKeys.dreamTask(c.dataScopeKey,a,b),queryFn:()=>(0,q.getDreamTask)(a,b),enabled:d&&!!a&&!!b,refetchInterval:a=>{let b=a.state.data;return b?!t.DREAM_TERMINAL_STATUSES.has(b.status)&&5e3:5e3},refetchIntervalInBackground:!1})}(A,B),D=(a=(0,v.useQueryClient)(),(0,u.useMutation)({mutationFn:a=>(0,q.cancelDreamTask)(A,a),onSuccess:()=>{a.invalidateQueries({queryKey:["memory"],predicate:a=>Array.isArray(a.queryKey)&&a.queryKey.includes("dream-tasks")&&a.queryKey.includes(A)})}})),[G,H]=(0,c.useState)(!1),[I,J]=(0,c.useState)(!1),[K,L]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1);if(C.error instanceof Error&&"code"in C.error&&"DREAMING_DISABLED"===C.error.code)return(0,b.jsx)(U.MemoryDreamDisabled,{});let O=C.data,P=O?.input.scopes??[],R=1===P.length?(0,Z.toExactScope)(P[0]):null,S=O&&t.DREAM_TERMINAL_STATUSES.has(O.status),T=O?.taskType==="skill"||O?.taskType==="profile",V=O?.status==="awaiting_plan_approval",W=async()=>{try{await D.mutateAsync(B),f.toast.success(x("memory.dream.cancelSuccess")),H(!1)}catch(b){let a=b instanceof Error?b.message:x("memory.dream.cancelFailed");f.toast.error(a)}},_=async()=>{if(O)try{let a=X(O,"reject");if("cancel"!==a.kind)return;await D.mutateAsync(a.dreamId),f.toast.success(x("memory.dream.rejectPlanSuccess")),L(!1)}catch(b){let a=b instanceof Error?b.message:x("memory.dream.rejectPlanFailed");f.toast.error(a)}};return(0,b.jsxs)("div",{className:"space-y-5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(j.Button,{variant:"ghost",size:"sm",onClick:()=>z.push(`/memory/${encodeURIComponent(A)}/dream`),children:[(0,b.jsx)(h.ArrowLeft,{className:"mr-1 h-3.5 w-3.5"}),x("memory.dream.backToTaskList")]}),R?(0,b.jsx)(j.Button,{asChild:!0,variant:"ghost",size:"sm",children:(0,b.jsxs)(d.default,{href:(0,Z.buildScopeWorkspaceHref)(A,R),children:[(0,b.jsx)(h.ArrowLeft,{className:"mr-1 h-3.5 w-3.5"}),x("memory.dream.backToScope")]})}):null]}),C.isLoading?(0,b.jsx)(k.Skeleton,{className:"h-32 w-full"}):O?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-5",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(g.CopyableId,{value:O.dreamId,label:x("memory.dream.tableId"),valueClassName:"text-base"}),(w=O.taskType||"memory",(0,b.jsx)("span",{className:(0,E.cn)("inline-flex rounded-full px-2 py-0.5 text-xs font-medium whitespace-nowrap",ad[w]??"bg-muted text-muted-foreground"),children:ac[w]?x(ac[w]):w}))]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,b.jsx)(ab,{status:O.status,t:x}),(!O.taskType||"memory"===O.taskType)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{children:"safe_auto"===O.applyMode?x("memory.dream.applyModeAutoDetail"):"plan"===O.applyMode?x("memory.dream.applyModePlanDetail"):x("memory.dream.applyModeProposalDetail")}),(0,b.jsx)("span",{children:"·"})]}),(0,b.jsx)("span",{children:x("memory.dream.effortDetail",{value:O.effort})}),(!O.taskType||"memory"===O.taskType)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{children:"·"}),(0,b.jsx)("span",{children:x("memory.dream.scopeOutput",{value:"promote_scope"===O.scopeOutputMode?x("memory.dream.scopeOutputPromote"):x("memory.dream.scopeOutputPreserve")})})]}),!S&&(0,b.jsx)("span",{className:"ml-1 italic",children:x("memory.dream.autoRefresh")})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(m.RefreshButton,{onClick:()=>C.refetch(),loading:C.isRefetching}),O.lastError&&(0,b.jsxs)(j.Button,{size:"sm",variant:"outline",onClick:()=>N(!0),className:"text-[hsl(var(--destructive))]",children:[(0,b.jsx)(i.AlertTriangle,{className:"mr-1 h-3.5 w-3.5"}),x("memory.dream.viewError")]}),V&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(j.Button,{size:"sm",onClick:()=>J(!0),children:x("memory.dream.approvePlan")}),(0,b.jsx)(j.Button,{size:"sm",variant:"destructive",onClick:()=>L(!0),disabled:D.isPending,children:x("memory.dream.rejectPlan")})]}),!S&&!V&&(0,b.jsx)(j.Button,{size:"sm",variant:"outline",onClick:()=>H(!0),disabled:D.isPending,children:x("memory.dream.cancelTask")})]})]}),(0,b.jsxs)("div",{className:"mt-5 grid grid-cols-2 gap-4 sm:grid-cols-4",children:[(0,b.jsx)(ae,{label:x("memory.dream.statSessions"),value:O.input.sessionCount}),(0,b.jsx)(ae,{label:x("memory.dream.statMessages"),value:O.input.messageCount}),(!O.taskType||"memory"===O.taskType)&&(0,b.jsx)(ae,{label:x("memory.dream.statMemories"),value:O.input.memoryCount}),(0,b.jsx)(ae,{label:T?x("memory.dream.statOutput"):x("memory.dream.statActionTotal"),value:O.actions.total}),T?(0,b.jsx)(ae,{label:x("memory.dream.statApplied"),value:O.actions.applied}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ae,{label:x("memory.dream.statProposed"),value:O.actions.proposed}),(0,b.jsx)(ae,{label:x("memory.dream.statAppliedShort"),value:O.actions.applied}),(0,b.jsx)(ae,{label:x("memory.dream.statSkipped"),value:O.actions.skipped})]}),O.actions.failed>0&&(0,b.jsx)(ae,{label:x("memory.dream.statFailed"),value:O.actions.failed})]}),(0,b.jsxs)("div",{className:"mt-5 flex flex-wrap gap-x-6 gap-y-1 text-xs text-muted-foreground",children:[(0,b.jsxs)("span",{children:[x("memory.dream.metaCreated"),(0,b.jsx)(o.RelativeTime,{timestamp:new Date(O.createdAt).getTime()})]}),(0,b.jsxs)("span",{children:[x("memory.dream.metaUpdated"),(0,b.jsx)(o.RelativeTime,{timestamp:new Date(O.updatedAt).getTime()})]}),O.finishedAt&&(0,b.jsxs)("span",{children:[x("memory.dream.metaFinished"),(0,b.jsx)(o.RelativeTime,{timestamp:new Date(O.finishedAt).getTime()})]}),O.input.scopes&&O.input.scopes.length>0&&(0,b.jsxs)("span",{children:[x("memory.dream.metaInputScopes"),O.input.scopes.map(a=>[a.appId,a.tenantId,a.agentId,a.runId].filter(Boolean).join(" / ")||"-").slice(0,3).join(" | "),O.input.scopes.length>3&&` +${O.input.scopes.length-3}`]})]})]}),(O.stage||void 0!==O.processedThroughMs||O.plan?.approvedAt||O.plan?.executionExpiresAt)&&(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-4",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:x("memory.dream.publicRuntimeTitle")}),(0,b.jsxs)("dl",{className:"grid gap-3 text-xs sm:grid-cols-2 lg:grid-cols-4",children:[(0,b.jsx)(af,{label:x("memory.dream.detailStage"),value:O.stage}),(0,b.jsx)(af,{label:x("memory.dream.detailProcessedThrough"),value:O.processedThroughMs}),(0,b.jsx)(af,{label:x("memory.dream.detailPlanApproved"),value:O.plan?.approvedAt}),(0,b.jsx)(af,{label:x("memory.dream.detailExecutionExpires"),value:O.plan?.executionExpiresAt})]})]}),O.plan&&(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-4",children:[(0,b.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:x("memory.dream.planSummary")}),(0,b.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:O.plan.summary}),(0,b.jsx)("h4",{className:"mb-2 mt-4 text-xs font-semibold uppercase text-muted-foreground",children:x("memory.dream.planDeletionWhitelist")}),O.plan.deleteMemoryIds.length>0?(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:O.plan.deleteMemoryIds.map(a=>(0,b.jsx)("li",{className:"break-all",children:a},a))}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:x("memory.dream.planNoDeletions")})]}),O.instructions&&(0,b.jsxs)("div",{className:"rounded-lg border border-[hsl(var(--border))] p-4",children:[(0,b.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:"profile"===O.taskType?x("memory.dream.instructionsProfile"):"skill"===O.taskType?x("memory.dream.instructionsSkill"):x("memory.dream.instructionsMemory")}),(0,b.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[hsl(var(--muted)/0.4)] p-3 text-xs",children:O.instructions})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:T?x("memory.dream.resultsExtract"):x("memory.dream.resultsActions")}),(0,b.jsx)(Q,{memoryStoreName:A,dreamId:B,taskType:O.taskType,artifactWikiHref:a=>$(A,a)})]}),(0,b.jsx)(n.ConfirmDialog,{open:G,onOpenChange:H,title:x("memory.dream.cancelConfirmTitle"),description:x("memory.dream.cancelConfirmDesc"),variant:"danger",onConfirm:W}),V&&(0,b.jsx)(Y,{memoryStoreName:A,task:O,open:I,onOpenChange:J}),(0,b.jsx)(n.ConfirmDialog,{open:K,onOpenChange:L,title:x("memory.dream.rejectPlanConfirmTitle"),description:x("memory.dream.rejectPlanConfirmDesc"),confirmText:x("memory.dream.rejectPlan"),variant:"danger",onConfirm:_}),(0,b.jsx)(l.Dialog,{open:M,onOpenChange:N,children:(0,b.jsxs)(l.DialogContent,{className:"max-w-2xl",children:[(0,b.jsx)(l.DialogHeader,{children:(0,b.jsx)(l.DialogTitle,{children:x("memory.dream.lastError")})}),(0,b.jsx)("pre",{className:"max-h-96 overflow-auto rounded bg-danger-soft p-3 text-xs text-danger",children:O.lastError})]})})]}):(0,b.jsx)("div",{className:"rounded-lg border border-dashed py-10 text-center text-sm text-muted-foreground",children:x("memory.dream.taskNotFound")})]})}],909598)}];
2
2
 
3
3
  //# sourceMappingURL=dashboard_src_app_%28dashboard%29_memory_%5Bstore%5D_dream_%5BdreamId%5D_page_tsx_0wy3tv6._.js.map