@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.
- package/.codex/skills/pi-agent-harness/SKILL.md +319 -0
- package/.codex/skills/pi-agent-harness/agents/openai.yaml +4 -0
- package/README.md +318 -0
- package/context/codex-base-prompt.md +144 -0
- package/context/pibo-compaction-prompt.md +100 -0
- package/context/pibo-system-prompt.md +17 -0
- package/dist/apps/chat/agent-profiles.js +26 -0
- package/dist/apps/chat/agent-store.js +336 -0
- package/dist/apps/chat/event-log.js +307 -0
- package/dist/apps/chat/read-model.js +218 -0
- package/dist/apps/chat/rooms.js +321 -0
- package/dist/apps/chat/session-metadata.js +14 -0
- package/dist/apps/chat/stream.js +122 -0
- package/dist/apps/chat/trace.js +1182 -0
- package/dist/apps/chat/web-app.js +2569 -0
- package/dist/apps/chat-ui/assets/apl-BxEMbctQ.js +1 -0
- package/dist/apps/chat-ui/assets/asciiarmor-eFjeGRuZ.js +1 -0
- package/dist/apps/chat-ui/assets/asn1-Cfx-0pt9.js +1 -0
- package/dist/apps/chat-ui/assets/asterisk-B5BHTsBr.js +1 -0
- package/dist/apps/chat-ui/assets/brainfuck-CAA2xofr.js +1 -0
- package/dist/apps/chat-ui/assets/clike-BoDCOLzN.js +1 -0
- package/dist/apps/chat-ui/assets/clojure-kVFSWX0o.js +1 -0
- package/dist/apps/chat-ui/assets/cmake-BUPAhezI.js +1 -0
- package/dist/apps/chat-ui/assets/cobol-BfgHZgup.js +1 -0
- package/dist/apps/chat-ui/assets/coffeescript-G1Pe_1AZ.js +1 -0
- package/dist/apps/chat-ui/assets/commonlisp-B3N0CjHn.js +1 -0
- package/dist/apps/chat-ui/assets/crystal-C15ndaGM.js +1 -0
- package/dist/apps/chat-ui/assets/css-BqOeyZOV.js +1 -0
- package/dist/apps/chat-ui/assets/cypher-KjIKv-wW.js +1 -0
- package/dist/apps/chat-ui/assets/d-BlT5AEC-.js +1 -0
- package/dist/apps/chat-ui/assets/diff-oF98tbqj.js +1 -0
- package/dist/apps/chat-ui/assets/dist--55mTWk3.js +1 -0
- package/dist/apps/chat-ui/assets/dist-B5rcjVCj.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BPv5MdlL.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BZ39rB1W.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BsedZGJo.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BvO6SpaM.js +9 -0
- package/dist/apps/chat-ui/assets/dist-C5YJOwhH.js +1 -0
- package/dist/apps/chat-ui/assets/dist-C5oXtFSP.js +1 -0
- package/dist/apps/chat-ui/assets/dist-CG_gRSwv.js +23 -0
- package/dist/apps/chat-ui/assets/dist-CKM5j-iy.js +1 -0
- package/dist/apps/chat-ui/assets/dist-CUp9us2q.js +1 -0
- package/dist/apps/chat-ui/assets/dist-CZ9T4Cly.js +1 -0
- package/dist/apps/chat-ui/assets/dist-D4HhiFWB.js +6 -0
- package/dist/apps/chat-ui/assets/dist-DHE-yBLH.js +1 -0
- package/dist/apps/chat-ui/assets/dist-DSKQpPaz.js +1 -0
- package/dist/apps/chat-ui/assets/dist-L1B-KWZO.js +1 -0
- package/dist/apps/chat-ui/assets/dist-SVPsM5Oi.js +13 -0
- package/dist/apps/chat-ui/assets/dist-Zqt9kNG9.js +1 -0
- package/dist/apps/chat-ui/assets/dist-_DPv0-QF.js +1 -0
- package/dist/apps/chat-ui/assets/dist-_oM7g0eh.js +11 -0
- package/dist/apps/chat-ui/assets/dist-laadbMWg.js +1 -0
- package/dist/apps/chat-ui/assets/dist-nFui3f-r.js +2 -0
- package/dist/apps/chat-ui/assets/dist-tGfufz3b.js +1 -0
- package/dist/apps/chat-ui/assets/dockerfile-CUaqzcqp.js +1 -0
- package/dist/apps/chat-ui/assets/dtd-VCA9yr61.js +1 -0
- package/dist/apps/chat-ui/assets/dylan-O-V5Dw5W.js +1 -0
- package/dist/apps/chat-ui/assets/ebnf-SPmdBkvT.js +1 -0
- package/dist/apps/chat-ui/assets/ecl-ChfCttfI.js +1 -0
- package/dist/apps/chat-ui/assets/eiffel-cB9EbjeN.js +1 -0
- package/dist/apps/chat-ui/assets/elm-BTiVflBU.js +1 -0
- package/dist/apps/chat-ui/assets/erlang-egf0TXFm.js +1 -0
- package/dist/apps/chat-ui/assets/factor-C2tAxNob.js +1 -0
- package/dist/apps/chat-ui/assets/fcl-BiCjh1tj.js +1 -0
- package/dist/apps/chat-ui/assets/forth-C4kDGW6u.js +1 -0
- package/dist/apps/chat-ui/assets/fortran-DzkLaPnd.js +1 -0
- package/dist/apps/chat-ui/assets/gas-DMOxskQF.js +1 -0
- package/dist/apps/chat-ui/assets/gherkin-BPxBpp-k.js +1 -0
- package/dist/apps/chat-ui/assets/groovy-CkEnc0ZY.js +1 -0
- package/dist/apps/chat-ui/assets/haskell-Dadpo9-w.js +1 -0
- package/dist/apps/chat-ui/assets/haxe-CDNZL9MW.js +1 -0
- package/dist/apps/chat-ui/assets/http-jy9Zxxt3.js +1 -0
- package/dist/apps/chat-ui/assets/idl-CGSB6iiy.js +1 -0
- package/dist/apps/chat-ui/assets/index-BdcqTugD.js +151 -0
- package/dist/apps/chat-ui/assets/index-Dk-opWl3.css +1 -0
- package/dist/apps/chat-ui/assets/javascript-DSlzRUd8.js +1 -0
- package/dist/apps/chat-ui/assets/julia-DTiF9v6R.js +1 -0
- package/dist/apps/chat-ui/assets/livescript-Ci8Xxna6.js +1 -0
- package/dist/apps/chat-ui/assets/lua-eVxIrt9t.js +1 -0
- package/dist/apps/chat-ui/assets/mathematica-Da3grj36.js +1 -0
- package/dist/apps/chat-ui/assets/mbox-BWBMSafM.js +1 -0
- package/dist/apps/chat-ui/assets/mirc-CtHu9S1B.js +1 -0
- package/dist/apps/chat-ui/assets/mllike-wTFlPWXS.js +1 -0
- package/dist/apps/chat-ui/assets/modelica-cKbQ0UXu.js +1 -0
- package/dist/apps/chat-ui/assets/mscgen-C5pXQCMK.js +1 -0
- package/dist/apps/chat-ui/assets/mumps-CKBHkOQq.js +1 -0
- package/dist/apps/chat-ui/assets/nginx-B00AiQel.js +1 -0
- package/dist/apps/chat-ui/assets/nsis-SMDwKltR.js +1 -0
- package/dist/apps/chat-ui/assets/ntriples-B_36EBV0.js +1 -0
- package/dist/apps/chat-ui/assets/octave-BXPjzAif.js +1 -0
- package/dist/apps/chat-ui/assets/oz-Dedpat1M.js +1 -0
- package/dist/apps/chat-ui/assets/pascal-CMcUg72K.js +1 -0
- package/dist/apps/chat-ui/assets/perl-DoVTbnzt.js +1 -0
- package/dist/apps/chat-ui/assets/pig-CULXT1YV.js +1 -0
- package/dist/apps/chat-ui/assets/powershell-Cv5Uhf6b.js +1 -0
- package/dist/apps/chat-ui/assets/properties-CQ1C2P-M.js +1 -0
- package/dist/apps/chat-ui/assets/protobuf-SRlvzrl6.js +1 -0
- package/dist/apps/chat-ui/assets/pug-Bo3wfL-f.js +1 -0
- package/dist/apps/chat-ui/assets/puppet-ClSqCGj6.js +1 -0
- package/dist/apps/chat-ui/assets/python-C2_X1GpX.js +1 -0
- package/dist/apps/chat-ui/assets/q-B_6Gdyzl.js +1 -0
- package/dist/apps/chat-ui/assets/r-BD07NGED.js +1 -0
- package/dist/apps/chat-ui/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/apps/chat-ui/assets/rpm-CRu5Z2Jl.js +1 -0
- package/dist/apps/chat-ui/assets/ruby-dZPnOz8h.js +1 -0
- package/dist/apps/chat-ui/assets/sas-S2t8_sDI.js +1 -0
- package/dist/apps/chat-ui/assets/scheme-WcyFWLW2.js +1 -0
- package/dist/apps/chat-ui/assets/shell-DUelnYSh.js +1 -0
- package/dist/apps/chat-ui/assets/sieve-jDjlVhNh.js +1 -0
- package/dist/apps/chat-ui/assets/simple-mode-CL04yRVp.js +1 -0
- package/dist/apps/chat-ui/assets/smalltalk-ddWDYy10.js +1 -0
- package/dist/apps/chat-ui/assets/solr-C7rQhLuW.js +1 -0
- package/dist/apps/chat-ui/assets/sparql--fPCCgVd.js +1 -0
- package/dist/apps/chat-ui/assets/spreadsheet-DjthqD5G.js +1 -0
- package/dist/apps/chat-ui/assets/sql-D_dieYbr.js +1 -0
- package/dist/apps/chat-ui/assets/stex-rHcFYcA0.js +1 -0
- package/dist/apps/chat-ui/assets/stylus-DxF70RNr.js +1 -0
- package/dist/apps/chat-ui/assets/swift-T0hDoOb-.js +1 -0
- package/dist/apps/chat-ui/assets/tcl-Dlzy1mPk.js +1 -0
- package/dist/apps/chat-ui/assets/textile-Dy5rFZe5.js +1 -0
- package/dist/apps/chat-ui/assets/tiddlywiki-DQP1OymS.js +1 -0
- package/dist/apps/chat-ui/assets/tiki-0vOj3DB2.js +1 -0
- package/dist/apps/chat-ui/assets/toml-DEltN0lI.js +1 -0
- package/dist/apps/chat-ui/assets/troff-CRbBpEqY.js +1 -0
- package/dist/apps/chat-ui/assets/ttcn-M5q1nLKg.js +1 -0
- package/dist/apps/chat-ui/assets/ttcn-cfg-Rmw9NWq9.js +1 -0
- package/dist/apps/chat-ui/assets/turtle-BCDWhJK0.js +1 -0
- package/dist/apps/chat-ui/assets/vb-QQ7LGlOz.js +1 -0
- package/dist/apps/chat-ui/assets/vbscript-BiSEdUzz.js +1 -0
- package/dist/apps/chat-ui/assets/velocity-CzMg5_6w.js +1 -0
- package/dist/apps/chat-ui/assets/verilog-BJOO83gk.js +1 -0
- package/dist/apps/chat-ui/assets/vhdl-ed4zAZAA.js +1 -0
- package/dist/apps/chat-ui/assets/webidl-Ddy6hbV6.js +1 -0
- package/dist/apps/chat-ui/assets/xquery-Bw1zwhh6.js +1 -0
- package/dist/apps/chat-ui/assets/yacas-DZdTXy3s.js +1 -0
- package/dist/apps/chat-ui/assets/z80-DMG02_YV.js +1 -0
- package/dist/apps/chat-ui/index.html +15 -0
- package/dist/apps/context-files-ui/assets/apl-14BqhLYK.js +1 -0
- package/dist/apps/context-files-ui/assets/asciiarmor-WLvjqI7d.js +1 -0
- package/dist/apps/context-files-ui/assets/asn1-Bg4FbdCg.js +1 -0
- package/dist/apps/context-files-ui/assets/asterisk-B2MO-X4d.js +1 -0
- package/dist/apps/context-files-ui/assets/brainfuck-CV9kufud.js +1 -0
- package/dist/apps/context-files-ui/assets/clike-CjmcUpt6.js +1 -0
- package/dist/apps/context-files-ui/assets/clojure-De3QGfx6.js +1 -0
- package/dist/apps/context-files-ui/assets/cmake-i2VDNaRq.js +1 -0
- package/dist/apps/context-files-ui/assets/cobol-BwO6DF08.js +1 -0
- package/dist/apps/context-files-ui/assets/coffeescript-BtivDvRz.js +1 -0
- package/dist/apps/context-files-ui/assets/commonlisp-DFkEQdLP.js +1 -0
- package/dist/apps/context-files-ui/assets/crystal-CU0NkcVL.js +1 -0
- package/dist/apps/context-files-ui/assets/css-CbMZAQ1W.js +1 -0
- package/dist/apps/context-files-ui/assets/cypher-Dke5QOzv.js +1 -0
- package/dist/apps/context-files-ui/assets/d-TPqSVaHM.js +1 -0
- package/dist/apps/context-files-ui/assets/diff-B365LSoZ.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-B5PTVnox.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-B5ZAfwf5.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-BJW3917N.js +11 -0
- package/dist/apps/context-files-ui/assets/dist-BkUONE3N.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-CKQF1zEu.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-CwbH_3RN.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-CxRLRmMx.js +2 -0
- package/dist/apps/context-files-ui/assets/dist-D1KyNDg5.js +13 -0
- package/dist/apps/context-files-ui/assets/dist-DFi2YGux.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DKoyMSNr.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DLMjd26T.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DQXzt2Ng.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DotDq_kD.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DyfSeBMu.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-MyZgX9K2.js +9 -0
- package/dist/apps/context-files-ui/assets/dist-QQuDy4KA.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-YwR9dpb-.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-dTBsFYAl.js +1 -0
- package/dist/apps/context-files-ui/assets/dockerfile-CJb2sekW.js +1 -0
- package/dist/apps/context-files-ui/assets/dtd-CBMymJ7O.js +1 -0
- package/dist/apps/context-files-ui/assets/dylan-08Azy1NK.js +1 -0
- package/dist/apps/context-files-ui/assets/ebnf-Dkum_1J8.js +1 -0
- package/dist/apps/context-files-ui/assets/ecl-dhxjHL8y.js +1 -0
- package/dist/apps/context-files-ui/assets/eiffel-C446m6dI.js +1 -0
- package/dist/apps/context-files-ui/assets/elm-po1E9de0.js +1 -0
- package/dist/apps/context-files-ui/assets/erlang-BD5LkVkR.js +1 -0
- package/dist/apps/context-files-ui/assets/factor-B2EMQZkP.js +1 -0
- package/dist/apps/context-files-ui/assets/fcl-DkEOamHd.js +1 -0
- package/dist/apps/context-files-ui/assets/forth-dCg2_HVB.js +1 -0
- package/dist/apps/context-files-ui/assets/fortran-3ZpXLFh1.js +1 -0
- package/dist/apps/context-files-ui/assets/gas-DMmxLZRI.js +1 -0
- package/dist/apps/context-files-ui/assets/gherkin-DUSFg2R6.js +1 -0
- package/dist/apps/context-files-ui/assets/groovy-Cmduloe1.js +1 -0
- package/dist/apps/context-files-ui/assets/haskell-Cyr255R9.js +1 -0
- package/dist/apps/context-files-ui/assets/haxe-BJVKtprM.js +1 -0
- package/dist/apps/context-files-ui/assets/http-DszHFpc-.js +1 -0
- package/dist/apps/context-files-ui/assets/idl-Cati9Nrv.js +1 -0
- package/dist/apps/context-files-ui/assets/index-BwRDoHMC.css +1 -0
- package/dist/apps/context-files-ui/assets/index-GwvjXytt.js +202 -0
- package/dist/apps/context-files-ui/assets/javascript-C5pDVaoP.js +1 -0
- package/dist/apps/context-files-ui/assets/julia-DlqY1cTU.js +1 -0
- package/dist/apps/context-files-ui/assets/livescript-C6p8-2W1.js +1 -0
- package/dist/apps/context-files-ui/assets/lua-BxuTHaF7.js +1 -0
- package/dist/apps/context-files-ui/assets/mathematica-nDHZUMJT.js +1 -0
- package/dist/apps/context-files-ui/assets/mbox-DAaR0Hcz.js +1 -0
- package/dist/apps/context-files-ui/assets/mirc-CCA0FRfl.js +1 -0
- package/dist/apps/context-files-ui/assets/mllike-Cw3Iccsb.js +1 -0
- package/dist/apps/context-files-ui/assets/modelica-Czx80fNR.js +1 -0
- package/dist/apps/context-files-ui/assets/mscgen-BmfuTbzG.js +1 -0
- package/dist/apps/context-files-ui/assets/mumps-Ds_ZaumL.js +1 -0
- package/dist/apps/context-files-ui/assets/nginx-D9M2PQ4U.js +1 -0
- package/dist/apps/context-files-ui/assets/nsis-DOo3SJmd.js +1 -0
- package/dist/apps/context-files-ui/assets/ntriples-DLHGTvHs.js +1 -0
- package/dist/apps/context-files-ui/assets/octave-8jj96JiC.js +1 -0
- package/dist/apps/context-files-ui/assets/oz-BmMq7iC4.js +1 -0
- package/dist/apps/context-files-ui/assets/pascal-BgMr6XpT.js +1 -0
- package/dist/apps/context-files-ui/assets/perl-D6YJObi_.js +1 -0
- package/dist/apps/context-files-ui/assets/pig-nx7uchs8.js +1 -0
- package/dist/apps/context-files-ui/assets/powershell-B4IPkVxR.js +1 -0
- package/dist/apps/context-files-ui/assets/properties-CoavQdLC.js +1 -0
- package/dist/apps/context-files-ui/assets/protobuf-D5EWhcmc.js +1 -0
- package/dist/apps/context-files-ui/assets/pug-QU72BPAa.js +1 -0
- package/dist/apps/context-files-ui/assets/puppet-B_0GFuyD.js +1 -0
- package/dist/apps/context-files-ui/assets/python-Cs7sNzy_.js +1 -0
- package/dist/apps/context-files-ui/assets/q-BIB9pPtI.js +1 -0
- package/dist/apps/context-files-ui/assets/r-CN5s4f3o.js +1 -0
- package/dist/apps/context-files-ui/assets/rpm-Ct_Ck8mQ.js +1 -0
- package/dist/apps/context-files-ui/assets/ruby-BVPradRk.js +1 -0
- package/dist/apps/context-files-ui/assets/sas-DN4j74IF.js +1 -0
- package/dist/apps/context-files-ui/assets/scheme-CvNgHAnh.js +1 -0
- package/dist/apps/context-files-ui/assets/shell-BjiMLAaM.js +1 -0
- package/dist/apps/context-files-ui/assets/sieve-C2U1O5Z4.js +1 -0
- package/dist/apps/context-files-ui/assets/simple-mode-DnMbQuKW.js +1 -0
- package/dist/apps/context-files-ui/assets/smalltalk-DkYwYufV.js +1 -0
- package/dist/apps/context-files-ui/assets/solr-BopnSD-v.js +1 -0
- package/dist/apps/context-files-ui/assets/sparql-Cpg3YQfd.js +1 -0
- package/dist/apps/context-files-ui/assets/spreadsheet-kRxtVt9J.js +1 -0
- package/dist/apps/context-files-ui/assets/sql-DYI2GwJR.js +1 -0
- package/dist/apps/context-files-ui/assets/stex-BCRT8IJ3.js +1 -0
- package/dist/apps/context-files-ui/assets/stylus-CARoeVE9.js +1 -0
- package/dist/apps/context-files-ui/assets/swift-DKNaLAK6.js +1 -0
- package/dist/apps/context-files-ui/assets/tcl-CQyXkgMH.js +1 -0
- package/dist/apps/context-files-ui/assets/textile-Yg_UWn-t.js +1 -0
- package/dist/apps/context-files-ui/assets/tiddlywiki-dqVbkfX4.js +1 -0
- package/dist/apps/context-files-ui/assets/tiki-CC_ic8g0.js +1 -0
- package/dist/apps/context-files-ui/assets/toml-B7gGzVkJ.js +1 -0
- package/dist/apps/context-files-ui/assets/troff-Bq3z6oAu.js +1 -0
- package/dist/apps/context-files-ui/assets/ttcn-GvRgs2AT.js +1 -0
- package/dist/apps/context-files-ui/assets/ttcn-cfg-CGCXz7Vo.js +1 -0
- package/dist/apps/context-files-ui/assets/turtle-CwIpz2yy.js +1 -0
- package/dist/apps/context-files-ui/assets/vb-BmcHUM2C.js +1 -0
- package/dist/apps/context-files-ui/assets/vbscript-Cs9dylre.js +1 -0
- package/dist/apps/context-files-ui/assets/velocity-CBWU0VCy.js +1 -0
- package/dist/apps/context-files-ui/assets/verilog-DVCHmufx.js +1 -0
- package/dist/apps/context-files-ui/assets/vhdl-BGDk4f1d.js +1 -0
- package/dist/apps/context-files-ui/assets/webidl-egXQEWlC.js +1 -0
- package/dist/apps/context-files-ui/assets/xquery-5f0hn7cg.js +1 -0
- package/dist/apps/context-files-ui/assets/yacas-DNs9XkmQ.js +1 -0
- package/dist/apps/context-files-ui/assets/z80-B7Dfb4UO.js +1 -0
- package/dist/apps/context-files-ui/index.html +14 -0
- package/dist/auth/better-auth.js +129 -0
- package/dist/auth/types.js +14 -0
- package/dist/bin/pibo.js +3 -0
- package/dist/channels/types.js +1 -0
- package/dist/cli-errors.js +18 -0
- package/dist/cli.js +264 -0
- package/dist/config/config.js +167 -0
- package/dist/core/base-prompt.js +104 -0
- package/dist/core/codex-compat.js +44 -0
- package/dist/core/compaction-prompt.js +258 -0
- package/dist/core/events.js +1 -0
- package/dist/core/profiles.js +138 -0
- package/dist/core/routed-session.js +538 -0
- package/dist/core/runtime.js +323 -0
- package/dist/core/session-router.js +437 -0
- package/dist/core/system-prompt-template.js +56 -0
- package/dist/core/thinking.js +9 -0
- package/dist/core/workspace.js +5 -0
- package/dist/debug/events.js +92 -0
- package/dist/debug/index.js +631 -0
- package/dist/debug/session.js +200 -0
- package/dist/debug/sql.js +238 -0
- package/dist/debug/stores.js +49 -0
- package/dist/debug/trace.js +245 -0
- package/dist/env.js +32 -0
- package/dist/gateway/client.js +200 -0
- package/dist/gateway/protocol.js +46 -0
- package/dist/gateway/request.js +146 -0
- package/dist/gateway/server.js +221 -0
- package/dist/gateway/tool.js +69 -0
- package/dist/gateway/web.js +80 -0
- package/dist/index.js +23 -0
- package/dist/local/client.js +77 -0
- package/dist/local/extension.js +548 -0
- package/dist/local/tui.js +25 -0
- package/dist/mcp/agent-context.js +123 -0
- package/dist/mcp/client.js +332 -0
- package/dist/mcp/commands/call.js +146 -0
- package/dist/mcp/commands/grep.js +145 -0
- package/dist/mcp/commands/info.js +71 -0
- package/dist/mcp/commands/list.js +94 -0
- package/dist/mcp/config-command.js +217 -0
- package/dist/mcp/config.js +440 -0
- package/dist/mcp/daemon-client.js +266 -0
- package/dist/mcp/daemon.js +327 -0
- package/dist/mcp/errors.js +287 -0
- package/dist/mcp/index.js +431 -0
- package/dist/mcp/output.js +171 -0
- package/dist/mcp/python-runtime.js +131 -0
- package/dist/mcp/registry.js +116 -0
- package/dist/mcp/version.js +5 -0
- package/dist/pi-packages/cli.js +92 -0
- package/dist/pi-packages/installer.js +70 -0
- package/dist/pi-packages/metadata.js +231 -0
- package/dist/pi-packages/runtime.js +61 -0
- package/dist/pi-packages/store.js +175 -0
- package/dist/pi-packages/types.js +1 -0
- package/dist/plugins/better-auth.js +11 -0
- package/dist/plugins/builtin.js +249 -0
- package/dist/plugins/chat-web.js +11 -0
- package/dist/plugins/codex-compat.js +72 -0
- package/dist/plugins/context-files-store.js +354 -0
- package/dist/plugins/context-files.js +999 -0
- package/dist/plugins/core-tools.js +94 -0
- package/dist/plugins/example.js +67 -0
- package/dist/plugins/registry.js +368 -0
- package/dist/plugins/remote-agent.js +9 -0
- package/dist/plugins/types.js +1 -0
- package/dist/plugins/web.js +11 -0
- package/dist/reliability/store.js +759 -0
- package/dist/remote/channel.js +176 -0
- package/dist/remote/client.js +92 -0
- package/dist/remote/examples/tui-controller.js +263 -0
- package/dist/remote/protocol.js +55 -0
- package/dist/remote/session-client.js +189 -0
- package/dist/runs/registry.js +323 -0
- package/dist/runs/tools.js +185 -0
- package/dist/sessions/bindings.js +41 -0
- package/dist/sessions/sqlite-store.js +154 -0
- package/dist/sessions/store.js +125 -0
- package/dist/shared/trace-order.js +83 -0
- package/dist/subagents/tool.js +63 -0
- package/dist/tools/browser-use-cdp.js +207 -0
- package/dist/tools/browser-use-leases.js +338 -0
- package/dist/tools/browser-use-wrapper.js +338 -0
- package/dist/tools/codex-compat.js +85 -0
- package/dist/tools/desktop-env.js +90 -0
- package/dist/tools/guides.js +276 -0
- package/dist/tools/index.js +366 -0
- package/dist/tools/python-runtime.js +154 -0
- package/dist/tools/registry.js +107 -0
- package/dist/tools/web-search.js +137 -0
- package/dist/web/auth.js +10 -0
- package/dist/web/channel.js +151 -0
- package/dist/web/http.js +110 -0
- package/dist/web/types.js +1 -0
- package/package.json +74 -0
- 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
|
+
}
|