@geminilight/mindos 0.6.73 β†’ 0.6.75

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 (257) hide show
  1. package/_standalone/.mindos-build-version +1 -1
  2. package/_standalone/.next/BUILD_ID +1 -1
  3. package/_standalone/.next/app-path-routes-manifest.json +30 -30
  4. package/_standalone/.next/build-manifest.json +3 -3
  5. package/_standalone/.next/cache/.previewinfo +1 -1
  6. package/_standalone/.next/cache/.rscinfo +1 -1
  7. package/_standalone/.next/cache/config.json +3 -3
  8. package/_standalone/.next/prerender-manifest.json +3 -3
  9. package/_standalone/.next/react-loadable-manifest.json +5 -5
  10. package/_standalone/.next/required-server-files.json +14 -1
  11. package/_standalone/.next/server/app/.well-known/agent-card.json/route_client-reference-manifest.js +1 -1
  12. package/_standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  13. package/_standalone/.next/server/app/_global-error.html +2 -2
  14. package/_standalone/.next/server/app/_global-error.rsc +1 -1
  15. package/_standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/_standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  17. package/_standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  18. package/_standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  19. package/_standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  20. package/_standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  21. package/_standalone/.next/server/app/_not-found/page.js +1 -1
  22. package/_standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  23. package/_standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  24. package/_standalone/.next/server/app/agents/[agentKey]/page.js +1 -1
  25. package/_standalone/.next/server/app/agents/[agentKey]/page.js.nft.json +1 -1
  26. package/_standalone/.next/server/app/agents/[agentKey]/page_client-reference-manifest.js +1 -1
  27. package/_standalone/.next/server/app/agents/page.js +1 -1
  28. package/_standalone/.next/server/app/agents/page.js.nft.json +1 -1
  29. package/_standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  30. package/_standalone/.next/server/app/api/a2a/agents/route_client-reference-manifest.js +1 -1
  31. package/_standalone/.next/server/app/api/a2a/delegations/route_client-reference-manifest.js +1 -1
  32. package/_standalone/.next/server/app/api/a2a/discover/route_client-reference-manifest.js +1 -1
  33. package/_standalone/.next/server/app/api/a2a/route_client-reference-manifest.js +1 -1
  34. package/_standalone/.next/server/app/api/acp/config/route_client-reference-manifest.js +1 -1
  35. package/_standalone/.next/server/app/api/acp/detect/route_client-reference-manifest.js +1 -1
  36. package/_standalone/.next/server/app/api/acp/install/route_client-reference-manifest.js +1 -1
  37. package/_standalone/.next/server/app/api/acp/registry/route_client-reference-manifest.js +1 -1
  38. package/_standalone/.next/server/app/api/acp/session/route_client-reference-manifest.js +1 -1
  39. package/_standalone/.next/server/app/api/agent-activity/route_client-reference-manifest.js +1 -1
  40. package/_standalone/.next/server/app/api/agents/copy-skill/route.js.nft.json +1 -1
  41. package/_standalone/.next/server/app/api/agents/copy-skill/route_client-reference-manifest.js +1 -1
  42. package/_standalone/.next/server/app/api/agents/custom/detect/route_client-reference-manifest.js +1 -1
  43. package/_standalone/.next/server/app/api/agents/custom/route_client-reference-manifest.js +1 -1
  44. package/_standalone/.next/server/app/api/ask/route.js +1 -1
  45. package/_standalone/.next/server/app/api/ask/route.js.nft.json +1 -1
  46. package/_standalone/.next/server/app/api/ask/route_client-reference-manifest.js +1 -1
  47. package/_standalone/.next/server/app/api/ask-sessions/route_client-reference-manifest.js +1 -1
  48. package/_standalone/.next/server/app/api/auth/route_client-reference-manifest.js +1 -1
  49. package/_standalone/.next/server/app/api/backlinks/route.js.nft.json +1 -1
  50. package/_standalone/.next/server/app/api/backlinks/route_client-reference-manifest.js +1 -1
  51. package/_standalone/.next/server/app/api/bootstrap/route.js.nft.json +1 -1
  52. package/_standalone/.next/server/app/api/bootstrap/route_client-reference-manifest.js +1 -1
  53. package/_standalone/.next/server/app/api/changes/route.js.nft.json +1 -1
  54. package/_standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
  55. package/_standalone/.next/server/app/api/channels/verify/route.js.nft.json +1 -1
  56. package/_standalone/.next/server/app/api/channels/verify/route_client-reference-manifest.js +1 -1
  57. package/_standalone/.next/server/app/api/connect/route_client-reference-manifest.js +1 -1
  58. package/_standalone/.next/server/app/api/embedding/route.js.nft.json +1 -1
  59. package/_standalone/.next/server/app/api/embedding/route_client-reference-manifest.js +1 -1
  60. package/_standalone/.next/server/app/api/export/route.js.nft.json +1 -1
  61. package/_standalone/.next/server/app/api/export/route_client-reference-manifest.js +1 -1
  62. package/_standalone/.next/server/app/api/extract-pdf/route.js.nft.json +1 -1
  63. package/_standalone/.next/server/app/api/extract-pdf/route_client-reference-manifest.js +1 -1
  64. package/_standalone/.next/server/app/api/file/import/route.js.nft.json +1 -1
  65. package/_standalone/.next/server/app/api/file/import/route_client-reference-manifest.js +1 -1
  66. package/_standalone/.next/server/app/api/file/raw/route.js.nft.json +1 -1
  67. package/_standalone/.next/server/app/api/file/raw/route_client-reference-manifest.js +1 -1
  68. package/_standalone/.next/server/app/api/file/route.js.nft.json +1 -1
  69. package/_standalone/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
  70. package/_standalone/.next/server/app/api/files/route.js.nft.json +1 -1
  71. package/_standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  72. package/_standalone/.next/server/app/api/git/route.js.nft.json +1 -1
  73. package/_standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  74. package/_standalone/.next/server/app/api/graph/route.js.nft.json +1 -1
  75. package/_standalone/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
  76. package/_standalone/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
  77. package/_standalone/.next/server/app/api/im/activity/route_client-reference-manifest.js +1 -1
  78. package/_standalone/.next/server/app/api/im/config/route.js +1 -1
  79. package/_standalone/.next/server/app/api/im/config/route_client-reference-manifest.js +1 -1
  80. package/_standalone/.next/server/app/api/im/status/route.js +1 -7
  81. package/_standalone/.next/server/app/api/im/status/route.js.nft.json +1 -1
  82. package/_standalone/.next/server/app/api/im/status/route_client-reference-manifest.js +1 -1
  83. package/_standalone/.next/server/app/api/im/test/route.js.nft.json +1 -1
  84. package/_standalone/.next/server/app/api/im/test/route_client-reference-manifest.js +1 -1
  85. package/_standalone/.next/server/app/api/im/webhook/feishu/route.js +1 -7
  86. package/_standalone/.next/server/app/api/im/webhook/feishu/route.js.nft.json +1 -1
  87. package/_standalone/.next/server/app/api/im/webhook/feishu/route_client-reference-manifest.js +1 -1
  88. package/_standalone/.next/server/app/api/im/webhook-status/route.js +1 -7
  89. package/_standalone/.next/server/app/api/im/webhook-status/route.js.nft.json +1 -1
  90. package/_standalone/.next/server/app/api/im/webhook-status/route_client-reference-manifest.js +1 -1
  91. package/_standalone/.next/server/app/api/inbox/clip/route.js.nft.json +1 -1
  92. package/_standalone/.next/server/app/api/inbox/clip/route_client-reference-manifest.js +1 -1
  93. package/_standalone/.next/server/app/api/inbox/route.js.nft.json +1 -1
  94. package/_standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -1
  95. package/_standalone/.next/server/app/api/init/route.js.nft.json +1 -1
  96. package/_standalone/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  97. package/_standalone/.next/server/app/api/lint/route.js.nft.json +1 -1
  98. package/_standalone/.next/server/app/api/lint/route_client-reference-manifest.js +1 -1
  99. package/_standalone/.next/server/app/api/mcp/agents/route.js.nft.json +1 -1
  100. package/_standalone/.next/server/app/api/mcp/agents/route_client-reference-manifest.js +1 -1
  101. package/_standalone/.next/server/app/api/mcp/direct-tools/route_client-reference-manifest.js +1 -1
  102. package/_standalone/.next/server/app/api/mcp/install/route_client-reference-manifest.js +1 -1
  103. package/_standalone/.next/server/app/api/mcp/install-skill/route_client-reference-manifest.js +1 -1
  104. package/_standalone/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
  105. package/_standalone/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
  106. package/_standalone/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
  107. package/_standalone/.next/server/app/api/mcp/uninstall/route_client-reference-manifest.js +1 -1
  108. package/_standalone/.next/server/app/api/monitoring/route.js.nft.json +1 -1
  109. package/_standalone/.next/server/app/api/monitoring/route_client-reference-manifest.js +1 -1
  110. package/_standalone/.next/server/app/api/recent-files/route.js.nft.json +1 -1
  111. package/_standalone/.next/server/app/api/recent-files/route_client-reference-manifest.js +1 -1
  112. package/_standalone/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  113. package/_standalone/.next/server/app/api/search/route.js.nft.json +1 -1
  114. package/_standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
  115. package/_standalone/.next/server/app/api/settings/list-models/route_client-reference-manifest.js +1 -1
  116. package/_standalone/.next/server/app/api/settings/reset-token/route_client-reference-manifest.js +1 -1
  117. package/_standalone/.next/server/app/api/settings/route.js.nft.json +1 -1
  118. package/_standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  119. package/_standalone/.next/server/app/api/settings/test-key/route_client-reference-manifest.js +1 -1
  120. package/_standalone/.next/server/app/api/setup/check-path/route_client-reference-manifest.js +1 -1
  121. package/_standalone/.next/server/app/api/setup/check-port/route_client-reference-manifest.js +1 -1
  122. package/_standalone/.next/server/app/api/setup/generate-token/route_client-reference-manifest.js +1 -1
  123. package/_standalone/.next/server/app/api/setup/ls/route_client-reference-manifest.js +1 -1
  124. package/_standalone/.next/server/app/api/setup/route_client-reference-manifest.js +1 -1
  125. package/_standalone/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  126. package/_standalone/.next/server/app/api/space-overview/route.js.nft.json +1 -1
  127. package/_standalone/.next/server/app/api/space-overview/route_client-reference-manifest.js +1 -1
  128. package/_standalone/.next/server/app/api/sync/route_client-reference-manifest.js +1 -1
  129. package/_standalone/.next/server/app/api/tree-version/route.js.nft.json +1 -1
  130. package/_standalone/.next/server/app/api/tree-version/route_client-reference-manifest.js +1 -1
  131. package/_standalone/.next/server/app/api/uninstall/route_client-reference-manifest.js +1 -1
  132. package/_standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  133. package/_standalone/.next/server/app/api/update-check/route_client-reference-manifest.js +1 -1
  134. package/_standalone/.next/server/app/api/update-status/route_client-reference-manifest.js +1 -1
  135. package/_standalone/.next/server/app/api/workflows/route.js.nft.json +1 -1
  136. package/_standalone/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
  137. package/_standalone/.next/server/app/changelog/page.js +1 -1
  138. package/_standalone/.next/server/app/changelog/page.js.nft.json +1 -1
  139. package/_standalone/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  140. package/_standalone/.next/server/app/changes/page.js +1 -1
  141. package/_standalone/.next/server/app/changes/page.js.nft.json +1 -1
  142. package/_standalone/.next/server/app/changes/page_client-reference-manifest.js +1 -1
  143. package/_standalone/.next/server/app/echo/[segment]/page.js +1 -1
  144. package/_standalone/.next/server/app/echo/[segment]/page.js.nft.json +1 -1
  145. package/_standalone/.next/server/app/echo/[segment]/page_client-reference-manifest.js +1 -1
  146. package/_standalone/.next/server/app/echo/page.js +1 -1
  147. package/_standalone/.next/server/app/echo/page.js.nft.json +1 -1
  148. package/_standalone/.next/server/app/echo/page_client-reference-manifest.js +1 -1
  149. package/_standalone/.next/server/app/explore/page.js +1 -1
  150. package/_standalone/.next/server/app/explore/page.js.nft.json +1 -1
  151. package/_standalone/.next/server/app/explore/page_client-reference-manifest.js +1 -1
  152. package/_standalone/.next/server/app/help/page.js +1 -1
  153. package/_standalone/.next/server/app/help/page.js.nft.json +1 -1
  154. package/_standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
  155. package/_standalone/.next/server/app/inbox/history/page.js +1 -1
  156. package/_standalone/.next/server/app/inbox/history/page.js.nft.json +1 -1
  157. package/_standalone/.next/server/app/inbox/history/page_client-reference-manifest.js +1 -1
  158. package/_standalone/.next/server/app/login/page.js +1 -1
  159. package/_standalone/.next/server/app/login/page.js.nft.json +1 -1
  160. package/_standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
  161. package/_standalone/.next/server/app/page.js +1 -1
  162. package/_standalone/.next/server/app/page.js.nft.json +1 -1
  163. package/_standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  164. package/_standalone/.next/server/app/setup/page.js +2 -2
  165. package/_standalone/.next/server/app/setup/page.js.nft.json +1 -1
  166. package/_standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  167. package/_standalone/.next/server/app/trash/page.js +3 -3
  168. package/_standalone/.next/server/app/trash/page.js.nft.json +1 -1
  169. package/_standalone/.next/server/app/trash/page_client-reference-manifest.js +1 -1
  170. package/_standalone/.next/server/app/view/[...path]/page.js +3 -3
  171. package/_standalone/.next/server/app/view/[...path]/page.js.nft.json +1 -1
  172. package/_standalone/.next/server/app/view/[...path]/page_client-reference-manifest.js +1 -1
  173. package/_standalone/.next/server/app-paths-manifest.json +30 -30
  174. package/_standalone/.next/server/chunks/1076.js +1 -1
  175. package/_standalone/.next/server/chunks/{2449.js β†’ 2424.js} +2 -2
  176. package/_standalone/.next/server/chunks/2792.js +1 -0
  177. package/_standalone/.next/server/chunks/2885.js +7 -0
  178. package/_standalone/.next/server/chunks/3800.js +1 -1
  179. package/_standalone/.next/server/chunks/5299.js +1 -1
  180. package/_standalone/.next/server/chunks/5464.js +1 -1
  181. package/_standalone/.next/server/chunks/6022.js +28 -28
  182. package/_standalone/.next/server/chunks/6539.js +1 -1
  183. package/_standalone/.next/server/chunks/8388.js +2 -2
  184. package/_standalone/.next/server/middleware-build-manifest.js +1 -1
  185. package/_standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  186. package/_standalone/.next/server/pages/500.html +2 -2
  187. package/_standalone/.next/server/server-reference-manifest.js +1 -1
  188. package/_standalone/.next/server/server-reference-manifest.json +1 -1
  189. package/_standalone/.next/static/chunks/{5331.c89084fd7f67887d.js β†’ 4342.ccc18d7a45f204a4.js} +5 -5
  190. package/_standalone/.next/static/chunks/{4094.09364c01df411380.js β†’ 4496.f77a677ac2034e48.js} +1 -1
  191. package/_standalone/.next/static/chunks/{5358-15618fc9b20018ee.js β†’ 5358-15ceeb8c1cd9889d.js} +6 -6
  192. package/_standalone/.next/static/chunks/{6902-edc5c487c696bd0b.js β†’ 6902-53a31f849968ddf8.js} +1 -1
  193. package/_standalone/.next/static/chunks/9207-456dc6941d557f33.js +1 -0
  194. package/_standalone/.next/static/chunks/app/{layout-fcbde5bee626d21a.js β†’ layout-09f08f52e3cbfc47.js} +66 -66
  195. package/_standalone/.next/static/chunks/app/setup/{page-e40f3c5704c3c857.js β†’ page-64d7fa097ef3f367.js} +1 -1
  196. package/_standalone/.next/static/chunks/app/trash/page-8e0ea3ba71702757.js +1 -0
  197. package/_standalone/.next/static/chunks/app/view/[...path]/page-04f43178679a8bfb.js +12 -0
  198. package/_standalone/.next/static/chunks/{webpack-dc486b68118d1328.js β†’ webpack-ec9c6076012b75f3.js} +1 -1
  199. package/_standalone/.next/trace +72 -72
  200. package/_standalone/__tests__/agent/provider-presets.test.ts +32 -0
  201. package/_standalone/__tests__/api/im-config-feishu-conversation.test.ts +39 -0
  202. package/_standalone/__tests__/api/im-webhook-feishu.test.ts +21 -12
  203. package/_standalone/__tests__/api/pi-subagents.test.ts +81 -0
  204. package/_standalone/__tests__/ask/file-chip-variants.test.tsx +18 -0
  205. package/_standalone/__tests__/ask/message-list-agent-attribution.test.tsx +2 -0
  206. package/_standalone/__tests__/im/feishu-dispatcher.test.ts +151 -0
  207. package/_standalone/__tests__/im/feishu-webhook.test.ts +85 -57
  208. package/_standalone/__tests__/im/feishu-ws-client.test.ts +91 -0
  209. package/_standalone/__tests__/settings/custom-provider-form.test.ts +30 -0
  210. package/_standalone/components/ask/FileChip.tsx +1 -1
  211. package/_standalone/components/ask/MessageList.tsx +2 -2
  212. package/_standalone/components/settings/CustomProviderFields.tsx +1 -1
  213. package/_standalone/components/settings/CustomProvidersCard.tsx +3 -0
  214. package/_standalone/components/settings/useCustomProviderForm.ts +78 -24
  215. package/_standalone/components/shared/ProviderSelect.tsx +6 -5
  216. package/_standalone/next.config.ts +28 -4
  217. package/_standalone/package-lock.json +20 -2
  218. package/_standalone/package.json +3 -1
  219. package/_standalone/scripts/feishu-long-connection.ts +32 -0
  220. package/_standalone/server.js +1 -1
  221. package/_standalone/tsconfig.tsbuildinfo +1 -1
  222. package/app/__tests__/agent/provider-presets.test.ts +32 -0
  223. package/app/__tests__/api/im-config-feishu-conversation.test.ts +39 -0
  224. package/app/__tests__/api/im-webhook-feishu.test.ts +21 -12
  225. package/app/__tests__/api/pi-subagents.test.ts +81 -0
  226. package/app/__tests__/ask/file-chip-variants.test.tsx +18 -0
  227. package/app/__tests__/ask/message-list-agent-attribution.test.tsx +2 -0
  228. package/app/__tests__/im/feishu-dispatcher.test.ts +151 -0
  229. package/app/__tests__/im/feishu-webhook.test.ts +85 -57
  230. package/app/__tests__/im/feishu-ws-client.test.ts +91 -0
  231. package/app/__tests__/settings/custom-provider-form.test.ts +30 -0
  232. package/app/app/api/ask/route.ts +2 -0
  233. package/app/app/api/im/config/route.ts +2 -0
  234. package/app/app/api/im/webhook/feishu/route.ts +4 -2
  235. package/app/components/ask/FileChip.tsx +1 -1
  236. package/app/components/ask/MessageList.tsx +2 -2
  237. package/app/components/settings/CustomProviderFields.tsx +1 -1
  238. package/app/components/settings/CustomProvidersCard.tsx +3 -0
  239. package/app/components/settings/useCustomProviderForm.ts +78 -24
  240. package/app/components/shared/ProviderSelect.tsx +6 -5
  241. package/app/lib/agent/providers.ts +44 -6
  242. package/app/lib/im/feishu-dispatcher.ts +111 -0
  243. package/app/lib/im/feishu-ws-client.ts +72 -0
  244. package/app/lib/im/types.ts +14 -0
  245. package/app/lib/im/webhook/feishu.ts +44 -55
  246. package/app/next.config.ts +28 -4
  247. package/app/package.json +3 -1
  248. package/app/scripts/feishu-long-connection.ts +32 -0
  249. package/bin/cli.js +3 -1
  250. package/bin/commands/feishu-ws.js +39 -0
  251. package/package.json +1 -1
  252. package/scripts/build-runtime-archive.sh +36 -2
  253. package/_standalone/.next/static/chunks/9207-3b19c55a3c974a09.js +0 -1
  254. package/_standalone/.next/static/chunks/app/trash/page-e623ff0ab35de002.js +0 -1
  255. package/_standalone/.next/static/chunks/app/view/[...path]/page-49c4eff6ffdb5168.js +0 -12
  256. /package/_standalone/.next/static/{Dn8EHqUedSzanCfrM8WWS β†’ dZDCx13MSM8QVQk2QNRs8}/_buildManifest.js +0 -0
  257. /package/_standalone/.next/static/{Dn8EHqUedSzanCfrM8WWS β†’ dZDCx13MSM8QVQk2QNRs8}/_ssgManifest.js +0 -0
@@ -55,8 +55,11 @@ export interface TelegramConfig {
55
55
  bot_token: string;
56
56
  }
57
57
 
58
+ export type FeishuConversationTransport = 'webhook' | 'long_connection';
59
+
58
60
  export interface FeishuConversationConfig {
59
61
  enabled?: boolean;
62
+ transport?: FeishuConversationTransport;
60
63
  encrypt_key?: string;
61
64
  verification_token?: string;
62
65
  public_base_url?: string;
@@ -249,3 +252,14 @@ export interface FeishuWebhookEventEnvelope {
249
252
  };
250
253
  }
251
254
 
255
+ export interface FeishuSdkMessageEvent {
256
+ event_type?: string;
257
+ message?: NonNullable<FeishuWebhookEventEnvelope['event']>['message'];
258
+ sender?: NonNullable<FeishuWebhookEventEnvelope['event']>['sender'];
259
+ }
260
+
261
+ export interface FeishuWebhookDispatchResult {
262
+ status: number;
263
+ body: Record<string, unknown>;
264
+ }
265
+
@@ -2,15 +2,20 @@ import { runHeadlessAgent } from '@/lib/agent/headless';
2
2
  import { appendConversationTurn, getConversationHistory } from '@/lib/im/conversation-store';
3
3
  import { recordActivity } from '@/lib/im/activity';
4
4
  import { sendIMMessage } from '@/lib/im/executor';
5
+ import { getFeishuWSClientStatus } from '@/lib/im/feishu-ws-client';
5
6
  import type { Message } from '@/lib/types';
6
7
  import type {
7
8
  FeishuConfig,
8
- FeishuWebhookChallengeBody,
9
+ FeishuSdkMessageEvent,
9
10
  FeishuWebhookEventEnvelope,
10
11
  IMWebhookStatus,
11
12
  IncomingIMMessage,
12
13
  } from '@/lib/im/types';
13
14
 
15
+ function getFeishuTransport(config?: FeishuConfig): 'webhook' | 'long_connection' {
16
+ return config?.conversation?.transport ?? 'webhook';
17
+ }
18
+
14
19
  function trimTrailingSlash(value: string): string {
15
20
  return value.replace(/\/+$/, '');
16
21
  }
@@ -32,6 +37,7 @@ function hasBotMention(event: FeishuWebhookEventEnvelope): boolean {
32
37
 
33
38
  export function buildFeishuWebhookStatus(config?: FeishuConfig): IMWebhookStatus {
34
39
  const conversation = config?.conversation;
40
+ const transport = getFeishuTransport(config);
35
41
  const publicBaseUrl = conversation?.public_base_url?.trim();
36
42
  const normalizedBaseUrl = publicBaseUrl ? trimTrailingSlash(publicBaseUrl) : undefined;
37
43
  const webhookUrl = normalizedBaseUrl ? `${normalizedBaseUrl}/api/im/webhook/feishu` : undefined;
@@ -45,6 +51,23 @@ export function buildFeishuWebhookStatus(config?: FeishuConfig): IMWebhookStatus
45
51
  };
46
52
  }
47
53
 
54
+ if (transport === 'long_connection') {
55
+ const wsStatus = getFeishuWSClientStatus();
56
+ if (!config?.app_id || !config?.app_secret) {
57
+ return {
58
+ platform: 'feishu',
59
+ state: 'error',
60
+ lastError: 'Feishu App ID and App Secret are required for long connection mode.',
61
+ };
62
+ }
63
+
64
+ return {
65
+ platform: 'feishu',
66
+ state: wsStatus.running ? 'ready' : 'pending',
67
+ lastError: wsStatus.running ? undefined : (wsStatus.lastError ?? 'Start the Feishu long connection client to receive events locally.'),
68
+ };
69
+ }
70
+
48
71
  if (!conversation.encrypt_key) {
49
72
  return {
50
73
  platform: 'feishu',
@@ -102,12 +125,6 @@ export function normalizeFeishuIncomingMessage(event: FeishuWebhookEventEnvelope
102
125
  };
103
126
  }
104
127
 
105
- export type FeishuWebhookResult = {
106
- kind: 'challenge' | 'accepted';
107
- status: number;
108
- body: Record<string, unknown>;
109
- };
110
-
111
128
  function buildFallbackReply(): string {
112
129
  return 'I received your message, but I could not generate a reply just now. Please try again from MindOS or send another message.';
113
130
  }
@@ -163,53 +180,29 @@ export async function processFeishuIncomingMessage(incoming: IncomingIMMessage):
163
180
  });
164
181
  }
165
182
 
166
- export async function handleFeishuWebhook(params: {
167
- config: FeishuConfig;
168
- body: unknown;
169
- }): Promise<FeishuWebhookResult> {
170
- const challengeBody = params.body as FeishuWebhookChallengeBody;
171
- if (typeof challengeBody?.challenge === 'string' && challengeBody.challenge) {
172
- const expectedToken = params.config.conversation?.verification_token;
173
- if (expectedToken && challengeBody.token && challengeBody.token !== expectedToken) {
174
- return {
175
- kind: 'accepted',
176
- status: 401,
177
- body: { ok: false, error: 'Invalid verification token' },
178
- };
179
- }
180
- return {
181
- kind: 'challenge',
182
- status: 200,
183
- body: { challenge: challengeBody.challenge },
184
- };
183
+ export async function handleFeishuMessageReceiveEvent(event: FeishuSdkMessageEvent): Promise<Record<string, unknown>> {
184
+ if (!event.message?.chat_id || !event.message?.message_id || !event.sender?.sender_id) {
185
+ return { ok: true, ignored: true, reason: 'invalid_event_payload' };
185
186
  }
186
187
 
187
- const status = buildFeishuWebhookStatus(params.config);
188
- if (status.state !== 'ready') {
189
- return {
190
- kind: 'accepted',
191
- status: 202,
192
- body: { ok: false, ignored: true, reason: status.lastError ?? 'Webhook is not ready' },
193
- };
194
- }
188
+ const envelope: FeishuWebhookEventEnvelope = {
189
+ header: {
190
+ event_type: event.event_type ?? 'im.message.receive_v1',
191
+ },
192
+ event: {
193
+ message: event.message,
194
+ sender: event.sender,
195
+ },
196
+ };
195
197
 
196
- const event = params.body as FeishuWebhookEventEnvelope;
197
- const decision = shouldProcessFeishuEvent(event);
198
+ const decision = shouldProcessFeishuEvent(envelope);
198
199
  if (!decision.ok) {
199
- return {
200
- kind: 'accepted',
201
- status: 202,
202
- body: { ok: true, ignored: true, reason: decision.reason },
203
- };
200
+ return { ok: true, ignored: true, reason: decision.reason };
204
201
  }
205
202
 
206
- const incoming = normalizeFeishuIncomingMessage(event);
203
+ const incoming = normalizeFeishuIncomingMessage(envelope);
207
204
  if (!incoming.text.trim()) {
208
- return {
209
- kind: 'accepted',
210
- status: 202,
211
- body: { ok: true, ignored: true, reason: 'empty_text' },
212
- };
205
+ return { ok: true, ignored: true, reason: 'empty_text' };
213
206
  }
214
207
 
215
208
  void processFeishuIncomingMessage(incoming).catch((error) => {
@@ -217,13 +210,9 @@ export async function handleFeishuWebhook(params: {
217
210
  });
218
211
 
219
212
  return {
220
- kind: 'accepted',
221
- status: 202,
222
- body: {
223
- ok: true,
224
- queued: true,
225
- reason: decision.reason,
226
- incoming,
227
- },
213
+ ok: true,
214
+ queued: true,
215
+ reason: decision.reason,
216
+ incoming,
228
217
  };
229
218
  }
@@ -15,9 +15,24 @@ const nextConfig: NextConfig = {
15
15
  // when the project is inside node_modules (global npm install).
16
16
  ...(inNodeModules ? ['@geminilight/mindos'] : []),
17
17
  ],
18
- serverExternalPackages: ['chokidar', 'openai', 'discord.js', '@mariozechner/pi-ai', '@mariozechner/pi-agent-core', '@mariozechner/pi-coding-agent', 'pi-mcp-adapter'],
18
+ serverExternalPackages: [
19
+ 'chokidar', 'openai', 'discord.js',
20
+ '@mariozechner/pi-ai', '@mariozechner/pi-agent-core', '@mariozechner/pi-coding-agent', 'pi-mcp-adapter',
21
+ // Heavy packages excluded from bundle β€” dynamically imported at runtime.
22
+ '@huggingface/transformers', 'onnxruntime-web',
23
+ 'sharp', '@img/sharp-linux-x64', '@img/sharp-darwin-arm64', '@img/sharp-win32-x64',
24
+ ],
19
25
  output: 'standalone',
20
26
  outputFileTracingRoot: projectDir,
27
+ // Exclude heavy native packages from standalone trace to reduce runtime archive.
28
+ // @img/sharp-* (33MB) is optional for image processing.
29
+ outputFileTracingExcludes: {
30
+ '*': [
31
+ './node_modules/onnxruntime-node/**',
32
+ './node_modules/@img/**',
33
+ './node_modules/sharp/**',
34
+ ],
35
+ },
21
36
  outputFileTracingIncludes: {
22
37
  // extract-pdf.cjs is spawned at runtime (not bundled) β€” ensure it's
23
38
  // copied into .next/standalone/scripts/ so standalone builds work.
@@ -32,11 +47,20 @@ const nextConfig: NextConfig = {
32
47
  },
33
48
  },
34
49
  webpack: (config) => {
50
+ config.resolve = config.resolve ?? {};
51
+ config.resolve.alias = config.resolve.alias ?? {};
52
+ const alias = config.resolve.alias as Record<string, string>;
53
+
35
54
  if (inNodeModules) {
36
- config.resolve = config.resolve ?? {};
37
- config.resolve.alias = config.resolve.alias ?? {};
38
- (config.resolve.alias as Record<string, string>)['@'] = projectDir;
55
+ alias['@'] = projectDir;
39
56
  }
57
+
58
+ // Replace onnxruntime-node (355MB native binary) with onnxruntime-web (WASM).
59
+ // @huggingface/transformers statically imports onnxruntime-node in its Node.js
60
+ // entry. This alias makes it resolve to the lightweight WASM version instead,
61
+ // reducing the runtime archive from ~250MB to ~35MB with no code changes needed.
62
+ alias['onnxruntime-node'] = 'onnxruntime-web';
63
+
40
64
  return config;
41
65
  },
42
66
  };
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-app",
3
- "version": "0.6.73",
3
+ "version": "0.6.75",
4
4
  "private": true,
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -60,9 +60,11 @@
60
60
  "marked": "^17.0.5",
61
61
  "nanoid": "^5.1.0",
62
62
  "next": "16.1.6",
63
+ "onnxruntime-web": "^1.25.0-dev.20260327-722743c0e2",
63
64
  "papaparse": "^5.5.3",
64
65
  "pdfjs-dist": "^4.10.38",
65
66
  "pi-mcp-adapter": "^2.2.2",
67
+ "pi-subagents": "^0.12.5",
66
68
  "picocolors": "^1.1.1",
67
69
  "react": "19.2.3",
68
70
  "react-dom": "19.2.3",
@@ -0,0 +1,32 @@
1
+ import { getPlatformConfig } from '@/lib/im/config';
2
+ import { startFeishuWSClient, getFeishuWSClientStatus } from '@/lib/im/feishu-ws-client';
3
+
4
+ async function main() {
5
+ const config = getPlatformConfig('feishu');
6
+ if (!config) {
7
+ throw new Error('Feishu is not configured. Save App ID and App Secret first.');
8
+ }
9
+
10
+ await startFeishuWSClient(config);
11
+ const status = getFeishuWSClientStatus();
12
+
13
+ console.log('[feishu/ws] status:', JSON.stringify(status, null, 2));
14
+ console.log('[feishu/ws] connected. Keep this process running to receive events.');
15
+
16
+ process.on('SIGINT', () => {
17
+ console.log('\n[feishu/ws] shutting down');
18
+ process.exit(0);
19
+ });
20
+
21
+ process.on('SIGTERM', () => {
22
+ console.log('\n[feishu/ws] shutting down');
23
+ process.exit(0);
24
+ });
25
+
26
+ await new Promise(() => {});
27
+ }
28
+
29
+ main().catch((error) => {
30
+ console.error('[feishu/ws] failed:', error instanceof Error ? error.message : String(error));
31
+ process.exit(1);
32
+ });
package/bin/cli.js CHANGED
@@ -40,6 +40,7 @@ import * as logsCmd from './commands/logs.js';
40
40
  import * as apiCmd from './commands/api.js';
41
41
  import * as initSkillsCmd from './commands/init-skills.js';
42
42
  import * as channelCmd from './commands/channel.js';
43
+ import * as feishuWsCmd from './commands/feishu-ws.js';
43
44
 
44
45
  // ── Command registry ──────────────────────────────────────────────────────────
45
46
 
@@ -50,7 +51,7 @@ const modules = [
50
51
  mcpCmd, tokenCmd,
51
52
  syncCmd,
52
53
  gatewayCmd,
53
- onboardCmd, configCmd, channelCmd, doctorCmd, updateCmd, uninstallCmd, logsCmd, apiCmd,
54
+ onboardCmd, configCmd, channelCmd, feishuWsCmd, doctorCmd, updateCmd, uninstallCmd, logsCmd, apiCmd,
54
55
  initSkillsCmd,
55
56
  ];
56
57
 
@@ -90,6 +91,7 @@ const coreEntries = [
90
91
  ['init', onboardCmd],
91
92
  ['config', configCmd],
92
93
  ['channel', channelCmd],
94
+ ['feishu-ws', feishuWsCmd],
93
95
  ['doctor', doctorCmd],
94
96
  ['update', updateCmd],
95
97
  ];
@@ -0,0 +1,39 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { resolve } from 'node:path';
3
+ import { bold, cyan, dim, red } from '../lib/colors.js';
4
+
5
+ export const meta = {
6
+ name: 'feishu-ws',
7
+ group: 'IM Integration',
8
+ summary: 'Start Feishu long connection client',
9
+ usage: 'mindos feishu-ws',
10
+ examples: [
11
+ 'mindos feishu-ws',
12
+ ],
13
+ };
14
+
15
+ export async function run() {
16
+ const scriptPath = resolve(process.cwd(), 'app/scripts/feishu-long-connection.ts');
17
+
18
+ console.log();
19
+ console.log(bold('Starting Feishu long connection'));
20
+ console.log(dim('This keeps a WSClient process running for local event validation.'));
21
+ console.log(dim(`Script: ${scriptPath}`));
22
+ console.log();
23
+
24
+ const child = spawn('npx', ['tsx', scriptPath], {
25
+ cwd: process.cwd(),
26
+ stdio: 'inherit',
27
+ env: process.env,
28
+ });
29
+
30
+ child.on('exit', (code) => {
31
+ process.exit(code ?? 0);
32
+ });
33
+
34
+ child.on('error', (error) => {
35
+ console.error(red(`Failed to start Feishu long connection: ${error.message}`));
36
+ console.error(cyan('Try running:'), dim(`npx tsx ${scriptPath}`));
37
+ process.exit(1);
38
+ });
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geminilight/mindos",
3
- "version": "0.6.73",
3
+ "version": "0.6.75",
4
4
  "description": "MindOS β€” Human-Agent Collaborative Mind System. Local-first knowledge base that syncs your mind to all AI Agents via MCP.",
5
5
  "keywords": [
6
6
  "mindos",
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
  # Build a minimal MindOS runtime archive for Desktop Core Hot Update.
3
- # Output: /tmp/mindos-runtime-{VERSION}.tar.gz (pre-built, ~32MB)
3
+ # Output: /tmp/mindos-runtime-{VERSION}.tar.gz (pre-built, ~30-40MB)
4
4
  #
5
5
  # Directory structure matches what ProcessManager + analyzeMindOsLayout expect:
6
6
  # app/.next/standalone/server.js
@@ -26,7 +26,13 @@ echo "πŸ“¦ Building MindOS runtime v${VERSION}..."
26
26
  echo " Copying standalone..."
27
27
  mkdir -p "$WORK/app/.next"
28
28
  # Copy the entire standalone tree (server.js + node_modules + .next/server + .next/static + public)
29
- cp -r app/.next/standalone "$WORK/app/.next/standalone"
29
+ # IMPORTANT: --no-dereference preserves symlinks as-is instead of following them.
30
+ # Next.js standalone creates node_modules/node_modules -> ../../node_modules symlinks
31
+ # that cause infinite recursion with plain cp -r (blowing up from ~30MB to 2GB+).
32
+ cp -r --no-dereference app/.next/standalone "$WORK/app/.next/standalone"
33
+ # Remove symlinks inside node_modules β€” they point to paths outside standalone
34
+ # and are not needed at runtime (standalone has all traced deps already).
35
+ find "$WORK/app/.next/standalone/node_modules" -type l -delete 2>/dev/null || true
30
36
  # Remove dev artifacts that sneak into standalone
31
37
  rm -rf "$WORK/app/.next/standalone/.next/cache" \
32
38
  "$WORK/app/.next/standalone/.next/dev" \
@@ -34,6 +40,34 @@ rm -rf "$WORK/app/.next/standalone/.next/cache" \
34
40
  "$WORK/app/.next/standalone/.next/types" \
35
41
  "$WORK/app/.next/standalone/__tests__" \
36
42
  "$WORK/app/.next/standalone/.next/lock"
43
+
44
+ # Strip dev-only files from node_modules to reduce archive size
45
+ echo " Stripping dev-only files from node_modules..."
46
+ STANDALONE_NM="$WORK/app/.next/standalone/node_modules"
47
+ if [ -d "$STANDALONE_NM" ]; then
48
+ # TypeScript declaration files (only needed for IDE, not runtime)
49
+ find "$STANDALONE_NM" -name '*.d.ts' -delete
50
+ find "$STANDALONE_NM" -name '*.d.cts' -delete
51
+ find "$STANDALONE_NM" -name '*.d.mts' -delete
52
+ find "$STANDALONE_NM" -name '*.d.ts.map' -delete
53
+ # Source maps (debugging only)
54
+ find "$STANDALONE_NM" -name '*.js.map' -delete
55
+ find "$STANDALONE_NM" -name '*.mjs.map' -delete
56
+ find "$STANDALONE_NM" -name '*.cjs.map' -delete
57
+ # TypeScript source files (compiled JS is what runs)
58
+ find "$STANDALONE_NM" -name '*.ts' ! -name '*.d.ts' -path '*/src/*' -delete
59
+ # Markdown docs inside packages
60
+ find "$STANDALONE_NM" -name 'README.md' -delete
61
+ find "$STANDALONE_NM" -name 'CHANGELOG.md' -delete
62
+ find "$STANDALONE_NM" -name 'LICENSE' -delete
63
+ find "$STANDALONE_NM" -name 'LICENSE.md' -delete
64
+ # Empty directories left after deletion
65
+ find "$STANDALONE_NM" -type d -empty -delete 2>/dev/null || true
66
+ # Remove packages not needed at runtime
67
+ rm -rf "$STANDALONE_NM/typescript" # Only needed for type-checking, not runtime
68
+ rm -rf "$STANDALONE_NM/@types" # TypeScript type definitions
69
+ rm -rf "$STANDALONE_NM/caniuse-lite" # Browser compat data, not needed server-side
70
+ fi
37
71
  # Copy static assets at top level (isBundledRuntimeIntact checks app/.next/static/)
38
72
  cp -r app/.next/static "$WORK/app/.next/static"
39
73
  # Copy public assets
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9207],{51842:(e,r,t)=>{t.d(r,{A:()=>c});var s=t(95155),o=t(12115),a=t(12651),l=t(51914),n=t(66088),d=t(30125),i=t(47376),u=t(35581);function c({value:e,onChange:r,showSkip:t=!1,compact:c=!1,configuredProviders:m,customProviders:x,onAdd:f}){let{locale:h}=(0,u.Y)(),[p,b]=(0,o.useState)(!1),g=(0,i.bf)(),v=m&&m.size>0,y=x&&x.length>0,j=c&&(v||y)&&!t,k=v?i.jt.filter(e=>m.has(e)):[],{primary:N,more:w}=g,C=t=>{let o=i.T_[t],l="zh"===h?o.nameZh:o.name,n=e===t,d=m?.has(t);return(0,s.jsxs)("button",{type:"button",onClick:()=>r(t),className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm ${n?"border-[var(--amber)] bg-[var(--amber-subtle)] shadow-sm":"border-border/50 hover:border-border hover:bg-muted/30"}`,children:[(0,s.jsx)("span",{className:`font-medium ${n?"text-foreground":"text-muted-foreground"}`,children:l}),d&&!n&&(0,s.jsx)(a.A,{size:12,className:"text-success ml-auto shrink-0"}),n&&(0,s.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]},t)},z=t=>{let o=i.T_[t],l="zh"===h?o.nameZh:o.name,n="zh"===h?o.descriptionZh:o.description,d=e===t,u=m?.has(t);return(0,s.jsxs)("button",{type:"button",onClick:()=>r(t),className:"flex items-start gap-3 p-4 rounded-xl border text-left transition-all duration-150",style:{background:d?"var(--amber-dim)":"var(--card)",borderColor:d?"var(--amber)":"var(--border)"},children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--foreground)"},children:l}),n&&(0,s.jsx)("p",{className:"text-xs mt-0.5",style:{color:"var(--muted-foreground)"},children:n}),(0,s.jsx)("p",{className:`text-xs ${n?"mt-1":"mt-0.5"}`,style:{color:"var(--muted-foreground)"},children:o.defaultModel})]}),u&&!d&&(0,s.jsx)(a.A,{size:14,className:"text-success shrink-0 mt-0.5"}),d&&(0,s.jsx)(a.A,{size:16,className:"shrink-0 mt-0.5",style:{color:"var(--amber)"}})]},t)};return j?(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[k.map(e=>C(e)),x?.map(t=>{let o=e===t.id;return(0,s.jsxs)("button",{type:"button",onClick:()=>r(t.id),className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm ${o?"border-[var(--amber)] bg-[var(--amber-subtle)] shadow-sm":"border-border/50 hover:border-border hover:bg-muted/30"}`,children:[(0,s.jsx)("span",{className:`font-medium ${o?"text-foreground":"text-muted-foreground"}`,children:t.name}),o&&(0,s.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]},t.id)}),f&&(0,s.jsxs)("button",{type:"button",onClick:f,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-border/50 text-sm text-muted-foreground hover:border-border hover:text-foreground transition-all",children:[(0,s.jsx)(l.A,{size:14}),(0,s.jsx)("span",{children:"zh"===h?"添加":"Add"})]})]})}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:c?"flex flex-wrap gap-2":"grid grid-cols-1 gap-2",children:N.map(e=>c?C(e):z(e))}),w.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>b(!p),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",children:[(0,s.jsx)(n.A,{size:12,className:`transition-transform ${p?"rotate-180":""}`}),p?"zh"===h?"ζ”Άθ΅·":"Show less":"zh"===h?`ζ›΄ε€š (${w.length})`:`More (${w.length})`]}),p&&(0,s.jsx)("div",{className:c?"flex flex-wrap gap-2":"grid grid-cols-1 gap-2",children:w.map(e=>c?C(e):z(e))})]}),t&&(0,s.jsxs)("button",{type:"button",onClick:()=>r("skip"),className:"flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm w-full mt-1",style:{background:"skip"===e?"var(--amber-dim)":"var(--card)",borderColor:"skip"===e?"var(--amber)":"var(--border)"},children:[(0,s.jsx)(d.A,{size:14,className:"shrink-0",style:{color:"skip"===e?"var(--amber)":"var(--muted-foreground)"}}),(0,s.jsx)("span",{className:`font-medium ${"skip"===e?"text-foreground":"text-muted-foreground"}`,children:"zh"===h?"ζš‚ζ—Άθ·³θΏ‡":"Skip for now"}),"skip"===e&&(0,s.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]})]})}},79704:(e,r,t)=>{t.d(r,{A:()=>i});var s=t(95155),o=t(12115),a=t(6296),l=t(66088),n=t(20171),d=t(47376);function i({value:e,onChange:r,placeholder:t,provider:i,apiKey:u,envKey:c,baseUrl:m,supportsListModels:x,allowNoKey:f,browseLabel:h="Browse",noModelsLabel:p="No models found"}){let[b,g]=(0,o.useState)(null),[v,y]=(0,o.useState)(!1),[j,k]=(0,o.useState)(!1),[N,w]=(0,o.useState)(""),[C,z]=(0,o.useState)(!1),[A,S]=(0,o.useState)(-1),E=(0,o.useRef)(null),$=(0,o.useRef)(null),L=(0,o.useRef)(null),[R,_]=(0,o.useState)({}),D=(0,o.useRef)(!1),T=(0,o.useRef)(0),F=(0,o.useRef)(!1),K=f||!!u||!!c||!!d.T_[i]?.apiKeyFallback;(0,o.useEffect)(()=>{D.current=!1,T.current++,g(null)},[i,u,m]);let M=(0,o.useCallback)(async(e=!1)=>{if(F.current)return;F.current=!0,y(!0),e||w("");let r=T.current;try{let t={provider:i};u&&(t.apiKey=u),m&&(t.baseUrl=m);let s=await fetch("/api/settings/list-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r!==T.current)return;let o=await s.json();if(r!==T.current)return;o.ok&&Array.isArray(o.models)?(g(o.models),D.current=!0,e||k(!0)):e||w(o.error||"Failed to fetch models")}catch{if(r!==T.current)return;e||w("Network error")}finally{F.current=!1,y(!1)}},[i,u,m]),Z=(0,o.useCallback)(()=>{z(!0),!D.current&&x&&K&&!F.current&&M(!0)},[x,K,M]),B=(0,o.useMemo)(()=>{if(!b)return[];if(!e.trim())return b;let r=e.toLowerCase();return[...b].sort((e,t)=>{let s=e.toLowerCase(),o=t.toLowerCase(),a=s.includes(r),l=o.includes(r);if(a!==l)return a?-1:1;if(a&&l){let e=s.startsWith(r);if(e!==o.startsWith(r))return e?-1:1;let t=s===r;if(t!==(o===r))return t?-1:1}return e.localeCompare(t)})},[b,e]),O=j||C&&null!==b&&e.trim().length>0&&B.length>0;(0,o.useEffect)(()=>{if(!O||!$.current)return;let e=$.current.getBoundingClientRect();_({position:"fixed",top:e.bottom+4,left:e.left,width:e.width})},[O]),(0,o.useEffect)(()=>{S(-1)},[B]),(0,o.useEffect)(()=>{if(A<0||!L.current)return;let e=L.current.querySelectorAll("[data-model-item]");e[A]?.scrollIntoView({block:"nearest"})},[A]);let U=(0,o.useCallback)(e=>{let t=O?B:[];t.length&&("ArrowDown"===e.key?(e.preventDefault(),S(e=>(e+1)%t.length)):"ArrowUp"===e.key?(e.preventDefault(),S(e=>(e-1+t.length)%t.length)):"Enter"===e.key&&A>=0&&A<t.length?(e.preventDefault(),r(t[A]),k(!1),z(!1)):"Escape"===e.key&&(k(!1),z(!1)))},[O,B,A,r]);return(0,o.useEffect)(()=>{if(O)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){E.current&&!E.current.contains(e.target)&&(k(!1),z(!1))}},[O]),(0,s.jsxs)("div",{ref:E,className:"relative",children:[(0,s.jsxs)("div",{ref:$,className:"flex gap-1.5",children:[(0,s.jsx)(n.pd,{value:e,onChange:e=>{r(e.target.value),j||z(!0)},onFocus:Z,onKeyDown:U,placeholder:t,className:"flex-1",autoComplete:"off"}),x&&(0,s.jsxs)("button",{type:"button",disabled:!K||v,onClick:()=>M(!1),title:h,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:border-foreground/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[v?(0,s.jsx)(a.A,{size:12,className:"animate-spin"}):(0,s.jsx)(l.A,{size:12}),h]})]}),N&&(0,s.jsx)("p",{className:"text-xs text-error mt-1",children:N}),O&&B.length>0&&(0,s.jsx)("div",{ref:L,style:R,className:"fixed z-50 max-h-48 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg",children:B.map((t,o)=>{let a=!e.trim()||t.toLowerCase().includes(e.toLowerCase());return(0,s.jsx)("button",{type:"button","data-model-item":!0,className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${t===e?"bg-accent/60 font-medium":o===A?"bg-accent":"hover:bg-accent"} ${!a?"opacity-50":""}`,onClick:()=>{r(t),k(!1),z(!1)},children:t},t)})}),j&&0===B.length&&(0,s.jsx)("div",{style:R,className:"fixed z-50 rounded-lg border border-border bg-popover shadow-lg px-3 py-2 text-xs text-muted-foreground",children:p})]})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1227],{729:(e,t,r)=>{"use strict";r.d(t,{default:()=>j});var s=r(95155),a=r(12115),l=r(68459),i=r(38798),n=r(33078),d=r(48368),o=r(41585),c=r(6296),u=r(9199),m=r(33210),h=r(73321),x=r(35581),f=r(9339);let p=(0,f.createServerReference)("60406dc77d1b718062048258d5454d5a9441a65db7",f.callServer,void 0,f.findSourceMapURL,"restoreFromTrashAction"),b=(0,f.createServerReference)("40f00189372e0652e0b80b9458043fdef6462ab28c",f.callServer,void 0,f.findSourceMapURL,"permanentlyDeleteAction"),v=(0,f.createServerReference)("009102f21f80fd5d09459f7919bb6240c4c4993e12",f.callServer,void 0,f.findSourceMapURL,"emptyTrashAction");var g=r(39498),y=r(4235);function j({initialItems:e}){let{t}=(0,x.Y)(),r=(0,h.useRouter)(),[f,j]=(0,a.useState)(e),[N,k]=(0,a.useTransition)(),[A,w]=(0,a.useState)(!1),[M,C]=(0,a.useState)(null),[S,R]=(0,a.useState)(null),[z,P]=(0,a.useState)(null),L=(0,a.useCallback)(async e=>{P(e.id);try{let s=await p(e.id,"restore");s.success?(j(t=>t.filter(t=>t.id!==e.id)),y.oR.success(t.trash.restored),r.refresh()):s.conflict?R(e):y.oR.error(s.error??t.trash.restoreFailed)}finally{P(null)}},[t,r]),T=(0,a.useCallback)(async e=>{if(!S)return;let s=await p(S.id,e);s.success?(j(e=>e.filter(e=>e.id!==S.id)),y.oR.success(t.trash.restored),R(null),r.refresh()):y.oR.error(s.error??t.trash.restoreFailed)},[S,t,r]),_=(0,a.useCallback)(async()=>{if(!M)return;let e=await b(M.id);e.success?(j(e=>e.filter(e=>e.id!==M.id)),y.oR.success(t.trash.deleted)):y.oR.error(e.error??t.trash.deleteFailed),C(null)},[M,t]),E=(0,a.useCallback)(async()=>{k(async()=>{let e=await v();e.success?(j([]),y.oR.success(t.trash.emptied(e.count??0))):y.oR.error(e.error??t.trash.emptyFailed),w(!1)})},[t]);return(0,s.jsxs)("div",{className:"min-h-screen",children:[(0,s.jsx)("div",{className:"px-4 md:px-6 pt-6 md:pt-8",children:(0,s.jsx)("div",{className:"content-width xl:mr-[220px] rounded-xl border border-border bg-card px-4 py-3 md:px-5 md:py-4",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,s.jsx)(l.A,{size:15}),t.trash.title]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:t.trash.subtitle}),f.length>0&&(0,s.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:t.trash.itemCount(f.length)})]}),f.length>0&&(0,s.jsx)("button",{type:"button",onClick:()=>w(!0),disabled:N,className:"px-2.5 py-1.5 rounded-md text-xs font-medium bg-error/10 text-error hover:bg-error/20 transition-colors disabled:opacity-50",children:t.trash.emptyTrash})]})})}),(0,s.jsx)("div",{className:"px-4 md:px-6 py-4 md:py-6",children:(0,s.jsx)("div",{className:"content-width xl:mr-[220px]",children:0===f.length?(0,s.jsxs)("div",{className:"rounded-xl border border-border/40 bg-card/30 p-12 text-center",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-muted/60 mb-4",children:(0,s.jsx)(l.A,{size:22,className:"text-muted-foreground/40"})}),(0,s.jsx)("p",{className:"text-sm font-medium text-muted-foreground/70",children:t.trash.empty}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/40 mt-1 max-w-xs mx-auto leading-relaxed",children:t.trash.emptySubtext})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:f.map(e=>{let r=Math.max(0,Math.ceil((new Date(e.expiresAt).getTime()-Date.now())/864e5)),a=r<=3;return(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4 flex flex-col gap-3 hover:border-border/80 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 min-w-0",children:[(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg bg-muted/50 flex items-center justify-center shrink-0",children:e.isDirectory?(0,s.jsx)(i.A,{size:16,className:"text-muted-foreground"}):e.fileName.endsWith(".csv")?(0,s.jsx)(n.A,{size:16,className:"text-success"}):(0,s.jsx)(d.A,{size:16,className:"text-muted-foreground"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground truncate",title:e.fileName,children:e.fileName}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground truncate mt-0.5",title:e.originalPath,children:[t.trash.from,": ",e.originalPath.split("/").slice(0,-1).join("/")||"/"]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-2xs text-muted-foreground",children:t.trash.deletedAgo(function(e,t){let r=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(r<1)return t.justNow??"just now";if(r<60)return t.minutesAgo?.(r)??`${r}m ago`;let s=Math.floor(r/60);if(s<24)return t.hoursAgo?.(s)??`${s}h ago`;let a=Math.floor(s/24);return t.daysAgo?.(a)??`${a}d ago`}(e.deletedAt,t.trash))}),(0,s.jsxs)("span",{className:`text-2xs ${a?"text-error":"text-muted-foreground/60"}`,children:[a&&(0,s.jsx)(o.A,{size:9,className:"inline mr-0.5"}),t.trash.expiresIn(r)]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>L(e),disabled:z===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs font-medium bg-success/10 text-success hover:bg-success/20 transition-colors disabled:opacity-50",children:[z===e.id?(0,s.jsx)(c.A,{size:11,className:"animate-spin"}):(0,s.jsx)(u.A,{size:11}),t.trash.restore]}),(0,s.jsx)("button",{type:"button",onClick:()=>C(e),className:"p-1 rounded-md text-muted-foreground hover:text-error hover:bg-error/10 transition-colors",title:t.trash.deletePermanently,children:(0,s.jsx)(m.A,{size:13})})]})]})]},e.id)})})})}),(0,s.jsx)(g.TM,{open:A,title:t.trash.emptyTrash,message:t.trash.emptyTrashConfirm,confirmLabel:t.trash.emptyTrash,cancelLabel:t.trash.cancel??"Cancel",onConfirm:()=>void E(),onCancel:()=>w(!1),variant:"destructive"}),(0,s.jsx)(g.TM,{open:!!M,title:t.trash.deletePermanently,message:M?t.trash.deletePermanentlyConfirm(M.fileName):"",confirmLabel:t.trash.deletePermanently,cancelLabel:t.trash.cancel??"Cancel",onConfirm:()=>void _(),onCancel:()=>C(null),variant:"destructive"}),S&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center modal-backdrop",children:(0,s.jsxs)("div",{className:"bg-card border border-border rounded-xl shadow-xl max-w-sm w-full mx-4 p-5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)(o.A,{size:16,className:"text-[var(--amber)]"}),(0,s.jsx)("h3",{className:"text-sm font-semibold",children:t.trash.restoreConflict})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground mb-4",children:['"',S.fileName,'" β€” ',S.originalPath]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,s.jsx)("button",{type:"button",onClick:()=>R(null),className:"px-3 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:t.trash.cancel??"Cancel"}),(0,s.jsx)("button",{type:"button",onClick:()=>void T("copy"),className:"px-3 py-1.5 rounded-md text-xs font-medium bg-muted text-foreground hover:bg-muted/80 transition-colors",children:t.trash.saveAsCopy}),(0,s.jsx)("button",{type:"button",onClick:()=>void T("overwrite"),className:"px-3 py-1.5 rounded-md text-xs font-medium bg-[var(--amber-dim)] text-[var(--amber-text)] hover:opacity-80 transition-colors",children:t.trash.overwrite})]})]})})]})}},1934:(e,t,r)=>{"use strict";r.d(t,{v:()=>i});var s=r(12115);let a=e=>{let t,r=new Set,s=(e,s)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=s?s:"object"!=typeof a||null===a)?a:Object.assign({},t,a),r.forEach(r=>r(t,e))}},a=()=>t,l={setState:s,getState:a,getInitialState:()=>i,subscribe:e=>(r.add(e),()=>r.delete(e))},i=t=e(s,a,l);return l},l=e=>{let t=e?a(e):a,r=e=>(function(e,t=e=>e){let r=s.useSyncExternalStore(e.subscribe,s.useCallback(()=>t(e.getState()),[e,t]),s.useCallback(()=>t(e.getInitialState()),[e,t]));return s.useDebugValue(r),r})(t,e);return Object.assign(r,t),r},i=e=>e?l(e):l},6296:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},9199:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},9339:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s={callServer:function(){return l.callServer},createServerReference:function(){return n.createServerReference},findSourceMapURL:function(){return i.findSourceMapURL}};for(var a in s)Object.defineProperty(t,a,{enumerable:!0,get:s[a]});let l=r(77304),i=r(4060),n=r(77197)},33078:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]])},33210:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},38798:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]])},41585:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},48368:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},51914:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},54839:(e,t,r)=>{Promise.resolve().then(r.bind(r,729))},68459:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(90425).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},73321:(e,t,r)=>{"use strict";var s=r(74645);r.o(s,"usePathname")&&r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")&&r.d(t,{useSearchParams:function(){return s.useSearchParams}})},90425:(e,t,r)=>{"use strict";r.d(t,{A:()=>d});var s=r(12115);let a=(...e)=>e.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),l=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let n=(0,s.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:n="",children:d,iconNode:o,...c},u)=>(0,s.createElement)("svg",{ref:u,...i,width:t,height:t,stroke:e,strokeWidth:l?24*Number(r)/Number(t):r,className:a("lucide",n),...!d&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(c)&&{"aria-hidden":"true"},...c},[...o.map(([e,t])=>(0,s.createElement)(e,t)),...Array.isArray(d)?d:[d]])),d=(e,t)=>{let r=(0,s.forwardRef)(({className:r,...i},d)=>(0,s.createElement)(n,{ref:d,iconNode:t,className:a(`lucide-${l(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,r),...i}));return r.displayName=l(e),r}}},e=>{e.O(0,[5581,8252,8441,3794,7358],()=>e(e.s=54839)),_N_E=e.O()}]);