@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
@@ -1,5 +1,9 @@
1
1
  # @celljs/ta
2
2
 
3
+ ## 4.12.0
4
+
5
+ No changes in this release.
6
+
3
7
  ## 4.11.0
4
8
 
5
9
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "type": "module",
5
5
  "piConfig": {
6
6
  "name": "ta",
@@ -246,7 +246,7 @@ class AgentTurn {
246
246
  async settle(id, quietMs, signal) {
247
247
  for (;; ) {
248
248
  const run = this.tools.get(id);
249
- if (!run || run.complete || this.ended || signal?.aborted || this.items.some((item) => item.type !== "tool")) {
249
+ if (!run || run.complete || run.left || this.ended || signal?.aborted || this.items.some((item) => item.type !== "tool")) {
250
250
  return;
251
251
  }
252
252
  const left = run.updatedAt + quietMs - Date.now();
@@ -259,12 +259,32 @@ class AgentTurn {
259
259
  async waitTool(id, signal) {
260
260
  for (;; ) {
261
261
  const run = this.tools.get(id);
262
- if (!run || run.done || this.ended || signal?.aborted) {
262
+ if (!run || run.done || run.left || this.ended || signal?.aborted) {
263
263
  return run;
264
264
  }
265
265
  await this.changed(signal);
266
266
  }
267
267
  }
268
+ open() {
269
+ for (const run of this.tools.values()) {
270
+ if (!run.done && !run.left) {
271
+ return true;
272
+ }
273
+ }
274
+ return false;
275
+ }
276
+ step() {
277
+ let changed = false;
278
+ for (const run of this.tools.values()) {
279
+ if (!run.done && !run.left) {
280
+ run.left = true;
281
+ changed = true;
282
+ }
283
+ }
284
+ if (changed) {
285
+ this.notify();
286
+ }
287
+ }
268
288
  pushText(type, text) {
269
289
  if (!text) {
270
290
  return;
@@ -290,6 +310,7 @@ class AgentTurn {
290
310
  status: "pending",
291
311
  output: "",
292
312
  done: false,
313
+ left: false,
293
314
  complete: false,
294
315
  terminal: "",
295
316
  updatedAt: Date.now()
@@ -471,13 +492,15 @@ ${AgentTurn.diff(item.oldText ?? "", item.newText)}`;
471
492
  }
472
493
 
473
494
  // src/agent-session.ts
474
- var UNSOLICITED_QUIET_MS = 3000;
495
+ var STEP_PHASES = new Set(["preparing", "model_requesting"]);
475
496
  var ABANDON_WAIT_MS = 5000;
476
497
  var ANSWER_WAIT_MS = 15000;
477
498
 
478
499
  class AgentSession {
479
500
  host;
480
501
  id;
502
+ static unfinishedIdleMs = 20000;
503
+ static quietMs = 3000;
481
504
  turn;
482
505
  options = [];
483
506
  models;
@@ -486,11 +509,17 @@ class AgentSession {
486
509
  return;
487
510
  } };
488
511
  told = new Set;
512
+ context;
489
513
  queued = [];
490
514
  quietTimer;
491
515
  abandoned;
492
516
  answer;
493
517
  working = false;
518
+ phaseOf;
519
+ idleTimer;
520
+ retrying;
521
+ failure;
522
+ delivered = 0;
494
523
  requests = new Set;
495
524
  earlier = new Set;
496
525
  constructor(host, id, setup) {
@@ -523,20 +552,17 @@ class AgentSession {
523
552
  this.callbacks.title?.(this.title);
524
553
  }
525
554
  const phase = AgentSession.phase(meta);
526
- const stale = ids.some((id) => this.earlier.has(id));
527
- if (phase && !stale && this.turn && !this.turn.unsolicited) {
528
- if (phase !== "idle") {
529
- this.working = true;
530
- } else if (this.working) {
531
- this.working = false;
532
- this.turn.end("end_turn");
533
- }
555
+ if (phase && !ids.some((id) => this.earlier.has(id)) && AgentSession.own(meta)) {
556
+ this.phase(this.turn, phase, meta);
534
557
  }
535
558
  if (meta && Object.keys(meta).some((key) => /unsolicitedTurn$/.test(key)) && !this.turn) {
536
559
  this.startUnsolicited(false);
537
560
  }
538
561
  return;
539
562
  }
563
+ case "usage_update":
564
+ this.measure(update);
565
+ break;
540
566
  case "session_end":
541
567
  if (this.turn?.unsolicited) {
542
568
  this.turn.end("end_turn");
@@ -566,8 +592,22 @@ class AgentSession {
566
592
  const turn = new AgentTurn(false, /^\/[\w:.-]+/.exec(first)?.[0], (path, before) => this.callbacks.write?.(path, before));
567
593
  this.turn = turn;
568
594
  this.working = false;
595
+ this.phaseOf = undefined;
596
+ this.failure = undefined;
597
+ this.stopWaiting();
569
598
  this.earlier = new Set(this.requests);
570
- const answer = this.host.request("session/prompt", { sessionId: this.id, prompt }).then((response) => turn.end(response?.stopReason ?? "end_turn"), (error) => turn.fail(error.message, error.code));
599
+ const answer = this.host.request("session/prompt", { sessionId: this.id, prompt }).then((response) => {
600
+ this.answered(turn);
601
+ const error = response?.stopReason === "cancelled" ? undefined : AgentSession.errorOf(response?._meta);
602
+ if (error) {
603
+ turn.fail(error);
604
+ } else {
605
+ turn.end(response?.stopReason ?? "end_turn");
606
+ }
607
+ }, (error) => {
608
+ this.answered(turn);
609
+ turn.fail(error.message, error.code);
610
+ });
571
611
  this.answer = answer;
572
612
  return turn;
573
613
  }
@@ -601,6 +641,7 @@ class AgentSession {
601
641
  this.turn = undefined;
602
642
  clearTimeout(this.quietTimer);
603
643
  this.quietTimer = undefined;
644
+ this.stopWaiting();
604
645
  }
605
646
  }
606
647
  cancel() {
@@ -628,6 +669,47 @@ class AgentSession {
628
669
  }
629
670
  }
630
671
  }
672
+ phase(turn, phase, meta) {
673
+ if (phase !== "idle") {
674
+ this.working = true;
675
+ this.stopWaiting();
676
+ this.retried(phase === "retrying" ? AgentSession.retryOf(meta) : undefined);
677
+ if (STEP_PHASES.has(phase)) {
678
+ turn?.step();
679
+ }
680
+ } else if (this.working) {
681
+ this.working = false;
682
+ this.retried(undefined);
683
+ this.stopWaiting();
684
+ if (this.phaseOf === "model_done" && !turn?.open()) {
685
+ turn?.end("end_turn");
686
+ } else if (turn) {
687
+ this.idleTimer = setTimeout(() => {
688
+ this.idleTimer = undefined;
689
+ turn.end("end_turn");
690
+ }, AgentSession.unfinishedIdleMs);
691
+ this.idleTimer.unref?.();
692
+ }
693
+ }
694
+ this.phaseOf = phase;
695
+ }
696
+ stopWaiting() {
697
+ clearTimeout(this.idleTimer);
698
+ this.idleTimer = undefined;
699
+ }
700
+ answered(turn) {
701
+ if (this.turn === turn) {
702
+ this.stopWaiting();
703
+ this.retried(undefined);
704
+ }
705
+ }
706
+ retried(retry) {
707
+ if (retry?.reason === this.retrying?.reason && retry?.attempt === this.retrying?.attempt && !retry === !this.retrying) {
708
+ return;
709
+ }
710
+ this.retrying = retry;
711
+ this.callbacks.retry?.(retry);
712
+ }
631
713
  startUnsolicited(quiet) {
632
714
  const turn = new AgentTurn(true, undefined, (path, before) => this.callbacks.write?.(path, before));
633
715
  this.turn = turn;
@@ -638,12 +720,75 @@ class AgentSession {
638
720
  }
639
721
  quiet(turn) {
640
722
  clearTimeout(this.quietTimer);
641
- this.quietTimer = setTimeout(() => turn.end("end_turn"), UNSOLICITED_QUIET_MS);
723
+ this.quietTimer = setTimeout(() => {
724
+ if (turn.ended) {
725
+ return;
726
+ }
727
+ if (this.working || this.idleTimer || turn.open()) {
728
+ this.quiet(turn);
729
+ } else {
730
+ turn.end("end_turn");
731
+ }
732
+ }, AgentSession.quietMs);
642
733
  this.quietTimer.unref?.();
643
734
  }
735
+ measure(update) {
736
+ const used = AgentSession.contextUsed(update);
737
+ if (used === undefined || Object.keys(update._meta ?? {}).some((key) => /parentToolCallId$/.test(key))) {
738
+ return;
739
+ }
740
+ if (this.context !== undefined && used < this.context / 2) {
741
+ this.told.clear();
742
+ }
743
+ this.context = used;
744
+ }
745
+ static contextUsed(update) {
746
+ if (typeof update.used === "number" && update.used > 0) {
747
+ return update.used;
748
+ }
749
+ const tokens = update._meta?.usage;
750
+ const count = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
751
+ const total = count(tokens?.prompt_tokens) || count(tokens?.input_tokens) + count(tokens?.cache_read_input_tokens) + count(tokens?.cache_creation_input_tokens);
752
+ return total > 0 ? total : undefined;
753
+ }
754
+ static own(meta) {
755
+ return !Object.keys(meta ?? {}).some((key) => /(parentToolCallId|memberEvent)$/.test(key));
756
+ }
644
757
  static requestIds(meta) {
645
758
  return Object.entries(meta ?? {}).filter(([key, value]) => /requestId$/i.test(key) && typeof value === "string" && value).map(([, value]) => value);
646
759
  }
760
+ static retryOf(meta) {
761
+ for (const [key, value] of Object.entries(meta ?? {})) {
762
+ const retry = value?.retry;
763
+ if (/agentPhase$/.test(key) && retry && typeof retry === "object") {
764
+ return {
765
+ ...typeof retry.reason === "string" ? { reason: retry.reason } : {},
766
+ ...typeof retry.attempt === "number" ? { attempt: retry.attempt } : {}
767
+ };
768
+ }
769
+ }
770
+ return {};
771
+ }
772
+ static errorOf(meta) {
773
+ for (const [key, value] of Object.entries(meta ?? {})) {
774
+ if (/errorMessage$/.test(key) && typeof value === "string" && value.trim()) {
775
+ return AgentSession.messageOf(value.trim());
776
+ }
777
+ }
778
+ return;
779
+ }
780
+ static messageOf(text) {
781
+ if (!text.startsWith("{")) {
782
+ return text;
783
+ }
784
+ try {
785
+ const value = JSON.parse(text);
786
+ const message = value.message ?? (typeof value.error === "string" ? value.error : value.error?.message);
787
+ return typeof message === "string" && message.trim() ? message.trim() : text;
788
+ } catch {
789
+ return text;
790
+ }
791
+ }
647
792
  static phase(meta) {
648
793
  for (const [key, value] of Object.entries(meta ?? {})) {
649
794
  const phase = value?.phase;
@@ -828,6 +973,18 @@ var TEXTS = {
828
973
  en: (agent) => `Starting ${agent}…`,
829
974
  zh: (agent) => `正在启动 ${agent}…`
830
975
  },
976
+ refused: {
977
+ en: (agent) => `${agent} declined to go on with this turn.`,
978
+ zh: (agent) => `${agent} 拒绝继续这一轮。`
979
+ },
980
+ retrying: {
981
+ en: (agent, network, attempt) => `${agent}: ${network ? "the connection to its model dropped" : "a request to its model failed"}, retrying${attempt ? ` (attempt ${attempt})` : ""}…`,
982
+ zh: (agent, network, attempt) => `${agent}:${network ? "连接模型的网络中断" : "模型请求失败"},正在重试${attempt ? `(第 ${attempt} 次)` : ""}…`
983
+ },
984
+ dropped: {
985
+ en: (agent) => `${agent} went on without finishing this call.`,
986
+ zh: (agent) => `${agent} 没有完成这次调用就接着往下做了。`
987
+ },
831
988
  unfinished: {
832
989
  en: (agent) => `${agent} ended its turn before this call finished.`,
833
990
  zh: (agent) => `${agent} 在这次调用完成前结束了这一轮。`
@@ -1200,6 +1357,11 @@ var AgentPrompt;
1200
1357
  return result;
1201
1358
  }
1202
1359
  AgentPrompt.pending = pending;
1360
+ function resume(error) {
1361
+ return `Your last turn stopped with an error before it finished: ${error}
1362
+ Continue where you left off.`;
1363
+ }
1364
+ AgentPrompt.resume = resume;
1203
1365
  function blocks(messages, images) {
1204
1366
  const result = [];
1205
1367
  for (const message of messages) {
@@ -1250,7 +1412,7 @@ ${kept}
1250
1412
  const system = messages.filter((message) => message.role === "system").map((message) => [text2(message), ...sections(message)].join(`
1251
1413
  `)).join(`
1252
1414
  `);
1253
- return [...system.matchAll(/<(ta-[\w-]+)>[\s\S]*?<\/\1>/g)].map((match) => match[0]);
1415
+ return [...system.matchAll(/^<(ta-[\w-]+)>[\s\S]*?<\/\1>$/gm)].map((match) => match[0]);
1254
1416
  }
1255
1417
  AgentPrompt.notes = notes;
1256
1418
  function sections(message) {
@@ -1336,7 +1498,7 @@ var AgentTool;
1336
1498
  calls.delete(toolCallId);
1337
1499
  const details = { agent: call.agent, kind: run?.kind, title: run?.title, status: run?.status, locations: run?.locations };
1338
1500
  if (!run?.done) {
1339
- return { content: [{ type: "text", text: text("unfinished", call.agent) }], details, isError: true };
1501
+ return { content: [{ type: "text", text: text(run?.left ? "dropped" : "unfinished", call.agent) }], details, isError: true };
1340
1502
  }
1341
1503
  return { content: [{ type: "text", text: run.output || "(no output)" }], details, isError: run.status === "failed" };
1342
1504
  }
@@ -1501,7 +1663,10 @@ class AgentStreamer {
1501
1663
  async run(config, model, context, options, builder) {
1502
1664
  const signal = options?.signal;
1503
1665
  const { session, fresh, images, dirs } = await this.host.open(config, signal);
1504
- const pending = AgentPrompt.pending(context.messages);
1666
+ let pending = AgentPrompt.pending(context.messages);
1667
+ if (session.failure !== undefined) {
1668
+ pending = pending.filter((message) => !(message.timestamp <= session.delivered));
1669
+ }
1505
1670
  let turn = session.turn;
1506
1671
  if (turn) {
1507
1672
  if (pending.length) {
@@ -1509,10 +1674,14 @@ class AgentStreamer {
1509
1674
  }
1510
1675
  } else {
1511
1676
  let prompt = pending.length ? AgentPrompt.blocks(pending, images) : session.takeQueued();
1677
+ if (!prompt?.length && session.failure !== undefined) {
1678
+ prompt = [{ type: "text", text: AgentPrompt.resume(session.failure) }];
1679
+ }
1512
1680
  if (!prompt?.length) {
1513
1681
  builder.done("stop");
1514
1682
  return;
1515
1683
  }
1684
+ session.delivered = Math.max(session.delivered, ...pending.map((message) => message.timestamp ?? 0));
1516
1685
  const earlier = fresh ? AgentPrompt.transcript(context.messages, pending.length) : undefined;
1517
1686
  if (earlier) {
1518
1687
  prompt = [{ type: "text", text: earlier }, ...prompt];
@@ -1555,6 +1724,9 @@ class AgentStreamer {
1555
1724
  }
1556
1725
  if (item.reason === "cancelled" && signal?.aborted) {
1557
1726
  builder.error("aborted", "Aborted");
1727
+ } else if (item.reason === "refusal") {
1728
+ session.failure = text("refused", config.name);
1729
+ builder.error("error", session.failure);
1558
1730
  } else {
1559
1731
  if (turn.command && !turn.produced) {
1560
1732
  builder.append("text", text("commandDone", config.name, turn.command));
@@ -1565,7 +1737,8 @@ class AgentStreamer {
1565
1737
  }
1566
1738
  case "error":
1567
1739
  session.finished(turn);
1568
- builder.error("error", AgentStreamer.describe(config, item));
1740
+ session.failure = AgentStreamer.describe(config, item);
1741
+ builder.error("error", session.failure);
1569
1742
  return;
1570
1743
  }
1571
1744
  }
@@ -1730,6 +1903,10 @@ function activate(pi, options = {}) {
1730
1903
  const option = request.options.find((candidate) => candidate.name === chosen);
1731
1904
  return option ? { outcome: "selected", optionId: option.optionId } : { outcome: "cancelled" };
1732
1905
  },
1906
+ retry: (retry) => {
1907
+ const ui = context?.hasUI ? context.ui : undefined;
1908
+ ui?.setWorkingMessage(retry ? text("retrying", config.name, retry.reason === "network" ? "network" : "", retry.attempt ? String(retry.attempt) : "") : undefined);
1909
+ },
1733
1910
  title: (title) => {
1734
1911
  if (context && !pi.getSessionName()) {
1735
1912
  pi.setSessionName(title);
@@ -143,6 +143,11 @@ export declare namespace Acp {
143
143
  outcome: 'cancelled';
144
144
  };
145
145
  type StopReason = 'end_turn' | 'max_tokens' | 'max_turn_requests' | 'refusal' | 'cancelled';
146
+ /** The answer to `session/prompt`; an agent may say why it failed in `_meta` (`<agent>/errorMessage`). */
147
+ interface PromptResponse {
148
+ stopReason: StopReason;
149
+ _meta?: Record<string, unknown>;
150
+ }
146
151
  /** The text of a block; other blocks are named, not shown. */
147
152
  function text(block: ContentBlock | undefined): string;
148
153
  /** The values of a select option, its groups flattened. */
@@ -6,6 +6,8 @@ export declare const ACTIVITY_TEXT = "[The agent continued on its own]";
6
6
  export declare namespace AgentPrompt {
7
7
  /** The user messages at the end of the transcript, after the last answer or tool result. */
8
8
  function pending(messages: readonly Message[]): Message[];
9
+ /** What pi's retry of a turn that failed with `error` says to the agent, which keeps its own history. */
10
+ function resume(error: string): string;
9
11
  /** The messages as a prompt; images when the agent takes them. */
10
12
  function blocks(messages: readonly Message[], images: boolean): Acp.ContentBlock[];
11
13
  /**
@@ -16,7 +18,8 @@ export declare namespace AgentPrompt {
16
18
  /**
17
19
  * The notes Ta's packages add to pi's system prompt (its system messages), each in a tag of its own
18
20
  * (`<ta-glance>…</ta-glance>`): an agent keeps its own system prompt and gets none of pi's, but these say how Ta
19
- * shows a reply, what was asked before.
21
+ * shows a reply, what was asked before. A tag only counts at the start of a line and its end at the end of one: the
22
+ * instructions of a project (AGENTS.md) may name `<ta-glance>` in a sentence, which is not a note.
20
23
  */
21
24
  function notes(messages: readonly Message[]): string[];
22
25
  function text(message: Message): string;
@@ -25,6 +25,11 @@ var AgentPrompt;
25
25
  return result;
26
26
  }
27
27
  AgentPrompt.pending = pending;
28
+ /** What pi's retry of a turn that failed with `error` says to the agent, which keeps its own history. */
29
+ function resume(error) {
30
+ return `Your last turn stopped with an error before it finished: ${error}\nContinue where you left off.`;
31
+ }
32
+ AgentPrompt.resume = resume;
28
33
  /** The messages as a prompt; images when the agent takes them. */
29
34
  function blocks(messages, images) {
30
35
  const result = [];
@@ -75,14 +80,15 @@ var AgentPrompt;
75
80
  /**
76
81
  * The notes Ta's packages add to pi's system prompt (its system messages), each in a tag of its own
77
82
  * (`<ta-glance>…</ta-glance>`): an agent keeps its own system prompt and gets none of pi's, but these say how Ta
78
- * shows a reply, what was asked before.
83
+ * shows a reply, what was asked before. A tag only counts at the start of a line and its end at the end of one: the
84
+ * instructions of a project (AGENTS.md) may name `<ta-glance>` in a sentence, which is not a note.
79
85
  */
80
86
  function notes(messages) {
81
87
  const system = messages
82
88
  .filter(message => message.role === 'system')
83
89
  .map(message => [text(message), ...sections(message)].join('\n'))
84
90
  .join('\n');
85
- return [...system.matchAll(/<(ta-[\w-]+)>[\s\S]*?<\/\1>/g)].map(match => match[0]);
91
+ return [...system.matchAll(/^<(ta-[\w-]+)>[\s\S]*?<\/\1>$/gm)].map(match => match[0]);
86
92
  }
87
93
  AgentPrompt.notes = notes;
88
94
  /** The sections of a system message of pi, each `<name>…</name>`; a later one holds those that changed, `null` for one gone. */
@@ -9,11 +9,18 @@ export interface AgentSessionCallbacks {
9
9
  permission(request: Acp.PermissionRequest): Promise<Acp.PermissionOutcome>;
10
10
  /** The agent named the session. */
11
11
  title?(title: string): void;
12
+ /** The agent retries a request of its model that failed (`retrying`), or is past it (`undefined`). */
13
+ retry?(retry: AgentRetry | undefined): void;
12
14
  /** The agent started a turn on its own, for example to report a background task that finished. */
13
15
  activity(session: AgentSession): void;
14
16
  /** A call of the agent is about to change a file, or changed it (see WriteListener). */
15
17
  write?: WriteListener;
16
18
  }
19
+ /** What an agent says of a request of its model it retries: why (`network`), and which attempt, when it says. */
20
+ export interface AgentRetry {
21
+ reason?: string;
22
+ attempt?: number;
23
+ }
17
24
  /**
18
25
  * A session of an ACP agent: its settings, and its turn. A prompt starts a turn; what the user says
19
26
  * while it runs is sent once it ended, since ACP has no way to steer a running turn.
@@ -21,14 +28,24 @@ export interface AgentSessionCallbacks {
21
28
  export declare class AgentSession {
22
29
  protected readonly host: AgentSessionHost;
23
30
  readonly id: string;
31
+ /**
32
+ * How long a turn waits for the answer to its prompt once the agent went idle without finishing a response
33
+ * (`model_done`) or with calls still open: a request that failed, which the agent reports in its answer, or
34
+ * goes on with after all (a call of a tool it does not have).
35
+ */
36
+ static unfinishedIdleMs: number;
37
+ /** How long a turn the agent started on its own lasts after its last update, when the agent does not say it ended. */
38
+ static quietMs: number;
24
39
  /** The turn being streamed: until the provider took its end, even after the agent answered. */
25
40
  turn?: AgentTurn;
26
41
  options: Acp.ConfigOption[];
27
42
  models?: Acp.SessionModels;
28
43
  title?: string;
29
44
  callbacks: AgentSessionCallbacks;
30
- /** The notes of Ta's packages the agent was given (AgentPrompt.notes), each once. */
45
+ /** The notes of Ta's packages the agent was given (AgentPrompt.notes), each once, until it compacts its context. */
31
46
  readonly told: Set<string>;
47
+ /** How much of its context the agent last said it used, to see it compact. */
48
+ protected context?: number;
32
49
  protected readonly queued: Acp.ContentBlock[][];
33
50
  protected quietTimer?: ReturnType<typeof setTimeout>;
34
51
  protected abandoned?: AgentTurn;
@@ -36,6 +53,18 @@ export declare class AgentSession {
36
53
  protected answer?: Promise<unknown>;
37
54
  /** The agent said it works on the turn (a phase other than idle), so its next idle ends it. */
38
55
  protected working: boolean;
56
+ /** The phase the agent said last in this turn: idle right after `model_done` is the end of the turn. */
57
+ protected phaseOf?: string;
58
+ protected idleTimer?: ReturnType<typeof setTimeout>;
59
+ /** The agent retries a request: what it said of it. */
60
+ protected retrying?: AgentRetry;
61
+ /**
62
+ * The last turn failed (the error the agent gave): what pi sends next with nothing new from the user is a
63
+ * retry of it (pi's auto-retry), and goes to the agent as a word to go on.
64
+ */
65
+ failure?: string;
66
+ /** When the last message of the user sent to the agent was written: sent once, not again with a retry. */
67
+ delivered: number;
39
68
  /** The ids of the requests the agent named in its updates (`_meta` `…requestId`), and those before the current prompt. */
40
69
  protected readonly requests: Set<string>;
41
70
  protected earlier: Set<string>;
@@ -60,12 +89,51 @@ export declare class AgentSession {
60
89
  cancel(): void;
61
90
  /** Sets a select option to `value` unless it already is, or the agent does not offer it. */
62
91
  select(category: string, value: string | undefined, signal?: AbortSignal): Promise<void>;
92
+ /**
93
+ * What the agent's phase says of `turn`, or of the next turn it starts on its own. Some agents (CodeBuddy Code)
94
+ * answer the prompt seconds after they are done, once they named the session, and say nothing of when a turn of
95
+ * their own ends: going idle after a response it finished ends the turn. Idle in the middle of a request, or with
96
+ * calls still open, is a request that failed: the turn waits for the answer, which says why, or for the agent to
97
+ * 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
98
+ * of its model ends the calls before, which it may have dropped without a word.
99
+ */
100
+ protected phase(turn: AgentTurn | undefined, phase: string, meta: Record<string, unknown> | undefined): void;
101
+ protected stopWaiting(): void;
102
+ /** The agent answered the prompt of `turn`: what waited for the answer of the turn of now stops. */
103
+ protected answered(turn: AgentTurn): void;
104
+ protected retried(retry: AgentRetry | undefined): void;
63
105
  protected startUnsolicited(quiet: boolean): void;
64
- /** Ends a turn the agent started without saying when it ends, once it is quiet. */
106
+ /**
107
+ * Ends a turn the agent started without saying when it ends, once it is quiet: not while it says it works or a
108
+ * call of it runs, which would cut the turn in pieces and fail the calls.
109
+ */
65
110
  protected quiet(turn: AgentTurn): void;
66
111
  /** The ids of requests in `_meta`, under keys of the agent's own (`<agent>/requestId`, `<agent>/messageRequestId`). */
112
+ /**
113
+ * An agent compacts its context by itself, and what it was told goes with what it summed up: once its context
114
+ * shrank to less than half, the notes go again with the next prompt. A subagent's request (`…parentToolCallId`) is not its context.
115
+ */
116
+ protected measure(update: {
117
+ used?: number;
118
+ _meta?: Record<string, unknown>;
119
+ }): void;
120
+ /** How much context a usage update says the agent used: `used`, else the tokens of its request in `_meta`. */
121
+ static contextUsed(update: {
122
+ used?: number;
123
+ _meta?: Record<string, unknown>;
124
+ }): number | undefined;
125
+ /** Whether an update is of the session's own agent, not of a subagent (`…parentToolCallId`) or a teammate (`…memberEvent`). */
126
+ static own(meta: Record<string, unknown> | undefined): boolean;
67
127
  static requestIds(meta: Record<string, unknown> | undefined): string[];
68
128
  /** What the agent says it is doing, if it says (CodeBuddy Code: `_meta['codebuddy.ai/agentPhase'].phase`). */
129
+ /** What an agent's `retrying` phase says of the retry (`…agentPhase` `retry`: `{ reason, attempt }`). */
130
+ static retryOf(meta: Record<string, unknown> | undefined): AgentRetry;
131
+ /**
132
+ * The error an agent gives with its answer to a prompt, under a key of its own (`<agent>/errorMessage`):
133
+ * a text, or the JSON of an error, read for its message.
134
+ */
135
+ static errorOf(meta: Record<string, unknown> | undefined): string | undefined;
136
+ static messageOf(text: string): string;
69
137
  static phase(meta: Record<string, unknown> | undefined): string | undefined;
70
138
  /** Allows once: pi does not ask before tool calls, and neither does Ta for the agents it runs. */
71
139
  static allow(request: Acp.PermissionRequest): Acp.PermissionOutcome;