@celljs/ta 4.11.0 → 4.12.0

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 (206) hide show
  1. package/dist/pi/CHANGELOG.md +4 -0
  2. package/dist/pi/package.json +1 -1
  3. package/dist/pi/packages/ta-agents/extension/index.mjs +194 -17
  4. package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts +5 -0
  5. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +4 -1
  6. package/dist/pi/packages/ta-agents/lib/agent-prompt.js +8 -2
  7. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts +70 -2
  8. package/dist/pi/packages/ta-agents/lib/agent-session.js +176 -18
  9. package/dist/pi/packages/ta-agents/lib/agent-streamer.js +16 -2
  10. package/dist/pi/packages/ta-agents/lib/agent-tool.js +1 -1
  11. package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts +7 -1
  12. package/dist/pi/packages/ta-agents/lib/agent-turn.js +26 -3
  13. package/dist/pi/packages/ta-agents/lib/extension.js +7 -0
  14. package/dist/pi/packages/ta-agents/lib/texts.d.ts +12 -0
  15. package/dist/pi/packages/ta-agents/lib/texts.js +12 -0
  16. package/dist/pi/packages/ta-agents/package.json +1 -1
  17. package/dist/pi/packages/ta-bots/package.json +1 -1
  18. package/dist/pi/packages/ta-changes/package.json +1 -1
  19. package/dist/pi/packages/ta-channels/lib/sidebar.js +31 -13
  20. package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
  21. package/dist/pi/packages/ta-channels/lib/style.js +3 -0
  22. package/dist/pi/packages/ta-channels/lib/views.d.ts +12 -0
  23. package/dist/pi/packages/ta-channels/lib/views.js +19 -0
  24. package/dist/pi/packages/ta-channels/package.json +1 -1
  25. package/dist/pi/packages/ta-channels/web/index.js +54 -9
  26. package/dist/pi/packages/ta-computer-use/package.json +1 -1
  27. package/dist/pi/packages/ta-cron/package.json +1 -1
  28. package/dist/pi/packages/ta-extensions/package.json +1 -1
  29. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +1 -0
  30. package/dist/pi/packages/ta-games/package.json +1 -1
  31. package/dist/pi/packages/ta-glance/lib/card.js +5 -4
  32. package/dist/pi/packages/ta-glance/lib/glance-spec.d.ts +2 -1
  33. package/dist/pi/packages/ta-glance/lib/glance-spec.js +8 -6
  34. package/dist/pi/packages/ta-glance/lib/style.d.ts +1 -1
  35. package/dist/pi/packages/ta-glance/lib/style.js +178 -101
  36. package/dist/pi/packages/ta-glance/package.json +1 -1
  37. package/dist/pi/packages/ta-glance/web/index.js +189 -109
  38. package/dist/pi/packages/ta-launcher/package.json +1 -1
  39. package/dist/pi/packages/ta-manual/lib/pictures-c.d.ts +2 -0
  40. package/dist/pi/packages/ta-manual/lib/pictures-c.js +53 -0
  41. package/dist/pi/packages/ta-manual/lib/pictures.js +2 -1
  42. package/dist/pi/packages/ta-manual/lib/topics.d.ts +1 -0
  43. package/dist/pi/packages/ta-manual/lib/topics.js +35 -1
  44. package/dist/pi/packages/ta-manual/package.json +1 -1
  45. package/dist/pi/packages/ta-manual/skills/ta-manual/SKILL.md +11 -0
  46. package/dist/pi/packages/ta-manual/web/index.js +186 -1
  47. package/dist/pi/packages/ta-notify/package.json +1 -1
  48. package/dist/pi/packages/ta-recall/extension/index.mjs +2 -1
  49. package/dist/pi/packages/ta-recall/lib/conversations.js +6 -0
  50. package/dist/pi/packages/ta-recall/lib/extension.js +5 -4
  51. package/dist/pi/packages/ta-recall/package.json +1 -1
  52. package/dist/pi/packages/ta-recall/web/index.js +4 -0
  53. package/dist/pi/packages/ta-rooms/README.en.md +8 -2
  54. package/dist/pi/packages/ta-rooms/README.md +8 -2
  55. package/dist/pi/packages/ta-rooms/extension/index.mjs +362 -0
  56. package/dist/pi/packages/ta-rooms/host/index.mjs +966 -0
  57. package/dist/pi/packages/ta-rooms/lib/agents-view.d.ts +25 -0
  58. package/dist/pi/packages/ta-rooms/lib/agents-view.js +128 -0
  59. package/dist/pi/packages/ta-rooms/lib/double-host.d.ts +114 -0
  60. package/dist/pi/packages/ta-rooms/lib/double-host.js +645 -0
  61. package/dist/pi/packages/ta-rooms/lib/double-i18n.d.ts +85 -0
  62. package/dist/pi/packages/ta-rooms/lib/double-i18n.js +172 -0
  63. package/dist/pi/packages/ta-rooms/lib/double-protocol.d.ts +165 -0
  64. package/dist/pi/packages/ta-rooms/lib/double-protocol.js +73 -0
  65. package/dist/pi/packages/ta-rooms/lib/double-util.d.ts +99 -0
  66. package/dist/pi/packages/ta-rooms/lib/double-util.js +180 -0
  67. package/dist/pi/packages/ta-rooms/lib/doubles-store.d.ts +45 -0
  68. package/dist/pi/packages/ta-rooms/lib/doubles-store.js +145 -0
  69. package/dist/pi/packages/ta-rooms/lib/doubles-view.d.ts +34 -0
  70. package/dist/pi/packages/ta-rooms/lib/doubles-view.js +223 -0
  71. package/dist/pi/packages/ta-rooms/lib/extension.d.ts +24 -0
  72. package/dist/pi/packages/ta-rooms/lib/extension.js +176 -0
  73. package/dist/pi/packages/ta-rooms/lib/host.d.ts +7 -0
  74. package/dist/pi/packages/ta-rooms/lib/host.js +18 -0
  75. package/dist/pi/packages/ta-rooms/lib/i18n.d.ts +4 -0
  76. package/dist/pi/packages/ta-rooms/lib/i18n.js +8 -0
  77. package/dist/pi/packages/ta-rooms/lib/index.js +23 -2
  78. package/dist/pi/packages/ta-rooms/lib/members-view.js +32 -2
  79. package/dist/pi/packages/ta-rooms/lib/page.d.ts +57 -8
  80. package/dist/pi/packages/ta-rooms/lib/page.js +121 -27
  81. package/dist/pi/packages/ta-rooms/lib/room-view.d.ts +2 -4
  82. package/dist/pi/packages/ta-rooms/lib/room-view.js +52 -34
  83. package/dist/pi/packages/ta-rooms/lib/rooms-home.d.ts +32 -0
  84. package/dist/pi/packages/ta-rooms/lib/rooms-home.js +141 -0
  85. package/dist/pi/packages/ta-rooms/lib/rooms-page.d.ts +8 -2
  86. package/dist/pi/packages/ta-rooms/lib/rooms-page.js +64 -21
  87. package/dist/pi/packages/ta-rooms/lib/style.d.ts +1 -1
  88. package/dist/pi/packages/ta-rooms/lib/style.js +96 -45
  89. package/dist/pi/packages/ta-rooms/package.json +9 -3
  90. package/dist/pi/packages/ta-rooms/web/index.js +1380 -147
  91. package/dist/pi/packages/ta-share/lib/shares-page.js +35 -11
  92. package/dist/pi/packages/ta-share/lib/style.d.ts +1 -1
  93. package/dist/pi/packages/ta-share/lib/style.js +11 -5
  94. package/dist/pi/packages/ta-share/package.json +1 -1
  95. package/dist/pi/packages/ta-share/web/index.js +45 -18
  96. package/dist/pi/packages/ta-workspace/package.json +1 -1
  97. package/dist/public/assets/{abnfDiagram-S7VZAUFO-D9uU0Tx2.js → abnfDiagram-S7VZAUFO-BnqtcbpZ.js} +1 -1
  98. package/dist/public/assets/{architecture-WOLXFQ4H-f7Nm7EIo.js → architecture-WOLXFQ4H-BzPq1Ioe.js} +1 -1
  99. package/dist/public/assets/{architectureDiagram-YGSQEFNW-DSAqlcms.js → architectureDiagram-YGSQEFNW-BsquO3a7.js} +1 -1
  100. package/dist/public/assets/{blockDiagram-APKKGZFW-C0lPIW9g.js → blockDiagram-APKKGZFW-BQNYOEP4.js} +1 -1
  101. package/dist/public/assets/{browser-WLpgVYno.js → browser-DS711n7Y.js} +1 -1
  102. package/dist/public/assets/{c4Diagram-KJ2TOQU5-CDcZ7mJq.js → c4Diagram-KJ2TOQU5-D6e79Ycq.js} +1 -1
  103. package/dist/public/assets/{chunk-6MUBBAK2-CXPuyqPL.js → chunk-6MUBBAK2-B-sgaPoU.js} +1 -1
  104. package/dist/public/assets/{chunk-AXFCVDMN-Du6JRX1x.js → chunk-AXFCVDMN-D8pJKIg2.js} +1 -1
  105. package/dist/public/assets/{chunk-BG4553SI-D592E55X.js → chunk-BG4553SI-86TL-vCz.js} +1 -1
  106. package/dist/public/assets/{chunk-DQASFODM-BW2r2SL4.js → chunk-DQASFODM-CfUVuGjc.js} +1 -1
  107. package/dist/public/assets/{chunk-HFQBQIA3-C3yoe54R.js → chunk-HFQBQIA3-Drm0FEYk.js} +1 -1
  108. package/dist/public/assets/{chunk-KQLB2F66-DF8gfYCy.js → chunk-KQLB2F66-BVFRADlC.js} +1 -1
  109. package/dist/public/assets/{chunk-KS47KZWR-C8CRMTv1.js → chunk-KS47KZWR-DfyALEmP.js} +1 -1
  110. package/dist/public/assets/{chunk-LEVMRMFU-BDcMKiwj.js → chunk-LEVMRMFU-DtJVzk2c.js} +1 -1
  111. package/dist/public/assets/{chunk-M57EVK23-CKJPBygc.js → chunk-M57EVK23-DTy27PHQ.js} +1 -1
  112. package/dist/public/assets/{chunk-OY52VR5R-B3ZWH07L.js → chunk-OY52VR5R-nSgn7jZg.js} +1 -1
  113. package/dist/public/assets/{chunk-QB3YPZ4I-DI-z4UPL.js → chunk-QB3YPZ4I-CkSxO_X6.js} +1 -1
  114. package/dist/public/assets/{chunk-R3KSYZAL-Bg4-haAc.js → chunk-R3KSYZAL-Ck6iAjAL.js} +1 -1
  115. package/dist/public/assets/{chunk-STOXU5M4-l_SHib3p.js → chunk-STOXU5M4-DQPHdSTh.js} +1 -1
  116. package/dist/public/assets/{chunk-TU62E6Q5-BINu9tIm.js → chunk-TU62E6Q5-Bc2AbV2Y.js} +1 -1
  117. package/dist/public/assets/{chunk-X4PVCEUW-BQn-mvV5.js → chunk-X4PVCEUW-Cgpm0IXm.js} +1 -1
  118. package/dist/public/assets/{chunk-XXDRQBXY-uvpAu0Ys.js → chunk-XXDRQBXY-CGE4eLpg.js} +1 -1
  119. package/dist/public/assets/{classDiagram-v2-L25IHNXF-BIowooW1.js → classDiagram-v2-L25IHNXF-4eQuDPEo.js} +1 -1
  120. package/dist/public/assets/{cose-bilkent-JH36ORCC-BTyx1Mh2.js → cose-bilkent-JH36ORCC-tDLCWq07.js} +1 -1
  121. package/dist/public/assets/cynefin-EF2NZ3EQ-Dd40W2Jh.js +1 -0
  122. package/dist/public/assets/{cynefinDiagram-L36ESFBY-D64EU9I0.js → cynefinDiagram-L36ESFBY-ByqcZ8x9.js} +1 -1
  123. package/dist/public/assets/{d3-selection-CN9k6_B9.js → d3-selection-Bgn1374-.js} +1 -1
  124. package/dist/public/assets/{dagre-SPEB5RXH-FCbz2-Kk.js → dagre-SPEB5RXH-mCgr71mV.js} +1 -1
  125. package/dist/public/assets/{diagram-3B7GL73J-OhHUSI7j.js → diagram-3B7GL73J-DpYSwpQ0.js} +1 -1
  126. package/dist/public/assets/{diagram-DNEMPZML-Be4xMtp6.js → diagram-DNEMPZML-DMozUQzi.js} +1 -1
  127. package/dist/public/assets/{diagram-L3MUGCDN-CmKSs3aG.js → diagram-L3MUGCDN-Bk5Uf8PD.js} +1 -1
  128. package/dist/public/assets/{diagram-LA4NIPWU-D1C32rMN.js → diagram-LA4NIPWU-DFt5cPVK.js} +1 -1
  129. package/dist/public/assets/{diagram-MHCOC4E2-BjoE6JXs.js → diagram-MHCOC4E2-BkZZcKqK.js} +1 -1
  130. package/dist/public/assets/{diagram-XPFHEONP-B22k4v8R.js → diagram-XPFHEONP-HEY6kyyN.js} +1 -1
  131. package/dist/public/assets/{dist-DcBP8Cf6.js → dist-Bj2CrKn7.js} +1 -1
  132. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-Tn-K8-X7.js → ebnfDiagram-UZSYDL2S-D4JvYyVb.js} +1 -1
  133. package/dist/public/assets/{editor.api-Bz4sjRz_.js → editor.api-BpJFzYbl.js} +1 -1
  134. package/dist/public/assets/{elk-XV6XMXQE-COnQsWlN.js → elk-XV6XMXQE-CT6qLJkF.js} +1 -1
  135. package/dist/public/assets/{erDiagram-EYBAPDEH-c53dJilq.js → erDiagram-EYBAPDEH-BGng1goR.js} +1 -1
  136. package/dist/public/assets/{eventmodeling-K75KTNOO-DaFpPPks.js → eventmodeling-K75KTNOO-Tt8O-Q1Z.js} +1 -1
  137. package/dist/public/assets/flowDiagram-MALGAFMO-uFzenfA3.js +1 -0
  138. package/dist/public/assets/{freemarker2-BLxfRHsw.js → freemarker2-Dd5ksoRn.js} +1 -1
  139. package/dist/public/assets/{ganttDiagram-23REXITY-Md-SavIS.js → ganttDiagram-23REXITY-Jl8VO_g2.js} +1 -1
  140. package/dist/public/assets/gitGraph-VSP46ZUC-D28I_jUc.js +1 -0
  141. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-CMSwTghO.js → gitGraphDiagram-STJD7YCW-Be4qXALb.js} +1 -1
  142. package/dist/public/assets/{handlebars-sNpu01kP.js → handlebars-4xabgUi4.js} +1 -1
  143. package/dist/public/assets/{html-C_tKd-uP.js → html-Dk3kt2w_.js} +1 -1
  144. package/dist/public/assets/{index-Bn86rI4n.js → index-Bx0c7eoh.js} +2 -2
  145. package/dist/public/assets/info-OHQRW6UA-5vIGEIq7.js +1 -0
  146. package/dist/public/assets/{infoDiagram-KBXO4MBG-CwgNj-7i.js → infoDiagram-KBXO4MBG-Coc0tdwb.js} +1 -1
  147. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-BSlzQNMN.js → ishikawaDiagram-M35NCXHK-CE_1VQCg.js} +1 -1
  148. package/dist/public/assets/{javascript-l3qKw0L-.js → javascript-DKLGqy6v.js} +1 -1
  149. package/dist/public/assets/{journeyDiagram-OPLOXDXO-B09LPEnF.js → journeyDiagram-OPLOXDXO-CrolRZ_7.js} +1 -1
  150. package/dist/public/assets/{jsonMode-5SQQn1EX.js → jsonMode-Chcs19_y.js} +1 -1
  151. package/dist/public/assets/{kanban-definition-BZKZHSQY-BiW4aJ29.js → kanban-definition-BZKZHSQY-CjJj47De.js} +1 -1
  152. package/dist/public/assets/{liquid-BGyTIIUt.js → liquid-jff3p-Ji.js} +1 -1
  153. package/dist/public/assets/{mdx-8tGjz4em.js → mdx-DW4uRDfJ.js} +1 -1
  154. package/dist/public/assets/{mermaid-parser.core-CctN5b0z.js → mermaid-parser.core-XhQj6FvH.js} +3 -3
  155. package/dist/public/assets/{mermaid.core-7ERSdZ4-.js → mermaid.core-OD4Atimg.js} +4 -4
  156. package/dist/public/assets/{mindmap-definition-I2QAS2VK-D-GOUwW1.js → mindmap-definition-I2QAS2VK-DpGelVY7.js} +1 -1
  157. package/dist/public/assets/module-CrD0OHQp.js +1 -0
  158. package/dist/public/assets/module-DEBMgdtf.js +2273 -0
  159. package/dist/public/assets/{monaco-B_9hlk78.js → monaco-BTVZP-tU.js} +3 -3
  160. package/dist/public/assets/packet-JDAUHWVQ-CBxQ5Mzy.js +1 -0
  161. package/dist/public/assets/{pegDiagram-FD4XPPHP-Dmy1fWB3.js → pegDiagram-FD4XPPHP-CqcBmPfB.js} +1 -1
  162. package/dist/public/assets/pie-XZMESJXO-DT5V3581.js +1 -0
  163. package/dist/public/assets/{pieDiagram-J4AKIIQI-CXFHLYTg.js → pieDiagram-J4AKIIQI-CRir3beB.js} +1 -1
  164. package/dist/public/assets/{python-e-JK0s5M.js → python-BwW_0207.js} +1 -1
  165. package/dist/public/assets/{quadrantDiagram-XTYBLID2-RQvEpGWO.js → quadrantDiagram-XTYBLID2-DIY6gdcf.js} +1 -1
  166. package/dist/public/assets/radar-ABXABTNO-BAOovYEa.js +1 -0
  167. package/dist/public/assets/railroad-I3PHUGI6-RZ2Rnwzh.js +1 -0
  168. package/dist/public/assets/{railroad-abnf-LNEFI6M7-CDOSPZwX.js → railroad-abnf-LNEFI6M7-XWNOzunl.js} +1 -1
  169. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-BTrNQ0DX.js → railroad-ebnf-DWYD2UWJ-CI0-j1Jz.js} +1 -1
  170. package/dist/public/assets/{railroad-peg-JR7BVNR7-B7NtVofS.js → railroad-peg-JR7BVNR7-BVB_IaIG.js} +1 -1
  171. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-DsDrT0Jf.js → railroadDiagram-MRQ6NCDL-CudwT6q2.js} +1 -1
  172. package/dist/public/assets/{razor-DtSPwumi.js → razor-DrjCyQqB.js} +1 -1
  173. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-BQh0hFuA.js → requirementDiagram-Y7LWUY3S-CvRMeRqj.js} +1 -1
  174. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-BUXNAQEF.js → sankeyDiagram-WGJFYUXA-adxYCJKr.js} +1 -1
  175. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-05f-N5V_.js → sequenceDiagram-5NDRBG5M-lCRsoLUp.js} +1 -1
  176. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-D6V1fGWV.js → stateDiagram-v2-FJ4FJNEA-DNst1BLg.js} +1 -1
  177. package/dist/public/assets/{swimlanes-UMQ2AFYF-DWhlPvKs.js → swimlanes-UMQ2AFYF-S_omrdvA.js} +1 -1
  178. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-By5lnz4u.js +8 -0
  179. package/dist/public/assets/{timeline-definition-SEUHKTQE-CMdocOui.js → timeline-definition-SEUHKTQE-_pMGrTE-.js} +1 -1
  180. package/dist/public/assets/treeView-D4JQ5SDB-Cyb9N8KY.js +1 -0
  181. package/dist/public/assets/treemap-SAJKECNS-BkMo57pG.js +1 -0
  182. package/dist/public/assets/{typescript-65jNyipU.js → typescript-0-z_OYCU.js} +1 -1
  183. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-BQTHUX1f.js → usecaseDiagram-AFA6YXN4-B2oJKi5Q.js} +1 -1
  184. package/dist/public/assets/{vennDiagram-NNMJR3RB-BULkVTfA.js → vennDiagram-NNMJR3RB-inPs2Kkr.js} +1 -1
  185. package/dist/public/assets/wardley-7MLQ67FV-CSt-uQ-Y.js +1 -0
  186. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-Cek6l8lz.js → wardleyDiagram-S7YFUSEH-DNhNHM7b.js} +1 -1
  187. package/dist/public/assets/{xml-DWBejfu-.js → xml-BXPxQzKF.js} +1 -1
  188. package/dist/public/assets/{xychartDiagram-GGNKY7IX-ujnZQTWA.js → xychartDiagram-GGNKY7IX-DJc93dNT.js} +1 -1
  189. package/dist/public/assets/{yaml-CwRCT7q1.js → yaml-CGmD9Rya.js} +1 -1
  190. package/dist/public/index.html +1 -1
  191. package/dist/serve/index.mjs +1222 -727
  192. package/package.json +31 -31
  193. package/dist/public/assets/cynefin-EF2NZ3EQ-Dg54eFzZ.js +0 -1
  194. package/dist/public/assets/flowDiagram-MALGAFMO-V5qkYWIO.js +0 -1
  195. package/dist/public/assets/gitGraph-VSP46ZUC-1q8ldRXU.js +0 -1
  196. package/dist/public/assets/info-OHQRW6UA-Crere6sx.js +0 -1
  197. package/dist/public/assets/module-DEqsdd00.js +0 -1
  198. package/dist/public/assets/module-TWc52XwT.js +0 -2244
  199. package/dist/public/assets/packet-JDAUHWVQ-qMf5LkHT.js +0 -1
  200. package/dist/public/assets/pie-XZMESJXO-BjqLn4qm.js +0 -1
  201. package/dist/public/assets/radar-ABXABTNO-DWO6t_4C.js +0 -1
  202. package/dist/public/assets/railroad-I3PHUGI6-D1XOJPWy.js +0 -1
  203. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CRn5uHsY.js +0 -8
  204. package/dist/public/assets/treeView-D4JQ5SDB-D09wHNzT.js +0 -1
  205. package/dist/public/assets/treemap-SAJKECNS-ChxAT7Fq.js +0 -1
  206. package/dist/public/assets/wardley-7MLQ67FV-DfSjKzbJ.js +0 -1
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentSession = void 0;
4
4
  const acp_protocol_1 = require("./acp-protocol");
5
5
  const agent_turn_1 = require("./agent-turn");
6
- /** How long a turn the agent started on its own lasts after its last update, when the agent does not say it ended. */
7
- const UNSOLICITED_QUIET_MS = 3000;
6
+ /** The phases in which the agent asks its model again, once the calls before are over. */
7
+ const STEP_PHASES = new Set(['preparing', 'model_requesting']);
8
8
  /** How long a prompt waits for the agent to end a turn that was cancelled. */
9
9
  const ABANDON_WAIT_MS = 5000;
10
10
  /** How long a prompt waits for the agent to answer the one before, which it may still finish after saying it is idle. */
@@ -19,11 +19,13 @@ class AgentSession {
19
19
  this.id = id;
20
20
  this.options = [];
21
21
  this.callbacks = { permission: async (request) => AgentSession.allow(request), activity: () => undefined };
22
- /** The notes of Ta's packages the agent was given (AgentPrompt.notes), each once. */
22
+ /** The notes of Ta's packages the agent was given (AgentPrompt.notes), each once, until it compacts its context. */
23
23
  this.told = new Set();
24
24
  this.queued = [];
25
25
  /** The agent said it works on the turn (a phase other than idle), so its next idle ends it. */
26
26
  this.working = false;
27
+ /** When the last message of the user sent to the agent was written: sent once, not again with a retry. */
28
+ this.delivered = 0;
27
29
  /** The ids of the requests the agent named in its updates (`_meta` `…requestId`), and those before the current prompt. */
28
30
  this.requests = new Set();
29
31
  this.earlier = new Set();
@@ -56,24 +58,18 @@ class AgentSession {
56
58
  (_b = (_a = this.callbacks).title) === null || _b === void 0 ? void 0 : _b.call(_a, this.title);
57
59
  }
58
60
  const phase = AgentSession.phase(meta);
59
- // A phase of a request before this prompt (the end of a compaction, say) is not this turn's.
60
- const stale = ids.some(id => this.earlier.has(id));
61
- if (phase && !stale && this.turn && !this.turn.unsolicited) {
62
- // Some agents (CodeBuddy Code) answer the prompt seconds after they are done, once they named
63
- // the session: their phase says when the turn ended.
64
- if (phase !== 'idle') {
65
- this.working = true;
66
- }
67
- else if (this.working) {
68
- this.working = false;
69
- this.turn.end('end_turn');
70
- }
61
+ // A phase of a request before this prompt (the end of a compaction, say) is not this turn's, nor one of a subagent or a teammate.
62
+ if (phase && !ids.some(id => this.earlier.has(id)) && AgentSession.own(meta)) {
63
+ this.phase(this.turn, phase, meta);
71
64
  }
72
65
  if (meta && Object.keys(meta).some(key => /unsolicitedTurn$/.test(key)) && !this.turn) {
73
66
  this.startUnsolicited(false);
74
67
  }
75
68
  return;
76
69
  }
70
+ case 'usage_update':
71
+ this.measure(update);
72
+ break;
77
73
  case 'session_end':
78
74
  if ((_c = this.turn) === null || _c === void 0 ? void 0 : _c.unsolicited) {
79
75
  this.turn.end('end_turn');
@@ -107,8 +103,24 @@ class AgentSession {
107
103
  const turn = new agent_turn_1.AgentTurn(false, (_c = /^\/[\w:.-]+/.exec(first)) === null || _c === void 0 ? void 0 : _c[0], (path, before) => { var _a, _b; return (_b = (_a = this.callbacks).write) === null || _b === void 0 ? void 0 : _b.call(_a, path, before); });
108
104
  this.turn = turn;
109
105
  this.working = false;
106
+ this.phaseOf = undefined;
107
+ this.failure = undefined;
108
+ this.stopWaiting();
110
109
  this.earlier = new Set(this.requests);
111
- const answer = this.host.request('session/prompt', { sessionId: this.id, prompt }).then(response => { var _a; return turn.end((_a = response === null || response === void 0 ? void 0 : response.stopReason) !== null && _a !== void 0 ? _a : 'end_turn'); }, (error) => turn.fail(error.message, error.code));
110
+ const answer = this.host.request('session/prompt', { sessionId: this.id, prompt }).then(response => {
111
+ var _a;
112
+ this.answered(turn);
113
+ const error = (response === null || response === void 0 ? void 0 : response.stopReason) === 'cancelled' ? undefined : AgentSession.errorOf(response === null || response === void 0 ? void 0 : response._meta);
114
+ if (error) {
115
+ turn.fail(error);
116
+ }
117
+ else {
118
+ turn.end((_a = response === null || response === void 0 ? void 0 : response.stopReason) !== null && _a !== void 0 ? _a : 'end_turn');
119
+ }
120
+ }, (error) => {
121
+ this.answered(turn);
122
+ turn.fail(error.message, error.code);
123
+ });
112
124
  this.answer = answer;
113
125
  return turn;
114
126
  }
@@ -150,6 +162,7 @@ class AgentSession {
150
162
  this.turn = undefined;
151
163
  clearTimeout(this.quietTimer);
152
164
  this.quietTimer = undefined;
165
+ this.stopWaiting();
153
166
  }
154
167
  }
155
168
  cancel() {
@@ -180,6 +193,60 @@ class AgentSession {
180
193
  }
181
194
  }
182
195
  }
196
+ /**
197
+ * What the agent's phase says of `turn`, or of the next turn it starts on its own. Some agents (CodeBuddy Code)
198
+ * answer the prompt seconds after they are done, once they named the session, and say nothing of when a turn of
199
+ * their own ends: going idle after a response it finished ends the turn. Idle in the middle of a request, or with
200
+ * calls still open, is a request that failed: the turn waits for the answer, which says why, or for the agent to
201
+ * go on (it recovers on its own, from a call of a tool it does not have, say), a while at most. Each new request
202
+ * of its model ends the calls before, which it may have dropped without a word.
203
+ */
204
+ phase(turn, phase, meta) {
205
+ var _a, _b;
206
+ if (phase !== 'idle') {
207
+ this.working = true;
208
+ this.stopWaiting();
209
+ this.retried(phase === 'retrying' ? AgentSession.retryOf(meta) : undefined);
210
+ if (STEP_PHASES.has(phase)) {
211
+ turn === null || turn === void 0 ? void 0 : turn.step();
212
+ }
213
+ }
214
+ else if (this.working) {
215
+ this.working = false;
216
+ this.retried(undefined);
217
+ this.stopWaiting();
218
+ if (this.phaseOf === 'model_done' && !(turn === null || turn === void 0 ? void 0 : turn.open())) {
219
+ turn === null || turn === void 0 ? void 0 : turn.end('end_turn');
220
+ }
221
+ else if (turn) {
222
+ this.idleTimer = setTimeout(() => {
223
+ this.idleTimer = undefined;
224
+ turn.end('end_turn');
225
+ }, AgentSession.unfinishedIdleMs);
226
+ (_b = (_a = this.idleTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
227
+ }
228
+ }
229
+ this.phaseOf = phase;
230
+ }
231
+ stopWaiting() {
232
+ clearTimeout(this.idleTimer);
233
+ this.idleTimer = undefined;
234
+ }
235
+ /** The agent answered the prompt of `turn`: what waited for the answer of the turn of now stops. */
236
+ answered(turn) {
237
+ if (this.turn === turn) {
238
+ this.stopWaiting();
239
+ this.retried(undefined);
240
+ }
241
+ }
242
+ retried(retry) {
243
+ var _a, _b, _c, _d;
244
+ if ((retry === null || retry === void 0 ? void 0 : retry.reason) === ((_a = this.retrying) === null || _a === void 0 ? void 0 : _a.reason) && (retry === null || retry === void 0 ? void 0 : retry.attempt) === ((_b = this.retrying) === null || _b === void 0 ? void 0 : _b.attempt) && !retry === !this.retrying) {
245
+ return;
246
+ }
247
+ this.retrying = retry;
248
+ (_d = (_c = this.callbacks).retry) === null || _d === void 0 ? void 0 : _d.call(_c, retry);
249
+ }
183
250
  startUnsolicited(quiet) {
184
251
  const turn = new agent_turn_1.AgentTurn(true, undefined, (path, before) => { var _a, _b; return (_b = (_a = this.callbacks).write) === null || _b === void 0 ? void 0 : _b.call(_a, path, before); });
185
252
  this.turn = turn;
@@ -188,20 +255,103 @@ class AgentSession {
188
255
  }
189
256
  this.callbacks.activity(this);
190
257
  }
191
- /** Ends a turn the agent started without saying when it ends, once it is quiet. */
258
+ /**
259
+ * Ends a turn the agent started without saying when it ends, once it is quiet: not while it says it works or a
260
+ * call of it runs, which would cut the turn in pieces and fail the calls.
261
+ */
192
262
  quiet(turn) {
193
263
  var _a, _b;
194
264
  clearTimeout(this.quietTimer);
195
- this.quietTimer = setTimeout(() => turn.end('end_turn'), UNSOLICITED_QUIET_MS);
265
+ this.quietTimer = setTimeout(() => {
266
+ if (turn.ended) {
267
+ return;
268
+ }
269
+ if (this.working || this.idleTimer || turn.open()) {
270
+ this.quiet(turn);
271
+ }
272
+ else {
273
+ turn.end('end_turn');
274
+ }
275
+ }, AgentSession.quietMs);
196
276
  (_b = (_a = this.quietTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
197
277
  }
198
278
  /** The ids of requests in `_meta`, under keys of the agent's own (`<agent>/requestId`, `<agent>/messageRequestId`). */
279
+ /**
280
+ * An agent compacts its context by itself, and what it was told goes with what it summed up: once its context
281
+ * shrank to less than half, the notes go again with the next prompt. A subagent's request (`…parentToolCallId`) is not its context.
282
+ */
283
+ measure(update) {
284
+ var _a;
285
+ const used = AgentSession.contextUsed(update);
286
+ if (used === undefined || Object.keys((_a = update._meta) !== null && _a !== void 0 ? _a : {}).some(key => /parentToolCallId$/.test(key))) {
287
+ return;
288
+ }
289
+ if (this.context !== undefined && used < this.context / 2) {
290
+ this.told.clear();
291
+ }
292
+ this.context = used;
293
+ }
294
+ /** How much context a usage update says the agent used: `used`, else the tokens of its request in `_meta`. */
295
+ static contextUsed(update) {
296
+ var _a;
297
+ if (typeof update.used === 'number' && update.used > 0) {
298
+ return update.used;
299
+ }
300
+ const tokens = (_a = update._meta) === null || _a === void 0 ? void 0 : _a.usage;
301
+ const count = (value) => (typeof value === 'number' && Number.isFinite(value) ? value : 0);
302
+ const total = count(tokens === null || tokens === void 0 ? void 0 : tokens.prompt_tokens) || count(tokens === null || tokens === void 0 ? void 0 : tokens.input_tokens) + count(tokens === null || tokens === void 0 ? void 0 : tokens.cache_read_input_tokens) + count(tokens === null || tokens === void 0 ? void 0 : tokens.cache_creation_input_tokens);
303
+ return total > 0 ? total : undefined;
304
+ }
305
+ /** Whether an update is of the session's own agent, not of a subagent (`…parentToolCallId`) or a teammate (`…memberEvent`). */
306
+ static own(meta) {
307
+ return !Object.keys(meta !== null && meta !== void 0 ? meta : {}).some(key => /(parentToolCallId|memberEvent)$/.test(key));
308
+ }
199
309
  static requestIds(meta) {
200
310
  return Object.entries(meta !== null && meta !== void 0 ? meta : {})
201
311
  .filter(([key, value]) => /requestId$/i.test(key) && typeof value === 'string' && value)
202
312
  .map(([, value]) => value);
203
313
  }
204
314
  /** What the agent says it is doing, if it says (CodeBuddy Code: `_meta['codebuddy.ai/agentPhase'].phase`). */
315
+ /** What an agent's `retrying` phase says of the retry (`…agentPhase` `retry`: `{ reason, attempt }`). */
316
+ static retryOf(meta) {
317
+ for (const [key, value] of Object.entries(meta !== null && meta !== void 0 ? meta : {})) {
318
+ const retry = value === null || value === void 0 ? void 0 : value.retry;
319
+ if (/agentPhase$/.test(key) && retry && typeof retry === 'object') {
320
+ return {
321
+ ...(typeof retry.reason === 'string' ? { reason: retry.reason } : {}),
322
+ ...(typeof retry.attempt === 'number' ? { attempt: retry.attempt } : {}),
323
+ };
324
+ }
325
+ }
326
+ return {};
327
+ }
328
+ /**
329
+ * The error an agent gives with its answer to a prompt, under a key of its own (`<agent>/errorMessage`):
330
+ * a text, or the JSON of an error, read for its message.
331
+ */
332
+ static errorOf(meta) {
333
+ for (const [key, value] of Object.entries(meta !== null && meta !== void 0 ? meta : {})) {
334
+ if (/errorMessage$/.test(key) && typeof value === 'string' && value.trim()) {
335
+ return AgentSession.messageOf(value.trim());
336
+ }
337
+ }
338
+ return undefined;
339
+ }
340
+ static messageOf(text) {
341
+ var _a;
342
+ var _b;
343
+ if (!text.startsWith('{')) {
344
+ return text;
345
+ }
346
+ try {
347
+ const value = JSON.parse(text);
348
+ const message = (_b = value.message) !== null && _b !== void 0 ? _b : (typeof value.error === 'string' ? value.error : (_a = value.error) === null || _a === void 0 ? void 0 : _a.message);
349
+ return typeof message === 'string' && message.trim() ? message.trim() : text;
350
+ }
351
+ catch (_c) {
352
+ return text;
353
+ }
354
+ }
205
355
  static phase(meta) {
206
356
  for (const [key, value] of Object.entries(meta !== null && meta !== void 0 ? meta : {})) {
207
357
  const phase = value === null || value === void 0 ? void 0 : value.phase;
@@ -219,4 +369,12 @@ class AgentSession {
219
369
  }
220
370
  }
221
371
  exports.AgentSession = AgentSession;
372
+ /**
373
+ * How long a turn waits for the answer to its prompt once the agent went idle without finishing a response
374
+ * (`model_done`) or with calls still open: a request that failed, which the agent reports in its answer, or
375
+ * goes on with after all (a call of a tool it does not have).
376
+ */
377
+ AgentSession.unfinishedIdleMs = 20000;
378
+ /** How long a turn the agent started on its own lasts after its last update, when the agent does not say it ended. */
379
+ AgentSession.quietMs = 3000;
222
380
  //# sourceMappingURL=agent-session.js.map
@@ -44,7 +44,11 @@ class AgentStreamer {
44
44
  async run(config, model, context, options, builder) {
45
45
  const signal = options === null || options === void 0 ? void 0 : options.signal;
46
46
  const { session, fresh, images, dirs } = await this.host.open(config, signal);
47
- const pending = agent_prompt_1.AgentPrompt.pending(context.messages);
47
+ let pending = agent_prompt_1.AgentPrompt.pending(context.messages);
48
+ if (session.failure !== undefined) {
49
+ // pi retries the turn that failed without its error: what the user said then went already.
50
+ pending = pending.filter(message => !(message.timestamp <= session.delivered));
51
+ }
48
52
  let turn = session.turn;
49
53
  if (turn) {
50
54
  // What the user said while the agent works goes once it ended.
@@ -54,10 +58,15 @@ class AgentStreamer {
54
58
  }
55
59
  else {
56
60
  let prompt = pending.length ? agent_prompt_1.AgentPrompt.blocks(pending, images) : session.takeQueued();
61
+ if (!(prompt === null || prompt === void 0 ? void 0 : prompt.length) && session.failure !== undefined) {
62
+ // pi's retry of a turn that failed: the agent keeps its history, and goes on from where it stopped.
63
+ prompt = [{ type: 'text', text: agent_prompt_1.AgentPrompt.resume(session.failure) }];
64
+ }
57
65
  if (!(prompt === null || prompt === void 0 ? void 0 : prompt.length)) {
58
66
  builder.done('stop');
59
67
  return;
60
68
  }
69
+ session.delivered = Math.max(session.delivered, ...pending.map(message => { var _a; return (_a = message.timestamp) !== null && _a !== void 0 ? _a : 0; }));
61
70
  const earlier = fresh ? agent_prompt_1.AgentPrompt.transcript(context.messages, pending.length) : undefined;
62
71
  if (earlier) {
63
72
  prompt = [{ type: 'text', text: earlier }, ...prompt];
@@ -99,6 +108,10 @@ class AgentStreamer {
99
108
  if (item.reason === 'cancelled' && (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
100
109
  builder.error('aborted', 'Aborted');
101
110
  }
111
+ else if (item.reason === 'refusal') {
112
+ session.failure = (0, texts_1.text)('refused', config.name);
113
+ builder.error('error', session.failure);
114
+ }
102
115
  else {
103
116
  if (turn.command && !turn.produced) {
104
117
  // A command of the agent that only acts in its own interface (a panel, a reset) says nothing.
@@ -110,7 +123,8 @@ class AgentStreamer {
110
123
  }
111
124
  case 'error':
112
125
  session.finished(turn);
113
- builder.error('error', AgentStreamer.describe(config, item));
126
+ session.failure = AgentStreamer.describe(config, item);
127
+ builder.error('error', session.failure);
114
128
  return;
115
129
  }
116
130
  }
@@ -78,7 +78,7 @@ var AgentTool;
78
78
  calls.delete(toolCallId);
79
79
  const details = { agent: call.agent, kind: run === null || run === void 0 ? void 0 : run.kind, title: run === null || run === void 0 ? void 0 : run.title, status: run === null || run === void 0 ? void 0 : run.status, locations: run === null || run === void 0 ? void 0 : run.locations };
80
80
  if (!(run === null || run === void 0 ? void 0 : run.done)) {
81
- return { content: [{ type: 'text', text: (0, texts_1.text)('unfinished', call.agent) }], details, isError: true };
81
+ return { content: [{ type: 'text', text: (0, texts_1.text)((run === null || run === void 0 ? void 0 : run.left) ? 'dropped' : 'unfinished', call.agent) }], details, isError: true };
82
82
  }
83
83
  return { content: [{ type: 'text', text: run.output || '(no output)' }], details, isError: run.status === 'failed' };
84
84
  },
@@ -29,6 +29,8 @@ export interface ToolRun {
29
29
  status: Acp.ToolStatus;
30
30
  output: string;
31
31
  done: boolean;
32
+ /** The agent went on to its next step without saying the call ended: it dropped it (a call of a tool it does not have, say). */
33
+ left: boolean;
32
34
  /** Its arguments are all there: the agent said so, or announced the call with them before running it. */
33
35
  complete: boolean;
34
36
  /** What its terminal printed, as some agents report it (Codex: `_meta.terminal_output_delta`). */
@@ -82,8 +84,12 @@ export declare class AgentTurn {
82
84
  * say something else, or nothing was said about the call for `quietMs`.
83
85
  */
84
86
  settle(id: string, quietMs: number, signal?: AbortSignal): Promise<void>;
85
- /** The call once it ended, or the turn did. */
87
+ /** The call once it ended, the agent went on without it, or the turn ended. */
86
88
  waitTool(id: string, signal?: AbortSignal): Promise<ToolRun | undefined>;
89
+ /** Calls the agent started that neither ended nor were dropped. */
90
+ open(): boolean;
91
+ /** The agent asks its model again: the calls before are over, said so or not. */
92
+ step(): void;
87
93
  protected pushText(type: 'text' | 'thinking', text: string): void;
88
94
  protected tool(update: Acp.ToolCallUpdate): void;
89
95
  /**
@@ -94,7 +94,7 @@ class AgentTurn {
94
94
  async settle(id, quietMs, signal) {
95
95
  for (;;) {
96
96
  const run = this.tools.get(id);
97
- if (!run || run.complete || this.ended || (signal === null || signal === void 0 ? void 0 : signal.aborted) || this.items.some(item => item.type !== 'tool')) {
97
+ if (!run || run.complete || run.left || this.ended || (signal === null || signal === void 0 ? void 0 : signal.aborted) || this.items.some(item => item.type !== 'tool')) {
98
98
  return;
99
99
  }
100
100
  const left = run.updatedAt + quietMs - Date.now();
@@ -104,16 +104,38 @@ class AgentTurn {
104
104
  await this.changed(signal, left);
105
105
  }
106
106
  }
107
- /** The call once it ended, or the turn did. */
107
+ /** The call once it ended, the agent went on without it, or the turn ended. */
108
108
  async waitTool(id, signal) {
109
109
  for (;;) {
110
110
  const run = this.tools.get(id);
111
- if (!run || run.done || this.ended || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
111
+ if (!run || run.done || run.left || this.ended || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
112
112
  return run;
113
113
  }
114
114
  await this.changed(signal);
115
115
  }
116
116
  }
117
+ /** Calls the agent started that neither ended nor were dropped. */
118
+ open() {
119
+ for (const run of this.tools.values()) {
120
+ if (!run.done && !run.left) {
121
+ return true;
122
+ }
123
+ }
124
+ return false;
125
+ }
126
+ /** The agent asks its model again: the calls before are over, said so or not. */
127
+ step() {
128
+ let changed = false;
129
+ for (const run of this.tools.values()) {
130
+ if (!run.done && !run.left) {
131
+ run.left = true;
132
+ changed = true;
133
+ }
134
+ }
135
+ if (changed) {
136
+ this.notify();
137
+ }
138
+ }
117
139
  pushText(type, text) {
118
140
  if (!text) {
119
141
  return;
@@ -142,6 +164,7 @@ class AgentTurn {
142
164
  status: 'pending',
143
165
  output: '',
144
166
  done: false,
167
+ left: false,
145
168
  complete: false,
146
169
  terminal: '',
147
170
  updatedAt: Date.now(),
@@ -145,6 +145,13 @@ function activate(pi, options = {}) {
145
145
  const option = request.options.find(candidate => candidate.name === chosen);
146
146
  return option ? { outcome: 'selected', optionId: option.optionId } : { outcome: 'cancelled' };
147
147
  },
148
+ // What the line of a turn at work says while the agent retries its model, as of pi's own retries.
149
+ retry: retry => {
150
+ const ui = (context === null || context === void 0 ? void 0 : context.hasUI) ? context.ui : undefined;
151
+ ui === null || ui === void 0 ? void 0 : ui.setWorkingMessage(retry
152
+ ? (0, texts_1.text)('retrying', config.name, retry.reason === 'network' ? 'network' : '', retry.attempt ? String(retry.attempt) : '')
153
+ : undefined);
154
+ },
148
155
  // The agent may still speak after the pi session closed, when pi's API is no longer usable.
149
156
  title: title => {
150
157
  if (context && !pi.getSessionName()) {
@@ -24,6 +24,18 @@ declare const TEXTS: {
24
24
  readonly en: (agent: string) => string;
25
25
  readonly zh: (agent: string) => string;
26
26
  };
27
+ readonly refused: {
28
+ readonly en: (agent: string) => string;
29
+ readonly zh: (agent: string) => string;
30
+ };
31
+ readonly retrying: {
32
+ readonly en: (agent: string, network: string, attempt: string) => string;
33
+ readonly zh: (agent: string, network: string, attempt: string) => string;
34
+ };
35
+ readonly dropped: {
36
+ readonly en: (agent: string) => string;
37
+ readonly zh: (agent: string) => string;
38
+ };
27
39
  readonly unfinished: {
28
40
  readonly en: (agent: string) => string;
29
41
  readonly zh: (agent: string) => string;
@@ -28,6 +28,18 @@ const TEXTS = {
28
28
  en: (agent) => `Starting ${agent}…`,
29
29
  zh: (agent) => `正在启动 ${agent}…`,
30
30
  },
31
+ refused: {
32
+ en: (agent) => `${agent} declined to go on with this turn.`,
33
+ zh: (agent) => `${agent} 拒绝继续这一轮。`,
34
+ },
35
+ retrying: {
36
+ en: (agent, network, attempt) => `${agent}: ${network ? 'the connection to its model dropped' : 'a request to its model failed'}, retrying${attempt ? ` (attempt ${attempt})` : ''}…`,
37
+ zh: (agent, network, attempt) => `${agent}:${network ? '连接模型的网络中断' : '模型请求失败'},正在重试${attempt ? `(第 ${attempt} 次)` : ''}…`,
38
+ },
39
+ dropped: {
40
+ en: (agent) => `${agent} went on without finishing this call.`,
41
+ zh: (agent) => `${agent} 没有完成这次调用就接着往下做了。`,
42
+ },
31
43
  unfinished: {
32
44
  en: (agent) => `${agent} ended its turn before this call finished.`,
33
45
  zh: (agent) => `${agent} 在这次调用完成前结束了这一轮。`,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-agents",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "A pi package for Ta: other coding agents (CodeBuddy Code, Claude Code, Codex and any agent that speaks ACP) as models to pick, each running a conversation on its own harness",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-bots",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "A pi package for Ta: bots of WeChat (ClawBot) and WeCom connected to the double, an agent or a conversation, messages and files both ways",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-changes",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "A pi package for Ta: the files each reply changed, with their diffs, and a button that takes the changes of a reply back",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -270,14 +270,22 @@ function useUnseen(storage, latest, busy, shown, answered, known) {
270
270
  return (id) => id !== looking && !busy.has(id) && views_1.SidebarUtil.unseen(latest.get(id), seen, id, answered[id]);
271
271
  }
272
272
  /**
273
- * What each agent said last, its sessions read again when the team says something or stops. The side bar
274
- * opens again with what it read before (context.sessionLines); undefined until it was read once, so that no
275
- * line of a channel shows for a moment in place of a later one of a session.
273
+ * What each agent said last, as the saved and open sessions have it. The page lists the saved ones of the last days
274
+ * as they change (`ui.useSavedSessions`): the older are read once, kept in context.sessionLines for the side bar
275
+ * opening again. An older app lists none: its sessions are read again when the team says something or stops.
276
+ * Undefined until read once, so that no line of a channel shows for a moment in place of a later one of a session.
276
277
  */
277
278
  function useSessionLines(context, changed) {
279
+ var _a, _b;
278
280
  const { pi } = context;
281
+ const listed = (_b = (_a = pi.ui).useSavedSessions) === null || _b === void 0 ? void 0 : _b.call(_a);
282
+ const follows = !!listed;
279
283
  const [lines, setLines] = react_1.React.useState(context.sessionLines);
284
+ const again = follows ? '' : changed;
280
285
  react_1.React.useEffect(() => {
286
+ if (follows && context.sessionLines) {
287
+ return;
288
+ }
281
289
  let live = true;
282
290
  const read = () => Promise.all([pi.server.listSessions().catch(() => []), pi.server.listSavedSessions().catch(() => [])]).then(([open, saved]) => {
283
291
  context.sessionLines = [...saved, ...open];
@@ -286,14 +294,19 @@ function useSessionLines(context, changed) {
286
294
  }
287
295
  });
288
296
  void read();
289
- const again = () => document.visibilityState === 'visible' && void read();
290
- document.addEventListener('visibilitychange', again);
297
+ if (follows) {
298
+ return () => {
299
+ live = false;
300
+ };
301
+ }
302
+ const onShow = () => document.visibilityState === 'visible' && void read();
303
+ document.addEventListener('visibilitychange', onShow);
291
304
  return () => {
292
305
  live = false;
293
- document.removeEventListener('visibilitychange', again);
306
+ document.removeEventListener('visibilitychange', onShow);
294
307
  };
295
- }, [context, pi, changed]);
296
- return lines;
308
+ }, [context, pi, follows, again]);
309
+ return react_1.React.useMemo(() => (lines && listed ? [...lines, ...listed] : lines), [lines, listed]);
297
310
  }
298
311
  /**
299
312
  * Which tasks are chosen while the list selects (undefined while it does not), as the page's lists of tasks
@@ -364,6 +377,7 @@ function HomeRow({ pi, item }) {
364
377
  var _a;
365
378
  const [opening, setOpening] = react_1.React.useState(false);
366
379
  const Glyph = item.icon;
380
+ const Own = item.face;
367
381
  const open = () => {
368
382
  setOpening(true);
369
383
  Promise.resolve()
@@ -371,7 +385,7 @@ function HomeRow({ pi, item }) {
371
385
  .catch(error => pi.ui.notify(views_1.ChannelViews.message(error), 'error'))
372
386
  .finally(() => setOpening(false));
373
387
  };
374
- return (react_1.React.createElement(Row, { pi: pi, avatar: react_1.React.createElement("span", { className: "tac-home-icon", style: { background: `var(--ta-tint-${item.tone})`, color: `var(--ta-tint-ink-${item.tone})` } }, opening ? react_1.React.createElement("span", { className: "ta-spinner" }) : react_1.React.createElement(Glyph, { size: 19, strokeWidth: 1.8 })), title: item.title, preview: (_a = item.detail) !== null && _a !== void 0 ? _a : '', fresh: item.unseen, dot: item.unseen ? 'attention' : undefined, time: item.at ? views_1.SidebarUtil.time(item.at, pi.ui.language) : '', selected: false, onSelect: open }));
388
+ return (react_1.React.createElement(Row, { pi: pi, avatar: Own && !opening ? (react_1.React.createElement(Own, { size: 40 })) : (react_1.React.createElement("span", { className: "tac-home-icon", style: { background: `var(--ta-tint-${item.tone})`, color: `var(--ta-tint-ink-${item.tone})` } }, opening ? react_1.React.createElement("span", { className: "ta-spinner" }) : react_1.React.createElement(Glyph, { size: 19, strokeWidth: 1.8 }))), title: item.title, preview: (_a = item.detail) !== null && _a !== void 0 ? _a : '', fresh: item.unseen, dot: item.unseen ? 'attention' : undefined, time: item.at ? views_1.SidebarUtil.time(item.at, pi.ui.language) : '', selected: false, onSelect: open }));
375
389
  }
376
390
  function AgentsSidebar({ context }) {
377
391
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -389,6 +403,9 @@ function AgentsSidebar({ context }) {
389
403
  const tasks = pi.ui.useTasks();
390
404
  // What extensions add under the double (a daily brief); none in an older app.
391
405
  const homeItems = (_k = (_b = (_a = pi.ui).useHomeItems) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _k !== void 0 ? _k : NO_HOME_ITEMS;
406
+ // Those of a section of their own (the rooms) after Ta's sections, the rest right under the double.
407
+ const homeShown = homeItems.filter(item => views_1.SidebarUtil.matches(query, item.title, item.detail));
408
+ const homeSections = views_1.SidebarUtil.homeSections(homeShown);
392
409
  const [folded, fold] = useFolded();
393
410
  const [byDirectory, setByDirectory] = useStored(pi.storage, BY_DIRECTORY_KEY, false);
394
411
  const language = pi.ui.language;
@@ -468,7 +485,7 @@ function AgentsSidebar({ context }) {
468
485
  };
469
486
  // Selecting, every task shows: Select all chooses what the user sees.
470
487
  const ended = allEnded || selection.selecting ? groups.ended : groups.ended.slice(0, ENDED_SHOWN);
471
- const nothing = query && shownTasks.length === 0 && channels.length === 0 && agents.length === 0;
488
+ const nothing = query && shownTasks.length === 0 && channels.length === 0 && agents.length === 0 && homeShown.length === 0;
472
489
  const running = tasks.filter(task => task.status === 'running').length;
473
490
  const waiting = tasks.filter(task => task.status === 'waiting').length;
474
491
  const fresh = tasks.filter(task => task.status !== 'waiting' && seen.needsLook(task)).length;
@@ -496,8 +513,8 @@ function AgentsSidebar({ context }) {
496
513
  react_1.React.createElement("span", { className: "tac-double-go", "aria-hidden": "true" },
497
514
  react_1.React.createElement(ChevronRight, { size: 18 }))),
498
515
  double.menu && (react_1.React.createElement(more_menu_1.MoreMenu, { pi: pi, label: double.title, items: () => { var _a; var _b; return ((_b = (_a = double.menu) === null || _a === void 0 ? void 0 : _a.call(double)) !== null && _b !== void 0 ? _b : []).map(section => section.map(({ icon: Icon, ...item }) => ({ ...item, icon: Icon && react_1.React.createElement(Icon, { size: 15 }) }))); } })))),
499
- homeItems
500
- .filter(item => views_1.SidebarUtil.matches(query, item.title, item.detail))
516
+ homeShown
517
+ .filter(item => !item.section)
501
518
  .map(item => (react_1.React.createElement(HomeRow, { key: item.key, pi: pi, item: item }))),
502
519
  draft && (react_1.React.createElement(Row, { pi: pi, avatar: react_1.React.createElement(faces_1.Face, { face: draft.face, size: 40 }), title: draft.name || w.newAgentName, preview: w.notStarted, time: "", selected: !!(agentPage === null || agentPage === void 0 ? void 0 : agentPage.shown), onSelect: () => pi.ui.showView(create_1.AGENT_PAGE) })),
503
520
  !state.loaded && !query && Skeleton && react_1.React.createElement(Skeleton, { rows: 4 }),
@@ -541,7 +558,8 @@ function AgentsSidebar({ context }) {
541
558
  ? `${name(last.author)}:${last.text.replace(/\s+/g, ' ')}`
542
559
  : ((_c = channel.topic) !== null && _c !== void 0 ? _c : w.noMessages);
543
560
  return (react_1.React.createElement(Row, { pi: pi, key: channel.id, avatar: react_1.React.createElement(faces_1.RoomFace, { members: members, faces: faces, size: 40, working: busy }), title: channel.name, badge: react_1.React.createElement(PinMark, { pi: pi, pinned: channel.pinned }), preview: preview, live: busy.length > 0, dot: busy.length > 0 ? 'running' : unread.includes(channel.id) ? 'attention' : undefined, time: views_1.SidebarUtil.time((_d = last === null || last === void 0 ? void 0 : last.at) !== null && _d !== void 0 ? _d : channel.createdAt, pi.ui.language), hint: channel.topic ? `#${channel.name} · ${channel.topic}` : `#${channel.name}`, selected: !!(channelPage === null || channelPage === void 0 ? void 0 : channelPage.shown) && channelId === channel.id, deleting: state.deleting.includes(channel.id), onSelect: () => context.showChannel(channel.id), more: react_1.React.createElement(channel_menu_1.ChannelMenu, { context: context, channel: channel, working: busy }), swipe: swipePinDelete(pi, !!channel.pinned, pinned => context.service.updateChannel(channel.id, { pinned }), () => (0, channel_menu_1.deleteChannel)(context, channel)) }));
544
- })))),
561
+ }))),
562
+ homeSections.map(section => (react_1.React.createElement(Section, { key: section.id, id: section.id, title: section.title, count: section.items.length, folded: folded, onFold: fold, alert: section.items.some(item => item.unseen) }, section.items.map(item => (react_1.React.createElement(HomeRow, { key: item.key, pi: pi, item: item }))))))),
545
563
  selection.selecting && SelectBar && (react_1.React.createElement(SelectBar, { count: selection.selected.length, total: selection.removable.length, onSelectAll: selection.selectAll, onDone: selection.done, actions: [{ key: 'delete', label: w.delete, danger: true, run: () => void selection.removeSelected() }] }))));
546
564
  }
547
565
  //# sourceMappingURL=sidebar.js.map