@cc-monitoring/proxy-core 0.3.0 → 0.4.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/dist/cli/__tests__/commands.test.js +1 -1
- package/dist/cli/commands/exec.js +31 -42
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.Dc46Hlqp.js → app.DtYNT5zS.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.C4sjikMO.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.Snq5jR6J.js → VPLocalSearchBox.DpXF9ZAI.js} +1 -1
- package/dist/docs/assets/chunks/{theme.XLtxGM-l.js → theme.TS_gUyc7.js} +2 -2
- package/dist/docs/assets/{proxy-cli_data-hooks.md.w9Oe1OD3.js → proxy-cli_data-hooks.md.Bz8CVbxO.js} +1 -1
- package/dist/docs/assets/{proxy-core_ui-routes.md.Dyqkeoiv.js → proxy-core_ui-routes.md.B21t1p7R.js} +1 -1
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/index.html +3 -3
- package/dist/docs/overview.html +3 -3
- package/dist/docs/packages-utils.html +3 -3
- package/dist/docs/proxy-admin/env-and-build.html +3 -3
- package/dist/docs/proxy-admin/index.html +3 -3
- package/dist/docs/proxy-admin/layout-and-menu.html +3 -3
- package/dist/docs/proxy-admin/pages.html +3 -3
- package/dist/docs/proxy-admin/routing-and-auth.html +3 -3
- package/dist/docs/proxy-admin/services-and-mock.html +3 -3
- package/dist/docs/proxy-cli/api-layer.html +3 -3
- package/dist/docs/proxy-cli/app-shell.html +3 -3
- package/dist/docs/proxy-cli/components-common.html +3 -3
- package/dist/docs/proxy-cli/components-config.html +3 -3
- package/dist/docs/proxy-cli/components-requests.html +3 -3
- package/dist/docs/proxy-cli/components-stats.html +3 -3
- package/dist/docs/proxy-cli/components-status.html +3 -3
- package/dist/docs/proxy-cli/data-hooks.html +5 -5
- package/dist/docs/proxy-cli/index.html +3 -3
- package/dist/docs/proxy-cli/utils-and-i18n.html +3 -3
- package/dist/docs/proxy-core/chat-api.html +3 -3
- package/dist/docs/proxy-core/cli.html +3 -3
- package/dist/docs/proxy-core/config.html +3 -3
- package/dist/docs/proxy-core/data-layer.html +3 -3
- package/dist/docs/proxy-core/entry.html +3 -3
- package/dist/docs/proxy-core/index.html +3 -3
- package/dist/docs/proxy-core/pm2.html +3 -3
- package/dist/docs/proxy-core/providers.html +3 -3
- package/dist/docs/proxy-core/proxy.html +3 -3
- package/dist/docs/proxy-core/stats.html +3 -3
- package/dist/docs/proxy-core/tool.html +3 -3
- package/dist/docs/proxy-core/ui-routes.html +5 -5
- package/dist/docs/proxy-core/utilities.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/request-flow.html +3 -3
- package/dist/logger/index.d.ts +0 -3
- package/dist/logger/index.js +0 -1
- package/dist/mcp-server/index.js +5 -3
- package/dist/mcp-server/tools.js +31 -10
- package/dist/server/__tests__/providers-route.test.js +1 -0
- package/dist/server/auth.d.ts +0 -1
- package/dist/server/auth.js +1 -1
- package/dist/server/chat-route.js +48 -156
- package/dist/server/data-push.d.ts +0 -1
- package/dist/server/data-push.js +0 -7
- package/dist/server/proxy.js +128 -219
- package/dist/server/ui-route.js +76 -59
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry.d.ts +0 -4
- package/dist/tools/registry.js +0 -8
- package/dist/types/config.d.ts +0 -13
- package/dist/types/pm2.d.ts +1 -2
- package/dist/ui/assets/{1c-Bx3CHH-I.js → 1c-CCx-FOtz.js} +1 -1
- package/dist/ui/assets/{abnf-NN4-iXDM.js → abnf-Bwbi42Z8.js} +1 -1
- package/dist/ui/assets/{abnfDiagram-VRR7QNED-CXFZgDk7.js → abnfDiagram-VRR7QNED-Dm1-8q0E.js} +1 -1
- package/dist/ui/assets/{accesslog-Bq9x4vSZ.js → accesslog-DCytz_-m.js} +1 -1
- package/dist/ui/assets/{actionscript-CeaB6gjT.js → actionscript-3udf15oh.js} +1 -1
- package/dist/ui/assets/{ada-DObFDSC6.js → ada-M5Xa74xG.js} +1 -1
- package/dist/ui/assets/{angelscript-4pIbuWPH.js → angelscript-qlrFxfW-.js} +1 -1
- package/dist/ui/assets/{apache-w0LzP4me.js → apache-B-sF-DQH.js} +1 -1
- package/dist/ui/assets/{applescript-DXpD6Cc9.js → applescript-4FdcBnbI.js} +1 -1
- package/dist/ui/assets/{arc-Dtt1H4m8.js → arc-BB3K1enp.js} +1 -1
- package/dist/ui/assets/{arcade-D_zU9Djr.js → arcade-B_yqWaaG.js} +1 -1
- package/dist/ui/assets/{architectureDiagram-ZJ3FMSHR-C0E_eQDM.js → architectureDiagram-ZJ3FMSHR-B39vkY8V.js} +1 -1
- package/dist/ui/assets/{arduino-BnmN_xp_.js → arduino-yAcBoTWU.js} +1 -1
- package/dist/ui/assets/{armasm-CH_xJaHf.js → armasm-wIcY84bI.js} +1 -1
- package/dist/ui/assets/{asciidoc-BlvZZ-hO.js → asciidoc-Bxnu28-Z.js} +1 -1
- package/dist/ui/assets/{aspectj-DP5DdFKQ.js → aspectj-B2cKJA_O.js} +1 -1
- package/dist/ui/assets/{autohotkey-Cy7dy_B1.js → autohotkey-B_rMWTtE.js} +1 -1
- package/dist/ui/assets/{autoit-BmQwjQdM.js → autoit-DwcuvMwv.js} +1 -1
- package/dist/ui/assets/{avrasm-fcPy4w1X.js → avrasm-heGX1PXK.js} +1 -1
- package/dist/ui/assets/{awk-AlcwGSdk.js → awk-BiqCQAEf.js} +1 -1
- package/dist/ui/assets/{axapta-NyMN6Mvz.js → axapta-Cv8M-Ih6.js} +1 -1
- package/dist/ui/assets/{bash-Bn3yyTUs.js → bash-Divgn3JV.js} +1 -1
- package/dist/ui/assets/{basic-gp9eOjjv.js → basic-B9dnAP55.js} +1 -1
- package/dist/ui/assets/{blockDiagram-677ZJIJ3-BHAadGGo.js → blockDiagram-677ZJIJ3-DQ1mf7A_.js} +1 -1
- package/dist/ui/assets/{bnf-DRAiK-_J.js → bnf-kIL5mSsP.js} +1 -1
- package/dist/ui/assets/{brainfuck-IYgPavhh.js → brainfuck-DqB7xDjH.js} +1 -1
- package/dist/ui/assets/{coq-BYVsAo31.js → c-HmsCM6sx.js} +1 -1
- package/dist/ui/assets/{c-like-B7T39dtK.js → c-like-De5MhE7G.js} +1 -1
- package/dist/ui/assets/{c4Diagram-LMCZKHZV-4cXT8R9f.js → c4Diagram-LMCZKHZV-DQxtYsAx.js} +1 -1
- package/dist/ui/assets/{cal-DmXm_WLX.js → cal-mYdfz9en.js} +1 -1
- package/dist/ui/assets/{capnproto-Cb-rKd-Z.js → capnproto-D04CRlOt.js} +1 -1
- package/dist/ui/assets/{ceylon-Bn2aNwEq.js → ceylon-pi9lFCja.js} +1 -1
- package/dist/ui/assets/channel-ChTtxQDg.js +1 -0
- package/dist/ui/assets/{chunk-2Q5K7J3B-B3N_AddF.js → chunk-2Q5K7J3B-BDD1nPt8.js} +1 -1
- package/dist/ui/assets/{chunk-32BRIVSS-CW7iU3gE.js → chunk-32BRIVSS-DgeQFBb5.js} +1 -1
- package/dist/ui/assets/{chunk-5VM5RSS4-M8Ep3dJD.js → chunk-5VM5RSS4-C7Xf2SnI.js} +1 -1
- package/dist/ui/assets/{chunk-EX3LRPZG-t2hCXH-v.js → chunk-EX3LRPZG-B_3p1HEv.js} +1 -1
- package/dist/ui/assets/{chunk-JWPE2WC7-rQK8maXo.js → chunk-JWPE2WC7-Dvs7u8eY.js} +1 -1
- package/dist/ui/assets/{chunk-MOJQB5TN-BpU7vp3L.js → chunk-MOJQB5TN-By21wDCN.js} +1 -1
- package/dist/ui/assets/{chunk-RYQCIY6F-CJVNOulR.js → chunk-RYQCIY6F-6NC700r1.js} +1 -1
- package/dist/ui/assets/{chunk-V7JOEXUC-B--maww3.js → chunk-V7JOEXUC-vEUqZ3rh.js} +1 -1
- package/dist/ui/assets/{chunk-VR4S4FIN-QJ5u9nSh.js → chunk-VR4S4FIN-6tX2dNN9.js} +1 -1
- package/dist/ui/assets/{chunk-XXDRQBXY-BcM9JOXa.js → chunk-XXDRQBXY-qDb2jxAR.js} +1 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-Ccbvamlu.js +1 -0
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-Ccbvamlu.js +1 -0
- package/dist/ui/assets/{clean-BCfhFoON.js → clean-CLCsDUl1.js} +1 -1
- package/dist/ui/assets/{clojure-DtnBj8eB.js → clojure-dVi5Xifj.js} +1 -1
- package/dist/ui/assets/{clojure-repl-D8X-urCW.js → clojure-repl-BO_FpFmF.js} +1 -1
- package/dist/ui/assets/{cmake-BH2RXBgt.js → cmake-CP5aJbyK.js} +1 -1
- package/dist/ui/assets/{coffeescript-CuoLiQ_d.js → coffeescript-ZEfu_9pF.js} +1 -1
- package/dist/ui/assets/{c-Dht0EgwX.js → coq-6aKUn3zn.js} +1 -1
- package/dist/ui/assets/{cos-t-cDfrf6.js → cos-BohCnRN2.js} +1 -1
- package/dist/ui/assets/{cose-bilkent-JH36ORCC-CYip_9u7.js → cose-bilkent-JH36ORCC-DyXCbbro.js} +1 -1
- package/dist/ui/assets/{cpp-Cgv0dQ7g.js → cpp-FOgPWPEt.js} +1 -1
- package/dist/ui/assets/{crmsh-7pr1Pq_e.js → crmsh-B0OYb-Oe.js} +1 -1
- package/dist/ui/assets/{crystal-BHZFifeV.js → crystal-CuWb_dXm.js} +1 -1
- package/dist/ui/assets/{csharp-CVMfBRGF.js → csharp-BbcqM09j.js} +1 -1
- package/dist/ui/assets/{csp-NEBRDuZY.js → csp-rgHnTaDq.js} +1 -1
- package/dist/ui/assets/{css-B0fbMkoQ.js → css-C-ibh7ZG.js} +1 -1
- package/dist/ui/assets/{cynefin-VYW2F7L2-CycR2u2l.js → cynefin-VYW2F7L2-CkuBhgC4.js} +1 -1
- package/dist/ui/assets/{cynefinDiagram-TSTJHNR4-CvXYb5em.js → cynefinDiagram-TSTJHNR4-eycFyDao.js} +1 -1
- package/dist/ui/assets/{d-AzA6F7Ab.js → d-C0gXxJ0O.js} +1 -1
- package/dist/ui/assets/{dagre-VKFMJZFB-6NuSYMRG.js → dagre-VKFMJZFB-DzqX9e49.js} +1 -1
- package/dist/ui/assets/{dart-D0VXSwKi.js → dart-C-fTpuUV.js} +1 -1
- package/dist/ui/assets/{delphi-B-bkLmCx.js → delphi-Chm0B9xv.js} +1 -1
- package/dist/ui/assets/{diagram-FQU43EPY-CNNW_5O7.js → diagram-FQU43EPY-BEgCqfg1.js} +1 -1
- package/dist/ui/assets/{diagram-G47NLZAW-C60bRph-.js → diagram-G47NLZAW-Cw11Vs2v.js} +1 -1
- package/dist/ui/assets/{diagram-NH7WQ7WH-CwERNWac.js → diagram-NH7WQ7WH-DSG_UWpP.js} +1 -1
- package/dist/ui/assets/{diagram-OA4YK3LP-9XSTmf1Z.js → diagram-OA4YK3LP-CJz-WOaJ.js} +1 -1
- package/dist/ui/assets/{diagram-WEI45ONY-h8K41_YA.js → diagram-WEI45ONY-CBXjBCvc.js} +1 -1
- package/dist/ui/assets/{diff-Ch9RlEn8.js → diff-C-vyuMSL.js} +1 -1
- package/dist/ui/assets/{django-C00rhzcB.js → django-CJK7lReT.js} +1 -1
- package/dist/ui/assets/{dns-C5MKVde0.js → dns-D02SHjSy.js} +1 -1
- package/dist/ui/assets/{dockerfile-BpRaVDMB.js → dockerfile-trKL1Bqu.js} +1 -1
- package/dist/ui/assets/{dos-CjQOJ_vn.js → dos-C52dy-sK.js} +1 -1
- package/dist/ui/assets/{dsconfig-3zd3UkyN.js → dsconfig-MzHgzVrt.js} +1 -1
- package/dist/ui/assets/{dts-Bb6PtK5T.js → dts-B137dHyX.js} +1 -1
- package/dist/ui/assets/{dust-BEJKezIa.js → dust-BcbM0r5C.js} +1 -1
- package/dist/ui/assets/{ebnf-5-TvfsoC.js → ebnf-DkbpI7bK.js} +1 -1
- package/dist/ui/assets/{ebnfDiagram-CCIWWBDH-CRmIjeas.js → ebnfDiagram-CCIWWBDH-aI5uQ7w1.js} +1 -1
- package/dist/ui/assets/{elixir-B6gSEyen.js → elixir-BOtDuqQy.js} +1 -1
- package/dist/ui/assets/{elm-rR0aqyyf.js → elm-DS8Tyyu-.js} +1 -1
- package/dist/ui/assets/{erDiagram-Q63AITRT-DS3jYOq8.js → erDiagram-Q63AITRT-2vCbd4Mm.js} +1 -1
- package/dist/ui/assets/{erb-DUu22Jxg.js → erb-CSXECRbn.js} +1 -1
- package/dist/ui/assets/{erlang-C0m-R-6W.js → erlang-BMxlgKPJ.js} +1 -1
- package/dist/ui/assets/{erlang-repl-B7O2MhlI.js → erlang-repl-DPzlolPg.js} +1 -1
- package/dist/ui/assets/{excel-CIqnqFs1.js → excel-CW2Uxed3.js} +1 -1
- package/dist/ui/assets/{fix-Ds9tcTzQ.js → fix-UW84SlCs.js} +1 -1
- package/dist/ui/assets/{flix-ByzuevTB.js → flix-4UGiPULd.js} +1 -1
- package/dist/ui/assets/{flowDiagram-23GEKE2U-B9F3S_Hl.js → flowDiagram-23GEKE2U-R5PbCbZI.js} +1 -1
- package/dist/ui/assets/{fortran-DieSVGx5.js → fortran-nhHsngdu.js} +1 -1
- package/dist/ui/assets/{fsharp-DGP8m6H3.js → fsharp-CDyZ1ST5.js} +1 -1
- package/dist/ui/assets/{gams-BiLGBohb.js → gams-DHzkkUie.js} +1 -1
- package/dist/ui/assets/{ganttDiagram-NO4QXBWP-CHiCWnJt.js → ganttDiagram-NO4QXBWP-CGcq4Ie_.js} +1 -1
- package/dist/ui/assets/{gauss-Btl1fjJ0.js → gauss-DdhFGyBv.js} +1 -1
- package/dist/ui/assets/{gcode-DWl2YoL_.js → gcode-ImHh8OLA.js} +1 -1
- package/dist/ui/assets/{gherkin-D42ESIJ2.js → gherkin-CTWAW-XR.js} +1 -1
- package/dist/ui/assets/{gitGraphDiagram-IHSO6WYX-0pEKZnJg.js → gitGraphDiagram-IHSO6WYX-8nM2Z9lD.js} +1 -1
- package/dist/ui/assets/{glsl-Dx1QhGIM.js → glsl-0_W_27G2.js} +1 -1
- package/dist/ui/assets/{gml-f0noEVTB.js → gml-BoDggu2z.js} +1 -1
- package/dist/ui/assets/{go-DXT6c-0g.js → go-DYfFygwl.js} +1 -1
- package/dist/ui/assets/{golo-D3NuJxTg.js → golo-Mlq-TCg9.js} +1 -1
- package/dist/ui/assets/{gradle-CUsTLc_e.js → gradle-BALAinEB.js} +1 -1
- package/dist/ui/assets/{groovy-BIkOcIpQ.js → groovy-Dht--dWU.js} +1 -1
- package/dist/ui/assets/{haml-C5jI7YVN.js → haml-DpMrxg0d.js} +1 -1
- package/dist/ui/assets/{handlebars-UOvbWwDx.js → handlebars-DqHzujNj.js} +1 -1
- package/dist/ui/assets/{haskell-DuO_Av2n.js → haskell-DZSchhkY.js} +1 -1
- package/dist/ui/assets/{haxe-C0Cg5Hjh.js → haxe-C0zBRjdy.js} +1 -1
- package/dist/ui/assets/{hsp-CTDajZig.js → hsp-D_PwbSv2.js} +1 -1
- package/dist/ui/assets/{htmlbars-_ITuCkOs.js → htmlbars-DxAFMG8u.js} +1 -1
- package/dist/ui/assets/{http-Dr26PHfb.js → http-DvTRF0Do.js} +1 -1
- package/dist/ui/assets/{hy-B-ThgV4T.js → hy-lVO-kNyp.js} +1 -1
- package/dist/ui/assets/{index-CpQr158p.js → index-BbMRVVGt.js} +3 -3
- package/dist/ui/assets/{index-CwcnuNUs.js → index-Ci23SMK2.js} +242 -242
- package/dist/ui/assets/index-DlsVXaHT.css +10 -0
- package/dist/ui/assets/{infoDiagram-FWYZ7A6U-ClKPOdlx.js → infoDiagram-FWYZ7A6U-C7WYDlvc.js} +1 -1
- package/dist/ui/assets/{inform7-D7JYYkX9.js → inform7-B8Tf2n8v.js} +1 -1
- package/dist/ui/assets/{ini-BZwCkFAf.js → ini-DSoYMaLF.js} +1 -1
- package/dist/ui/assets/{irpf90-omMve0rd.js → irpf90-RCPdkB14.js} +1 -1
- package/dist/ui/assets/{isbl-C4xosfum.js → isbl-C2p75PPj.js} +1 -1
- package/dist/ui/assets/{ishikawaDiagram-FXEZZL3T-PtbNBMgh.js → ishikawaDiagram-FXEZZL3T-Cm6jsPlc.js} +1 -1
- package/dist/ui/assets/{java-CWjWDe7Q.js → java-DeY4Yuia.js} +1 -1
- package/dist/ui/assets/{javascript-C3dxrGuA.js → javascript-3uX1CO-H.js} +1 -1
- package/dist/ui/assets/{jboss-cli-CJE7m0Y-.js → jboss-cli-DgnD8mEc.js} +1 -1
- package/dist/ui/assets/{journeyDiagram-5HDEW3XC-DgK9V4yg.js → journeyDiagram-5HDEW3XC-DEGV1uA5.js} +1 -1
- package/dist/ui/assets/{json-DFUiNV7v.js → json-BV2PmJJp.js} +1 -1
- package/dist/ui/assets/{julia-CUTHpx8X.js → julia-B-m8kQm7.js} +1 -1
- package/dist/ui/assets/{julia-repl-_ZaQqdrz.js → julia-repl-C51atU2X.js} +1 -1
- package/dist/ui/assets/{kanban-definition-HUTT4EX6-BFrDfKdv.js → kanban-definition-HUTT4EX6-BJ4k5iTX.js} +1 -1
- package/dist/ui/assets/{kotlin-CrYjQYp8.js → kotlin-CYBziIgl.js} +1 -1
- package/dist/ui/assets/{lasso-CAiVg9m2.js → lasso-Dw2SBMDW.js} +1 -1
- package/dist/ui/assets/{latex-BkxnXIrT.js → latex-Dpd35yke.js} +1 -1
- package/dist/ui/assets/{ldif-CBOqxiN7.js → ldif-Ce9EZU__.js} +1 -1
- package/dist/ui/assets/{leaf-CbBZyOGH.js → leaf-CpkZzQtC.js} +1 -1
- package/dist/ui/assets/{less-Ca6uLPP0.js → less-Uzo7M0FD.js} +1 -1
- package/dist/ui/assets/{lisp-0Cm7_Bzv.js → lisp-DWXDlJYm.js} +1 -1
- package/dist/ui/assets/{livecodeserver-B7ka0vFT.js → livecodeserver-uEyPEgVJ.js} +1 -1
- package/dist/ui/assets/{livescript-CGmWmcLd.js → livescript-BQ5f07oK.js} +1 -1
- package/dist/ui/assets/{llvm-DCVMvkrH.js → llvm-BAvP-skE.js} +1 -1
- package/dist/ui/assets/{lsl-PVrTScpn.js → lsl-DhbiIKu6.js} +1 -1
- package/dist/ui/assets/{lua-BTo3z2Ux.js → lua-COxeUeLx.js} +1 -1
- package/dist/ui/assets/{makefile-DJGh9r9C.js → makefile-DhDx-IgL.js} +1 -1
- package/dist/ui/assets/{markdown-BOloL-q7.js → markdown-DX5_kSxq.js} +1 -1
- package/dist/ui/assets/{mathematica-CtMMQM2V.js → mathematica-D351ZddB.js} +1 -1
- package/dist/ui/assets/{matlab-Bfg_AWdR.js → matlab-CELqIiwF.js} +1 -1
- package/dist/ui/assets/{maxima-B2cdS7BY.js → maxima-B_YljrMm.js} +1 -1
- package/dist/ui/assets/{mel-BvfPvpYI.js → mel-DltsbNS8.js} +1 -1
- package/dist/ui/assets/{mercury-B6KgNIai.js → mercury-axX-5Vjj.js} +1 -1
- package/dist/ui/assets/{mindmap-definition-LN4V7U3C-BkeXo5If.js → mindmap-definition-LN4V7U3C-Bl1EJo6p.js} +1 -1
- package/dist/ui/assets/{mipsasm-Csras-cD.js → mipsasm-BxmerVwX.js} +1 -1
- package/dist/ui/assets/{mizar-C3WDI1-X.js → mizar-XNHfbpL2.js} +1 -1
- package/dist/ui/assets/{mojolicious-MnD2Whic.js → mojolicious-BR0U_7zk.js} +1 -1
- package/dist/ui/assets/{monkey-DLvUPYTI.js → monkey-lLuu9_f-.js} +1 -1
- package/dist/ui/assets/{moonscript-B0XEb3R3.js → moonscript-DoaZ3DRQ.js} +1 -1
- package/dist/ui/assets/{n1ql-BMRF54sY.js → n1ql-C6TId6Iu.js} +1 -1
- package/dist/ui/assets/{nginx-DqUyeHb8.js → nginx-BezSG-JT.js} +1 -1
- package/dist/ui/assets/{nim-3xwg8mOL.js → nim-Bb0rfXie.js} +1 -1
- package/dist/ui/assets/{nix-ByTkLdcH.js → nix-o3sJ5-54.js} +1 -1
- package/dist/ui/assets/{node-repl-sGSuIUFG.js → node-repl-Sv5hhcTf.js} +1 -1
- package/dist/ui/assets/{nsis-Dng5mFSM.js → nsis-B45BJFhF.js} +1 -1
- package/dist/ui/assets/{objectivec-DSQ8vb7n.js → objectivec-CzS6zVgh.js} +1 -1
- package/dist/ui/assets/{ocaml-BHOhEgRu.js → ocaml-Bqux7PyP.js} +1 -1
- package/dist/ui/assets/{openscad-DcUxQ-FQ.js → openscad-4Wf6mF84.js} +1 -1
- package/dist/ui/assets/{oxygene-DNlmqhsR.js → oxygene-Fvwqgkkt.js} +1 -1
- package/dist/ui/assets/{parser3-DIR98Q6n.js → parser3-zEfzT5wv.js} +1 -1
- package/dist/ui/assets/{pegDiagram-2B236MQR-BrXp_1_9.js → pegDiagram-2B236MQR-Dd4rIztM.js} +1 -1
- package/dist/ui/assets/{perl-16cY7fyu.js → perl-CsS1Gs6o.js} +1 -1
- package/dist/ui/assets/{pf-KrAq2BW7.js → pf-BNH1jO0R.js} +1 -1
- package/dist/ui/assets/{pgsql-BV1Z2bjp.js → pgsql-DqPigHrq.js} +1 -1
- package/dist/ui/assets/{php-FGjYSZqs.js → php-CdOl9bRs.js} +1 -1
- package/dist/ui/assets/{php-template-B1OW86WT.js → php-template-DPfirJg2.js} +1 -1
- package/dist/ui/assets/{pieDiagram-ENE6RG2P-Bh0bhWSa.js → pieDiagram-ENE6RG2P-DGaJNf4S.js} +1 -1
- package/dist/ui/assets/{plaintext-Cvn_UgSv.js → plaintext-EHbgBKzw.js} +1 -1
- package/dist/ui/assets/{pony-CRWnA3MR.js → pony-DmJajtp2.js} +1 -1
- package/dist/ui/assets/{powershell-Cwn155MZ.js → powershell-DfGzdWR6.js} +1 -1
- package/dist/ui/assets/{processing-BS6-1lrQ.js → processing-BT0ETgPG.js} +1 -1
- package/dist/ui/assets/{profile-C45OLQrv.js → profile-B3I-x5Lt.js} +1 -1
- package/dist/ui/assets/{prolog-C5YafSzY.js → prolog-B_4QJIvI.js} +1 -1
- package/dist/ui/assets/{properties-BULd-Zhg.js → properties-BFVI8weS.js} +1 -1
- package/dist/ui/assets/{protobuf-Qf1IuG5l.js → protobuf-PaF39oZZ.js} +1 -1
- package/dist/ui/assets/{puppet-93XdQvnn.js → puppet-BDC6Q8VF.js} +1 -1
- package/dist/ui/assets/{purebasic-DlYNScQP.js → purebasic-B2ejrOZK.js} +1 -1
- package/dist/ui/assets/{python-D-Do6-F0.js → python-BOxtIk9H.js} +1 -1
- package/dist/ui/assets/{python-repl-DGutP04w.js → python-repl-BslBh_Mx.js} +1 -1
- package/dist/ui/assets/{q-lmgfrySy.js → q-BPe8WLGW.js} +1 -1
- package/dist/ui/assets/{qml-BbjX_mSU.js → qml-BazRR6fz.js} +1 -1
- package/dist/ui/assets/{quadrantDiagram-ABIIQ3AL-B891FOO8.js → quadrantDiagram-ABIIQ3AL-BQ7aPkHk.js} +1 -1
- package/dist/ui/assets/{r--x8NzO9N.js → r-C09pGNJC.js} +1 -1
- package/dist/ui/assets/{railroadDiagram-RFXS5EU6-R3O-GKNe.js → railroadDiagram-RFXS5EU6-sCO9VGvE.js} +1 -1
- package/dist/ui/assets/{reasonml-DwHsAflh.js → reasonml-S7dzwVL9.js} +1 -1
- package/dist/ui/assets/{requirementDiagram-TGXJPOKE-D4l_xEXt.js → requirementDiagram-TGXJPOKE-CfT5aVZg.js} +1 -1
- package/dist/ui/assets/{rib-DMJNtDwV.js → rib-fM2EwQd4.js} +1 -1
- package/dist/ui/assets/{roboconf-BNNGTvHr.js → roboconf-D7AaeyrW.js} +1 -1
- package/dist/ui/assets/{routeros-BF7SVruD.js → routeros-c6Q7mKuq.js} +1 -1
- package/dist/ui/assets/{rsl-1EHeIZqp.js → rsl-sCpEQBxh.js} +1 -1
- package/dist/ui/assets/{ruby-B-v_BYYp.js → ruby-lcKhz2w9.js} +1 -1
- package/dist/ui/assets/{ruleslanguage-GFeEMSdK.js → ruleslanguage-BW4ATOuX.js} +1 -1
- package/dist/ui/assets/{rust-ApqGtMhh.js → rust-BbpU-0VY.js} +1 -1
- package/dist/ui/assets/{sankeyDiagram-HTMAVEWB-Dc-2lhBq.js → sankeyDiagram-HTMAVEWB-CaweCpvN.js} +1 -1
- package/dist/ui/assets/{sas-YkxX6N9_.js → sas-BPt5R0dx.js} +1 -1
- package/dist/ui/assets/{scala-BpHi86GZ.js → scala-DxW_vqXs.js} +1 -1
- package/dist/ui/assets/{scheme-D889qY8Y.js → scheme-T2Q_jWzT.js} +1 -1
- package/dist/ui/assets/{scilab-C3l-bcRx.js → scilab-DMORg9lV.js} +1 -1
- package/dist/ui/assets/{scss-D0iGASxm.js → scss-t0VsosqT.js} +1 -1
- package/dist/ui/assets/{sequenceDiagram-DBY2YBRQ-DvppgciC.js → sequenceDiagram-DBY2YBRQ-o-H_R4zb.js} +1 -1
- package/dist/ui/assets/{shell-PUnaEPCO.js → shell-CnCDa1s9.js} +1 -1
- package/dist/ui/assets/{sizeCapture-X5ZJPWSS-DhvIbxXs.js → sizeCapture-X5ZJPWSS-BNLkHGDS.js} +1 -1
- package/dist/ui/assets/{smali-Du_dF9hl.js → smali-_n-BxJyG.js} +1 -1
- package/dist/ui/assets/{smalltalk-CSr2Gc1v.js → smalltalk-B90PXJwK.js} +1 -1
- package/dist/ui/assets/{sml-D3zkvzP2.js → sml-fuY7bj-n.js} +1 -1
- package/dist/ui/assets/{sqf-BZQ34qEZ.js → sqf-COpwkyuo.js} +1 -1
- package/dist/ui/assets/{sql-BFKScMsf.js → sql-CXIT0j-x.js} +1 -1
- package/dist/ui/assets/{sql_more-C2Lc_Qqq.js → sql_more-C1Oxq4rx.js} +1 -1
- package/dist/ui/assets/{stan-CzY8VdxU.js → stan-BZEpaHeC.js} +1 -1
- package/dist/ui/assets/{stata-9GxyhPpV.js → stata-CkBwaiZM.js} +1 -1
- package/dist/ui/assets/{stateDiagram-2N3HPSRC-CM63y6f0.js → stateDiagram-2N3HPSRC-BkdnNF7I.js} +1 -1
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-0JnZ1VSQ.js +1 -0
- package/dist/ui/assets/{step21-BpK_Zw3v.js → step21-fs9N_U3O.js} +1 -1
- package/dist/ui/assets/{stylus-DQ4k28M4.js → stylus-Bs_9cvKZ.js} +1 -1
- package/dist/ui/assets/{subunit-C6ciOPNF.js → subunit-DvgcOCqJ.js} +1 -1
- package/dist/ui/assets/{swift-CJfqqSbT.js → swift-BE4ONsur.js} +1 -1
- package/dist/ui/assets/{swimlanes-5IMT3BWC-DS6_HNF7.js → swimlanes-5IMT3BWC-uqTAc7o7.js} +2 -2
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-DQRIIEmi.js +8 -0
- package/dist/ui/assets/{taggerscript-VouMmJ_v.js → taggerscript-BhmPJ64C.js} +1 -1
- package/dist/ui/assets/{tap-wXCy18ot.js → tap-DkueIVKV.js} +1 -1
- package/dist/ui/assets/{tcl-ewDOmCFX.js → tcl-DyXOOkFi.js} +1 -1
- package/dist/ui/assets/{thrift-BfFA03rE.js → thrift-Dhgbk56T.js} +1 -1
- package/dist/ui/assets/{timeline-definition-FHXFAJF6-Dz2m6S6x.js → timeline-definition-FHXFAJF6-DBAk9Ouc.js} +1 -1
- package/dist/ui/assets/{tp-HGBcpNf9.js → tp-BsXyrRGH.js} +1 -1
- package/dist/ui/assets/{twig-nrQZ0pw8.js → twig-J0HqIuHw.js} +1 -1
- package/dist/ui/assets/{typescript-B7tNYFEQ.js → typescript-Dkwvul39.js} +1 -1
- package/dist/ui/assets/{vala-BIjQtoo6.js → vala-CRGnf8aY.js} +1 -1
- package/dist/ui/assets/{vbnet-Bbspccm6.js → vbnet-BtJAUe3z.js} +1 -1
- package/dist/ui/assets/{vbscript-C45_QgOy.js → vbscript-RgFFNuM3.js} +1 -1
- package/dist/ui/assets/{vbscript-html-DlF2QBc7.js → vbscript-html-DO32Io9Y.js} +1 -1
- package/dist/ui/assets/{vennDiagram-L72KCM5P-BPEphYtX.js → vennDiagram-L72KCM5P-BJi6y0hh.js} +1 -1
- package/dist/ui/assets/{verilog-BSitd8W0.js → verilog-C4h6MLcI.js} +1 -1
- package/dist/ui/assets/{vhdl-C1bbeiC4.js → vhdl-DOafePyU.js} +1 -1
- package/dist/ui/assets/{vim-DchwbT8X.js → vim-BAdTA9TY.js} +1 -1
- package/dist/ui/assets/{wardleyDiagram-EHGQE667-BttTCoBT.js → wardleyDiagram-EHGQE667-C7c_4IJ6.js} +1 -1
- package/dist/ui/assets/{x86asm-vARxMUvn.js → x86asm-BCL6__QH.js} +1 -1
- package/dist/ui/assets/{xl-dx63vvXo.js → xl-qIzE4HOe.js} +1 -1
- package/dist/ui/assets/{xml-BUnj27wL.js → xml-DE2sJXYU.js} +1 -1
- package/dist/ui/assets/{xquery-T7gpnf0e.js → xquery-CQ35t92y.js} +1 -1
- package/dist/ui/assets/{xychartDiagram-FW5EYKEG-BfrNhdrG.js → xychartDiagram-FW5EYKEG-D2ILn0jL.js} +1 -1
- package/dist/ui/assets/{yaml-xRgQKzeL.js → yaml-5KaAvG5C.js} +1 -1
- package/dist/ui/assets/{zephir-Yu6l5qJj.js → zephir-CbR3Ryfq.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/__tests__/abort-signals.test.js +67 -0
- package/dist/utils/__tests__/inject-loop.test.js +1 -53
- package/dist/utils/__tests__/learn-tasks-db.test.js +82 -0
- package/dist/utils/__tests__/openai-converter.test.js +25 -0
- package/dist/utils/__tests__/pi-crawl-tools.test.js +15 -4
- package/dist/utils/__tests__/pi-dedup-reconcile.test.js +11 -9
- package/dist/utils/__tests__/pi-events.test.js +172 -0
- package/dist/utils/__tests__/pi-learn-orchestrator.test.js +216 -6
- package/dist/utils/__tests__/pi-runtime-json.test.js +38 -3
- package/dist/utils/__tests__/providers-db.test.js +40 -2
- package/dist/utils/__tests__/request-writer.test.js +271 -39
- package/dist/utils/__tests__/sse-protocol.test.d.ts +1 -0
- package/dist/utils/__tests__/sse-protocol.test.js +115 -0
- package/dist/utils/__tests__/vault.test.d.ts +1 -0
- package/dist/utils/__tests__/{knowledge-store.test.js → vault.test.js} +16 -16
- package/dist/utils/abort-signals.d.ts +13 -0
- package/dist/utils/abort-signals.js +33 -0
- package/dist/utils/db.d.ts +2 -0
- package/dist/utils/db.js +42 -0
- package/dist/utils/esm-dirname.d.ts +0 -15
- package/dist/utils/esm-dirname.js +0 -4
- package/dist/utils/inject-loop.d.ts +0 -27
- package/dist/utils/inject-loop.js +2 -56
- package/dist/utils/learn-tasks-db.d.ts +15 -0
- package/dist/utils/learn-tasks-db.js +35 -0
- package/dist/utils/openai-converter.js +88 -78
- package/dist/utils/pi-browser-tools.d.ts +0 -2
- package/dist/utils/pi-browser-tools.js +0 -174
- package/dist/utils/pi-crawl-tools.d.ts +2 -1
- package/dist/utils/pi-crawl-tools.js +16 -11
- package/dist/utils/pi-dedup.d.ts +8 -30
- package/dist/utils/pi-dedup.js +32 -67
- package/dist/utils/pi-events.d.ts +65 -0
- package/dist/utils/pi-events.js +98 -0
- package/dist/utils/pi-learn-orchestrator.d.ts +6 -5
- package/dist/utils/pi-learn-orchestrator.js +71 -106
- package/dist/utils/pi-runtime.d.ts +5 -6
- package/dist/utils/pi-runtime.js +38 -42
- package/dist/utils/pi-sandbox-ops.d.ts +0 -36
- package/dist/utils/pi-sandbox-ops.js +5 -190
- package/dist/utils/providers-db.d.ts +3 -0
- package/dist/utils/providers-db.js +21 -7
- package/dist/utils/request-writer.d.ts +60 -30
- package/dist/utils/request-writer.js +182 -61
- package/dist/utils/sse-protocol.d.ts +34 -0
- package/dist/utils/sse-protocol.js +121 -0
- package/dist/utils/sse-stream-processor.d.ts +4 -9
- package/dist/utils/sse-stream-processor.js +13 -104
- package/dist/utils/sse-writer.d.ts +1 -1
- package/dist/utils/sse-writer.js +3 -2
- package/dist/utils/stats-aggregator.js +3 -0
- package/dist/utils/tool-injector.js +7 -0
- package/dist/utils/vault.d.ts +111 -0
- package/dist/utils/vault.js +434 -0
- package/package.json +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BN6hB8Jr.js +0 -1
- package/dist/types/api.d.ts +0 -20
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -4
- package/dist/types/log.d.ts +0 -13
- package/dist/ui/assets/channel-BgAIihW-.js +0 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-0fsnUoNI.js +0 -1
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-0fsnUoNI.js +0 -1
- package/dist/ui/assets/index-C0fxlU9d.css +0 -10
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-OA9dcuA9.js +0 -1
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-BLEnJU_R.js +0 -8
- package/dist/utils/__tests__/sse-accumulator.test.js +0 -83
- package/dist/utils/knowledge-store.d.ts +0 -44
- package/dist/utils/knowledge-store.js +0 -193
- package/dist/utils/migrate-files-to-db.d.ts +0 -1
- package/dist/utils/migrate-files-to-db.js +0 -138
- package/dist/utils/sse-accumulator.d.ts +0 -9
- package/dist/utils/sse-accumulator.js +0 -59
- /package/dist/docs/assets/{proxy-cli_data-hooks.md.w9Oe1OD3.lean.js → proxy-cli_data-hooks.md.Bz8CVbxO.lean.js} +0 -0
- /package/dist/docs/assets/{proxy-core_ui-routes.md.Dyqkeoiv.lean.js → proxy-core_ui-routes.md.B21t1p7R.lean.js} +0 -0
- /package/dist/{types/api.js → utils/__tests__/abort-signals.test.d.ts} +0 -0
- /package/dist/{types/log.js → utils/__tests__/learn-tasks-db.test.d.ts} +0 -0
- /package/dist/utils/__tests__/{knowledge-store.test.d.ts → openai-converter.test.d.ts} +0 -0
- /package/dist/utils/__tests__/{sse-accumulator.test.d.ts → pi-events.test.d.ts} +0 -0
package/dist/utils/pi-runtime.js
CHANGED
|
@@ -8,12 +8,13 @@ import path from 'node:path';
|
|
|
8
8
|
import os from 'node:os';
|
|
9
9
|
import { Type } from 'typebox';
|
|
10
10
|
import { createAgentSession, DefaultResourceLoader, ModelRuntime, createWriteToolDefinition, } from '@earendil-works/pi-coding-agent';
|
|
11
|
-
import { dataDir } from './paths.js';
|
|
12
11
|
import { sandboxWriteOps } from './pi-sandbox-ops.js';
|
|
13
|
-
import {
|
|
12
|
+
import { vault } from './vault.js';
|
|
14
13
|
import { createCrawlTools } from './pi-crawl-tools.js';
|
|
14
|
+
import { createTimeoutSignal, bindAbort } from './abort-signals.js';
|
|
15
|
+
import { extractAssistantDelta } from './pi-events.js';
|
|
15
16
|
// 知识文档目录:所有文件工具的 cwd 和沙箱白名单根
|
|
16
|
-
const docsDir =
|
|
17
|
+
const docsDir = vault.root;
|
|
17
18
|
// pi agent 目录(auth / models / system.md)
|
|
18
19
|
const agentDir = path.join(os.homedir(), '.cc-monitoring', 'pi');
|
|
19
20
|
let runtimePromise = null;
|
|
@@ -67,7 +68,7 @@ STRUCTURE (all paths below are RELATIVE TO the knowledge root ~/.cc-monitoring/d
|
|
|
67
68
|
- Bodies live in <topic-slug>/chunks/chunk-NNN.md
|
|
68
69
|
- Root index.json lists all topics as JSON
|
|
69
70
|
- Fetched source pages for a topic are already prepared in <slug>/sources/ — you only READ them, never write or modify them`;
|
|
70
|
-
|
|
71
|
+
const CHAT_SYSTEM_PROMPT = `You are a knowledge management AI operating inside a sandbox.
|
|
71
72
|
${KB_STRUCTURE}
|
|
72
73
|
|
|
73
74
|
ANSWERING QUESTIONS:
|
|
@@ -77,7 +78,7 @@ ANSWERING QUESTIONS:
|
|
|
77
78
|
4. Call read_chunk(topic, chunk_id) for relevant chunks — only read chunks you need
|
|
78
79
|
5. Prefer answering from knowledge base chunks when relevant content exists; cite which chunks you used
|
|
79
80
|
6. If no relevant chunk exists, answer from your general knowledge; if you truly don't know, say so`;
|
|
80
|
-
|
|
81
|
+
const OUTLINE_SYSTEM_PROMPT = `You are an outline-phase worker. The relevant web pages have ALREADY been fetched and saved to sources/ for your assigned topic. Your job: read them and propose an outline of dictionary entries. Do NOT write chunks.
|
|
81
82
|
|
|
82
83
|
${KB_STRUCTURE}
|
|
83
84
|
|
|
@@ -95,7 +96,7 @@ HARD RULES:
|
|
|
95
96
|
- Do NOT write chunk files, source files, or index.json.
|
|
96
97
|
- Do NOT summarize prematurely — outline only; distillation happens later.
|
|
97
98
|
- After add_outline succeeds, print the returned slug and item count. Stop.`;
|
|
98
|
-
|
|
99
|
+
const CRAWL_SYSTEM_PROMPT = `You are a crawl-phase worker. You drive the browser YOURSELF to incrementally fetch web pages for your assigned topic and save every useful page into sources/. Do NOT outline or write chunks.
|
|
99
100
|
|
|
100
101
|
WORKFLOW:
|
|
101
102
|
1. Call crawl_open to open the entry URL given in your task.
|
|
@@ -109,7 +110,7 @@ HARD RULES:
|
|
|
109
110
|
- If a tool returns an error, do NOT retry the same URL; pick another link or finish.
|
|
110
111
|
- At most ~20 pages. Prefer a few dense pages over many thin ones.
|
|
111
112
|
- After crawl_finish succeeds, stop.`;
|
|
112
|
-
|
|
113
|
+
const REFINE_SYSTEM_PROMPT = `You are a refine-phase worker. For ONE item from the topic's outline, produce a single dictionary chunk.
|
|
113
114
|
|
|
114
115
|
${KB_STRUCTURE}
|
|
115
116
|
|
|
@@ -141,7 +142,7 @@ HARD RULES:
|
|
|
141
142
|
- One concept per chunk.
|
|
142
143
|
- If the material is thin on a concept, write what exists; do NOT invent content. Omit empty sections.
|
|
143
144
|
- Do NOT call add_topic. Do NOT write index.json.`;
|
|
144
|
-
|
|
145
|
+
const TAG_SYSTEM_PROMPT = `You are a tag-phase worker. Enrich an existing topic with rich, retrieval-friendly tags.
|
|
145
146
|
|
|
146
147
|
${KB_STRUCTURE}
|
|
147
148
|
|
|
@@ -189,13 +190,6 @@ function systemPromptForMode(mode) {
|
|
|
189
190
|
// 工具构造
|
|
190
191
|
const ok = (text) => ({ content: [{ type: 'text', text }], details: undefined });
|
|
191
192
|
const err = (e) => ({ content: [{ type: 'text', text: `error: ${e instanceof Error ? e.message : String(e)}` }], details: undefined });
|
|
192
|
-
// 与 knowledge-store TOPIC_RE 保持一致:防路径穿越(../、绝对路径、反斜杠等)
|
|
193
|
-
const SLUG_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
194
|
-
function assertSlug(slug, field) {
|
|
195
|
-
if (!SLUG_RE.test(slug)) {
|
|
196
|
-
throw new Error(`invalid ${field}: ${slug}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
193
|
/** add_outline:对已存在的 slug 目录登记大纲(写 outline.json + seed topic) */
|
|
200
194
|
function buildAddOutlineTool() {
|
|
201
195
|
return {
|
|
@@ -212,14 +206,8 @@ function buildAddOutlineTool() {
|
|
|
212
206
|
})),
|
|
213
207
|
}),
|
|
214
208
|
async execute(_id, params) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (!fs.existsSync(topicDir))
|
|
218
|
-
throw new Error(`topic dir not prepared: ${params.slug}`);
|
|
219
|
-
if (!fs.existsSync(path.join(topicDir, 'sources')))
|
|
220
|
-
throw new Error(`sources missing for topic: ${params.slug}`);
|
|
221
|
-
fs.writeFileSync(path.join(topicDir, 'outline.json'), JSON.stringify({ slug: params.slug, source: 'sources/', items: params.items }, null, 2));
|
|
222
|
-
await knowledgeStore.upsertTopic({
|
|
209
|
+
vault.writeOutline(params.slug, params.items);
|
|
210
|
+
await vault.upsertTopic({
|
|
223
211
|
slug: params.slug,
|
|
224
212
|
title: params.title,
|
|
225
213
|
summary: '(refining)',
|
|
@@ -237,12 +225,11 @@ function buildReadSourceTool() {
|
|
|
237
225
|
description: '读取该主题 sources/ 目录下全部已抓取网页(按文件名排序、--- 分隔)。',
|
|
238
226
|
parameters: Type.Object({ topic: Type.String({ description: '主题 slug' }) }),
|
|
239
227
|
async execute(_id, params) {
|
|
240
|
-
assertSlug(params.topic, 'topic');
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
if (files.length === 0)
|
|
228
|
+
vault.assertSlug(params.topic, 'topic');
|
|
229
|
+
const bodies = vault.readSourceBodies(params.topic);
|
|
230
|
+
if (bodies.length === 0)
|
|
244
231
|
throw new Error(`no sources for topic: ${params.topic}`);
|
|
245
|
-
const merged =
|
|
232
|
+
const merged = bodies.join('\n\n---\n\n');
|
|
246
233
|
return ok(merged);
|
|
247
234
|
},
|
|
248
235
|
};
|
|
@@ -257,7 +244,7 @@ function buildKnowledgeTools() {
|
|
|
257
244
|
parameters: Type.Object({}),
|
|
258
245
|
async execute() {
|
|
259
246
|
try {
|
|
260
|
-
return ok(JSON.stringify(await
|
|
247
|
+
return ok(JSON.stringify(await vault.listTopics(), null, 2));
|
|
261
248
|
}
|
|
262
249
|
catch (e) {
|
|
263
250
|
return err(e);
|
|
@@ -271,7 +258,7 @@ function buildKnowledgeTools() {
|
|
|
271
258
|
parameters: Type.Object({ topic: Type.String({ description: '主题 slug,如 react-hooks' }) }),
|
|
272
259
|
async execute(_id, params) {
|
|
273
260
|
try {
|
|
274
|
-
return ok(JSON.stringify(await
|
|
261
|
+
return ok(JSON.stringify(await vault.getTopic(params.topic), null, 2));
|
|
275
262
|
}
|
|
276
263
|
catch (e) {
|
|
277
264
|
return err(e);
|
|
@@ -285,7 +272,7 @@ function buildKnowledgeTools() {
|
|
|
285
272
|
parameters: Type.Object({ query: Type.String({ description: '搜索关键词' }) }),
|
|
286
273
|
async execute(_id, params) {
|
|
287
274
|
try {
|
|
288
|
-
return ok(JSON.stringify(await
|
|
275
|
+
return ok(JSON.stringify(await vault.searchChunks(params.query), null, 2));
|
|
289
276
|
}
|
|
290
277
|
catch (e) {
|
|
291
278
|
return err(e);
|
|
@@ -302,7 +289,7 @@ function buildKnowledgeTools() {
|
|
|
302
289
|
}),
|
|
303
290
|
async execute(_id, params) {
|
|
304
291
|
try {
|
|
305
|
-
return ok(await
|
|
292
|
+
return ok(await vault.readChunk(params.topic, params.chunk_id));
|
|
306
293
|
}
|
|
307
294
|
catch (e) {
|
|
308
295
|
return err(e);
|
|
@@ -321,7 +308,7 @@ function buildKnowledgeTools() {
|
|
|
321
308
|
}),
|
|
322
309
|
async execute(_id, params) {
|
|
323
310
|
try {
|
|
324
|
-
await
|
|
311
|
+
await vault.upsertTopic(params);
|
|
325
312
|
return ok('topic added');
|
|
326
313
|
}
|
|
327
314
|
catch (e) {
|
|
@@ -342,7 +329,7 @@ function buildKnowledgeTools() {
|
|
|
342
329
|
}),
|
|
343
330
|
async execute(_id, params) {
|
|
344
331
|
try {
|
|
345
|
-
await
|
|
332
|
+
await vault.upsertChunkRef({
|
|
346
333
|
topic: params.topic,
|
|
347
334
|
chunkId: params.chunk_id,
|
|
348
335
|
title: params.title,
|
|
@@ -362,7 +349,7 @@ const KNOWLEDGE_TOOLS = buildKnowledgeTools();
|
|
|
362
349
|
const KT = (name) => KNOWLEDGE_TOOLS.find((t) => t.name === name);
|
|
363
350
|
const WRITE_TOOL = createWriteToolDefinition(docsDir, { operations: sandboxWriteOps });
|
|
364
351
|
/** 按模式构建工具集(ToolDefinition 数组,用于 customTools) */
|
|
365
|
-
function buildModeTools(mode, crawlGuard) {
|
|
352
|
+
function buildModeTools(mode, crawlGuard, signal) {
|
|
366
353
|
switch (mode) {
|
|
367
354
|
case 'chat':
|
|
368
355
|
return [KT('list_topics'), KT('get_topic'), KT('search_chunks'), KT('read_chunk')];
|
|
@@ -371,7 +358,9 @@ function buildModeTools(mode, crawlGuard) {
|
|
|
371
358
|
case 'crawl':
|
|
372
359
|
if (!crawlGuard)
|
|
373
360
|
throw new Error('crawl 模式必须传入 crawlGuard');
|
|
374
|
-
|
|
361
|
+
if (!signal)
|
|
362
|
+
throw new Error('crawl 模式必须传入 signal');
|
|
363
|
+
return createCrawlTools(crawlGuard, signal);
|
|
375
364
|
case 'refine':
|
|
376
365
|
return [buildReadSourceTool(), WRITE_TOOL, KT('add_chunk')];
|
|
377
366
|
case 'tag':
|
|
@@ -411,7 +400,7 @@ export async function createPiSession(options) {
|
|
|
411
400
|
// 所以先放一个可变变量,返回 session 后再填值。
|
|
412
401
|
let currentSessionId = '';
|
|
413
402
|
const systemPrompt = systemPromptForMode(options.mode);
|
|
414
|
-
const modeTools = buildModeTools(options.mode, options.crawlGuard);
|
|
403
|
+
const modeTools = buildModeTools(options.mode, options.crawlGuard, options.signal);
|
|
415
404
|
const toolAllowlist = buildToolAllowlist(options.mode);
|
|
416
405
|
const resourceLoader = new DefaultResourceLoader({
|
|
417
406
|
cwd,
|
|
@@ -448,6 +437,8 @@ export async function createPiSession(options) {
|
|
|
448
437
|
}
|
|
449
438
|
// ============================================================
|
|
450
439
|
// 无工具 JSON 调用(reconcile 模式)
|
|
440
|
+
// 单次 JSON 调用超时:5 分钟
|
|
441
|
+
const STAGE_TIMEOUT_MS = 5 * 60 * 1000;
|
|
451
442
|
/**
|
|
452
443
|
* 从任意文本截取第一个 `{` 到最后一个 `}` 之间的子串并解析为 JSON 对象。
|
|
453
444
|
* 容忍 prose / 代码围栏包裹。无 `{` 或解析失败时抛错。
|
|
@@ -471,14 +462,16 @@ export function extractJsonObject(raw) {
|
|
|
471
462
|
*/
|
|
472
463
|
export async function runJsonPrompt(opts) {
|
|
473
464
|
const session = await createPiSession({ port: opts.port, mode: 'reconcile' });
|
|
465
|
+
// 5 分钟超时 + 外部取消:任一触发都调 session.abort();SDK abort 后 prompt/waitForIdle
|
|
466
|
+
// 会正常 resolve(不 reject),故 await(经 finally)后需检查 combined.aborted 主动抛错
|
|
467
|
+
const combined = createTimeoutSignal(STAGE_TIMEOUT_MS, opts.signal);
|
|
468
|
+
bindAbort(combined, () => session.abort());
|
|
474
469
|
// 订阅累积 assistant 文本 chunk
|
|
475
470
|
let accumulated = '';
|
|
476
471
|
const unsub = session.subscribe((ev) => {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
accumulated += ae.delta;
|
|
481
|
-
}
|
|
472
|
+
const d = extractAssistantDelta(ev);
|
|
473
|
+
if (d?.kind === 'text') {
|
|
474
|
+
accumulated += d.delta;
|
|
482
475
|
}
|
|
483
476
|
});
|
|
484
477
|
try {
|
|
@@ -488,5 +481,8 @@ export async function runJsonPrompt(opts) {
|
|
|
488
481
|
finally {
|
|
489
482
|
unsub();
|
|
490
483
|
}
|
|
484
|
+
if (combined.aborted) {
|
|
485
|
+
throw new Error('json prompt 已中止');
|
|
486
|
+
}
|
|
491
487
|
return extractJsonObject(accumulated);
|
|
492
488
|
}
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 校验传入路径必须在 docsDir 内,并返回归一化后的绝对路径。
|
|
3
|
-
* 越界则抛错,阻断 fs 调用。
|
|
4
|
-
*/
|
|
5
|
-
export declare function assertInside(absPath: string): string;
|
|
6
|
-
declare function access(absolutePath: string): Promise<void>;
|
|
7
|
-
export declare const sandboxReadOps: {
|
|
8
|
-
readFile(absolutePath: string): Promise<Buffer>;
|
|
9
|
-
access: typeof access;
|
|
10
|
-
detectImageMimeType: () => Promise<string | null | undefined>;
|
|
11
|
-
};
|
|
12
1
|
export declare const sandboxWriteOps: {
|
|
13
2
|
writeFile(absolutePath: string, content: string): Promise<void>;
|
|
14
3
|
mkdir(dir: string): Promise<void>;
|
|
15
4
|
};
|
|
16
|
-
export declare const sandboxEditOps: {
|
|
17
|
-
readFile(absolutePath: string): Promise<Buffer>;
|
|
18
|
-
writeFile(absolutePath: string, content: string): Promise<void>;
|
|
19
|
-
access: typeof access;
|
|
20
|
-
};
|
|
21
|
-
export declare const sandboxGrepOps: {
|
|
22
|
-
isDirectory(absolutePath: string): Promise<boolean>;
|
|
23
|
-
readFile(absolutePath: string): Promise<string>;
|
|
24
|
-
};
|
|
25
|
-
export declare const sandboxFindOps: {
|
|
26
|
-
exists(absolutePath: string): Promise<boolean>;
|
|
27
|
-
glob(pattern: string, cwd: string, options: {
|
|
28
|
-
ignore: string[];
|
|
29
|
-
limit: number;
|
|
30
|
-
}): Promise<string[]>;
|
|
31
|
-
};
|
|
32
|
-
export declare function globMatch(relPosixPath: string, pattern: string): boolean;
|
|
33
|
-
export declare const sandboxLsOps: {
|
|
34
|
-
exists(absolutePath: string): Promise<boolean>;
|
|
35
|
-
stat(absolutePath: string): Promise<{
|
|
36
|
-
isDirectory: () => boolean;
|
|
37
|
-
}>;
|
|
38
|
-
readdir(absolutePath: string): Promise<string[]>;
|
|
39
|
-
};
|
|
40
|
-
export {};
|
|
@@ -1,45 +1,22 @@
|
|
|
1
1
|
// 为 pi-coding-agent 的文件工具提供沙箱白名单 operations,
|
|
2
2
|
// 把所有 fs 访问限定在 ~/.cc-monitoring/docs/ 目录内。
|
|
3
|
+
// 边界判定(docsDir 内 / 受管 index.json)委托 vault。
|
|
3
4
|
import { promises as fs } from 'node:fs';
|
|
4
|
-
import
|
|
5
|
-
import { dataDir } from './paths.js';
|
|
6
|
-
// 知识文档目录:所有读写都必须落在它下面
|
|
7
|
-
const docsDir = path.join(dataDir, 'docs');
|
|
5
|
+
import { vault } from './vault.js';
|
|
8
6
|
/**
|
|
9
7
|
* 校验传入路径必须在 docsDir 内,并返回归一化后的绝对路径。
|
|
10
8
|
* 越界则抛错,阻断 fs 调用。
|
|
11
9
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (resolved !== docsDir && !resolved.startsWith(docsDir + path.sep)) {
|
|
15
|
-
throw new Error(`Access denied: ${absPath} is outside the knowledge directory ${docsDir}`);
|
|
16
|
-
}
|
|
17
|
-
return resolved;
|
|
10
|
+
function assertInside(absPath) {
|
|
11
|
+
return vault.assertInside(absPath);
|
|
18
12
|
}
|
|
19
13
|
/**
|
|
20
14
|
* 守卫:index.json 由 add_topic/add_chunk 工具原子维护,
|
|
21
15
|
* 禁止 LLM 通过 write/edit 直接改写。
|
|
22
16
|
*/
|
|
23
17
|
function assertNotManagedIndexJson(absPath) {
|
|
24
|
-
|
|
25
|
-
throw new Error('index.json is managed by add_topic/add_chunk tools, do not write directly');
|
|
26
|
-
}
|
|
18
|
+
vault.assertNotManagedIndexJson(absPath);
|
|
27
19
|
}
|
|
28
|
-
// 统一 access:校验可读性
|
|
29
|
-
async function access(absolutePath) {
|
|
30
|
-
const p = assertInside(absolutePath);
|
|
31
|
-
await fs.access(p);
|
|
32
|
-
}
|
|
33
|
-
// ============== read ==============
|
|
34
|
-
export const sandboxReadOps = {
|
|
35
|
-
async readFile(absolutePath) {
|
|
36
|
-
const p = assertInside(absolutePath);
|
|
37
|
-
return fs.readFile(p);
|
|
38
|
-
},
|
|
39
|
-
access,
|
|
40
|
-
// 沙箱内不做图片 MIME 检测(pi 会按非图片处理,足够用)
|
|
41
|
-
detectImageMimeType: async () => undefined,
|
|
42
|
-
};
|
|
43
20
|
// ============== write ==============
|
|
44
21
|
export const sandboxWriteOps = {
|
|
45
22
|
async writeFile(absolutePath, content) {
|
|
@@ -52,165 +29,3 @@ export const sandboxWriteOps = {
|
|
|
52
29
|
await fs.mkdir(p, { recursive: true });
|
|
53
30
|
},
|
|
54
31
|
};
|
|
55
|
-
// ============== edit ==============
|
|
56
|
-
export const sandboxEditOps = {
|
|
57
|
-
async readFile(absolutePath) {
|
|
58
|
-
const p = assertInside(absolutePath);
|
|
59
|
-
return fs.readFile(p);
|
|
60
|
-
},
|
|
61
|
-
async writeFile(absolutePath, content) {
|
|
62
|
-
const p = assertInside(absolutePath);
|
|
63
|
-
assertNotManagedIndexJson(p);
|
|
64
|
-
await fs.writeFile(p, content, 'utf8');
|
|
65
|
-
},
|
|
66
|
-
access,
|
|
67
|
-
};
|
|
68
|
-
// ============== grep ==============
|
|
69
|
-
// GrepOperations.readFile 签名是 Promise<string> | string(用于返回上下文行)
|
|
70
|
-
export const sandboxGrepOps = {
|
|
71
|
-
async isDirectory(absolutePath) {
|
|
72
|
-
// 越界直接 throw,让 pi 在 spawn rg 之前就 reject
|
|
73
|
-
const p = assertInside(absolutePath);
|
|
74
|
-
const st = await fs.stat(p);
|
|
75
|
-
return st.isDirectory();
|
|
76
|
-
},
|
|
77
|
-
async readFile(absolutePath) {
|
|
78
|
-
const p = assertInside(absolutePath);
|
|
79
|
-
return fs.readFile(p, 'utf8');
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
// ============== find ==============
|
|
83
|
-
export const sandboxFindOps = {
|
|
84
|
-
async exists(absolutePath) {
|
|
85
|
-
const p = assertInside(absolutePath);
|
|
86
|
-
try {
|
|
87
|
-
await fs.access(p);
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
async glob(pattern, cwd, options) {
|
|
95
|
-
// cwd 必须落在 docsDir 内
|
|
96
|
-
const root = assertInside(cwd);
|
|
97
|
-
// 递归收集 root 下所有文件的相对 posix 路径,再按 pattern + ignore 过滤
|
|
98
|
-
const all = [];
|
|
99
|
-
async function walk(dir) {
|
|
100
|
-
if (all.length >= options.limit * 4)
|
|
101
|
-
return;
|
|
102
|
-
let entries;
|
|
103
|
-
try {
|
|
104
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
for (const ent of entries) {
|
|
110
|
-
const full = path.join(dir, ent.name);
|
|
111
|
-
const rel = path.relative(root, full).split(path.sep).join('/');
|
|
112
|
-
if (options.ignore.some((ig) => globMatch(rel, ig)))
|
|
113
|
-
continue;
|
|
114
|
-
if (ent.isDirectory()) {
|
|
115
|
-
await walk(full);
|
|
116
|
-
}
|
|
117
|
-
else if (ent.isFile()) {
|
|
118
|
-
all.push(rel);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
await walk(root);
|
|
123
|
-
// 按 pattern 过滤,截断到 limit
|
|
124
|
-
// 语义对齐 fd:pattern 不含 '/' 时按 basename 匹配任意深度;
|
|
125
|
-
// 含 '/' 时按完整相对路径匹配(等价 '**/<pattern>')
|
|
126
|
-
const hasSlash = pattern.includes('/');
|
|
127
|
-
const out = all
|
|
128
|
-
.filter((r) => hasSlash ? globMatch(r, pattern) : matchSegment(pattern, path.posix.basename(r)))
|
|
129
|
-
.slice(0, options.limit);
|
|
130
|
-
return out;
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
// 极简 glob:支持 *、**、?,与 minimatch 在常见文档搜索场景下等价
|
|
134
|
-
// - '*.md' 匹配顶层 md 文件
|
|
135
|
-
// - '**/*.md' 匹配任意层级 md
|
|
136
|
-
// - 'docs/**' 匹配 docs 子树下所有文件
|
|
137
|
-
// - 'src/foo.ts' 字面路径
|
|
138
|
-
export function globMatch(relPosixPath, pattern) {
|
|
139
|
-
// 显式 '**' 段处理
|
|
140
|
-
const patternSegs = pattern.split('/');
|
|
141
|
-
const pathSegs = relPosixPath.split('/');
|
|
142
|
-
return matchSegs(patternSegs, pathSegs, 0, 0);
|
|
143
|
-
}
|
|
144
|
-
function matchSegs(pats, paths, pi, qi) {
|
|
145
|
-
if (pi === pats.length) {
|
|
146
|
-
return qi === paths.length;
|
|
147
|
-
}
|
|
148
|
-
const p = pats[pi];
|
|
149
|
-
if (p === '**') {
|
|
150
|
-
// '**' 匹配 0..n 段(含跨目录)
|
|
151
|
-
// 试:消耗 0 段;以及让 '**' 吃掉 q 到末尾任意段
|
|
152
|
-
if (matchSegs(pats, paths, pi + 1, qi))
|
|
153
|
-
return true;
|
|
154
|
-
for (let k = qi; k < paths.length; k++) {
|
|
155
|
-
if (matchSegs(pats, paths, pi + 1, k + 1))
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
if (qi === paths.length)
|
|
161
|
-
return false;
|
|
162
|
-
if (!matchSegment(p, paths[qi]))
|
|
163
|
-
return false;
|
|
164
|
-
return matchSegs(pats, paths, pi + 1, qi + 1);
|
|
165
|
-
}
|
|
166
|
-
function matchSegment(pattern, segment) {
|
|
167
|
-
if (pattern === '*')
|
|
168
|
-
return true;
|
|
169
|
-
// 把 *、? 转成正则,其余字符转义
|
|
170
|
-
let re = '^';
|
|
171
|
-
for (let i = 0; i < pattern.length; i++) {
|
|
172
|
-
const ch = pattern[i];
|
|
173
|
-
if (ch === '*') {
|
|
174
|
-
re += '[^/]*';
|
|
175
|
-
}
|
|
176
|
-
else if (ch === '?') {
|
|
177
|
-
re += '[^/]';
|
|
178
|
-
}
|
|
179
|
-
else if ('.+^${}()|\\'.includes(ch)) {
|
|
180
|
-
re += '\\' + ch;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
re += ch;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
re += '$';
|
|
187
|
-
try {
|
|
188
|
-
return new RegExp(re).test(segment);
|
|
189
|
-
}
|
|
190
|
-
catch {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
// ============== ls ==============
|
|
195
|
-
export const sandboxLsOps = {
|
|
196
|
-
async exists(absolutePath) {
|
|
197
|
-
const p = assertInside(absolutePath);
|
|
198
|
-
try {
|
|
199
|
-
await fs.access(p);
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
catch {
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
async stat(absolutePath) {
|
|
207
|
-
const p = assertInside(absolutePath);
|
|
208
|
-
const st = await fs.stat(p);
|
|
209
|
-
// fs.Stats 自带 isDirectory(),形状已满足 LsOperations
|
|
210
|
-
return st;
|
|
211
|
-
},
|
|
212
|
-
async readdir(absolutePath) {
|
|
213
|
-
const p = assertInside(absolutePath);
|
|
214
|
-
return fs.readdir(p);
|
|
215
|
-
},
|
|
216
|
-
};
|
|
@@ -12,6 +12,7 @@ export interface Provider {
|
|
|
12
12
|
provider: string;
|
|
13
13
|
default: boolean;
|
|
14
14
|
is_openai_compatible: boolean;
|
|
15
|
+
auth_style: 'bearer' | 'x-api-key';
|
|
15
16
|
created_at: string;
|
|
16
17
|
updated_at: string;
|
|
17
18
|
}
|
|
@@ -27,6 +28,7 @@ export interface ProviderInput {
|
|
|
27
28
|
provider: string;
|
|
28
29
|
default?: boolean;
|
|
29
30
|
is_openai_compatible?: boolean;
|
|
31
|
+
auth_style?: 'bearer' | 'x-api-key';
|
|
30
32
|
}
|
|
31
33
|
export interface ProviderValidationError {
|
|
32
34
|
index?: number;
|
|
@@ -34,6 +36,7 @@ export interface ProviderValidationError {
|
|
|
34
36
|
message: string;
|
|
35
37
|
}
|
|
36
38
|
export declare function listProviders(db: Database.Database): Provider[];
|
|
39
|
+
export declare function getActiveProvider(db: Database.Database): Provider | null;
|
|
37
40
|
/**
|
|
38
41
|
* Destructive full replacement: deletes ALL existing providers then inserts the given list.
|
|
39
42
|
* Passing an empty array will wipe all provider data with no replacement.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const REQUIRED_FIELDS = ['name', 'provider'];
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return rows.map(r => ({
|
|
2
|
+
function mapRow(r) {
|
|
3
|
+
return {
|
|
5
4
|
id: r.id,
|
|
6
5
|
name: r.name,
|
|
7
6
|
base_url: r.base_url,
|
|
@@ -14,9 +13,24 @@ export function listProviders(db) {
|
|
|
14
13
|
provider: r.provider,
|
|
15
14
|
default: !!r.is_default,
|
|
16
15
|
is_openai_compatible: !!r.is_openai_compatible,
|
|
16
|
+
auth_style: r.auth_style === 'x-api-key' ? 'x-api-key' : 'bearer',
|
|
17
17
|
created_at: r.created_at,
|
|
18
18
|
updated_at: r.updated_at,
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function listProviders(db) {
|
|
22
|
+
const rows = db.prepare('SELECT * FROM providers ORDER BY created_at DESC').all();
|
|
23
|
+
return rows.map(mapRow);
|
|
24
|
+
}
|
|
25
|
+
const activeProviderStmtCache = new WeakMap();
|
|
26
|
+
export function getActiveProvider(db) {
|
|
27
|
+
let stmt = activeProviderStmtCache.get(db);
|
|
28
|
+
if (!stmt) {
|
|
29
|
+
stmt = db.prepare('SELECT * FROM providers WHERE is_default = 1 LIMIT 1');
|
|
30
|
+
activeProviderStmtCache.set(db, stmt);
|
|
31
|
+
}
|
|
32
|
+
const row = stmt.get();
|
|
33
|
+
return row ? mapRow(row) : null;
|
|
20
34
|
}
|
|
21
35
|
/**
|
|
22
36
|
* Destructive full replacement: deletes ALL existing providers then inserts the given list.
|
|
@@ -28,13 +42,13 @@ export function listProviders(db) {
|
|
|
28
42
|
export function saveProviders(db, providers) {
|
|
29
43
|
const deleteAll = db.prepare('DELETE FROM providers');
|
|
30
44
|
const insertOne = db.prepare(`
|
|
31
|
-
INSERT INTO providers (name, base_url, api_key, model, haiku_model, sonnet_model, opus_model, subagent_model, provider, is_default, is_openai_compatible)
|
|
32
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
45
|
+
INSERT INTO providers (name, base_url, api_key, model, haiku_model, sonnet_model, opus_model, subagent_model, provider, is_default, is_openai_compatible, auth_style)
|
|
46
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
33
47
|
`);
|
|
34
48
|
const transaction = db.transaction(() => {
|
|
35
49
|
deleteAll.run();
|
|
36
50
|
for (const p of providers) {
|
|
37
|
-
insertOne.run(p.name, p.base_url && p.base_url.trim() !== '' ? p.base_url : null, p.api_key && p.api_key.trim() !== '' ? p.api_key : null, p.model && p.model.trim() !== '' ? p.model : null, p.haiku_model && p.haiku_model.trim() !== '' ? p.haiku_model : null, p.sonnet_model && p.sonnet_model.trim() !== '' ? p.sonnet_model : null, p.opus_model && p.opus_model.trim() !== '' ? p.opus_model : null, p.subagent_model && p.subagent_model.trim() !== '' ? p.subagent_model : null, p.provider, p.default ? 1 : 0, p.is_openai_compatible ? 1 : 0);
|
|
51
|
+
insertOne.run(p.name, p.base_url && p.base_url.trim() !== '' ? p.base_url : null, p.api_key && p.api_key.trim() !== '' ? p.api_key : null, p.model && p.model.trim() !== '' ? p.model : null, p.haiku_model && p.haiku_model.trim() !== '' ? p.haiku_model : null, p.sonnet_model && p.sonnet_model.trim() !== '' ? p.sonnet_model : null, p.opus_model && p.opus_model.trim() !== '' ? p.opus_model : null, p.subagent_model && p.subagent_model.trim() !== '' ? p.subagent_model : null, p.provider, p.default ? 1 : 0, p.is_openai_compatible ? 1 : 0, p.auth_style === 'x-api-key' ? 'x-api-key' : 'bearer');
|
|
38
52
|
}
|
|
39
53
|
});
|
|
40
54
|
transaction();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
requestId: string;
|
|
1
|
+
export interface RecordedRequest {
|
|
3
2
|
sessionId: string;
|
|
3
|
+
localRequestId: string;
|
|
4
4
|
timestamp: string;
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
proxyApiKey?: string;
|
|
@@ -13,14 +13,6 @@ export interface RequestData {
|
|
|
13
13
|
headers: Record<string, string>;
|
|
14
14
|
body?: any;
|
|
15
15
|
};
|
|
16
|
-
response?: {
|
|
17
|
-
statusCode: number;
|
|
18
|
-
headers?: Record<string, string>;
|
|
19
|
-
events?: any[];
|
|
20
|
-
completedAt?: string;
|
|
21
|
-
closedAt?: string;
|
|
22
|
-
error?: string;
|
|
23
|
-
};
|
|
24
16
|
}
|
|
25
17
|
export interface TokenUsage {
|
|
26
18
|
input_tokens?: number;
|
|
@@ -42,34 +34,72 @@ export interface RequestSummary {
|
|
|
42
34
|
baseUrl?: string;
|
|
43
35
|
model?: string;
|
|
44
36
|
machineId?: string;
|
|
37
|
+
userAgent?: string;
|
|
45
38
|
usage?: TokenUsage;
|
|
39
|
+
closedAt?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface RequestRecorder {
|
|
42
|
+
pending(): Promise<void>;
|
|
43
|
+
appendEvent(event: any): void;
|
|
44
|
+
headers(args: {
|
|
45
|
+
statusCode: number;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
}): void;
|
|
48
|
+
complete(args: {
|
|
49
|
+
cloudRequestId?: string;
|
|
50
|
+
statusCode: number;
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
interrupt(args: {
|
|
54
|
+
statusCode: number;
|
|
55
|
+
error: string;
|
|
56
|
+
}): void;
|
|
57
|
+
fail(args: {
|
|
58
|
+
statusCode: number;
|
|
59
|
+
error: string;
|
|
60
|
+
}): void;
|
|
46
61
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
interface LoadedRequest {
|
|
63
|
+
requestId: string;
|
|
64
|
+
sessionId: string;
|
|
65
|
+
timestamp: string;
|
|
66
|
+
apiKey?: string;
|
|
67
|
+
proxyApiKey?: string;
|
|
68
|
+
baseUrl?: string;
|
|
69
|
+
model?: string;
|
|
70
|
+
machineId?: string;
|
|
71
|
+
request: {
|
|
72
|
+
method: string;
|
|
73
|
+
path: string;
|
|
74
|
+
headers: Record<string, string>;
|
|
75
|
+
body?: any;
|
|
76
|
+
};
|
|
77
|
+
response?: {
|
|
78
|
+
statusCode: number;
|
|
79
|
+
headers?: Record<string, string>;
|
|
80
|
+
events?: any[];
|
|
81
|
+
completedAt?: string;
|
|
82
|
+
closedAt?: string;
|
|
83
|
+
error?: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export declare function createRequestRecorder(meta: RecordedRequest): RequestRecorder;
|
|
87
|
+
export declare function recordIteration(meta: RecordedRequest & {
|
|
88
|
+
response: {
|
|
89
|
+
statusCode: number;
|
|
90
|
+
headers?: Record<string, string>;
|
|
91
|
+
events?: any[];
|
|
92
|
+
};
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
export declare function loadRequestDB(compositeId: string): Promise<LoadedRequest>;
|
|
66
95
|
export declare function listRequestDB(limit?: number, before?: string): Promise<{
|
|
67
96
|
requests: RequestSummary[];
|
|
68
97
|
hasMore: boolean;
|
|
69
98
|
}>;
|
|
70
99
|
export declare function cleanOldRequestsDB(daysToKeep?: number): Promise<void>;
|
|
71
|
-
export declare function
|
|
100
|
+
export declare function interruptStaleRequestsOnStartup(maxAgeMs?: number): number;
|
|
72
101
|
export declare function loadSessionHistory(sessionId: string): {
|
|
73
102
|
messages: any[];
|
|
74
103
|
system?: any;
|
|
75
104
|
} | null;
|
|
105
|
+
export {};
|