abtars 0.2.1-alpha.9 → 0.2.2
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/CHANGELOG.md +64 -0
- package/README.md +93 -34
- package/bundle/{_registry.generated-ADOYFJJ4.js → _registry.generated-KYX63MGY.js} +19 -16
- package/bundle/{_registry.generated-ADOYFJJ4.js.map → _registry.generated-KYX63MGY.js.map} +1 -1
- package/bundle/abtars-browser.js +5 -6
- package/bundle/abtars-browser.js.map +2 -2
- package/bundle/abtars-cli.js +205 -179
- package/bundle/abtars-cli.js.map +4 -4
- package/bundle/abtars-restart.js +4 -4
- package/bundle/abtars-rss.js +25 -81
- package/bundle/abtars-rss.js.map +2 -2
- package/bundle/abtars-task.js +4 -5
- package/bundle/abtars-task.js.map +2 -2
- package/bundle/abtars-todo.js +133 -0
- package/bundle/abtars-todo.js.map +7 -0
- package/bundle/abtars.js +305 -182
- package/bundle/abtars.js.map +3 -3
- package/bundle/action-gate-DYV2XQBP.js +191 -0
- package/bundle/action-gate-DYV2XQBP.js.map +7 -0
- package/bundle/{agent-api-rate-limit-C25WGSFF.js → agent-api-rate-limit-R2OFAQ3N.js} +4 -4
- package/bundle/{agent-registry-SYUFNSVB.js → agent-registry-5VL5KI6U.js} +8 -8
- package/bundle/agent-registry-PIS5XJHX.js +19 -0
- package/bundle/{bridge-lock-transport-HO545SBK.js → bridge-lock-transport-N6OGDOSE.js} +5 -5
- package/bundle/{browse-delivery-VTLEAVYA.js → browse-delivery-DXGMDMXA.js} +8 -7
- package/bundle/{browser-REIXOJ6S.js → browser-QMYGSP5W.js} +11 -10
- package/bundle/{capability-ILW3D5HS.js → capability-733TLH4W.js} +6 -6
- package/bundle/chunk-3IPMKYYH.js +672 -0
- package/bundle/chunk-3IPMKYYH.js.map +7 -0
- package/bundle/{chunk-PZE3J7ER.js → chunk-3OXQWII3.js} +2 -2
- package/bundle/{chunk-X5FBUA53.js → chunk-4WKWPU6U.js} +137 -30
- package/bundle/chunk-4WKWPU6U.js.map +7 -0
- package/bundle/{chunk-4KJ76TTE.js → chunk-4XW7YA3K.js} +3 -3
- package/bundle/{chunk-A5OJYQNU.js → chunk-5WFIAUQC.js} +49 -22
- package/bundle/chunk-5WFIAUQC.js.map +7 -0
- package/bundle/{chunk-ZVDVNSXK.js → chunk-7WFE2JI5.js} +7 -7
- package/bundle/{chunk-R36WIOYX.js → chunk-B52YRWR6.js} +34 -6
- package/bundle/chunk-B52YRWR6.js.map +7 -0
- package/bundle/{chunk-Q62SXS73.js → chunk-BBDKU4EH.js} +9 -9
- package/bundle/chunk-BBTQKKDO.js +258 -0
- package/bundle/chunk-BBTQKKDO.js.map +7 -0
- package/bundle/{chunk-EX2SRTUE.js → chunk-CYSGXNBY.js} +2 -2
- package/bundle/{chunk-LYEAHE5V.js → chunk-DCY7DGMT.js} +2 -2
- package/bundle/chunk-DGS7J4P6.js +13 -0
- package/bundle/chunk-DGS7J4P6.js.map +7 -0
- package/bundle/{chunk-LDKSCXGL.js → chunk-DHPFI7OF.js} +8 -6
- package/bundle/{chunk-LDKSCXGL.js.map → chunk-DHPFI7OF.js.map} +1 -1
- package/bundle/{chunk-G6IXMYIO.js → chunk-DO4INSXE.js} +2 -2
- package/bundle/{chunk-VA5WKN3Z.js → chunk-EGA6JQVV.js} +4 -4
- package/bundle/chunk-EKHNWFEQ.js +85 -0
- package/bundle/chunk-EKHNWFEQ.js.map +7 -0
- package/bundle/{chunk-URAQLQ2U.js → chunk-F3HMZFIL.js} +4 -4
- package/bundle/{chunk-OOKLEC6V.js → chunk-FY3QUO2L.js} +7 -7
- package/bundle/{chunk-2BY6I4P5.js → chunk-GUTRAMK3.js} +2 -2
- package/bundle/chunk-GXKJKYU4.js +1089 -0
- package/bundle/chunk-GXKJKYU4.js.map +7 -0
- package/bundle/{chunk-GPL57SRN.js → chunk-H7RX7UCR.js} +3 -3
- package/bundle/{chunk-BYDUMHXT.js → chunk-HAF2AFBW.js} +2 -2
- package/bundle/chunk-HAS5NEK7.js +189 -0
- package/bundle/chunk-HAS5NEK7.js.map +7 -0
- package/bundle/chunk-HB54S5OY.js +4036 -0
- package/bundle/chunk-HB54S5OY.js.map +7 -0
- package/bundle/{chunk-OZ4IZFV4.js → chunk-HJQZP5CK.js} +9 -9
- package/bundle/{chunk-OZ4IZFV4.js.map → chunk-HJQZP5CK.js.map} +2 -2
- package/bundle/{chunk-HEHD3GG5.js → chunk-ITB2K6LI.js} +6 -13
- package/bundle/{chunk-HEHD3GG5.js.map → chunk-ITB2K6LI.js.map} +3 -3
- package/bundle/{chunk-KSEIWT4T.js → chunk-JFKOPNKL.js} +10 -10
- package/bundle/chunk-JFKOPNKL.js.map +7 -0
- package/bundle/{chunk-KFENC7BM.js → chunk-L33WNMCP.js} +2 -2
- package/bundle/{chunk-JRG4EFMP.js → chunk-LBMETTUP.js} +3 -3
- package/bundle/{chunk-TYVI3ZWA.js → chunk-LJAG2URA.js} +10 -7
- package/bundle/chunk-LJAG2URA.js.map +7 -0
- package/bundle/{chunk-KWBGYWDO.js → chunk-N24ROESF.js} +15 -17
- package/bundle/chunk-N24ROESF.js.map +7 -0
- package/bundle/{chunk-P2BZSLJJ.js → chunk-N7UG4FID.js} +448 -129
- package/bundle/chunk-N7UG4FID.js.map +7 -0
- package/bundle/chunk-NIYVCGBC.js +330 -0
- package/bundle/chunk-NIYVCGBC.js.map +7 -0
- package/bundle/{chunk-TOUZC6NR.js → chunk-OKMN6J4Z.js} +3 -3
- package/bundle/{chunk-RV54J75Q.js → chunk-PKHYCNTT.js} +13 -12
- package/bundle/chunk-PKHYCNTT.js.map +7 -0
- package/bundle/{chunk-XZSYMCLF.js → chunk-PUDGA4RR.js} +7 -7
- package/bundle/{chunk-CELR236Q.js → chunk-Q7CH5DA3.js} +2 -2
- package/bundle/chunk-QSC6QZ44.js +183 -0
- package/bundle/chunk-QSC6QZ44.js.map +7 -0
- package/bundle/chunk-RITEGAW6.js +138 -0
- package/bundle/chunk-RITEGAW6.js.map +7 -0
- package/bundle/{chunk-UDZIZB5F.js → chunk-RTL7HO3N.js} +3 -3
- package/bundle/{chunk-ITG6XGBS.js → chunk-SA44ITVX.js} +10 -10
- package/bundle/{chunk-3MO2MDXJ.js → chunk-SA6YEFNG.js} +3 -3
- package/bundle/{chunk-4BUOO6WI.js → chunk-SMZQDMSZ.js} +31 -11
- package/bundle/chunk-SMZQDMSZ.js.map +7 -0
- package/bundle/{chunk-GBBTK6H2.js → chunk-SRFEIZQT.js} +4 -4
- package/bundle/{chunk-ELRAH7VL.js → chunk-VXUVKC66.js} +3 -3
- package/bundle/chunk-VY2BUO6L.js +4035 -0
- package/bundle/chunk-VY2BUO6L.js.map +7 -0
- package/bundle/chunk-W6ELWLAR.js +143 -0
- package/bundle/chunk-W6ELWLAR.js.map +7 -0
- package/bundle/{chunk-RSWUPUNA.js → chunk-WMWI3SJ7.js} +30 -6
- package/bundle/chunk-WMWI3SJ7.js.map +7 -0
- package/bundle/{chunk-MJ6PHMOK.js → chunk-WW5F2DCO.js} +11 -2
- package/bundle/chunk-WW5F2DCO.js.map +7 -0
- package/bundle/chunk-Y2XBDQP3.js +4055 -0
- package/bundle/chunk-Y2XBDQP3.js.map +7 -0
- package/bundle/chunk-YMGX6HNP.js +131 -0
- package/bundle/chunk-YMGX6HNP.js.map +7 -0
- package/bundle/chunk-YWZPKBO6.js +22 -0
- package/bundle/chunk-YWZPKBO6.js.map +7 -0
- package/bundle/chunk-ZAA7B5BN.js +22 -0
- package/bundle/chunk-ZAA7B5BN.js.map +7 -0
- package/bundle/{commands-WUGPBPHI.js → commands-IGRSOSK6.js} +15 -14
- package/bundle/commands-LAWVNQTO.js +34 -0
- package/bundle/commands-RBWY7YXB.js +34 -0
- package/bundle/commands-XFZNMZN6.js +34 -0
- package/bundle/{config-DQIGDX4W.js → config-NDEYF4AQ.js} +7 -7
- package/bundle/{daemon-NPKYZ3CJ.js → daemon-WOQXCKNL.js} +4 -4
- package/bundle/{delegation-tools-6FICZQ5G.js → delegation-tools-Z5OM3TXS.js} +5 -5
- package/bundle/{deploy-lib-import-SBKXDD3F.js → deploy-lib-import-6VJTYXEG.js} +2 -2
- package/bundle/{deps-HN6CEXA4.js → deps-65V7XXG4.js} +4 -4
- package/bundle/{direct-api-transport-TRV45NO6.js → direct-api-transport-OZICXTWQ.js} +43 -15
- package/bundle/direct-api-transport-OZICXTWQ.js.map +7 -0
- package/bundle/direct-api-transport-QIWA5ES2.js +889 -0
- package/bundle/direct-api-transport-QIWA5ES2.js.map +7 -0
- package/bundle/{discord-adapter-WA2MFRK3.js → discord-adapter-JFIIVG34.js} +27 -24
- package/bundle/discord-adapter-JFIIVG34.js.map +7 -0
- package/bundle/discord-adapter-U3FA5OTY.js +589 -0
- package/bundle/discord-adapter-U3FA5OTY.js.map +7 -0
- package/bundle/discord-adapter-W6L5KJ6T.js +589 -0
- package/bundle/discord-adapter-W6L5KJ6T.js.map +7 -0
- package/bundle/discord-adapter-WWM6ROTW.js +589 -0
- package/bundle/discord-adapter-WWM6ROTW.js.map +7 -0
- package/bundle/{dns-wakeup-RYOCQ6GR.js → dns-wakeup-N46RPU5E.js} +3 -3
- package/bundle/{doctor-R54GZPKL.js → doctor-PIPSGI3H.js} +18 -7
- package/bundle/{doctor-R54GZPKL.js.map → doctor-PIPSGI3H.js.map} +2 -2
- package/bundle/{ensure-invariants-BJIEOSJ2.js → ensure-invariants-3NOBCYWS.js} +4 -4
- package/bundle/{env-schema-XCPAJ6IZ.js → env-schema-T43X43BU.js} +4 -4
- package/bundle/{hook-system-POI5VRIX.js → hook-system-ZCVOFFRD.js} +4 -4
- package/bundle/hotskills-DTROJY6G.js +17 -0
- package/bundle/{install-SH4UVUXQ.js → install-I3CXVW52.js} +3 -3
- package/bundle/{install-manifest-QRWID3KZ.js → install-manifest-KBYD7SAY.js} +3 -3
- package/bundle/{irc-adapter-AIEP6OX6.js → irc-adapter-HXO5D4SW.js} +3 -3
- package/bundle/{irc-config-6VY67UPQ.js → irc-config-XN5VW2V4.js} +5 -5
- package/bundle/kanban-board-6Q5E5GEB.js +31 -0
- package/bundle/kanban-board-I52RHNHQ.js +31 -0
- package/bundle/{lazy-require-UFYFFX2R.js → lazy-require-R3JYCV5M.js} +4 -4
- package/bundle/{media-utils-MOE36VWY.js → media-utils-W7XW3SVV.js} +4 -4
- package/bundle/{message-pipeline-2MBT44FO.js → message-pipeline-4CTBJ6K2.js} +17 -14
- package/bundle/message-pipeline-4KL7OWUH.js +38 -0
- package/bundle/message-pipeline-GFKSHRFU.js +38 -0
- package/bundle/message-pipeline-TGI2WJJM.js +38 -0
- package/bundle/meta.json +3181 -2356
- package/bundle/{notification-U6F5ZBSG.js → notification-ULESRDHB.js} +7 -6
- package/bundle/{openrouter-credits-7XXO6QGQ.js → openrouter-credits-PLIKRY5D.js} +4 -4
- package/bundle/{paths-ZJYIDND2.js → paths-QQM74XYT.js} +4 -2
- package/bundle/{peer-client-T44VI7NB.js → peer-client-D2F5QWRV.js} +8 -8
- package/bundle/{peer-config-D5A4454H.js → peer-config-5SUIBJLG.js} +5 -5
- package/bundle/{phase-transport-FEZ4SIJJ.js → phase-transport-INFD6ELA.js} +10 -10
- package/bundle/phase-transport-KXFZ5BVF.js +23 -0
- package/bundle/{restore-MFSW3EBL.js → restore-Z6MF54HS.js} +4 -4
- package/bundle/{restore-MFSW3EBL.js.map → restore-Z6MF54HS.js.map} +2 -2
- package/bundle/{update-check-O5MS6B3L.js → rollback-5RXXLUD6.js} +5 -7
- package/bundle/{self-healer-utils-7NFH22VJ.js → self-healer-utils-WPKOVXJD.js} +4 -4
- package/bundle/{skill-stats-IPVKMWN3.js → skill-stats-NHNH47QW.js} +5 -5
- package/bundle/{sleep-BPWX3FCN.js → sleep-ENFZFUJJ.js} +8 -8
- package/bundle/sleep-ENFZFUJJ.js.map +7 -0
- package/bundle/{soul-bundle-BRIUDEQ2.js → soul-bundle-QTPWDJB2.js} +7 -7
- package/bundle/soul-bundle-QTPWDJB2.js.map +7 -0
- package/bundle/{soul-loader-GBXJ7EBH.js → soul-loader-LCPTN4PK.js} +8 -8
- package/bundle/soul-loader-LCPTN4PK.js.map +7 -0
- package/bundle/{sse-parser-anthropic-H42TTLBD.js → sse-parser-anthropic-PYDJM3UC.js} +4 -4
- package/bundle/{sse-parser-responses-WG2LY2ML.js → sse-parser-responses-FYT7A5WT.js} +4 -4
- package/bundle/{ssrf-guard-E2KBBC5E.js → ssrf-guard-R4P5OCTO.js} +4 -4
- package/bundle/{start-CBVKNEAT.js → start-4DNURGIY.js} +1 -1
- package/bundle/{stt-CF3CPFDC.js → stt-YN77NND6.js} +5 -5
- package/bundle/stt-YN77NND6.js.map +7 -0
- package/bundle/{subagent-runtime-4MTYUBIZ.js → subagent-runtime-5AYOXOU2.js} +5 -5
- package/bundle/subagent-runtime-5AYOXOU2.js.map +7 -0
- package/bundle/subagent-runtime-VKTX6Q2M.js +13 -0
- package/bundle/subagent-runtime-VKTX6Q2M.js.map +7 -0
- package/bundle/system-event-buffer-OEPPNUGK.js +17 -0
- package/bundle/system-event-buffer-OEPPNUGK.js.map +7 -0
- package/bundle/{system-message-TALP6GP2.js → system-message-BRU267FW.js} +3 -3
- package/bundle/{system-status-GLYXXDE3.js → system-status-7K2QTH3J.js} +58 -51
- package/bundle/system-status-7K2QTH3J.js.map +7 -0
- package/bundle/{hotskills-6ECHLXTJ.js → task-failure-buffer-DPM5MWZ5.js} +8 -7
- package/bundle/task-failure-buffer-DPM5MWZ5.js.map +7 -0
- package/bundle/{task-store-LC7ZMS72.js → task-store-VCBHAB43.js} +5 -5
- package/bundle/task-store-VCBHAB43.js.map +7 -0
- package/bundle/{telegram-adapter-BJJYXN7J.js → telegram-adapter-4KI4CJPG.js} +51 -33
- package/bundle/telegram-adapter-4KI4CJPG.js.map +7 -0
- package/bundle/telegram-adapter-76B4JRJJ.js +1080 -0
- package/bundle/telegram-adapter-76B4JRJJ.js.map +7 -0
- package/bundle/telegram-adapter-VZA74EMT.js +1080 -0
- package/bundle/telegram-adapter-VZA74EMT.js.map +7 -0
- package/bundle/telegram-adapter-ZO2CLU22.js +1080 -0
- package/bundle/telegram-adapter-ZO2CLU22.js.map +7 -0
- package/bundle/{tool-registry-T7XLTI2Q.js → tool-registry-CG7GIS64.js} +13 -9
- package/bundle/tool-registry-CG7GIS64.js.map +7 -0
- package/bundle/tool-registry-TGNU5AMG.js +43 -0
- package/bundle/tool-registry-TGNU5AMG.js.map +7 -0
- package/bundle/{tool-sandbox-OZMXJZLQ.js → tool-sandbox-TLAL55QP.js} +5 -5
- package/bundle/tool-sandbox-TLAL55QP.js.map +7 -0
- package/bundle/{transport-config-G5NKQXPJ.js → transport-config-JIKHB7GT.js} +8 -8
- package/bundle/transport-config-JIKHB7GT.js.map +7 -0
- package/bundle/update-check-AJMIBQGQ.js +81 -0
- package/bundle/update-check-AJMIBQGQ.js.map +7 -0
- package/bundle/{user-registry-NUVNEHJU.js → user-registry-PEFDZ5AV.js} +5 -5
- package/bundle/user-registry-PEFDZ5AV.js.map +7 -0
- package/core/skills/tools/gmail/SKILL.md +5 -14
- package/core/skills/tools/rss/SKILL.md +51 -0
- package/install-manifest.json +8 -2
- package/package.json +4 -2
- package/scripts/abtars-daemon.service +3 -0
- package/scripts/abtars@.service +3 -0
- package/scripts/build-and-deploy.sh +68 -0
- package/scripts/doctor.sh +38 -0
- package/scripts/emergency-deploy.sh +95 -0
- package/scripts/watchdog.sh +51 -5
- package/bundle/chunk-4BUOO6WI.js.map +0 -7
- package/bundle/chunk-A5OJYQNU.js.map +0 -7
- package/bundle/chunk-JX3ZZU3O.js +0 -82
- package/bundle/chunk-JX3ZZU3O.js.map +0 -7
- package/bundle/chunk-KJOCXWJ5.js +0 -131
- package/bundle/chunk-KJOCXWJ5.js.map +0 -7
- package/bundle/chunk-KSEIWT4T.js.map +0 -7
- package/bundle/chunk-KWBGYWDO.js.map +0 -7
- package/bundle/chunk-MJ6PHMOK.js.map +0 -7
- package/bundle/chunk-P2BZSLJJ.js.map +0 -7
- package/bundle/chunk-R36WIOYX.js.map +0 -7
- package/bundle/chunk-RE3F3CFW.js +0 -300
- package/bundle/chunk-RE3F3CFW.js.map +0 -7
- package/bundle/chunk-RSWUPUNA.js.map +0 -7
- package/bundle/chunk-RV54J75Q.js.map +0 -7
- package/bundle/chunk-TYVI3ZWA.js.map +0 -7
- package/bundle/chunk-X5FBUA53.js.map +0 -7
- package/bundle/direct-api-transport-TRV45NO6.js.map +0 -7
- package/bundle/discord-adapter-WA2MFRK3.js.map +0 -7
- package/bundle/system-status-GLYXXDE3.js.map +0 -7
- package/bundle/telegram-adapter-BJJYXN7J.js.map +0 -7
- /package/bundle/{agent-api-rate-limit-C25WGSFF.js.map → agent-api-rate-limit-R2OFAQ3N.js.map} +0 -0
- /package/bundle/{agent-registry-SYUFNSVB.js.map → agent-registry-5VL5KI6U.js.map} +0 -0
- /package/bundle/{bridge-lock-transport-HO545SBK.js.map → agent-registry-PIS5XJHX.js.map} +0 -0
- /package/bundle/{browse-delivery-VTLEAVYA.js.map → bridge-lock-transport-N6OGDOSE.js.map} +0 -0
- /package/bundle/{browser-REIXOJ6S.js.map → browse-delivery-DXGMDMXA.js.map} +0 -0
- /package/bundle/{capability-ILW3D5HS.js.map → browser-QMYGSP5W.js.map} +0 -0
- /package/bundle/{commands-WUGPBPHI.js.map → capability-733TLH4W.js.map} +0 -0
- /package/bundle/{chunk-PZE3J7ER.js.map → chunk-3OXQWII3.js.map} +0 -0
- /package/bundle/{chunk-4KJ76TTE.js.map → chunk-4XW7YA3K.js.map} +0 -0
- /package/bundle/{chunk-ZVDVNSXK.js.map → chunk-7WFE2JI5.js.map} +0 -0
- /package/bundle/{chunk-Q62SXS73.js.map → chunk-BBDKU4EH.js.map} +0 -0
- /package/bundle/{chunk-EX2SRTUE.js.map → chunk-CYSGXNBY.js.map} +0 -0
- /package/bundle/{chunk-LYEAHE5V.js.map → chunk-DCY7DGMT.js.map} +0 -0
- /package/bundle/{chunk-G6IXMYIO.js.map → chunk-DO4INSXE.js.map} +0 -0
- /package/bundle/{chunk-VA5WKN3Z.js.map → chunk-EGA6JQVV.js.map} +0 -0
- /package/bundle/{chunk-URAQLQ2U.js.map → chunk-F3HMZFIL.js.map} +0 -0
- /package/bundle/{chunk-OOKLEC6V.js.map → chunk-FY3QUO2L.js.map} +0 -0
- /package/bundle/{chunk-2BY6I4P5.js.map → chunk-GUTRAMK3.js.map} +0 -0
- /package/bundle/{chunk-GPL57SRN.js.map → chunk-H7RX7UCR.js.map} +0 -0
- /package/bundle/{chunk-BYDUMHXT.js.map → chunk-HAF2AFBW.js.map} +0 -0
- /package/bundle/{chunk-KFENC7BM.js.map → chunk-L33WNMCP.js.map} +0 -0
- /package/bundle/{chunk-JRG4EFMP.js.map → chunk-LBMETTUP.js.map} +0 -0
- /package/bundle/{chunk-TOUZC6NR.js.map → chunk-OKMN6J4Z.js.map} +0 -0
- /package/bundle/{chunk-XZSYMCLF.js.map → chunk-PUDGA4RR.js.map} +0 -0
- /package/bundle/{chunk-CELR236Q.js.map → chunk-Q7CH5DA3.js.map} +0 -0
- /package/bundle/{chunk-UDZIZB5F.js.map → chunk-RTL7HO3N.js.map} +0 -0
- /package/bundle/{chunk-ITG6XGBS.js.map → chunk-SA44ITVX.js.map} +0 -0
- /package/bundle/{chunk-3MO2MDXJ.js.map → chunk-SA6YEFNG.js.map} +0 -0
- /package/bundle/{chunk-GBBTK6H2.js.map → chunk-SRFEIZQT.js.map} +0 -0
- /package/bundle/{chunk-ELRAH7VL.js.map → chunk-VXUVKC66.js.map} +0 -0
- /package/bundle/{config-DQIGDX4W.js.map → commands-IGRSOSK6.js.map} +0 -0
- /package/bundle/{delegation-tools-6FICZQ5G.js.map → commands-LAWVNQTO.js.map} +0 -0
- /package/bundle/{deploy-lib-import-SBKXDD3F.js.map → commands-RBWY7YXB.js.map} +0 -0
- /package/bundle/{env-schema-XCPAJ6IZ.js.map → commands-XFZNMZN6.js.map} +0 -0
- /package/bundle/{hook-system-POI5VRIX.js.map → config-NDEYF4AQ.js.map} +0 -0
- /package/bundle/{daemon-NPKYZ3CJ.js.map → daemon-WOQXCKNL.js.map} +0 -0
- /package/bundle/{hotskills-6ECHLXTJ.js.map → delegation-tools-Z5OM3TXS.js.map} +0 -0
- /package/bundle/{install-SH4UVUXQ.js.map → deploy-lib-import-6VJTYXEG.js.map} +0 -0
- /package/bundle/{deps-HN6CEXA4.js.map → deps-65V7XXG4.js.map} +0 -0
- /package/bundle/{dns-wakeup-RYOCQ6GR.js.map → dns-wakeup-N46RPU5E.js.map} +0 -0
- /package/bundle/{ensure-invariants-BJIEOSJ2.js.map → ensure-invariants-3NOBCYWS.js.map} +0 -0
- /package/bundle/{lazy-require-UFYFFX2R.js.map → env-schema-T43X43BU.js.map} +0 -0
- /package/bundle/{message-pipeline-2MBT44FO.js.map → hook-system-ZCVOFFRD.js.map} +0 -0
- /package/bundle/{notification-U6F5ZBSG.js.map → hotskills-DTROJY6G.js.map} +0 -0
- /package/bundle/{paths-ZJYIDND2.js.map → install-I3CXVW52.js.map} +0 -0
- /package/bundle/{install-manifest-QRWID3KZ.js.map → install-manifest-KBYD7SAY.js.map} +0 -0
- /package/bundle/{irc-adapter-AIEP6OX6.js.map → irc-adapter-HXO5D4SW.js.map} +0 -0
- /package/bundle/{irc-config-6VY67UPQ.js.map → irc-config-XN5VW2V4.js.map} +0 -0
- /package/bundle/{peer-config-D5A4454H.js.map → kanban-board-6Q5E5GEB.js.map} +0 -0
- /package/bundle/{phase-transport-FEZ4SIJJ.js.map → kanban-board-I52RHNHQ.js.map} +0 -0
- /package/bundle/{skill-stats-IPVKMWN3.js.map → lazy-require-R3JYCV5M.js.map} +0 -0
- /package/bundle/{media-utils-MOE36VWY.js.map → media-utils-W7XW3SVV.js.map} +0 -0
- /package/bundle/{sleep-BPWX3FCN.js.map → message-pipeline-4CTBJ6K2.js.map} +0 -0
- /package/bundle/{soul-bundle-BRIUDEQ2.js.map → message-pipeline-4KL7OWUH.js.map} +0 -0
- /package/bundle/{soul-loader-GBXJ7EBH.js.map → message-pipeline-GFKSHRFU.js.map} +0 -0
- /package/bundle/{stt-CF3CPFDC.js.map → message-pipeline-TGI2WJJM.js.map} +0 -0
- /package/bundle/{subagent-runtime-4MTYUBIZ.js.map → notification-ULESRDHB.js.map} +0 -0
- /package/bundle/{openrouter-credits-7XXO6QGQ.js.map → openrouter-credits-PLIKRY5D.js.map} +0 -0
- /package/bundle/{task-store-LC7ZMS72.js.map → paths-QQM74XYT.js.map} +0 -0
- /package/bundle/{peer-client-T44VI7NB.js.map → peer-client-D2F5QWRV.js.map} +0 -0
- /package/bundle/{tool-registry-T7XLTI2Q.js.map → peer-config-5SUIBJLG.js.map} +0 -0
- /package/bundle/{tool-sandbox-OZMXJZLQ.js.map → phase-transport-INFD6ELA.js.map} +0 -0
- /package/bundle/{transport-config-G5NKQXPJ.js.map → phase-transport-KXFZ5BVF.js.map} +0 -0
- /package/bundle/{update-check-O5MS6B3L.js.map → rollback-5RXXLUD6.js.map} +0 -0
- /package/bundle/{self-healer-utils-7NFH22VJ.js.map → self-healer-utils-WPKOVXJD.js.map} +0 -0
- /package/bundle/{user-registry-NUVNEHJU.js.map → skill-stats-NHNH47QW.js.map} +0 -0
- /package/bundle/{sse-parser-anthropic-H42TTLBD.js.map → sse-parser-anthropic-PYDJM3UC.js.map} +0 -0
- /package/bundle/{sse-parser-responses-WG2LY2ML.js.map → sse-parser-responses-FYT7A5WT.js.map} +0 -0
- /package/bundle/{ssrf-guard-E2KBBC5E.js.map → ssrf-guard-R4P5OCTO.js.map} +0 -0
- /package/bundle/{start-CBVKNEAT.js.map → start-4DNURGIY.js.map} +0 -0
- /package/bundle/{system-message-TALP6GP2.js.map → system-message-BRU267FW.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/guardrails.ts", "../src/components/transport/tool-registry.ts", "../src/components/transport/skill-authoring.ts", "../src/components/transport/mcp-tool.ts", "../src/components/transport/kanban-tool.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * guardrails.ts \u2014 path + command restrictions for SECURITY_MODE=guardrails.\n * Defense-in-depth: catches accidental/confused model behavior, NOT adversarial bypass.\n */\n\nimport { resolve, sep } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { getEnv } from \"./env-schema.js\";\nimport { logWarn } from \"./logger.js\";\n\nconst TAG = \"guardrails\";\nconst HOME = homedir();\n\nconst BLOCKED_PATHS = [\n `${HOME}/.ssh${sep}`,\n `${HOME}/.abtars/secret${sep}`,\n `/etc${sep}`,\n `/proc${sep}`,\n `/sys${sep}`,\n `/dev${sep}`,\n `/root${sep}`,\n `/run${sep}`,\n];\n\nconst WRITE_BLOCKED = [\n `${HOME}/.abtars/config/peers.json`,\n `${HOME}/.kiro${sep}`,\n];\n\nconst BLOCKED_COMMAND_PREFIXES = [\n \"rm -rf /\",\n];\n\nconst AUTH_REQUIRED_PATTERNS = [\n /\\brm\\s+(-[a-z]*f[a-z]*r|-[a-z]*r[a-z]*f)\\b/i,\n /\\bgit\\s+(reset\\s+--hard|push\\s+--force|clean\\s+-f|branch\\s+-D)/i,\n /\\bDROP\\s+(TABLE|DATABASE)\\b/i,\n /\\bTRUNCATE\\s/i,\n /\\bkill\\s+(-9|--signal\\s+(KILL|9))/i,\n /\\bsudo\\b/,\n /\\bchmod\\s+777\\b/,\n /\\bDELETE\\s+FROM\\s+\\w+\\s*;/i,\n];\n\nexport type CommandTier = \"block\" | \"auth-required\" | \"allow\";\n\n/** Classify a command into block / auth-required / allow. */\nexport function classifyCommand(cmd: string): CommandTier {\n const trimmed = cmd.trim();\n for (const prefix of BLOCKED_COMMAND_PREFIXES) {\n if (trimmed.toLowerCase().startsWith(prefix.toLowerCase())) return \"block\";\n }\n for (const re of AUTH_REQUIRED_PATTERNS) {\n if (re.test(trimmed)) return \"auth-required\";\n }\n return \"allow\";\n}\n\nexport type SecurityMode = \"off\" | \"guardrails\" | \"sandbox\";\n\nexport function getSecurityMode(): SecurityMode {\n const mode = getEnv().securityMode as SecurityMode;\n return mode || \"off\";\n}\n\nexport function isGuardrailsActive(): boolean {\n return getSecurityMode() !== \"off\";\n}\n\n/** Check if a file path is allowed. Returns error message or null if OK. */\nexport function checkPath(path: string, mode: \"read\" | \"write\"): string | null {\n if (!isGuardrailsActive()) return null;\n\n const resolved = resolve(path) + (path.endsWith(\"/\") ? sep : \"\");\n\n for (const blocked of BLOCKED_PATHS) {\n if (resolved.startsWith(blocked) || resolved === blocked.slice(0, -1)) {\n return `Path blocked by guardrails: ${path}`;\n }\n }\n\n if (mode === \"write\") {\n for (const wb of WRITE_BLOCKED) {\n if (resolved.startsWith(wb) || resolved === wb) {\n return `Write blocked by guardrails: ${path}`;\n }\n }\n }\n\n return null;\n}\n\n/** Check if a bash command is allowed. Returns error message or null if OK. */\nexport function checkCommand(cmd: string): string | null {\n if (!isGuardrailsActive()) return null;\n\n const tier = classifyCommand(cmd);\n if (tier === \"block\") {\n logWarn(TAG, `Blocked command: ${cmd.slice(0, 100)}`);\n return `Command blocked by guardrails: ${cmd.slice(0, 60)}`;\n }\n // \"auth-required\" is handled by action-gate at a higher level \u2014 not blocked here\n return null;\n}\n", "/**\n * Tool registry for DirectApiTransport.\n * Phase 2: native tool schemas. Phase 3: in-process memory when available.\n */\n\nimport { execFile } from \"node:child_process\";\nimport { appendFileSync, mkdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport type { MemoryBackend } from \"abmind\";\nimport type { InstantStoreParams } from \"../../types/index.js\";\nimport { logWarn, redactSecrets } from \"../logger.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\nimport { checkTool, checkPath, auditDeny, type SandboxPolicy } from \"../tool-sandbox.js\";\nimport { loadUsers } from \"../user-registry.js\";\n\nfunction getMasterUserId(): string {\n return loadUsers().users.find(u => u.role === \"master\")?.userId ?? \"aksika\";\n}\n\nconst TAG = \"tool_registry\";\n\n// #449: append-only audit log\nconst AUDIT_DIR = join(process.env[\"ABTARS_HOME\"] ?? join(homedir(), \".abtars\"), \"logs\");\nconst AUDIT_PATH = join(AUDIT_DIR, \"audit.jsonl\");\ntry { mkdirSync(AUDIT_DIR, { recursive: true }); } catch (err) { logAndSwallow(TAG, \"mkdirSync audit dir\", err); }\nfunction audit(entry: Record<string, unknown>): void {\n try { appendFileSync(AUDIT_PATH, JSON.stringify(entry) + \"\\n\"); } catch (err) { logAndSwallow(TAG, \"audit write\", err); }\n}\n\nexport type ToolDefinition = {\n readonly name: string;\n readonly description: string;\n readonly parameters: Record<string, unknown>;\n execute(args: Record<string, string>, context?: { userId: string; signal?: AbortSignal }): Promise<string>;\n};\n\nconst BASH_TIMEOUT_MS = 300_000;\nconst CLI_TIMEOUT_MS = 60_000;\n\n/**\n * Patterns that would spawn or restart a bridge/watchdog process.\n * Blocked to prevent the LLM (especially fallback models) from accidentally\n * starting a second bridge instance, which would cause port conflicts,\n * Telegram 409 errors, and bridge.lock PID confusion.\n *\n * See post-mortem of 2026-04-22 outage: cron agent ran execute_bash that\n * spawned a rogue bridge alongside the watchdog-supervised one.\n */\nconst BLOCKED_PATTERNS: readonly RegExp[] = [\n /\\bmain\\.js\\b/, // node .../current/dist/main.js ...\n /\\babtars\\.sh\\b/, // the launcher\n /\\bwatchdog\\.sh\\b/, // the watchdog\n /\\blaunchctl\\s+(load|bootstrap|kickstart|start)\\b/, // launchd bridge start\n];\n\nexport function isBridgeSpawnCommand(cmd: string): boolean {\n return BLOCKED_PATTERNS.some(p => p.test(cmd));\n}\n\n/** Block kill/pkill/killall targeting the bridge's own PID or process patterns (#414). */\nfunction isBridgeKillCommand(cmd: string): boolean {\n const pid = process.pid;\n const ppid = process.ppid;\n // Direct kill of own PID or parent\n if (new RegExp(`\\\\bkill\\\\s+(-\\\\d+\\\\s+)?${pid}\\\\b`).test(cmd)) return true;\n if (new RegExp(`\\\\bkill\\\\s+(-\\\\d+\\\\s+)?${ppid}\\\\b`).test(cmd)) return true;\n // pkill/killall targeting bridge patterns\n if (/\\b(pkill|killall)\\b.*\\b(abtars|main\\.js|watchdog)\\b/.test(cmd)) return true;\n if (/\\bkill\\b.*\\$\\(.*pgrep.*abtars/.test(cmd)) return true;\n return false;\n}\n\nfunction runBash(cmd: string, timeout = BASH_TIMEOUT_MS, signal?: AbortSignal): Promise<string> {\n // Guardrails: command check\n const { checkCommand, classifyCommand } = require(\"../guardrails.js\") as typeof import(\"../guardrails.js\");\n const cmdBlock = checkCommand(cmd);\n if (cmdBlock) {\n logWarn(\"tool-registry\", `Guardrails blocked: ${cmd.slice(0, 200)}`);\n return Promise.resolve(JSON.stringify({ stderr: cmdBlock, exit_code: 126 }));\n }\n\n // Action gate: auth-required commands\n const tier = classifyCommand(cmd);\n if (tier === \"auth-required\" && _actionGate) {\n return _actionGate.requestAuth(\"bash-auth\", cmd).then((granted) => {\n if (!granted) {\n logWarn(\"tool-registry\", `Auth denied for: ${cmd.slice(0, 200)}`);\n return JSON.stringify({ stderr: \"Command requires authorization. Master denied or timed out.\", exit_code: 126 });\n }\n return executeBash(cmd, timeout, signal);\n });\n }\n\n if (isBridgeSpawnCommand(cmd)) {\n logWarn(\"tool-registry\", `Blocked bridge-spawn command: ${cmd.slice(0, 200)}`);\n return Promise.resolve(JSON.stringify({\n stderr: \"Command blocked: this would spawn/restart a bridge or watchdog process. The bridge is already running under launchd+watchdog supervision; use launchctl inspection commands (launchctl list, launchctl print) or signal the existing process instead.\",\n exit_code: 126,\n }));\n }\n if (isBridgeKillCommand(cmd)) {\n logWarn(\"tool-registry\", `Blocked bridge-kill command: ${cmd.slice(0, 200)}`);\n return Promise.resolve(JSON.stringify({\n stderr: \"Command blocked: this would kill the bridge process (yourself). Ask the user to send /restart for a session reset or restart the bridge manually.\",\n exit_code: 126,\n }));\n }\n return executeBash(cmd, timeout, signal);\n}\n\nfunction executeBash(cmd: string, timeout: number, signal?: AbortSignal): Promise<string> {\n return new Promise((resolve) => {\n const child = execFile(\"bash\", [\"-c\", cmd], { timeout, maxBuffer: 1024 * 1024 }, (err, stdout, stderr) => {\n const result: Record<string, unknown> = {};\n if (stdout) result[\"stdout\"] = stdout.slice(0, 50_000);\n if (stderr) result[\"stderr\"] = stderr.slice(0, 10_000);\n if (err) result[\"exit_code\"] = (err as NodeJS.ErrnoException & { code?: number }).code ?? 1;\n else result[\"exit_code\"] = 0;\n resolve(JSON.stringify(result));\n });\n if (signal) {\n if (signal.aborted) { child.kill(\"SIGTERM\"); return; }\n const onAbort = (): void => { child.kill(\"SIGTERM\"); };\n signal.addEventListener(\"abort\", onAbort, { once: true });\n child.on(\"exit\", () => signal.removeEventListener(\"abort\", onAbort));\n }\n });\n}\n\nlet memoryBackend: MemoryBackend | null = null;\n\n/** Wire in-process memory backend. Call once after memory init. */\nexport function setMemoryBackend(backend: MemoryBackend | null): void {\n memoryBackend = backend;\n}\n\nlet _actionGate: import(\"../action-gate.js\").ActionGate | null = null;\n\n/** Wire action gate for auth-required commands. */\nexport function setActionGate(gate: import(\"../action-gate.js\").ActionGate | null): void {\n _actionGate = gate;\n}\n\nlet _peerActivityCb: ((msg: string) => void) | null = null;\n\n/** Wire peer activity notification callback. */\nexport function setPeerActivityCallback(cb: ((msg: string) => void) | null): void {\n _peerActivityCb = cb;\n}\n\n// --- Tool definitions ---\n\nconst bashTool: ToolDefinition = {\n name: \"execute_bash\",\n description: \"Execute a bash command. Use for file operations, git, running scripts, and any shell command. Commands that would spawn or restart a bridge/watchdog process (node main.js, abtars.sh, watchdog.sh, launchctl load/bootstrap/kickstart/start) are blocked \u2014 the bridge is already supervised.\",\n parameters: {\n type: \"object\",\n properties: { command: { type: \"string\", description: \"The bash command to execute\" } },\n required: [\"command\"],\n },\n execute: (args, context) => runBash(args[\"command\"] ?? \"\", BASH_TIMEOUT_MS, context?.signal),\n};\n\nlet _storeCount = 0;\nconst STORE_CAP = 20;\n\n/** Reset store counter (called on new subagent session). */\nexport function resetStoreCounter(): void { _storeCount = 0; }\n\nconst memoryStoreTool: ToolDefinition = {\n name: \"memory_store\",\n description: \"Store a memory. Use after learning something about the user, their preferences, decisions, or facts worth remembering.\",\n parameters: {\n type: \"object\",\n properties: {\n translated: { type: \"string\", description: \"Memory content in English\" },\n original: { type: \"string\", description: \"Memory content in original language (if not English)\" },\n type: { type: \"string\", enum: [\"fact\", \"preference\", \"decision\", \"experience\", \"skill\", \"relationship\", \"goal\"], description: \"Memory type\" },\n emotion: { type: \"integer\", description: \"Emotion score -5 to +5 (0=neutral)\" },\n confidence: { type: \"integer\", description: \"Confidence 1-5 (3=default)\" },\n classification: { type: \"integer\", description: \"0=public (general knowledge), 1=internal (default), 2=confidential (personal preferences, habits, opinions about specific users), 3=secret (credentials, API keys, tokens, passwords \u2014 store IMMEDIATELY with exact string, never paraphrase, never wait for Dreamy)\" },\n },\n required: [\"translated\", \"type\"],\n },\n async execute(args, context): Promise<string> {\n if (++_storeCount > STORE_CAP) {\n return JSON.stringify({ stored: false, error: \"Store limit reached for this session. Move to next task.\" });\n }\n if (memoryBackend) {\n try {\n const params: InstantStoreParams = {\n userId: context?.userId ?? getMasterUserId(),\n contentEn: args[\"translated\"] ?? \"\",\n contentOriginal: args[\"original\"] ?? args[\"translated\"] ?? \"\",\n memoryType: (args[\"type\"] ?? \"fact\") as InstantStoreParams[\"memoryType\"],\n emotionScore: parseInt(args[\"emotion\"] ?? \"0\", 10),\n confidence: parseInt(args[\"confidence\"] ?? \"3\", 10),\n classification: parseInt(args[\"classification\"] ?? \"1\", 10),\n };\n const result = await memoryBackend.instantStore({ ...params, createdBy: \"tool:memory_store\" });\n return JSON.stringify(result);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n // #706: FTS5 corruption self-heal \u2014 rebuild indexes and retry once\n if (msg.includes(\"fts5\") || msg.includes(\"corruption\")) {\n try {\n memoryBackend.rebuildFtsIndexes();\n logWarn(\"tool-registry\", \"FTS corruption detected \u2014 rebuilt indexes, retrying store\");\n const params: InstantStoreParams = {\n userId: context?.userId ?? getMasterUserId(),\n contentEn: args[\"translated\"] ?? \"\",\n contentOriginal: args[\"original\"] ?? args[\"translated\"] ?? \"\",\n memoryType: (args[\"type\"] ?? \"fact\") as InstantStoreParams[\"memoryType\"],\n emotionScore: parseInt(args[\"emotion\"] ?? \"0\", 10),\n confidence: parseInt(args[\"confidence\"] ?? \"3\", 10),\n classification: parseInt(args[\"classification\"] ?? \"1\", 10),\n };\n const result = await memoryBackend.instantStore({ ...params, createdBy: \"tool:memory_store\" });\n return JSON.stringify(result);\n } catch (retryErr) { /* fall through */ }\n }\n return JSON.stringify({ error: msg });\n }\n }\n let cmd = `abmind store --translated ${JSON.stringify(args[\"translated\"] ?? \"\")} --type ${args[\"type\"] ?? \"fact\"}`;\n if (args[\"original\"]) cmd += ` --original ${JSON.stringify(args[\"original\"])}`;\n if (args[\"emotion\"]) cmd += ` --emotion-score ${args[\"emotion\"]}`;\n if (args[\"confidence\"]) cmd += ` --confidence ${args[\"confidence\"]}`;\n if (args[\"classification\"]) cmd += ` --classification ${args[\"classification\"]}`;\n return runBash(cmd, CLI_TIMEOUT_MS);\n },\n};\n\nconst memoryRecallTool: ToolDefinition = {\n name: \"memory_recall\",\n description: \"Search memories by keyword or semantic query. Returns relevant stored memories.\",\n parameters: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n limit: { type: \"integer\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n async execute(args, context): Promise<string> {\n if (memoryBackend) {\n try {\n const result = await memoryBackend.recall({\n translated: [args[\"query\"] ?? \"\"],\n original: args[\"query\"] ?? \"\",\n userId: context?.userId ?? getMasterUserId(),\n limit: parseInt(args[\"limit\"] ?? \"10\", 10),\n });\n return JSON.stringify(result);\n } catch (err) {\n return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });\n }\n }\n let cmd = `abmind recall ${JSON.stringify(args[\"query\"] ?? \"\")}`;\n if (args[\"limit\"]) cmd += ` --limit ${args[\"limit\"]}`;\n return runBash(cmd, CLI_TIMEOUT_MS);\n },\n};\n\nconst memoryEditTool: ToolDefinition = {\n name: \"memory_edit\",\n description: \"Edit an existing memory by ID. Change content, type, emotion, confidence, or classification.\",\n parameters: {\n type: \"object\",\n properties: {\n memory_id: { type: \"integer\", description: \"Memory ID to edit\" },\n translated: { type: \"string\", description: \"New English content\" },\n original: { type: \"string\", description: \"New original language content\" },\n type: { type: \"string\", description: \"New memory type\" },\n emotion: { type: \"integer\", description: \"New emotion score\" },\n confidence: { type: \"integer\", description: \"New confidence\" },\n classification: { type: \"integer\", description: \"New classification\" },\n caller: { type: \"string\", enum: [\"kp\", \"dreamy\"], description: \"Who is making the edit\" },\n },\n required: [\"memory_id\"],\n },\n async execute(args): Promise<string> {\n if (memoryBackend) {\n try {\n const result = await memoryBackend.editMemory({\n memoryId: parseInt(args[\"memory_id\"] ?? \"0\", 10),\n contentEn: args[\"translated\"],\n contentOriginal: args[\"original\"],\n memoryType: args[\"type\"] as \"fact\" | \"decision\" | \"preference\" | \"event\" | undefined,\n emotionScore: args[\"emotion\"] ? parseInt(args[\"emotion\"], 10) : undefined,\n confidence: args[\"confidence\"] ? parseInt(args[\"confidence\"], 10) : undefined,\n classification: args[\"classification\"] ? parseInt(args[\"classification\"], 10) : undefined,\n caller: (args[\"caller\"] ?? \"kp\") as \"kp\" | \"dreamy\",\n });\n return JSON.stringify(result);\n } catch (err) {\n return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });\n }\n }\n let cmd = `abmind edit --memory-id ${args[\"memory_id\"] ?? \"0\"}`;\n if (args[\"translated\"]) cmd += ` --translated ${JSON.stringify(args[\"translated\"])}`;\n if (args[\"original\"]) cmd += ` --original ${JSON.stringify(args[\"original\"])}`;\n if (args[\"type\"]) cmd += ` --type ${args[\"type\"]}`;\n if (args[\"emotion\"]) cmd += ` --emotion-score ${args[\"emotion\"]}`;\n if (args[\"confidence\"]) cmd += ` --confidence ${args[\"confidence\"]}`;\n if (args[\"classification\"]) cmd += ` --classification ${args[\"classification\"]}`;\n if (args[\"caller\"]) cmd += ` --caller ${args[\"caller\"]}`;\n return runBash(cmd, CLI_TIMEOUT_MS);\n },\n};\n\nconst webBrowseTool: ToolDefinition = {\n name: \"web_browse\",\n description: \"Browse a URL or perform a complex multi-step web task. For quick lookups use execute_bash with curl.\",\n parameters: {\n type: \"object\",\n properties: {\n task: { type: \"string\", description: \"What to do on the web\" },\n chat_id: { type: \"string\", description: \"Chat ID for result delivery\" },\n engine: { type: \"string\", enum: [\"patchright\"], description: \"Browser engine (default: patchright)\" },\n },\n required: [\"task\", \"chat_id\"],\n },\n execute: (args) => {\n let cmd = `abtars-browse --task ${JSON.stringify(args[\"task\"] ?? \"\")} --chat-id ${args[\"chat_id\"] ?? \"0\"}`;\n if (args[\"engine\"]) cmd += ` --engine ${args[\"engine\"]}`;\n return runBash(cmd, CLI_TIMEOUT_MS);\n },\n};\n\nconst todoTool: ToolDefinition = {\n name: \"todo_manage\",\n description: \"Manage TODO items. Add, complete, or list tasks.\",\n parameters: {\n type: \"object\",\n properties: {\n action: { type: \"string\", enum: [\"add\", \"done\", \"list\", \"remove\"], description: \"Action to perform\" },\n text: { type: \"string\", description: \"TODO text (for add)\" },\n id: { type: \"string\", description: \"TODO ID (for done/remove)\" },\n },\n required: [\"action\"],\n },\n execute: (args) => {\n const action = args[\"action\"] ?? \"list\";\n if (action === \"add\") return runBash(`abtars-todo add ${JSON.stringify(args[\"text\"] ?? \"\")}`, CLI_TIMEOUT_MS);\n if (action === \"done\") return runBash(`abtars-todo done ${args[\"id\"] ?? \"\"}`, CLI_TIMEOUT_MS);\n if (action === \"remove\") return runBash(`abtars-todo remove ${args[\"id\"] ?? \"\"}`, CLI_TIMEOUT_MS);\n return runBash(\"abtars-todo list\", CLI_TIMEOUT_MS);\n },\n};\n\nlet _enqueueCron: ((id: string, manual?: boolean) => string | null) | null = null;\n\n/** Inject enqueueCron from bridge for task_manage --run. */\nexport function setEnqueueCron(fn: (id: string, manual?: boolean) => string | null): void { _enqueueCron = fn; }\n\nlet _ircSend: ((channel: string, message: string) => void) | null = null;\n\n/** Inject IRC send from bridge for irc_send tool. */\nexport function setIrcSend(fn: (channel: string, message: string) => void): void { _ircSend = fn; }\n\n/** @deprecated \u2014 secret_get now reads from file, not DB. Kept for backward compat (callers may still call this). */\nexport function setSecretGetDb(_db: unknown): void { /* no-op */ }\n\nlet _sendDocument: ((path: string, caption?: string) => Promise<number>) | null = null;\n\n/**\n * Inject sendDocument from bridge for the send_document tool.\n * Caller binds main chat id + telegram adapter; tool is a thin wrapper around that.\n */\nexport function setSendDocument(fn: ((path: string, caption?: string) => Promise<number>) | null): void { _sendDocument = fn; }\n\nconst sendDocumentTool: ToolDefinition = {\n name: \"send_document\",\n description: \"Send a file from disk to the user's Telegram chat. Use for delivering reports, daily summaries, logs, or any .md file the user asks for. Do not summarize \u2014 the raw file is sent as an attachment.\",\n parameters: {\n type: \"object\",\n properties: {\n path: { type: \"string\", description: \"Absolute path to the file\" },\n caption: { type: \"string\", description: \"Optional short caption (\u22641024 chars)\" },\n },\n required: [\"path\"],\n },\n execute: async (args) => {\n const path = args[\"path\"];\n if (!path) return JSON.stringify({ error: \"path is required\" });\n if (!_sendDocument) return JSON.stringify({ error: \"Telegram not configured (sendDocument unavailable)\" });\n try {\n const messageId = await _sendDocument(path, args[\"caption\"]);\n return JSON.stringify({ ok: true, message_id: messageId });\n } catch (err) {\n return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });\n }\n },\n};\n\nconst taskTool: ToolDefinition = {\n name: \"task_manage\",\n description: \"Manage scheduled/recurring tasks (cron). Add, list, remove, pause, resume, or run tasks. Use action=run to execute a task immediately via the cron queue (isolated subagent).\",\n parameters: {\n type: \"object\",\n properties: {\n action: { type: \"string\", enum: [\"add\", \"list\", \"remove\", \"pause\", \"resume\", \"run\"], description: \"Action\" },\n message: { type: \"string\", description: \"Task message/command (for add)\" },\n schedule: { type: \"string\", description: \"Cron schedule expression (for add)\" },\n type: { type: \"string\", enum: [\"reminder\", \"script\", \"agent\"], description: \"Task type (for add)\" },\n chat_id: { type: \"string\", description: \"Chat ID (for add)\" },\n id: { type: \"string\", description: \"Task ID (for remove/pause/resume/run)\" },\n },\n required: [\"action\"],\n },\n execute: (args) => {\n const action = args[\"action\"] ?? \"list\";\n if (action === \"list\") return runBash(\"abtars-task list\", CLI_TIMEOUT_MS);\n if (action === \"remove\") return runBash(`abtars-task remove ${args[\"id\"] ?? \"\"}`, CLI_TIMEOUT_MS);\n if (action === \"pause\") return runBash(`abtars-task pause ${args[\"id\"] ?? \"\"}`, CLI_TIMEOUT_MS);\n if (action === \"resume\") return runBash(`abtars-task resume ${args[\"id\"] ?? \"\"}`, CLI_TIMEOUT_MS);\n if (action === \"run\") {\n if (!_enqueueCron) return Promise.resolve(JSON.stringify({ error: \"enqueueCron not available\" }));\n const err = _enqueueCron(args[\"id\"] ?? \"\", true);\n return Promise.resolve(JSON.stringify(err ? { error: err } : { ok: true, message: `Task ${args[\"id\"]} enqueued for immediate execution` }));\n }\n let cmd = `abtars-task add --message ${JSON.stringify(args[\"message\"] ?? \"\")}`;\n if (args[\"schedule\"]) cmd += ` --schedule ${JSON.stringify(args[\"schedule\"])}`;\n if (args[\"type\"]) cmd += ` --type ${args[\"type\"]}`;\n if (args[\"chat_id\"]) cmd += ` --chat-id ${args[\"chat_id\"]}`;\n return runBash(cmd, CLI_TIMEOUT_MS);\n },\n};\n\nconst peerSessionTool: ToolDefinition = {\n name: \"peer_session\",\n description: \"Open or continue a peer-to-peer session with another agent. Messages persist across turns. Use only when the user explicitly asks to contact another agent.\",\n parameters: {\n type: \"object\",\n properties: {\n peer_name: { type: \"string\", description: \"Name of the peer (as in peers.json)\" },\n message: { type: \"string\", description: \"Your message to the peer\" },\n session_id: { type: \"string\", description: \"Session ID from previous call (omit for new conversation)\" },\n },\n required: [\"peer_name\", \"message\"],\n },\n async execute(args) {\n const { callPeer } = await import(\"../peer-client.js\");\n const { loadPeerConfig } = await import(\"../peer-config.js\");\n const { getOrCreateSession, addTurn, isEnded, destroySession } = await import(\"../peer-sessions.js\");\n\n const peerName = args.peer_name?.trim();\n const message = args.message?.trim();\n if (!peerName || !message) return JSON.stringify({ error: \"peer_name and message required\" });\n\n const config = loadPeerConfig();\n if (peerName === config.self.name) return JSON.stringify({ error: \"Cannot chat with yourself\" });\n if (!config.peers[peerName]) return JSON.stringify({ error: `Unknown peer: ${peerName}` });\n\n const session = getOrCreateSession(args.session_id?.trim() || undefined, peerName);\n\n // Check turn cap before sending\n if (session.messages.length >= 20) {\n destroySession(session.id);\n return JSON.stringify({ session_id: session.id, response: \"[SESSION_END] Turn limit reached.\", ended: true, reason: \"max-turns\" });\n }\n\n addTurn(session, \"user\", message);\n\n // Build full conversation for peer (OpenAI messages format)\n const prompt = session.messages.map(m => `${m.role === \"user\" ? \"You\" : \"Peer\"}: ${m.content}`).join(\"\\n\") + \"\\n\\nRespond to the latest message.\";\n\n try {\n const response = await callPeer(peerName, prompt, config.maxHops);\n addTurn(session, \"assistant\", response);\n _peerActivityCb?.(`\uD83E\uDD16 Agents: ${config.self.name} \u2194 ${peerName} session. [turn ${session.messages.length}]`);\n\n const { ended, reason } = isEnded(session, response);\n if (ended) destroySession(session.id);\n\n return JSON.stringify({ session_id: session.id, response, ended, reason });\n } catch (err) {\n destroySession(session.id);\n return JSON.stringify({ error: `peer_session failed: ${err instanceof Error ? err.message : String(err)}`, session_id: session.id, ended: true });\n }\n },\n};\n\nconst peerWakeupTool: ToolDefinition = {\n name: \"peer_wakeup\",\n description: \"Send a wake-up signal to a peer that cannot reach us directly (firewall). The peer's bridge will call us back via A2A within seconds.\",\n parameters: {\n type: \"object\",\n properties: {\n peer_name: { type: \"string\", description: \"Name of the peer to wake up (as in peers.json)\" },\n },\n required: [\"peer_name\"],\n },\n async execute(args) {\n const { sendWakeup } = await import(\"../dns-wakeup.js\");\n const { loadPeerConfig } = await import(\"../peer-config.js\");\n const peerName = args.peer_name?.trim();\n if (!peerName) return JSON.stringify({ error: \"peer_name required\" });\n const config = loadPeerConfig();\n const peer = config.peers[peerName];\n if (!peer) return JSON.stringify({ error: `Unknown peer: ${peerName}` });\n const udpPort = peer.udpPort ?? 5353;\n sendWakeup(config.self.name, peer.host, udpPort, peer.token);\n return JSON.stringify({ ok: true, message: `Wake-up sent to ${peerName}. Expect callback within seconds.` });\n },\n};\n\nconst ircSendTool: ToolDefinition = {\n name: \"irc_send\",\n description: \"Send a message to an IRC channel (e.g. #bridges)\",\n parameters: {\n channel: { type: \"string\", description: \"IRC channel (e.g. #bridges)\" },\n message: { type: \"string\", description: \"Message text to send\" },\n },\n execute: async (args) => {\n if (!_ircSend) return JSON.stringify({ error: \"IRC adapter not connected\" });\n const channel = args[\"channel\"] ?? \"\";\n const message = args[\"message\"] ?? \"\";\n if (!channel || !message) return JSON.stringify({ error: \"channel and message are required\" });\n _ircSend(channel, message);\n return JSON.stringify({ ok: true, channel, sent: message.length + \" chars\" });\n },\n};\n\nconst secretGetTool: ToolDefinition = {\n name: \"secret_get\",\n description: \"Retrieve a secret from ~/.abtars/secret/. For env-var secrets (no extension), returns the value. For files (with extension like .json), returns the full decrypted content. NEVER echo the value to the user.\",\n parameters: {\n properties: {\n name: { type: \"string\", description: \"Exact filename in secret/ dir (e.g. 'OPENROUTER_API_KEY', 'x-cookies.json')\" },\n },\n required: [\"name\"],\n },\n execute: async (args) => {\n const name = args.name?.trim();\n if (!name) return JSON.stringify({ error: \"name is required\" });\n try {\n const { join } = await import(\"node:path\");\n const { homedir } = await import(\"node:os\");\n const { readFileSync, existsSync } = await import(\"node:fs\");\n const { createDecipheriv, hkdfSync } = await import(\"node:crypto\");\n const { loadKey } = await import(\"abmind\");\n\n const secretPath = join(homedir(), \".abtars\", \"secret\", name);\n if (!existsSync(secretPath)) return JSON.stringify({ error: `secret '${name}' not found` });\n\n const raw = readFileSync(secretPath, \"utf-8\").trim();\n if (!raw) return JSON.stringify({ error: `secret '${name}' is empty` });\n\n let value: string;\n if (raw.startsWith(\"ENC:\")) {\n const master = loadKey();\n const key = Buffer.from(hkdfSync(\"sha256\", master, \"\", \"abtars-secrets-files-v1\", 32));\n const buf = Buffer.from(raw.slice(4), \"base64\");\n const d = createDecipheriv(\"aes-256-gcm\", key, buf.subarray(1, 13));\n d.setAuthTag(buf.subarray(buf.length - 16));\n value = d.update(buf.subarray(13, buf.length - 16), undefined, \"utf-8\") + d.final(\"utf-8\");\n } else {\n value = raw;\n }\n\n // For env-var type (no extension): also inject into process.env\n if (!name.includes(\".\")) {\n process.env[name] = value;\n return JSON.stringify({ ok: true, env_var: `$${name}`, hint: `Use $${name} in commands. NEVER print or echo the value.` });\n }\n return JSON.stringify({ ok: true, content: value });\n } catch (err) {\n return JSON.stringify({ error: `secret_get failed: ${err instanceof Error ? err.message : String(err)}` });\n }\n },\n};\n\nimport { skillCreateTool, skillUpdateTool, skillPatchTool, skillRemoveTool } from \"./skill-authoring.js\";\nimport { mcpTool } from \"./mcp-tool.js\";\nimport { getDelegationTools } from \"./delegation-tools.js\";\nimport { kanbanTool } from \"./kanban-tool.js\";\n\nconst ALL_TOOLS: ToolDefinition[] = [bashTool, memoryStoreTool, memoryRecallTool, memoryEditTool, webBrowseTool, todoTool, taskTool, sendDocumentTool, peerSessionTool, peerWakeupTool, ircSendTool, secretGetTool, skillCreateTool, skillUpdateTool, skillPatchTool, skillRemoveTool, mcpTool, kanbanTool, ...getDelegationTools()];\n\nexport function getToolDefinitions(): ToolDefinition[] { return ALL_TOOLS; }\n\nexport function getToolSchemas(policy?: SandboxPolicy): Array<{ type: \"function\"; function: { name: string; description: string; parameters: Record<string, unknown> } }> {\n const tools = policy ? ALL_TOOLS.filter(t => checkTool(t.name, policy).allowed) : ALL_TOOLS;\n return tools.map(t => ({\n type: \"function\" as const,\n function: { name: t.name, description: t.description, parameters: t.parameters },\n }));\n}\n\nimport { bumpRead } from \"../skill-stats.js\";\n\n/** Check if a bash command result indicates a skill file was read. */\nfunction checkSkillRead(toolName: string, args: Record<string, string>): void {\n if (toolName !== \"execute_bash\") return;\n const cmd = args[\"command\"] ?? \"\";\n if (cmd.includes(\"/.abtars/skills/\") && cmd.includes(\"/SKILL.md\")) {\n const match = cmd.match(/\\/.abtars\\/skills\\/[^/]+\\/([^/]+)\\/SKILL\\.md/);\n if (match) bumpRead(match[1]!);\n }\n}\n\nexport async function executeToolCall(name: string, args: Record<string, string>, context?: { userId: string; signal?: AbortSignal; sandboxPolicy?: SandboxPolicy }): Promise<string> {\n // Sandbox enforcement\n if (context?.sandboxPolicy) {\n const toolCheck = checkTool(name, context.sandboxPolicy);\n if (!toolCheck.allowed) {\n const available = ALL_TOOLS.filter(t => checkTool(t.name, context.sandboxPolicy!).allowed).map(t => t.name);\n auditDeny(name, undefined, \"session\", toolCheck.reason!);\n return JSON.stringify({ error: `Tool '${name}' not available in this session`, available_tools: available, reason: \"peer_sandbox\" });\n }\n const filePath = args[\"path\"] ?? args[\"file_path\"];\n if (filePath) {\n const mode = name.includes(\"read\") || name === \"memory_recall\" ? \"read\" as const : \"write\" as const;\n const pathCheck = checkPath(filePath, mode, context.sandboxPolicy);\n if (!pathCheck.allowed) {\n auditDeny(name, filePath, \"session\", pathCheck.reason!);\n return JSON.stringify({ error: pathCheck.reason, reason: \"peer_sandbox\" });\n }\n }\n }\n\n const tool = ALL_TOOLS.find(t => t.name === name);\n if (!tool) return JSON.stringify({ error: `Unknown tool: ${name}` });\n const ts = Date.now();\n\n // #621: redact abmind_store args based on classification\n const storeClass = (name === \"abmind_store\" || name === \"memory_store\") ? parseInt(args.classification ?? args.class ?? \"1\", 10) : 0;\n const auditArgs = storeClass >= 2\n ? `{\"class\":${storeClass},\"[REDACTED]\":true}`\n : redactSecrets(JSON.stringify(args));\n audit({ ts, tool: name, args: auditArgs, userId: context?.userId });\n\n try {\n const result = await tool.execute(args, context);\n audit({ ts, tool: name, status: \"ok\", chars: result.length });\n checkSkillRead(name, args);\n return result;\n } catch (err) {\n audit({ ts, tool: name, status: \"error\", error: err instanceof Error ? err.message : String(err) });\n throw err;\n }\n}\n", "/**\n * skill-authoring.ts \u2014 skill lifecycle tools (#381, #613, #614).\n * Agent persists procedural knowledge as skills under ~/.abtars/skills/self/.\n */\n\nimport { existsSync, mkdirSync, writeFileSync, readFileSync, renameSync, appendFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { abmind } from \"../../utils/abmind-lazy.js\";\nimport { abtarsHome } from \"../../paths.js\";\nimport { logInfo } from \"../logger.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\nimport { setProvenance } from \"../skill-stats.js\";\nimport type { ToolDefinition } from \"./tool-registry.js\";\n\nconst TAG = \"skill-authoring\";\nconst NAME_RE = /^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/;\nconst MIN_BYTES = 100;\nconst MAX_BYTES = 50_000;\nconst MAX_TAGS = 5;\n\nfunction skillsDir(): string { return join(abtarsHome(), \"skills\"); }\nfunction selfDir(): string { return join(skillsDir(), \"self\"); }\nfunction trashDir(): string { return join(skillsDir(), \".trash\"); }\nfunction auditLogPath(): string { return join(abtarsHome(), \"logs\", \"skill-authoring.log\"); }\n\nfunction audit(entry: string): void {\n const line = `[${new Date().toISOString()}] ${entry}\\n`;\n try {\n const dir = join(abtarsHome(), \"logs\");\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n appendFileSync(auditLogPath(), line);\n } catch (err) { logAndSwallow(TAG, \"audit write\", err); }\n}\n\nfunction validate(name: string, description: string, content: string): string | null {\n if (!NAME_RE.test(name)) return `Invalid name \"${name}\". Must be 3-64 chars, lowercase alphanumeric + hyphens, no leading/trailing hyphens.`;\n const desc = description.trim();\n if (desc.length < 1 || desc.length > 120) return `Description must be 1-120 chars (got ${desc.length}).`;\n const bytes = Buffer.byteLength(content, \"utf-8\");\n if (bytes < MIN_BYTES) return `Content too short (${bytes} bytes, minimum ${MIN_BYTES}). Write a useful skill, not a one-liner.`;\n if (bytes > MAX_BYTES) return `Content too large (${bytes} bytes, maximum ${MAX_BYTES}). Split into a skill + references/ files.`;\n const path = join(selfDir(), name, \"SKILL.md\");\n if (existsSync(path)) return `Skill \"${name}\" already exists. Use skill_update to modify it.`;\n const scan = abmind()?.scanForInjection(content);\n if (scan && !scan.safe) return `Content blocked by injection scanner: ${scan.flags[0]?.category ?? \"unknown\"} (score=${scan.score}). Rephrase the content.`;\n return null;\n}\n\n/** Parse YAML-like frontmatter from SKILL.md content. */\nfunction parseFrontmatter(raw: string): { meta: Record<string, unknown>; body: string } {\n const match = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n\\n?([\\s\\S]*)$/);\n if (!match) return { meta: {}, body: raw };\n const meta: Record<string, unknown> = {};\n for (const line of match[1]!.split(\"\\n\")) {\n const idx = line.indexOf(\":\");\n if (idx < 0) continue;\n const key = line.slice(0, idx).trim();\n let val: unknown = line.slice(idx + 1).trim();\n // Parse array: [a, b, c]\n if (typeof val === \"string\" && val.startsWith(\"[\") && val.endsWith(\"]\")) {\n val = val.slice(1, -1).split(\",\").map(s => s.trim()).filter(Boolean);\n }\n meta[key] = val;\n }\n return { meta, body: match[2]! };\n}\n\n/** Serialize frontmatter fields back to YAML-like string. */\nfunction serializeFrontmatter(meta: Record<string, unknown>): string {\n const lines: string[] = [\"---\"];\n for (const [k, v] of Object.entries(meta)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v) && v.length > 0) {\n lines.push(`${k}: [${v.join(\", \")}]`);\n } else if (!Array.isArray(v)) {\n lines.push(`${k}: ${v}`);\n }\n }\n lines.push(\"---\\n\\n\");\n return lines.join(\"\\n\");\n}\n\n/** Guard: skill must exist in self/ dir. Returns error string or null. */\nfunction guardSelfSkill(name: string): string | null {\n if (!NAME_RE.test(name)) return `Invalid name \"${name}\".`;\n const path = join(selfDir(), name, \"SKILL.md\");\n if (!existsSync(path)) return `Skill \"${name}\" not found in self/.`;\n return null;\n}\n\nexport const skillCreateTool: ToolDefinition = {\n name: \"skill_create\",\n description: \"Persist a new procedural skill to disk. Use when you've solved a novel task, discovered a workflow, or received a correction worth remembering as a repeatable recipe. Skills become available in future sessions via the skills_catalog.\",\n parameters: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Skill identifier, kebab-case, e.g. 'fix-pnpm-workspace-drift'. 3-64 chars, [a-z0-9-]+.\" },\n description: { type: \"string\", description: \"One-line description, max 120 chars. Shown in skills_catalog.\" },\n content: { type: \"string\", description: \"Skill body in Markdown. Starts with # <Title>. No frontmatter \u2014 the tool writes it.\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"Optional tags for categorization (max 5). E.g. ['tools', 'browser', 'debugging'].\" },\n related: { type: \"array\", items: { type: \"string\" }, description: \"Optional related skill names.\" },\n },\n required: [\"name\", \"description\", \"content\"],\n },\n async execute(args) {\n const { name, description, content, tags, related } = args as unknown as { name: string; description: string; content: string; tags?: string[]; related?: string[] };\n const error = validate(name, description, content);\n if (error) {\n audit(`skill_create name=${name} bytes=${content.length} ok=false error=\"${error}\"`);\n return JSON.stringify({ error });\n }\n\n const tagList = (tags ?? []).slice(0, MAX_TAGS).map(t => t.toLowerCase().trim()).filter(Boolean);\n const relList = (related ?? []).filter(Boolean);\n const tagsLine = tagList.length > 0 ? `tags: [${tagList.join(\", \")}]\\n` : \"\";\n const relatedLine = relList.length > 0 ? `related: [${relList.join(\", \")}]\\n` : \"\";\n const frontmatter = `---\\nname: ${name}\\ndescription: ${description.trim()}\\n${tagsLine}${relatedLine}---\\n\\n`;\n const fullContent = frontmatter + content;\n const dir = join(selfDir(), name);\n const filePath = join(dir, \"SKILL.md\");\n const tmpPath = filePath + \".tmp\";\n\n try {\n mkdirSync(dir, { recursive: true });\n writeFileSync(tmpPath, fullContent, \"utf-8\");\n renameSync(tmpPath, filePath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n audit(`skill_create name=${name} bytes=${content.length} ok=false error=\"write failed: ${msg}\"`);\n return JSON.stringify({ error: `Write failed: ${msg}` });\n }\n\n setProvenance(name, \"agent\");\n audit(`skill_create name=${name} tags=[${tagList.join(\",\")}] bytes=${content.length} ok=true`);\n logInfo(TAG, `Created skill: self/${name} (${content.length} bytes)`);\n return JSON.stringify({ ok: true, path: filePath, message: `Skill \"${name}\" created in self/. Available in skills_catalog after /skill reload.` });\n },\n};\n\nexport const skillUpdateTool: ToolDefinition = {\n name: \"skill_update\",\n description: \"Full rewrite of an existing skill's SKILL.md in self/. Preserves frontmatter fields (tags, related, description) when omitted by caller.\",\n parameters: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Skill name (must exist in self/).\" },\n description: { type: \"string\", description: \"New description (optional \u2014 keeps existing if omitted).\" },\n content: { type: \"string\", description: \"New skill body in Markdown (no frontmatter).\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"New tags (optional \u2014 keeps existing if omitted).\" },\n related: { type: \"array\", items: { type: \"string\" }, description: \"New related skills (optional \u2014 keeps existing if omitted).\" },\n },\n required: [\"name\", \"content\"],\n },\n async execute(args) {\n const { name, content, description, tags, related } = args as unknown as { name: string; content: string; description?: string; tags?: string[]; related?: string[] };\n const guard = guardSelfSkill(name);\n if (guard) { audit(`skill_update name=${name} ok=false error=\"${guard}\"`); return JSON.stringify({ error: guard }); }\n\n const bytes = Buffer.byteLength(content, \"utf-8\");\n if (bytes < MIN_BYTES) return JSON.stringify({ error: `Content too short (${bytes} bytes, minimum ${MIN_BYTES}).` });\n if (bytes > MAX_BYTES) return JSON.stringify({ error: `Content too large (${bytes} bytes, maximum ${MAX_BYTES}).` });\n\n const scan = abmind()?.scanForInjection(content);\n if (scan && !scan.safe) return JSON.stringify({ error: `Content blocked by injection scanner: ${scan.flags[0]?.category ?? \"unknown\"}.` });\n\n const filePath = join(selfDir(), name, \"SKILL.md\");\n const existing = readFileSync(filePath, \"utf-8\");\n const { meta } = parseFrontmatter(existing);\n\n // Merge: caller fields override, omitted fields preserved\n const merged: Record<string, unknown> = { ...meta, name };\n if (description !== undefined) merged[\"description\"] = description.trim();\n if (tags !== undefined) merged[\"tags\"] = tags.slice(0, MAX_TAGS).map(t => t.toLowerCase().trim()).filter(Boolean);\n if (related !== undefined) merged[\"related\"] = related.filter(Boolean);\n\n const fullContent = serializeFrontmatter(merged) + content;\n const tmpPath = filePath + \".tmp\";\n try {\n writeFileSync(tmpPath, fullContent, \"utf-8\");\n renameSync(tmpPath, filePath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n audit(`skill_update name=${name} ok=false error=\"write failed: ${msg}\"`);\n return JSON.stringify({ error: `Write failed: ${msg}` });\n }\n\n audit(`skill_update name=${name} bytes=${bytes} ok=true`);\n logInfo(TAG, `Updated skill: self/${name} (${bytes} bytes)`);\n return JSON.stringify({ ok: true, path: filePath, message: `Skill \"${name}\" updated.` });\n },\n};\n\nexport const skillPatchTool: ToolDefinition = {\n name: \"skill_patch\",\n description: \"Targeted find-and-replace within a skill's SKILL.md in self/. old_string must match exactly once.\",\n parameters: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Skill name (must exist in self/).\" },\n old_string: { type: \"string\", description: \"Exact string to find (must match once).\" },\n new_string: { type: \"string\", description: \"Replacement string.\" },\n },\n required: [\"name\", \"old_string\", \"new_string\"],\n },\n async execute(args) {\n const { name, old_string, new_string } = args as unknown as { name: string; old_string: string; new_string: string };\n const guard = guardSelfSkill(name);\n if (guard) { audit(`skill_patch name=${name} ok=false error=\"${guard}\"`); return JSON.stringify({ error: guard }); }\n\n const filePath = join(selfDir(), name, \"SKILL.md\");\n const existing = readFileSync(filePath, \"utf-8\");\n\n const count = existing.split(old_string).length - 1;\n if (count === 0) return JSON.stringify({ error: `old_string not found in skill \"${name}\".` });\n if (count > 1) return JSON.stringify({ error: `old_string matches ${count} times \u2014 must match exactly once.` });\n\n const patched = existing.replace(old_string, new_string);\n const scan = abmind()?.scanForInjection(patched);\n if (scan && !scan.safe) return JSON.stringify({ error: `Patched content blocked by injection scanner: ${scan.flags[0]?.category ?? \"unknown\"}.` });\n\n const tmpPath = filePath + \".tmp\";\n try {\n writeFileSync(tmpPath, patched, \"utf-8\");\n renameSync(tmpPath, filePath);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n audit(`skill_patch name=${name} ok=false error=\"write failed: ${msg}\"`);\n return JSON.stringify({ error: `Write failed: ${msg}` });\n }\n\n audit(`skill_patch name=${name} ok=true`);\n logInfo(TAG, `Patched skill: self/${name}`);\n return JSON.stringify({ ok: true, path: filePath, message: `Skill \"${name}\" patched.` });\n },\n};\n\nexport const skillRemoveTool: ToolDefinition = {\n name: \"skill_remove\",\n description: \"Soft-delete a skill from self/ by moving it to .trash/ (recoverable for 7 days).\",\n parameters: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Skill name (must exist in self/).\" },\n },\n required: [\"name\"],\n },\n async execute(args) {\n const { name } = args as unknown as { name: string };\n const guard = guardSelfSkill(name);\n if (guard) { audit(`skill_remove name=${name} ok=false error=\"${guard}\"`); return JSON.stringify({ error: guard }); }\n\n const srcDir = join(selfDir(), name);\n const ts = Date.now();\n const destDir = join(trashDir(), `${name}-${ts}`);\n try {\n mkdirSync(trashDir(), { recursive: true });\n renameSync(srcDir, destDir);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n audit(`skill_remove name=${name} ok=false error=\"move failed: ${msg}\"`);\n return JSON.stringify({ error: `Move failed: ${msg}` });\n }\n\n audit(`skill_remove name=${name} dest=${destDir} ok=true`);\n logInfo(TAG, `Removed skill: self/${name} \u2192 .trash/`);\n return JSON.stringify({ ok: true, message: `Skill \"${name}\" moved to .trash/. Will be pruned after 7 days.` });\n },\n};\n", "/**\n * mcp-tool.ts \u2014 Generic MCP tool (#471 v2).\n * Single tool that routes to any mcporter server/tool. Daemon starts on-demand.\n */\n\nimport { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { logInfo, logWarn } from \"../logger.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\nimport type { ToolDefinition } from \"./tool-registry.js\";\n\nconst execFileAsync = promisify(execFile);\nconst TAG = \"mcp\";\nlet daemonStarted = false;\n\nasync function ensureDaemon(): Promise<void> {\n if (daemonStarted) return;\n try {\n await execFileAsync(\"mcporter\", [\"daemon\", \"start\"], { timeout: 10_000 });\n daemonStarted = true;\n logInfo(TAG, \"mcporter daemon started (on-demand)\");\n } catch {\n logWarn(TAG, \"mcporter daemon start failed \u2014 calls may still work if already running\");\n daemonStarted = true; // don't retry every call \u2014 assume already running\n }\n}\n\nexport const mcpTool: ToolDefinition = {\n name: \"mcp\",\n description: \"Call an MCP server tool via mcporter. Available servers shown by /mcp command. Use when you need JIRA, presentations, or other MCP-connected services.\",\n parameters: {\n type: \"object\",\n properties: {\n server: { type: \"string\", description: \"Server name (e.g. 'pptx', 'atlassian')\" },\n tool: { type: \"string\", description: \"Tool name (e.g. 'jira_search', 'create_presentation')\" },\n args: { type: \"string\", description: \"Tool arguments as JSON string (e.g. '{\\\"query\\\": \\\"assignee = me\\\"}')\" },\n },\n required: [\"server\", \"tool\"],\n },\n async execute(params) {\n await ensureDaemon();\n const { server, tool, args } = params as { server: string; tool: string; args?: string };\n const cliArgs = [\"call\", `${server}.${tool}`];\n if (args) {\n try {\n const parsed = JSON.parse(args) as Record<string, string>;\n for (const [k, v] of Object.entries(parsed)) cliArgs.push(`${k}=${v}`);\n } catch (err) {\n logAndSwallow(TAG, \"JSON.parse mcp args\", err);\n cliArgs.push(args);\n }\n }\n try {\n const { stdout } = await execFileAsync(\"mcporter\", cliArgs, { timeout: 30_000, encoding: \"utf-8\" });\n return stdout;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return JSON.stringify({ error: `mcp call failed: ${msg}` });\n }\n },\n};\n", "/**\n * kanban-tool.ts \u2014 Agent-facing tool for managing the kanban board.\n */\n\nimport type { ToolDefinition } from \"./tool-registry.js\";\nimport { kanbanEnqueue, kanbanUpdate, kanbanList, type KanbanCard } from \"../tasks/kanban-board.js\";\n\nfunction formatCard(c: KanbanCard): string {\n const icon = c.status === \"delivered\" ? \"\u2705\" : c.status === \"done\" ? \"\uD83D\uDCEC\" : c.status === \"running\" ? \"\u23F3\" : c.status === \"failed\" ? \"\u274C\" : \"\uD83D\uDCE5\";\n const due = c.due_at ? ` due:${c.due_at}` : \"\";\n const lbl = c.labels ? ` [${c.labels}]` : \"\";\n return `${icon} #${c.id} ${c.title} (${c.priority}/${c.status})${due}${lbl}`;\n}\n\nasync function execute(args: Record<string, string>): Promise<string> {\n const action = args.action;\n\n if (action === \"create\") {\n if (!args.title) return \"\u274C title required\";\n const id = kanbanEnqueue(args.title, args.source || \"agent\", undefined, {\n priority: args.priority,\n type: args.type,\n labels: args.labels,\n due_at: args.due_at,\n parent_id: args.parent_id ? parseInt(args.parent_id, 10) : undefined,\n notes: args.notes,\n });\n return `\u2705 Card #${id} created: \"${args.title}\"`;\n }\n\n if (action === \"update\") {\n if (!args.id) return \"\u274C id required\";\n const fields: Record<string, unknown> = {};\n for (const k of [\"title\", \"status\", \"priority\", \"type\", \"labels\", \"due_at\", \"notes\", \"approval\"] as const) {\n if (args[k]) fields[k] = args[k];\n }\n if (args.parent_id) fields.parent_id = parseInt(args.parent_id, 10);\n kanbanUpdate(parseInt(args.id, 10), fields as any);\n return `\u2705 Card #${args.id} updated`;\n }\n\n if (action === \"list\") {\n const cards = kanbanList(args.status || undefined);\n if (cards.length === 0) return \"\uD83D\uDCCB Board is empty\";\n return `\uD83D\uDCCB Kanban Board (${cards.length}):\\n` + cards.map(formatCard).join(\"\\n\");\n }\n\n return `\u274C Unknown action: ${action}. Use create | update | list`;\n}\n\nexport const kanbanTool: ToolDefinition = {\n name: \"kanban_manage\",\n description: \"Create, update, or list cards on the kanban board. Use for tracking work items, user requests, and task decomposition.\",\n parameters: {\n type: \"object\",\n properties: {\n action: { type: \"string\", description: \"create | update | list\", enum: [\"create\", \"update\", \"list\"] },\n title: { type: \"string\", description: \"Card title (required for create)\" },\n id: { type: \"string\", description: \"Card ID (required for update)\" },\n source: { type: \"string\", description: \"Who created: user | agent | cron | peer\" },\n status: { type: \"string\", description: \"New status (for update): queued | running | done | failed\" },\n priority: { type: \"string\", description: \"CRITICAL | HIGH | MEDIUM | LOW\" },\n type: { type: \"string\", description: \"Card type (task, bug, feature, research, report, etc.)\" },\n labels: { type: \"string\", description: \"Comma-separated tags\" },\n due_at: { type: \"string\", description: \"ISO deadline (e.g. 2026-06-08T12:00:00)\" },\n parent_id: { type: \"string\", description: \"Parent card ID for subtasks\" },\n notes: { type: \"string\", description: \"Additional context\" },\n approval: { type: \"string\", description: \"pending | approved | rejected\" },\n },\n required: [\"action\"],\n },\n execute,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,mBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAKA,SAAS,SAAS,WAAW;AAC7B,SAAS,eAAe;AAyCjB,SAAS,gBAAgB,KAA0B;AACxD,QAAM,UAAU,IAAI,KAAK;AACzB,aAAW,UAAU,0BAA0B;AAC7C,QAAI,QAAQ,YAAY,EAAE,WAAW,OAAO,YAAY,CAAC,EAAG,QAAO;AAAA,EACrE;AACA,aAAW,MAAM,wBAAwB;AACvC,QAAI,GAAG,KAAK,OAAO,EAAG,QAAO;AAAA,EAC/B;AACA,SAAO;AACT;AAIO,SAAS,kBAAgC;AAC9C,QAAM,OAAO,OAAO,EAAE;AACtB,SAAO,QAAQ;AACjB;AAEO,SAAS,qBAA8B;AAC5C,SAAO,gBAAgB,MAAM;AAC/B;AAGO,SAASA,WAAU,MAAc,MAAuC;AAC7E,MAAI,CAAC,mBAAmB,EAAG,QAAO;AAElC,QAAM,WAAW,QAAQ,IAAI,KAAK,KAAK,SAAS,GAAG,IAAI,MAAM;AAE7D,aAAW,WAAW,eAAe;AACnC,QAAI,SAAS,WAAW,OAAO,KAAK,aAAa,QAAQ,MAAM,GAAG,EAAE,GAAG;AACrE,aAAO,+BAA+B,IAAI;AAAA,IAC5C;AAAA,EACF;AAEA,MAAI,SAAS,SAAS;AACpB,e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,QAAQ,eAAe,CAAC;AAAA,MAC3E;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,UAAU,KAAK,OAAK,EAAE,SAAS,IAAI;AAChD,MAAI,CAAC,KAAM,QAAO,KAAK,UAAU,EAAE,OAAO,iBAAiB,IAAI,GAAG,CAAC;AACnE,QAAM,KAAK,KAAK,IAAI;AAGpB,QAAM,aAAc,SAAS,kBAAkB,SAAS,iBAAkB,SAAS,KAAK,kBAAkB,KAAK,SAAS,KAAK,EAAE,IAAI;AACnI,QAAM,YAAY,cAAc,IAC5B,YAAY,UAAU,wBACtB,cAAc,KAAK,UAAU,IAAI,CAAC;AACtC,EAAAN,OAAM,EAAE,IAAI,MAAM,MAAM,MAAM,WAAW,QAAQ,SAAS,OAAO,CAAC;AAElE,MAAI;AACF,UAAM,SAAS,MAAM,KAAK,QAAQ,MAAM,OAAO;AAC/C,IAAAA,OAAM,EAAE,IAAI,MAAM,MAAM,QAAQ,MAAM,OAAO,OAAO,OAAO,CAAC;AAC5D,mBAAe,MAAM,IAAI;AACzB,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,IAAAA,OAAM,EAAE,IAAI,MAAM,MAAM,QAAQ,SAAS,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAAE,CAAC;AAClG,UAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": ["checkPath", "TAG", "execFile", "appendFileSync", "mkdirSync", "join", "homedir", "TAG", "TAG", "join", "homedir", "mkdirSync", "audit", "appendFileSync", "checkCommand", "classifyCommand", "resolve", "execFile", "readFileSync", "existsSync"]
|
|
7
|
+
}
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
init_logger,
|
|
5
5
|
logInfo,
|
|
6
6
|
logWarn
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GUTRAMK3.js";
|
|
8
8
|
import {
|
|
9
9
|
abtarsHome,
|
|
10
10
|
init_paths
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WW5F2DCO.js";
|
|
12
12
|
import {
|
|
13
13
|
__require
|
|
14
14
|
} from "./chunk-7K2YZTLD.js";
|
|
@@ -70,4 +70,4 @@ export {
|
|
|
70
70
|
installPackages,
|
|
71
71
|
lazyRequire
|
|
72
72
|
};
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
73
|
+
//# sourceMappingURL=chunk-4XW7YA3K.js.map
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { createRequire as __bundleCreateRequire } from 'node:module'; import { fileURLToPath as __bundleFileURLToPath } from 'node:url'; import { dirname as __bundleDirname } from 'node:path'; const require = __bundleCreateRequire(import.meta.url); const __chunk_filename = __bundleFileURLToPath(import.meta.url); const __chunk_dirname = __bundleDirname(__chunk_filename);
|
|
3
3
|
import {
|
|
4
4
|
createAgentTransport
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HAS5NEK7.js";
|
|
6
6
|
import {
|
|
7
7
|
loadUsers
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
init_log_and_swallow,
|
|
11
|
-
logAndSwallow
|
|
12
|
-
} from "./chunk-EX2SRTUE.js";
|
|
8
|
+
} from "./chunk-SRFEIZQT.js";
|
|
13
9
|
import {
|
|
14
10
|
getEnv,
|
|
15
11
|
init_env_schema
|
|
16
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3OXQWII3.js";
|
|
13
|
+
import {
|
|
14
|
+
init_log_and_swallow,
|
|
15
|
+
logAndSwallow
|
|
16
|
+
} from "./chunk-CYSGXNBY.js";
|
|
17
17
|
import {
|
|
18
18
|
init_logger,
|
|
19
19
|
isLogLevel,
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
logError,
|
|
22
22
|
logInfo,
|
|
23
23
|
logWarn
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-GUTRAMK3.js";
|
|
25
25
|
import {
|
|
26
26
|
abtarsHome,
|
|
27
27
|
init_paths
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-WW5F2DCO.js";
|
|
29
29
|
|
|
30
30
|
// src/boot/phase-transport.ts
|
|
31
31
|
init_log_and_swallow();
|
|
@@ -439,7 +439,7 @@ async function phaseTransport(ctx) {
|
|
|
439
439
|
async function buildTransport(ctx) {
|
|
440
440
|
const { config, memoryConfig } = ctx;
|
|
441
441
|
let transport;
|
|
442
|
-
const { resolveAgent, getEnvFallback, loadTransport, resolveHailMary, clearTransportCache, validateProviderReady } = await import("./transport-config-
|
|
442
|
+
const { resolveAgent, getEnvFallback, loadTransport, resolveHailMary, clearTransportCache, validateProviderReady } = await import("./transport-config-JIKHB7GT.js");
|
|
443
443
|
clearTransportCache();
|
|
444
444
|
const tc = loadTransport();
|
|
445
445
|
const prof = tc ? resolveAgent("professor", tc) : null;
|
|
@@ -496,7 +496,7 @@ async function buildTransport(ctx) {
|
|
|
496
496
|
defaults?.maxWaitSec ?? config.transport.tmuxMaxWaitSec
|
|
497
497
|
);
|
|
498
498
|
} else if (resolved.provider.transport === "api") {
|
|
499
|
-
const { DirectApiTransport } = await import("./direct-api-transport-
|
|
499
|
+
const { DirectApiTransport } = await import("./direct-api-transport-OZICXTWQ.js");
|
|
500
500
|
const { ModelHealthRegistry } = await import("./model-health-registry-7ECZFCW4.js");
|
|
501
501
|
const { FallbackPolicy } = await import("./fallback-policy-SR6ED5I3.js");
|
|
502
502
|
const apiKey = getEnv().getApiKey(resolved.provider.apiKeyEnv ?? "API_KEY");
|
|
@@ -517,8 +517,8 @@ async function buildTransport(ctx) {
|
|
|
517
517
|
}
|
|
518
518
|
if (!ctx.modelHealthRegistry.onDemote) {
|
|
519
519
|
ctx.modelHealthRegistry.onDemote = (model, _endpoint, reason) => {
|
|
520
|
-
import("./transport-config-
|
|
521
|
-
import("./notification-
|
|
520
|
+
import("./transport-config-JIKHB7GT.js").then(({ demoteModel }) => demoteModel(model, reason));
|
|
521
|
+
import("./notification-ULESRDHB.js").then(({ sendNotification }) => sendNotification(ctx, `\u26A0\uFE0F ${model} demoted (${reason}). Next healthy model promoted.`)).catch((err) => logAndSwallow(TAG2, "sendNotification model-demote", err));
|
|
522
522
|
};
|
|
523
523
|
}
|
|
524
524
|
const policy = new FallbackPolicy(candidates, ctx.modelHealthRegistry);
|
|
@@ -549,7 +549,7 @@ async function buildTransport(ctx) {
|
|
|
549
549
|
}
|
|
550
550
|
await transport.initialize();
|
|
551
551
|
if ("setSystemPrompt" in transport && typeof transport.setSystemPrompt === "function") {
|
|
552
|
-
const { loadSoulBundle } = await import("./soul-loader-
|
|
552
|
+
const { loadSoulBundle } = await import("./soul-loader-LCPTN4PK.js");
|
|
553
553
|
const soul = loadSoulBundle();
|
|
554
554
|
if (soul) transport.setSystemPrompt(soul);
|
|
555
555
|
}
|
|
@@ -566,17 +566,44 @@ async function buildTransport(ctx) {
|
|
|
566
566
|
ctx.runtime.setMainTransport(transport);
|
|
567
567
|
ctx.runtime.setSessionManager(ctx.sessionManager);
|
|
568
568
|
if (getEnv().enableAsyncDelegation) {
|
|
569
|
-
const { setDelegationDeps } = await import("./delegation-tools-
|
|
569
|
+
const { setDelegationDeps } = await import("./delegation-tools-Z5OM3TXS.js");
|
|
570
570
|
setDelegationDeps(ctx.runtime, ctx.sessionManager);
|
|
571
571
|
}
|
|
572
572
|
logInfo("main", "\u2705 Transport ready");
|
|
573
|
+
const { join: join3 } = await import("node:path");
|
|
574
|
+
const { abtarsHome: abtarsHome2 } = await import("./paths-QQM74XYT.js");
|
|
575
|
+
const { ActionGate } = await import("./action-gate-DYV2XQBP.js");
|
|
576
|
+
const { setActionGate } = await import("./tool-registry-TGNU5AMG.js");
|
|
577
|
+
const authDir = join3(abtarsHome2(), "auth");
|
|
578
|
+
ctx.actionGate = new ActionGate(authDir);
|
|
579
|
+
setActionGate(ctx.actionGate);
|
|
580
|
+
logDebug("main", "\u{1F512} ActionGate wired");
|
|
573
581
|
if (resolved.provider.transport === "api" && ctx.memory?.available) {
|
|
574
|
-
const { setMemoryBackend } = await import("./tool-registry-
|
|
575
|
-
const
|
|
576
|
-
const backend =
|
|
577
|
-
|
|
582
|
+
const { setMemoryBackend } = await import("./tool-registry-TGNU5AMG.js");
|
|
583
|
+
const mm = ctx.memory;
|
|
584
|
+
const backend = {
|
|
585
|
+
initialize: async () => {
|
|
586
|
+
},
|
|
587
|
+
close: () => {
|
|
588
|
+
},
|
|
589
|
+
instantStore: (p) => mm.editor.instantStore(p),
|
|
590
|
+
editMemory: (p) => mm.editor.editMemory(p),
|
|
591
|
+
reclassifyMemory: (id, level, uo) => {
|
|
592
|
+
mm.editor.reclassifyMemory(id, level, uo);
|
|
593
|
+
return Promise.resolve();
|
|
594
|
+
},
|
|
595
|
+
adjustRelevance: (id, delta) => {
|
|
596
|
+
mm.editor.adjustRelevance(id, delta);
|
|
597
|
+
return Promise.resolve();
|
|
598
|
+
},
|
|
599
|
+
mergeMemories: (a, b) => mm.editor.mergeMemories(a, b),
|
|
600
|
+
cascadeDelete: (ids, uid) => mm.editor.cascadeDelete(ids, uid),
|
|
601
|
+
recall: (p) => mm.recallSearch(p),
|
|
602
|
+
rebuildFtsIndexes: () => mm.rebuildFtsIndexes()
|
|
603
|
+
};
|
|
578
604
|
setMemoryBackend(backend);
|
|
579
|
-
logInfo("main", "\u{1F9E0} In-process memory wired to tool registry");
|
|
605
|
+
logInfo("main", "\u{1F9E0} In-process memory wired to tool registry (shared handle)");
|
|
606
|
+
transport.memoryBackend = ctx.memory;
|
|
580
607
|
const db = ctx.memory.getDb?.() ?? ctx.memory.getDatabase?.();
|
|
581
608
|
if (db && resolved.contextWindow >= 128e3) {
|
|
582
609
|
const { ContextEngine } = await import("abmind");
|
|
@@ -616,7 +643,7 @@ async function buildTransport(ctx) {
|
|
|
616
643
|
logInfo("main", msg);
|
|
617
644
|
if (model !== lastNotifiedModel || isLogLevel("debug")) {
|
|
618
645
|
lastNotifiedModel = model;
|
|
619
|
-
import("./notification-
|
|
646
|
+
import("./notification-ULESRDHB.js").then(({ sendNotification }) => sendNotification(ctx, msg)).catch((err) => logAndSwallow(TAG2, "sendNotification fallback", err));
|
|
620
647
|
}
|
|
621
648
|
};
|
|
622
649
|
}
|
|
@@ -642,4 +669,4 @@ export {
|
|
|
642
669
|
buildTransport,
|
|
643
670
|
rebuildTransport
|
|
644
671
|
};
|
|
645
|
-
//# sourceMappingURL=chunk-
|
|
672
|
+
//# sourceMappingURL=chunk-5WFIAUQC.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/boot/phase-transport.ts", "../src/components/transport/tmux-client.ts", "../src/boot/ctx-start.ts"],
|
|
4
|
+
"sourcesContent": ["import { logAndSwallow } from \"../components/log-and-swallow.js\";\nimport { getEnv } from \"../components/env-schema.js\";\n/**\n * phase-transport \u2014 boot phase 3: select, initialize, and wrap the agent transport.\n *\n * Also exports buildTransport/rebuildTransport for /reset to pick up transport.json changes\n * (including provider switches that can't be live-patched).\n */\n\nimport { execSync } from \"node:child_process\";\nimport { TmuxClient } from \"../components/transport/tmux-client.js\";\nimport { createAgentTransport } from \"../components/agent-registry.js\";\nimport { logDebug, logInfo, logWarn, logError, isLogLevel } from \"../components/logger.js\";\nimport { loadUsers } from \"../components/user-registry.js\";\nimport { updateCtxStart } from \"./ctx-start.js\";\nimport type { BootCtx, PhaseResult } from \"./context.js\";\nimport type { IKiroTransport } from \"../components/transport/kiro-transport.js\";\n\nconst TAG = \"transport\";\n\nexport async function phaseTransport(ctx: BootCtx): Promise<PhaseResult> {\n const { memoryConfig } = ctx;\n\n await buildTransport(ctx);\n\n // Initialize context-window-start for all known users\n if (memoryConfig.memoryEnabled) {\n const reg = loadUsers();\n for (const user of reg.users) updateCtxStart(memoryConfig.memoryDir, user.userId, ctx.startedAt);\n }\n return \"ran\";\n}\n\n/**\n * Construct professor transport from current transport.json + env and attach to ctx.transport.\n * Idempotent: destroys any existing ctx.transport first.\n *\n * #367 \u2014 Validates the resolved provider BEFORE destroying the old transport.\n * If validation fails:\n * - During `/reset` (old transport exists): logs ERROR, keeps the old transport up\n * - At boot (no old transport): falls back to .env config if possible, or throws\n * - In either case: bridge stays alive in degraded mode rather than crash-looping\n */\nexport async function buildTransport(ctx: BootCtx): Promise<PhaseResult> {\n const { config, memoryConfig } = ctx;\n\n let transport: IKiroTransport;\n\n const { resolveAgent, getEnvFallback, loadTransport, resolveHailMary, clearTransportCache, validateProviderReady } = await import(\"../components/transport-config.js\");\n clearTransportCache(); // always re-read (picks up /models change writes)\n const tc = loadTransport();\n const prof = tc ? resolveAgent(\"professor\", tc) : null;\n\n const hm = resolveHailMary(tc);\n if (hm) {\n ctx.hailMary = {\n model: hm.model,\n endpoint: hm.endpoint,\n apiKey: hm.apiKeyEnv ? getEnv().getApiKey(hm.apiKeyEnv) : undefined,\n };\n logInfo(\"main\", `\uD83D\uDEA8 hailMary configured: ${hm.model} (manual /model emergency only)`);\n } else {\n ctx.hailMary = null;\n }\n\n let resolved = prof ?? (() => {\n const fb = getEnvFallback();\n logWarn(\"main\", `\u26A0\uFE0F Using .env fallback: ${fb.model} via ${fb.providerName}`);\n return { model: fb.model, provider: fb.provider, providerName: fb.providerName, contextWindow: fb.contextWindow, maxOutput: fb.maxOutput, fallbacks: [] };\n })();\n\n // #367 \u2014 validate the resolved provider BEFORE destroying the existing transport.\n // If validation fails and an old transport is up, keep it; surface the error.\n // If no old transport (boot time), try .env fallback.\n const validation = validateProviderReady(resolved.providerName, resolved.provider, getEnv());\n if (!validation.ok) {\n const errMsg = `transport.json configures '${resolved.providerName}' but ${validation.reason}. Fix: ${validation.fix}`;\n if (ctx.transport) {\n // Existing transport still good \u2014 keep it. Don't destroy.\n logError(\"main\", `${errMsg} \u2014 keeping existing transport up (skipping rebuild)`);\n return \"ran\";\n }\n // Boot-time: try falling back to .env if we weren't already using it\n if (prof) {\n const fb = getEnvFallback();\n logError(\"main\", `${errMsg} \u2014 falling back to .env config (${fb.model} via ${fb.providerName})`);\n resolved = { model: fb.model, provider: fb.provider, providerName: fb.providerName, contextWindow: fb.contextWindow, maxOutput: fb.maxOutput, fallbacks: [] };\n // Validate fallback too \u2014 if even .env is broken, let the original error bubble\n const fbValidation = validateProviderReady(resolved.providerName, resolved.provider, getEnv());\n if (!fbValidation.ok) {\n logError(\"main\", `.env fallback '${resolved.providerName}' also invalid: ${fbValidation.reason}`);\n throw new Error(`${errMsg} (and .env fallback is also invalid: ${fbValidation.reason})`);\n }\n } else {\n // Already on .env fallback path and it's invalid \u2014 hard error\n throw new Error(errMsg);\n }\n }\n\n // Destroy old (if any) \u2014 now that we know the new config is valid\n if (ctx.transport) {\n try { await ctx.transport.destroy(); } catch (err) {\n logWarn(\"main\", `Old transport destroy failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n ctx.transport = null;\n }\n\n if (resolved.provider.transport === \"tmux\") {\n const defaults = tc?.transportDefaults?.tmux;\n logInfo(\"main\", `\uD83D\uDDA5\uFE0F tmux transport (${resolved.providerName})`);\n transport = new TmuxClient(\n defaults?.session ?? config.transport.tmuxSession,\n defaults?.captureDelaySec ?? config.transport.tmuxCaptureDelaySec,\n defaults?.maxWaitSec ?? config.transport.tmuxMaxWaitSec,\n );\n } else if (resolved.provider.transport === \"api\") {\n const { DirectApiTransport } = await import(\"../components/transport/direct-api-transport.js\");\n const { ModelHealthRegistry } = await import(\"../components/transport/model-health-registry.js\");\n const { FallbackPolicy } = await import(\"../components/transport/fallback-policy.js\");\n const apiKey = getEnv().getApiKey(resolved.provider.apiKeyEnv ?? \"API_KEY\");\n\n const candidates: Array<{ model: string; endpoint: string; apiKey?: string; maxContext: number }> = [\n { endpoint: resolved.provider.endpoint ?? \"http://localhost:11434/v1\", apiKey, model: resolved.model, maxContext: resolved.contextWindow },\n ];\n for (const fb of resolved.fallbacks) {\n const fbResolved = tc ? resolveAgent(\"_fallback\", { ...tc, agents: { ...tc.agents, _fallback: { model: fb.model, provider: fb.provider } } }) : null;\n candidates.push({\n endpoint: fbResolved?.provider.endpoint ?? resolved.provider.endpoint!,\n apiKey: fbResolved?.provider.apiKeyEnv ? getEnv().getApiKey(fbResolved.provider.apiKeyEnv) : apiKey,\n model: fb.model,\n maxContext: fbResolved?.contextWindow ?? resolved.contextWindow,\n });\n }\n\n if (!ctx.modelHealthRegistry) {\n ctx.modelHealthRegistry = new ModelHealthRegistry(tc?.healthPolicy);\n }\n // Wire auto-demotion\n if (!ctx.modelHealthRegistry.onDemote) {\n ctx.modelHealthRegistry.onDemote = (model, _endpoint, reason) => {\n import(\"../components/transport-config.js\").then(({ demoteModel }) => demoteModel(model, reason));\n import(\"../components/notification.js\").then(({ sendNotification }) =>\n sendNotification(ctx, `\u26A0\uFE0F ${model} demoted (${reason}). Next healthy model promoted.`)).catch(err => logAndSwallow(TAG, \"sendNotification model-demote\", err));\n };\n }\n const policy = new FallbackPolicy(candidates, ctx.modelHealthRegistry);\n\n transport = new DirectApiTransport({\n endpoint: resolved.provider.endpoint ?? \"http://localhost:11434/v1\",\n apiKey,\n model: resolved.model,\n maxContext: resolved.contextWindow,\n maxOutput: resolved.maxOutput,\n maxTurns: tc?.maxTurns ?? 50,\n apiFormat: resolved.provider.apiFormat,\n thinking: resolved.provider.thinking,\n }, policy);\n logInfo(\"main\", `\uD83D\uDD0C Direct API transport (${resolved.providerName}, model=${resolved.model}, ${candidates.length} candidates)`);\n } else {\n try { execSync(\"pkill -f 'kiro-cli.*acp.*professor' 2>/dev/null || true\", { timeout: 3000 }); } catch (err) { logAndSwallow(\"phase_transport\", \"op\", err); }\n logInfo(\"main\", `\uD83D\uDD0C ACP transport (${resolved.provider.cli ?? \"kiro-cli\"}, model=${resolved.model})`);\n transport = createAgentTransport(\"professor\", {\n cliPath: resolved.provider.cli ?? config.transport.agentCliPath,\n workingDir: config.transport.workingDir,\n agentCli: resolved.provider.cli ?? \"kiro-cli\",\n model: resolved.model,\n });\n }\n\n await transport.initialize();\n\n if (\"setSystemPrompt\" in transport && typeof (transport as { setSystemPrompt: unknown }).setSystemPrompt === \"function\") {\n const { loadSoulBundle } = await import(\"../components/soul-loader.js\");\n const soul = loadSoulBundle();\n if (soul) (transport as { setSystemPrompt: (p: string) => void }).setSystemPrompt(soul);\n }\n\n if (resolved.fallbacks.length > 0 && resolved.provider.transport !== \"api\") {\n logWarn(\"main\", `\u26A0\uFE0F Fallbacks configured for ${resolved.provider.transport} transport \u2014 only API transport supports model fallback`);\n }\n\n ctx.transport = transport;\n ctx.modelName = resolved.model;\n ctx.modelProvider = resolved.providerName;\n ctx.fallbackChain = resolved.fallbacks.map((f: { model: string }) => f.model);\n\n if (ctx.modelHealthRegistry) {\n ctx.runtime.setRegistry(ctx.modelHealthRegistry);\n }\n ctx.runtime.setMainTransport(transport);\n ctx.runtime.setSessionManager(ctx.sessionManager);\n\n // Wire async delegation tools (#570)\n if (getEnv().enableAsyncDelegation) {\n const { setDelegationDeps } = await import(\"../components/transport/delegation-tools.js\");\n setDelegationDeps(ctx.runtime, ctx.sessionManager);\n }\n\n logInfo(\"main\", \"\u2705 Transport ready\");\n\n // Wire ActionGate for auth-required commands\n const { join } = await import(\"node:path\");\n const { abtarsHome } = await import(\"../paths.js\");\n const { ActionGate } = await import(\"../components/action-gate.js\");\n const { setActionGate } = await import(\"../components/transport/tool-registry.js\");\n const authDir = join(abtarsHome(), \"auth\");\n ctx.actionGate = new ActionGate(authDir);\n setActionGate(ctx.actionGate);\n logDebug(\"main\", \"\uD83D\uDD12 ActionGate wired\");\n\n if (resolved.provider.transport === \"api\" && (ctx.memory as any)?.available) {\n const { setMemoryBackend } = await import(\"../components/transport/tool-registry.js\");\n // #860: Use the SAME MemoryManager instance \u2014 don't create a second SqliteBackend.\n // Two separate DB connections to the same WAL-mode file corrupt each other's handles.\n const mm = ctx.memory!;\n const backend = {\n initialize: async () => {},\n close: () => {},\n instantStore: (p: any) => mm.editor.instantStore(p),\n editMemory: (p: any) => mm.editor.editMemory(p),\n reclassifyMemory: (id: number, level: number, uo: boolean) => { mm.editor.reclassifyMemory(id, level, uo); return Promise.resolve(); },\n adjustRelevance: (id: number, delta: number) => { mm.editor.adjustRelevance(id, delta); return Promise.resolve(); },\n mergeMemories: (a: number, b: number) => mm.editor.mergeMemories(a, b),\n cascadeDelete: (ids: number[], uid: string) => mm.editor.cascadeDelete(ids, uid),\n recall: (p: any) => mm.recallSearch(p),\n rebuildFtsIndexes: () => mm.rebuildFtsIndexes(),\n };\n setMemoryBackend(backend as any);\n logInfo(\"main\", \"\uD83E\uDDE0 In-process memory wired to tool registry (shared handle)\");\n\n // #843: Wire memory to transport for session hydration on restart\n (transport as import(\"../components/transport/direct-api-transport.js\").DirectApiTransport).memoryBackend = ctx.memory!;\n\n // Wire context engine for automatic compaction\n const db = ctx.memory!.getDb?.() ?? ctx.memory!.getDatabase?.();\n if (db && resolved.contextWindow >= 128000) {\n const { ContextEngine } = await import(\"abmind\");\n const { createContextOrchestrator } = await import(\"../components/context/index.js\");\n const contextEngine = new ContextEngine(db);\n const orchestrator = createContextOrchestrator(\n contextEngine,\n async (systemPrompt: string, userPrompt: string) => {\n // Use the transport itself for summarization (same model, same endpoint)\n const { streamSingleCompletion } = await import(\"../components/transport/stream-single.js\");\n return streamSingleCompletion({\n endpoint: resolved.provider.endpoint ?? \"http://localhost:11434/v1\",\n apiKey: getEnv().getApiKey(resolved.provider.apiKeyEnv ?? \"API_KEY\") ?? undefined,\n model: resolved.model,\n systemPrompt,\n userPrompt,\n maxTokens: 4096,\n });\n },\n (_chatId: string) => {\n try { return ctx.memory?.getLastMessageTimestamp(true) ?? null; } catch (err) { logAndSwallow(TAG, \"getLastMessageTimestamp\", err); return null; }\n },\n );\n (transport as import(\"../components/transport/direct-api-transport.js\").DirectApiTransport).contextOrchestrator = orchestrator;\n logInfo(\"main\", \"\uD83D\uDCE6 Context engine wired (auto-compaction active)\");\n }\n }\n\n if (\"onFallback\" in transport) {\n let lastNotifiedModel: string | null = null;\n (transport as unknown as { onFallback: (model: string, ctxPct: number, reason?: string) => void }).onFallback = (model, ctxPct, reason) => {\n const reasonTag = reason ? ` (${reason})` : \"\";\n const msg = `\u26A1 Fallback${reasonTag}: ${model}${ctxPct >= 0 ? ` (ctx: ~${ctxPct}%)` : \"\"}`;\n logInfo(\"main\", msg);\n if (model !== lastNotifiedModel || isLogLevel(\"debug\")) {\n lastNotifiedModel = model;\n import(\"../components/notification.js\").then(({ sendNotification }) => sendNotification(ctx, msg)).catch(err => logAndSwallow(TAG, \"sendNotification fallback\", err));\n }\n };\n }\n return \"ran\";\n}\n\n/**\n * Rebuild professor transport in place (picks up transport.json changes).\n * Patches downstream references that captured the old transport (pipelineDeps, idleSave).\n */\nexport async function rebuildTransport(ctx: BootCtx): Promise<PhaseResult> {\n logInfo(\"main\", \"\uD83D\uDD04 Rebuilding transport...\");\n await buildTransport(ctx);\n if (ctx.pipelineDeps && ctx.transport) {\n (ctx.pipelineDeps as { transport: IKiroTransport }).transport = ctx.transport;\n }\n if (ctx.idleSave && ctx.transport) {\n (ctx.idleSave as unknown as { transport: IKiroTransport }).transport = ctx.transport;\n }\n logInfo(\"main\", \"\u2705 Transport rebuilt\");\n return \"ran\";\n}\n", "import { execSync } from \"node:child_process\";\nimport { writeFileSync, unlinkSync, mkdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { IKiroTransport } from \"./kiro-transport.js\";\nimport { logInfo, logDebug, logWarn } from \"../logger.js\";\nimport { logAndSwallow } from \"../log-and-swallow.js\";\nimport { abtarsHome } from \"../../paths.js\";\n\nconst TAG = \"tmux\";\n\n// Kiro CLI prompt pattern: \"N% >\" or \"N% !>\" where N is a number (context usage percentage)\n// The \"!\" appears in trust-all-tools mode\nconst KIRO_PROMPT_RE = /^\\d+%\\s*!?>/;\n\n// Also match common shell prompts as fallback\nconst SHELL_PROMPT_RE = /[$\u276F%#]\\s*$/;\n\n/**\n * Communicates with kiro-cli running inside a tmux session.\n * Uses `tmux send-keys` to send prompts and `tmux capture-pane`\n * to read responses.\n */\nexport class TmuxClient implements IKiroTransport {\n private readonly sessionName: string;\n private readonly captureDelaySec: number;\n private readonly maxWaitSec: number;\n private ready = false;\n\n /** Optional callback for streaming intermediate responses before final prompt. */\n onIntermediateResponse?: (text: string) => void;\n\n /** Tracks the cumulative text delivered via intermediate chunks (for tail detection). */\n private lastIntermediateDelivered = \"\";\n\n constructor(sessionName: string, captureDelaySec: number, maxWaitSec: number) {\n this.sessionName = sessionName;\n this.captureDelaySec = captureDelaySec;\n this.maxWaitSec = maxWaitSec;\n }\n\n async initialize(): Promise<void> {\n if (!this.sessionExists()) {\n throw new Error(\n `tmux session \"${this.sessionName}\" not found. ` +\n `Run: scripts/tmux-session.sh to start it.`,\n );\n }\n this.ready = true;\n logInfo(\"tmux\", `Session \"${this.sessionName}\" found`);\n }\n\n get isReady(): boolean {\n return this.ready && this.sessionExists();\n }\n\n readonly transportCommands: string[] = [];\n\n async sendPrompt(_sessionKey: string, message: string): Promise<string> {\n if (!this.isReady) {\n throw new Error(\"tmux session not available\");\n }\n\n this.lastIntermediateDelivered = \"\";\n const maxAttempts = 2;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n // Snapshot pane content before sending\n const before = this.capturePaneRaw();\n if (attempt === 1) {\n logDebug(\"tmux\", `Sending: \"${message.slice(0, 80)}\"`);\n } else {\n logInfo(\"tmux\", `Retry #${attempt}: resending prompt`);\n }\n\n // Send the message \u2014 use temp file for long prompts to avoid tmux command length limit\n try {\n if (message.length > 4000) {\n const tmpDir = join(abtarsHome(), \"tmp\");\n mkdirSync(tmpDir, { recursive: true });\n const tmpFile = join(tmpDir, `prompt-${Date.now()}.txt`);\n writeFileSync(tmpFile, message);\n const readCmd = `My full message is in ${tmpFile} \u2014 please read it and respond.`;\n const escaped = readCmd.replace(/'/g, \"'\\\\''\");\n this.exec(`tmux send-keys -t ${this.sessionName} '${escaped}' Enter`);\n setTimeout(() => { try { unlinkSync(tmpFile); } catch (err) { logAndSwallow(TAG, \"unlink tmpFile\", err); } }, 120_000);\n } else {\n const escaped = message.replace(/'/g, \"'\\\\''\");\n this.exec(`tmux send-keys -t ${this.sessionName} '${escaped}' Enter`);\n }\n } catch (err) {\n logWarn(\"tmux\", `send-keys failed: ${err instanceof Error ? err.message : String(err)}`);\n return \"\u26A0\uFE0F Failed to send message to Kiro session. The tmux session may be in copy mode or unresponsive. Try /reset.\";\n }\n\n // Wait for initial processing\n await sleep(this.captureDelaySec * 1000);\n\n // Poll until Kiro finishes\n const response = await this.pollForResponse(before);\n\n // Check for Kiro transient error \u2014 retry once\n if (response.startsWith(\"Kiro is having trouble\") && attempt < maxAttempts) {\n logInfo(\"tmux\", `Kiro trouble detected, will retry in 5s...`);\n await sleep(5000);\n continue;\n }\n\n logDebug(\"tmux\", `Got response (${response.length} chars)`);\n return response;\n }\n\n // Should not reach here, but just in case\n return \"\u26A0\uFE0F Kiro is having trouble responding. Try again or /reset.\";\n }\n\n async resetSession(_sessionKey: string): Promise<void> {\n if (!this.sessionExists()) return;\n this.exec(`tmux send-keys -t ${this.sessionName} C-c`);\n await sleep(1000);\n this.exec(`tmux send-keys -t ${this.sessionName} '/clear' Enter`);\n await sleep(2000);\n // Kiro asks \"Are you sure? [y/n]:\" \u2014 confirm with 'y'\n this.exec(`tmux send-keys -t ${this.sessionName} 'y' Enter`);\n await sleep(1000);\n }\n\n async restartSession(workingDir: string, kiroModel?: string): Promise<void> {\n // Kill existing tmux session and start fresh\n if (this.sessionExists()) {\n this.exec(`tmux kill-session -t ${this.sessionName}`);\n await sleep(1000);\n }\n let cmd = `kiro-cli chat --trust-all-tools`;\n if (kiroModel) cmd += ` --model ${kiroModel}`;\n this.exec(`tmux new-session -d -s ${this.sessionName} -c '${workingDir}' '${cmd}'`);\n this.exec(`tmux set-option -t ${this.sessionName} history-limit 5000`);\n await sleep(3000);\n // Enable thinking tool\n this.exec(`tmux send-keys -t ${this.sessionName} '/settings chat.enableThinking true' Enter`);\n await sleep(2000);\n this.ready = this.sessionExists();\n logInfo(\"tmux\", `Session restarted (ready=${this.ready})`);\n }\n\n async sendInterrupt(): Promise<void> {\n if (!this.sessionExists()) return;\n logInfo(\"tmux\", \"Sending Ctrl+C interrupt\");\n this.exec(`tmux send-keys -t ${this.sessionName} C-c`);\n }\n\n destroy(): void {\n this.ready = false;\n }\n\n /**\n * Poll capture-pane until Kiro's prompt reappears (N% >).\n * Delivers intermediate purple-line responses via onIntermediateResponse callback\n * so the user sees partial answers while Kiro continues with tools.\n * Only returns when the actual Kiro prompt appears or timeout.\n */\n private async pollForResponse(beforeSnapshot: string): Promise<string> {\n const startTime = Date.now();\n const maxWaitMs = this.maxWaitSec * 1000;\n let lastCapture = \"\";\n let stableCount = 0;\n let lastDeliveredAnswer = \"\";\n\n while (Date.now() - startTime < maxWaitMs) {\n const capture = this.capturePaneRaw();\n\n // Get only the NEW content (diff from before)\n const newContent = this.diffOutput(beforeSnapshot, capture);\n\n if (newContent.length === 0) {\n await sleep(2000);\n continue;\n }\n\n // Check if the last non-empty line is a Kiro prompt (N% >)\n const lines = capture.split(\"\\n\");\n const lastNonEmpty = this.getLastNonEmptyLine(lines);\n const lastClean = this.stripAnsi(lastNonEmpty);\n\n if (KIRO_PROMPT_RE.test(lastClean)) {\n const pctMatch = lastClean.match(/^(\\d+)%/);\n if (pctMatch) {\n this.lastContextPercent = parseInt(pctMatch[1]!, 10);\n logDebug(\"tmux\", `Context window: ${this.lastContextPercent}%`);\n }\n logDebug(\"tmux\", `Detected Kiro prompt: \"${lastClean}\"`);\n return this.extractResponse(newContent);\n }\n\n // Check for shell prompt as fallback\n if (SHELL_PROMPT_RE.test(lastClean) && newContent.length > 10) {\n logDebug(\"tmux\", `Detected shell prompt: \"${lastClean}\"`);\n return this.extractResponse(newContent);\n }\n\n // No prompt yet \u2014 deliver intermediate answer if we have new purple lines\n if (this.onIntermediateResponse && capture !== lastCapture) {\n const intermediateAnswer = this.extractAnswerOnly(newContent);\n if (intermediateAnswer && intermediateAnswer !== lastDeliveredAnswer) {\n const newPart = intermediateAnswer.startsWith(lastDeliveredAnswer)\n ? intermediateAnswer.slice(lastDeliveredAnswer.length).trim()\n : intermediateAnswer;\n if (newPart) {\n logDebug(\"tmux\", `Delivering intermediate chunk (${newPart.length} chars)`);\n this.onIntermediateResponse(newPart);\n lastDeliveredAnswer = intermediateAnswer;\n this.lastIntermediateDelivered = intermediateAnswer;\n }\n }\n }\n\n // Track stabilization but do NOT return on it \u2014 only N% > ends the poll\n if (capture === lastCapture) {\n stableCount++;\n } else {\n stableCount = 0;\n lastCapture = capture;\n }\n\n await sleep(2000);\n }\n\n // Timeout\n const finalCapture = this.capturePaneRaw();\n const finalNew = this.diffOutput(beforeSnapshot, finalCapture);\n if (finalNew.length > 0) {\n return this.extractResponse(finalNew) + \"\\n\\n\u23F1\uFE0F (response may be incomplete \u2014 timed out)\";\n }\n return \"\u23F1\uFE0F Kiro is still processing. Check the tmux session directly.\";\n }\n\n /**\n * Extract the meaningful response from the diff.\n * Removes the echoed user input line and Kiro's prompt lines.\n * Stores the \"answer only\" portion (lines that were \"> \" prefixed)\n * separately for TTS use.\n *\n * Kiro output format:\n * N% > <echoed user input>\n * > <response line 1>\n * > <response line 2>\n * \u25B8 Time: Ns\n * M% >\n */\n private lastAnswerOnly = \"\";\n private lastContextPercent = -1;\n\n /** Get just the Kiro answer lines (\"> \" prefixed) from the last response \u2014 for TTS. */\n get answerOnly(): string {\n return this.lastAnswerOnly;\n }\n get toolCallsSucceeded(): number { return 0; }\n\n /** Get the context window usage percentage from the last Kiro prompt (e.g. 10 for \"10% >\"). Returns -1 if unknown. */\n get contextPercent(): number {\n return this.lastContextPercent;\n }\n /** Get the cumulative text that was delivered via intermediate streaming. */\n get intermediateDeliveredText(): string {\n return this.lastIntermediateDelivered;\n }\n\n /** Extract just the purple \"> \" answer lines from raw tmux output (no side effects). */\n private extractAnswerOnly(raw: string): string {\n const PURPLE_PREFIX = /\\x1b\\[38;5;141m>\\s/;\n const lines = raw.split(\"\\n\");\n\n // Find last contiguous block of purple lines\n let blockStart = -1;\n for (let i = lines.length - 1; i >= 0; i--) {\n if (PURPLE_PREFIX.test(lines[i]!)) {\n blockStart = i;\n while (blockStart > 0 && PURPLE_PREFIX.test(lines[blockStart - 1]!)) blockStart--;\n break;\n }\n }\n if (blockStart < 0) return \"\";\n\n const answerLines: string[] = [];\n for (let i = blockStart; i < lines.length; i++) {\n const clean = this.stripAnsi(lines[i]!).trim();\n if (KIRO_PROMPT_RE.test(clean)) break;\n if (clean.startsWith(\"\u25B8 Time:\")) break;\n if (clean.startsWith(\"> \")) answerLines.push(clean.slice(2));\n else if (clean === \">\") answerLines.push(\"\");\n else if (clean === \"\") answerLines.push(\"\");\n else answerLines.push(clean);\n }\n return answerLines.join(\"\\n\").trim();\n }\n\n private extractResponse(raw: string): string {\n // ANSI color 141 (light purple) marks the \"> \" prefix on actual LLM response lines.\n // We detect these BEFORE stripping ANSI to reliably distinguish LLM output from\n // injected context (gray, color 245) and other noise.\n const PURPLE_PREFIX = /\\x1b\\[38;5;141m>\\s/;\n\n const lines = raw.split(\"\\n\");\n\n // First pass: identify lines that are genuine LLM responses (purple \"> \" prefix)\n const answerLines: string[] = [];\n let lastPurpleBlockStart = -1;\n\n for (let i = 0; i < lines.length; i++) {\n if (PURPLE_PREFIX.test(lines[i]!)) {\n if (lastPurpleBlockStart === -1) lastPurpleBlockStart = i;\n }\n }\n\n // Find the LAST contiguous block of purple \"> \" lines \u2014 that's the real answer.\n // Walk backwards to find the start of the last block.\n let blockStart = -1;\n for (let i = lines.length - 1; i >= 0; i--) {\n if (PURPLE_PREFIX.test(lines[i]!)) {\n blockStart = i;\n // Keep walking back through contiguous purple lines and continuation lines\n while (blockStart > 0) {\n const prev = lines[blockStart - 1]!;\n if (PURPLE_PREFIX.test(prev) || (!KIRO_PROMPT_RE.test(this.stripAnsi(prev).trim()) && !prev.includes(\"\u25B8 Time:\") && this.stripAnsi(prev).trim() !== \"\" && !PURPLE_PREFIX.test(prev) && blockStart === i)) {\n // Only extend back through purple lines\n if (PURPLE_PREFIX.test(prev)) {\n blockStart--;\n } else {\n break;\n }\n } else {\n break;\n }\n }\n break;\n }\n }\n\n if (blockStart >= 0) {\n // Extract from the last purple block to the end, stripping ANSI and \"> \" prefix\n for (let i = blockStart; i < lines.length; i++) {\n const line = lines[i]!;\n const clean = this.stripAnsi(line).trim();\n // Stop at Kiro prompt or Time summary\n if (KIRO_PROMPT_RE.test(clean)) break;\n if (clean.startsWith(\"\u25B8 Time:\") || clean.startsWith(\"\u25B8 Time:\")) break;\n if (clean === \"\") {\n answerLines.push(\"\");\n continue;\n }\n // Strip \"> \" prefix\n if (clean.startsWith(\"> \")) {\n answerLines.push(clean.slice(2));\n } else if (clean === \">\") {\n answerLines.push(\"\");\n } else {\n answerLines.push(clean);\n }\n }\n this.lastAnswerOnly = answerLines.join(\"\\n\").trim();\n } else {\n this.lastAnswerOnly = \"\";\n }\n\n // Full response: strip ANSI, then remove prompt lines and noise (legacy behavior)\n const cleaned = this.stripAnsi(raw);\n const allLines = cleaned.split(\"\\n\");\n const result: string[] = [];\n\n for (const line of allLines) {\n const trimmed = line.trim();\n if (result.length === 0 && trimmed === \"\") continue;\n if (KIRO_PROMPT_RE.test(trimmed)) continue;\n if (trimmed.startsWith(\"\u25B8 Time:\") || trimmed.startsWith(\"\u25B8 Time:\")) continue;\n if (/^-{4,}$/.test(trimmed)) continue;\n result.push(line);\n }\n\n const stripped = result.map((line) => {\n const trimmed = line.trimStart();\n if (trimmed.startsWith(\"> \")) return trimmed.slice(2);\n if (trimmed === \">\") return \"\";\n return line;\n });\n\n const final = stripped.join(\"\\n\").trim();\n logDebug(\"tmux\", `extractResponse: ${result.length} lines \u2192 \"${final.slice(0, 120)}\"`);\n if (this.lastAnswerOnly) {\n logDebug(\"tmux\", `answerOnly (${this.lastAnswerOnly.length} chars): \"${this.lastAnswerOnly.slice(0, 120)}\"`);\n }\n return final;\n }\n\n /** Get new content by diffing before/after snapshots. */\n private diffOutput(before: string, after: string): string {\n const beforeLines = before.split(\"\\n\");\n const afterLines = after.split(\"\\n\");\n\n // Find where the new content starts\n let commonPrefix = 0;\n while (\n commonPrefix < beforeLines.length &&\n commonPrefix < afterLines.length &&\n beforeLines[commonPrefix] === afterLines[commonPrefix]\n ) {\n commonPrefix++;\n }\n\n return afterLines.slice(commonPrefix).join(\"\\n\").trim();\n }\n\n /** Get the last non-empty line from an array. */\n private getLastNonEmptyLine(lines: string[]): string {\n for (let i = lines.length - 1; i >= 0; i--) {\n const trimmed = lines[i]!.trim();\n if (trimmed.length > 0) return trimmed;\n }\n return \"\";\n }\n\n /** Strip ANSI escape codes. */\n private stripAnsi(text: string): string {\n // eslint-disable-next-line no-control-regex\n return text.replace(/\\x1B\\[[0-9;]*[a-zA-Z]/g, \"\")\n .replace(/\\x1B\\][^\\x07]*\\x07/g, \"\"); // OSC sequences\n }\n\n private capturePaneRaw(): string {\n try {\n return this.exec(`tmux capture-pane -t ${this.sessionName} -p -e -S -2000`);\n } catch (err) {\n logAndSwallow(TAG, \"capturePaneRaw\", err);\n return \"\";\n }\n }\n\n private sessionExists(): boolean {\n try {\n this.exec(`tmux has-session -t ${this.sessionName}`);\n return true;\n } catch (err) {\n logAndSwallow(TAG, \"sessionExists check\", err);\n return false;\n }\n }\n\n private exec(command: string): string {\n return execSync(command, {\n encoding: \"utf-8\",\n timeout: 15_000,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n", "/**\n * Context-window-start persistence \u2014 per-user timestamps tracking when the\n * current context window began. Used by recall fallback stages.\n *\n * Called from phase-transport (initialize at boot), phase-sleep-cycle (reset\n * after sleep), and message-pipeline (update on session turn).\n */\n\nimport { logAndSwallow } from \"../components/log-and-swallow.js\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/** Update context-window-start timestamp for a chat. */\nexport function updateCtxStart(memoryDir: string, userId: string, ts = Date.now()): void {\n const p = join(memoryDir, \"context-window-start.json\");\n let data: Record<string, number> = {};\n try { data = JSON.parse(readFileSync(p, \"utf-8\")); } catch (err) { logAndSwallow(\"ctx_start\", \"op\", err); }\n data[userId] = ts;\n writeFileSync(p, JSON.stringify(data), \"utf-8\");\n}\n\n/** Set all context-window-start entries to now (called after sleep). */\nexport function resetAllCtxStarts(memoryDir: string): void {\n const p = join(memoryDir, \"context-window-start.json\");\n let data: Record<string, number> = {};\n try { data = JSON.parse(readFileSync(p, \"utf-8\")); } catch (err) { logAndSwallow(\"ctx_start\", \"read ctx-start json\", err); return; }\n const now = Date.now();\n for (const key of Object.keys(data)) data[key] = now;\n writeFileSync(p, JSON.stringify(data), \"utf-8\");\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQA,SAAS,YAAAA,iBAAgB;;;ACLzB;AACA;AACA;AANA,SAAS,gBAAgB;AACzB,SAAS,eAAe,YAAY,iBAAiB;AACrD,SAAS,YAAY;AAMrB,IAAM,MAAM;AAIZ,IAAM,iBAAiB;AAGvB,IAAM,kBAAkB;AAOjB,IAAM,aAAN,MAA2C;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACT,QAAQ;AAAA;AAAA,EAGhB;AAAA;AAAA,EAGQ,4BAA4B;AAAA,EAEpC,YAAY,aAAqB,iBAAyB,YAAoB;AAC5E,SAAK,cAAc;AACnB,SAAK,kBAAkB;AACvB,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,MAAM,aAA4B;AAChC,QAAI,CAAC,KAAK,cAAc,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,iBAAiB,KAAK,WAAW;AAAA,MAEnC;AAAA,IACF;AACA,SAAK,QAAQ;AACb,YAAQ,QAAQ,YAAY,KAAK,WAAW,SAAS;AAAA,EACvD;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,KAAK,SAAS,KAAK,cAAc;AAAA,EAC1C;AAAA,EAES,oB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BAAoB;AACpB,eAAO,4BAA+B,EAAE,KAAK,CAAC,EAAE,iBAAiB,MAAM,iBAAiB,KAAK,GAAG,CAAC,EAAE,MAAM,SAAO,cAAcA,MAAK,6BAA6B,GAAG,CAAC;AAAA,MACtK;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMA,eAAsB,iBAAiB,KAAoC;AACzE,UAAQ,QAAQ,mCAA4B;AAC5C,QAAM,eAAe,GAAG;AACxB,MAAI,IAAI,gBAAgB,IAAI,WAAW;AACrC,IAAC,IAAI,aAA+C,YAAY,IAAI;AAAA,EACtE;AACA,MAAI,IAAI,YAAY,IAAI,WAAW;AACjC,IAAC,IAAI,SAAsD,YAAY,IAAI;AAAA,EAC7E;AACA,UAAQ,QAAQ,0BAAqB;AACrC,SAAO;AACT;",
|
|
6
|
+
"names": ["execSync", "writeFileSync", "join", "TAG", "execSync", "join", "abtarsHome"]
|
|
7
|
+
}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { createRequire as __bundleCreateRequire } from 'node:module'; import { fileURLToPath as __bundleFileURLToPath } from 'node:url'; import { dirname as __bundleDirname } from 'node:path'; const require = __bundleCreateRequire(import.meta.url); const __chunk_filename = __bundleFileURLToPath(import.meta.url); const __chunk_dirname = __bundleDirname(__chunk_filename);
|
|
3
3
|
import {
|
|
4
4
|
AcpTransport
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PKHYCNTT.js";
|
|
6
6
|
import {
|
|
7
7
|
getEnv,
|
|
8
8
|
init_env_schema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3OXQWII3.js";
|
|
10
10
|
import {
|
|
11
11
|
init_logger,
|
|
12
12
|
logInfo,
|
|
13
13
|
logWarn
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GUTRAMK3.js";
|
|
15
15
|
|
|
16
16
|
// src/components/agent-registry.ts
|
|
17
17
|
init_env_schema();
|
|
@@ -60,7 +60,7 @@ var SUBAGENT_ACP_ROLE = {
|
|
|
60
60
|
task: "task"
|
|
61
61
|
};
|
|
62
62
|
async function createSubagentTransport(role, registry, currentModel) {
|
|
63
|
-
const { resolveAgent, getEnvFallback, loadTransport } = await import("./transport-config-
|
|
63
|
+
const { resolveAgent, getEnvFallback, loadTransport } = await import("./transport-config-JIKHB7GT.js");
|
|
64
64
|
const tc = loadTransport();
|
|
65
65
|
const agentName = SUBAGENT_TO_AGENT[role];
|
|
66
66
|
const resolved = tc ? resolveAgent(agentName, tc) : null;
|
|
@@ -70,7 +70,7 @@ async function createSubagentTransport(role, registry, currentModel) {
|
|
|
70
70
|
return { model: fb.model, provider: fb.provider, providerName: fb.providerName, contextWindow: fb.contextWindow, maxOutput: fb.maxOutput, fallbacks: [] };
|
|
71
71
|
})();
|
|
72
72
|
if (agent.provider.transport === "api") {
|
|
73
|
-
const { DirectApiTransport } = await import("./direct-api-transport-
|
|
73
|
+
const { DirectApiTransport } = await import("./direct-api-transport-QIWA5ES2.js");
|
|
74
74
|
const { FallbackPolicy } = await import("./fallback-policy-SR6ED5I3.js");
|
|
75
75
|
const apiKey = getEnv().getApiKey(agent.provider.apiKeyEnv ?? "API_KEY");
|
|
76
76
|
const startModel = currentModel ?? agent.model;
|
|
@@ -154,7 +154,7 @@ async function createSubagentTransport(role, registry, currentModel) {
|
|
|
154
154
|
logInfo("subagent", `${role} transport: DirectAPI ${agent.providerName} (model=${startModel}, ${candidates.length} candidates, shared registry: ${!!registry})`);
|
|
155
155
|
return { transport, model: agent.model };
|
|
156
156
|
}
|
|
157
|
-
const { loadAndValidateConfig } = await import("./config-
|
|
157
|
+
const { loadAndValidateConfig } = await import("./config-NDEYF4AQ.js");
|
|
158
158
|
const config = await loadAndValidateConfig();
|
|
159
159
|
const chain = agent.provider.fallbackChain ?? [];
|
|
160
160
|
const modelsToTry = [agent.model, ...chain.filter((m) => m !== agent.model)];
|
|
@@ -186,4 +186,4 @@ export {
|
|
|
186
186
|
createAgentTransport,
|
|
187
187
|
createSubagentTransport
|
|
188
188
|
};
|
|
189
|
-
//# sourceMappingURL=chunk-
|
|
189
|
+
//# sourceMappingURL=chunk-7WFE2JI5.js.map
|