@pasko70/pibo 1.0.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 (351) hide show
  1. package/.codex/skills/pi-agent-harness/SKILL.md +319 -0
  2. package/.codex/skills/pi-agent-harness/agents/openai.yaml +4 -0
  3. package/README.md +318 -0
  4. package/context/codex-base-prompt.md +144 -0
  5. package/context/pibo-compaction-prompt.md +100 -0
  6. package/context/pibo-system-prompt.md +17 -0
  7. package/dist/apps/chat/agent-profiles.js +26 -0
  8. package/dist/apps/chat/agent-store.js +336 -0
  9. package/dist/apps/chat/event-log.js +307 -0
  10. package/dist/apps/chat/read-model.js +218 -0
  11. package/dist/apps/chat/rooms.js +321 -0
  12. package/dist/apps/chat/session-metadata.js +14 -0
  13. package/dist/apps/chat/stream.js +122 -0
  14. package/dist/apps/chat/trace.js +1182 -0
  15. package/dist/apps/chat/web-app.js +2569 -0
  16. package/dist/apps/chat-ui/assets/apl-BxEMbctQ.js +1 -0
  17. package/dist/apps/chat-ui/assets/asciiarmor-eFjeGRuZ.js +1 -0
  18. package/dist/apps/chat-ui/assets/asn1-Cfx-0pt9.js +1 -0
  19. package/dist/apps/chat-ui/assets/asterisk-B5BHTsBr.js +1 -0
  20. package/dist/apps/chat-ui/assets/brainfuck-CAA2xofr.js +1 -0
  21. package/dist/apps/chat-ui/assets/clike-BoDCOLzN.js +1 -0
  22. package/dist/apps/chat-ui/assets/clojure-kVFSWX0o.js +1 -0
  23. package/dist/apps/chat-ui/assets/cmake-BUPAhezI.js +1 -0
  24. package/dist/apps/chat-ui/assets/cobol-BfgHZgup.js +1 -0
  25. package/dist/apps/chat-ui/assets/coffeescript-G1Pe_1AZ.js +1 -0
  26. package/dist/apps/chat-ui/assets/commonlisp-B3N0CjHn.js +1 -0
  27. package/dist/apps/chat-ui/assets/crystal-C15ndaGM.js +1 -0
  28. package/dist/apps/chat-ui/assets/css-BqOeyZOV.js +1 -0
  29. package/dist/apps/chat-ui/assets/cypher-KjIKv-wW.js +1 -0
  30. package/dist/apps/chat-ui/assets/d-BlT5AEC-.js +1 -0
  31. package/dist/apps/chat-ui/assets/diff-oF98tbqj.js +1 -0
  32. package/dist/apps/chat-ui/assets/dist--55mTWk3.js +1 -0
  33. package/dist/apps/chat-ui/assets/dist-B5rcjVCj.js +1 -0
  34. package/dist/apps/chat-ui/assets/dist-BPv5MdlL.js +1 -0
  35. package/dist/apps/chat-ui/assets/dist-BZ39rB1W.js +1 -0
  36. package/dist/apps/chat-ui/assets/dist-BsedZGJo.js +1 -0
  37. package/dist/apps/chat-ui/assets/dist-BvO6SpaM.js +9 -0
  38. package/dist/apps/chat-ui/assets/dist-C5YJOwhH.js +1 -0
  39. package/dist/apps/chat-ui/assets/dist-C5oXtFSP.js +1 -0
  40. package/dist/apps/chat-ui/assets/dist-CG_gRSwv.js +23 -0
  41. package/dist/apps/chat-ui/assets/dist-CKM5j-iy.js +1 -0
  42. package/dist/apps/chat-ui/assets/dist-CUp9us2q.js +1 -0
  43. package/dist/apps/chat-ui/assets/dist-CZ9T4Cly.js +1 -0
  44. package/dist/apps/chat-ui/assets/dist-D4HhiFWB.js +6 -0
  45. package/dist/apps/chat-ui/assets/dist-DHE-yBLH.js +1 -0
  46. package/dist/apps/chat-ui/assets/dist-DSKQpPaz.js +1 -0
  47. package/dist/apps/chat-ui/assets/dist-L1B-KWZO.js +1 -0
  48. package/dist/apps/chat-ui/assets/dist-SVPsM5Oi.js +13 -0
  49. package/dist/apps/chat-ui/assets/dist-Zqt9kNG9.js +1 -0
  50. package/dist/apps/chat-ui/assets/dist-_DPv0-QF.js +1 -0
  51. package/dist/apps/chat-ui/assets/dist-_oM7g0eh.js +11 -0
  52. package/dist/apps/chat-ui/assets/dist-laadbMWg.js +1 -0
  53. package/dist/apps/chat-ui/assets/dist-nFui3f-r.js +2 -0
  54. package/dist/apps/chat-ui/assets/dist-tGfufz3b.js +1 -0
  55. package/dist/apps/chat-ui/assets/dockerfile-CUaqzcqp.js +1 -0
  56. package/dist/apps/chat-ui/assets/dtd-VCA9yr61.js +1 -0
  57. package/dist/apps/chat-ui/assets/dylan-O-V5Dw5W.js +1 -0
  58. package/dist/apps/chat-ui/assets/ebnf-SPmdBkvT.js +1 -0
  59. package/dist/apps/chat-ui/assets/ecl-ChfCttfI.js +1 -0
  60. package/dist/apps/chat-ui/assets/eiffel-cB9EbjeN.js +1 -0
  61. package/dist/apps/chat-ui/assets/elm-BTiVflBU.js +1 -0
  62. package/dist/apps/chat-ui/assets/erlang-egf0TXFm.js +1 -0
  63. package/dist/apps/chat-ui/assets/factor-C2tAxNob.js +1 -0
  64. package/dist/apps/chat-ui/assets/fcl-BiCjh1tj.js +1 -0
  65. package/dist/apps/chat-ui/assets/forth-C4kDGW6u.js +1 -0
  66. package/dist/apps/chat-ui/assets/fortran-DzkLaPnd.js +1 -0
  67. package/dist/apps/chat-ui/assets/gas-DMOxskQF.js +1 -0
  68. package/dist/apps/chat-ui/assets/gherkin-BPxBpp-k.js +1 -0
  69. package/dist/apps/chat-ui/assets/groovy-CkEnc0ZY.js +1 -0
  70. package/dist/apps/chat-ui/assets/haskell-Dadpo9-w.js +1 -0
  71. package/dist/apps/chat-ui/assets/haxe-CDNZL9MW.js +1 -0
  72. package/dist/apps/chat-ui/assets/http-jy9Zxxt3.js +1 -0
  73. package/dist/apps/chat-ui/assets/idl-CGSB6iiy.js +1 -0
  74. package/dist/apps/chat-ui/assets/index-BdcqTugD.js +151 -0
  75. package/dist/apps/chat-ui/assets/index-Dk-opWl3.css +1 -0
  76. package/dist/apps/chat-ui/assets/javascript-DSlzRUd8.js +1 -0
  77. package/dist/apps/chat-ui/assets/julia-DTiF9v6R.js +1 -0
  78. package/dist/apps/chat-ui/assets/livescript-Ci8Xxna6.js +1 -0
  79. package/dist/apps/chat-ui/assets/lua-eVxIrt9t.js +1 -0
  80. package/dist/apps/chat-ui/assets/mathematica-Da3grj36.js +1 -0
  81. package/dist/apps/chat-ui/assets/mbox-BWBMSafM.js +1 -0
  82. package/dist/apps/chat-ui/assets/mirc-CtHu9S1B.js +1 -0
  83. package/dist/apps/chat-ui/assets/mllike-wTFlPWXS.js +1 -0
  84. package/dist/apps/chat-ui/assets/modelica-cKbQ0UXu.js +1 -0
  85. package/dist/apps/chat-ui/assets/mscgen-C5pXQCMK.js +1 -0
  86. package/dist/apps/chat-ui/assets/mumps-CKBHkOQq.js +1 -0
  87. package/dist/apps/chat-ui/assets/nginx-B00AiQel.js +1 -0
  88. package/dist/apps/chat-ui/assets/nsis-SMDwKltR.js +1 -0
  89. package/dist/apps/chat-ui/assets/ntriples-B_36EBV0.js +1 -0
  90. package/dist/apps/chat-ui/assets/octave-BXPjzAif.js +1 -0
  91. package/dist/apps/chat-ui/assets/oz-Dedpat1M.js +1 -0
  92. package/dist/apps/chat-ui/assets/pascal-CMcUg72K.js +1 -0
  93. package/dist/apps/chat-ui/assets/perl-DoVTbnzt.js +1 -0
  94. package/dist/apps/chat-ui/assets/pig-CULXT1YV.js +1 -0
  95. package/dist/apps/chat-ui/assets/powershell-Cv5Uhf6b.js +1 -0
  96. package/dist/apps/chat-ui/assets/properties-CQ1C2P-M.js +1 -0
  97. package/dist/apps/chat-ui/assets/protobuf-SRlvzrl6.js +1 -0
  98. package/dist/apps/chat-ui/assets/pug-Bo3wfL-f.js +1 -0
  99. package/dist/apps/chat-ui/assets/puppet-ClSqCGj6.js +1 -0
  100. package/dist/apps/chat-ui/assets/python-C2_X1GpX.js +1 -0
  101. package/dist/apps/chat-ui/assets/q-B_6Gdyzl.js +1 -0
  102. package/dist/apps/chat-ui/assets/r-BD07NGED.js +1 -0
  103. package/dist/apps/chat-ui/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
  104. package/dist/apps/chat-ui/assets/rpm-CRu5Z2Jl.js +1 -0
  105. package/dist/apps/chat-ui/assets/ruby-dZPnOz8h.js +1 -0
  106. package/dist/apps/chat-ui/assets/sas-S2t8_sDI.js +1 -0
  107. package/dist/apps/chat-ui/assets/scheme-WcyFWLW2.js +1 -0
  108. package/dist/apps/chat-ui/assets/shell-DUelnYSh.js +1 -0
  109. package/dist/apps/chat-ui/assets/sieve-jDjlVhNh.js +1 -0
  110. package/dist/apps/chat-ui/assets/simple-mode-CL04yRVp.js +1 -0
  111. package/dist/apps/chat-ui/assets/smalltalk-ddWDYy10.js +1 -0
  112. package/dist/apps/chat-ui/assets/solr-C7rQhLuW.js +1 -0
  113. package/dist/apps/chat-ui/assets/sparql--fPCCgVd.js +1 -0
  114. package/dist/apps/chat-ui/assets/spreadsheet-DjthqD5G.js +1 -0
  115. package/dist/apps/chat-ui/assets/sql-D_dieYbr.js +1 -0
  116. package/dist/apps/chat-ui/assets/stex-rHcFYcA0.js +1 -0
  117. package/dist/apps/chat-ui/assets/stylus-DxF70RNr.js +1 -0
  118. package/dist/apps/chat-ui/assets/swift-T0hDoOb-.js +1 -0
  119. package/dist/apps/chat-ui/assets/tcl-Dlzy1mPk.js +1 -0
  120. package/dist/apps/chat-ui/assets/textile-Dy5rFZe5.js +1 -0
  121. package/dist/apps/chat-ui/assets/tiddlywiki-DQP1OymS.js +1 -0
  122. package/dist/apps/chat-ui/assets/tiki-0vOj3DB2.js +1 -0
  123. package/dist/apps/chat-ui/assets/toml-DEltN0lI.js +1 -0
  124. package/dist/apps/chat-ui/assets/troff-CRbBpEqY.js +1 -0
  125. package/dist/apps/chat-ui/assets/ttcn-M5q1nLKg.js +1 -0
  126. package/dist/apps/chat-ui/assets/ttcn-cfg-Rmw9NWq9.js +1 -0
  127. package/dist/apps/chat-ui/assets/turtle-BCDWhJK0.js +1 -0
  128. package/dist/apps/chat-ui/assets/vb-QQ7LGlOz.js +1 -0
  129. package/dist/apps/chat-ui/assets/vbscript-BiSEdUzz.js +1 -0
  130. package/dist/apps/chat-ui/assets/velocity-CzMg5_6w.js +1 -0
  131. package/dist/apps/chat-ui/assets/verilog-BJOO83gk.js +1 -0
  132. package/dist/apps/chat-ui/assets/vhdl-ed4zAZAA.js +1 -0
  133. package/dist/apps/chat-ui/assets/webidl-Ddy6hbV6.js +1 -0
  134. package/dist/apps/chat-ui/assets/xquery-Bw1zwhh6.js +1 -0
  135. package/dist/apps/chat-ui/assets/yacas-DZdTXy3s.js +1 -0
  136. package/dist/apps/chat-ui/assets/z80-DMG02_YV.js +1 -0
  137. package/dist/apps/chat-ui/index.html +15 -0
  138. package/dist/apps/context-files-ui/assets/apl-14BqhLYK.js +1 -0
  139. package/dist/apps/context-files-ui/assets/asciiarmor-WLvjqI7d.js +1 -0
  140. package/dist/apps/context-files-ui/assets/asn1-Bg4FbdCg.js +1 -0
  141. package/dist/apps/context-files-ui/assets/asterisk-B2MO-X4d.js +1 -0
  142. package/dist/apps/context-files-ui/assets/brainfuck-CV9kufud.js +1 -0
  143. package/dist/apps/context-files-ui/assets/clike-CjmcUpt6.js +1 -0
  144. package/dist/apps/context-files-ui/assets/clojure-De3QGfx6.js +1 -0
  145. package/dist/apps/context-files-ui/assets/cmake-i2VDNaRq.js +1 -0
  146. package/dist/apps/context-files-ui/assets/cobol-BwO6DF08.js +1 -0
  147. package/dist/apps/context-files-ui/assets/coffeescript-BtivDvRz.js +1 -0
  148. package/dist/apps/context-files-ui/assets/commonlisp-DFkEQdLP.js +1 -0
  149. package/dist/apps/context-files-ui/assets/crystal-CU0NkcVL.js +1 -0
  150. package/dist/apps/context-files-ui/assets/css-CbMZAQ1W.js +1 -0
  151. package/dist/apps/context-files-ui/assets/cypher-Dke5QOzv.js +1 -0
  152. package/dist/apps/context-files-ui/assets/d-TPqSVaHM.js +1 -0
  153. package/dist/apps/context-files-ui/assets/diff-B365LSoZ.js +1 -0
  154. package/dist/apps/context-files-ui/assets/dist-B5PTVnox.js +1 -0
  155. package/dist/apps/context-files-ui/assets/dist-B5ZAfwf5.js +1 -0
  156. package/dist/apps/context-files-ui/assets/dist-BJW3917N.js +11 -0
  157. package/dist/apps/context-files-ui/assets/dist-BkUONE3N.js +1 -0
  158. package/dist/apps/context-files-ui/assets/dist-CKQF1zEu.js +1 -0
  159. package/dist/apps/context-files-ui/assets/dist-CwbH_3RN.js +1 -0
  160. package/dist/apps/context-files-ui/assets/dist-CxRLRmMx.js +2 -0
  161. package/dist/apps/context-files-ui/assets/dist-D1KyNDg5.js +13 -0
  162. package/dist/apps/context-files-ui/assets/dist-DFi2YGux.js +1 -0
  163. package/dist/apps/context-files-ui/assets/dist-DKoyMSNr.js +1 -0
  164. package/dist/apps/context-files-ui/assets/dist-DLMjd26T.js +1 -0
  165. package/dist/apps/context-files-ui/assets/dist-DQXzt2Ng.js +1 -0
  166. package/dist/apps/context-files-ui/assets/dist-DotDq_kD.js +1 -0
  167. package/dist/apps/context-files-ui/assets/dist-DyfSeBMu.js +1 -0
  168. package/dist/apps/context-files-ui/assets/dist-MyZgX9K2.js +9 -0
  169. package/dist/apps/context-files-ui/assets/dist-QQuDy4KA.js +1 -0
  170. package/dist/apps/context-files-ui/assets/dist-YwR9dpb-.js +1 -0
  171. package/dist/apps/context-files-ui/assets/dist-dTBsFYAl.js +1 -0
  172. package/dist/apps/context-files-ui/assets/dockerfile-CJb2sekW.js +1 -0
  173. package/dist/apps/context-files-ui/assets/dtd-CBMymJ7O.js +1 -0
  174. package/dist/apps/context-files-ui/assets/dylan-08Azy1NK.js +1 -0
  175. package/dist/apps/context-files-ui/assets/ebnf-Dkum_1J8.js +1 -0
  176. package/dist/apps/context-files-ui/assets/ecl-dhxjHL8y.js +1 -0
  177. package/dist/apps/context-files-ui/assets/eiffel-C446m6dI.js +1 -0
  178. package/dist/apps/context-files-ui/assets/elm-po1E9de0.js +1 -0
  179. package/dist/apps/context-files-ui/assets/erlang-BD5LkVkR.js +1 -0
  180. package/dist/apps/context-files-ui/assets/factor-B2EMQZkP.js +1 -0
  181. package/dist/apps/context-files-ui/assets/fcl-DkEOamHd.js +1 -0
  182. package/dist/apps/context-files-ui/assets/forth-dCg2_HVB.js +1 -0
  183. package/dist/apps/context-files-ui/assets/fortran-3ZpXLFh1.js +1 -0
  184. package/dist/apps/context-files-ui/assets/gas-DMmxLZRI.js +1 -0
  185. package/dist/apps/context-files-ui/assets/gherkin-DUSFg2R6.js +1 -0
  186. package/dist/apps/context-files-ui/assets/groovy-Cmduloe1.js +1 -0
  187. package/dist/apps/context-files-ui/assets/haskell-Cyr255R9.js +1 -0
  188. package/dist/apps/context-files-ui/assets/haxe-BJVKtprM.js +1 -0
  189. package/dist/apps/context-files-ui/assets/http-DszHFpc-.js +1 -0
  190. package/dist/apps/context-files-ui/assets/idl-Cati9Nrv.js +1 -0
  191. package/dist/apps/context-files-ui/assets/index-BwRDoHMC.css +1 -0
  192. package/dist/apps/context-files-ui/assets/index-GwvjXytt.js +202 -0
  193. package/dist/apps/context-files-ui/assets/javascript-C5pDVaoP.js +1 -0
  194. package/dist/apps/context-files-ui/assets/julia-DlqY1cTU.js +1 -0
  195. package/dist/apps/context-files-ui/assets/livescript-C6p8-2W1.js +1 -0
  196. package/dist/apps/context-files-ui/assets/lua-BxuTHaF7.js +1 -0
  197. package/dist/apps/context-files-ui/assets/mathematica-nDHZUMJT.js +1 -0
  198. package/dist/apps/context-files-ui/assets/mbox-DAaR0Hcz.js +1 -0
  199. package/dist/apps/context-files-ui/assets/mirc-CCA0FRfl.js +1 -0
  200. package/dist/apps/context-files-ui/assets/mllike-Cw3Iccsb.js +1 -0
  201. package/dist/apps/context-files-ui/assets/modelica-Czx80fNR.js +1 -0
  202. package/dist/apps/context-files-ui/assets/mscgen-BmfuTbzG.js +1 -0
  203. package/dist/apps/context-files-ui/assets/mumps-Ds_ZaumL.js +1 -0
  204. package/dist/apps/context-files-ui/assets/nginx-D9M2PQ4U.js +1 -0
  205. package/dist/apps/context-files-ui/assets/nsis-DOo3SJmd.js +1 -0
  206. package/dist/apps/context-files-ui/assets/ntriples-DLHGTvHs.js +1 -0
  207. package/dist/apps/context-files-ui/assets/octave-8jj96JiC.js +1 -0
  208. package/dist/apps/context-files-ui/assets/oz-BmMq7iC4.js +1 -0
  209. package/dist/apps/context-files-ui/assets/pascal-BgMr6XpT.js +1 -0
  210. package/dist/apps/context-files-ui/assets/perl-D6YJObi_.js +1 -0
  211. package/dist/apps/context-files-ui/assets/pig-nx7uchs8.js +1 -0
  212. package/dist/apps/context-files-ui/assets/powershell-B4IPkVxR.js +1 -0
  213. package/dist/apps/context-files-ui/assets/properties-CoavQdLC.js +1 -0
  214. package/dist/apps/context-files-ui/assets/protobuf-D5EWhcmc.js +1 -0
  215. package/dist/apps/context-files-ui/assets/pug-QU72BPAa.js +1 -0
  216. package/dist/apps/context-files-ui/assets/puppet-B_0GFuyD.js +1 -0
  217. package/dist/apps/context-files-ui/assets/python-Cs7sNzy_.js +1 -0
  218. package/dist/apps/context-files-ui/assets/q-BIB9pPtI.js +1 -0
  219. package/dist/apps/context-files-ui/assets/r-CN5s4f3o.js +1 -0
  220. package/dist/apps/context-files-ui/assets/rpm-Ct_Ck8mQ.js +1 -0
  221. package/dist/apps/context-files-ui/assets/ruby-BVPradRk.js +1 -0
  222. package/dist/apps/context-files-ui/assets/sas-DN4j74IF.js +1 -0
  223. package/dist/apps/context-files-ui/assets/scheme-CvNgHAnh.js +1 -0
  224. package/dist/apps/context-files-ui/assets/shell-BjiMLAaM.js +1 -0
  225. package/dist/apps/context-files-ui/assets/sieve-C2U1O5Z4.js +1 -0
  226. package/dist/apps/context-files-ui/assets/simple-mode-DnMbQuKW.js +1 -0
  227. package/dist/apps/context-files-ui/assets/smalltalk-DkYwYufV.js +1 -0
  228. package/dist/apps/context-files-ui/assets/solr-BopnSD-v.js +1 -0
  229. package/dist/apps/context-files-ui/assets/sparql-Cpg3YQfd.js +1 -0
  230. package/dist/apps/context-files-ui/assets/spreadsheet-kRxtVt9J.js +1 -0
  231. package/dist/apps/context-files-ui/assets/sql-DYI2GwJR.js +1 -0
  232. package/dist/apps/context-files-ui/assets/stex-BCRT8IJ3.js +1 -0
  233. package/dist/apps/context-files-ui/assets/stylus-CARoeVE9.js +1 -0
  234. package/dist/apps/context-files-ui/assets/swift-DKNaLAK6.js +1 -0
  235. package/dist/apps/context-files-ui/assets/tcl-CQyXkgMH.js +1 -0
  236. package/dist/apps/context-files-ui/assets/textile-Yg_UWn-t.js +1 -0
  237. package/dist/apps/context-files-ui/assets/tiddlywiki-dqVbkfX4.js +1 -0
  238. package/dist/apps/context-files-ui/assets/tiki-CC_ic8g0.js +1 -0
  239. package/dist/apps/context-files-ui/assets/toml-B7gGzVkJ.js +1 -0
  240. package/dist/apps/context-files-ui/assets/troff-Bq3z6oAu.js +1 -0
  241. package/dist/apps/context-files-ui/assets/ttcn-GvRgs2AT.js +1 -0
  242. package/dist/apps/context-files-ui/assets/ttcn-cfg-CGCXz7Vo.js +1 -0
  243. package/dist/apps/context-files-ui/assets/turtle-CwIpz2yy.js +1 -0
  244. package/dist/apps/context-files-ui/assets/vb-BmcHUM2C.js +1 -0
  245. package/dist/apps/context-files-ui/assets/vbscript-Cs9dylre.js +1 -0
  246. package/dist/apps/context-files-ui/assets/velocity-CBWU0VCy.js +1 -0
  247. package/dist/apps/context-files-ui/assets/verilog-DVCHmufx.js +1 -0
  248. package/dist/apps/context-files-ui/assets/vhdl-BGDk4f1d.js +1 -0
  249. package/dist/apps/context-files-ui/assets/webidl-egXQEWlC.js +1 -0
  250. package/dist/apps/context-files-ui/assets/xquery-5f0hn7cg.js +1 -0
  251. package/dist/apps/context-files-ui/assets/yacas-DNs9XkmQ.js +1 -0
  252. package/dist/apps/context-files-ui/assets/z80-B7Dfb4UO.js +1 -0
  253. package/dist/apps/context-files-ui/index.html +14 -0
  254. package/dist/auth/better-auth.js +129 -0
  255. package/dist/auth/types.js +14 -0
  256. package/dist/bin/pibo.js +3 -0
  257. package/dist/channels/types.js +1 -0
  258. package/dist/cli-errors.js +18 -0
  259. package/dist/cli.js +264 -0
  260. package/dist/config/config.js +167 -0
  261. package/dist/core/base-prompt.js +104 -0
  262. package/dist/core/codex-compat.js +44 -0
  263. package/dist/core/compaction-prompt.js +258 -0
  264. package/dist/core/events.js +1 -0
  265. package/dist/core/profiles.js +138 -0
  266. package/dist/core/routed-session.js +538 -0
  267. package/dist/core/runtime.js +323 -0
  268. package/dist/core/session-router.js +437 -0
  269. package/dist/core/system-prompt-template.js +56 -0
  270. package/dist/core/thinking.js +9 -0
  271. package/dist/core/workspace.js +5 -0
  272. package/dist/debug/events.js +92 -0
  273. package/dist/debug/index.js +631 -0
  274. package/dist/debug/session.js +200 -0
  275. package/dist/debug/sql.js +238 -0
  276. package/dist/debug/stores.js +49 -0
  277. package/dist/debug/trace.js +245 -0
  278. package/dist/env.js +32 -0
  279. package/dist/gateway/client.js +200 -0
  280. package/dist/gateway/protocol.js +46 -0
  281. package/dist/gateway/request.js +146 -0
  282. package/dist/gateway/server.js +221 -0
  283. package/dist/gateway/tool.js +69 -0
  284. package/dist/gateway/web.js +80 -0
  285. package/dist/index.js +23 -0
  286. package/dist/local/client.js +77 -0
  287. package/dist/local/extension.js +548 -0
  288. package/dist/local/tui.js +25 -0
  289. package/dist/mcp/agent-context.js +123 -0
  290. package/dist/mcp/client.js +332 -0
  291. package/dist/mcp/commands/call.js +146 -0
  292. package/dist/mcp/commands/grep.js +145 -0
  293. package/dist/mcp/commands/info.js +71 -0
  294. package/dist/mcp/commands/list.js +94 -0
  295. package/dist/mcp/config-command.js +217 -0
  296. package/dist/mcp/config.js +440 -0
  297. package/dist/mcp/daemon-client.js +266 -0
  298. package/dist/mcp/daemon.js +327 -0
  299. package/dist/mcp/errors.js +287 -0
  300. package/dist/mcp/index.js +431 -0
  301. package/dist/mcp/output.js +171 -0
  302. package/dist/mcp/python-runtime.js +131 -0
  303. package/dist/mcp/registry.js +116 -0
  304. package/dist/mcp/version.js +5 -0
  305. package/dist/pi-packages/cli.js +92 -0
  306. package/dist/pi-packages/installer.js +70 -0
  307. package/dist/pi-packages/metadata.js +231 -0
  308. package/dist/pi-packages/runtime.js +61 -0
  309. package/dist/pi-packages/store.js +175 -0
  310. package/dist/pi-packages/types.js +1 -0
  311. package/dist/plugins/better-auth.js +11 -0
  312. package/dist/plugins/builtin.js +249 -0
  313. package/dist/plugins/chat-web.js +11 -0
  314. package/dist/plugins/codex-compat.js +72 -0
  315. package/dist/plugins/context-files-store.js +354 -0
  316. package/dist/plugins/context-files.js +999 -0
  317. package/dist/plugins/core-tools.js +94 -0
  318. package/dist/plugins/example.js +67 -0
  319. package/dist/plugins/registry.js +368 -0
  320. package/dist/plugins/remote-agent.js +9 -0
  321. package/dist/plugins/types.js +1 -0
  322. package/dist/plugins/web.js +11 -0
  323. package/dist/reliability/store.js +759 -0
  324. package/dist/remote/channel.js +176 -0
  325. package/dist/remote/client.js +92 -0
  326. package/dist/remote/examples/tui-controller.js +263 -0
  327. package/dist/remote/protocol.js +55 -0
  328. package/dist/remote/session-client.js +189 -0
  329. package/dist/runs/registry.js +323 -0
  330. package/dist/runs/tools.js +185 -0
  331. package/dist/sessions/bindings.js +41 -0
  332. package/dist/sessions/sqlite-store.js +154 -0
  333. package/dist/sessions/store.js +125 -0
  334. package/dist/shared/trace-order.js +83 -0
  335. package/dist/subagents/tool.js +63 -0
  336. package/dist/tools/browser-use-cdp.js +207 -0
  337. package/dist/tools/browser-use-leases.js +338 -0
  338. package/dist/tools/browser-use-wrapper.js +338 -0
  339. package/dist/tools/codex-compat.js +85 -0
  340. package/dist/tools/desktop-env.js +90 -0
  341. package/dist/tools/guides.js +276 -0
  342. package/dist/tools/index.js +366 -0
  343. package/dist/tools/python-runtime.js +154 -0
  344. package/dist/tools/registry.js +107 -0
  345. package/dist/tools/web-search.js +137 -0
  346. package/dist/web/auth.js +10 -0
  347. package/dist/web/channel.js +151 -0
  348. package/dist/web/http.js +110 -0
  349. package/dist/web/types.js +1 -0
  350. package/package.json +74 -0
  351. package/src/mcp/LICENSE.mcp-cli +21 -0
@@ -0,0 +1,176 @@
1
+ import { createServer } from "node:net";
2
+ import { DEFAULT_REMOTE_AGENT_HOST, DEFAULT_REMOTE_AGENT_PORT, REMOTE_AGENT_CHANNEL_NAME, encodeRemoteAgentFrame, isRemoteAgentRequestFrame, remoteAgentErrorResponse, } from "./protocol.js";
3
+ function parseJsonLine(line) {
4
+ try {
5
+ return JSON.parse(line);
6
+ }
7
+ catch {
8
+ throw new Error("Invalid JSON frame");
9
+ }
10
+ }
11
+ function createConnection(socket) {
12
+ return {
13
+ socket,
14
+ send(frame) {
15
+ if (socket.destroyed)
16
+ return;
17
+ socket.write(encodeRemoteAgentFrame(frame));
18
+ },
19
+ };
20
+ }
21
+ export function createRemoteAgentChannel(options = {}) {
22
+ const host = options.host ?? DEFAULT_REMOTE_AGENT_HOST;
23
+ const port = options.port ?? DEFAULT_REMOTE_AGENT_PORT;
24
+ const defaultProfile = options.defaultProfile ?? "pibo-minimal";
25
+ const connections = new Set();
26
+ let server;
27
+ let unsubscribe;
28
+ let context;
29
+ const requireContext = () => {
30
+ if (!context)
31
+ throw new Error("Remote agent channel is not started");
32
+ return context;
33
+ };
34
+ const handleRequest = async (connection, frame) => {
35
+ const ctx = requireContext();
36
+ if (frame.type === "remote_attach") {
37
+ const binding = ctx.resolveSession({
38
+ channel: REMOTE_AGENT_CHANNEL_NAME,
39
+ externalId: frame.sessionName,
40
+ defaultProfile: frame.profile ?? defaultProfile,
41
+ });
42
+ connection.binding = binding;
43
+ return {
44
+ type: "remote_res",
45
+ id: frame.id,
46
+ ok: true,
47
+ payload: {
48
+ binding,
49
+ capabilities: {
50
+ actions: ctx.getGatewayActions(),
51
+ },
52
+ },
53
+ };
54
+ }
55
+ if (frame.type === "remote_capabilities") {
56
+ return {
57
+ type: "remote_res",
58
+ id: frame.id,
59
+ ok: true,
60
+ payload: {
61
+ actions: ctx.getGatewayActions(),
62
+ },
63
+ };
64
+ }
65
+ if (!connection.binding) {
66
+ throw new Error("Remote agent client is not attached");
67
+ }
68
+ const sessionKey = connection.binding.sessionKey;
69
+ const output = frame.input.type === "message"
70
+ ? await ctx.emit({
71
+ type: "message",
72
+ sessionKey,
73
+ id: frame.id,
74
+ text: frame.input.text,
75
+ source: "ui",
76
+ })
77
+ : await ctx.emit({
78
+ type: "execution",
79
+ sessionKey,
80
+ id: frame.id,
81
+ action: frame.input.action,
82
+ params: frame.input.params,
83
+ });
84
+ return { type: "remote_res", id: frame.id, ok: true, payload: output };
85
+ };
86
+ const handleLine = async (connection, line) => {
87
+ let frame;
88
+ try {
89
+ frame = parseJsonLine(line);
90
+ if (!isRemoteAgentRequestFrame(frame)) {
91
+ throw new Error("Invalid remote agent request frame");
92
+ }
93
+ }
94
+ catch (error) {
95
+ connection.send(remoteAgentErrorResponse("invalid", error));
96
+ return;
97
+ }
98
+ try {
99
+ connection.send(await handleRequest(connection, frame));
100
+ }
101
+ catch (error) {
102
+ connection.send(remoteAgentErrorResponse(frame.id, error));
103
+ }
104
+ };
105
+ const handleSocket = (socket) => {
106
+ const connection = createConnection(socket);
107
+ connections.add(connection);
108
+ let buffer = "";
109
+ socket.setEncoding("utf-8");
110
+ socket.on("data", (chunk) => {
111
+ buffer += chunk;
112
+ let newlineIndex = buffer.indexOf("\n");
113
+ while (newlineIndex !== -1) {
114
+ const line = buffer.slice(0, newlineIndex).trim();
115
+ buffer = buffer.slice(newlineIndex + 1);
116
+ if (line) {
117
+ void handleLine(connection, line);
118
+ }
119
+ newlineIndex = buffer.indexOf("\n");
120
+ }
121
+ });
122
+ socket.once("close", () => connections.delete(connection));
123
+ socket.once("error", () => connections.delete(connection));
124
+ };
125
+ return {
126
+ name: REMOTE_AGENT_CHANNEL_NAME,
127
+ kind: "local",
128
+ description: "Local Pi Coding Agent style remote-control channel for pibo sessions.",
129
+ auth: { mode: "trusted-local" },
130
+ async start(channelContext) {
131
+ if (server)
132
+ return;
133
+ context = channelContext;
134
+ unsubscribe = channelContext.subscribe((event) => {
135
+ for (const connection of connections) {
136
+ if (connection.binding?.sessionKey === event.sessionKey) {
137
+ connection.send({ type: "remote_event", sessionKey: event.sessionKey, payload: event });
138
+ }
139
+ }
140
+ });
141
+ server = createServer((socket) => handleSocket(socket));
142
+ await new Promise((resolve, reject) => {
143
+ server.once("error", reject);
144
+ server.listen(port, host, () => {
145
+ server.off("error", reject);
146
+ resolve();
147
+ });
148
+ });
149
+ const address = this.getAddress();
150
+ if (address && options.announce !== false) {
151
+ console.error(`pibo remote agent channel listening on ${address.host}:${address.port}`);
152
+ }
153
+ },
154
+ async stop() {
155
+ unsubscribe?.();
156
+ unsubscribe = undefined;
157
+ context = undefined;
158
+ for (const connection of connections) {
159
+ connection.socket.destroy();
160
+ }
161
+ connections.clear();
162
+ if (server) {
163
+ await new Promise((resolve, reject) => {
164
+ server.close((error) => (error ? reject(error) : resolve()));
165
+ });
166
+ server = undefined;
167
+ }
168
+ },
169
+ getAddress() {
170
+ const address = server?.address();
171
+ if (!address || typeof address === "string")
172
+ return undefined;
173
+ return { host: address.address, port: address.port };
174
+ },
175
+ };
176
+ }
@@ -0,0 +1,92 @@
1
+ import readline from "node:readline/promises";
2
+ import { stdin as input, stdout as output } from "node:process";
3
+ import { DEFAULT_REMOTE_AGENT_HOST, DEFAULT_REMOTE_AGENT_PORT } from "./protocol.js";
4
+ import { RemoteAgentSessionClient } from "./session-client.js";
5
+ function isSessionStatus(value) {
6
+ if (!value || typeof value !== "object")
7
+ return false;
8
+ const candidate = value;
9
+ return (typeof candidate.sessionKey === "string" &&
10
+ typeof candidate.queuedMessages === "number" &&
11
+ typeof candidate.processing === "boolean");
12
+ }
13
+ function printResponse(frame) {
14
+ if (frame.ok)
15
+ return;
16
+ console.error(`\nerror: ${frame.error?.message ?? "request failed"}`);
17
+ }
18
+ function printExecutionResult(event) {
19
+ if (event.action === "status" && isSessionStatus(event.result)) {
20
+ console.error(`status: session=${event.result.sessionKey} queued=${event.result.queuedMessages} processing=${event.result.processing} streaming=${event.result.streaming}`);
21
+ return;
22
+ }
23
+ if (event.action === "clear_queue" && event.result && typeof event.result === "object") {
24
+ const cleared = event.result.cleared;
25
+ console.error(`clear: removed ${typeof cleared === "number" ? cleared : 0} queued message(s)`);
26
+ return;
27
+ }
28
+ console.error(`${event.action}: ${JSON.stringify(event.result)}`);
29
+ }
30
+ function printEvent(event, state) {
31
+ if (event.type === "assistant_delta") {
32
+ state.sawAssistantDelta = true;
33
+ output.write(event.text);
34
+ return;
35
+ }
36
+ if (event.type === "assistant_message") {
37
+ if (!state.sawAssistantDelta) {
38
+ output.write(event.text);
39
+ }
40
+ state.sawAssistantDelta = false;
41
+ output.write("\n");
42
+ return;
43
+ }
44
+ if (event.type === "message_started") {
45
+ state.sawAssistantDelta = false;
46
+ output.write("assistant> ");
47
+ return;
48
+ }
49
+ if (event.type === "session_error") {
50
+ console.error(`\nsession error: ${event.error}`);
51
+ return;
52
+ }
53
+ if (event.type === "execution_result") {
54
+ printExecutionResult(event);
55
+ }
56
+ }
57
+ export async function runRemoteAgentClient(options = {}) {
58
+ const resolvedOptions = {
59
+ host: options.host ?? DEFAULT_REMOTE_AGENT_HOST,
60
+ port: options.port ?? DEFAULT_REMOTE_AGENT_PORT,
61
+ sessionName: options.sessionName ?? "default",
62
+ profile: options.profile ?? "pibo-minimal",
63
+ };
64
+ const client = await RemoteAgentSessionClient.connect(resolvedOptions);
65
+ const slashCommands = client.getSlashCommands();
66
+ console.error(`connected to pibo remote agent at ${resolvedOptions.host}:${resolvedOptions.port}`);
67
+ console.error(`session: ${client.binding.sessionKey}`);
68
+ console.error(`profile: ${client.binding.originalProfile}`);
69
+ console.error(`commands: ${[...slashCommands.keys(), "/quit"].join(", ")}`);
70
+ const renderState = { sawAssistantDelta: false };
71
+ client.onEvent((event) => printEvent(event, renderState));
72
+ const rl = readline.createInterface({ input, output });
73
+ try {
74
+ while (true) {
75
+ const text = (await rl.question("remote> ")).trim();
76
+ if (!text)
77
+ continue;
78
+ if (text === "/quit" || text === "/exit")
79
+ break;
80
+ const action = slashCommands.get(text);
81
+ if (action) {
82
+ client.sendExecution(action).then(printResponse).catch((error) => console.error(`\nerror: ${error.message}`));
83
+ continue;
84
+ }
85
+ client.sendMessage(text).then(printResponse).catch((error) => console.error(`\nerror: ${error.message}`));
86
+ }
87
+ }
88
+ finally {
89
+ rl.close();
90
+ client.close();
91
+ }
92
+ }
@@ -0,0 +1,263 @@
1
+ import { Box, Container, Spacer, Text } from "@mariozechner/pi-tui";
2
+ import { InitialSessionContextBuilder } from "../../core/profiles.js";
3
+ import { runPiboTui } from "../../core/runtime.js";
4
+ import { DEFAULT_REMOTE_AGENT_HOST, DEFAULT_REMOTE_AGENT_PORT, } from "../protocol.js";
5
+ import { createRemoteSlashCommandMap, RemoteAgentSessionClient } from "../session-client.js";
6
+ const LOCAL_PI_TUI_COMMANDS = new Set([
7
+ "settings",
8
+ "model",
9
+ "scoped-models",
10
+ "export",
11
+ "import",
12
+ "share",
13
+ "copy",
14
+ "name",
15
+ "session",
16
+ "changelog",
17
+ "hotkeys",
18
+ "fork",
19
+ "clone",
20
+ "tree",
21
+ "login",
22
+ "logout",
23
+ "new",
24
+ "compact",
25
+ "reload",
26
+ "debug",
27
+ "resume",
28
+ "quit",
29
+ ]);
30
+ const REMOTE_MESSAGE_TYPE = "pibo.remote";
31
+ function createRemoteControllerProfile() {
32
+ return new InitialSessionContextBuilder("pibo-remote-controller")
33
+ .withBuiltinTools("disabled")
34
+ .createSession();
35
+ }
36
+ function bg(color, text) {
37
+ return `\x1b[48;5;${color}m${text}\x1b[0m`;
38
+ }
39
+ function fg(color, text) {
40
+ return `\x1b[38;5;${color}m${text}\x1b[0m`;
41
+ }
42
+ function bold(text) {
43
+ return `\x1b[1m${text}\x1b[22m`;
44
+ }
45
+ function getRemoteMessageStyle(role) {
46
+ if (role === "user") {
47
+ return { label: "you -> remote", bgColor: 24, labelColor: 117 };
48
+ }
49
+ if (role === "assistant") {
50
+ return { label: "remote assistant", bgColor: 22, labelColor: 120 };
51
+ }
52
+ if (role === "execution") {
53
+ return { label: "remote execution", bgColor: 58, labelColor: 229 };
54
+ }
55
+ if (role === "error") {
56
+ return { label: "remote error", bgColor: 52, labelColor: 210 };
57
+ }
58
+ return { label: "remote session", bgColor: 236, labelColor: 250 };
59
+ }
60
+ function createRemoteMessageComponent(content, details) {
61
+ const style = getRemoteMessageStyle(details.role);
62
+ const container = new Container();
63
+ const box = new Box(1, 1, (text) => bg(style.bgColor, text));
64
+ box.addChild(new Text(bold(fg(style.labelColor, style.label)), 0, 0));
65
+ box.addChild(new Spacer(1));
66
+ box.addChild(new Text(content, 0, 0));
67
+ container.addChild(new Spacer(1));
68
+ container.addChild(box);
69
+ return container;
70
+ }
71
+ function createTuiSlashCommandMap(capabilities) {
72
+ const commands = createRemoteSlashCommandMap(capabilities);
73
+ for (const command of commands.keys()) {
74
+ if (LOCAL_PI_TUI_COMMANDS.has(command.slice(1))) {
75
+ commands.delete(command);
76
+ }
77
+ }
78
+ return commands;
79
+ }
80
+ function createRemoteAutocompleteProvider(current, allowedCommands) {
81
+ return {
82
+ async getSuggestions(lines, cursorLine, cursorCol, options) {
83
+ const suggestions = await current.getSuggestions(lines, cursorLine, cursorCol, options);
84
+ const beforeCursor = (lines[cursorLine] ?? "").slice(0, cursorCol);
85
+ if (!suggestions || !beforeCursor.startsWith("/") || beforeCursor.includes(" ")) {
86
+ return suggestions;
87
+ }
88
+ const items = suggestions.items.filter((item) => allowedCommands.has(item.value));
89
+ return items.length > 0 ? { ...suggestions, items } : null;
90
+ },
91
+ applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
92
+ return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
93
+ },
94
+ shouldTriggerFileCompletion: current.shouldTriggerFileCompletion
95
+ ? (lines, cursorLine, cursorCol) => current.shouldTriggerFileCompletion(lines, cursorLine, cursorCol)
96
+ : undefined,
97
+ };
98
+ }
99
+ function isSessionStatus(value) {
100
+ if (!value || typeof value !== "object")
101
+ return false;
102
+ const candidate = value;
103
+ return (typeof candidate.sessionKey === "string" &&
104
+ typeof candidate.queuedMessages === "number" &&
105
+ typeof candidate.processing === "boolean");
106
+ }
107
+ function formatExecutionResult(event) {
108
+ if (event.action === "status" && isSessionStatus(event.result)) {
109
+ return `status: session=${event.result.sessionKey} queued=${event.result.queuedMessages} processing=${event.result.processing} streaming=${event.result.streaming}`;
110
+ }
111
+ if (event.action === "clear_queue" && event.result && typeof event.result === "object") {
112
+ const cleared = event.result.cleared;
113
+ return `clear: removed ${typeof cleared === "number" ? cleared : 0} queued message(s)`;
114
+ }
115
+ return `${event.action}: ${JSON.stringify(event.result)}`;
116
+ }
117
+ function sendTuiMessage(pi, content, details) {
118
+ pi.sendMessage({
119
+ customType: REMOTE_MESSAGE_TYPE,
120
+ content,
121
+ display: true,
122
+ details,
123
+ });
124
+ }
125
+ function formatConnectedMessage(client, slashCommands) {
126
+ const commands = [...slashCommands.keys()].join(", ") || "none";
127
+ return [
128
+ `Connected to pibo remote session ${client.binding.sessionKey}.`,
129
+ `Profile: ${client.binding.originalProfile}`,
130
+ `Remote commands: ${commands}`,
131
+ "Pi TUI built-in slash commands stay local.",
132
+ ].join("\n");
133
+ }
134
+ export function createRemoteAgentTuiExtension(options = {}) {
135
+ const resolvedOptions = {
136
+ host: options.host ?? DEFAULT_REMOTE_AGENT_HOST,
137
+ port: options.port ?? DEFAULT_REMOTE_AGENT_PORT,
138
+ sessionName: options.sessionName ?? "default",
139
+ profile: options.profile ?? "pibo-minimal",
140
+ };
141
+ return (pi) => {
142
+ let client;
143
+ let connectPromise;
144
+ let slashCommands = new Map();
145
+ let context;
146
+ let assistantBuffer = "";
147
+ let autocompleteRefreshed = false;
148
+ const registeredCommands = new Set();
149
+ pi.registerMessageRenderer(REMOTE_MESSAGE_TYPE, (message) => {
150
+ return createRemoteMessageComponent(String(message.content), message.details ?? { role: "system" });
151
+ });
152
+ const setStatus = (text) => {
153
+ context?.ui.setStatus("pibo.remote", text);
154
+ };
155
+ const handleRemoteEvent = (event) => {
156
+ if (event.type === "message_started") {
157
+ assistantBuffer = "";
158
+ setStatus("remote running");
159
+ return;
160
+ }
161
+ if (event.type === "assistant_delta") {
162
+ assistantBuffer += event.text;
163
+ return;
164
+ }
165
+ if (event.type === "assistant_message") {
166
+ sendTuiMessage(pi, event.text || assistantBuffer, { role: "assistant", event });
167
+ assistantBuffer = "";
168
+ setStatus("remote connected");
169
+ return;
170
+ }
171
+ if (event.type === "execution_result") {
172
+ sendTuiMessage(pi, formatExecutionResult(event), { role: "execution", event });
173
+ setStatus("remote connected");
174
+ return;
175
+ }
176
+ if (event.type === "session_error") {
177
+ sendTuiMessage(pi, `Remote error: ${event.error}`, { role: "error", event });
178
+ setStatus("remote error");
179
+ }
180
+ };
181
+ const ensureClient = async (ctx) => {
182
+ context = ctx;
183
+ if (client)
184
+ return client;
185
+ if (connectPromise)
186
+ return connectPromise;
187
+ setStatus("remote connecting");
188
+ connectPromise = RemoteAgentSessionClient.connect(resolvedOptions)
189
+ .then((connectedClient) => {
190
+ client = connectedClient;
191
+ slashCommands = createTuiSlashCommandMap(connectedClient.capabilities);
192
+ for (const [slashCommand, action] of slashCommands) {
193
+ const name = slashCommand.slice(1);
194
+ if (registeredCommands.has(name))
195
+ continue;
196
+ registeredCommands.add(name);
197
+ const description = connectedClient.capabilities.actions.find((candidate) => candidate.name === action)?.description ??
198
+ `Run remote gateway action "${action}".`;
199
+ pi.registerCommand(name, {
200
+ description,
201
+ async handler() {
202
+ sendTuiMessage(pi, slashCommand, { role: "user" });
203
+ await connectedClient.sendExecution(action);
204
+ },
205
+ });
206
+ }
207
+ if (!autocompleteRefreshed) {
208
+ const allowedCommands = new Set([...slashCommands.keys()].map((command) => command.slice(1)));
209
+ allowedCommands.add("quit");
210
+ ctx.ui.addAutocompleteProvider((current) => createRemoteAutocompleteProvider(current, allowedCommands));
211
+ autocompleteRefreshed = true;
212
+ }
213
+ connectedClient.onEvent(handleRemoteEvent);
214
+ setStatus("remote connected");
215
+ sendTuiMessage(pi, formatConnectedMessage(connectedClient, slashCommands), { role: "system" });
216
+ return connectedClient;
217
+ })
218
+ .catch((error) => {
219
+ connectPromise = undefined;
220
+ setStatus("remote offline");
221
+ sendTuiMessage(pi, `Remote connection failed: ${error.message}`, { role: "error" });
222
+ throw error;
223
+ });
224
+ return connectPromise;
225
+ };
226
+ pi.on("session_start", async (_event, ctx) => {
227
+ await ensureClient(ctx).catch(() => { });
228
+ });
229
+ pi.on("session_shutdown", () => {
230
+ client?.close();
231
+ client = undefined;
232
+ connectPromise = undefined;
233
+ });
234
+ pi.on("input", async (event, ctx) => {
235
+ const text = event.text.trim();
236
+ if (!text)
237
+ return { action: "continue" };
238
+ try {
239
+ const connectedClient = await ensureClient(ctx);
240
+ sendTuiMessage(pi, text, { role: "user" });
241
+ const action = slashCommands.get(text);
242
+ if (action) {
243
+ await connectedClient.sendExecution(action);
244
+ }
245
+ else {
246
+ await connectedClient.sendMessage(event.text);
247
+ }
248
+ }
249
+ catch (error) {
250
+ const message = error instanceof Error ? error.message : String(error);
251
+ sendTuiMessage(pi, `Remote request failed: ${message}`, { role: "error" });
252
+ }
253
+ return { action: "handled" };
254
+ });
255
+ };
256
+ }
257
+ export async function runRemoteAgentTui(options = {}) {
258
+ await runPiboTui({
259
+ persistSession: false,
260
+ profile: createRemoteControllerProfile(),
261
+ extensionFactories: [createRemoteAgentTuiExtension(options)],
262
+ });
263
+ }
@@ -0,0 +1,55 @@
1
+ export const DEFAULT_REMOTE_AGENT_HOST = "127.0.0.1";
2
+ export const DEFAULT_REMOTE_AGENT_PORT = 4790;
3
+ export const REMOTE_AGENT_CHANNEL_NAME = "remote-agent";
4
+ function isJsonValue(value) {
5
+ if (value === null ||
6
+ typeof value === "string" ||
7
+ typeof value === "boolean" ||
8
+ (typeof value === "number" && Number.isFinite(value))) {
9
+ return true;
10
+ }
11
+ if (Array.isArray(value)) {
12
+ return value.every(isJsonValue);
13
+ }
14
+ if (typeof value === "object") {
15
+ return Object.values(value).every(isJsonValue);
16
+ }
17
+ return false;
18
+ }
19
+ export function encodeRemoteAgentFrame(frame) {
20
+ return `${JSON.stringify(frame)}\n`;
21
+ }
22
+ export function remoteAgentErrorResponse(id, error) {
23
+ return {
24
+ type: "remote_res",
25
+ id,
26
+ ok: false,
27
+ error: { message: error instanceof Error ? error.message : String(error) },
28
+ };
29
+ }
30
+ export function isRemoteAgentRequestFrame(value) {
31
+ if (!value || typeof value !== "object")
32
+ return false;
33
+ const frame = value;
34
+ if (typeof frame.id !== "string")
35
+ return false;
36
+ if (frame.type === "remote_attach") {
37
+ return (typeof frame.sessionName === "string" &&
38
+ frame.sessionName.length > 0 &&
39
+ (frame.profile === undefined || typeof frame.profile === "string"));
40
+ }
41
+ if (frame.type === "remote_input") {
42
+ if (!frame.input || typeof frame.input !== "object")
43
+ return false;
44
+ const input = frame.input;
45
+ if (input.type === "message")
46
+ return typeof input.text === "string";
47
+ if (input.type === "execution") {
48
+ return typeof input.action === "string" && (input.params === undefined || isJsonValue(input.params));
49
+ }
50
+ }
51
+ if (frame.type === "remote_capabilities") {
52
+ return true;
53
+ }
54
+ return false;
55
+ }