@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,538 @@
|
|
|
1
|
+
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
function errorMessage(error) {
|
|
3
|
+
return error instanceof Error ? error.message : String(error);
|
|
4
|
+
}
|
|
5
|
+
function messageContentIndex(candidate) {
|
|
6
|
+
return typeof candidate.assistantMessageEvent?.contentIndex === "number"
|
|
7
|
+
? candidate.assistantMessageEvent.contentIndex
|
|
8
|
+
: undefined;
|
|
9
|
+
}
|
|
10
|
+
function promptSource(source) {
|
|
11
|
+
return source === "user" || source === "ui" ? "interactive" : "rpc";
|
|
12
|
+
}
|
|
13
|
+
function lastTextPartFromMessage(message) {
|
|
14
|
+
if (!message || typeof message !== "object")
|
|
15
|
+
return undefined;
|
|
16
|
+
const content = message.content;
|
|
17
|
+
if (!Array.isArray(content))
|
|
18
|
+
return undefined;
|
|
19
|
+
for (let index = content.length - 1; index >= 0; index -= 1) {
|
|
20
|
+
const part = content[index];
|
|
21
|
+
if (!part || typeof part !== "object")
|
|
22
|
+
continue;
|
|
23
|
+
const candidate = part;
|
|
24
|
+
if (candidate.type === "text" && typeof candidate.text === "string" && candidate.text.length > 0) {
|
|
25
|
+
return { text: candidate.text, contentIndex: index };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function toolCallFromMessage(message, contentIndex) {
|
|
31
|
+
if (!message || typeof message !== "object" || typeof contentIndex !== "number")
|
|
32
|
+
return undefined;
|
|
33
|
+
const content = message.content;
|
|
34
|
+
if (!Array.isArray(content))
|
|
35
|
+
return undefined;
|
|
36
|
+
const candidate = content[contentIndex];
|
|
37
|
+
if (!candidate || typeof candidate !== "object")
|
|
38
|
+
return undefined;
|
|
39
|
+
const toolCall = candidate;
|
|
40
|
+
if (toolCall.type !== "toolCall" || typeof toolCall.id !== "string" || typeof toolCall.name !== "string") {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return { id: toolCall.id, name: toolCall.name, args: toolCall.arguments ?? {} };
|
|
44
|
+
}
|
|
45
|
+
function toolCallFromAssistantEvent(candidate) {
|
|
46
|
+
const eventToolCall = candidate.assistantMessageEvent?.toolCall;
|
|
47
|
+
if (eventToolCall && typeof eventToolCall.id === "string" && typeof eventToolCall.name === "string") {
|
|
48
|
+
return { id: eventToolCall.id, name: eventToolCall.name, args: eventToolCall.arguments ?? {} };
|
|
49
|
+
}
|
|
50
|
+
return toolCallFromMessage(candidate.message, candidate.assistantMessageEvent?.contentIndex);
|
|
51
|
+
}
|
|
52
|
+
function normalizeToolCallEvent(piboSessionId, candidate) {
|
|
53
|
+
if (candidate.type === "message_update" &&
|
|
54
|
+
(candidate.assistantMessageEvent?.type === "toolcall_start" ||
|
|
55
|
+
candidate.assistantMessageEvent?.type === "toolcall_end")) {
|
|
56
|
+
const toolCall = toolCallFromAssistantEvent(candidate);
|
|
57
|
+
if (!toolCall)
|
|
58
|
+
return undefined;
|
|
59
|
+
return {
|
|
60
|
+
type: "tool_call",
|
|
61
|
+
piboSessionId,
|
|
62
|
+
toolCallId: toolCall.id,
|
|
63
|
+
toolName: toolCall.name,
|
|
64
|
+
args: toolCall.args,
|
|
65
|
+
argsComplete: candidate.assistantMessageEvent.type === "toolcall_end",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function normalizeToolExecutionEvent(piboSessionId, candidate) {
|
|
71
|
+
if (typeof candidate.toolCallId !== "string" || typeof candidate.toolName !== "string") {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
if (candidate.type === "tool_execution_start") {
|
|
75
|
+
return {
|
|
76
|
+
type: "tool_execution_started",
|
|
77
|
+
piboSessionId,
|
|
78
|
+
toolCallId: candidate.toolCallId,
|
|
79
|
+
toolName: candidate.toolName,
|
|
80
|
+
args: candidate.args,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (candidate.type === "tool_execution_update") {
|
|
84
|
+
return {
|
|
85
|
+
type: "tool_execution_updated",
|
|
86
|
+
piboSessionId,
|
|
87
|
+
toolCallId: candidate.toolCallId,
|
|
88
|
+
toolName: candidate.toolName,
|
|
89
|
+
args: candidate.args,
|
|
90
|
+
partialResult: candidate.partialResult,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (candidate.type === "tool_execution_end") {
|
|
94
|
+
return {
|
|
95
|
+
type: "tool_execution_finished",
|
|
96
|
+
piboSessionId,
|
|
97
|
+
toolCallId: candidate.toolCallId,
|
|
98
|
+
toolName: candidate.toolName,
|
|
99
|
+
result: candidate.result,
|
|
100
|
+
isError: candidate.isError === true,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
function normalizePiEvent(piboSessionId, event) {
|
|
106
|
+
if (!event || typeof event !== "object")
|
|
107
|
+
return undefined;
|
|
108
|
+
const candidate = event;
|
|
109
|
+
if (candidate.type === "message_update" &&
|
|
110
|
+
candidate.assistantMessageEvent?.type === "text_delta" &&
|
|
111
|
+
typeof candidate.assistantMessageEvent.delta === "string") {
|
|
112
|
+
return {
|
|
113
|
+
type: "assistant_delta",
|
|
114
|
+
piboSessionId,
|
|
115
|
+
contentIndex: messageContentIndex(candidate),
|
|
116
|
+
text: candidate.assistantMessageEvent.delta,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (candidate.type === "message_update" &&
|
|
120
|
+
candidate.assistantMessageEvent?.type === "thinking_start") {
|
|
121
|
+
return { type: "thinking_started", piboSessionId, contentIndex: messageContentIndex(candidate) };
|
|
122
|
+
}
|
|
123
|
+
if (candidate.type === "message_update" &&
|
|
124
|
+
candidate.assistantMessageEvent?.type === "thinking_delta" &&
|
|
125
|
+
typeof candidate.assistantMessageEvent.delta === "string") {
|
|
126
|
+
return { type: "thinking_delta", piboSessionId, contentIndex: messageContentIndex(candidate), text: candidate.assistantMessageEvent.delta };
|
|
127
|
+
}
|
|
128
|
+
if (candidate.type === "message_update" && candidate.assistantMessageEvent?.type === "thinking_end") {
|
|
129
|
+
const text = typeof candidate.assistantMessageEvent.content === "string" ? candidate.assistantMessageEvent.content : undefined;
|
|
130
|
+
return text === undefined
|
|
131
|
+
? { type: "thinking_finished", piboSessionId, contentIndex: messageContentIndex(candidate) }
|
|
132
|
+
: { type: "thinking_finished", piboSessionId, contentIndex: messageContentIndex(candidate), text };
|
|
133
|
+
}
|
|
134
|
+
const toolCallEvent = normalizeToolCallEvent(piboSessionId, candidate);
|
|
135
|
+
if (toolCallEvent)
|
|
136
|
+
return toolCallEvent;
|
|
137
|
+
const toolExecutionEvent = normalizeToolExecutionEvent(piboSessionId, candidate);
|
|
138
|
+
if (toolExecutionEvent)
|
|
139
|
+
return toolExecutionEvent;
|
|
140
|
+
if (candidate.type === "message_end") {
|
|
141
|
+
const message = candidate.message;
|
|
142
|
+
const role = message?.role;
|
|
143
|
+
if (role === "assistant") {
|
|
144
|
+
if (message?.stopReason === "error" || typeof message?.errorMessage === "string") {
|
|
145
|
+
return {
|
|
146
|
+
type: "session_error",
|
|
147
|
+
piboSessionId,
|
|
148
|
+
error: typeof message.errorMessage === "string" && message.errorMessage.length > 0
|
|
149
|
+
? message.errorMessage
|
|
150
|
+
: "Assistant message failed.",
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const textPart = lastTextPartFromMessage(candidate.message);
|
|
154
|
+
if (textPart) {
|
|
155
|
+
return {
|
|
156
|
+
type: "assistant_message",
|
|
157
|
+
piboSessionId,
|
|
158
|
+
contentIndex: textPart.contentIndex,
|
|
159
|
+
text: textPart.text,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
export class RoutedSession {
|
|
167
|
+
piboSessionId;
|
|
168
|
+
runtime;
|
|
169
|
+
emit;
|
|
170
|
+
pluginRegistry;
|
|
171
|
+
forwardPiEvents;
|
|
172
|
+
onSessionOperation;
|
|
173
|
+
queue = [];
|
|
174
|
+
processing = false;
|
|
175
|
+
disposed = false;
|
|
176
|
+
activeMessage;
|
|
177
|
+
activeAssistantIndex;
|
|
178
|
+
nextAssistantIndex = 0;
|
|
179
|
+
activeThinkingIndex;
|
|
180
|
+
nextThinkingIndex = 0;
|
|
181
|
+
unsubscribe;
|
|
182
|
+
constructor(piboSessionId, runtime, emit, pluginRegistry, forwardPiEvents, onSessionOperation) {
|
|
183
|
+
this.piboSessionId = piboSessionId;
|
|
184
|
+
this.runtime = runtime;
|
|
185
|
+
this.emit = emit;
|
|
186
|
+
this.pluginRegistry = pluginRegistry;
|
|
187
|
+
this.forwardPiEvents = forwardPiEvents;
|
|
188
|
+
this.onSessionOperation = onSessionOperation;
|
|
189
|
+
this.bindRuntimeSession();
|
|
190
|
+
this.runtime.setRebindSession(async () => {
|
|
191
|
+
this.bindRuntimeSession();
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
bindRuntimeSession() {
|
|
195
|
+
this.unsubscribe?.();
|
|
196
|
+
this.unsubscribe = this.runtime.session.subscribe((event) => {
|
|
197
|
+
const normalized = normalizePiEvent(this.piboSessionId, event);
|
|
198
|
+
if (normalized) {
|
|
199
|
+
this.emit(this.withActiveMessage(normalized));
|
|
200
|
+
}
|
|
201
|
+
if (this.forwardPiEvents) {
|
|
202
|
+
this.emit({ type: "pi_event", piboSessionId: this.piboSessionId, event });
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
enqueueMessage(event) {
|
|
207
|
+
this.assertActive();
|
|
208
|
+
this.queue.push(event);
|
|
209
|
+
const output = {
|
|
210
|
+
type: "message_queued",
|
|
211
|
+
piboSessionId: this.piboSessionId,
|
|
212
|
+
eventId: event.id,
|
|
213
|
+
queuedMessages: this.queue.length,
|
|
214
|
+
text: event.text,
|
|
215
|
+
source: event.source,
|
|
216
|
+
};
|
|
217
|
+
this.emit(output);
|
|
218
|
+
void this.drain();
|
|
219
|
+
return output;
|
|
220
|
+
}
|
|
221
|
+
async executeAction(event) {
|
|
222
|
+
this.assertActive();
|
|
223
|
+
const result = await this.runAction(event);
|
|
224
|
+
if (isSessionOperationResult(result))
|
|
225
|
+
await this.onSessionOperation?.(result, event);
|
|
226
|
+
const output = {
|
|
227
|
+
type: "execution_result",
|
|
228
|
+
piboSessionId: this.piboSessionId,
|
|
229
|
+
eventId: event.id,
|
|
230
|
+
action: event.action,
|
|
231
|
+
result,
|
|
232
|
+
};
|
|
233
|
+
this.emit(output);
|
|
234
|
+
return output;
|
|
235
|
+
}
|
|
236
|
+
getStatus() {
|
|
237
|
+
return {
|
|
238
|
+
piboSessionId: this.piboSessionId,
|
|
239
|
+
queuedMessages: this.queue.length,
|
|
240
|
+
processing: this.processing,
|
|
241
|
+
streaming: this.runtime.session.isStreaming,
|
|
242
|
+
activeTools: this.runtime.session.getActiveToolNames(),
|
|
243
|
+
cwd: this.runtime.cwd,
|
|
244
|
+
disposed: this.disposed,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
removeQueuedMessages(predicate) {
|
|
248
|
+
this.assertActive();
|
|
249
|
+
let removed = 0;
|
|
250
|
+
for (let index = this.queue.length - 1; index >= 0; index -= 1) {
|
|
251
|
+
if (!predicate(this.queue[index]))
|
|
252
|
+
continue;
|
|
253
|
+
this.queue.splice(index, 1);
|
|
254
|
+
removed += 1;
|
|
255
|
+
}
|
|
256
|
+
return removed;
|
|
257
|
+
}
|
|
258
|
+
getCurrentSession() {
|
|
259
|
+
return this.createSessionSnapshot();
|
|
260
|
+
}
|
|
261
|
+
async listSessions() {
|
|
262
|
+
const manager = this.runtime.session.sessionManager;
|
|
263
|
+
const sessions = await SessionManager.list(this.runtime.cwd, manager.getSessionDir());
|
|
264
|
+
return sessions.map((session) => ({
|
|
265
|
+
path: session.path,
|
|
266
|
+
id: session.id,
|
|
267
|
+
cwd: session.cwd,
|
|
268
|
+
name: session.name,
|
|
269
|
+
parentSessionPath: session.parentSessionPath,
|
|
270
|
+
created: session.created.toISOString(),
|
|
271
|
+
modified: session.modified.toISOString(),
|
|
272
|
+
messageCount: session.messageCount,
|
|
273
|
+
firstMessage: session.firstMessage,
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
getForkCandidates() {
|
|
277
|
+
return this.runtime.session.getUserMessagesForForking();
|
|
278
|
+
}
|
|
279
|
+
async forkSession(entryId) {
|
|
280
|
+
this.assertActive();
|
|
281
|
+
const previous = this.createSessionSnapshot();
|
|
282
|
+
const result = await this.runtime.fork(entryId);
|
|
283
|
+
return {
|
|
284
|
+
piboSessionId: this.piboSessionId,
|
|
285
|
+
previous,
|
|
286
|
+
current: this.createSessionSnapshot(),
|
|
287
|
+
cancelled: result.cancelled,
|
|
288
|
+
selectedText: result.selectedText,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
async cloneSession() {
|
|
292
|
+
this.assertActive();
|
|
293
|
+
const leafId = this.runtime.session.sessionManager.getLeafId();
|
|
294
|
+
if (!leafId) {
|
|
295
|
+
throw new Error("Cannot clone session: no current entry selected");
|
|
296
|
+
}
|
|
297
|
+
const previous = this.createSessionSnapshot();
|
|
298
|
+
const result = await this.runtime.fork(leafId, { position: "at" });
|
|
299
|
+
return {
|
|
300
|
+
piboSessionId: this.piboSessionId,
|
|
301
|
+
previous,
|
|
302
|
+
current: this.createSessionSnapshot(),
|
|
303
|
+
cancelled: result.cancelled,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
getSessionTree() {
|
|
307
|
+
this.assertActive();
|
|
308
|
+
return {
|
|
309
|
+
current: this.createSessionSnapshot(),
|
|
310
|
+
tree: normalizeSessionTree(this.runtime.session.sessionManager.getTree()),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async navigateSessionTree(params) {
|
|
314
|
+
this.assertActive();
|
|
315
|
+
const previous = this.createSessionSnapshot();
|
|
316
|
+
const result = await this.runtime.session.navigateTree(params.entryId, {
|
|
317
|
+
summarize: params.summarize,
|
|
318
|
+
customInstructions: params.customInstructions,
|
|
319
|
+
replaceInstructions: params.replaceInstructions,
|
|
320
|
+
label: params.label,
|
|
321
|
+
});
|
|
322
|
+
return {
|
|
323
|
+
piboSessionId: this.piboSessionId,
|
|
324
|
+
previous,
|
|
325
|
+
current: this.createSessionSnapshot(),
|
|
326
|
+
cancelled: result.cancelled,
|
|
327
|
+
editorText: result.editorText,
|
|
328
|
+
summaryEntryId: result.summaryEntry?.id,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
async switchSession(params) {
|
|
332
|
+
this.assertActive();
|
|
333
|
+
const previous = this.createSessionSnapshot();
|
|
334
|
+
const result = await this.runtime.switchSession(params.sessionFile, { cwdOverride: params.cwdOverride });
|
|
335
|
+
return {
|
|
336
|
+
piboSessionId: this.piboSessionId,
|
|
337
|
+
previous,
|
|
338
|
+
current: this.createSessionSnapshot(),
|
|
339
|
+
cancelled: result.cancelled,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
setThinkingLevel(level) {
|
|
343
|
+
this.assertActive();
|
|
344
|
+
this.runtime.session.setThinkingLevel(level);
|
|
345
|
+
return this.getThinkingResult();
|
|
346
|
+
}
|
|
347
|
+
cycleThinkingLevel() {
|
|
348
|
+
this.assertActive();
|
|
349
|
+
this.runtime.session.cycleThinkingLevel();
|
|
350
|
+
return this.getThinkingResult();
|
|
351
|
+
}
|
|
352
|
+
async dispose() {
|
|
353
|
+
if (this.disposed)
|
|
354
|
+
return;
|
|
355
|
+
this.queue.length = 0;
|
|
356
|
+
this.unsubscribe?.();
|
|
357
|
+
this.unsubscribe = undefined;
|
|
358
|
+
this.disposed = true;
|
|
359
|
+
await this.runtime.dispose();
|
|
360
|
+
}
|
|
361
|
+
async cancelMessage(eventId) {
|
|
362
|
+
this.assertActive();
|
|
363
|
+
const queuedIndex = this.queue.findIndex((event) => event.id === eventId);
|
|
364
|
+
if (queuedIndex >= 0) {
|
|
365
|
+
this.queue.splice(queuedIndex, 1);
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
if (this.activeMessage?.id === eventId) {
|
|
369
|
+
await this.runtime.session.abort();
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
async drain() {
|
|
375
|
+
if (this.processing || this.disposed)
|
|
376
|
+
return;
|
|
377
|
+
this.processing = true;
|
|
378
|
+
try {
|
|
379
|
+
while (this.queue.length > 0 && !this.disposed) {
|
|
380
|
+
const event = this.queue.shift();
|
|
381
|
+
this.emit({
|
|
382
|
+
type: "message_started",
|
|
383
|
+
piboSessionId: this.piboSessionId,
|
|
384
|
+
eventId: event.id,
|
|
385
|
+
text: event.text,
|
|
386
|
+
source: event.source,
|
|
387
|
+
});
|
|
388
|
+
try {
|
|
389
|
+
this.activeMessage = event;
|
|
390
|
+
this.activeAssistantIndex = undefined;
|
|
391
|
+
this.nextAssistantIndex = 0;
|
|
392
|
+
this.activeThinkingIndex = undefined;
|
|
393
|
+
this.nextThinkingIndex = 0;
|
|
394
|
+
await this.runtime.session.prompt(event.text, { source: promptSource(event.source) });
|
|
395
|
+
this.emit({
|
|
396
|
+
type: "message_finished",
|
|
397
|
+
piboSessionId: this.piboSessionId,
|
|
398
|
+
eventId: event.id,
|
|
399
|
+
source: event.source,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
this.emit({
|
|
404
|
+
type: "session_error",
|
|
405
|
+
piboSessionId: this.piboSessionId,
|
|
406
|
+
eventId: event.id,
|
|
407
|
+
error: errorMessage(error),
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
this.activeMessage = undefined;
|
|
412
|
+
this.activeAssistantIndex = undefined;
|
|
413
|
+
this.nextAssistantIndex = 0;
|
|
414
|
+
this.activeThinkingIndex = undefined;
|
|
415
|
+
this.nextThinkingIndex = 0;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
finally {
|
|
420
|
+
this.processing = false;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async runAction(event) {
|
|
424
|
+
const action = event.action;
|
|
425
|
+
const gatewayAction = this.pluginRegistry.getGatewayAction(action);
|
|
426
|
+
if (!gatewayAction) {
|
|
427
|
+
throw new Error(`Unknown execution action "${action}"`);
|
|
428
|
+
}
|
|
429
|
+
return await gatewayAction.execute({
|
|
430
|
+
piboSessionId: this.piboSessionId,
|
|
431
|
+
getStatus: () => this.getStatus(),
|
|
432
|
+
clearQueue: () => this.clearQueue(),
|
|
433
|
+
abort: async () => {
|
|
434
|
+
await this.runtime.session.abort();
|
|
435
|
+
},
|
|
436
|
+
dispose: () => this.dispose(),
|
|
437
|
+
getCurrentSession: () => this.getCurrentSession(),
|
|
438
|
+
listSessions: () => this.listSessions(),
|
|
439
|
+
getForkCandidates: () => this.getForkCandidates(),
|
|
440
|
+
forkSession: (entryId) => this.forkSession(entryId),
|
|
441
|
+
cloneSession: () => this.cloneSession(),
|
|
442
|
+
getSessionTree: () => this.getSessionTree(),
|
|
443
|
+
navigateSessionTree: (params) => this.navigateSessionTree(params),
|
|
444
|
+
switchSession: (params) => this.switchSession(params),
|
|
445
|
+
setThinkingLevel: (level) => this.setThinkingLevel(level),
|
|
446
|
+
cycleThinkingLevel: () => this.cycleThinkingLevel(),
|
|
447
|
+
}, event);
|
|
448
|
+
}
|
|
449
|
+
assertActive() {
|
|
450
|
+
if (this.disposed) {
|
|
451
|
+
throw new Error(`Session "${this.piboSessionId}" has been disposed`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
getThinkingResult() {
|
|
455
|
+
return {
|
|
456
|
+
level: this.runtime.session.thinkingLevel,
|
|
457
|
+
availableLevels: this.runtime.session.getAvailableThinkingLevels(),
|
|
458
|
+
supported: this.runtime.session.supportsThinking(),
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
clearQueue() {
|
|
462
|
+
const cleared = this.queue.length;
|
|
463
|
+
this.queue.length = 0;
|
|
464
|
+
return cleared;
|
|
465
|
+
}
|
|
466
|
+
createSessionSnapshot() {
|
|
467
|
+
const session = this.runtime.session;
|
|
468
|
+
const manager = session.sessionManager;
|
|
469
|
+
return {
|
|
470
|
+
piSessionId: session.sessionId,
|
|
471
|
+
sessionFile: session.sessionFile,
|
|
472
|
+
leafId: manager.getLeafId(),
|
|
473
|
+
cwd: this.runtime.cwd,
|
|
474
|
+
sessionName: session.sessionName,
|
|
475
|
+
parentSessionFile: manager.getHeader()?.parentSession,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
withActiveMessage(event) {
|
|
479
|
+
if (this.activeMessage?.id && event.type === "assistant_delta") {
|
|
480
|
+
const assistantIndex = this.activeAssistantIndex ?? this.nextAssistantIndex;
|
|
481
|
+
if (this.activeAssistantIndex === undefined) {
|
|
482
|
+
this.nextAssistantIndex += 1;
|
|
483
|
+
this.activeAssistantIndex = assistantIndex;
|
|
484
|
+
}
|
|
485
|
+
return { ...event, eventId: this.activeMessage.id, assistantIndex };
|
|
486
|
+
}
|
|
487
|
+
if (this.activeMessage?.id && event.type === "assistant_message") {
|
|
488
|
+
const assistantIndex = this.activeAssistantIndex ?? this.nextAssistantIndex;
|
|
489
|
+
if (this.activeAssistantIndex === undefined) {
|
|
490
|
+
this.nextAssistantIndex += 1;
|
|
491
|
+
}
|
|
492
|
+
this.activeAssistantIndex = undefined;
|
|
493
|
+
return { ...event, eventId: this.activeMessage.id, assistantIndex };
|
|
494
|
+
}
|
|
495
|
+
if (this.activeMessage?.id && event.type === "thinking_started") {
|
|
496
|
+
const thinkingIndex = this.nextThinkingIndex;
|
|
497
|
+
this.nextThinkingIndex += 1;
|
|
498
|
+
this.activeThinkingIndex = thinkingIndex;
|
|
499
|
+
return { ...event, eventId: this.activeMessage.id, thinkingIndex };
|
|
500
|
+
}
|
|
501
|
+
if (this.activeMessage?.id && (event.type === "thinking_delta" || event.type === "thinking_finished")) {
|
|
502
|
+
const thinkingIndex = this.activeThinkingIndex ?? this.nextThinkingIndex;
|
|
503
|
+
if (this.activeThinkingIndex === undefined) {
|
|
504
|
+
this.nextThinkingIndex += 1;
|
|
505
|
+
this.activeThinkingIndex = thinkingIndex;
|
|
506
|
+
}
|
|
507
|
+
const output = { ...event, eventId: this.activeMessage.id, thinkingIndex };
|
|
508
|
+
if (event.type === "thinking_finished")
|
|
509
|
+
this.activeThinkingIndex = undefined;
|
|
510
|
+
return output;
|
|
511
|
+
}
|
|
512
|
+
if (this.activeMessage?.id &&
|
|
513
|
+
(event.type === "tool_call" ||
|
|
514
|
+
event.type === "tool_execution_started" ||
|
|
515
|
+
event.type === "tool_execution_updated" ||
|
|
516
|
+
event.type === "tool_execution_finished" ||
|
|
517
|
+
event.type === "session_error")) {
|
|
518
|
+
return { ...event, eventId: this.activeMessage.id };
|
|
519
|
+
}
|
|
520
|
+
return event;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function normalizeSessionTree(nodes) {
|
|
524
|
+
return nodes.map((node) => ({
|
|
525
|
+
entry: JSON.parse(JSON.stringify(node.entry)),
|
|
526
|
+
children: normalizeSessionTree(node.children),
|
|
527
|
+
label: node.label,
|
|
528
|
+
labelTimestamp: node.labelTimestamp,
|
|
529
|
+
}));
|
|
530
|
+
}
|
|
531
|
+
function isSessionOperationResult(value) {
|
|
532
|
+
if (!value || typeof value !== "object")
|
|
533
|
+
return false;
|
|
534
|
+
const candidate = value;
|
|
535
|
+
return (typeof candidate.piboSessionId === "string" &&
|
|
536
|
+
Boolean(candidate.current) &&
|
|
537
|
+
typeof candidate.current?.piSessionId === "string");
|
|
538
|
+
}
|