@seqyuan/annovibe 0.8.41 → 0.8.54

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 (239) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +14 -7
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/routes-manifest.json +48 -8
  8. package/.next/server/app/_global-error/page.js +2 -2
  9. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/_global-error.html +1 -1
  11. package/.next/server/app/_global-error.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  17. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/.next/server/app/_not-found/page.js +2 -2
  19. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/.next/server/app/_not-found.html +1 -1
  21. package/.next/server/app/_not-found.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  26. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  27. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  28. package/.next/server/app/api/agent/[id]/events/route.js +1 -1
  29. package/.next/server/app/api/agent/[id]/route.js +1 -1
  30. package/.next/server/app/api/agent/new/route.js +1 -1
  31. package/.next/server/app/api/agent/runtime/route.js +1 -1
  32. package/.next/server/app/api/apps/[id]/[[...path]]/route.js +1 -1
  33. package/.next/server/app/api/apps/route.js +2 -2
  34. package/.next/server/app/api/auth/all-providers/route.js +1 -1
  35. package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
  36. package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
  37. package/.next/server/app/api/auth/login/route.js +1 -1
  38. package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
  39. package/.next/server/app/api/auth/providers/route.js +1 -1
  40. package/.next/server/app/api/auth/status/route.js +1 -1
  41. package/.next/server/app/api/default-cwd/route.js +1 -1
  42. package/.next/server/app/api/files/[...path]/route.js +3 -3
  43. package/.next/server/app/api/harness/route.js +1 -1
  44. package/.next/server/app/api/home/route.js +1 -1
  45. package/.next/server/app/api/im/cancel/route.js +1 -0
  46. package/.next/server/app/api/im/cancel/route_client-reference-manifest.js +1 -0
  47. package/.next/server/app/api/im/gateway-status/route.js +1 -0
  48. package/.next/server/app/api/im/gateway-status/route_client-reference-manifest.js +1 -0
  49. package/.next/server/app/api/im/gateway-token/route.js +1 -0
  50. package/.next/server/app/api/im/gateway-token/route_client-reference-manifest.js +1 -0
  51. package/.next/server/app/api/im/project/route.js +1 -0
  52. package/.next/server/app/api/im/project/route_client-reference-manifest.js +1 -0
  53. package/.next/server/app/api/im/projects/route.js +1 -0
  54. package/.next/server/app/api/im/projects/route_client-reference-manifest.js +1 -0
  55. package/.next/server/app/api/im/session-ids/route.js +1 -0
  56. package/.next/server/app/api/im/session-ids/route_client-reference-manifest.js +1 -0
  57. package/.next/server/app/api/im/turn/route.js +3 -0
  58. package/.next/server/app/api/im/turn/route_client-reference-manifest.js +1 -0
  59. package/.next/server/app/api/internal/runtime/route.js +1 -1
  60. package/.next/server/app/api/memory/promote/route.js +2 -2
  61. package/.next/server/app/api/models/route.js +1 -1
  62. package/.next/server/app/api/models-config/discover/route.js +1 -1
  63. package/.next/server/app/api/models-config/route.js +1 -1
  64. package/.next/server/app/api/models-config/test/route.js +1 -1
  65. package/.next/server/app/api/plot-kernels/route.js +1 -1
  66. package/.next/server/app/api/plot-kernels/save/route.js +1 -0
  67. package/.next/server/app/api/plot-kernels/save/route_client-reference-manifest.js +1 -0
  68. package/.next/server/app/api/plot-kernels/status/route.js +1 -1
  69. package/.next/server/app/api/plot-kernels/stop/route.js +1 -1
  70. package/.next/server/app/api/projects/browse/route.js +1 -1
  71. package/.next/server/app/api/projects/route.js +2 -2
  72. package/.next/server/app/api/search/route.js +2 -2
  73. package/.next/server/app/api/sessions/[id]/context/route.js +2 -2
  74. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  75. package/.next/server/app/api/sessions/new/route.js +1 -1
  76. package/.next/server/app/api/sessions/route.js +2 -2
  77. package/.next/server/app/api/settings/route.js +1 -1
  78. package/.next/server/app/api/skills/install/route.js +2 -2
  79. package/.next/server/app/api/skills/route.js +2 -2
  80. package/.next/server/app/api/skills/search/route.js +1 -1
  81. package/.next/server/app/api/soul/route.js +1 -1
  82. package/.next/server/app/api/subagents/status/route.js +1 -1
  83. package/.next/server/app/api/version/route.js +1 -1
  84. package/.next/server/app/favicon.ico/route.js +1 -1
  85. package/.next/server/app/icon.svg/route.js +1 -1
  86. package/.next/server/app/index.html +1 -1
  87. package/.next/server/app/index.rsc +2 -2
  88. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  89. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  90. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  91. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  92. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  93. package/.next/server/app/login/page.js +2 -2
  94. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  95. package/.next/server/app/login.html +1 -1
  96. package/.next/server/app/login.rsc +1 -1
  97. package/.next/server/app/login.segments/_full.segment.rsc +1 -1
  98. package/.next/server/app/login.segments/_head.segment.rsc +1 -1
  99. package/.next/server/app/login.segments/_index.segment.rsc +1 -1
  100. package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  101. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
  102. package/.next/server/app/login.segments/login.segment.rsc +1 -1
  103. package/.next/server/app/page.js +10 -10
  104. package/.next/server/app/page_client-reference-manifest.js +1 -1
  105. package/.next/server/app/smoke/page.js +3 -3
  106. package/.next/server/app/smoke/page_client-reference-manifest.js +1 -1
  107. package/.next/server/app/smoke.html +78 -23
  108. package/.next/server/app/smoke.rsc +2 -2
  109. package/.next/server/app/smoke.segments/_full.segment.rsc +2 -2
  110. package/.next/server/app/smoke.segments/_head.segment.rsc +1 -1
  111. package/.next/server/app/smoke.segments/_index.segment.rsc +1 -1
  112. package/.next/server/app/smoke.segments/_tree.segment.rsc +1 -1
  113. package/.next/server/app/smoke.segments/smoke/__PAGE__.segment.rsc +2 -2
  114. package/.next/server/app/smoke.segments/smoke.segment.rsc +1 -1
  115. package/.next/server/app-paths-manifest.json +14 -7
  116. package/.next/server/chunks/1494.js +278 -0
  117. package/.next/server/chunks/7601.js +44 -75
  118. package/.next/server/functions-config-manifest.json +3 -0
  119. package/.next/server/middleware-build-manifest.js +1 -1
  120. package/.next/server/next-font-manifest.js +1 -1
  121. package/.next/server/next-font-manifest.json +1 -1
  122. package/.next/server/pages/404.html +1 -1
  123. package/.next/server/pages/500.html +1 -1
  124. package/.next/server/server-reference-manifest.json +1 -1
  125. package/.next/static/TS6P9hsexC-QhX3lT3LiC/_buildManifest.js +1 -0
  126. package/.next/static/chunks/9901-7e044d778f6622ea.js +278 -0
  127. package/.next/static/chunks/app/_global-error/page-b23e767fd4cc8cb6.js +1 -0
  128. package/.next/static/chunks/app/api/agent/[id]/events/route-b23e767fd4cc8cb6.js +1 -0
  129. package/.next/static/chunks/app/api/agent/[id]/route-b23e767fd4cc8cb6.js +1 -0
  130. package/.next/static/chunks/app/api/agent/new/route-b23e767fd4cc8cb6.js +1 -0
  131. package/.next/static/chunks/app/api/agent/runtime/route-b23e767fd4cc8cb6.js +1 -0
  132. package/.next/static/chunks/app/api/apps/[id]/[[...path]]/route-b23e767fd4cc8cb6.js +1 -0
  133. package/.next/static/chunks/app/api/apps/route-b23e767fd4cc8cb6.js +1 -0
  134. package/.next/static/chunks/app/api/auth/all-providers/route-b23e767fd4cc8cb6.js +1 -0
  135. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-b23e767fd4cc8cb6.js +1 -0
  136. package/.next/static/chunks/app/api/auth/login/[provider]/route-b23e767fd4cc8cb6.js +1 -0
  137. package/.next/static/chunks/app/api/auth/login/route-b23e767fd4cc8cb6.js +1 -0
  138. package/.next/static/chunks/app/api/auth/logout/[provider]/route-b23e767fd4cc8cb6.js +1 -0
  139. package/.next/static/chunks/app/api/auth/providers/route-b23e767fd4cc8cb6.js +1 -0
  140. package/.next/static/chunks/app/api/auth/status/route-b23e767fd4cc8cb6.js +1 -0
  141. package/.next/static/chunks/app/api/default-cwd/route-b23e767fd4cc8cb6.js +1 -0
  142. package/.next/static/chunks/app/api/files/[...path]/route-b23e767fd4cc8cb6.js +1 -0
  143. package/.next/static/chunks/app/api/harness/route-b23e767fd4cc8cb6.js +1 -0
  144. package/.next/static/chunks/app/api/home/route-b23e767fd4cc8cb6.js +1 -0
  145. package/.next/static/chunks/app/api/im/cancel/route-b23e767fd4cc8cb6.js +1 -0
  146. package/.next/static/chunks/app/api/im/gateway-status/route-b23e767fd4cc8cb6.js +1 -0
  147. package/.next/static/chunks/app/api/im/gateway-token/route-b23e767fd4cc8cb6.js +1 -0
  148. package/.next/static/chunks/app/api/im/project/route-b23e767fd4cc8cb6.js +1 -0
  149. package/.next/static/chunks/app/api/im/projects/route-b23e767fd4cc8cb6.js +1 -0
  150. package/.next/static/chunks/app/api/im/session-ids/route-b23e767fd4cc8cb6.js +1 -0
  151. package/.next/static/chunks/app/api/im/turn/route-b23e767fd4cc8cb6.js +1 -0
  152. package/.next/static/chunks/app/api/internal/runtime/route-b23e767fd4cc8cb6.js +1 -0
  153. package/.next/static/chunks/app/api/memory/promote/route-b23e767fd4cc8cb6.js +1 -0
  154. package/.next/static/chunks/app/api/models/route-b23e767fd4cc8cb6.js +1 -0
  155. package/.next/static/chunks/app/api/models-config/discover/route-b23e767fd4cc8cb6.js +1 -0
  156. package/.next/static/chunks/app/api/models-config/route-b23e767fd4cc8cb6.js +1 -0
  157. package/.next/static/chunks/app/api/models-config/test/route-b23e767fd4cc8cb6.js +1 -0
  158. package/.next/static/chunks/app/api/plot-kernels/route-b23e767fd4cc8cb6.js +1 -0
  159. package/.next/static/chunks/app/api/plot-kernels/save/route-b23e767fd4cc8cb6.js +1 -0
  160. package/.next/static/chunks/app/api/plot-kernels/status/route-b23e767fd4cc8cb6.js +1 -0
  161. package/.next/static/chunks/app/api/plot-kernels/stop/route-b23e767fd4cc8cb6.js +1 -0
  162. package/.next/static/chunks/app/api/projects/browse/route-b23e767fd4cc8cb6.js +1 -0
  163. package/.next/static/chunks/app/api/projects/route-b23e767fd4cc8cb6.js +1 -0
  164. package/.next/static/chunks/app/api/search/route-b23e767fd4cc8cb6.js +1 -0
  165. package/.next/static/chunks/app/api/sessions/[id]/context/route-b23e767fd4cc8cb6.js +1 -0
  166. package/.next/static/chunks/app/api/sessions/[id]/route-b23e767fd4cc8cb6.js +1 -0
  167. package/.next/static/chunks/app/api/sessions/new/route-b23e767fd4cc8cb6.js +1 -0
  168. package/.next/static/chunks/app/api/sessions/route-b23e767fd4cc8cb6.js +1 -0
  169. package/.next/static/chunks/app/api/settings/route-b23e767fd4cc8cb6.js +1 -0
  170. package/.next/static/chunks/app/api/skills/install/route-b23e767fd4cc8cb6.js +1 -0
  171. package/.next/static/chunks/app/api/skills/route-b23e767fd4cc8cb6.js +1 -0
  172. package/.next/static/chunks/app/api/skills/search/route-b23e767fd4cc8cb6.js +1 -0
  173. package/.next/static/chunks/app/api/soul/route-b23e767fd4cc8cb6.js +1 -0
  174. package/.next/static/chunks/app/api/subagents/status/route-b23e767fd4cc8cb6.js +1 -0
  175. package/.next/static/chunks/app/api/version/route-b23e767fd4cc8cb6.js +1 -0
  176. package/.next/static/chunks/app/favicon.ico/route-b23e767fd4cc8cb6.js +1 -0
  177. package/.next/static/chunks/app/page-7dae74b4ec345ca7.js +27 -0
  178. package/.next/static/chunks/app/smoke/{page-431310549b820f3b.js → page-d1be0dc9ec4396ba.js} +2 -2
  179. package/.next/static/chunks/next/dist/client/components/builtin/app-error-b23e767fd4cc8cb6.js +1 -0
  180. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-b23e767fd4cc8cb6.js +1 -0
  181. package/.next/static/chunks/next/dist/client/components/builtin/not-found-b23e767fd4cc8cb6.js +1 -0
  182. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b23e767fd4cc8cb6.js +1 -0
  183. package/bin/annovibe-im-gateway.js +675 -0
  184. package/bin/pi-web.js +60 -1
  185. package/package.json +3 -2
  186. package/.next/server/app/api/reports/[id]/route.js +0 -12
  187. package/.next/server/app/api/reports/[id]/route_client-reference-manifest.js +0 -1
  188. package/.next/server/chunks/1210.js +0 -246
  189. package/.next/static/3gDAeILrwgLWhlwi2MAOg/_buildManifest.js +0 -1
  190. package/.next/static/chunks/9595-2f001a1f6d133466.js +0 -246
  191. package/.next/static/chunks/app/_global-error/page-412387d4b52026c9.js +0 -1
  192. package/.next/static/chunks/app/api/agent/[id]/events/route-412387d4b52026c9.js +0 -1
  193. package/.next/static/chunks/app/api/agent/[id]/route-412387d4b52026c9.js +0 -1
  194. package/.next/static/chunks/app/api/agent/new/route-412387d4b52026c9.js +0 -1
  195. package/.next/static/chunks/app/api/agent/runtime/route-412387d4b52026c9.js +0 -1
  196. package/.next/static/chunks/app/api/apps/[id]/[[...path]]/route-412387d4b52026c9.js +0 -1
  197. package/.next/static/chunks/app/api/apps/route-412387d4b52026c9.js +0 -1
  198. package/.next/static/chunks/app/api/auth/all-providers/route-412387d4b52026c9.js +0 -1
  199. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-412387d4b52026c9.js +0 -1
  200. package/.next/static/chunks/app/api/auth/login/[provider]/route-412387d4b52026c9.js +0 -1
  201. package/.next/static/chunks/app/api/auth/login/route-412387d4b52026c9.js +0 -1
  202. package/.next/static/chunks/app/api/auth/logout/[provider]/route-412387d4b52026c9.js +0 -1
  203. package/.next/static/chunks/app/api/auth/providers/route-412387d4b52026c9.js +0 -1
  204. package/.next/static/chunks/app/api/auth/status/route-412387d4b52026c9.js +0 -1
  205. package/.next/static/chunks/app/api/default-cwd/route-412387d4b52026c9.js +0 -1
  206. package/.next/static/chunks/app/api/files/[...path]/route-412387d4b52026c9.js +0 -1
  207. package/.next/static/chunks/app/api/harness/route-412387d4b52026c9.js +0 -1
  208. package/.next/static/chunks/app/api/home/route-412387d4b52026c9.js +0 -1
  209. package/.next/static/chunks/app/api/internal/runtime/route-412387d4b52026c9.js +0 -1
  210. package/.next/static/chunks/app/api/memory/promote/route-412387d4b52026c9.js +0 -1
  211. package/.next/static/chunks/app/api/models/route-412387d4b52026c9.js +0 -1
  212. package/.next/static/chunks/app/api/models-config/discover/route-412387d4b52026c9.js +0 -1
  213. package/.next/static/chunks/app/api/models-config/route-412387d4b52026c9.js +0 -1
  214. package/.next/static/chunks/app/api/models-config/test/route-412387d4b52026c9.js +0 -1
  215. package/.next/static/chunks/app/api/plot-kernels/route-412387d4b52026c9.js +0 -1
  216. package/.next/static/chunks/app/api/plot-kernels/status/route-412387d4b52026c9.js +0 -1
  217. package/.next/static/chunks/app/api/plot-kernels/stop/route-412387d4b52026c9.js +0 -1
  218. package/.next/static/chunks/app/api/projects/browse/route-412387d4b52026c9.js +0 -1
  219. package/.next/static/chunks/app/api/projects/route-412387d4b52026c9.js +0 -1
  220. package/.next/static/chunks/app/api/reports/[id]/route-412387d4b52026c9.js +0 -1
  221. package/.next/static/chunks/app/api/search/route-412387d4b52026c9.js +0 -1
  222. package/.next/static/chunks/app/api/sessions/[id]/context/route-412387d4b52026c9.js +0 -1
  223. package/.next/static/chunks/app/api/sessions/[id]/route-412387d4b52026c9.js +0 -1
  224. package/.next/static/chunks/app/api/sessions/new/route-412387d4b52026c9.js +0 -1
  225. package/.next/static/chunks/app/api/sessions/route-412387d4b52026c9.js +0 -1
  226. package/.next/static/chunks/app/api/settings/route-412387d4b52026c9.js +0 -1
  227. package/.next/static/chunks/app/api/skills/install/route-412387d4b52026c9.js +0 -1
  228. package/.next/static/chunks/app/api/skills/route-412387d4b52026c9.js +0 -1
  229. package/.next/static/chunks/app/api/skills/search/route-412387d4b52026c9.js +0 -1
  230. package/.next/static/chunks/app/api/soul/route-412387d4b52026c9.js +0 -1
  231. package/.next/static/chunks/app/api/subagents/status/route-412387d4b52026c9.js +0 -1
  232. package/.next/static/chunks/app/api/version/route-412387d4b52026c9.js +0 -1
  233. package/.next/static/chunks/app/favicon.ico/route-412387d4b52026c9.js +0 -1
  234. package/.next/static/chunks/app/page-d82d53365a2be371.js +0 -27
  235. package/.next/static/chunks/next/dist/client/components/builtin/app-error-412387d4b52026c9.js +0 -1
  236. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-412387d4b52026c9.js +0 -1
  237. package/.next/static/chunks/next/dist/client/components/builtin/not-found-412387d4b52026c9.js +0 -1
  238. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-412387d4b52026c9.js +0 -1
  239. /package/.next/static/{3gDAeILrwgLWhlwi2MAOg → TS6P9hsexC-QhX3lT3LiC}/_ssgManifest.js +0 -0
package/bin/pi-web.js CHANGED
@@ -37,6 +37,7 @@ const stateFile = path.join(agentDir, "annovibe.json");
37
37
  const legacyStateFile = path.join(agentDir, "pidex.json");
38
38
  const logFile = path.join(agentDir, "annovibe.log");
39
39
  const legacyLogFile = path.join(agentDir, "pidex.log");
40
+ const imGatewayLogFile = path.join(agentDir, "annovibe-im-gateway.log");
40
41
  const STOP_TERM_TIMEOUT_MS = 6000;
41
42
  const STOP_KILL_TIMEOUT_MS = 2000;
42
43
  const PROCESS_TITLE = "annovibe";
@@ -487,6 +488,8 @@ function renderState(state, json = false) {
487
488
  restartStartedAt: state?.restartStartedAt ?? null,
488
489
  logFile,
489
490
  stateFile,
491
+ imGatewayPid: state?.imGatewayPid && isPidAlive(state.imGatewayPid) ? state.imGatewayPid : null,
492
+ imGatewayLogFile: state?.imGatewayLogFile ?? imGatewayLogFile,
490
493
  };
491
494
  if (json) return JSON.stringify(payload, null, 2);
492
495
  if (payload.status === "stopped") {
@@ -508,6 +511,7 @@ function renderState(state, json = false) {
508
511
  `restart: pending${payload.installedVersion ? ` for v${payload.installedVersion}` : ""}`,
509
512
  ] : []),
510
513
  `log: ${payload.logFile}`,
514
+ ...(payload.imGatewayPid ? [`im-gateway pid: ${payload.imGatewayPid}`, `im-gateway log: ${payload.imGatewayLogFile}`] : ["im-gateway: not started"]),
511
515
  ].join("\n");
512
516
  }
513
517
 
@@ -563,6 +567,21 @@ async function stopManagedServer(quiet = false) {
563
567
  stopped = portStop.stopped && stopped;
564
568
  }
565
569
 
570
+ // Stop orphaned IM gateway (in case supervisor died but gateway lived on)
571
+ let imGatewayStopped = true;
572
+ try {
573
+ const imStatePath = path.join(agentDir, "im", "gateway.json");
574
+ if (fs.existsSync(imStatePath)) {
575
+ const imState = JSON.parse(fs.readFileSync(imStatePath, "utf8"));
576
+ if (imState?.pid && isPidAlive(imState.pid)) {
577
+ imGatewayStopped = await terminatePid(imState.pid);
578
+ if (!quiet) console.log(`annovibe stop: stopped im-gateway pid ${imState.pid}`);
579
+ }
580
+ }
581
+ } catch {
582
+ // ignore errors reading IM gateway state
583
+ }
584
+
566
585
  if (stopped) {
567
586
  removeState();
568
587
  if (!quiet) {
@@ -572,6 +591,7 @@ async function stopManagedServer(quiet = false) {
572
591
  console.log("annovibe stop: state was stale; cleaned up");
573
592
  }
574
593
  }
594
+ if (!imGatewayStopped) return 1;
575
595
  return 0;
576
596
  }
577
597
  if (!quiet) console.error(`annovibe stop: failed to stop annovibe process${verifiedCount === 1 ? "" : "es"}`);
@@ -671,9 +691,10 @@ Usage:
671
691
  annovibe [options]
672
692
  annovibe start Start annovibe in background
673
693
  annovibe restart Stop then start annovibe in background
674
- annovibe stop Stop background annovibe
694
+ annovibe stop Stop background annovibe and im-gateway (and orphaned processes)
675
695
  annovibe status [--json] Show background server status
676
696
  annovibe logs [-f] Show background server logs
697
+ annovibe im-gateway Run WeCom IM sidecar standalone (auto-started by annovibe start)
677
698
  annovibe passwd Change password (or set if none)
678
699
  annovibe passwd --reset Remove password (disable auth)
679
700
  annovibe update Update to the latest version
@@ -744,6 +765,20 @@ if (firstPos === "restart") {
744
765
  return;
745
766
  }
746
767
 
768
+ if (firstPos === "im-gateway") {
769
+ console.error("Note: im-gateway is auto-started by annovibe start. Use this command only for standalone debugging.");
770
+ const gatewayScript = path.join(__dirname, "annovibe-im-gateway.js");
771
+ const child = spawn(process.execPath, [gatewayScript, ...positionals.slice(1)], {
772
+ stdio: "inherit",
773
+ env: process.env,
774
+ });
775
+ child.on("exit", (code, signal) => {
776
+ if (signal) process.exit(1);
777
+ process.exit(code ?? 0);
778
+ });
779
+ return;
780
+ }
781
+
747
782
  if (firstPos === "update") {
748
783
  console.log(`\n Updating ${PKG_NAME} to latest version...\n`);
749
784
  const npmExecPath = process.env.npm_execpath;
@@ -1055,6 +1090,27 @@ async function runServerProcess() {
1055
1090
  });
1056
1091
  let restarting = false;
1057
1092
 
1093
+ // Spawn IM gateway as a child of the supervisor
1094
+ const gatewayScript = path.join(__dirname, "annovibe-im-gateway.js");
1095
+ let imGatewayChild = null;
1096
+ if (fs.existsSync(gatewayScript)) {
1097
+ const gwFd = fs.openSync(imGatewayLogFile, "a");
1098
+ imGatewayChild = spawn(process.execPath, [gatewayScript], {
1099
+ cwd: pkgDir,
1100
+ stdio: ["ignore", gwFd, gwFd],
1101
+ env: {
1102
+ ...process.env,
1103
+ ANNOVIBE_SUPERVISOR_PID: String(process.pid),
1104
+ ANNOVIBE_IM_GATEWAY_MANAGED: "1",
1105
+ },
1106
+ });
1107
+ fs.closeSync(gwFd);
1108
+ imGatewayChild.on("exit", (code, signal) => {
1109
+ const reason = signal ? `signal ${signal}` : `code ${code ?? "null"}`;
1110
+ console.error(`annovibe: im-gateway exited with ${reason}`);
1111
+ });
1112
+ }
1113
+
1058
1114
  const writeCurrentState = (patch = {}) => {
1059
1115
  const current = readState() ?? {};
1060
1116
  writeState({
@@ -1063,6 +1119,8 @@ async function runServerProcess() {
1063
1119
  command: getServerCommand(),
1064
1120
  supervisorPid: process.pid,
1065
1121
  nextPid: child.pid ?? null,
1122
+ imGatewayPid: imGatewayChild?.pid ?? null,
1123
+ imGatewayLogFile,
1066
1124
  port: String(port),
1067
1125
  hostname,
1068
1126
  url,
@@ -1097,6 +1155,7 @@ async function runServerProcess() {
1097
1155
  const shutdown = async () => {
1098
1156
  stopAutoRestartWatcher();
1099
1157
  await terminatePid(child.pid);
1158
+ if (imGatewayChild?.pid) await terminatePid(imGatewayChild.pid);
1100
1159
  if (!restarting) removeState();
1101
1160
  process.exit(0);
1102
1161
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seqyuan/annovibe",
3
- "version": "0.8.41",
3
+ "version": "0.8.54",
4
4
  "description": "AI-native bioinformatics workspace by Annoroad",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -70,6 +70,7 @@
70
70
  "@types/node": "^25",
71
71
  "@types/react": "19.2.17",
72
72
  "@types/react-dom": "^19",
73
+ "@types/ws": "^8.18.1",
73
74
  "ansi-to-react": "^6.2.6",
74
75
  "codemirror": "^6.0.2",
75
76
  "docx-preview": "^0.3.7",
@@ -84,7 +85,7 @@
84
85
  "shiki": "^4.2.0",
85
86
  "streamdown": "^2.5.0",
86
87
  "tailwindcss": "^4.2.2",
87
- "typescript": "5.9.3",
88
+ "typescript": "^5.9.3",
88
89
  "xlsx": "^0.18.5"
89
90
  }
90
91
  }
@@ -1,12 +0,0 @@
1
- (()=>{var a={};a.id=1635,a.ids=[1635],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12039:(a,b,c)=>{"use strict";function d(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>("object"!=typeof a||null===a||Array.isArray(a)||"toolCall"!==a.type?null:{type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input})??a);return{...a,content:c}}c.d(b,{B:()=>d})},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},40402:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$M:()=>e.getAgentDir,BR:()=>l,DK:()=>m,O8:()=>k,Uv:()=>n,dQ:()=>h,os:()=>j});var e=c(75430),f=c(12039),g=a([e]);async function h(){let a=await e.SessionManager.listAll(),b=new Map;for(let c of a)b.set(c.path,c.id);let c=i();return a.map(a=>(c.set(a.id,a.path),{path:a.path,id:a.id,cwd:a.cwd,name:a.name,created:a.created instanceof Date?a.created.toISOString():String(a.created),modified:a.modified instanceof Date?a.modified.toISOString():String(a.modified),messageCount:a.messageCount,firstMessage:a.firstMessage||"(no messages)",parentSessionId:a.parentSessionPath?b.get(a.parentSessionPath):void 0}))}function i(){return globalThis.__piSessionPathCache||(globalThis.__piSessionPathCache=new Map),globalThis.__piSessionPathCache}async function j(a){let b=i().get(a);return b||(await h(),i().get(a)??null)}function k(a,b){i().set(a,b)}function l(a){i().delete(a)}function m(a){return e.SessionManager.open(a).getEntries()}function n(a,b){let c,d,g,h=new Map;for(let b of a)h.set(b.id,b);let i=(0,e.buildSessionContext)(a,b,h);if(null===b||(b&&(c=h.get(b)),c||(c=a[a.length-1]),!c))return{messages:[],entryIds:[],thinkingLevel:i.thinkingLevel,model:i.model};let j=[],k=c;for(;k;)j.unshift(k),k=k.parentId?h.get(k.parentId):void 0;for(let a of j)"compaction"===a.type&&(d=a.id,g=a.firstKeptEntryId);let l=[];if(d){l.push(d);let a=j.findIndex(a=>a.id===d),b=g?j.findIndex((b,c)=>c<a&&b.id===g):-1,c=b>=0?b:a;for(let b=c;b<a;b++)"message"===j[b].type&&l.push(j[b].id);for(let b=a+1;b<j.length;b++)"message"===j[b].type&&l.push(j[b].id)}else for(let a of j)"message"===a.type&&l.push(a.id);return{messages:i.messages.map(a=>"compactionSummary"===a.role?{role:"user",content:`*The conversation history before this point was compacted into the following summary:*
2
-
3
- ${a.summary??""}`,timestamp:a.timestamp}:(0,f.B)(a)),entryIds:l,thinkingLevel:i.thinkingLevel,model:i.model}}e=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66059:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{handler:()=>y,patchFetch:()=>x,routeModule:()=>z,serverHooks:()=>C,workAsyncStorage:()=>A,workUnitAsyncStorage:()=>B});var e=c(19225),f=c(84006),g=c(8317),h=c(99373),i=c(34775),j=c(24235),k=c(261),l=c(54365),m=c(90771),n=c(73461),o=c(67798),p=c(92280),q=c(62018),r=c(45696),s=c(47929),t=c(86439),u=c(37527),v=c(88742),w=a([v]);v=(w.then?(await w)():w)[0];let z=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/reports/[id]/route",pathname:"/api/reports/[id]",filename:"route",bundlePath:"app/api/reports/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/annovibe/annovibe/app/api/reports/[id]/route.ts",nextConfigOutput:"",userland:v}),{workAsyncStorage:A,workUnitAsyncStorage:B,serverHooks:C}=z;function x(){return(0,g.patchFetch)({workAsyncStorage:A,workUnitAsyncStorage:B})}async function y(a,b,c){c.requestMeta&&(0,h.setRequestMeta)(a,c.requestMeta),z.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/reports/[id]/route";"/index"===d&&(d="/");let e=await z.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!e)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:g,params:v,nextConfig:w,parsedUrl:x,isDraftMode:y,prerenderManifest:A,routerServerContext:B,isOnDemandRevalidate:C,revalidateOnlyGenerated:D,resolvedPathname:E,clientReferenceManifest:F,serverActionsManifest:G}=e,H=(0,k.normalizeAppPath)(d),I=!!(A.dynamicRoutes[H]||A.routes[E]),J=async()=>((null==B?void 0:B.render404)?await B.render404(a,b,x,!1):b.end("This page could not be found"),null);if(I&&!y){let a=!!A.routes[E],b=A.dynamicRoutes[H];if(b&&!1===b.fallback&&!a){if(w.adapterPath)return await J();throw new t.NoFallbackError}}let K=null;!I||z.isDev||y||(K=E,K="/index"===K?"/":K);let L=!0===z.isDev||!I,M=I&&!L;G&&F&&(0,j.setManifestsSingleton)({page:d,clientReferenceManifest:F,serverActionsManifest:G});let N=a.method||"GET",O=(0,i.getTracer)(),P=O.getActiveScopeSpan(),Q=!!(null==B?void 0:B.isWrappedByNextServer),R=!!(0,h.getRequestMeta)(a,"minimalMode"),S=(0,h.getRequestMeta)(a,"incrementalCache")||await z.getIncrementalCache(a,w,A,R);null==S||S.resetRequestCache(),globalThis.__incrementalCache=S;let T={params:v,previewProps:A.preview,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:L,incrementalCache:S,cacheLifeProfiles:w.cacheLife,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>z.onRequestError(a,b,d,e,B)},sharedContext:{buildId:g}},U=new l.NodeNextRequest(a),V=new l.NodeNextResponse(b),W=m.NextRequestAdapter.fromNodeNextRequest(U,(0,m.signalFromNodeResponse)(b));try{let e,g=async a=>z.handle(W,T).finally(()=>{if(!a)return;a.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let c=O.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==n.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let f=c.get("next.route");if(f){let b=`${N} ${f}`;a.setAttributes({"next.route":f,"http.route":f,"next.span_name":b}),a.updateName(b),e&&e!==a&&(e.setAttribute("http.route",f),e.updateName(b))}else a.updateName(`${N} ${d}`)}),h=async e=>{var h,i;let j=async({previousCacheEntry:f})=>{try{if(!R&&C&&D&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await g(e);a.fetchMetrics=T.renderOpts.fetchMetrics;let h=T.renderOpts.pendingWaitUntil;h&&c.waitUntil&&(c.waitUntil(h),h=void 0);let i=T.renderOpts.collectedTags;if(!I)return await (0,p.I)(U,V,d,T.renderOpts.pendingWaitUntil),null;{let a=await d.blob(),b=(0,q.toNodeOutgoingHttpHeaders)(d.headers);i&&(b[s.NEXT_CACHE_TAGS_HEADER]=i),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==T.renderOpts.collectedRevalidate&&!(T.renderOpts.collectedRevalidate>=s.INFINITE_CACHE)&&T.renderOpts.collectedRevalidate,e=void 0===T.renderOpts.collectedExpire||T.renderOpts.collectedExpire>=s.INFINITE_CACHE?void 0:T.renderOpts.collectedExpire;return{value:{kind:u.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==f?void 0:f.isStale)&&await z.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,o.c)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,B),b}},k=await z.handleResponse({req:a,nextConfig:w,cacheKey:K,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:C,revalidateOnlyGenerated:D,responseGenerator:j,waitUntil:c.waitUntil,isMinimalMode:R});if(!I)return null;if((null==k||null==(h=k.value)?void 0:h.kind)!==u.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==k||null==(i=k.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});R||b.setHeader("x-nextjs-cache",C?"REVALIDATED":k.isMiss?"MISS":k.isStale?"STALE":"HIT"),y&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let l=(0,q.fromNodeOutgoingHttpHeaders)(k.value.headers);return R&&I||l.delete(s.NEXT_CACHE_TAGS_HEADER),!k.cacheControl||b.getHeader("Cache-Control")||l.get("Cache-Control")||l.set("Cache-Control",(0,r.getCacheControlHeader)(k.cacheControl)),await (0,p.I)(U,V,new Response(k.value.body,{headers:l,status:k.value.status||200})),null};Q&&P?await h(P):(e=O.getActiveScopeSpan(),await O.withPropagatedContext(a.headers,()=>O.trace(n.BaseServerSpan.handleRequest,{spanName:`${N} ${d}`,kind:i.SpanKind.SERVER,attributes:{"http.method":N,"http.target":a.url}},h),void 0,!Q))}catch(b){if(b instanceof t.NoFallbackError||await z.onRequestError(a,b,{routerKind:"App Router",routePath:H,routeType:"route",revalidateReason:(0,o.c)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,B),I)throw b;return await (0,p.I)(U,V,new Response(null,{status:500})),null}}d()}catch(a){d(a)}})},73196:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{c3:()=>B,tL:()=>o,u5:()=>q,wr:()=>A});var e=c(29021),f=c(33873),g=c(75430),h=a([g]);g=(h.then?(await h)():h)[0];let D=[{id:"objective",title:"Objective"},{id:"input_data",title:"Input Data"},{id:"methods",title:"Methods"},{id:"quality_control",title:"Quality Control"},{id:"results",title:"Results"},{id:"interpretation",title:"Biological Interpretation"},{id:"outputs",title:"Output Files"},{id:"reproducibility",title:"Reproducibility"}],E=/(?:^|[\s(["'`])((?:\.{1,2}\/|\/|~\/)?[A-Za-z0-9_.@+\-/\\]+?\.(?:csv|tsv|txt|xlsx|xls|pdf|png|jpg|jpeg|svg|html|htm|r|R|py|ipynb|qmd|md|rds|h5ad|loom|mtx|tsv\.gz|csv\.gz))(?:$|[\s)\]"'`,;:])/g,F=/(?:^|[\s(["'`])((?:\.{1,2}\/|\/|~\/)?[A-Za-z0-9_.@+\-/\\]+\/)(?=\s*(?:[::-]|[0-9]+|含|共|files?|个文件|PDFs?|PNGs?|CSVs?|TSVs?|输出|output|results?))/gim,G=/\b(seurat|scanpy|single[- ]cell|scrna|qc|quality control|normalize|normalization|pca|umap|tsne|cluster|clustering|resolution|marker|differential expression|deg|go enrichment|kegg|reactome|pathway|cell type|annotation|doublet|batch|integration|harmony|scvi)\b/i,H=/\b(result|found|identified|showed|observed|enriched|upregulated|downregulated|marker|cluster|cell type|figure|plot|table|significant|p\s*[<>=]|fdr|padj|logfc|auc)\b/i,I=/\b(suggest|indicate|imply|consistent with|biological|interpret|likely|may reflect|supports|driven by|associated with)\b/i,J=/\b(qc|quality control|filter|filtered|mitochondrial|percent\.mt|nfeature|ncount|doublet|ambient|low[- ]quality)\b/i,K=/\b(seurat|scanpy|single[- ]cell|scrna|sc[- ]rna|rna[- ]seq|transcriptom|gene|genes|marker|cell type|cluster|clustering|umap|tsne|pca|qc|mitochondrial|percent\.mt|nfeature|ncount|deg|differential expression|go enrichment|kegg|reactome|pathway|gsea|volcano|heatmap|h5ad|rds|loom|mtx|fastq|bam|vcf|counts?|expression|annotation|doublet|batch|integration|harmony|scvi)\b|生信|单细胞|转录组|基因|表达矩阵|差异表达|富集|通路|聚类|细胞类型|细胞注释|质控|线粒体|标记基因|火山图|热图/i,L=new Set(["_No curated content yet._","_No analysis objective detected yet._","_No input data paths detected yet._","_No output files detected yet._","_No reproducibility notes detected yet._"]);function i(){return new Date().toISOString()}function j(a){return(0,f.join)((0,g.getAgentDir)(),"reports",`${Buffer.from(a).toString("base64url")}.json`)}function k(a,b){return{id:a,title:b,markdown:"",status:"draft",updatedAt:null,sources:[]}}function l(a){let b=a.trim();return L.has(b)?"":b}function m(a){return a.some(a=>l(a.markdown).length>0)}function n(a,b,c){let d=i(),e=D.map(a=>k(a.id,a.title));return{schemaVersion:1,sessionId:a,cwd:b,title:c||"Analysis Report",createdAt:d,updatedAt:d,markdown:"",sections:e,sources:[],changes:[],appliedUpdateKeys:[]}}function o(a,b="",c){let d=j(a);if(!(0,e.existsSync)(d))return n(a,b,c);try{let f=JSON.parse((0,e.readFileSync)(d,"utf8")),g=n(a,b,c),h=Array.isArray(f.sections)?f.sections:[],i=D.map(a=>{let b=h.find(b=>b?.id===a.id),c=l("string"==typeof b?.markdown?b.markdown:"");return{...k(a.id,a.title),...b&&"object"==typeof b?b:{},id:a.id,title:a.title,markdown:c,status:c?b?.status??"draft":"draft",updatedAt:c?b?.updatedAt??null:null,sources:c&&Array.isArray(b?.sources)?b.sources:[]}}),j="string"==typeof f.title&&f.title.trim()?f.title:g.title;return{...g,...f,schemaVersion:1,sessionId:a,cwd:"string"==typeof f.cwd?f.cwd:b,title:j,createdAt:"string"==typeof f.createdAt?f.createdAt:g.createdAt,updatedAt:"string"==typeof f.updatedAt?f.updatedAt:g.updatedAt,sections:i,markdown:C(j,i),sources:m(i)&&Array.isArray(f.sources)?f.sources:[],changes:m(i)&&Array.isArray(f.changes)?f.changes:[],appliedUpdateKeys:Array.isArray(f.appliedUpdateKeys)?f.appliedUpdateKeys.filter(a=>"string"==typeof a):[]}}catch{return n(a,b,c)}}function p(a){let b=0x811c9dc5;for(let c=0;c<a.length;c++)b^=a.charCodeAt(c),b=Math.imul(b,0x1000193);return(b>>>0).toString(36)}function q(a){let b=i(),c={...a,updatedAt:b,markdown:C(a.title,a.sections)},d=j(a.sessionId);(0,e.mkdirSync)((0,f.dirname)(d),{recursive:!0});let g=`${d}.tmp`;return(0,e.writeFileSync)(g,JSON.stringify(c,null,2),"utf8"),(0,e.renameSync)(g,d),c}function r(a){return a.replace(/\s+/g," ").trim()}function s(a){return/\.(png|jpe?g|svg)$/i.test(a)}function t(a,b){let c=a.trim();if(!c)return"";let d=r(b??"").slice(0,120);if(!d)return c;let e=`### ${d}`;return c===e||c.startsWith(`${e}
4
- `)?c:`${e}
5
-
6
- ${c}`}function u(a){let b=a.content;return"string"==typeof b?r(b):Array.isArray(b)?r(b.map(a=>"text"===a.type?a.text:"toolCall"===a.type?`${a.toolName} ${JSON.stringify(a.input)}`:"").join(" ")):""}function v(a,b,c){let d=r(b);!(!d||a.includes(d))&&(a.push(d),a.length>c&&(a.length=c))}function w(a,b="_No curated content yet._"){return 0===a.length?b:a.map(a=>`- ${a}`).join("\n")}function x(a){return 0===a.length?"":["| File or Directory | Notes |","| --- | --- |",...a.map(a=>{let b;return`| \`${a.replace(/\|/g,"\\|")}\` | ${b=a.toLowerCase(),/\.(png|jpe?g|svg)$/.test(b)?"Representative image/figure.":/\.pdf$/.test(b)?"PDF figure or report.":/\.(csv|tsv|csv\.gz|tsv\.gz|xlsx?|mtx)$/.test(b)?"Result table or matrix.":/\.(r|py|ipynb|qmd|md)$/.test(b)?"Analysis script or document.":/\.(rds|h5ad|loom)$/.test(b)?"Analysis object or dataset.":/\.(html?|svg)$/.test(b)?"Browser-renderable output.":"Detected from session output."} |`})].join("\n")}function y(a,b,c,d="draft",e=[]){let f=a.sections.find(a=>a.id===b);f&&(f.markdown=c.trim(),f.status=d,f.updatedAt=i(),f.sources=e)}function z(a){if(!a)return null;let b=a.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"");return D.some(a=>a.id===b)?b:b.includes("objective")||b.includes("goal")?"objective":b.includes("input")||b.includes("sample")||b.includes("data")?"input_data":b.includes("method")||b.includes("parameter")||b.includes("workflow")?"methods":b.includes("qc")||b.includes("quality")||b.includes("filter")?"quality_control":b.includes("result")||b.includes("marker")||b.includes("deg")||b.includes("enrichment")?"results":b.includes("interpret")||b.includes("biology")||b.includes("biological")?"interpretation":b.includes("output")||b.includes("file")||b.includes("figure")?"outputs":b.includes("reproduc")?"reproducibility":null}function A(a,b,c){let d=z(b.section),e="string"==typeof b.markdown?t(b.markdown,b.topic):"";if(!d||!e)return a;let f=c?p(c):null;if(f&&a.appliedUpdateKeys?.includes(f))return a;let g=i(),h={...a,sections:a.sections.map(a=>({...a,sources:[...a.sources]})),sources:[...a.sources],changes:[...a.changes],appliedUpdateKeys:[...a.appliedUpdateKeys??[]]},j=h.sections.find(a=>a.id===d);if(!j)return a;j.markdown="replace"!==b.action&&j.markdown.trim()?`${j.markdown.trim()}
7
-
8
- ${e}`:e,j.status=b.status??"draft",j.updatedAt=g;let k=function(a){if(!Array.isArray(a))return[];let b=[];for(let c of a)"string"==typeof c?b.push({type:"file",path:c,label:c}):c&&"object"==typeof c&&"string"==typeof c.label&&b.push({type:"session"===c.type?"session":"file",id:"string"==typeof c.id?c.id:void 0,path:"string"==typeof c.path?c.path:void 0,label:c.label});return b}(b.sources);for(let a of(j.sources=k.length>0?k:j.sources,Array.isArray(b.invalidates)?b.invalidates.map(z).filter(Boolean):[])){let b=h.sections.find(b=>b.id===a);b&&b.id!==j.id&&(b.status="outdated",b.updatedAt=g)}return h.sources=[...h.sources,...k].filter((a,b,c)=>{let d=`${a.type}:${a.id??""}:${a.path??""}:${a.label}`;return c.findIndex(a=>`${a.type}:${a.id??""}:${a.path??""}:${a.label}`===d)===b}),h.changes=[{id:`change-${Date.now()}`,timestamp:g,title:`Updated ${j.title}`,detail:b.note||"Applied a structured analysis report update from the assistant."},...h.changes].slice(0,50),f&&(h.appliedUpdateKeys=[f,...h.appliedUpdateKeys??[]].slice(0,500)),h}function B(a){let b,c,d={...a.report,title:a.report.title||a.sessionTitle||"Analysis Report",sections:a.report.sections.map(a=>({...a,sources:[...a.sources]})),sources:[...a.report.sources],changes:[...a.report.changes],appliedUpdateKeys:[...a.report.appliedUpdateKeys??[]]},e={type:"session",id:d.sessionId,label:"Current conversation"};if(!a.context.messages.some(a=>K.test(u(a))))return m(d.sections)?{...d,markdown:C(d.title,d.sections)}:{...d,sections:D.map(a=>k(a.id,a.title)),sources:[],changes:[],markdown:""};let f=((b=a.context.messages.find(a=>"user"===a.role&&K.test(u(a))))?u(b).slice(0,900):"")||((c=a.context.messages.find(a=>"user"===a.role))?u(c).slice(0,900):""),g=function(a){let b=[];for(let c of a.messages){let a=u(c);if(a){for(let c of a.matchAll(E)){let a=c[1]?.replace(/[.,;:)]+$/,"");a&&v(b,a,30)}for(let c of a.matchAll(F)){let a=c[1]?.replace(/[.,;:)]+$/,"");a&&v(b,a,30)}}}return b}(a.context),h=function(a){let b=[],c=[],d=[],e=[],f=[];for(let g of a.messages){let a=u(g);if(!a||a.length<12)continue;let h=a.length>500?`${a.slice(0,500).trim()}...`:a;"assistant"===g.role&&(J.test(h)&&v(c,h,8),G.test(h)&&v(b,h,10),H.test(h)&&v(d,h,12),I.test(h)&&v(e,h,8)),"toolResult"===g.role&&/saved|wrote|created|exported|generated|output|success/i.test(h)&&v(f,h,8)}return{methods:b,qc:c,results:d,interpretation:e,reproducibility:f}}(a.context),j=a.topic??(f?r(f).slice(0,80):""),l=function(a,b=4){let c=a.filter(s).slice(0,b);return 0===c.length?"":["#### Representative Figures","",...c.flatMap(a=>{let b=a.split(/[\\/]/).filter(Boolean).pop()??a;return[`![${b}](${a.replace(/\\/g,"/").replace(/([()\s])/g,"\\$1")})`,"",`_Figure: ${b}. Representative visual output detected from this analysis topic._`,""]})].join("\n").trim()}(g),n=[h.results.length>0?w(h.results):"",l].map(a=>a.trim()).filter(Boolean).join("\n\n");if(a.topic){let a=d,b=(b,c,e=[])=>{let f=c.trim();f&&(a=A(a,{topic:j,section:b,action:"append",status:"draft",markdown:f,sources:e,note:`Added current-topic summary for ${j}.`},`${d.sessionId}:${j}:${b}:${p(f)}`))};return b("objective",f?`- ${f}`:"",f?[e]:[]),b("input_data",g.length>0?["Detected data or result paths mentioned in this topic:\n",x(g.slice(0,12))].join("\n"):"",g.length>0?[e]:[]),b("methods",h.methods.length>0?w(h.methods):"",h.methods.length>0?[e]:[]),b("quality_control",h.qc.length>0?w(h.qc):"",h.qc.length>0?[e]:[]),b("results",n,n?[e]:[]),b("interpretation",h.interpretation.length>0?w(h.interpretation):"",h.interpretation.length>0?[e]:[]),b("outputs",g.length>0?x(g):"",g.length>0?[e]:[]),b("reproducibility",h.reproducibility.length>0?w(h.reproducibility):"",h.reproducibility.length>0?[e]:[]),a}return y(d,"objective",f?t(`- ${f}`,j):"","draft",f?[e]:[]),y(d,"input_data",g.length>0?t(["Detected data or result paths mentioned in this session:\n",x(g.slice(0,12))].join("\n"),j):"",(g.length,"draft"),g.length>0?[e]:[]),y(d,"methods",h.methods.length>0?t(w(h.methods),j):"",(h.methods.length,"draft"),h.methods.length>0?[e]:[]),y(d,"quality_control",h.qc.length>0?t(w(h.qc),j):"",(h.qc.length,"draft"),h.qc.length>0?[e]:[]),y(d,"results",n?t(n,j):"","draft",n?[e]:[]),y(d,"interpretation",h.interpretation.length>0?t(w(h.interpretation),j):"",(h.interpretation.length,"draft"),h.interpretation.length>0?[e]:[]),y(d,"outputs",g.length>0?t(x(g),j):"",(g.length,"draft"),g.length>0?[e]:[]),y(d,"reproducibility",h.reproducibility.length>0?t(w(h.reproducibility),j):"",(h.reproducibility.length,"draft"),h.reproducibility.length>0?[e]:[]),m(d.sections)&&(d.sources=[e],d.changes=[{id:`change-${Date.now()}`,timestamp:i(),title:"Generated from conversation",detail:"Refreshed the analysis report from the current session, keeping only analysis objectives, methods, results, interpretations, outputs, and reproducibility notes."},...d.changes].slice(0,50)),d}function C(a,b){let c=b.filter(a=>l(a.markdown).length>0);if(0===c.length)return"";let d=c.map(a=>{let b="verified"===a.status?"verified":"outdated"===a.status?"outdated":"needs_review"===a.status?"needs review":"draft",c=l(a.markdown);return`## ${a.title}
9
-
10
- _Status: ${b}_
11
-
12
- ${c}`});return[`# ${a||"Analysis Report"}`,...d].join("\n\n")}d()}catch(a){d(a)}})},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},88742:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>k,POST:()=>m,PUT:()=>l,dynamic:()=>n});var e=c(23211),f=c(75430),g=c(40402),h=c(73196),i=a([f,g,h]);[f,g,h]=i.then?(await i)():i;let n="force-dynamic";async function j(a){let b=await (0,g.os)(a);if(!b)throw Error("Session not found");let c=f.SessionManager.open(b),d=c.getHeader()?.cwd??"",e=function(a){let b=a.getSessionName();if(b)return b;let c=a.getHeader();return c?.id,"Analysis Report"}(c),i=(0,h.tL)(a,d,e);return{sm:c,cwd:d,title:e,report:i}}async function k(a,{params:b}){let{id:c}=await b;try{let{report:a}=await j(c);return e.NextResponse.json({report:a})}catch(b){let a=b instanceof Error?b.message:String(b);return e.NextResponse.json({error:a},{status:"Session not found"===a?404:500})}}async function l(a,{params:b}){let{id:c}=await b;try{let b=await a.json();if(!b.report||"object"!=typeof b.report)return e.NextResponse.json({error:"report is required"},{status:400});let{cwd:d,title:f}=await j(c),g=(0,h.u5)({...b.report,schemaVersion:1,sessionId:c,cwd:d,title:b.report.title||f});return e.NextResponse.json({report:g})}catch(b){let a=b instanceof Error?b.message:String(b);return e.NextResponse.json({error:a},{status:"Session not found"===a?404:500})}}async function m(a,{params:b}){let{id:c}=await b;try{let b=await a.json().catch(()=>({})),{sm:d,title:f,report:i}=await j(c),k=b.action??"generate";if("apply_update"===k){if(!b.update||"object"!=typeof b.update)return e.NextResponse.json({error:"update is required"},{status:400});let a=(0,h.u5)((0,h.wr)(i,b.update,"string"==typeof b.updateKey?b.updateKey:void 0));return e.NextResponse.json({report:a})}if("generate"!==k)return e.NextResponse.json({error:"Unsupported action"},{status:400});let l=d.getEntries(),m=(0,g.Uv)(l,void 0===b.leafId?d.getLeafId():b.leafId),n=(0,h.c3)({report:i,context:m,sessionTitle:f,topic:b.topic}),o=(0,h.u5)(n);return e.NextResponse.json({report:o})}catch(b){let a=b instanceof Error?b.message:String(b);return e.NextResponse.json({error:a},{status:"Session not found"===a?404:500})}}d()}catch(a){d(a)}})},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=66059));module.exports=c})();
@@ -1 +0,0 @@
1
- globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST["/api/reports/[id]/route"]={"moduleLoading":{"prefix":"/_next/"},"ssrModuleMapping":{},"edgeSSRModuleMapping":{},"clientModules":{},"entryCSSFiles":{"/home/runner/work/annovibe/annovibe/app/api/reports/[id]/route":[]},"rscModuleMapping":{},"edgeRscModuleMapping":{}};