@caspian2026/agent-sdk 0.0.25 → 0.0.27

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 (362) hide show
  1. package/dist/gateway/index.js +98 -22
  2. package/dist/gateway/worker.js +1005 -982
  3. package/dist/sdk/query.cjs +2 -362
  4. package/dist/sdk/query.js +2 -367
  5. package/package.json +126 -128
  6. package/dist/chunk-04n4fe72.js +0 -107
  7. package/dist/chunk-04ys66ej.js +0 -344
  8. package/dist/chunk-07069jq1.js +0 -30
  9. package/dist/chunk-0731m51q.js +0 -8
  10. package/dist/chunk-086x4ct4.js +0 -26
  11. package/dist/chunk-0btqb97n.js +0 -295
  12. package/dist/chunk-0paqc2yw.js +0 -15
  13. package/dist/chunk-0r1rjydx.js +0 -145
  14. package/dist/chunk-0r5bb9j4.js +0 -477
  15. package/dist/chunk-0t81d427.js +0 -41
  16. package/dist/chunk-0teq2mz0.js +0 -420
  17. package/dist/chunk-0vkfrmqm.js +0 -690
  18. package/dist/chunk-0vp3wfab.js +0 -12
  19. package/dist/chunk-0warp8dx.js +0 -253
  20. package/dist/chunk-0xjaqda8.js +0 -1124
  21. package/dist/chunk-10gzv316.js +0 -62
  22. package/dist/chunk-11pq9n08.js +0 -168
  23. package/dist/chunk-1ae3nt9j.js +0 -31
  24. package/dist/chunk-1fmb0njn.js +0 -396
  25. package/dist/chunk-1gx78081.js +0 -66
  26. package/dist/chunk-1h2famwb.js +0 -49
  27. package/dist/chunk-1ng8xwxz.js +0 -276
  28. package/dist/chunk-1v7jp29h.js +0 -206
  29. package/dist/chunk-1xxy5zhb.js +0 -673
  30. package/dist/chunk-20b73w7w.js +0 -117
  31. package/dist/chunk-20qxd83a.js +0 -1161
  32. package/dist/chunk-2239ny9q.js +0 -90
  33. package/dist/chunk-22d4rnef.js +0 -226
  34. package/dist/chunk-26wtxbdc.js +0 -13870
  35. package/dist/chunk-27225bjh.js +0 -618
  36. package/dist/chunk-2b0e32an.js +0 -5822
  37. package/dist/chunk-2bfa9w1y.js +0 -323
  38. package/dist/chunk-2epq04w1.js +0 -63
  39. package/dist/chunk-2fwze72g.js +0 -24
  40. package/dist/chunk-2gzv8nrw.js +0 -205
  41. package/dist/chunk-2mexte1r.js +0 -349
  42. package/dist/chunk-2mzaqh5g.js +0 -338
  43. package/dist/chunk-2tb6mzfc.js +0 -81
  44. package/dist/chunk-2xq0g43w.js +0 -558
  45. package/dist/chunk-334aeqg9.js +0 -90
  46. package/dist/chunk-34jx4rjd.js +0 -995
  47. package/dist/chunk-35w5nhex.js +0 -132
  48. package/dist/chunk-3c25bcsw.js +0 -17
  49. package/dist/chunk-3eaxj8dg.js +0 -151
  50. package/dist/chunk-3fdgrwd2.js +0 -111
  51. package/dist/chunk-3jw0r58d.js +0 -121
  52. package/dist/chunk-3mgywd32.js +0 -8
  53. package/dist/chunk-3nk79af8.js +0 -8
  54. package/dist/chunk-3vy1jt9p.js +0 -1010
  55. package/dist/chunk-3x78pd4j.js +0 -153
  56. package/dist/chunk-47x3dsmn.js +0 -95
  57. package/dist/chunk-49pqt48n.js +0 -108
  58. package/dist/chunk-4f7m9fjw.js +0 -317
  59. package/dist/chunk-4jm600zv.js +0 -13
  60. package/dist/chunk-4k9d7gxv.js +0 -118
  61. package/dist/chunk-4net8san.js +0 -155
  62. package/dist/chunk-4pbx3g7s.js +0 -26
  63. package/dist/chunk-4v125j4z.js +0 -58
  64. package/dist/chunk-4vxkv5vz.js +0 -1438
  65. package/dist/chunk-51fqpjy3.js +0 -121
  66. package/dist/chunk-52e64f2h.js +0 -439
  67. package/dist/chunk-52e9mdjv.js +0 -684
  68. package/dist/chunk-55raexh7.js +0 -14358
  69. package/dist/chunk-59pq5122.js +0 -269
  70. package/dist/chunk-5bsj67v1.js +0 -349
  71. package/dist/chunk-5ccdsxgy.js +0 -74
  72. package/dist/chunk-5ekyhb1w.js +0 -422
  73. package/dist/chunk-5gcqdn8x.js +0 -867
  74. package/dist/chunk-5h5kx2jd.js +0 -34
  75. package/dist/chunk-5hf3werb.js +0 -193
  76. package/dist/chunk-5n1jc02d.js +0 -87
  77. package/dist/chunk-5wfxvxm8.js +0 -127
  78. package/dist/chunk-5wjebwmn.js +0 -89
  79. package/dist/chunk-5z28bqne.js +0 -6748
  80. package/dist/chunk-5zwsxpjn.js +0 -671
  81. package/dist/chunk-60phw466.js +0 -29
  82. package/dist/chunk-64c1avct.js +0 -13
  83. package/dist/chunk-64r16v22.js +0 -162
  84. package/dist/chunk-65t1r7zs.js +0 -418
  85. package/dist/chunk-66zry909.js +0 -11
  86. package/dist/chunk-67hxjjgc.js +0 -731
  87. package/dist/chunk-68ffk5qa.js +0 -14
  88. package/dist/chunk-69dr6rrd.js +0 -177
  89. package/dist/chunk-69n11zng.js +0 -436
  90. package/dist/chunk-6dj5t602.js +0 -341
  91. package/dist/chunk-6dngjwkh.js +0 -63
  92. package/dist/chunk-6dp8sz55.js +0 -3561
  93. package/dist/chunk-6hqgg0sv.js +0 -103
  94. package/dist/chunk-6nsd9606.js +0 -790
  95. package/dist/chunk-6p0hbwz3.js +0 -65
  96. package/dist/chunk-6ywdv5vg.js +0 -97
  97. package/dist/chunk-6zc758qw.js +0 -640
  98. package/dist/chunk-7aw745vx.js +0 -40175
  99. package/dist/chunk-7fxaphbq.js +0 -116
  100. package/dist/chunk-7sgtxrsc.js +0 -1059
  101. package/dist/chunk-7wm5s02e.js +0 -216
  102. package/dist/chunk-7xdk4109.js +0 -442
  103. package/dist/chunk-7xyswgjh.js +0 -8
  104. package/dist/chunk-83hfzbx3.js +0 -10
  105. package/dist/chunk-87m69h0v.js +0 -219
  106. package/dist/chunk-8g5pe1gr.js +0 -37
  107. package/dist/chunk-8jbw0fnf.js +0 -167
  108. package/dist/chunk-8jf9se66.js +0 -321
  109. package/dist/chunk-8p65embj.js +0 -875
  110. package/dist/chunk-8qrmaff1.js +0 -2669
  111. package/dist/chunk-8r975mwc.js +0 -93
  112. package/dist/chunk-8yhf030a.js +0 -69
  113. package/dist/chunk-93emz367.js +0 -107
  114. package/dist/chunk-948mn975.js +0 -460
  115. package/dist/chunk-99chkt7r.js +0 -54
  116. package/dist/chunk-9f7c1hzz.js +0 -50
  117. package/dist/chunk-9fk9ps1g.js +0 -178
  118. package/dist/chunk-9rh0k0aq.js +0 -90
  119. package/dist/chunk-9x5zgy22.js +0 -12
  120. package/dist/chunk-a0k2vj5b.js +0 -460
  121. package/dist/chunk-a0m57ssq.js +0 -325
  122. package/dist/chunk-a0nsmmz1.js +0 -133
  123. package/dist/chunk-a25jh1v4.js +0 -105
  124. package/dist/chunk-a4j5ekv0.js +0 -83
  125. package/dist/chunk-a8k3zf58.js +0 -313
  126. package/dist/chunk-ah0zarbq.js +0 -260
  127. package/dist/chunk-ase86y73.js +0 -15
  128. package/dist/chunk-b0kf00ff.js +0 -637
  129. package/dist/chunk-b1kcd3ss.js +0 -27
  130. package/dist/chunk-b8kcqqds.js +0 -93
  131. package/dist/chunk-bg4x9ex0.js +0 -21
  132. package/dist/chunk-bh5zqvyc.js +0 -36
  133. package/dist/chunk-bqrkfekw.js +0 -267
  134. package/dist/chunk-brjd9zmk.js +0 -42
  135. package/dist/chunk-byfawrfx.js +0 -121
  136. package/dist/chunk-c6sjhj89.js +0 -1284
  137. package/dist/chunk-c7e5yv0q.js +0 -212
  138. package/dist/chunk-c7jwbe76.js +0 -29030
  139. package/dist/chunk-cb5v8w7k.js +0 -289
  140. package/dist/chunk-cdef9v7b.js +0 -27
  141. package/dist/chunk-cdz5yb0r.js +0 -57
  142. package/dist/chunk-cgfdkzhb.js +0 -12
  143. package/dist/chunk-cgqw4x5z.js +0 -155
  144. package/dist/chunk-cnsj3vq2.js +0 -35
  145. package/dist/chunk-cqxm7ggc.js +0 -123
  146. package/dist/chunk-cxrktb5g.js +0 -51
  147. package/dist/chunk-d089t7dk.js +0 -312
  148. package/dist/chunk-d1z934cp.js +0 -71
  149. package/dist/chunk-d4mdda98.js +0 -94
  150. package/dist/chunk-d7xw8v91.js +0 -332
  151. package/dist/chunk-dc06c3rw.js +0 -1154
  152. package/dist/chunk-ddsjkqs4.js +0 -39
  153. package/dist/chunk-dfzkwynj.js +0 -5368
  154. package/dist/chunk-dnmp7s85.js +0 -20
  155. package/dist/chunk-dqqwjkv3.js +0 -8583
  156. package/dist/chunk-dt2mr4vf.js +0 -2962
  157. package/dist/chunk-dztm97gg.js +0 -150
  158. package/dist/chunk-e0abab5b.js +0 -445
  159. package/dist/chunk-e0ragz46.js +0 -209386
  160. package/dist/chunk-e9w9zc0g.js +0 -392
  161. package/dist/chunk-ebwskmsr.js +0 -107
  162. package/dist/chunk-efztk52j.js +0 -114
  163. package/dist/chunk-ehd8wacx.js +0 -40
  164. package/dist/chunk-ehtwnxpg.js +0 -1591
  165. package/dist/chunk-eqp1rfft.js +0 -17
  166. package/dist/chunk-etdt1xz3.js +0 -19
  167. package/dist/chunk-eva785x8.js +0 -88
  168. package/dist/chunk-ewadzrm8.js +0 -103
  169. package/dist/chunk-f2ajmcav.js +0 -92
  170. package/dist/chunk-fajg8x36.js +0 -8158
  171. package/dist/chunk-fbv4apne.js +0 -51
  172. package/dist/chunk-fcynwjpm.js +0 -1072
  173. package/dist/chunk-fev86f95.js +0 -1052
  174. package/dist/chunk-feyzykye.js +0 -10
  175. package/dist/chunk-ff85rwvc.js +0 -180
  176. package/dist/chunk-fk6ktvg2.js +0 -275
  177. package/dist/chunk-fqak69ft.js +0 -458
  178. package/dist/chunk-fqwas4jk.js +0 -281
  179. package/dist/chunk-fs35fdpj.js +0 -439
  180. package/dist/chunk-fvr3f9s3.js +0 -55
  181. package/dist/chunk-fyc5fepv.js +0 -10
  182. package/dist/chunk-g2g9cwt9.js +0 -54
  183. package/dist/chunk-g4znz46v.js +0 -2335
  184. package/dist/chunk-g5ts4e6k.js +0 -697
  185. package/dist/chunk-g6een9wr.js +0 -654
  186. package/dist/chunk-g7cmtx8r.js +0 -77
  187. package/dist/chunk-g9f19ttm.js +0 -15
  188. package/dist/chunk-gc7ap41t.js +0 -516
  189. package/dist/chunk-gdwdqewd.js +0 -19
  190. package/dist/chunk-gg14h3n4.js +0 -131
  191. package/dist/chunk-gg55fns0.js +0 -6440
  192. package/dist/chunk-gq7zab4e.js +0 -418
  193. package/dist/chunk-gydw3qy3.js +0 -169
  194. package/dist/chunk-gz1e8y1w.js +0 -33
  195. package/dist/chunk-h19r628d.js +0 -91
  196. package/dist/chunk-h2k8mt3z.js +0 -329
  197. package/dist/chunk-h9n54swm.js +0 -27
  198. package/dist/chunk-hakdhagh.js +0 -16606
  199. package/dist/chunk-hc2chp3g.js +0 -308
  200. package/dist/chunk-hemcv9t7.js +0 -153
  201. package/dist/chunk-hm62ntv3.js +0 -20
  202. package/dist/chunk-hmq09ytj.js +0 -100
  203. package/dist/chunk-hmv4hhqt.js +0 -2718
  204. package/dist/chunk-hwfknpxv.js +0 -39
  205. package/dist/chunk-j5bth84e.js +0 -97
  206. package/dist/chunk-j64ga6ta.js +0 -8035
  207. package/dist/chunk-j6v3w4yf.js +0 -244
  208. package/dist/chunk-jc29d2nm.js +0 -130
  209. package/dist/chunk-jd32zbps.js +0 -15
  210. package/dist/chunk-jd4sx4wh.js +0 -594
  211. package/dist/chunk-jha8n8b9.js +0 -33118
  212. package/dist/chunk-jj71qx7m.js +0 -122
  213. package/dist/chunk-jka9vpak.js +0 -114
  214. package/dist/chunk-jkf6ayv0.js +0 -32
  215. package/dist/chunk-jpz6t2tt.js +0 -61
  216. package/dist/chunk-jqt3sw12.js +0 -9114
  217. package/dist/chunk-jswd1q63.js +0 -101
  218. package/dist/chunk-jtc4aa2y.js +0 -1543
  219. package/dist/chunk-jyx3h86z.js +0 -635
  220. package/dist/chunk-jzthz1bx.js +0 -15
  221. package/dist/chunk-k0p9w03v.js +0 -4957
  222. package/dist/chunk-k6x3s7x5.js +0 -211
  223. package/dist/chunk-k7kmvnnx.js +0 -942
  224. package/dist/chunk-k8vp0atq.js +0 -2331
  225. package/dist/chunk-k9vm6x6z.js +0 -257
  226. package/dist/chunk-kb1edvhs.js +0 -120
  227. package/dist/chunk-kbhbe33q.js +0 -113
  228. package/dist/chunk-kgcgpp7z.js +0 -140
  229. package/dist/chunk-kvywbvqs.js +0 -261
  230. package/dist/chunk-kwekc97v.js +0 -18
  231. package/dist/chunk-kwyk9zp1.js +0 -74
  232. package/dist/chunk-ky1z78ve.js +0 -119
  233. package/dist/chunk-mcws22k3.js +0 -42
  234. package/dist/chunk-mr2z79r3.js +0 -1385
  235. package/dist/chunk-mst9nmns.js +0 -642
  236. package/dist/chunk-mswx2nma.js +0 -103
  237. package/dist/chunk-n1e3fjpz.js +0 -266
  238. package/dist/chunk-n6vjp9yg.js +0 -138
  239. package/dist/chunk-n84tqtvv.js +0 -120
  240. package/dist/chunk-n8ssddbw.js +0 -105
  241. package/dist/chunk-na35whkd.js +0 -227
  242. package/dist/chunk-netzwgv1.js +0 -154
  243. package/dist/chunk-ng7j0yy1.js +0 -100
  244. package/dist/chunk-nmgj86tt.js +0 -24
  245. package/dist/chunk-ns7x6xam.js +0 -22820
  246. package/dist/chunk-p7vkh4wx.js +0 -15
  247. package/dist/chunk-p8na2wwp.js +0 -14
  248. package/dist/chunk-pe3rkfp2.js +0 -74
  249. package/dist/chunk-pf0152j3.js +0 -40
  250. package/dist/chunk-pgtnj1mt.js +0 -705
  251. package/dist/chunk-ppwjyveh.js +0 -8
  252. package/dist/chunk-pq5qp2y4.js +0 -388
  253. package/dist/chunk-pqqxdk5f.js +0 -543
  254. package/dist/chunk-ps49ymvj.js +0 -43
  255. package/dist/chunk-pws8gq7m.js +0 -7422
  256. package/dist/chunk-pwwa7s62.js +0 -11
  257. package/dist/chunk-pyq0fabn.js +0 -860
  258. package/dist/chunk-q0p1m40t.js +0 -79
  259. package/dist/chunk-q0vhv550.js +0 -393
  260. package/dist/chunk-q7r0kt08.js +0 -1809
  261. package/dist/chunk-qajrkk97.js +0 -298
  262. package/dist/chunk-qatfdxvd.js +0 -34
  263. package/dist/chunk-qb6k2afy.js +0 -153
  264. package/dist/chunk-qg2qgx8h.js +0 -266
  265. package/dist/chunk-qkczt8cr.js +0 -24
  266. package/dist/chunk-qnfx3qtx.js +0 -617
  267. package/dist/chunk-qp2qdcda.js +0 -100
  268. package/dist/chunk-qtwgzej9.js +0 -85
  269. package/dist/chunk-r1dh0ymt.js +0 -91
  270. package/dist/chunk-r36xvgvv.js +0 -407
  271. package/dist/chunk-r48he8g3.js +0 -251
  272. package/dist/chunk-r63tqmtk.js +0 -146
  273. package/dist/chunk-rbdd3q5k.js +0 -101
  274. package/dist/chunk-rmbbmd3s.js +0 -68
  275. package/dist/chunk-rn0v1hk8.js +0 -34
  276. package/dist/chunk-rnxctq9p.js +0 -1646
  277. package/dist/chunk-rrs2mchs.js +0 -183
  278. package/dist/chunk-rtrybvnp.js +0 -209
  279. package/dist/chunk-rw2wkn45.js +0 -494
  280. package/dist/chunk-s4kzkdhd.js +0 -847
  281. package/dist/chunk-s7a0zn7b.js +0 -55
  282. package/dist/chunk-s8gy4ky9.js +0 -122
  283. package/dist/chunk-s8kj6ajy.js +0 -32
  284. package/dist/chunk-sag785ad.js +0 -283
  285. package/dist/chunk-scqjyben.js +0 -174
  286. package/dist/chunk-sd36yzx8.js +0 -954
  287. package/dist/chunk-sdtqm0nm.js +0 -374
  288. package/dist/chunk-sg60xg0x.js +0 -52
  289. package/dist/chunk-sgpmpn90.js +0 -35
  290. package/dist/chunk-sh02d2qn.js +0 -38
  291. package/dist/chunk-sz9y6z13.js +0 -61
  292. package/dist/chunk-szj5wvdy.js +0 -28
  293. package/dist/chunk-t29a6zb5.js +0 -45
  294. package/dist/chunk-t2b49hcf.js +0 -87
  295. package/dist/chunk-t2wqdppz.js +0 -445
  296. package/dist/chunk-t4khqff1.js +0 -16
  297. package/dist/chunk-t70t2gne.js +0 -121
  298. package/dist/chunk-t9p85zff.js +0 -24
  299. package/dist/chunk-tkrstmwz.js +0 -94
  300. package/dist/chunk-tnyb4exc.js +0 -74
  301. package/dist/chunk-tpn8jsvw.js +0 -71
  302. package/dist/chunk-tt7x5j1q.js +0 -111
  303. package/dist/chunk-tw1p628z.js +0 -984
  304. package/dist/chunk-twvdafcz.js +0 -528
  305. package/dist/chunk-tzwjafgn.js +0 -24
  306. package/dist/chunk-v140t8ay.js +0 -152
  307. package/dist/chunk-v1kzp02e.js +0 -785
  308. package/dist/chunk-v4t6dyyh.js +0 -9076
  309. package/dist/chunk-v78fj8by.js +0 -145
  310. package/dist/chunk-v8kjswxt.js +0 -61
  311. package/dist/chunk-v9smspw2.js +0 -4301
  312. package/dist/chunk-vcfbjkk9.js +0 -201
  313. package/dist/chunk-ve167rcs.js +0 -148
  314. package/dist/chunk-vf612n57.js +0 -472
  315. package/dist/chunk-vhffyae8.js +0 -895
  316. package/dist/chunk-vkhrrvfq.js +0 -44
  317. package/dist/chunk-vybkmfhf.js +0 -91
  318. package/dist/chunk-vyjeh50y.js +0 -2149
  319. package/dist/chunk-w6m6trzq.js +0 -58
  320. package/dist/chunk-w9b6kngq.js +0 -234
  321. package/dist/chunk-wa8yn2p0.js +0 -2007
  322. package/dist/chunk-wanceff6.js +0 -2840
  323. package/dist/chunk-wcze2nea.js +0 -336
  324. package/dist/chunk-wgk9sxk7.js +0 -329
  325. package/dist/chunk-wnxcgfsd.js +0 -253
  326. package/dist/chunk-wyjerrr6.js +0 -565
  327. package/dist/chunk-wz9brkq5.js +0 -60
  328. package/dist/chunk-x47h283a.js +0 -56
  329. package/dist/chunk-x59j3x9c.js +0 -98
  330. package/dist/chunk-x6r4v44b.js +0 -8
  331. package/dist/chunk-x7fdwq3d.js +0 -33
  332. package/dist/chunk-x8d2ehd7.js +0 -19
  333. package/dist/chunk-xeb6075z.js +0 -3435
  334. package/dist/chunk-xfw2pxwd.js +0 -223
  335. package/dist/chunk-xh06jc72.js +0 -200
  336. package/dist/chunk-xhfmdq1y.js +0 -147
  337. package/dist/chunk-xkwyg1d2.js +0 -195
  338. package/dist/chunk-xv3era3s.js +0 -8
  339. package/dist/chunk-xyapc58m.js +0 -87
  340. package/dist/chunk-xzgnc76g.js +0 -107
  341. package/dist/chunk-y1784krc.js +0 -19
  342. package/dist/chunk-y4ca9kqz.js +0 -3830
  343. package/dist/chunk-y9bhjjdz.js +0 -145
  344. package/dist/chunk-yb3bxv3w.js +0 -30
  345. package/dist/chunk-yddek6xk.js +0 -146
  346. package/dist/chunk-ypaq3d12.js +0 -4265
  347. package/dist/chunk-yq8z040g.js +0 -111
  348. package/dist/chunk-yqs481qq.js +0 -1163
  349. package/dist/chunk-ys9a9c9h.js +0 -105
  350. package/dist/chunk-yyex5gsf.js +0 -269
  351. package/dist/chunk-yzn396hn.js +0 -89
  352. package/dist/chunk-z2dp53wn.js +0 -17
  353. package/dist/chunk-zay4xp4n.js +0 -251
  354. package/dist/chunk-zc8bwy57.js +0 -212
  355. package/dist/chunk-zhx88cfx.js +0 -97
  356. package/dist/chunk-zkh6f4ct.js +0 -385
  357. package/dist/chunk-zq56gcca.js +0 -206
  358. package/dist/chunk-zrkefd22.js +0 -490
  359. package/dist/chunk-zs5p0yq1.js +0 -1030
  360. package/dist/chunk-zxh62ved.js +0 -31
  361. package/dist/chunk-zzm33q8x.js +0 -8
  362. package/dist/cli.js +0 -220
@@ -1,1809 +0,0 @@
1
- // @bun
2
- import {
3
- Fuse,
4
- init_fuse
5
- } from "./chunk-c6sjhj89.js";
6
- import {
7
- Messages,
8
- init_Messages
9
- } from "./chunk-ypaq3d12.js";
10
- import {
11
- init_SearchBox
12
- } from "./chunk-p8na2wwp.js";
13
- import {
14
- init_useSearchInput,
15
- useSearchInput
16
- } from "./chunk-hc2chp3g.js";
17
- import {
18
- ConfigurableShortcutHint,
19
- Select,
20
- Spinner,
21
- TextInput,
22
- getAllBaseTools,
23
- getFirstMeaningfulUserMessageTextContent,
24
- getSessionIdFromLog,
25
- getTheme,
26
- getWorktreePaths,
27
- init_ConfigurableShortcutHint,
28
- init_Spinner,
29
- init_TextInput,
30
- init_getWorktreePaths,
31
- init_select,
32
- init_sessionStorage,
33
- init_shellQuote,
34
- init_sideQuery,
35
- init_theme,
36
- init_tools1 as init_tools,
37
- init_useTerminalSize,
38
- isCustomTitleEnabled,
39
- isLiteLog,
40
- loadFullLog,
41
- quote,
42
- saveCustomTitle,
43
- sideQuery
44
- } from "./chunk-e0ragz46.js";
45
- import {
46
- init_useExitOnCtrlCDWithKeybindings,
47
- useExitOnCtrlCDWithKeybindings
48
- } from "./chunk-4k9d7gxv.js";
49
- import {
50
- init_useKeybinding
51
- } from "./chunk-68ffk5qa.js";
52
- import {
53
- getSmallFastModel,
54
- init_model
55
- } from "./chunk-jtc4aa2y.js";
56
- import {
57
- count,
58
- init_array
59
- } from "./chunk-6nsd9606.js";
60
- import {
61
- formatLogMetadata,
62
- formatRelativeTimeAgo,
63
- init_format,
64
- truncateToWidth
65
- } from "./chunk-fqak69ft.js";
66
- import {
67
- Byline,
68
- Divider,
69
- KeyboardShortcutHint,
70
- LoadingState,
71
- SearchBox,
72
- ThemedBox_default,
73
- ThemedText,
74
- applyColor,
75
- init_source,
76
- init_src,
77
- source_default,
78
- stringWidth,
79
- useKeybinding,
80
- useTerminalFocus,
81
- useTerminalSize,
82
- useTheme,
83
- use_input_default
84
- } from "./chunk-c7jwbe76.js";
85
- import {
86
- require_jsx_dev_runtime,
87
- require_react
88
- } from "./chunk-7sgtxrsc.js";
89
- import {
90
- init_analytics,
91
- logEvent
92
- } from "./chunk-x8d2ehd7.js";
93
- import {
94
- getBranch,
95
- init_git
96
- } from "./chunk-3vy1jt9p.js";
97
- import {
98
- figures_default,
99
- init_figures
100
- } from "./chunk-qajrkk97.js";
101
- import {
102
- getLogDisplayTitle,
103
- init_debug,
104
- init_log,
105
- init_slowOperations,
106
- jsonParse,
107
- logError,
108
- logForDebugging
109
- } from "./chunk-gg55fns0.js";
110
- import {
111
- getOriginalCwd,
112
- getSessionId,
113
- init_state
114
- } from "./chunk-k8vp0atq.js";
115
- import {
116
- __esm,
117
- __toESM
118
- } from "./chunk-qp2qdcda.js";
119
-
120
- // src/components/SessionPreview.tsx
121
- function SessionPreview({
122
- log,
123
- onExit,
124
- onSelect
125
- }) {
126
- const [fullLog, setFullLog] = import_react.default.useState(null);
127
- import_react.default.useEffect(() => {
128
- setFullLog(null);
129
- if (isLiteLog(log)) {
130
- loadFullLog(log).then(setFullLog);
131
- }
132
- }, [log]);
133
- const isLoading = isLiteLog(log) && fullLog === null;
134
- const displayLog = fullLog ?? log;
135
- const conversationId = getSessionIdFromLog(displayLog) || "";
136
- const tools = getAllBaseTools();
137
- useKeybinding("confirm:no", onExit, { context: "Confirmation" });
138
- const handleSelect = import_react.useCallback(() => {
139
- onSelect(fullLog ?? log);
140
- }, [onSelect, fullLog, log]);
141
- useKeybinding("confirm:yes", handleSelect, { context: "Confirmation" });
142
- if (isLoading) {
143
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
144
- flexDirection: "column",
145
- padding: 1,
146
- children: [
147
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(LoadingState, {
148
- message: "Loading session\u2026"
149
- }, undefined, false, undefined, this),
150
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
151
- dimColor: true,
152
- children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Byline, {
153
- children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ConfigurableShortcutHint, {
154
- action: "confirm:no",
155
- context: "Confirmation",
156
- fallback: "Esc",
157
- description: "cancel"
158
- }, undefined, false, undefined, this)
159
- }, undefined, false, undefined, this)
160
- }, undefined, false, undefined, this)
161
- ]
162
- }, undefined, true, undefined, this);
163
- }
164
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
165
- flexDirection: "column",
166
- children: [
167
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Messages, {
168
- messages: displayLog.messages,
169
- tools,
170
- commands: [],
171
- verbose: true,
172
- toolJSX: null,
173
- toolUseConfirmQueue: [],
174
- inProgressToolUseIDs: new Set,
175
- isMessageSelectorVisible: false,
176
- conversationId,
177
- screen: "transcript",
178
- streamingToolUses: [],
179
- showAllInTranscript: true,
180
- isLoading: false
181
- }, undefined, false, undefined, this),
182
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
183
- flexShrink: 0,
184
- flexDirection: "column",
185
- borderTopDimColor: true,
186
- borderBottom: false,
187
- borderLeft: false,
188
- borderRight: false,
189
- borderStyle: "single",
190
- paddingLeft: 2,
191
- children: [
192
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
193
- children: [
194
- formatRelativeTimeAgo(displayLog.modified),
195
- " \xB7",
196
- " ",
197
- displayLog.messageCount,
198
- " messages",
199
- displayLog.gitBranch ? ` \xB7 ${displayLog.gitBranch}` : ""
200
- ]
201
- }, undefined, true, undefined, this),
202
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
203
- dimColor: true,
204
- children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Byline, {
205
- children: [
206
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(KeyboardShortcutHint, {
207
- shortcut: "Enter",
208
- action: "resume"
209
- }, undefined, false, undefined, this),
210
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ConfigurableShortcutHint, {
211
- action: "confirm:no",
212
- context: "Confirmation",
213
- fallback: "Esc",
214
- description: "cancel"
215
- }, undefined, false, undefined, this)
216
- ]
217
- }, undefined, true, undefined, this)
218
- }, undefined, false, undefined, this)
219
- ]
220
- }, undefined, true, undefined, this)
221
- ]
222
- }, undefined, true, undefined, this);
223
- }
224
- var import_react, jsx_dev_runtime;
225
- var init_SessionPreview = __esm(() => {
226
- init_src();
227
- init_useKeybinding();
228
- init_tools();
229
- init_format();
230
- init_sessionStorage();
231
- init_ConfigurableShortcutHint();
232
- init_Messages();
233
- import_react = __toESM(require_react(), 1);
234
- jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
235
- });
236
-
237
- // src/components/TagTabs.tsx
238
- function getTabWidth(tab, maxWidth) {
239
- if (tab === ALL_TAB_LABEL) {
240
- return ALL_TAB_LABEL.length + TAB_PADDING;
241
- }
242
- const tagWidth = stringWidth(tab);
243
- const effectiveTagWidth = maxWidth ? Math.min(tagWidth, maxWidth - TAB_PADDING - HASH_PREFIX_LENGTH) : tagWidth;
244
- return Math.max(0, effectiveTagWidth) + TAB_PADDING + HASH_PREFIX_LENGTH;
245
- }
246
- function truncateTag(tag, maxWidth) {
247
- const availableForTag = maxWidth - TAB_PADDING - HASH_PREFIX_LENGTH;
248
- if (stringWidth(tag) <= availableForTag) {
249
- return tag;
250
- }
251
- if (availableForTag <= 1) {
252
- return tag.charAt(0);
253
- }
254
- return truncateToWidth(tag, availableForTag);
255
- }
256
- function TagTabs({
257
- tabs,
258
- selectedIndex,
259
- availableWidth,
260
- showAllProjects = false
261
- }) {
262
- const resumeLabel = showAllProjects ? "Resume (All Projects)" : "Resume";
263
- const resumeLabelWidth = resumeLabel.length + 1;
264
- const rightHintWidth = Math.max(RIGHT_HINT_WIDTH_WITH_COUNT, RIGHT_HINT_WIDTH_NO_COUNT);
265
- const maxTabsWidth = availableWidth - resumeLabelWidth - rightHintWidth - 2;
266
- const safeSelectedIndex = Math.max(0, Math.min(selectedIndex, tabs.length - 1));
267
- const maxSingleTabWidth = Math.max(20, Math.floor(maxTabsWidth / 2));
268
- const tabWidths = tabs.map((tab) => getTabWidth(tab, maxSingleTabWidth));
269
- let startIndex = 0;
270
- let endIndex = tabs.length;
271
- const totalTabsWidth = tabWidths.reduce((sum, w, i) => sum + w + (i < tabWidths.length - 1 ? 1 : 0), 0);
272
- if (totalTabsWidth > maxTabsWidth) {
273
- const effectiveMaxWidth = maxTabsWidth - LEFT_ARROW_WIDTH;
274
- let windowWidth = tabWidths[safeSelectedIndex] ?? 0;
275
- startIndex = safeSelectedIndex;
276
- endIndex = safeSelectedIndex + 1;
277
- while (startIndex > 0 || endIndex < tabs.length) {
278
- const canExpandLeft = startIndex > 0;
279
- const canExpandRight = endIndex < tabs.length;
280
- if (canExpandLeft) {
281
- const leftWidth = (tabWidths[startIndex - 1] ?? 0) + 1;
282
- if (windowWidth + leftWidth <= effectiveMaxWidth) {
283
- startIndex--;
284
- windowWidth += leftWidth;
285
- continue;
286
- }
287
- }
288
- if (canExpandRight) {
289
- const rightWidth = (tabWidths[endIndex] ?? 0) + 1;
290
- if (windowWidth + rightWidth <= effectiveMaxWidth) {
291
- endIndex++;
292
- windowWidth += rightWidth;
293
- continue;
294
- }
295
- }
296
- break;
297
- }
298
- }
299
- const hiddenLeft = startIndex;
300
- const hiddenRight = tabs.length - endIndex;
301
- const visibleTabs = tabs.slice(startIndex, endIndex);
302
- const visibleIndices = visibleTabs.map((_, i) => startIndex + i);
303
- return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
304
- flexDirection: "row",
305
- gap: 1,
306
- children: [
307
- /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
308
- color: "suggestion",
309
- children: resumeLabel
310
- }, undefined, false, undefined, this),
311
- hiddenLeft > 0 && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
312
- dimColor: true,
313
- children: [
314
- LEFT_ARROW_PREFIX,
315
- hiddenLeft
316
- ]
317
- }, undefined, true, undefined, this),
318
- visibleTabs.map((tab, i) => {
319
- const actualIndex = visibleIndices[i];
320
- const isSelected = actualIndex === safeSelectedIndex;
321
- const displayText = tab === ALL_TAB_LABEL ? tab : `#${truncateTag(tab, maxSingleTabWidth - TAB_PADDING)}`;
322
- return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
323
- backgroundColor: isSelected ? "suggestion" : undefined,
324
- color: isSelected ? "inverseText" : undefined,
325
- bold: isSelected,
326
- children: [
327
- " ",
328
- displayText,
329
- " "
330
- ]
331
- }, tab, true, undefined, this);
332
- }),
333
- hiddenRight > 0 ? /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
334
- dimColor: true,
335
- children: [
336
- RIGHT_HINT_WITH_COUNT_PREFIX,
337
- hiddenRight,
338
- RIGHT_HINT_SUFFIX
339
- ]
340
- }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
341
- dimColor: true,
342
- children: RIGHT_HINT_NO_COUNT
343
- }, undefined, false, undefined, this)
344
- ]
345
- }, undefined, true, undefined, this);
346
- }
347
- var jsx_dev_runtime2, ALL_TAB_LABEL = "All", TAB_PADDING = 2, HASH_PREFIX_LENGTH = 1, LEFT_ARROW_PREFIX = "\u2190 ", RIGHT_HINT_WITH_COUNT_PREFIX = "\u2192", RIGHT_HINT_SUFFIX = " (tab to cycle)", RIGHT_HINT_NO_COUNT = "(tab to cycle)", MAX_OVERFLOW_DIGITS = 2, LEFT_ARROW_WIDTH, RIGHT_HINT_WIDTH_WITH_COUNT, RIGHT_HINT_WIDTH_NO_COUNT;
348
- var init_TagTabs = __esm(() => {
349
- init_src();
350
- init_format();
351
- jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
352
- LEFT_ARROW_WIDTH = LEFT_ARROW_PREFIX.length + MAX_OVERFLOW_DIGITS + 1;
353
- RIGHT_HINT_WIDTH_WITH_COUNT = RIGHT_HINT_WITH_COUNT_PREFIX.length + MAX_OVERFLOW_DIGITS + RIGHT_HINT_SUFFIX.length;
354
- RIGHT_HINT_WIDTH_NO_COUNT = RIGHT_HINT_NO_COUNT.length;
355
- });
356
-
357
- // src/components/ui/TreeSelect.tsx
358
- function TreeSelect({
359
- nodes,
360
- onSelect,
361
- onCancel,
362
- onFocus,
363
- focusNodeId,
364
- visibleOptionCount,
365
- layout = "expanded",
366
- isDisabled = false,
367
- hideIndexes = false,
368
- isNodeExpanded,
369
- onExpand,
370
- onCollapse,
371
- getParentPrefix,
372
- getChildPrefix,
373
- onUpFromFirstItem
374
- }) {
375
- const [internalExpandedIds, setInternalExpandedIds] = import_react2.default.useState(new Set);
376
- const isProgrammaticFocusRef = import_react2.default.useRef(false);
377
- const lastFocusedIdRef = import_react2.default.useRef(null);
378
- const isExpanded = import_react2.default.useCallback((nodeId) => {
379
- if (isNodeExpanded) {
380
- return isNodeExpanded(nodeId);
381
- }
382
- return internalExpandedIds.has(nodeId);
383
- }, [isNodeExpanded, internalExpandedIds]);
384
- const flattenedNodes = import_react2.default.useMemo(() => {
385
- const result = [];
386
- function traverse(node, depth, parentId) {
387
- const hasChildren = !!node.children && node.children.length > 0;
388
- const nodeIsExpanded = isExpanded(node.id);
389
- result.push({
390
- node,
391
- depth,
392
- isExpanded: nodeIsExpanded,
393
- hasChildren,
394
- parentId
395
- });
396
- if (hasChildren && nodeIsExpanded && node.children) {
397
- for (const child of node.children) {
398
- traverse(child, depth + 1, node.id);
399
- }
400
- }
401
- }
402
- for (const node of nodes) {
403
- traverse(node, 0);
404
- }
405
- return result;
406
- }, [nodes, isExpanded]);
407
- const defaultGetParentPrefix = import_react2.default.useCallback((isExpanded2) => isExpanded2 ? "\u25BC " : "\u25B6 ", []);
408
- const defaultGetChildPrefix = import_react2.default.useCallback((_depth) => " \u25B8 ", []);
409
- const parentPrefixFn = getParentPrefix ?? defaultGetParentPrefix;
410
- const childPrefixFn = getChildPrefix ?? defaultGetChildPrefix;
411
- const buildLabel = import_react2.default.useCallback((flatNode) => {
412
- let prefix = "";
413
- if (flatNode.hasChildren) {
414
- prefix = parentPrefixFn(flatNode.isExpanded);
415
- } else if (flatNode.depth > 0) {
416
- prefix = childPrefixFn(flatNode.depth);
417
- }
418
- return prefix + flatNode.node.label;
419
- }, [parentPrefixFn, childPrefixFn]);
420
- const options = import_react2.default.useMemo(() => {
421
- return flattenedNodes.map((flatNode) => ({
422
- label: buildLabel(flatNode),
423
- description: flatNode.node.description,
424
- dimDescription: flatNode.node.dimDescription ?? true,
425
- value: flatNode.node.id
426
- }));
427
- }, [flattenedNodes, buildLabel]);
428
- const nodeMap = import_react2.default.useMemo(() => {
429
- const map = new Map;
430
- flattenedNodes.forEach((fn) => map.set(fn.node.id, fn.node));
431
- return map;
432
- }, [flattenedNodes]);
433
- const findFlattenedNode = import_react2.default.useCallback((nodeId) => {
434
- return flattenedNodes.find((fn) => fn.node.id === nodeId);
435
- }, [flattenedNodes]);
436
- const toggleExpand = import_react2.default.useCallback((nodeId, shouldExpand) => {
437
- const flatNode = findFlattenedNode(nodeId);
438
- if (!flatNode || !flatNode.hasChildren)
439
- return;
440
- if (shouldExpand) {
441
- if (onExpand) {
442
- onExpand(nodeId);
443
- } else {
444
- setInternalExpandedIds((prev) => new Set(prev).add(nodeId));
445
- }
446
- } else {
447
- if (onCollapse) {
448
- onCollapse(nodeId);
449
- } else {
450
- setInternalExpandedIds((prev) => {
451
- const newSet = new Set(prev);
452
- newSet.delete(nodeId);
453
- return newSet;
454
- });
455
- }
456
- }
457
- }, [findFlattenedNode, onExpand, onCollapse]);
458
- const handleKeyDown = (e) => {
459
- if (!focusNodeId || isDisabled)
460
- return;
461
- const flatNode = findFlattenedNode(focusNodeId);
462
- if (!flatNode)
463
- return;
464
- if (e.key === "right" && flatNode.hasChildren) {
465
- e.preventDefault();
466
- toggleExpand(focusNodeId, true);
467
- } else if (e.key === "left") {
468
- if (flatNode.hasChildren && flatNode.isExpanded) {
469
- e.preventDefault();
470
- toggleExpand(focusNodeId, false);
471
- } else if (flatNode.parentId !== undefined) {
472
- e.preventDefault();
473
- isProgrammaticFocusRef.current = true;
474
- toggleExpand(flatNode.parentId, false);
475
- if (onFocus) {
476
- const parentNode = nodeMap.get(flatNode.parentId);
477
- if (parentNode) {
478
- onFocus(parentNode);
479
- }
480
- }
481
- }
482
- }
483
- };
484
- const handleChange = import_react2.default.useCallback((nodeId) => {
485
- const node = nodeMap.get(nodeId);
486
- if (!node)
487
- return;
488
- onSelect(node);
489
- }, [nodeMap, onSelect]);
490
- const handleFocus = import_react2.default.useCallback((nodeId) => {
491
- if (isProgrammaticFocusRef.current) {
492
- isProgrammaticFocusRef.current = false;
493
- return;
494
- }
495
- if (lastFocusedIdRef.current === nodeId) {
496
- return;
497
- }
498
- lastFocusedIdRef.current = nodeId;
499
- if (onFocus) {
500
- const node = nodeMap.get(nodeId);
501
- if (node) {
502
- onFocus(node);
503
- }
504
- }
505
- }, [onFocus, nodeMap]);
506
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
507
- tabIndex: 0,
508
- autoFocus: true,
509
- onKeyDown: handleKeyDown,
510
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Select, {
511
- options,
512
- onChange: handleChange,
513
- onFocus: handleFocus,
514
- onCancel,
515
- defaultFocusValue: focusNodeId,
516
- visibleOptionCount,
517
- layout,
518
- isDisabled,
519
- hideIndexes,
520
- onUpFromFirstItem
521
- }, undefined, false, undefined, this)
522
- }, undefined, false, undefined, this);
523
- }
524
- var import_react2, jsx_dev_runtime3;
525
- var init_TreeSelect = __esm(() => {
526
- init_src();
527
- init_select();
528
- import_react2 = __toESM(require_react(), 1);
529
- jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
530
- });
531
-
532
- // src/components/LogSelector.tsx
533
- function normalizeAndTruncateToWidth(text, maxWidth) {
534
- const normalized = text.replace(/\s+/g, " ").trim();
535
- return truncateToWidth(normalized, maxWidth);
536
- }
537
- function formatSnippet({ before, match, after }, highlightColor) {
538
- return source_default.dim(before) + highlightColor(match) + source_default.dim(after);
539
- }
540
- function extractSnippet(text, query, contextChars) {
541
- const matchIndex = text.toLowerCase().indexOf(query.toLowerCase());
542
- if (matchIndex === -1)
543
- return null;
544
- const matchEnd = matchIndex + query.length;
545
- const snippetStart = Math.max(0, matchIndex - contextChars);
546
- const snippetEnd = Math.min(text.length, matchEnd + contextChars);
547
- const beforeRaw = text.slice(snippetStart, matchIndex);
548
- const matchText = text.slice(matchIndex, matchEnd);
549
- const afterRaw = text.slice(matchEnd, snippetEnd);
550
- return {
551
- before: (snippetStart > 0 ? "\u2026" : "") + beforeRaw.replace(/\s+/g, " ").trimStart(),
552
- match: matchText.trim(),
553
- after: afterRaw.replace(/\s+/g, " ").trimEnd() + (snippetEnd < text.length ? "\u2026" : "")
554
- };
555
- }
556
- function buildLogLabel(log, maxLabelWidth, options) {
557
- const {
558
- isGroupHeader = false,
559
- isChild = false,
560
- forkCount = 0
561
- } = options || {};
562
- const prefixWidth = isGroupHeader && forkCount > 0 ? PARENT_PREFIX_WIDTH : isChild ? CHILD_PREFIX_WIDTH : 0;
563
- const sessionCountSuffix = isGroupHeader && forkCount > 0 ? ` (+${forkCount} other ${forkCount === 1 ? "session" : "sessions"})` : "";
564
- const sidechainSuffix = log.isSidechain ? " (sidechain)" : "";
565
- const maxSummaryWidth = maxLabelWidth - prefixWidth - sidechainSuffix.length - sessionCountSuffix.length;
566
- const truncatedSummary = normalizeAndTruncateToWidth(getLogDisplayTitle(log), maxSummaryWidth);
567
- return `${truncatedSummary}${sidechainSuffix}${sessionCountSuffix}`;
568
- }
569
- function buildLogMetadata(log, options) {
570
- const { isChild = false, showProjectPath = false } = options || {};
571
- const childPadding = isChild ? " " : "";
572
- const baseMetadata = formatLogMetadata(log);
573
- const projectSuffix = showProjectPath && log.projectPath ? ` \xB7 ${log.projectPath}` : "";
574
- return childPadding + baseMetadata + projectSuffix;
575
- }
576
- function LogSelector({
577
- logs,
578
- maxHeight = Infinity,
579
- forceWidth,
580
- onCancel,
581
- onSelect,
582
- onLogsChanged,
583
- onLoadMore,
584
- initialSearchQuery,
585
- showAllProjects = false,
586
- onToggleAllProjects,
587
- onAgenticSearch
588
- }) {
589
- const terminalSize = useTerminalSize();
590
- const columns = forceWidth === undefined ? terminalSize.columns : forceWidth;
591
- const exitState = useExitOnCtrlCDWithKeybindings(onCancel);
592
- const isTerminalFocused = useTerminalFocus();
593
- const isResumeWithRenameEnabled = isCustomTitleEnabled();
594
- const isDeepSearchEnabled = process.env.USER_TYPE === "ant";
595
- const [themeName] = useTheme();
596
- const theme = getTheme(themeName);
597
- const highlightColor = import_react3.default.useMemo(() => (text) => applyColor(text, theme.warning), [theme.warning]);
598
- const isAgenticSearchEnabled = process.env.USER_TYPE === "ant";
599
- const [currentBranch, setCurrentBranch] = import_react3.default.useState(null);
600
- const [branchFilterEnabled, setBranchFilterEnabled] = import_react3.default.useState(false);
601
- const [showAllWorktrees, setShowAllWorktrees] = import_react3.default.useState(false);
602
- const [hasMultipleWorktrees, setHasMultipleWorktrees] = import_react3.default.useState(false);
603
- const currentCwd = import_react3.default.useMemo(() => getOriginalCwd(), []);
604
- const [renameValue, setRenameValue] = import_react3.default.useState("");
605
- const [renameCursorOffset, setRenameCursorOffset] = import_react3.default.useState(0);
606
- const [expandedGroupSessionIds, setExpandedGroupSessionIds] = import_react3.default.useState(new Set);
607
- const [focusedNode, setFocusedNode] = import_react3.default.useState(null);
608
- const [focusedIndex, setFocusedIndex] = import_react3.default.useState(1);
609
- const [viewMode, setViewMode] = import_react3.default.useState("list");
610
- const [previewLog, setPreviewLog] = import_react3.default.useState(null);
611
- const prevFocusedIdRef = import_react3.default.useRef(null);
612
- const [selectedTagIndex, setSelectedTagIndex] = import_react3.default.useState(0);
613
- const [agenticSearchState, setAgenticSearchState] = import_react3.default.useState({ status: "idle" });
614
- const [isAgenticSearchOptionFocused, setIsAgenticSearchOptionFocused] = import_react3.default.useState(false);
615
- const agenticSearchAbortRef = import_react3.default.useRef(null);
616
- const {
617
- query: searchQuery,
618
- setQuery: setSearchQuery,
619
- cursorOffset: searchCursorOffset
620
- } = useSearchInput({
621
- isActive: viewMode === "search" && agenticSearchState.status !== "searching",
622
- onExit: () => {
623
- setViewMode("list");
624
- logEvent("tengu_session_search_toggled", { enabled: false });
625
- },
626
- onExitUp: () => {
627
- setViewMode("list");
628
- logEvent("tengu_session_search_toggled", { enabled: false });
629
- },
630
- passthroughCtrlKeys: ["n"],
631
- initialQuery: initialSearchQuery || ""
632
- });
633
- const deferredSearchQuery = import_react3.default.useDeferredValue(searchQuery);
634
- const [debouncedDeepSearchQuery, setDebouncedDeepSearchQuery] = import_react3.default.useState("");
635
- import_react3.default.useEffect(() => {
636
- if (!deferredSearchQuery) {
637
- setDebouncedDeepSearchQuery("");
638
- return;
639
- }
640
- const timeoutId = setTimeout(setDebouncedDeepSearchQuery, 300, deferredSearchQuery);
641
- return () => clearTimeout(timeoutId);
642
- }, [deferredSearchQuery]);
643
- const [deepSearchResults, setDeepSearchResults] = import_react3.default.useState(null);
644
- const [isSearching, setIsSearching] = import_react3.default.useState(false);
645
- import_react3.default.useEffect(() => {
646
- getBranch().then((branch) => setCurrentBranch(branch));
647
- getWorktreePaths(currentCwd).then((paths) => {
648
- setHasMultipleWorktrees(paths.length > 1);
649
- });
650
- }, [currentCwd]);
651
- const searchableTextByLog = import_react3.default.useMemo(() => new Map(logs.map((log) => [log, buildSearchableText(log)])), [logs]);
652
- const fuseIndex = import_react3.default.useMemo(() => {
653
- if (!isDeepSearchEnabled)
654
- return null;
655
- const logsWithText = logs.map((log) => ({
656
- log,
657
- searchableText: searchableTextByLog.get(log) ?? ""
658
- })).filter((item) => item.searchableText);
659
- return new Fuse(logsWithText, {
660
- keys: ["searchableText"],
661
- threshold: FUSE_THRESHOLD,
662
- ignoreLocation: true,
663
- includeScore: true
664
- });
665
- }, [logs, searchableTextByLog, isDeepSearchEnabled]);
666
- const uniqueTags = import_react3.default.useMemo(() => getUniqueTags(logs), [logs]);
667
- const hasTags = uniqueTags.length > 0;
668
- const tagTabs = import_react3.default.useMemo(() => hasTags ? ["All", ...uniqueTags] : [], [hasTags, uniqueTags]);
669
- const effectiveTagIndex = tagTabs.length > 0 && selectedTagIndex < tagTabs.length ? selectedTagIndex : 0;
670
- const selectedTab = tagTabs[effectiveTagIndex];
671
- const tagFilter = selectedTab === "All" ? undefined : selectedTab;
672
- const tagTabsLines = hasTags ? 1 : 0;
673
- const baseFilteredLogs = import_react3.default.useMemo(() => {
674
- let filtered = logs;
675
- if (isResumeWithRenameEnabled) {
676
- filtered = logs.filter((log) => {
677
- const currentSessionId = getSessionId();
678
- const logSessionId = getSessionIdFromLog(log);
679
- const isCurrentSession = currentSessionId && logSessionId === currentSessionId;
680
- if (isCurrentSession) {
681
- return true;
682
- }
683
- if (log.customTitle) {
684
- return true;
685
- }
686
- const fromMessages = getFirstMeaningfulUserMessageTextContent(log.messages);
687
- if (fromMessages) {
688
- return true;
689
- }
690
- if (log.firstPrompt || log.customTitle) {
691
- return true;
692
- }
693
- return false;
694
- });
695
- }
696
- if (tagFilter !== undefined) {
697
- filtered = filtered.filter((log) => log.tag === tagFilter);
698
- }
699
- if (branchFilterEnabled && currentBranch) {
700
- filtered = filtered.filter((log) => log.gitBranch === currentBranch);
701
- }
702
- if (hasMultipleWorktrees && !showAllWorktrees) {
703
- filtered = filtered.filter((log) => log.projectPath === currentCwd);
704
- }
705
- return filtered;
706
- }, [
707
- logs,
708
- isResumeWithRenameEnabled,
709
- tagFilter,
710
- branchFilterEnabled,
711
- currentBranch,
712
- hasMultipleWorktrees,
713
- showAllWorktrees,
714
- currentCwd
715
- ]);
716
- const titleFilteredLogs = import_react3.default.useMemo(() => {
717
- if (!searchQuery) {
718
- return baseFilteredLogs;
719
- }
720
- const query = searchQuery.toLowerCase();
721
- return baseFilteredLogs.filter((log) => {
722
- const displayedTitle = getLogDisplayTitle(log).toLowerCase();
723
- const branch = (log.gitBranch || "").toLowerCase();
724
- const tag = (log.tag || "").toLowerCase();
725
- const prInfo = log.prNumber ? `pr #${log.prNumber} ${log.prRepository || ""}`.toLowerCase() : "";
726
- return displayedTitle.includes(query) || branch.includes(query) || tag.includes(query) || prInfo.includes(query);
727
- });
728
- }, [baseFilteredLogs, searchQuery]);
729
- import_react3.default.useEffect(() => {
730
- if (isDeepSearchEnabled && deferredSearchQuery && deferredSearchQuery !== debouncedDeepSearchQuery) {
731
- setIsSearching(true);
732
- }
733
- }, [deferredSearchQuery, debouncedDeepSearchQuery, isDeepSearchEnabled]);
734
- import_react3.default.useEffect(() => {
735
- if (!isDeepSearchEnabled || !debouncedDeepSearchQuery || !fuseIndex) {
736
- setDeepSearchResults(null);
737
- setIsSearching(false);
738
- return;
739
- }
740
- const timeoutId = setTimeout((fuseIndex2, debouncedDeepSearchQuery2, setDeepSearchResults2, setIsSearching2) => {
741
- const results = fuseIndex2.search(debouncedDeepSearchQuery2);
742
- results.sort((a, b) => {
743
- const aTime = new Date(a.item.log.modified).getTime();
744
- const bTime = new Date(b.item.log.modified).getTime();
745
- const timeDiff = bTime - aTime;
746
- if (Math.abs(timeDiff) > DATE_TIE_THRESHOLD_MS) {
747
- return timeDiff;
748
- }
749
- return (a.score ?? 1) - (b.score ?? 1);
750
- });
751
- setDeepSearchResults2({
752
- results: results.map((r) => ({
753
- log: r.item.log,
754
- score: r.score,
755
- searchableText: r.item.searchableText
756
- })),
757
- query: debouncedDeepSearchQuery2
758
- });
759
- setIsSearching2(false);
760
- }, 0, fuseIndex, debouncedDeepSearchQuery, setDeepSearchResults, setIsSearching);
761
- return () => {
762
- clearTimeout(timeoutId);
763
- };
764
- }, [debouncedDeepSearchQuery, fuseIndex, isDeepSearchEnabled]);
765
- const { filteredLogs, snippets } = import_react3.default.useMemo(() => {
766
- const snippetMap = new Map;
767
- let filtered = titleFilteredLogs;
768
- if (deepSearchResults && debouncedDeepSearchQuery && deepSearchResults.query === debouncedDeepSearchQuery) {
769
- for (const result of deepSearchResults.results) {
770
- if (result.searchableText) {
771
- const snippet = extractSnippet(result.searchableText, debouncedDeepSearchQuery, SNIPPET_CONTEXT_CHARS);
772
- if (snippet) {
773
- snippetMap.set(result.log, snippet);
774
- }
775
- }
776
- }
777
- const titleMatchIds = new Set(filtered.map((log) => log.messages[0]?.uuid));
778
- const transcriptOnlyMatches = deepSearchResults.results.map((r) => r.log).filter((log) => !titleMatchIds.has(log.messages[0]?.uuid));
779
- filtered = [...filtered, ...transcriptOnlyMatches];
780
- }
781
- return { filteredLogs: filtered, snippets: snippetMap };
782
- }, [titleFilteredLogs, deepSearchResults, debouncedDeepSearchQuery]);
783
- const displayedLogs = import_react3.default.useMemo(() => {
784
- if (agenticSearchState.status === "results" && agenticSearchState.results.length > 0) {
785
- return agenticSearchState.results;
786
- }
787
- return filteredLogs;
788
- }, [agenticSearchState, filteredLogs]);
789
- const maxLabelWidth = Math.max(30, columns - 4);
790
- const treeNodes = import_react3.default.useMemo(() => {
791
- if (!isResumeWithRenameEnabled) {
792
- return [];
793
- }
794
- const sessionGroups = groupLogsBySessionId(displayedLogs);
795
- return Array.from(sessionGroups.entries()).map(([sessionId, groupLogs]) => {
796
- const latestLog = groupLogs[0];
797
- const indexInFiltered = displayedLogs.indexOf(latestLog);
798
- const snippet = snippets.get(latestLog);
799
- const snippetStr = snippet ? formatSnippet(snippet, highlightColor) : null;
800
- if (groupLogs.length === 1) {
801
- const metadata = buildLogMetadata(latestLog, {
802
- showProjectPath: showAllProjects
803
- });
804
- return {
805
- id: `log:${sessionId}:0`,
806
- value: { log: latestLog, indexInFiltered },
807
- label: buildLogLabel(latestLog, maxLabelWidth),
808
- description: snippetStr ? `${metadata}
809
- ${snippetStr}` : metadata,
810
- dimDescription: true
811
- };
812
- }
813
- const forkCount = groupLogs.length - 1;
814
- const children = groupLogs.slice(1).map((log, index) => {
815
- const childIndexInFiltered = displayedLogs.indexOf(log);
816
- const childSnippet = snippets.get(log);
817
- const childSnippetStr = childSnippet ? formatSnippet(childSnippet, highlightColor) : null;
818
- const childMetadata = buildLogMetadata(log, {
819
- isChild: true,
820
- showProjectPath: showAllProjects
821
- });
822
- return {
823
- id: `log:${sessionId}:${index + 1}`,
824
- value: { log, indexInFiltered: childIndexInFiltered },
825
- label: buildLogLabel(log, maxLabelWidth, { isChild: true }),
826
- description: childSnippetStr ? `${childMetadata}
827
- ${childSnippetStr}` : childMetadata,
828
- dimDescription: true
829
- };
830
- });
831
- const parentMetadata = buildLogMetadata(latestLog, {
832
- showProjectPath: showAllProjects
833
- });
834
- return {
835
- id: `group:${sessionId}`,
836
- value: { log: latestLog, indexInFiltered },
837
- label: buildLogLabel(latestLog, maxLabelWidth, {
838
- isGroupHeader: true,
839
- forkCount
840
- }),
841
- description: snippetStr ? `${parentMetadata}
842
- ${snippetStr}` : parentMetadata,
843
- dimDescription: true,
844
- children
845
- };
846
- });
847
- }, [
848
- isResumeWithRenameEnabled,
849
- displayedLogs,
850
- maxLabelWidth,
851
- showAllProjects,
852
- snippets,
853
- highlightColor
854
- ]);
855
- const flatOptions = import_react3.default.useMemo(() => {
856
- if (isResumeWithRenameEnabled) {
857
- return [];
858
- }
859
- return displayedLogs.map((log, index) => {
860
- const rawSummary = getLogDisplayTitle(log);
861
- const summaryWithSidechain = rawSummary + (log.isSidechain ? " (sidechain)" : "");
862
- const summary = normalizeAndTruncateToWidth(summaryWithSidechain, maxLabelWidth);
863
- const baseDescription = formatLogMetadata(log);
864
- const projectSuffix = showAllProjects && log.projectPath ? ` \xB7 ${log.projectPath}` : "";
865
- const snippet = snippets.get(log);
866
- const snippetStr = snippet ? formatSnippet(snippet, highlightColor) : null;
867
- return {
868
- label: summary,
869
- description: snippetStr ? `${baseDescription}${projectSuffix}
870
- ${snippetStr}` : baseDescription + projectSuffix,
871
- dimDescription: true,
872
- value: index.toString()
873
- };
874
- });
875
- }, [
876
- isResumeWithRenameEnabled,
877
- displayedLogs,
878
- highlightColor,
879
- maxLabelWidth,
880
- showAllProjects,
881
- snippets
882
- ]);
883
- const focusedLog = focusedNode?.value.log ?? null;
884
- const getExpandCollapseHint = () => {
885
- if (!isResumeWithRenameEnabled || !focusedLog)
886
- return "";
887
- const sessionId = getSessionIdFromLog(focusedLog);
888
- if (!sessionId)
889
- return "";
890
- const sessionLogs = displayedLogs.filter((log) => getSessionIdFromLog(log) === sessionId);
891
- const hasMultipleLogs = sessionLogs.length > 1;
892
- if (!hasMultipleLogs)
893
- return "";
894
- const isExpanded = expandedGroupSessionIds.has(sessionId);
895
- const isChildNode = sessionLogs.indexOf(focusedLog) > 0;
896
- if (isChildNode) {
897
- return "\u2190 to collapse";
898
- }
899
- return isExpanded ? "\u2190 to collapse" : "\u2192 to expand";
900
- };
901
- const handleRenameSubmit = import_react3.default.useCallback(async () => {
902
- const sessionId = focusedLog ? getSessionIdFromLog(focusedLog) : undefined;
903
- if (!focusedLog || !sessionId) {
904
- setViewMode("list");
905
- setRenameValue("");
906
- return;
907
- }
908
- if (renameValue.trim()) {
909
- await saveCustomTitle(sessionId, renameValue.trim(), focusedLog.fullPath);
910
- if (isResumeWithRenameEnabled && onLogsChanged) {
911
- onLogsChanged();
912
- }
913
- }
914
- setViewMode("list");
915
- setRenameValue("");
916
- }, [focusedLog, renameValue, onLogsChanged, isResumeWithRenameEnabled]);
917
- const exitSearchMode = import_react3.default.useCallback(() => {
918
- setViewMode("list");
919
- logEvent("tengu_session_search_toggled", { enabled: false });
920
- }, []);
921
- const enterSearchMode = import_react3.default.useCallback(() => {
922
- setViewMode("search");
923
- logEvent("tengu_session_search_toggled", { enabled: true });
924
- }, []);
925
- const handleAgenticSearch = import_react3.default.useCallback(async () => {
926
- if (!searchQuery.trim() || !onAgenticSearch || !isAgenticSearchEnabled) {
927
- return;
928
- }
929
- agenticSearchAbortRef.current?.abort();
930
- const abortController = new AbortController;
931
- agenticSearchAbortRef.current = abortController;
932
- setAgenticSearchState({ status: "searching" });
933
- logEvent("tengu_agentic_search_started", {
934
- query_length: searchQuery.length
935
- });
936
- try {
937
- const results = await onAgenticSearch(searchQuery, logs, abortController.signal);
938
- if (abortController.signal.aborted) {
939
- return;
940
- }
941
- setAgenticSearchState({ status: "results", results, query: searchQuery });
942
- logEvent("tengu_agentic_search_completed", {
943
- query_length: searchQuery.length,
944
- results_count: results.length
945
- });
946
- } catch (error) {
947
- if (abortController.signal.aborted) {
948
- return;
949
- }
950
- setAgenticSearchState({
951
- status: "error",
952
- message: error instanceof Error ? error.message : "Search failed"
953
- });
954
- logEvent("tengu_agentic_search_error", {
955
- query_length: searchQuery.length
956
- });
957
- }
958
- }, [searchQuery, onAgenticSearch, isAgenticSearchEnabled, logs]);
959
- import_react3.default.useEffect(() => {
960
- if (agenticSearchState.status !== "idle" && agenticSearchState.status !== "searching") {
961
- if (agenticSearchState.status === "results" && agenticSearchState.query !== searchQuery || agenticSearchState.status === "error") {
962
- setAgenticSearchState({ status: "idle" });
963
- }
964
- }
965
- }, [searchQuery, agenticSearchState]);
966
- import_react3.default.useEffect(() => {
967
- return () => {
968
- agenticSearchAbortRef.current?.abort();
969
- };
970
- }, []);
971
- const prevAgenticStatusRef = import_react3.default.useRef(agenticSearchState.status);
972
- import_react3.default.useEffect(() => {
973
- const prevStatus = prevAgenticStatusRef.current;
974
- prevAgenticStatusRef.current = agenticSearchState.status;
975
- if (prevStatus === "searching" && agenticSearchState.status === "results") {
976
- if (isResumeWithRenameEnabled && treeNodes.length > 0) {
977
- setFocusedNode(treeNodes[0]);
978
- } else if (!isResumeWithRenameEnabled && displayedLogs.length > 0) {
979
- const firstLog = displayedLogs[0];
980
- setFocusedNode({
981
- id: "0",
982
- value: { log: firstLog, indexInFiltered: 0 },
983
- label: ""
984
- });
985
- }
986
- }
987
- }, [
988
- agenticSearchState.status,
989
- isResumeWithRenameEnabled,
990
- treeNodes,
991
- displayedLogs
992
- ]);
993
- const handleFlatOptionsSelectFocus = import_react3.default.useCallback((value) => {
994
- const index = parseInt(value, 10);
995
- const log = displayedLogs[index];
996
- if (!log || prevFocusedIdRef.current === index.toString()) {
997
- return;
998
- }
999
- prevFocusedIdRef.current = index.toString();
1000
- setFocusedNode({
1001
- id: index.toString(),
1002
- value: { log, indexInFiltered: index },
1003
- label: ""
1004
- });
1005
- setFocusedIndex(index + 1);
1006
- }, [displayedLogs]);
1007
- const handleTreeSelectFocus = import_react3.default.useCallback((node) => {
1008
- setFocusedNode(node);
1009
- const index = displayedLogs.findIndex((log) => getSessionIdFromLog(log) === getSessionIdFromLog(node.value.log));
1010
- if (index >= 0) {
1011
- setFocusedIndex(index + 1);
1012
- }
1013
- }, [displayedLogs]);
1014
- useKeybinding("confirm:no", () => {
1015
- agenticSearchAbortRef.current?.abort();
1016
- setAgenticSearchState({ status: "idle" });
1017
- logEvent("tengu_agentic_search_cancelled", {});
1018
- }, {
1019
- context: "Confirmation",
1020
- isActive: viewMode !== "preview" && agenticSearchState.status === "searching"
1021
- });
1022
- useKeybinding("confirm:no", () => {
1023
- setViewMode("list");
1024
- setRenameValue("");
1025
- }, {
1026
- context: "Settings",
1027
- isActive: viewMode === "rename" && agenticSearchState.status !== "searching"
1028
- });
1029
- useKeybinding("confirm:no", () => {
1030
- setSearchQuery("");
1031
- setIsAgenticSearchOptionFocused(false);
1032
- onCancel?.();
1033
- }, {
1034
- context: "Confirmation",
1035
- isActive: viewMode !== "preview" && viewMode !== "rename" && viewMode !== "search" && isAgenticSearchOptionFocused && agenticSearchState.status !== "searching"
1036
- });
1037
- use_input_default((input, key) => {
1038
- if (viewMode === "preview") {
1039
- return;
1040
- }
1041
- if (agenticSearchState.status === "searching") {
1042
- return;
1043
- }
1044
- if (viewMode === "rename") {} else if (viewMode === "search") {
1045
- if (input.toLowerCase() === "n" && key.ctrl) {
1046
- exitSearchMode();
1047
- } else if (key.return || key.downArrow) {
1048
- if (searchQuery.trim() && onAgenticSearch && isAgenticSearchEnabled && agenticSearchState.status !== "results") {
1049
- setIsAgenticSearchOptionFocused(true);
1050
- }
1051
- }
1052
- } else {
1053
- if (isAgenticSearchOptionFocused) {
1054
- if (key.return) {
1055
- handleAgenticSearch();
1056
- setIsAgenticSearchOptionFocused(false);
1057
- return;
1058
- } else if (key.downArrow) {
1059
- setIsAgenticSearchOptionFocused(false);
1060
- return;
1061
- } else if (key.upArrow) {
1062
- setViewMode("search");
1063
- setIsAgenticSearchOptionFocused(false);
1064
- return;
1065
- }
1066
- }
1067
- if (hasTags && key.tab) {
1068
- const offset = key.shift ? -1 : 1;
1069
- setSelectedTagIndex((prev) => {
1070
- const current = prev < tagTabs.length ? prev : 0;
1071
- const newIndex = (current + tagTabs.length + offset) % tagTabs.length;
1072
- const newTab = tagTabs[newIndex];
1073
- logEvent("tengu_session_tag_filter_changed", {
1074
- is_all: newTab === "All",
1075
- tag_count: uniqueTags.length
1076
- });
1077
- return newIndex;
1078
- });
1079
- return;
1080
- }
1081
- const keyIsNotCtrlOrMeta = !key.ctrl && !key.meta;
1082
- const lowerInput = input.toLowerCase();
1083
- if (lowerInput === "a" && key.ctrl && onToggleAllProjects) {
1084
- onToggleAllProjects();
1085
- logEvent("tengu_session_all_projects_toggled", {
1086
- enabled: !showAllProjects
1087
- });
1088
- } else if (lowerInput === "b" && key.ctrl) {
1089
- const newEnabled = !branchFilterEnabled;
1090
- setBranchFilterEnabled(newEnabled);
1091
- logEvent("tengu_session_branch_filter_toggled", {
1092
- enabled: newEnabled
1093
- });
1094
- } else if (lowerInput === "w" && key.ctrl && hasMultipleWorktrees) {
1095
- const newValue = !showAllWorktrees;
1096
- setShowAllWorktrees(newValue);
1097
- logEvent("tengu_session_worktree_filter_toggled", {
1098
- enabled: newValue
1099
- });
1100
- } else if (lowerInput === "/" && keyIsNotCtrlOrMeta) {
1101
- setViewMode("search");
1102
- logEvent("tengu_session_search_toggled", { enabled: true });
1103
- } else if (lowerInput === "r" && key.ctrl && focusedLog) {
1104
- setViewMode("rename");
1105
- setRenameValue("");
1106
- logEvent("tengu_session_rename_started", {});
1107
- } else if (lowerInput === "v" && key.ctrl && focusedLog) {
1108
- setPreviewLog(focusedLog);
1109
- setViewMode("preview");
1110
- logEvent("tengu_session_preview_opened", {
1111
- messageCount: focusedLog.messageCount
1112
- });
1113
- } else if (focusedLog && keyIsNotCtrlOrMeta && input.length > 0 && !/^\s+$/.test(input)) {
1114
- setViewMode("search");
1115
- setSearchQuery(input);
1116
- logEvent("tengu_session_search_toggled", { enabled: true });
1117
- }
1118
- }
1119
- }, { isActive: true });
1120
- const filterIndicators = [];
1121
- if (branchFilterEnabled && currentBranch) {
1122
- filterIndicators.push(currentBranch);
1123
- }
1124
- if (hasMultipleWorktrees && !showAllWorktrees) {
1125
- filterIndicators.push("current worktree");
1126
- }
1127
- const showAdditionalFilterLine = filterIndicators.length > 0 && viewMode !== "search";
1128
- const searchBoxLines = 3;
1129
- const headerLines = 5 + searchBoxLines + (showAdditionalFilterLine ? 1 : 0) + tagTabsLines;
1130
- const footerLines = 2;
1131
- const visibleCount = Math.max(1, Math.floor((maxHeight - headerLines - footerLines) / 3));
1132
- import_react3.default.useEffect(() => {
1133
- if (!onLoadMore)
1134
- return;
1135
- const buffer = visibleCount * 2;
1136
- if (focusedIndex + buffer >= displayedLogs.length) {
1137
- onLoadMore(visibleCount * 3);
1138
- }
1139
- }, [focusedIndex, visibleCount, displayedLogs.length, onLoadMore]);
1140
- if (logs.length === 0) {
1141
- return null;
1142
- }
1143
- if (viewMode === "preview" && previewLog && isResumeWithRenameEnabled) {
1144
- return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(SessionPreview, {
1145
- log: previewLog,
1146
- onExit: () => {
1147
- setViewMode("list");
1148
- setPreviewLog(null);
1149
- },
1150
- onSelect
1151
- }, undefined, false, undefined, this);
1152
- }
1153
- return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1154
- flexDirection: "column",
1155
- height: maxHeight - 1,
1156
- children: [
1157
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1158
- flexShrink: 0,
1159
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Divider, {
1160
- color: "suggestion"
1161
- }, undefined, false, undefined, this)
1162
- }, undefined, false, undefined, this),
1163
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1164
- flexShrink: 0,
1165
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1166
- children: " "
1167
- }, undefined, false, undefined, this)
1168
- }, undefined, false, undefined, this),
1169
- hasTags ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(TagTabs, {
1170
- tabs: tagTabs,
1171
- selectedIndex: effectiveTagIndex,
1172
- availableWidth: columns,
1173
- showAllProjects
1174
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1175
- flexShrink: 0,
1176
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1177
- bold: true,
1178
- color: "suggestion",
1179
- children: [
1180
- "Resume Session",
1181
- viewMode === "list" && displayedLogs.length > visibleCount && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1182
- dimColor: true,
1183
- children: [
1184
- " ",
1185
- "(",
1186
- focusedIndex,
1187
- " of ",
1188
- displayedLogs.length,
1189
- ")"
1190
- ]
1191
- }, undefined, true, undefined, this)
1192
- ]
1193
- }, undefined, true, undefined, this)
1194
- }, undefined, false, undefined, this),
1195
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(SearchBox, {
1196
- query: searchQuery,
1197
- isFocused: viewMode === "search",
1198
- isTerminalFocused,
1199
- cursorOffset: searchCursorOffset
1200
- }, undefined, false, undefined, this),
1201
- filterIndicators.length > 0 && viewMode !== "search" && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1202
- flexShrink: 0,
1203
- paddingLeft: 2,
1204
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1205
- dimColor: true,
1206
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Byline, {
1207
- children: filterIndicators
1208
- }, undefined, false, undefined, this)
1209
- }, undefined, false, undefined, this)
1210
- }, undefined, false, undefined, this),
1211
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1212
- flexShrink: 0,
1213
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1214
- children: " "
1215
- }, undefined, false, undefined, this)
1216
- }, undefined, false, undefined, this),
1217
- agenticSearchState.status === "searching" && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1218
- paddingLeft: 1,
1219
- flexShrink: 0,
1220
- children: [
1221
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Spinner, {}, undefined, false, undefined, this),
1222
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1223
- children: " Searching\u2026"
1224
- }, undefined, false, undefined, this)
1225
- ]
1226
- }, undefined, true, undefined, this),
1227
- agenticSearchState.status === "results" && agenticSearchState.results.length > 0 && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1228
- paddingLeft: 1,
1229
- marginBottom: 1,
1230
- flexShrink: 0,
1231
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1232
- dimColor: true,
1233
- italic: true,
1234
- children: "Claude found these results:"
1235
- }, undefined, false, undefined, this)
1236
- }, undefined, false, undefined, this),
1237
- agenticSearchState.status === "results" && agenticSearchState.results.length === 0 && filteredLogs.length === 0 && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1238
- paddingLeft: 1,
1239
- marginBottom: 1,
1240
- flexShrink: 0,
1241
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1242
- dimColor: true,
1243
- italic: true,
1244
- children: "No matching sessions found."
1245
- }, undefined, false, undefined, this)
1246
- }, undefined, false, undefined, this),
1247
- agenticSearchState.status === "error" && filteredLogs.length === 0 && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1248
- paddingLeft: 1,
1249
- marginBottom: 1,
1250
- flexShrink: 0,
1251
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1252
- dimColor: true,
1253
- italic: true,
1254
- children: "No matching sessions found."
1255
- }, undefined, false, undefined, this)
1256
- }, undefined, false, undefined, this),
1257
- Boolean(searchQuery.trim()) && onAgenticSearch && isAgenticSearchEnabled && agenticSearchState.status !== "searching" && agenticSearchState.status !== "results" && agenticSearchState.status !== "error" && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1258
- flexShrink: 0,
1259
- flexDirection: "column",
1260
- children: [
1261
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1262
- flexDirection: "row",
1263
- gap: 1,
1264
- children: [
1265
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1266
- color: isAgenticSearchOptionFocused ? "suggestion" : undefined,
1267
- children: isAgenticSearchOptionFocused ? figures_default.pointer : " "
1268
- }, undefined, false, undefined, this),
1269
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1270
- color: isAgenticSearchOptionFocused ? "suggestion" : undefined,
1271
- bold: isAgenticSearchOptionFocused,
1272
- children: "Search deeply using Claude \u2192"
1273
- }, undefined, false, undefined, this)
1274
- ]
1275
- }, undefined, true, undefined, this),
1276
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1277
- height: 1
1278
- }, undefined, false, undefined, this)
1279
- ]
1280
- }, undefined, true, undefined, this),
1281
- agenticSearchState.status === "searching" ? null : viewMode === "rename" && focusedLog ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1282
- paddingLeft: 2,
1283
- flexDirection: "column",
1284
- children: [
1285
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1286
- bold: true,
1287
- children: "Rename session:"
1288
- }, undefined, false, undefined, this),
1289
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1290
- paddingTop: 1,
1291
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(TextInput, {
1292
- value: renameValue,
1293
- onChange: setRenameValue,
1294
- onSubmit: handleRenameSubmit,
1295
- placeholder: getLogDisplayTitle(focusedLog, "Enter new session name"),
1296
- columns,
1297
- cursorOffset: renameCursorOffset,
1298
- onChangeCursorOffset: setRenameCursorOffset,
1299
- showCursor: true
1300
- }, undefined, false, undefined, this)
1301
- }, undefined, false, undefined, this)
1302
- ]
1303
- }, undefined, true, undefined, this) : isResumeWithRenameEnabled ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(TreeSelect, {
1304
- nodes: treeNodes,
1305
- onSelect: (node) => {
1306
- onSelect(node.value.log);
1307
- },
1308
- onFocus: handleTreeSelectFocus,
1309
- onCancel,
1310
- focusNodeId: focusedNode?.id,
1311
- visibleOptionCount: visibleCount,
1312
- layout: "expanded",
1313
- isDisabled: viewMode === "search" || isAgenticSearchOptionFocused,
1314
- hideIndexes: false,
1315
- isNodeExpanded: (nodeId) => {
1316
- if (viewMode === "search" || branchFilterEnabled) {
1317
- return true;
1318
- }
1319
- const sessionId = typeof nodeId === "string" && nodeId.startsWith("group:") ? nodeId.substring(6) : null;
1320
- return sessionId ? expandedGroupSessionIds.has(sessionId) : false;
1321
- },
1322
- onExpand: (nodeId) => {
1323
- const sessionId = typeof nodeId === "string" && nodeId.startsWith("group:") ? nodeId.substring(6) : null;
1324
- if (sessionId) {
1325
- setExpandedGroupSessionIds((prev) => new Set(prev).add(sessionId));
1326
- logEvent("tengu_session_group_expanded", {});
1327
- }
1328
- },
1329
- onCollapse: (nodeId) => {
1330
- const sessionId = typeof nodeId === "string" && nodeId.startsWith("group:") ? nodeId.substring(6) : null;
1331
- if (sessionId) {
1332
- setExpandedGroupSessionIds((prev) => {
1333
- const newSet = new Set(prev);
1334
- newSet.delete(sessionId);
1335
- return newSet;
1336
- });
1337
- }
1338
- },
1339
- onUpFromFirstItem: enterSearchMode
1340
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Select, {
1341
- options: flatOptions,
1342
- onChange: (value) => {
1343
- const itemIndex = parseInt(value, 10);
1344
- const log = displayedLogs[itemIndex];
1345
- if (log) {
1346
- onSelect(log);
1347
- }
1348
- },
1349
- visibleOptionCount: visibleCount,
1350
- onCancel,
1351
- onFocus: handleFlatOptionsSelectFocus,
1352
- defaultFocusValue: focusedNode?.id.toString(),
1353
- layout: "expanded",
1354
- isDisabled: viewMode === "search" || isAgenticSearchOptionFocused,
1355
- onUpFromFirstItem: enterSearchMode
1356
- }, undefined, false, undefined, this),
1357
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedBox_default, {
1358
- paddingLeft: 2,
1359
- children: exitState.pending ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1360
- dimColor: true,
1361
- children: [
1362
- "Press ",
1363
- exitState.keyName,
1364
- " again to exit"
1365
- ]
1366
- }, undefined, true, undefined, this) : viewMode === "rename" ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1367
- dimColor: true,
1368
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Byline, {
1369
- children: [
1370
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1371
- shortcut: "Enter",
1372
- action: "save"
1373
- }, undefined, false, undefined, this),
1374
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConfigurableShortcutHint, {
1375
- action: "confirm:no",
1376
- context: "Confirmation",
1377
- fallback: "Esc",
1378
- description: "cancel"
1379
- }, undefined, false, undefined, this)
1380
- ]
1381
- }, undefined, true, undefined, this)
1382
- }, undefined, false, undefined, this) : agenticSearchState.status === "searching" ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1383
- dimColor: true,
1384
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Byline, {
1385
- children: [
1386
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1387
- children: "Searching with Claude\u2026"
1388
- }, undefined, false, undefined, this),
1389
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConfigurableShortcutHint, {
1390
- action: "confirm:no",
1391
- context: "Confirmation",
1392
- fallback: "Esc",
1393
- description: "cancel"
1394
- }, undefined, false, undefined, this)
1395
- ]
1396
- }, undefined, true, undefined, this)
1397
- }, undefined, false, undefined, this) : isAgenticSearchOptionFocused ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1398
- dimColor: true,
1399
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Byline, {
1400
- children: [
1401
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1402
- shortcut: "Enter",
1403
- action: "search"
1404
- }, undefined, false, undefined, this),
1405
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1406
- shortcut: "\u2193",
1407
- action: "skip"
1408
- }, undefined, false, undefined, this),
1409
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConfigurableShortcutHint, {
1410
- action: "confirm:no",
1411
- context: "Confirmation",
1412
- fallback: "Esc",
1413
- description: "cancel"
1414
- }, undefined, false, undefined, this)
1415
- ]
1416
- }, undefined, true, undefined, this)
1417
- }, undefined, false, undefined, this) : viewMode === "search" ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1418
- dimColor: true,
1419
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Byline, {
1420
- children: [
1421
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1422
- children: isSearching && isDeepSearchEnabled ? "Searching\u2026" : "Type to Search"
1423
- }, undefined, false, undefined, this),
1424
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1425
- shortcut: "Enter",
1426
- action: "select"
1427
- }, undefined, false, undefined, this),
1428
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConfigurableShortcutHint, {
1429
- action: "confirm:no",
1430
- context: "Confirmation",
1431
- fallback: "Esc",
1432
- description: "clear"
1433
- }, undefined, false, undefined, this)
1434
- ]
1435
- }, undefined, true, undefined, this)
1436
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1437
- dimColor: true,
1438
- children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Byline, {
1439
- children: [
1440
- onToggleAllProjects && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1441
- shortcut: "Ctrl+A",
1442
- action: `show ${showAllProjects ? "current dir" : "all projects"}`
1443
- }, undefined, false, undefined, this),
1444
- currentBranch && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1445
- shortcut: "Ctrl+B",
1446
- action: "toggle branch"
1447
- }, undefined, false, undefined, this),
1448
- hasMultipleWorktrees && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1449
- shortcut: "Ctrl+W",
1450
- action: `show ${showAllWorktrees ? "current worktree" : "all worktrees"}`
1451
- }, undefined, false, undefined, this),
1452
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1453
- shortcut: "Ctrl+V",
1454
- action: "preview"
1455
- }, undefined, false, undefined, this),
1456
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(KeyboardShortcutHint, {
1457
- shortcut: "Ctrl+R",
1458
- action: "rename"
1459
- }, undefined, false, undefined, this),
1460
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1461
- children: "Type to search"
1462
- }, undefined, false, undefined, this),
1463
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConfigurableShortcutHint, {
1464
- action: "confirm:no",
1465
- context: "Confirmation",
1466
- fallback: "Esc",
1467
- description: "cancel"
1468
- }, undefined, false, undefined, this),
1469
- getExpandCollapseHint() && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
1470
- children: getExpandCollapseHint()
1471
- }, undefined, false, undefined, this)
1472
- ]
1473
- }, undefined, true, undefined, this)
1474
- }, undefined, false, undefined, this)
1475
- }, undefined, false, undefined, this)
1476
- ]
1477
- }, undefined, true, undefined, this);
1478
- }
1479
- function extractSearchableText(message) {
1480
- if (message.type !== "user" && message.type !== "assistant") {
1481
- return "";
1482
- }
1483
- const content = "message" in message ? message.message?.content : undefined;
1484
- if (!content)
1485
- return "";
1486
- if (typeof content === "string") {
1487
- return content;
1488
- }
1489
- if (Array.isArray(content)) {
1490
- return content.map((block) => {
1491
- if (typeof block === "string")
1492
- return block;
1493
- if ("text" in block && typeof block.text === "string")
1494
- return block.text;
1495
- return "";
1496
- }).filter(Boolean).join(" ");
1497
- }
1498
- return "";
1499
- }
1500
- function buildSearchableText(log) {
1501
- const searchableMessages = log.messages.length <= DEEP_SEARCH_MAX_MESSAGES ? log.messages : [
1502
- ...log.messages.slice(0, DEEP_SEARCH_CROP_SIZE),
1503
- ...log.messages.slice(-DEEP_SEARCH_CROP_SIZE)
1504
- ];
1505
- const messageText = searchableMessages.map(extractSearchableText).filter(Boolean).join(" ");
1506
- const metadata = [
1507
- log.customTitle,
1508
- log.summary,
1509
- log.firstPrompt,
1510
- log.gitBranch,
1511
- log.tag,
1512
- log.prNumber ? `PR #${log.prNumber}` : undefined,
1513
- log.prRepository
1514
- ].filter(Boolean).join(" ");
1515
- const fullText = `${metadata} ${messageText}`.trim();
1516
- return fullText.length > DEEP_SEARCH_MAX_TEXT_LENGTH ? fullText.slice(0, DEEP_SEARCH_MAX_TEXT_LENGTH) : fullText;
1517
- }
1518
- function groupLogsBySessionId(filteredLogs) {
1519
- const groups = new Map;
1520
- for (const log of filteredLogs) {
1521
- const sessionId = getSessionIdFromLog(log);
1522
- if (sessionId) {
1523
- const existing = groups.get(sessionId);
1524
- if (existing) {
1525
- existing.push(log);
1526
- } else {
1527
- groups.set(sessionId, [log]);
1528
- }
1529
- }
1530
- }
1531
- groups.forEach((logs) => logs.sort((a, b) => new Date(b.modified).getTime() - new Date(a.modified).getTime()));
1532
- return groups;
1533
- }
1534
- function getUniqueTags(logs) {
1535
- const tags = new Set;
1536
- for (const log of logs) {
1537
- if (log.tag) {
1538
- tags.add(log.tag);
1539
- }
1540
- }
1541
- return Array.from(tags).sort((a, b) => a.localeCompare(b));
1542
- }
1543
- var import_react3, jsx_dev_runtime4, PARENT_PREFIX_WIDTH = 2, CHILD_PREFIX_WIDTH = 4, DEEP_SEARCH_MAX_MESSAGES = 2000, DEEP_SEARCH_CROP_SIZE = 1000, DEEP_SEARCH_MAX_TEXT_LENGTH = 50000, FUSE_THRESHOLD = 0.3, DATE_TIE_THRESHOLD_MS, SNIPPET_CONTEXT_CHARS = 50;
1544
- var init_LogSelector = __esm(() => {
1545
- init_source();
1546
- init_figures();
1547
- init_fuse();
1548
- init_state();
1549
- init_useExitOnCtrlCDWithKeybindings();
1550
- init_useSearchInput();
1551
- init_useTerminalSize();
1552
- init_src();
1553
- init_useKeybinding();
1554
- init_analytics();
1555
- init_format();
1556
- init_getWorktreePaths();
1557
- init_git();
1558
- init_log();
1559
- init_sessionStorage();
1560
- init_theme();
1561
- init_ConfigurableShortcutHint();
1562
- init_select();
1563
- init_SearchBox();
1564
- init_SessionPreview();
1565
- init_Spinner();
1566
- init_TagTabs();
1567
- init_TextInput();
1568
- init_TreeSelect();
1569
- import_react3 = __toESM(require_react(), 1);
1570
- jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
1571
- DATE_TIE_THRESHOLD_MS = 60 * 1000;
1572
- });
1573
-
1574
- // src/utils/agenticSessionSearch.ts
1575
- function extractMessageText(message) {
1576
- if (message.type !== "user" && message.type !== "assistant") {
1577
- return "";
1578
- }
1579
- const content = "message" in message ? message.message?.content : undefined;
1580
- if (!content)
1581
- return "";
1582
- if (typeof content === "string") {
1583
- return content;
1584
- }
1585
- if (Array.isArray(content)) {
1586
- return content.map((block) => {
1587
- if (typeof block === "string")
1588
- return block;
1589
- if ("text" in block && typeof block.text === "string")
1590
- return block.text;
1591
- return "";
1592
- }).filter(Boolean).join(" ");
1593
- }
1594
- return "";
1595
- }
1596
- function extractTranscript(messages) {
1597
- if (messages.length === 0)
1598
- return "";
1599
- const messagesToScan = messages.length <= MAX_MESSAGES_TO_SCAN ? messages : [
1600
- ...messages.slice(0, MAX_MESSAGES_TO_SCAN / 2),
1601
- ...messages.slice(-MAX_MESSAGES_TO_SCAN / 2)
1602
- ];
1603
- const text = messagesToScan.map(extractMessageText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
1604
- return text.length > MAX_TRANSCRIPT_CHARS ? text.slice(0, MAX_TRANSCRIPT_CHARS) + "\u2026" : text;
1605
- }
1606
- function logContainsQuery(log, queryLower) {
1607
- const title = getLogDisplayTitle(log).toLowerCase();
1608
- if (title.includes(queryLower))
1609
- return true;
1610
- if (log.customTitle?.toLowerCase().includes(queryLower))
1611
- return true;
1612
- if (log.tag?.toLowerCase().includes(queryLower))
1613
- return true;
1614
- if (log.gitBranch?.toLowerCase().includes(queryLower))
1615
- return true;
1616
- if (log.summary?.toLowerCase().includes(queryLower))
1617
- return true;
1618
- if (log.firstPrompt?.toLowerCase().includes(queryLower))
1619
- return true;
1620
- if (log.messages && log.messages.length > 0) {
1621
- const transcript = extractTranscript(log.messages).toLowerCase();
1622
- if (transcript.includes(queryLower))
1623
- return true;
1624
- }
1625
- return false;
1626
- }
1627
- async function agenticSessionSearch(query, logs, signal) {
1628
- if (!query.trim() || logs.length === 0) {
1629
- return [];
1630
- }
1631
- const queryLower = query.toLowerCase();
1632
- const matchingLogs = logs.filter((log) => logContainsQuery(log, queryLower));
1633
- let logsToSearch;
1634
- if (matchingLogs.length >= MAX_SESSIONS_TO_SEARCH) {
1635
- logsToSearch = matchingLogs.slice(0, MAX_SESSIONS_TO_SEARCH);
1636
- } else {
1637
- const nonMatchingLogs = logs.filter((log) => !logContainsQuery(log, queryLower));
1638
- const remainingSlots = MAX_SESSIONS_TO_SEARCH - matchingLogs.length;
1639
- logsToSearch = [
1640
- ...matchingLogs,
1641
- ...nonMatchingLogs.slice(0, remainingSlots)
1642
- ];
1643
- }
1644
- logForDebugging(`Agentic search: ${logsToSearch.length}/${logs.length} logs, query="${query}", ` + `matching: ${matchingLogs.length}, with messages: ${count(logsToSearch, (l) => l.messages?.length > 0)}`);
1645
- const logsWithTranscriptsPromises = logsToSearch.map(async (log) => {
1646
- if (isLiteLog(log)) {
1647
- try {
1648
- return await loadFullLog(log);
1649
- } catch (error) {
1650
- logError(error);
1651
- return log;
1652
- }
1653
- }
1654
- return log;
1655
- });
1656
- const logsWithTranscripts = await Promise.all(logsWithTranscriptsPromises);
1657
- logForDebugging(`Agentic search: loaded ${count(logsWithTranscripts, (l) => l.messages?.length > 0)}/${logsToSearch.length} logs with transcripts`);
1658
- const sessionList = logsWithTranscripts.map((log, index) => {
1659
- const parts = [`${index}:`];
1660
- const displayTitle = getLogDisplayTitle(log);
1661
- parts.push(displayTitle);
1662
- if (log.customTitle && log.customTitle !== displayTitle) {
1663
- parts.push(`[custom title: ${log.customTitle}]`);
1664
- }
1665
- if (log.tag) {
1666
- parts.push(`[tag: ${log.tag}]`);
1667
- }
1668
- if (log.gitBranch) {
1669
- parts.push(`[branch: ${log.gitBranch}]`);
1670
- }
1671
- if (log.summary) {
1672
- parts.push(`- Summary: ${log.summary}`);
1673
- }
1674
- if (log.firstPrompt && log.firstPrompt !== "No prompt") {
1675
- parts.push(`- First message: ${log.firstPrompt.slice(0, 300)}`);
1676
- }
1677
- if (log.messages && log.messages.length > 0) {
1678
- const transcript = extractTranscript(log.messages);
1679
- if (transcript) {
1680
- parts.push(`- Transcript: ${transcript}`);
1681
- }
1682
- }
1683
- return parts.join(" ");
1684
- }).join(`
1685
- `);
1686
- const userMessage = `Sessions:
1687
- ${sessionList}
1688
-
1689
- Search query: "${query}"
1690
-
1691
- Find the sessions that are most relevant to this query.`;
1692
- logForDebugging(`Agentic search prompt (first 500 chars): ${userMessage.slice(0, 500)}...`);
1693
- try {
1694
- const model = getSmallFastModel();
1695
- logForDebugging(`Agentic search using model: ${model}`);
1696
- const response = await sideQuery({
1697
- model,
1698
- system: SESSION_SEARCH_SYSTEM_PROMPT,
1699
- messages: [{ role: "user", content: userMessage }],
1700
- signal,
1701
- querySource: "session_search"
1702
- });
1703
- const textContent = response.content.find((block) => block.type === "text");
1704
- if (!textContent || textContent.type !== "text") {
1705
- logForDebugging("No text content in agentic search response");
1706
- return [];
1707
- }
1708
- logForDebugging(`Agentic search response: ${textContent.text}`);
1709
- const jsonMatch = textContent.text.match(/\{[\s\S]*\}/);
1710
- if (!jsonMatch) {
1711
- logForDebugging("Could not find JSON in agentic search response");
1712
- return [];
1713
- }
1714
- const result = jsonParse(jsonMatch[0]);
1715
- const relevantIndices = result.relevant_indices || [];
1716
- const relevantLogs = relevantIndices.filter((index) => index >= 0 && index < logsWithTranscripts.length).map((index) => logsWithTranscripts[index]);
1717
- logForDebugging(`Agentic search found ${relevantLogs.length} relevant sessions`);
1718
- return relevantLogs;
1719
- } catch (error) {
1720
- logError(error);
1721
- logForDebugging(`Agentic search error: ${error}`);
1722
- return [];
1723
- }
1724
- }
1725
- var MAX_TRANSCRIPT_CHARS = 2000, MAX_MESSAGES_TO_SCAN = 100, MAX_SESSIONS_TO_SEARCH = 100, SESSION_SEARCH_SYSTEM_PROMPT = `Your goal is to find relevant sessions based on a user's search query.
1726
-
1727
- You will be given a list of sessions with their metadata and a search query. Identify which sessions are most relevant to the query.
1728
-
1729
- Each session may include:
1730
- - Title (display name or custom title)
1731
- - Tag (user-assigned category, shown as [tag: name] - users tag sessions with /tag command to categorize them)
1732
- - Branch (git branch name, shown as [branch: name])
1733
- - Summary (AI-generated summary)
1734
- - First message (beginning of the conversation)
1735
- - Transcript (excerpt of conversation content)
1736
-
1737
- IMPORTANT: Tags are user-assigned labels that indicate the session's topic or category. If the query matches a tag exactly or partially, those sessions should be highly prioritized.
1738
-
1739
- For each session, consider (in order of priority):
1740
- 1. Exact tag matches (highest priority - user explicitly categorized this session)
1741
- 2. Partial tag matches or tag-related terms
1742
- 3. Title matches (custom titles or first message content)
1743
- 4. Branch name matches
1744
- 5. Summary and transcript content matches
1745
- 6. Semantic similarity and related concepts
1746
-
1747
- CRITICAL: Be VERY inclusive in your matching. Include sessions that:
1748
- - Contain the query term anywhere in any field
1749
- - Are semantically related to the query (e.g., "testing" matches sessions about "tests", "unit tests", "QA", etc.)
1750
- - Discuss topics that could be related to the query
1751
- - Have transcripts that mention the concept even in passing
1752
-
1753
- When in doubt, INCLUDE the session. It's better to return too many results than too few. The user can easily scan through results, but missing relevant sessions is frustrating.
1754
-
1755
- Return sessions ordered by relevance (most relevant first). If truly no sessions have ANY connection to the query, return an empty array - but this should be rare.
1756
-
1757
- Respond with ONLY the JSON object, no markdown formatting:
1758
- {"relevant_indices": [2, 5, 0]}`;
1759
- var init_agenticSessionSearch = __esm(() => {
1760
- init_array();
1761
- init_debug();
1762
- init_log();
1763
- init_model();
1764
- init_sessionStorage();
1765
- init_sideQuery();
1766
- init_slowOperations();
1767
- });
1768
-
1769
- // src/utils/crossProjectResume.ts
1770
- import { sep } from "path";
1771
- function checkCrossProjectResume(log, showAllProjects, worktreePaths) {
1772
- const currentCwd = getOriginalCwd();
1773
- if (!showAllProjects || !log.projectPath || log.projectPath === currentCwd) {
1774
- return { isCrossProject: false };
1775
- }
1776
- if (process.env.USER_TYPE !== "ant") {
1777
- const sessionId2 = getSessionIdFromLog(log);
1778
- const command2 = `cd ${quote([log.projectPath])} && claude --resume ${sessionId2}`;
1779
- return {
1780
- isCrossProject: true,
1781
- isSameRepoWorktree: false,
1782
- command: command2,
1783
- projectPath: log.projectPath
1784
- };
1785
- }
1786
- const isSameRepo = worktreePaths.some((wt) => log.projectPath === wt || log.projectPath.startsWith(wt + sep));
1787
- if (isSameRepo) {
1788
- return {
1789
- isCrossProject: true,
1790
- isSameRepoWorktree: true,
1791
- projectPath: log.projectPath
1792
- };
1793
- }
1794
- const sessionId = getSessionIdFromLog(log);
1795
- const command = `cd ${quote([log.projectPath])} && claude --resume ${sessionId}`;
1796
- return {
1797
- isCrossProject: true,
1798
- isSameRepoWorktree: false,
1799
- command,
1800
- projectPath: log.projectPath
1801
- };
1802
- }
1803
- var init_crossProjectResume = __esm(() => {
1804
- init_state();
1805
- init_shellQuote();
1806
- init_sessionStorage();
1807
- });
1808
-
1809
- export { LogSelector, init_LogSelector, agenticSessionSearch, init_agenticSessionSearch, checkCrossProjectResume, init_crossProjectResume };