@herbertgao/pi-extensions 2026.10.18 → 2026.11.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 (264) hide show
  1. package/README.md +19 -5
  2. package/THIRD_PARTY_NOTICES.md +53 -3
  3. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  4. package/node_modules/@herbertgao/pi-subagents/README.md +142 -45
  5. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +17 -7
  6. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  7. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +111 -59
  8. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +135 -117
  9. package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +41 -14
  10. package/node_modules/@herbertgao/pi-subagents/src/index.ts +110 -19
  11. package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +8 -0
  12. package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +31 -0
  13. package/node_modules/@tintinweb/pi-tasks/CHANGELOG.md +270 -0
  14. package/node_modules/@tintinweb/pi-tasks/CONTRIBUTING.md +67 -0
  15. package/node_modules/@tintinweb/pi-tasks/CUSTOMIZING.md +289 -0
  16. package/node_modules/@tintinweb/pi-tasks/LICENSE +21 -0
  17. package/node_modules/@tintinweb/pi-tasks/README.md +417 -0
  18. package/node_modules/@tintinweb/pi-tasks/SECURITY.md +107 -0
  19. package/node_modules/@tintinweb/pi-tasks/dist/auto-clear.d.ts +64 -0
  20. package/node_modules/@tintinweb/pi-tasks/dist/auto-clear.js +129 -0
  21. package/node_modules/@tintinweb/pi-tasks/dist/index.d.ts +17 -0
  22. package/node_modules/@tintinweb/pi-tasks/dist/index.js +1338 -0
  23. package/node_modules/@tintinweb/pi-tasks/dist/process-tracker.d.ts +29 -0
  24. package/node_modules/@tintinweb/pi-tasks/dist/process-tracker.js +121 -0
  25. package/node_modules/@tintinweb/pi-tasks/dist/reminder-cadence.d.ts +39 -0
  26. package/node_modules/@tintinweb/pi-tasks/dist/reminder-cadence.js +61 -0
  27. package/node_modules/@tintinweb/pi-tasks/dist/task-glyphs.d.ts +48 -0
  28. package/node_modules/@tintinweb/pi-tasks/dist/task-glyphs.js +68 -0
  29. package/node_modules/@tintinweb/pi-tasks/dist/task-paths.d.ts +44 -0
  30. package/node_modules/@tintinweb/pi-tasks/dist/task-paths.js +60 -0
  31. package/node_modules/@tintinweb/pi-tasks/dist/task-sort.d.ts +23 -0
  32. package/node_modules/@tintinweb/pi-tasks/dist/task-sort.js +69 -0
  33. package/node_modules/@tintinweb/pi-tasks/dist/task-store.d.ts +61 -0
  34. package/node_modules/@tintinweb/pi-tasks/dist/task-store.js +397 -0
  35. package/node_modules/@tintinweb/pi-tasks/dist/tasks-config.d.ts +16 -0
  36. package/node_modules/@tintinweb/pi-tasks/dist/tasks-config.js +51 -0
  37. package/node_modules/@tintinweb/pi-tasks/dist/types.d.ts +36 -0
  38. package/node_modules/@tintinweb/pi-tasks/dist/types.js +4 -0
  39. package/node_modules/@tintinweb/pi-tasks/dist/ui/settings-menu.d.ts +15 -0
  40. package/node_modules/@tintinweb/pi-tasks/dist/ui/settings-menu.js +140 -0
  41. package/node_modules/@tintinweb/pi-tasks/dist/ui/task-widget.d.ts +69 -0
  42. package/node_modules/@tintinweb/pi-tasks/dist/ui/task-widget.js +278 -0
  43. package/node_modules/@tintinweb/pi-tasks/package.json +57 -0
  44. package/node_modules/@tintinweb/pi-tasks/src/auto-clear.ts +134 -0
  45. package/node_modules/@tintinweb/pi-tasks/src/index.ts +1417 -0
  46. package/node_modules/@tintinweb/pi-tasks/src/process-tracker.ts +140 -0
  47. package/node_modules/@tintinweb/pi-tasks/src/reminder-cadence.ts +90 -0
  48. package/node_modules/@tintinweb/pi-tasks/src/task-glyphs.ts +110 -0
  49. package/node_modules/@tintinweb/pi-tasks/src/task-paths.ts +65 -0
  50. package/node_modules/@tintinweb/pi-tasks/src/task-sort.ts +90 -0
  51. package/node_modules/@tintinweb/pi-tasks/src/task-store.ts +402 -0
  52. package/node_modules/@tintinweb/pi-tasks/src/tasks-config.ts +77 -0
  53. package/node_modules/@tintinweb/pi-tasks/src/types.ts +40 -0
  54. package/node_modules/@tintinweb/pi-tasks/src/ui/settings-menu.ts +174 -0
  55. package/node_modules/@tintinweb/pi-tasks/src/ui/task-widget.ts +325 -0
  56. package/node_modules/pi-commandcode-provider/CHANGELOG.md +330 -0
  57. package/node_modules/pi-commandcode-provider/CONTRIBUTING.md +192 -0
  58. package/node_modules/pi-commandcode-provider/LICENSE +21 -0
  59. package/node_modules/pi-commandcode-provider/README.md +243 -0
  60. package/node_modules/pi-commandcode-provider/RELEASE.md +194 -0
  61. package/node_modules/pi-commandcode-provider/index.ts +309 -0
  62. package/node_modules/pi-commandcode-provider/package.json +91 -0
  63. package/node_modules/pi-commandcode-provider/scripts/live-e2e-profile.mjs +87 -0
  64. package/node_modules/pi-commandcode-provider/scripts/pi-authenticated.mjs +50 -0
  65. package/node_modules/pi-commandcode-provider/scripts/pi-isolated.mjs +79 -0
  66. package/node_modules/pi-commandcode-provider/src/api-key.ts +69 -0
  67. package/node_modules/pi-commandcode-provider/src/auth-server.ts +229 -0
  68. package/node_modules/pi-commandcode-provider/src/commandcode-catalog-overrides.ts +28 -0
  69. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +260 -0
  70. package/node_modules/pi-commandcode-provider/src/converters.ts +477 -0
  71. package/node_modules/pi-commandcode-provider/src/core.ts +836 -0
  72. package/node_modules/pi-commandcode-provider/src/cost.ts +76 -0
  73. package/node_modules/pi-commandcode-provider/src/json-schema.ts +417 -0
  74. package/node_modules/pi-commandcode-provider/src/models.ts +515 -0
  75. package/node_modules/pi-commandcode-provider/src/oauth.ts +229 -0
  76. package/node_modules/pi-commandcode-provider/src/overflow.ts +120 -0
  77. package/node_modules/pi-commandcode-provider/src/pricing.ts +370 -0
  78. package/node_modules/pi-commandcode-provider/src/quota-command.ts +66 -0
  79. package/node_modules/pi-commandcode-provider/src/quota-format.ts +143 -0
  80. package/node_modules/pi-commandcode-provider/src/quota-types.ts +47 -0
  81. package/node_modules/pi-commandcode-provider/src/quota.ts +357 -0
  82. package/node_modules/pi-commandcode-provider/src/responses-stream.ts +249 -0
  83. package/node_modules/pi-commandcode-provider/src/runtime.ts +330 -0
  84. package/node_modules/pi-commandcode-provider/src/transcript.ts +56 -0
  85. package/node_modules/pi-commandcode-provider/src/transport.ts +147 -0
  86. package/node_modules/pi-commandcode-provider/src/types.ts +212 -0
  87. package/node_modules/pi-commandcode-provider/src/usage.ts +261 -0
  88. package/node_modules/pi-lens/CHANGELOG.md +149 -0
  89. package/node_modules/pi-lens/README.md +12 -2
  90. package/node_modules/pi-lens/config/markdownlint/run-no-fix.mjs +36 -0
  91. package/node_modules/pi-lens/dist/{chunk-WME2OQST.js → chunk-2453RRJ2.js} +11 -6
  92. package/node_modules/pi-lens/dist/{chunk-FZKFVUEC.js → chunk-2BKUFQKR.js} +276 -208
  93. package/node_modules/pi-lens/dist/chunk-2TS4GLOJ.js +31 -0
  94. package/node_modules/pi-lens/dist/{chunk-QHSNL7B2.js → chunk-2ZE3AUJQ.js} +12 -14
  95. package/node_modules/pi-lens/dist/{chunk-MPKRJBPK.js → chunk-35WKJWO5.js} +28 -30
  96. package/node_modules/pi-lens/dist/chunk-3JAHQBSY.js +27 -0
  97. package/node_modules/pi-lens/dist/{chunk-4LM3VAZH.js → chunk-3O5EII3W.js} +2 -2
  98. package/node_modules/pi-lens/dist/chunk-447YZL4S.js +25 -0
  99. package/node_modules/pi-lens/dist/{chunk-H7OR7DFZ.js → chunk-4B2YFN4U.js} +25 -21
  100. package/node_modules/pi-lens/dist/{chunk-OSTKYB55.js → chunk-4BKU7PV3.js} +1 -1
  101. package/node_modules/pi-lens/dist/{chunk-RRV3FNNM.js → chunk-4LL2VRNY.js} +27 -28
  102. package/node_modules/pi-lens/dist/{chunk-BZARLRJW.js → chunk-4NBWFYWW.js} +9 -9
  103. package/node_modules/pi-lens/dist/{chunk-KKCK636N.js → chunk-4QG55RRC.js} +12 -12
  104. package/node_modules/pi-lens/dist/{chunk-RQS4QQSD.js → chunk-4W52ZKZX.js} +2 -2
  105. package/node_modules/pi-lens/dist/{chunk-Z2XAOKHK.js → chunk-565VRUP4.js} +2 -2
  106. package/node_modules/pi-lens/dist/{chunk-HWDAVBFU.js → chunk-57X2CDRX.js} +23 -23
  107. package/node_modules/pi-lens/dist/{chunk-MB6PXBUA.js → chunk-5F3XF3SX.js} +7 -15
  108. package/node_modules/pi-lens/dist/{chunk-O4BJFESU.js → chunk-5RNB4HVK.js} +1 -1
  109. package/node_modules/pi-lens/dist/{chunk-ZMAUPOMG.js → chunk-5T5A6YAJ.js} +35 -34
  110. package/node_modules/pi-lens/dist/{chunk-4ZYJHQMB.js → chunk-6FIRFP6A.js} +12 -12
  111. package/node_modules/pi-lens/dist/{chunk-4YHYPW2G.js → chunk-6GMGEKQN.js} +9 -5
  112. package/node_modules/pi-lens/dist/{chunk-4LOE5R5P.js → chunk-6LJOJ6EO.js} +20 -15
  113. package/node_modules/pi-lens/dist/{chunk-3YY7IXIL.js → chunk-6YUNI7B5.js} +3 -3
  114. package/node_modules/pi-lens/dist/{chunk-PKES3ISE.js → chunk-7ANZ7XDD.js} +2 -2
  115. package/node_modules/pi-lens/dist/{chunk-FB5SCCPT.js → chunk-7CGIDRIK.js} +16 -15
  116. package/node_modules/pi-lens/dist/{chunk-L3CMBQMH.js → chunk-7MAD5ZAY.js} +16 -17
  117. package/node_modules/pi-lens/dist/{chunk-WDBICWH3.js → chunk-7TNILKGY.js} +1 -1
  118. package/node_modules/pi-lens/dist/{chunk-RORGS5II.js → chunk-A5GRLYPZ.js} +9 -9
  119. package/node_modules/pi-lens/dist/{chunk-MNJIXFX4.js → chunk-AGGUWKRK.js} +1 -1
  120. package/node_modules/pi-lens/dist/{chunk-ABPKUVA4.js → chunk-BBET6HD6.js} +1 -1
  121. package/node_modules/pi-lens/dist/{chunk-L5JYIU47.js → chunk-BHWW6FAX.js} +14 -13
  122. package/node_modules/pi-lens/dist/{chunk-URCQWAQ4.js → chunk-BOPDQ7AZ.js} +23 -21
  123. package/node_modules/pi-lens/dist/{chunk-KDX35VXP.js → chunk-BQG2QFVO.js} +158 -133
  124. package/node_modules/pi-lens/dist/{chunk-CB4WHS4H.js → chunk-BUZIQDFS.js} +3 -3
  125. package/node_modules/pi-lens/dist/{chunk-2PHMIAKO.js → chunk-CM73PPGD.js} +4 -4
  126. package/node_modules/pi-lens/dist/{chunk-DH5JPM3K.js → chunk-CUDD35TW.js} +10 -9
  127. package/node_modules/pi-lens/dist/{chunk-AWDSEDER.js → chunk-CZL44WFN.js} +2 -2
  128. package/node_modules/pi-lens/dist/{chunk-N5WSK2K7.js → chunk-DIWK3LBC.js} +12 -15
  129. package/node_modules/pi-lens/dist/{chunk-24BILSZW.js → chunk-DYRZGUMA.js} +2 -2
  130. package/node_modules/pi-lens/dist/{chunk-PR6PO3ES.js → chunk-FHEV6T4L.js} +22 -18
  131. package/node_modules/pi-lens/dist/{chunk-DQZFQSR5.js → chunk-FRLAUP2B.js} +4 -4
  132. package/node_modules/pi-lens/dist/{chunk-RZOXUSPC.js → chunk-G5GV2Q7K.js} +2 -2
  133. package/node_modules/pi-lens/dist/{chunk-EKWX4WD3.js → chunk-G6JKM4O7.js} +7 -7
  134. package/node_modules/pi-lens/dist/chunk-GGYOZWHW.js +27 -0
  135. package/node_modules/pi-lens/dist/{chunk-XT2HTCJ5.js → chunk-GIRBSBGL.js} +6 -5
  136. package/node_modules/pi-lens/dist/{chunk-PQJFG24Z.js → chunk-GMROJJRN.js} +1292 -946
  137. package/node_modules/pi-lens/dist/{chunk-U6VN4NVL.js → chunk-HHR7WGCI.js} +3 -3
  138. package/node_modules/pi-lens/dist/{chunk-TIQJPRDD.js → chunk-HKIL6DCL.js} +3 -2
  139. package/node_modules/pi-lens/dist/{chunk-SNDXCFRS.js → chunk-HUAM7QG3.js} +11 -11
  140. package/node_modules/pi-lens/dist/{chunk-QOE342SU.js → chunk-HXFUTMX2.js} +2 -2
  141. package/node_modules/pi-lens/dist/{chunk-U7BD2QL7.js → chunk-I22THIHI.js} +12 -12
  142. package/node_modules/pi-lens/dist/chunk-IE5D3RA5.js +58 -0
  143. package/node_modules/pi-lens/dist/{chunk-DPGEAHZT.js → chunk-IYVYZQRL.js} +10 -16
  144. package/node_modules/pi-lens/dist/{chunk-3F6BMY53.js → chunk-JBP7KESM.js} +1 -1
  145. package/node_modules/pi-lens/dist/{chunk-U5HPROLA.js → chunk-JE6HKLC7.js} +2 -2
  146. package/node_modules/pi-lens/dist/{chunk-ZE3KXHS7.js → chunk-JPRDTY5S.js} +85 -3
  147. package/node_modules/pi-lens/dist/{chunk-HO6LWE2E.js → chunk-JYLOYTZD.js} +17 -1
  148. package/node_modules/pi-lens/dist/{chunk-KW5JQPO5.js → chunk-JZRP4DGP.js} +2 -2
  149. package/node_modules/pi-lens/dist/{chunk-CPSR3AVL.js → chunk-KZ4ALBCH.js} +2 -2
  150. package/node_modules/pi-lens/dist/{chunk-6IR3ZYIB.js → chunk-L3CLUGDY.js} +3 -3
  151. package/node_modules/pi-lens/dist/{chunk-LV4UMYVH.js → chunk-L4NEVZ4T.js} +28 -27
  152. package/node_modules/pi-lens/dist/chunk-LPYTPNOJ.js +22 -0
  153. package/node_modules/pi-lens/dist/{chunk-WGRJOXED.js → chunk-LSFXZLPW.js} +1016 -636
  154. package/node_modules/pi-lens/dist/{chunk-LBLBAFG3.js → chunk-MC6VB2E5.js} +4 -4
  155. package/node_modules/pi-lens/dist/{chunk-U2SDMG7C.js → chunk-NM2NWH55.js} +5 -5
  156. package/node_modules/pi-lens/dist/{chunk-T7A2HK2B.js → chunk-NSPVR3FN.js} +19 -18
  157. package/node_modules/pi-lens/dist/{chunk-ZGSJDWQU.js → chunk-O2ARHQKF.js} +2 -2
  158. package/node_modules/pi-lens/dist/{chunk-OXOI55RU.js → chunk-O4N5BQ3T.js} +10 -10
  159. package/node_modules/pi-lens/dist/{chunk-3FRLWYBG.js → chunk-OC7VWJBZ.js} +39 -40
  160. package/node_modules/pi-lens/dist/chunk-OFNMHPBT.js +89 -0
  161. package/node_modules/pi-lens/dist/{chunk-HR3OJ3TH.js → chunk-OWTG6UMO.js} +21 -21
  162. package/node_modules/pi-lens/dist/{chunk-75GAYVNO.js → chunk-OY7WZI7Q.js} +6 -6
  163. package/node_modules/pi-lens/dist/{chunk-ZJTT47IG.js → chunk-OZWXLJMX.js} +2 -2
  164. package/node_modules/pi-lens/dist/{chunk-F6X3YJWD.js → chunk-PIQQM32Y.js} +2 -2
  165. package/node_modules/pi-lens/dist/chunk-PKLB2XJL.js +8 -0
  166. package/node_modules/pi-lens/dist/{chunk-EAOK7MIZ.js → chunk-PKSUMEPT.js} +17 -4
  167. package/node_modules/pi-lens/dist/{chunk-YISME6ON.js → chunk-PPKECBPP.js} +1 -1
  168. package/node_modules/pi-lens/dist/{chunk-4L36HG27.js → chunk-R2QQC33W.js} +14 -14
  169. package/node_modules/pi-lens/dist/{chunk-LUBPZN36.js → chunk-R4QWJQ2H.js} +11 -11
  170. package/node_modules/pi-lens/dist/{chunk-V63BC55Q.js → chunk-RGGH6M34.js} +1 -1
  171. package/node_modules/pi-lens/dist/{chunk-Y7F7IEE3.js → chunk-RZG472YW.js} +65 -7
  172. package/node_modules/pi-lens/dist/{chunk-PUZ3E2J4.js → chunk-SDFKOLSF.js} +6 -6
  173. package/node_modules/pi-lens/dist/{chunk-YHC2O2WO.js → chunk-SFLHSL5R.js} +9 -9
  174. package/node_modules/pi-lens/dist/{chunk-CCV2EU7T.js → chunk-SP4TFY5F.js} +14 -13
  175. package/node_modules/pi-lens/dist/{chunk-J6JP25XU.js → chunk-SQC7K3SP.js} +4 -3
  176. package/node_modules/pi-lens/dist/{chunk-3K2F6UDZ.js → chunk-T2S3FNNJ.js} +44 -42
  177. package/node_modules/pi-lens/dist/{chunk-2TF6RXWB.js → chunk-TV6RXRYH.js} +10 -10
  178. package/node_modules/pi-lens/dist/{chunk-GNSIWBAT.js → chunk-U3AS2FR6.js} +3 -3
  179. package/node_modules/pi-lens/dist/{chunk-F7K5IBZG.js → chunk-UHHLR2VY.js} +40 -40
  180. package/node_modules/pi-lens/dist/chunk-UYXV5NIS.js +20 -0
  181. package/node_modules/pi-lens/dist/{chunk-VSFLRN5Y.js → chunk-VLQ7UKZH.js} +1 -1
  182. package/node_modules/pi-lens/dist/{chunk-VUZWQ7UG.js → chunk-VN3L2JWZ.js} +46 -72
  183. package/node_modules/pi-lens/dist/{chunk-NA7SEXHE.js → chunk-VOP4PJKA.js} +7 -7
  184. package/node_modules/pi-lens/dist/{chunk-F5Z6URKM.js → chunk-VOXTCULR.js} +2 -2
  185. package/node_modules/pi-lens/dist/{chunk-LLS45EWB.js → chunk-VPLBLWFO.js} +6 -8
  186. package/node_modules/pi-lens/dist/chunk-W3BGKBBK.js +27 -0
  187. package/node_modules/pi-lens/dist/{chunk-ZKXQKGWZ.js → chunk-WC6WRNQT.js} +4 -3
  188. package/node_modules/pi-lens/dist/{chunk-YVHBNSME.js → chunk-WMDUT4KH.js} +1148 -1132
  189. package/node_modules/pi-lens/dist/{chunk-KXF5R4UN.js → chunk-WQV6BI4Q.js} +1 -1
  190. package/node_modules/pi-lens/dist/chunk-WXUDRAG6.js +24 -0
  191. package/node_modules/pi-lens/dist/{chunk-KPPJTH44.js → chunk-X35S7HSB.js} +28 -10
  192. package/node_modules/pi-lens/dist/{chunk-JMEKXFOL.js → chunk-X66YJ2SS.js} +40 -34
  193. package/node_modules/pi-lens/dist/{chunk-CE6VMBCB.js → chunk-XOMGO63G.js} +22 -21
  194. package/node_modules/pi-lens/dist/{chunk-LS3QJRUB.js → chunk-XWIME22V.js} +13 -13
  195. package/node_modules/pi-lens/dist/{chunk-R5MOQM2H.js → chunk-XYLC35E4.js} +119 -87
  196. package/node_modules/pi-lens/dist/{chunk-OE5ZBP7F.js → chunk-YHGYAEFH.js} +18 -18
  197. package/node_modules/pi-lens/dist/{chunk-7E2563GA.js → chunk-ZFORSIED.js} +13 -13
  198. package/node_modules/pi-lens/dist/{chunk-E7HJ56Y7.js → chunk-ZKLTNLAW.js} +64 -73
  199. package/node_modules/pi-lens/dist/chunk-ZONZ6YY3.js +74 -0
  200. package/node_modules/pi-lens/dist/chunk-ZSM35JF4.js +30 -0
  201. package/node_modules/pi-lens/dist/{chunk-RC2Z6K47.js → chunk-ZZDIOAAJ.js} +15 -6
  202. package/node_modules/pi-lens/dist/index.js +6993 -5396
  203. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +10 -10
  204. package/node_modules/pi-lens/dist/mcp/cli.js +44 -42
  205. package/node_modules/pi-lens/dist/mcp/server.js +1627 -504
  206. package/node_modules/pi-lens/dist/mcp/worker.js +62 -61
  207. package/node_modules/pi-lens/dist/probes/installer.js +20 -19
  208. package/node_modules/pi-lens/docs/adr/0003-git-guard-latch-writer.md +11 -6
  209. package/node_modules/pi-lens/docs/agent-tools.md +18 -8
  210. package/node_modules/pi-lens/docs/alignment-families.md +29 -0
  211. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +6 -4
  212. package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +126 -0
  213. package/node_modules/pi-lens/docs/configuration.md +99 -3
  214. package/node_modules/pi-lens/docs/defect-shapes.md +55 -12
  215. package/node_modules/pi-lens/docs/engineering-principles.md +27 -2
  216. package/node_modules/pi-lens/docs/features.md +2 -2
  217. package/node_modules/pi-lens/docs/invariants/git-guard-host.md +7 -3
  218. package/node_modules/pi-lens/docs/invariants/language-config.md +15 -4
  219. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +16 -2
  220. package/node_modules/pi-lens/docs/invariants/paths-os.md +4 -2
  221. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +119 -39
  222. package/node_modules/pi-lens/docs/merge-queue-rollout.md +1 -1
  223. package/node_modules/pi-lens/docs/pi-lens-fixer.md +24 -17
  224. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +20 -11
  225. package/node_modules/pi-lens/docs/pi-lens-monitor.md +9 -0
  226. package/node_modules/pi-lens/docs/pi-lens-orchestration.md +4 -1
  227. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +5 -5
  228. package/node_modules/pi-lens/docs/pi-lens-subagent.md +6 -3
  229. package/node_modules/pi-lens/docs/public-api-stability.md +18 -2
  230. package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +10 -0
  231. package/node_modules/pi-lens/docs/settings.md +10 -6
  232. package/node_modules/pi-lens/docs/word-index.md +17 -5
  233. package/node_modules/pi-lens/package.json +5 -3
  234. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-accumulating-spread-js-test.yml +37 -0
  235. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ts-redundant-filter-map-test.yml +12 -1
  236. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-js-test.yml +12 -0
  237. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-test.yml +25 -0
  238. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-accumulating-spread-js.yml +49 -1
  239. package/node_modules/pi-lens/rules/ast-grep-rules/rules/ts-redundant-filter-map.yml +9 -1
  240. package/node_modules/pi-lens/rules/ast-grep-rules/rules-disabled/filter-then-map-js.yml +17 -0
  241. package/node_modules/pi-lens/rules/ast-grep-rules/rules-disabled/filter-then-map.yml +36 -0
  242. package/node_modules/pi-lens/rules/ast-grep-rules/self-scan-baseline.json +1 -1
  243. package/node_modules/pi-provider-qoder/README.md +22 -0
  244. package/node_modules/pi-provider-qoder/dist/index.js +370 -11
  245. package/node_modules/pi-provider-qoder/package.json +5 -2
  246. package/package.json +11 -11
  247. package/node_modules/@tifan/pi-inline-skills/README.md +0 -41
  248. package/node_modules/@tifan/pi-inline-skills/package.json +0 -44
  249. package/node_modules/@tifan/pi-inline-skills/src/index.ts +0 -646
  250. package/node_modules/@tifan/pi-preferred-thinking/README.md +0 -54
  251. package/node_modules/@tifan/pi-preferred-thinking/package.json +0 -43
  252. package/node_modules/@tifan/pi-preferred-thinking/src/index.ts +0 -236
  253. package/node_modules/pi-lens/dist/chunk-46TNM7XZ.js +0 -88
  254. package/node_modules/pi-lens/dist/chunk-72OKUXSD.js +0 -31
  255. package/node_modules/pi-lens/dist/chunk-7GLOLOSH.js +0 -57
  256. package/node_modules/pi-lens/dist/chunk-AKUUMGD5.js +0 -26
  257. package/node_modules/pi-lens/dist/chunk-ASUXV767.js +0 -22
  258. package/node_modules/pi-lens/dist/chunk-CTADOKYM.js +0 -25
  259. package/node_modules/pi-lens/dist/chunk-JJ2RRESP.js +0 -58
  260. package/node_modules/pi-lens/dist/chunk-LSC3VADM.js +0 -23
  261. package/node_modules/pi-lens/dist/chunk-SHLDT3OI.js +0 -27
  262. package/node_modules/pi-lens/dist/chunk-UF7RTZSO.js +0 -27
  263. package/node_modules/pi-lens/dist/chunk-W4WP2ERB.js +0 -30
  264. package/node_modules/pi-lens/dist/chunk-YES5CACN.js +0 -73
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.22.0-local.2",
3
+ "version": "0.22.1-local.1",
4
4
  "description": "Claude Code-style autonomous subagents and workflow orchestration for Pi, with HerbertGao-maintained UI extensions.",
5
5
  "keywords": [
6
6
  "agent",
@@ -69,10 +69,10 @@
69
69
  },
70
70
  "x-upstream": {
71
71
  "package": "@tintinweb/pi-subagents",
72
- "version": "0.22.0",
73
- "reviewedVersion": "0.22.0",
72
+ "version": "0.22.1",
73
+ "reviewedVersion": "0.22.1",
74
74
  "repository": "https://github.com/tintinweb/pi-subagents",
75
- "commit": "85a704cb8f35c96c0cabfa665b572bab296942e5",
75
+ "commit": "fc089c4b7ab0f1185453b2e53027997c1f637e38",
76
76
  "trackVersion": true
77
77
  }
78
78
  }
@@ -49,6 +49,12 @@ import {
49
49
 
50
50
  export type OnAgentComplete = (record: AgentRecord) => void
51
51
  export type OnAgentStart = (record: AgentRecord) => void
52
+ /**
53
+ * Fired by `steer()` once a message is delivered or queued. Every steer path
54
+ * goes through it except the steer tools (`steer_subagent` in index.ts, and its
55
+ * nested twin in nested-tools.ts), which await the session directly.
56
+ */
57
+ export type OnAgentSteered = (record: AgentRecord, message: string) => void
52
58
  export type OnAgentCompact = (record: AgentRecord, info: CompactionInfo) => void
53
59
  /**
54
60
  * Fired once per assistant `message_end`, for EVERY agent this manager owns —
@@ -351,6 +357,14 @@ interface ResumeOptions {
351
357
  * record — the historical behavior.
352
358
  */
353
359
  isBackground?: boolean
360
+ /**
361
+ * Explicit turn limit for the resumed run: this, else the limit the agent
362
+ * was spawned with, else its type's own `max_turns`, else the default —
363
+ * counted afresh from the resume prompt (#368).
364
+ */
365
+ maxTurns?: number
366
+ /** Called at the end of each resumed turn with the count since the resume. */
367
+ onTurnEnd?: (turnCount: number) => void
354
368
  /** Called on tool start/end with activity info (for streaming progress to UI). */
355
369
  onToolActivity?: (activity: ToolActivity) => void
356
370
  /** Called once per assistant message_end with that message's usage delta. */
@@ -420,6 +434,7 @@ export class AgentManager {
420
434
  private onStart?: OnAgentStart
421
435
  private onCompact?: OnAgentCompact
422
436
  private onUsage?: OnAgentUsage
437
+ private onSteered?: OnAgentSteered
423
438
  private maxConcurrent: number
424
439
  private maxConcurrentForeground = DEFAULT_MAX_CONCURRENT_FOREGROUND
425
440
  /** Base repos worktrees were created from — so dispose() can prune them all,
@@ -476,11 +491,13 @@ export class AgentManager {
476
491
  onStart?: OnAgentStart,
477
492
  onCompact?: OnAgentCompact,
478
493
  onUsage?: OnAgentUsage,
494
+ onSteered?: OnAgentSteered,
479
495
  ) {
480
496
  this.onComplete = onComplete
481
497
  this.onStart = onStart
482
498
  this.onCompact = onCompact
483
499
  this.onUsage = onUsage
500
+ this.onSteered = onSteered
484
501
  this.maxConcurrent = maxConcurrent
485
502
  // Cleanup consumed completed agents after 10 minutes
486
503
  this.cleanupInterval = setInterval(() => this.cleanup(), 60_000)
@@ -972,28 +989,18 @@ export class AgentManager {
972
989
  structuredJson,
973
990
  structuredRetried,
974
991
  }) => {
975
- // Don't overwrite status if externally stopped via abort()
976
- if (record.status !== "stopped") {
977
- // Precedence: a hard abort keeps "aborted"; then a failed final turn
978
- // (provider error that pi resolved instead of rejecting, #144) is an
979
- // honest "error" — not a completion with an empty or stale result.
980
- if (aborted) {
981
- record.status = "aborted"
982
- } else if (failure) {
983
- record.status = "error"
984
- record.error = failure
985
- } else {
986
- record.status = steered ? "steered" : "completed"
987
- }
988
- }
989
- record.result = responseText
992
+ this.settleOutcome(record, {
993
+ text: responseText,
994
+ failure,
995
+ aborted,
996
+ steered,
997
+ })
990
998
  // Kept beside `result`, never inside it: `result` is prose meant for a
991
999
  // reader — it is previewed, transcribed, and appended to below — while
992
1000
  // this is a machine-readable payload one caller asked for by schema.
993
1001
  record.structuredJson = structuredJson
994
1002
  record.structuredRetried = structuredRetried
995
1003
  record.session = session
996
- record.completedAt ??= Date.now()
997
1004
 
998
1005
  detach()
999
1006
 
@@ -1383,36 +1390,46 @@ export class AgentManager {
1383
1390
  record.completedAt = undefined
1384
1391
  record.result = undefined
1385
1392
  record.error = undefined
1393
+ // Fresh controller, as on the detached path: `abort()` fires whatever
1394
+ // `record.abortController` holds, and the spawn's has long settled — so a
1395
+ // stop from `/agents` or the caller's Esc would mark the record stopped
1396
+ // while the resumed prompt ran on to completion.
1397
+ const abortController = new AbortController()
1398
+ record.abortController = abortController
1399
+ this.armParentAbort(record, signal)
1400
+ // `addEventListener` never fires on a signal that is already aborted, and
1401
+ // the runner skips the prompt only when ITS signal is — stop now, so that
1402
+ // holds for a resume issued on a call that was cancelled first.
1403
+ if (signal?.aborted) this.abort(id)
1386
1404
 
1387
1405
  try {
1388
- const { text, failure } = await resumeAgent(record.session, prompt, {
1389
- onToolActivity: (activity) => {
1390
- if (activity.type === "end") record.toolUses++
1391
- options?.onToolActivity?.(activity)
1392
- },
1393
- onAssistantUsage: (usage) => {
1394
- addUsage(record.lifetimeUsage, usage)
1395
- this.onUsage?.(record, usage)
1396
- options?.onAssistantUsage?.(usage)
1397
- },
1398
- onCompaction: (info) => {
1399
- record.compactionCount++
1400
- this.onCompact?.(record, info)
1401
- options?.onCompaction?.(info)
1402
- },
1403
- signal,
1404
- })
1405
- // Same contract as the spawn path (#144): a failed final turn is an
1406
- // error, not a completion — but the resumed text stays available.
1407
- record.status = failure ? "error" : "completed"
1408
- if (failure) record.error = failure
1409
- record.result = text
1410
- record.completedAt = Date.now()
1406
+ this.settleOutcome(
1407
+ record,
1408
+ await resumeAgent(record.session, prompt, {
1409
+ type: record.type,
1410
+ maxTurns: options?.maxTurns ?? record.invocation?.maxTurns,
1411
+ onTurnEnd: options?.onTurnEnd,
1412
+ onToolActivity: (activity) => {
1413
+ if (activity.type === "end") record.toolUses++
1414
+ options?.onToolActivity?.(activity)
1415
+ },
1416
+ onAssistantUsage: (usage) => {
1417
+ addUsage(record.lifetimeUsage, usage)
1418
+ this.onUsage?.(record, usage)
1419
+ options?.onAssistantUsage?.(usage)
1420
+ },
1421
+ onCompaction: (info) => {
1422
+ record.compactionCount++
1423
+ this.onCompact?.(record, info)
1424
+ options?.onCompaction?.(info)
1425
+ },
1426
+ signal: abortController.signal,
1427
+ }),
1428
+ )
1411
1429
  } catch (err) {
1412
- record.status = "error"
1413
- record.error = err instanceof Error ? err.message : String(err)
1414
- record.completedAt = Date.now()
1430
+ this.failResume(record, err)
1415
1431
  }
1432
+ this.detachParentAbort(record)
1416
1433
 
1417
1434
  // Same contract as the spawn settle paths: children spawned during the
1418
1435
  // resumed turn must not outlive it — nothing else can see or reach them.
@@ -1421,6 +1438,46 @@ export class AgentManager {
1421
1438
  return record
1422
1439
  }
1423
1440
 
1441
+ /**
1442
+ * Write a run's outcome onto its record — a spawn's or a resume's, with one
1443
+ * precedence: an external stop keeps "stopped"; a hard abort (turn limit +
1444
+ * grace) is "aborted"; a failed final turn (a provider error pi resolved
1445
+ * instead of rejecting, #144) is an "error", not a completion with an empty
1446
+ * or stale result; otherwise "steered" or "completed". The run's text stays
1447
+ * available in every case.
1448
+ */
1449
+ private settleOutcome(
1450
+ record: AgentRecord,
1451
+ {
1452
+ text,
1453
+ failure,
1454
+ aborted,
1455
+ steered,
1456
+ }: Awaited<ReturnType<typeof resumeAgent>>,
1457
+ ): void {
1458
+ if (record.status !== "stopped") {
1459
+ if (aborted) {
1460
+ record.status = "aborted"
1461
+ } else if (failure) {
1462
+ record.status = "error"
1463
+ record.error = failure
1464
+ } else {
1465
+ record.status = steered ? "steered" : "completed"
1466
+ }
1467
+ }
1468
+ record.result = text
1469
+ record.completedAt ??= Date.now()
1470
+ }
1471
+
1472
+ /** A resume whose runner rejected: an error, unless an external stop got there first. */
1473
+ private failResume(record: AgentRecord, err: unknown): void {
1474
+ if (record.status !== "stopped") {
1475
+ record.status = "error"
1476
+ record.error = err instanceof Error ? err.message : String(err)
1477
+ }
1478
+ record.completedAt ??= Date.now()
1479
+ }
1480
+
1424
1481
  /**
1425
1482
  * Start a background resume run: detached, settling and notifying like
1426
1483
  * startAgent's background path. Invoked immediately, or from drainQueue when
@@ -1490,6 +1547,9 @@ export class AgentManager {
1490
1547
  }
1491
1548
 
1492
1549
  const promise = resumeAgent(record.session, prompt, {
1550
+ type: record.type,
1551
+ maxTurns: options.maxTurns ?? record.invocation?.maxTurns,
1552
+ onTurnEnd: options.onTurnEnd,
1493
1553
  onToolActivity: (activity) => {
1494
1554
  if (activity.type === "end") record.toolUses++
1495
1555
  options.onToolActivity?.(activity)
@@ -1506,25 +1566,13 @@ export class AgentManager {
1506
1566
  },
1507
1567
  signal: abortController.signal,
1508
1568
  })
1509
- .then(({ text, failure }) => {
1510
- // Don't overwrite status if externally stopped via abort().
1511
- if (record.status !== "stopped") {
1512
- // Same contract as the spawn path (#144): a failed final turn is an
1513
- // error, not a completion — but the resumed text stays available.
1514
- record.status = failure ? "error" : "completed"
1515
- if (failure) record.error = failure
1516
- }
1517
- record.result = text
1518
- record.completedAt ??= Date.now()
1569
+ .then((outcome) => {
1570
+ this.settleOutcome(record, outcome)
1519
1571
  settle()
1520
- return text
1572
+ return outcome.text
1521
1573
  })
1522
1574
  .catch((err) => {
1523
- if (record.status !== "stopped") {
1524
- record.status = "error"
1525
- record.error = err instanceof Error ? err.message : String(err)
1526
- }
1527
- record.completedAt ??= Date.now()
1575
+ this.failResume(record, err)
1528
1576
  settle()
1529
1577
  return ""
1530
1578
  })
@@ -1538,7 +1586,10 @@ export class AgentManager {
1538
1586
  * current tool execution and appears as a user message. If the session isn't
1539
1587
  * ready yet, the message is queued on `pendingSteers` and flushed when the
1540
1588
  * session is created. Returns false if the agent can't accept steering
1541
- * (unknown id, or no longer running/queued).
1589
+ * (unknown id, or no longer running/queued). Fires `onSteered` on either
1590
+ * accepted path, so the UI viewers, an `@handle` and the RPC all report
1591
+ * the steer the same way without each emitting by hand. The steer tools
1592
+ * bypass this method because they await delivery.
1542
1593
  */
1543
1594
  steer(id: string, message: string): boolean {
1544
1595
  const record = this.agents.get(id)
@@ -1550,6 +1601,7 @@ export class AgentManager {
1550
1601
  if (!record.pendingSteers) record.pendingSteers = []
1551
1602
  record.pendingSteers.push(message)
1552
1603
  }
1604
+ this.onSteered?.(record, message)
1553
1605
  return true
1554
1606
  }
1555
1607
 
@@ -42,7 +42,11 @@ import {
42
42
  getMaxSubagentDepth,
43
43
  type NestedAgentManager,
44
44
  } from "./nested-tools.js"
45
- import { buildAgentPrompt, type PromptExtras } from "./prompts.js"
45
+ import {
46
+ buildAgentPrompt,
47
+ inheritableParentPrompt,
48
+ type PromptExtras,
49
+ } from "./prompts.js"
46
50
  import { preloadSkills } from "./skill-loader.js"
47
51
  import {
48
52
  createStructuredCapture,
@@ -722,6 +726,91 @@ function finalTurnError(
722
726
  return undefined
723
727
  }
724
728
 
729
+ /** The per-run callbacks a spawn and a resume share, plus the resolved turn limit. */
730
+ type RunObserverOptions = Pick<
731
+ RunOptions,
732
+ | "onTurnEnd"
733
+ | "onTextDelta"
734
+ | "onToolActivity"
735
+ | "onAssistantUsage"
736
+ | "onCompaction"
737
+ > & {
738
+ /** Already resolved: undefined = unlimited. */
739
+ maxTurns?: number
740
+ }
741
+
742
+ /**
743
+ * Observe one prompt of a session — a spawn's or a resume's — and enforce its
744
+ * turn limit: steer once at `maxTurns`, hard-abort after the grace turns.
745
+ * `steered` / `aborted` are live fields, read while the prompt is still in
746
+ * flight (the structured-output retry) and after it settles (the result).
747
+ * Shared by `runAgent` and `resumeAgent` so a resumed run is bounded exactly
748
+ * like the first one (#368).
749
+ */
750
+ function observeRun(session: AgentSession, options: RunObserverOptions) {
751
+ let turnCount = 0
752
+ let currentMessageText = ""
753
+ const run = {
754
+ steered: false,
755
+ aborted: false,
756
+ unsubscribe: () => {},
757
+ }
758
+ run.unsubscribe = session.subscribe((event: AgentSessionEvent) => {
759
+ if (event.type === "turn_end") {
760
+ turnCount++
761
+ options.onTurnEnd?.(turnCount)
762
+ if (options.maxTurns != null) {
763
+ if (!run.steered && turnCount >= options.maxTurns) {
764
+ run.steered = true
765
+ session.steer(
766
+ "You have reached your turn limit. Wrap up immediately — provide your final answer now.",
767
+ )
768
+ } else if (run.steered && turnCount >= options.maxTurns + graceTurns) {
769
+ run.aborted = true
770
+ session.abort()
771
+ }
772
+ }
773
+ }
774
+ if (event.type === "message_start") {
775
+ currentMessageText = ""
776
+ }
777
+ if (
778
+ event.type === "message_update" &&
779
+ event.assistantMessageEvent.type === "text_delta"
780
+ ) {
781
+ currentMessageText += event.assistantMessageEvent.delta
782
+ options.onTextDelta?.(
783
+ event.assistantMessageEvent.delta,
784
+ currentMessageText,
785
+ )
786
+ }
787
+ if (event.type === "tool_execution_start") {
788
+ options.onToolActivity?.({ type: "start", toolName: event.toolName })
789
+ }
790
+ if (event.type === "tool_execution_end") {
791
+ options.onToolActivity?.({ type: "end", toolName: event.toolName })
792
+ }
793
+ if (event.type === "message_end" && event.message.role === "assistant") {
794
+ const u = (event.message as any).usage
795
+ if (u)
796
+ options.onAssistantUsage?.({
797
+ input: u.input ?? 0,
798
+ output: u.output ?? 0,
799
+ cacheWrite: u.cacheWrite ?? 0,
800
+ cacheRead: u.cacheRead ?? 0,
801
+ cost: u.cost?.total ?? 0,
802
+ })
803
+ }
804
+ if (event.type === "compaction_end" && !event.aborted && event.result) {
805
+ options.onCompaction?.({
806
+ reason: event.reason,
807
+ tokensBefore: event.result.tokensBefore,
808
+ })
809
+ }
810
+ })
811
+ return run
812
+ }
813
+
725
814
  /**
726
815
  * Wire an AbortSignal to abort a session.
727
816
  * Returns a cleanup function to remove the listener.
@@ -764,8 +853,12 @@ export async function runAgent(
764
853
 
765
854
  const env = await detectEnv(options.pi, effectiveCwd)
766
855
 
767
- // Get parent system prompt for append-mode agents
768
- const parentSystemPrompt = ctx.getSystemPrompt()
856
+ // Get parent system prompt for append-mode agents, without the sections the
857
+ // child session renders itself (skills, cwd, extension sections).
858
+ const parentSystemPrompt = inheritableParentPrompt(
859
+ ctx.getSystemPrompt(),
860
+ ctx.cwd,
861
+ )
769
862
 
770
863
  // Build prompt extras (memory, skill preloading)
771
864
  const extras: PromptExtras = {}
@@ -1072,8 +1165,12 @@ export async function runAgent(
1072
1165
  options.model ??
1073
1166
  resolveDefaultModel(ctx.model, ctx.modelRegistry, agentConfig?.model)
1074
1167
 
1075
- // Resolve thinking level: explicit option > agent config > undefined (inherit)
1076
- const thinkingLevel = options.thinkingLevel ?? agentConfig?.thinking
1168
+ // Resolve thinking level: explicit option > agent config > parent session level.
1169
+ // Without the parent step, an unset level falls through to pi's
1170
+ // defaultThinkingLevel (e.g. "max") instead of matching the spawning session.
1171
+ // Same idiom as mention-clone.ts.
1172
+ const thinkingLevel =
1173
+ options.thinkingLevel ?? agentConfig?.thinking ?? ctx.thinkingLevel
1077
1174
 
1078
1175
  const disallowedSet = agentConfig?.disallowedTools
1079
1176
  ? new Set(agentConfig.disallowedTools)
@@ -1316,65 +1413,9 @@ export async function runAgent(
1316
1413
 
1317
1414
  options.onSessionCreated?.(session)
1318
1415
 
1319
- // Track turns for graceful max_turns enforcement
1320
- let turnCount = 0
1321
- const maxTurns = resolveEffectiveMaxTurns(type, options.maxTurns)
1322
- let softLimitReached = false
1323
- let aborted = false
1324
-
1325
- let currentMessageText = ""
1326
- const unsubTurns = session.subscribe((event: AgentSessionEvent) => {
1327
- if (event.type === "turn_end") {
1328
- turnCount++
1329
- options.onTurnEnd?.(turnCount)
1330
- if (maxTurns != null) {
1331
- if (!softLimitReached && turnCount >= maxTurns) {
1332
- softLimitReached = true
1333
- session.steer(
1334
- "You have reached your turn limit. Wrap up immediately — provide your final answer now.",
1335
- )
1336
- } else if (softLimitReached && turnCount >= maxTurns + graceTurns) {
1337
- aborted = true
1338
- session.abort()
1339
- }
1340
- }
1341
- }
1342
- if (event.type === "message_start") {
1343
- currentMessageText = ""
1344
- }
1345
- if (
1346
- event.type === "message_update" &&
1347
- event.assistantMessageEvent.type === "text_delta"
1348
- ) {
1349
- currentMessageText += event.assistantMessageEvent.delta
1350
- options.onTextDelta?.(
1351
- event.assistantMessageEvent.delta,
1352
- currentMessageText,
1353
- )
1354
- }
1355
- if (event.type === "tool_execution_start") {
1356
- options.onToolActivity?.({ type: "start", toolName: event.toolName })
1357
- }
1358
- if (event.type === "tool_execution_end") {
1359
- options.onToolActivity?.({ type: "end", toolName: event.toolName })
1360
- }
1361
- if (event.type === "message_end" && event.message.role === "assistant") {
1362
- const u = (event.message as any).usage
1363
- if (u)
1364
- options.onAssistantUsage?.({
1365
- input: u.input ?? 0,
1366
- output: u.output ?? 0,
1367
- cacheWrite: u.cacheWrite ?? 0,
1368
- cacheRead: u.cacheRead ?? 0,
1369
- cost: u.cost?.total ?? 0,
1370
- })
1371
- }
1372
- if (event.type === "compaction_end" && !event.aborted && event.result) {
1373
- options.onCompaction?.({
1374
- reason: event.reason,
1375
- tokensBefore: event.result.tokensBefore,
1376
- })
1377
- }
1416
+ const run = observeRun(session, {
1417
+ ...options,
1418
+ maxTurns: resolveEffectiveMaxTurns(type, options.maxTurns),
1378
1419
  })
1379
1420
 
1380
1421
  const collector = collectResponseText(session)
@@ -1407,14 +1448,14 @@ export async function runAgent(
1407
1448
  if (
1408
1449
  structuredCapture !== undefined &&
1409
1450
  structuredCapture.json === undefined &&
1410
- !aborted &&
1451
+ !run.aborted &&
1411
1452
  options.signal?.aborted !== true
1412
1453
  ) {
1413
1454
  structuredRetried = true
1414
1455
  await session.prompt(structuredRetryPrompt(structuredCapture))
1415
1456
  }
1416
1457
  } finally {
1417
- unsubTurns()
1458
+ run.unsubscribe()
1418
1459
  collector.unsubscribe()
1419
1460
  cleanupAbort()
1420
1461
  }
@@ -1433,8 +1474,8 @@ export async function runAgent(
1433
1474
  return {
1434
1475
  responseText,
1435
1476
  session,
1436
- aborted,
1437
- steered: softLimitReached,
1477
+ aborted: run.aborted,
1478
+ steered: run.steered,
1438
1479
  failure: finalTurnError(session, startLen) ?? structuredFailure,
1439
1480
  ...(structuredCapture?.json !== undefined
1440
1481
  ? { structuredJson: structuredCapture.json }
@@ -1444,77 +1485,54 @@ export async function runAgent(
1444
1485
  }
1445
1486
 
1446
1487
  /**
1447
- * Send a new prompt to an existing session (resume).
1488
+ * Send a new prompt to an existing session (resume). A fresh run of the same
1489
+ * agent: the turn limit is resolved as `runAgent` resolves it — an explicit
1490
+ * `maxTurns`, else the agent type's own `max_turns`, else the project default
1491
+ * — and counted from this prompt (#368).
1448
1492
  */
1449
1493
  export async function resumeAgent(
1450
1494
  session: AgentSession,
1451
1495
  prompt: string,
1452
- options: {
1453
- onToolActivity?: (activity: ToolActivity) => void
1454
- onAssistantUsage?: (usage: LifetimeUsage) => void
1455
- onCompaction?: (info: {
1456
- reason: "manual" | "threshold" | "overflow"
1457
- tokensBefore: number
1458
- }) => void
1459
- signal?: AbortSignal
1460
- } = {},
1461
- ): Promise<{ text: string; failure?: string }> {
1496
+ options: Pick<
1497
+ RunOptions,
1498
+ | "maxTurns"
1499
+ | "onTurnEnd"
1500
+ | "onToolActivity"
1501
+ | "onAssistantUsage"
1502
+ | "onCompaction"
1503
+ | "signal"
1504
+ > & {
1505
+ /** The agent's type, for its own `max_turns`. */
1506
+ type: SubagentType
1507
+ },
1508
+ ): Promise<
1509
+ { text: string; failure?: string } & Pick<RunResult, "aborted" | "steered">
1510
+ > {
1462
1511
  // Boundary for the history fallback: the session already holds prior turns,
1463
1512
  // so only assistant text produced by THIS resume prompt counts as its output
1464
1513
  // — a failed resume must not surface the previous turn's answer (#144).
1465
1514
  const startLen = session.messages.length
1466
1515
  const collector = collectResponseText(session)
1467
1516
  const cleanupAbort = forwardAbortSignal(session, options.signal)
1468
-
1469
- const unsubEvents =
1470
- options.onToolActivity || options.onAssistantUsage || options.onCompaction
1471
- ? session.subscribe((event: AgentSessionEvent) => {
1472
- if (event.type === "tool_execution_start")
1473
- options.onToolActivity?.({
1474
- type: "start",
1475
- toolName: event.toolName,
1476
- })
1477
- if (event.type === "tool_execution_end")
1478
- options.onToolActivity?.({ type: "end", toolName: event.toolName })
1479
- if (
1480
- event.type === "message_end" &&
1481
- event.message.role === "assistant"
1482
- ) {
1483
- const u = (event.message as any).usage
1484
- if (u)
1485
- options.onAssistantUsage?.({
1486
- input: u.input ?? 0,
1487
- output: u.output ?? 0,
1488
- cacheWrite: u.cacheWrite ?? 0,
1489
- cacheRead: u.cacheRead ?? 0,
1490
- cost: u.cost?.total ?? 0,
1491
- })
1492
- }
1493
- if (
1494
- event.type === "compaction_end" &&
1495
- !event.aborted &&
1496
- event.result
1497
- ) {
1498
- options.onCompaction?.({
1499
- reason: event.reason,
1500
- tokensBefore: event.result.tokensBefore,
1501
- })
1502
- }
1503
- })
1504
- : () => {}
1517
+ const run = observeRun(session, {
1518
+ ...options,
1519
+ maxTurns: resolveEffectiveMaxTurns(options.type, options.maxTurns),
1520
+ })
1505
1521
 
1506
1522
  try {
1507
1523
  // Already aborted: not prompted, as in `runAgent`.
1508
1524
  if (options.signal?.aborted !== true) await session.prompt(prompt)
1509
1525
  } finally {
1510
1526
  collector.unsubscribe()
1511
- unsubEvents()
1527
+ run.unsubscribe()
1512
1528
  cleanupAbort()
1513
1529
  }
1514
1530
 
1515
1531
  return {
1516
1532
  text: collector.getText().trim() || getLastAssistantText(session, startLen),
1517
1533
  failure: finalTurnError(session, startLen),
1534
+ aborted: run.aborted,
1535
+ steered: run.steered,
1518
1536
  }
1519
1537
  }
1520
1538