agentix-cli 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -118
- package/apps/mac-helper/Sources/AgentXHelper/AXTree.swift +159 -0
- package/apps/mac-helper/Sources/AgentXHelper/Brand.swift +63 -0
- package/apps/mac-helper/Sources/AgentXHelper/Focus.swift +97 -0
- package/apps/mac-helper/Sources/AgentXHelper/HUD.swift +179 -0
- package/apps/mac-helper/Sources/AgentXHelper/OCR.swift +117 -0
- package/apps/mac-helper/Sources/AgentXHelper/Pointer.swift +309 -0
- package/apps/mac-helper/Sources/AgentXHelper/Screens.swift +67 -0
- package/apps/mac-helper/Sources/AgentXHelper/Typer.swift +185 -0
- package/apps/mac-helper/Sources/AgentXHelper/Vision.swift +201 -0
- package/apps/mac-helper/Sources/AgentXHelper/main.swift +265 -0
- package/apps/mac-helper/build.sh +39 -0
- package/apps/mac-voice/Resources/Info.plist +18 -0
- package/apps/mac-voice/Sources/AgentXVoice/AgentClient.swift +108 -0
- package/apps/mac-voice/Sources/AgentXVoice/Brand.swift +123 -0
- package/apps/mac-voice/Sources/AgentXVoice/Config.swift +68 -0
- package/apps/mac-voice/Sources/AgentXVoice/Hold.swift +74 -0
- package/apps/mac-voice/Sources/AgentXVoice/Hotkey.swift +76 -0
- package/apps/mac-voice/Sources/AgentXVoice/Markdown.swift +140 -0
- package/apps/mac-voice/Sources/AgentXVoice/Panel.swift +275 -0
- package/apps/mac-voice/Sources/AgentXVoice/Progress.swift +147 -0
- package/apps/mac-voice/Sources/AgentXVoice/Recorder.swift +139 -0
- package/apps/mac-voice/Sources/AgentXVoice/ResultCard.swift +162 -0
- package/apps/mac-voice/Sources/AgentXVoice/SmartPaste.swift +72 -0
- package/apps/mac-voice/Sources/AgentXVoice/Speech.swift +192 -0
- package/apps/mac-voice/Sources/AgentXVoice/StepLabel.swift +159 -0
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +380 -0
- package/apps/mac-voice/build.sh +32 -0
- package/dist/{App-BPNHIGUX.js → App-CKPH3HHF.js} +2 -2
- package/dist/{ChatApp-6XSSZB4U.js → ChatApp-MX7IG4K2.js} +2 -2
- package/dist/agent-2U574KBZ.js +2 -0
- package/dist/article-fields-L4D2BOGY.js +2 -0
- package/dist/article-quality-44ONVGLN.js +3 -0
- package/dist/article-quality-44ONVGLN.js.map +1 -0
- package/dist/{audit-JU3HWISB.js → audit-4245CX6P.js} +2 -2
- package/dist/backfill-MTD2B62I.js +6 -0
- package/dist/backfill-MTD2B62I.js.map +1 -0
- package/dist/{board-dashboard-M3372FLO.js → board-dashboard-QR7CVTKA.js} +1411 -453
- package/dist/board-dashboard-QR7CVTKA.js.map +1 -0
- package/dist/{builtin-FRKAQMFS.js → builtin-B67DMJ3M.js} +2 -2
- package/dist/calibration-ILS5OI44.js +2 -0
- package/dist/{chunk-V3U4OF7L.js → chunk-3LYM22IV.js} +46 -48
- package/dist/chunk-3LYM22IV.js.map +1 -0
- package/dist/chunk-3SCPRYJB.js +5 -0
- package/dist/chunk-3SCPRYJB.js.map +1 -0
- package/dist/chunk-4BR7D2OU.js +36 -0
- package/dist/chunk-4BR7D2OU.js.map +1 -0
- package/dist/{chunk-P4VWIVKN.js → chunk-52ZPELD2.js} +403 -29
- package/dist/chunk-52ZPELD2.js.map +1 -0
- package/dist/chunk-5IA2CYHN.js +5 -0
- package/dist/{chunk-O6YPEOQF.js.map → chunk-5IA2CYHN.js.map} +1 -1
- package/dist/chunk-64CAIB3C.js +9 -0
- package/dist/chunk-64CAIB3C.js.map +1 -0
- package/dist/{chunk-5U35WAZF.js → chunk-77OV7346.js} +6 -6
- package/dist/chunk-77OV7346.js.map +1 -0
- package/dist/chunk-AJ5RMU7X.js +2 -0
- package/dist/chunk-AJ5RMU7X.js.map +1 -0
- package/dist/chunk-AJONZWLT.js +2 -0
- package/dist/chunk-AJONZWLT.js.map +1 -0
- package/dist/chunk-BH3GTCZ6.js +2 -0
- package/dist/chunk-BH3GTCZ6.js.map +1 -0
- package/dist/chunk-E3UJHQGN.js +1189 -0
- package/dist/chunk-E3UJHQGN.js.map +1 -0
- package/dist/chunk-EVWEG3VD.js +3 -0
- package/dist/chunk-EVWEG3VD.js.map +1 -0
- package/dist/chunk-F4HZTZHW.js +2 -0
- package/dist/chunk-F4HZTZHW.js.map +1 -0
- package/dist/chunk-F6CNF7V3.js +25 -0
- package/dist/chunk-F6CNF7V3.js.map +1 -0
- package/dist/chunk-FIOB3MEX.js +2 -0
- package/dist/{chunk-H5D7ATXS.js → chunk-FKBGJYWQ.js} +5 -5
- package/dist/chunk-FKBGJYWQ.js.map +1 -0
- package/dist/{chunk-BVGJSPW4.js → chunk-G2HMRDUQ.js} +7 -7
- package/dist/chunk-G2HMRDUQ.js.map +1 -0
- package/dist/chunk-H2QQU2XV.js +109 -0
- package/dist/chunk-H2QQU2XV.js.map +1 -0
- package/dist/{chunk-LDHPMJ7M.js → chunk-IWMW5432.js} +3 -3
- package/dist/chunk-IWMW5432.js.map +1 -0
- package/dist/chunk-K33GIBSE.js +2 -0
- package/dist/chunk-K33GIBSE.js.map +1 -0
- package/dist/chunk-L2WSPY6S.js +2 -0
- package/dist/chunk-L2WSPY6S.js.map +1 -0
- package/dist/chunk-LCIREYTD.js +54 -0
- package/dist/chunk-LCIREYTD.js.map +1 -0
- package/dist/chunk-MHIMGM4G.js +126 -0
- package/dist/chunk-MHIMGM4G.js.map +1 -0
- package/dist/chunk-P5ZBBEPL.js +13 -0
- package/dist/chunk-P5ZBBEPL.js.map +1 -0
- package/dist/{chunk-JTJIPNXY.js → chunk-PNWNVOEZ.js} +1 -1
- package/dist/chunk-PNWNVOEZ.js.map +1 -0
- package/dist/chunk-QHTQPBHU.js +45 -0
- package/dist/chunk-QHTQPBHU.js.map +1 -0
- package/dist/chunk-S2MNL5V6.js +2 -0
- package/dist/chunk-S2MNL5V6.js.map +1 -0
- package/dist/chunk-SCTIUFL4.js +5 -0
- package/dist/{chunk-K2CAPYES.js.map → chunk-SCTIUFL4.js.map} +1 -1
- package/dist/chunk-ULLAE6LE.js +157 -0
- package/dist/chunk-ULLAE6LE.js.map +1 -0
- package/dist/{chunk-DJEZ2HVU.js → chunk-VDMYBPYB.js} +1 -1
- package/dist/chunk-VDMYBPYB.js.map +1 -0
- package/dist/chunk-VIH7ARPF.js +547 -0
- package/dist/chunk-VIH7ARPF.js.map +1 -0
- package/dist/chunk-W5C2GDNC.js +32 -0
- package/dist/{chunk-JP5IEXR7.js.map → chunk-W5C2GDNC.js.map} +1 -1
- package/dist/chunk-WPMX3VGI.js +3 -0
- package/dist/chunk-WPMX3VGI.js.map +1 -0
- package/dist/chunk-YLBERT7N.js +24 -0
- package/dist/chunk-YLBERT7N.js.map +1 -0
- package/dist/chunk-YLGIZRHV.js +114 -0
- package/dist/chunk-YLGIZRHV.js.map +1 -0
- package/dist/chunk-ZMYGXHPT.js +121 -0
- package/dist/chunk-ZMYGXHPT.js.map +1 -0
- package/dist/chunk-ZTEU5JVQ.js +2 -0
- package/dist/chunk-ZTEU5JVQ.js.map +1 -0
- package/dist/{chunk-2WVX3LEC.js → chunk-ZVP6GB4G.js} +1 -1
- package/dist/chunk-ZVP6GB4G.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client-ZLSXGPTV.js +2 -0
- package/dist/{compaction-NWEMOSHA.js → compaction-FD4R23HZ.js} +4 -4
- package/dist/config-HMW3EBZL.js +2 -0
- package/dist/config-mutator-4SZ5YEVD.js +2 -0
- package/dist/{conflict-detector-D7VIYPDI.js → conflict-detector-ZPOT3M2C.js} +2 -2
- package/dist/conflict-detector-ZPOT3M2C.js.map +1 -0
- package/dist/context-planner-AQHJMVY2.js +17 -0
- package/dist/context-planner-AQHJMVY2.js.map +1 -0
- package/dist/debug-3MEUO2P2.js +2 -0
- package/dist/{discover-XJXQXXIO.js → discover-D4VVRNAI.js} +2 -2
- package/dist/discover-D4VVRNAI.js.map +1 -0
- package/dist/doctor-LRYV3QLK.js +2 -0
- package/dist/editor-chat-OB7IQOB5.js +137 -0
- package/dist/editor-chat-OB7IQOB5.js.map +1 -0
- package/dist/entry-triage-LK34TSQD.js +2 -0
- package/dist/entry-triage-LK34TSQD.js.map +1 -0
- package/dist/facts-YVEJOM7O.js +22 -0
- package/dist/facts-YVEJOM7O.js.map +1 -0
- package/dist/heal-FVLBHYP7.js +2 -0
- package/dist/index.d.ts +1040 -64
- package/dist/index.js +12 -19
- package/dist/index.js.map +1 -1
- package/dist/{ingest-whatsapp-LZE62INA.js → ingest-whatsapp-NS4OWDOU.js} +2 -2
- package/dist/loader-4ZGTK7LD.js +2 -0
- package/dist/loader-BOKE5M5S.js +2 -0
- package/dist/memory-extract-F5ZHWY5E.js +2 -0
- package/dist/{migrate-v2-QO7SLKIM.js → migrate-v2-V4WN2VVM.js} +2 -2
- package/dist/ntfy-X7EPB3TG.js +4 -0
- package/dist/ntfy-X7EPB3TG.js.map +1 -0
- package/dist/processes-WU23U2OJ.js +2 -0
- package/dist/program-GSZ5AYAM.js +2 -0
- package/dist/{projects-api-KRME2YKZ.js → projects-api-QE6L65SK.js} +2 -2
- package/dist/{projects-mutate-3NHVG437.js → projects-mutate-MY7JTLSZ.js} +2 -2
- package/dist/providers-KO2DODIO.js +2 -0
- package/dist/query-SQDHE4HV.js +2 -0
- package/dist/questions-4B4KSPXG.js +3 -0
- package/dist/questions-4B4KSPXG.js.map +1 -0
- package/dist/recipes-7S4MC5OJ.js +2 -0
- package/dist/registry-LE6FWYZC.js +2 -0
- package/dist/review-candidates-RQU5KNZM.js +4 -0
- package/dist/review-candidates-RQU5KNZM.js.map +1 -0
- package/dist/review-store-B4YE3EFK.js +4 -0
- package/dist/review-store-B4YE3EFK.js.map +1 -0
- package/dist/{rotation-memo-B3EXXSEH.js → rotation-memo-7T75BLEX.js} +2 -2
- package/dist/routing-ILERJXB6.js +2 -0
- package/dist/runner-YRBVNYTY.js +2 -0
- package/dist/scheduler-BFM3EINS.js +2 -0
- package/dist/seat-7WM7II2B.js +2 -0
- package/dist/select-X4KVMOP5.js +2 -0
- package/dist/select-X4KVMOP5.js.map +1 -0
- package/dist/store-MCOA6N4F.js +2 -0
- package/dist/{subagent-WV7QKQ3L.js → subagent-2SJHSSJS.js} +2 -2
- package/dist/{surface-usage-PRL6Z4U3.js → surface-usage-NS74AXSE.js} +2 -2
- package/dist/timers-PCB4ZIBD.js +2 -0
- package/dist/triage-backtest-JNO7RKX7.js +2 -0
- package/dist/triage-backtest-JNO7RKX7.js.map +1 -0
- package/dist/types-H5ENIUIT.js +2 -0
- package/dist/types-OIFU3KSQ.js +2 -0
- package/dist/types-OIFU3KSQ.js.map +1 -0
- package/dist/web/workflow-editor.global.js +1542 -0
- package/dist/web/workflow-editor.global.js.map +1 -0
- package/dist/{whatsapp-state-XMTCSRXU.js → whatsapp-state-6D6FHHD2.js} +2 -2
- package/dist/wiki-2AUFSIKO.js +2 -0
- package/dist/wiki-2AUFSIKO.js.map +1 -0
- package/dist/workflows/templates/branching.yaml +1 -1
- package/dist/{workspace-setup-TBQAHYHJ.js → workspace-setup-B3F3TUDE.js} +2 -2
- package/dist/workspace-setup-B3F3TUDE.js.map +1 -0
- package/package.json +14 -3
- package/scripts/postinstall.mjs +80 -0
- package/dist/agent-5QMITZT6.js +0 -2
- package/dist/architect-SEPWMWS4.js +0 -2
- package/dist/board-dashboard-M3372FLO.js.map +0 -1
- package/dist/chunk-2WVX3LEC.js.map +0 -1
- package/dist/chunk-3WQFCIB6.js +0 -24
- package/dist/chunk-3WQFCIB6.js.map +0 -1
- package/dist/chunk-4YCH6IZV.js +0 -2
- package/dist/chunk-53NRX2NA.js +0 -2
- package/dist/chunk-53NRX2NA.js.map +0 -1
- package/dist/chunk-5U35WAZF.js.map +0 -1
- package/dist/chunk-BFXONUUN.js +0 -108
- package/dist/chunk-BFXONUUN.js.map +0 -1
- package/dist/chunk-BFZUG66X.js +0 -45
- package/dist/chunk-BFZUG66X.js.map +0 -1
- package/dist/chunk-BTHHSY7D.js +0 -13
- package/dist/chunk-BTHHSY7D.js.map +0 -1
- package/dist/chunk-BVGJSPW4.js.map +0 -1
- package/dist/chunk-D46VZ7K7.js +0 -116
- package/dist/chunk-D46VZ7K7.js.map +0 -1
- package/dist/chunk-DJEZ2HVU.js.map +0 -1
- package/dist/chunk-E5CXCI33.js +0 -155
- package/dist/chunk-E5CXCI33.js.map +0 -1
- package/dist/chunk-FDWOECJY.js +0 -54
- package/dist/chunk-FDWOECJY.js.map +0 -1
- package/dist/chunk-H5D7ATXS.js.map +0 -1
- package/dist/chunk-HR4JSRZS.js +0 -3
- package/dist/chunk-HR4JSRZS.js.map +0 -1
- package/dist/chunk-ISEBLHWX.js +0 -118
- package/dist/chunk-ISEBLHWX.js.map +0 -1
- package/dist/chunk-JP5IEXR7.js +0 -32
- package/dist/chunk-JTJIPNXY.js.map +0 -1
- package/dist/chunk-K2CAPYES.js +0 -5
- package/dist/chunk-LDHPMJ7M.js.map +0 -1
- package/dist/chunk-METYYZKQ.js +0 -1115
- package/dist/chunk-METYYZKQ.js.map +0 -1
- package/dist/chunk-MTAPOCGA.js +0 -47
- package/dist/chunk-MTAPOCGA.js.map +0 -1
- package/dist/chunk-O6YPEOQF.js +0 -5
- package/dist/chunk-P4VWIVKN.js.map +0 -1
- package/dist/chunk-SR3X25TN.js +0 -3
- package/dist/chunk-SR3X25TN.js.map +0 -1
- package/dist/chunk-UHE5FCPB.js +0 -431
- package/dist/chunk-UHE5FCPB.js.map +0 -1
- package/dist/chunk-V3U4OF7L.js.map +0 -1
- package/dist/chunk-VJUTQAPJ.js +0 -2
- package/dist/chunk-VJUTQAPJ.js.map +0 -1
- package/dist/chunk-VT5XYFDD.js +0 -126
- package/dist/chunk-VT5XYFDD.js.map +0 -1
- package/dist/client-HGKAC6VP.js +0 -2
- package/dist/config-A4RWEJHV.js +0 -2
- package/dist/config-mutator-MNSFUN7D.js +0 -2
- package/dist/conflict-detector-D7VIYPDI.js.map +0 -1
- package/dist/context-planner-45GEWKGL.js +0 -17
- package/dist/context-planner-45GEWKGL.js.map +0 -1
- package/dist/debug-N3B5NVJU.js +0 -2
- package/dist/discover-XJXQXXIO.js.map +0 -1
- package/dist/doctor-3Q36ZFE6.js +0 -2
- package/dist/heal-HZ3EQD52.js +0 -2
- package/dist/loader-5CA3O5GM.js +0 -2
- package/dist/loader-6IHUCPVO.js +0 -2
- package/dist/memory-extract-AENFVVO5.js +0 -2
- package/dist/processes-UIC4XXA6.js +0 -2
- package/dist/program-SAUNRCCD.js +0 -2
- package/dist/providers-L27BJ5A6.js +0 -2
- package/dist/query-HZYYRCLU.js +0 -2
- package/dist/recipes-EPLE2SNT.js +0 -2
- package/dist/registry-HK3WQ7BS.js +0 -2
- package/dist/runner-BFYDWPUO.js +0 -2
- package/dist/scheduler-6T2SU5ST.js +0 -2
- package/dist/store-I3HEWVLQ.js +0 -2
- package/dist/timers-5LPZN55J.js +0 -2
- package/dist/types-VECTMYTO.js +0 -2
- package/dist/types-Y6ZCZ52Z.js +0 -2
- package/dist/wiki-M6YNRFC4.js +0 -2
- /package/dist/{App-BPNHIGUX.js.map → App-CKPH3HHF.js.map} +0 -0
- /package/dist/{ChatApp-6XSSZB4U.js.map → ChatApp-MX7IG4K2.js.map} +0 -0
- /package/dist/{agent-5QMITZT6.js.map → agent-2U574KBZ.js.map} +0 -0
- /package/dist/{architect-SEPWMWS4.js.map → article-fields-L4D2BOGY.js.map} +0 -0
- /package/dist/{audit-JU3HWISB.js.map → audit-4245CX6P.js.map} +0 -0
- /package/dist/{builtin-FRKAQMFS.js.map → builtin-B67DMJ3M.js.map} +0 -0
- /package/dist/{chunk-4YCH6IZV.js.map → calibration-ILS5OI44.js.map} +0 -0
- /package/dist/{client-HGKAC6VP.js.map → chunk-FIOB3MEX.js.map} +0 -0
- /package/dist/{config-A4RWEJHV.js.map → client-ZLSXGPTV.js.map} +0 -0
- /package/dist/{compaction-NWEMOSHA.js.map → compaction-FD4R23HZ.js.map} +0 -0
- /package/dist/{config-mutator-MNSFUN7D.js.map → config-HMW3EBZL.js.map} +0 -0
- /package/dist/{debug-N3B5NVJU.js.map → config-mutator-4SZ5YEVD.js.map} +0 -0
- /package/dist/{doctor-3Q36ZFE6.js.map → debug-3MEUO2P2.js.map} +0 -0
- /package/dist/{heal-HZ3EQD52.js.map → doctor-LRYV3QLK.js.map} +0 -0
- /package/dist/{loader-5CA3O5GM.js.map → heal-FVLBHYP7.js.map} +0 -0
- /package/dist/{ingest-whatsapp-LZE62INA.js.map → ingest-whatsapp-NS4OWDOU.js.map} +0 -0
- /package/dist/{loader-6IHUCPVO.js.map → loader-4ZGTK7LD.js.map} +0 -0
- /package/dist/{memory-extract-AENFVVO5.js.map → loader-BOKE5M5S.js.map} +0 -0
- /package/dist/{processes-UIC4XXA6.js.map → memory-extract-F5ZHWY5E.js.map} +0 -0
- /package/dist/{migrate-v2-QO7SLKIM.js.map → migrate-v2-V4WN2VVM.js.map} +0 -0
- /package/dist/{program-SAUNRCCD.js.map → processes-WU23U2OJ.js.map} +0 -0
- /package/dist/{providers-L27BJ5A6.js.map → program-GSZ5AYAM.js.map} +0 -0
- /package/dist/{projects-api-KRME2YKZ.js.map → projects-api-QE6L65SK.js.map} +0 -0
- /package/dist/{projects-mutate-3NHVG437.js.map → projects-mutate-MY7JTLSZ.js.map} +0 -0
- /package/dist/{query-HZYYRCLU.js.map → providers-KO2DODIO.js.map} +0 -0
- /package/dist/{recipes-EPLE2SNT.js.map → query-SQDHE4HV.js.map} +0 -0
- /package/dist/{registry-HK3WQ7BS.js.map → recipes-7S4MC5OJ.js.map} +0 -0
- /package/dist/{runner-BFYDWPUO.js.map → registry-LE6FWYZC.js.map} +0 -0
- /package/dist/{rotation-memo-B3EXXSEH.js.map → rotation-memo-7T75BLEX.js.map} +0 -0
- /package/dist/{scheduler-6T2SU5ST.js.map → routing-ILERJXB6.js.map} +0 -0
- /package/dist/{store-I3HEWVLQ.js.map → runner-YRBVNYTY.js.map} +0 -0
- /package/dist/{surface-usage-PRL6Z4U3.js.map → scheduler-BFM3EINS.js.map} +0 -0
- /package/dist/{timers-5LPZN55J.js.map → seat-7WM7II2B.js.map} +0 -0
- /package/dist/{types-VECTMYTO.js.map → store-MCOA6N4F.js.map} +0 -0
- /package/dist/{subagent-WV7QKQ3L.js.map → subagent-2SJHSSJS.js.map} +0 -0
- /package/dist/{types-Y6ZCZ52Z.js.map → surface-usage-NS74AXSE.js.map} +0 -0
- /package/dist/{wiki-M6YNRFC4.js.map → timers-PCB4ZIBD.js.map} +0 -0
- /package/dist/{workspace-setup-TBQAHYHJ.js.map → types-H5ENIUIT.js.map} +0 -0
- /package/dist/{whatsapp-state-XMTCSRXU.js.map → whatsapp-state-6D6FHHD2.js.map} +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import{a as Ge,b as Fe,c as Se}from"./chunk-SFQUP3BP.js";import{b as Te,c as Ce}from"./chunk-QOYAX2FT.js";import{a as Q,c as Ne,e as we,f as ke,g as be,i as xe,k as gt,o as ve,p as ht}from"./chunk-LCIREYTD.js";import{a as R,b as ye}from"./chunk-L2WSPY6S.js";import{a as Le,d as _e}from"./chunk-VDMYBPYB.js";import{e as b}from"./chunk-DSYKYZMT.js";import{z as $}from"zod";var qe=$.object({provider:$.enum(["claude-code","claude","openai","deepseek","ollama","demo","custom"]).default("claude-code"),model:$.string().optional(),apiKey:$.string().optional(),skills:$.array($.string()).default([]),output:$.object({dir:$.string().default("./generated")}).default({}),context7:$.object({enabled:$.boolean().default(!0),apiKey:$.string().optional()}).default({}),agentic:$.object({maxIterations:$.number().default(20),enabledTools:$.array($.string()).default(["create_files","ask_user","read_file","search_files","list_directory","run_command","edit_file"]),disabledTools:$.array($.string()).default([])}).default({})}),Vt=["component","page","api","website","document","script","config","skill","media","report","test","workflow","schema","email","diagram","auto"],Yt={component:"UI component (any framework)",page:"Full page or screen",api:"API endpoint, route handler, or service",website:"Multi-page website or app",document:"Markdown, documentation, or specification",script:"Standalone script or utility",config:"Configuration file or setup",skill:"Agent skill (SKILL.md format for skills.sh)",media:"Media generation prompt (image/audio/video description)",report:"Analysis report or audit",test:"Test suite, test fixtures, or test data",workflow:"CI/CD pipeline, GitHub Actions, or automation",schema:"Database schema, Zod validators, or GraphQL types",email:"Email template (React Email, MJML, HTML)",diagram:"Mermaid, D2, or PlantUML diagram",auto:"Auto-detect the best output type"};ht();ke();ke();import{existsSync as yt,promises as wt}from"fs";import K from"path";import kt from"fast-glob";var Be={"prisma/schema.prisma":{type:"prisma",category:"database"},"drizzle/schema.ts":{type:"drizzle",category:"database"},"schema.graphql":{type:"graphql",category:"api"},"schema.gql":{type:"graphql",category:"api"},"openapi.yaml":{type:"openapi",category:"api"},"openapi.json":{type:"openapi",category:"api"},"swagger.yaml":{type:"openapi",category:"api"},"swagger.json":{type:"openapi",category:"api"}};async function We(r){let e={},t=await kt.glob("**/*",{cwd:r,deep:4,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**","**/target/**","**/__pycache__/**","**/vendor/**","**/.git/**"],onlyFiles:!0});for(let[s,i]of Object.entries(Be)){let c=t.find(a=>a.endsWith(s)||a===s);if(c&&i.category==="database"){let a=await Z(K.resolve(r,c));if(a){e.database={type:i.type,content:ce(a,3e3),tables:bt(a,i.type)};break}}}for(let[s,i]of Object.entries(Be)){let c=t.find(a=>a.endsWith(s)||a===s);if(c&&i.category==="api"){let a=await Z(K.resolve(r,c));if(a){e.api={type:i.type,content:ce(a,3e3)};break}}}if(!e.api){let s=t.find(i=>i.includes("trpc")&&(i.endsWith("router.ts")||i.endsWith("router.js")));if(s){let i=await Z(K.resolve(r,s));i&&(e.api={type:"trpc",content:ce(i,3e3)})}}let o=t.find(s=>s===".env.example"||s===".env.local.example"||s===".env.template");if(o){let s=await Z(K.resolve(r,o));s&&(e.env=xt(s))}let n=t.filter(s=>(s.includes("models")||s.includes("types")||s.includes("schemas"))&&(s.endsWith(".ts")||s.endsWith(".py")||s.endsWith(".rs")||s.endsWith(".go")));if(n.length){e.models=[];for(let s of n.slice(0,5)){let i=await Z(K.resolve(r,s));i&&e.models.push({path:s,content:ce(i,2e3),type:K.extname(s).slice(1)})}}return e}function bt(r,e){if(e==="prisma"){let t=r.match(/model\s+(\w+)\s*\{/g);return t?t.map(o=>o.replace(/model\s+/,"").replace(/\s*\{/,"")):[]}return[]}function xt(r){return{variables:r.split(`
|
|
2
|
+
`).filter(o=>o.trim()&&!o.trim().startsWith("#")).map(o=>{let[n]=o.split("="),s=n.trim(),i=o.includes("=")&&o.split("=")[1]?.trim().length>0;return{key:s,required:!i}})}}async function Z(r){try{return yt(r)?await wt.readFile(r,"utf8"):null}catch{return null}}function ce(r,e){return r.length<=e?r:r.slice(0,e)+`
|
|
3
|
+
... (truncated)`}function ze(r){let e=[];if(r.database&&e.push(`## Database Schema (${r.database.type})
|
|
4
|
+
`+(r.database.tables?.length?`Tables: ${r.database.tables.join(", ")}
|
|
5
|
+
`:"")+"```\n"+r.database.content+"\n```"),r.api&&e.push(`## API Schema (${r.api.type})
|
|
6
|
+
\`\`\`
|
|
7
|
+
`+r.api.content+"\n```"),r.env&&e.push(`## Environment Variables
|
|
8
|
+
`+r.env.variables.map(t=>`- ${t.key}${t.required?" (required)":""}`).join(`
|
|
9
|
+
`)),r.models?.length)for(let t of r.models)e.push(`## Model: ${t.path}
|
|
10
|
+
\`\`\``+t.type+`
|
|
11
|
+
`+t.content+"\n```");return e.join(`
|
|
12
|
+
|
|
13
|
+
`)}import Je from"node-fetch";var Ke="https://api.context7.com/v1";async function vt(r,e){try{let t={"Content-Type":"application/json"};e&&(t.Authorization=`Bearer ${e}`);let o=await Je(`${Ke}/libraries/resolve`,{method:"POST",headers:t,body:JSON.stringify({name:r})});if(!o.ok)return null;let n=await o.json();return n?.libraries?.length?n.libraries[0]:null}catch{return null}}async function _t(r,e,t=5e3,o){try{let n={"Content-Type":"application/json"};o&&(n.Authorization=`Bearer ${o}`);let s=await Je(`${Ke}/libraries/${encodeURIComponent(r)}/docs`,{method:"POST",headers:n,body:JSON.stringify({topic:e,maxTokens:t})});return s.ok&&(await s.json())?.content||null}catch{return null}}async function Ve(r,e,t){let o=[];for(let i of r.frameworks.slice(0,3))o.push(i.name);let n=["react","vue","svelte","angular","next","nuxt","express","fastify","hono","prisma","drizzle-orm","tailwindcss","shadcn","@tanstack/react-query","zod","trpc"];for(let i of n)(r.dependencies[i]||r.devDependencies[i])&&(o.includes(i)||o.push(i));let s=[];for(let i of o.slice(0,5)){let c=await vt(i,t);if(c){let a=await _t(c.id,e,3e3,t);a&&s.push(`## ${c.name} Documentation
|
|
14
|
+
${a}`)}}return s.length?`# Relevant Library Documentation (via Context7)
|
|
15
|
+
|
|
16
|
+
${s.join(`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
`)}`:""}var Ye={component:{type:"component",baseDir:"src/components",filePatterns:["*.tsx","*.vue","*.svelte","*.jsx","*.ts"],description:"UI component"},page:{type:"page",baseDir:"src/app",filePatterns:["*.tsx","*.vue","*.svelte","*.jsx","*.astro"],description:"Page or screen"},api:{type:"api",baseDir:"src/api",filePatterns:["*.ts","*.js","*.py","*.go","*.rs"],description:"API route or endpoint"},website:{type:"website",baseDir:".",filePatterns:["*"],description:"Multi-file website"},document:{type:"document",baseDir:"docs",filePatterns:["*.md","*.mdx","*.txt","*.rst"],description:"Documentation"},script:{type:"script",baseDir:"scripts",filePatterns:["*.ts","*.js","*.py","*.sh","*.go"],description:"Standalone script"},config:{type:"config",baseDir:".",filePatterns:["*.json","*.yaml","*.yml","*.toml","*.env"],description:"Configuration file"},skill:{type:"skill",baseDir:".skills",filePatterns:["SKILL.md"],description:"Agent skill (SKILL.md)"},media:{type:"media",baseDir:"media",filePatterns:["*.md","*.json","*.txt"],description:"Media generation prompt/description"},report:{type:"report",baseDir:"reports",filePatterns:["*.md","*.html","*.json"],description:"Analysis report"},test:{type:"test",baseDir:"src",filePatterns:["*.test.ts","*.test.tsx","*.spec.ts","*.test.js","*.test.py","*.test.go"],description:"Test suite or fixture"},workflow:{type:"workflow",baseDir:".github/workflows",filePatterns:["*.yml","*.yaml"],description:"CI/CD pipeline or automation"},schema:{type:"schema",baseDir:"src",filePatterns:["*.ts","*.prisma","*.graphql","*.gql","*.py"],description:"Database schema, validators, or types"},email:{type:"email",baseDir:"src/emails",filePatterns:["*.tsx","*.jsx","*.html","*.mjml"],description:"Email template"},diagram:{type:"diagram",baseDir:"docs",filePatterns:["*.md","*.mmd","*.d2","*.puml"],description:"Architecture or data diagram"}};function Pe(r,e){if(r&&r!=="auto")return r;let t=e.toLowerCase(),o=[[/\b(component|button|card|modal|dialog|form|input|dropdown|nav|sidebar|header|footer|widget|ui)\b/i,"component"],[/\b(page|screen|view|route|layout|dashboard|landing)\b/i,"page"],[/\b(api|endpoint|route handler|rest|graphql|webhook|middleware|server)\b/i,"api"],[/\b(website|site|web app|landing page|portfolio|blog)\b/i,"website"],[/\b(document|doc|readme|guide|tutorial|specification|spec|changelog)\b/i,"document"],[/\b(script|cli|command|tool|utility|migration|seed|cron)\b/i,"script"],[/\b(config|configuration|setup|env|settings)\b/i,"config"],[/\b(skill|agent skill|skill\.md)\b/i,"skill"],[/\b(video|audio|image|media|animation|thumbnail|podcast)\b/i,"media"],[/\b(report|audit|analysis|review|assessment|benchmark)\b/i,"report"],[/\b(test|spec|unit test|integration test|e2e|coverage|fixture|mock)\b/i,"test"],[/\b(workflow|ci|cd|pipeline|github action|deploy|automation|ci\/cd)\b/i,"workflow"],[/\b(schema|model|migration|prisma|drizzle|zod|validator|graphql type)\b/i,"schema"],[/\b(email|newsletter|transactional|invite|welcome email|notification email)\b/i,"email"],[/\b(diagram|erd|flowchart|architecture diagram|sequence diagram|mermaid|plantuml|d2)\b/i,"diagram"]];for(let[n,s]of o)if(n.test(t))return s;return"component"}import{existsSync as It,promises as ot}from"fs";import ue from"path";import{execa as Ct}from"execa";import{z as N}from"zod";var ee=["pre:generate","post:generate","pre:file-write","post:file-write","pre:prompt","post:response","pre:command","on:error","pre:tool-call","post:tool-call","pre:channel-message","post:channel-message","pre:a2a-task","pre:cron-run","post:cron-run","on:gitlab-pipeline","on:gitlab-issue","on:gitlab-mr","on:gitlab-note","on:github-issue","on:github-pr","on:github-push","on:n8n","on:stripe-event","on:sentry-issue","on:vercel-deployment","on:odoo-event","on:hubspot-event"],Re=["pre:generate","pre:file-write","pre:prompt","post:response","pre:command","pre:tool-call","pre:channel-message","post:channel-message","pre:a2a-task","pre:cron-run"],Xe=N.object({name:N.string(),type:N.enum(["command","prompt","script"]),command:N.string().optional(),prompt:N.string().optional(),provider:N.enum(["claude-code","claude","openai","deepseek","ollama","custom"]).optional(),model:N.string().optional(),script:N.string().optional(),priority:N.number().default(100),enabled:N.boolean().default(!0)});ye();var Qe={"claude-sonnet":{input:3,output:15},"claude-opus":{input:15,output:75},"claude-haiku":{input:.25,output:1.25}};function St(r){let e=r.toLowerCase();return e.includes("opus")?"claude-opus":e.includes("haiku")?"claude-haiku":"claude-sonnet"}var le=class{steps=[];models=new Map;recordStep(e,t,o,n){let s=St(t),i=Qe[s]||Qe["claude-sonnet"],c=o/1e6*i.input+n/1e6*i.output;this.steps.push({step:e,model:t,inputTokens:o,outputTokens:n,cost:c,timestamp:Date.now()});let a=this.models.get(t)||{inputTokens:0,outputTokens:0,cost:0,steps:0};a.inputTokens+=o,a.outputTokens+=n,a.cost+=c,a.steps++,this.models.set(t,a)}getSummary(){let e=0,t=0,o=0;for(let s of this.steps)e+=s.inputTokens,t+=s.outputTokens,o+=s.cost;let n={};for(let[s,i]of this.models)n[s]={...i};return{totalInputTokens:e,totalOutputTokens:t,totalTokens:e+t,totalCost:o,steps:[...this.steps],models:n}}reset(){this.steps=[],this.models.clear()}},te=new le;function Tt(r,e){let t=[];if(t.push(`# Session: ${r.id}`),t.push(""),t.push(`- **Created**: ${r.createdAt}`),t.push(`- **Updated**: ${r.updatedAt}`),t.push(`- **CWD**: ${r.cwd}`),t.push(`- **Messages**: ${r.messages.length}`),t.push(`- **Tokens**: ${r.tokensUsed.toLocaleString()}`),t.push(""),r.filesGenerated.length){t.push("## Files Generated"),t.push("");for(let o of r.filesGenerated)t.push(`- \`${o}\``);t.push("")}if(r.messages.length){t.push("## Conversation"),t.push("");for(let o of r.messages){if(o.role==="system")continue;let n=o.role==="user"?"**User**":"**Assistant**";t.push(`### ${n}`),t.push(""),o.role,t.push(o.content),t.push("")}}if(e){if(t.push("## Cost Summary"),t.push(""),t.push(`- **Total tokens**: ${e.totalTokens.toLocaleString()}`),t.push(` - Input: ${e.totalInputTokens.toLocaleString()}`),t.push(` - Output: ${e.totalOutputTokens.toLocaleString()}`),t.push(`- **Total cost**: $${e.totalCost.toFixed(4)}`),t.push(""),Object.keys(e.models).length){t.push("### Per Model"),t.push(""),t.push("| Model | Input | Output | Cost | Steps |"),t.push("|-------|-------|--------|------|-------|");for(let[o,n]of Object.entries(e.models))t.push(`| ${o} | ${n.inputTokens.toLocaleString()} | ${n.outputTokens.toLocaleString()} | $${n.cost.toFixed(4)} | ${n.steps} |`);t.push("")}if(e.steps.length){t.push("### Per Step"),t.push(""),t.push("| Step | Model | Input | Output | Cost |"),t.push("|------|-------|-------|--------|------|");for(let o of e.steps)t.push(`| ${o.step} | ${o.model} | ${o.inputTokens.toLocaleString()} | ${o.outputTokens.toLocaleString()} | $${o.cost.toFixed(4)} |`);t.push("")}}return t.join(`
|
|
21
|
+
`)}ke();var oe=class{hooks=new Map;register(e,t){if(!t.enabled)return;let o=this.createHandler(t),n={event:e,definition:t,handler:o},s=this.hooks.get(e)||[];s.push(n),s.sort((i,c)=>i.definition.priority-c.definition.priority),this.hooks.set(e,s)}async execute(e,t){let o=this.hooks.get(e);if(!o?.length)return{};let n=Re.includes(e),s={};for(let i of o){let c=Date.now();try{let a=await i.handler({...t,...s}),p=Date.now()-c;if(a.modified&&(s={...s,...a.modified}),n&&a.blocked)return b.hook(i.definition.name,p,"blocked"),{blocked:!0,message:a.message||`Blocked by hook: ${i.definition.name}`,modified:s};b.hook(i.definition.name,p,"ok")}catch(a){let p=Date.now()-c;if(b.hook(i.definition.name,p,`error: ${a.message}`),R.warn(`Hook "${i.definition.name}" failed: ${a.message}`),n)return{blocked:!0,message:`Hook "${i.definition.name}" errored: ${a.message}`}}}return{modified:Object.keys(s).length?s:void 0}}registerHandler(e,t,o,n=100){let i={event:e,definition:{name:t,type:"script",priority:n,enabled:!0},handler:o},c=this.hooks.get(e)||[];c.push(i),c.sort((a,p)=>a.definition.priority-p.definition.priority),this.hooks.set(e,c)}has(e){return!!this.hooks.get(e)?.length}clear(){this.hooks.clear()}size(){let e=0;for(let t of this.hooks.values())e+=t.length;return e}createHandler(e){switch(e.type){case"command":return this.createCommandHandler(e);case"script":return this.createScriptHandler(e);case"prompt":return this.createPromptHandler(e);default:throw new Error(`Unknown hook type: ${e.type}`)}}createCommandHandler(e){return async t=>{if(!e.command)return{};let o=e.command;o=o.replace(/\{\{(\w+)\}\}/g,(s,i)=>String(t[i]??""));let n=await Ct("sh",["-c",o],{cwd:t.cwd||process.cwd(),reject:!1,timeout:6e4,env:process.env});return n.exitCode!==0?{blocked:!0,message:n.stderr||n.stdout||`Command hook "${e.name}" failed`}:{}}}createScriptHandler(e){return async t=>{if(!e.script)return{};let n=await import(e.script.startsWith("/")?e.script:`${t.cwd||process.cwd()}/${e.script}`),s=n.default||n.handler||n;return typeof s=="function"?await s(t):{}}}createPromptHandler(e){return async t=>{if(!e.prompt)return{};let o=e.provider||Q()?.provider||"claude-code",n=Ne();if(!n&&o!=="claude-code")return R.warn(`Prompt hook "${e.name}" skipped: no credentials available for provider "${o}"`),{};try{let{createProvider:s}=await import("./providers-KO2DODIO.js"),i=s(o,n?.token),c=e.prompt;c=c.replace(/\{\{(\w+)\}\}/g,(m,I)=>String(t[I]??""));let a=`You are a hook validator for agentx. Analyze the following context and respond with ONLY a JSON object (no markdown, no code fences).
|
|
22
|
+
|
|
23
|
+
Response format:
|
|
24
|
+
{"action": "allow", "message": "optional explanation"}
|
|
25
|
+
OR
|
|
26
|
+
{"action": "block", "message": "reason for blocking"}
|
|
27
|
+
OR
|
|
28
|
+
{"action": "allow", "message": "optional", "modified": {"key": "new value"}}
|
|
29
|
+
|
|
30
|
+
The "modified" field is optional and can contain updated values to pass forward.`,d=(await i.generate([{role:"system",content:a},{role:"user",content:c}],{model:e.model,maxTokens:1024})).content.trim().match(/\{[\s\S]*\}/);if(!d)return R.warn(`Prompt hook "${e.name}": LLM response was not valid JSON, allowing`),{};let u=JSON.parse(d[0]);return u.action==="block"?{blocked:!0,message:u.message||`Blocked by prompt hook: ${e.name}`}:u.modified?{modified:u.modified}:{}}catch(s){return R.warn(`Prompt hook "${e.name}" failed: ${s.message}`),{}}}}};import{existsSync as Ze,readFileSync as Pt,readdirSync as Rt}from"fs";import pe from"path";ye();function Mt(r,e){$t(r,e),Et(r,e)}function $t(r,e){let t=pe.join(r,"agentx.config.json");if(Ze(t))try{let o=JSON.parse(Pt(t,"utf8"));if(!o.hooks)return;for(let[n,s]of Object.entries(o.hooks)){if(!ee.includes(n)){R.warn(`Unknown hook event in config: ${n}`);continue}let i=n;if(Array.isArray(s))for(let c of s)try{let a=Xe.parse(c);e.register(i,a)}catch(a){R.warn(`Invalid hook definition for ${i}: ${a.message}`)}}}catch(o){R.warn(`Failed to load hooks from config: ${o.message}`)}}function Et(r,e){let t=pe.join(r,".agentx","hooks");if(Ze(t))try{let o=Rt(t).filter(n=>n.endsWith(".ts")||n.endsWith(".js")||n.endsWith(".mjs"));for(let n of o){let s=n.replace(/\.(ts|js|mjs)$/,"").split(".");if(s.length<2){R.warn(`Hook file "${n}" should be named <event>.<name>.<ext>`);continue}let i=s[0],c=s.slice(1).join("."),a=i.replace(/-/g,":");if(!ee.includes(a)){let p=i.replace("-",":");if(!ee.includes(p)){R.warn(`Unknown hook event in filename: ${n}`);continue}e.register(p,{name:c,type:"script",script:pe.join(t,n),priority:100,enabled:!0});continue}e.register(a,{name:c,type:"script",script:pe.join(t,n),priority:100,enabled:!0})}}catch(o){R.warn(`Failed to load hooks from directory: ${o.message}`)}}var f=new oe;import At from"prompts";import Ot from"chalk";import{z as q}from"zod";var et=["default","acceptEdits","plan","yolo"],tt=q.enum(et),Me=q.object({mode:tt.default("default"),allow:q.array(q.string()).default([]),deny:q.array(q.string()).default([]),confirm:q.array(q.string()).default([])});function jt(r,e){let t=e.replace(/\./g,"\\.").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{GLOBSTAR\}\}/g,".*").replace(/\?/g,"[^/]");return new RegExp(`^${t}$`).test(r)}var de=class{mode;allowPatterns;denyPatterns;confirmPatterns;autoAllowAll=!1;constructor(e){let t=Me.parse(e||{});this.mode=t.mode,this.allowPatterns=t.allow,this.denyPatterns=t.deny,this.confirmPatterns=t.confirm}getMode(){return this.mode}setMode(e){this.mode=e,this.autoAllowAll=!1,b.context("permissions",`mode set to ${e}`)}async checkFileWrite(e){if(b.context("permissions",`checking write: ${e} (mode: ${this.mode})`),this.matchesAny(e,this.denyPatterns))return b.context("permissions",`denied by pattern: ${e}`),"deny";switch(this.mode){case"yolo":return"allow";case"plan":return"skip";case"acceptEdits":return"allow";case"default":return this.autoAllowAll||this.matchesAny(e,this.allowPatterns)?"allow":this.promptUser(e);default:return"allow"}}async checkCommand(e){return this.mode==="yolo"?"allow":this.mode==="plan"?"deny":"allow"}matchesAny(e,t){return t.some(o=>jt(e,o))}async promptUser(e){let{action:t}=await At({type:"select",name:"action",message:`Write file ${Ot.cyan(e)}?`,choices:[{title:"Yes",value:"allow"},{title:"No",value:"deny"},{title:"All (allow remaining)",value:"all"},{title:"Skip",value:"skip"}],initial:0});return t==="all"?(this.autoAllowAll=!0,"allow"):t||"deny"}},W=new de;async function me(r,e){let t={written:[],skipped:[],errors:[]};for(let o of r){let n=ue.isAbsolute(o.path)?o.path:ue.resolve(e.cwd,e.outputDir||"",o.path);try{let s=o.content;if(f.has("pre:file-write")){let p=await f.execute("pre:file-write",{event:"pre:file-write",file:n,fileContent:s,cwd:e.cwd});if(p.blocked){t.skipped.push(n);continue}p.modified?.fileContent&&(s=String(p.modified.fileContent))}let i=ue.relative(e.cwd,n),c=await W.checkFileWrite(i);if(c==="deny"){t.skipped.push(n);continue}if(c==="skip"){t.written.push(n);continue}if(It(n)&&!e.overwrite){t.skipped.push(n);continue}if(e.dryRun){t.written.push(n);continue}let a=ue.dirname(n);await ot.mkdir(a,{recursive:!0}),await ot.writeFile(n,s,"utf8"),t.written.push(n),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:n,fileContent:s,cwd:e.cwd})}catch(s){t.errors.push(`${n}: ${s.message}`)}}return t}function fe(r,e,t){if(t)return t;let o=Ye[r];if(!o)return"generated";let n=o.baseDir;return r==="component"&&(e.srcDir?n=`${e.srcDir}/components`:n="components"),r==="page"&&e.frameworks.find(i=>i.name==="nextjs")&&e.srcDir&&(n=`${e.srcDir}/app`),r==="api"&&e.frameworks.find(i=>i.name==="nextjs")&&(n=e.srcDir?`${e.srcDir}/app/api`:"app/api"),r==="test"&&(e.testing.includes("vitest")||e.testing.includes("jest"))&&(n=e.srcDir||"src"),r==="workflow"&&(n=".github/workflows"),r==="schema"&&(e.databases.includes("prisma")?n="prisma":e.srcDir&&(n=`${e.srcDir}/schemas`)),r==="email"&&(n=e.srcDir?`${e.srcDir}/emails`:"emails"),n}ye();import Ut from"os";var Ht=Ut.homedir(),ne=class{constructor(e){this.cwd=e;this.userMemory=new Se(Ht),this.projectMemory=new Se(e)}userMemory;projectMemory;async load(){await Promise.all([this.userMemory.load(),this.projectMemory.load()])}async save(){await Promise.all([this.userMemory.save(),this.projectMemory.save()])}buildMemoryContext(e){let t=this.userMemory.buildMemoryContext(e),o=this.projectMemory.buildMemoryContext(e);if(!t&&!o)return"";let n=[];return o&&n.push(o),t&&n.push(t.replace("# Memory (learned from past interactions)","# Global Memory (cross-project patterns)")),n.join(`
|
|
31
|
+
|
|
32
|
+
`)}async learnPreference(e,t,o){await this.userMemory.learnPreference(e,t,o)}async recordGeneration(e){return this.projectMemory.recordGeneration(e)}getPreferences(){let e=this.userMemory.getPreferences(),t=this.projectMemory.getPreferences(),o=new Map;for(let n of e)o.set(n.key,n);for(let n of t)o.set(n.key,n);return Array.from(o.values())}getPatterns(){let e=this.userMemory.getPatterns();return[...this.projectMemory.getPatterns(),...e]}getStats(){return{user:this.userMemory.getStats(),project:this.projectMemory.getStats()}}getRecentGenerations(e=10){return this.projectMemory.getRecentGenerations(e)}};import{existsSync as nt,readFileSync as rt}from"fs";import st from"path";function it(r,e){return r.replace(/@([\w./-]+)/g,(t,o)=>{let n=st.resolve(e,o);if(nt(n))try{return rt(n,"utf8")}catch{return t}return t})}function Ee(r){let e=["SHADXN.md","CLAUDE.md"];for(let t of e){let o=st.join(r,t);if(nt(o))try{let n=rt(o,"utf8");return n=it(n,r),n}catch{}}return""}function Dt(r){return Math.ceil(r.length/4)}var $e=class{sections=[];addSection(e,t,o=50){t.trim()&&this.sections.push({label:e,content:t,priority:o})}buildContext(e,t=12e3){if(this.sections.length===0)return"";let o=this.sections.map(l=>l.content),n=Te(o),s=Ce(e,n),i=new Map(s.map(l=>[l.docIndex,l.score])),c=this.sections.map((l,d)=>({...l,relevance:i.get(d)??0,tokens:Dt(l.content)}));c.sort((l,d)=>d.priority+d.relevance*100-(l.priority+l.relevance*100));let a=[],p=0;for(let l of c)p+l.tokens>t&&a.length>0||(a.push(l),p+=l.tokens);return a.map(l=>l.content).join(`
|
|
33
|
+
|
|
34
|
+
`)}};gt();import{promises as re}from"fs";import ge from"path";import{execa as Gt}from"execa";import pt from"fast-glob";var Nt=["list_projects","get_project","create_task","update_task","add_deliverable","list_attachments","get_credit_balance"],at=[{name:"list_projects",description:"List the example.com user's active projects with per-project task counts. Use when the user asks 'what am I working on' or wants a project overview.",input_schema:{type:"object",properties:{},additionalProperties:!1},permission:"none"},{name:"get_project",description:"Get a single project with its tasks and recent conversations. Use after list_projects when the user picks one.",input_schema:{type:"object",properties:{project_id:{type:"string",description:"Project UUID from list_projects."}},required:["project_id"],additionalProperties:!1},permission:"none"},{name:"create_task",description:"Queue a new task for the user. Use when they ask you to build, fix, or work on something. CONFIRM the summary verbally first.",input_schema:{type:"object",properties:{summary:{type:"string",description:"Short task description (one sentence)."},project_id:{type:"string",description:"Optional \u2014 bind to a project."},conversation_id:{type:"string",description:"Optional \u2014 bind to the on-site conversation id (from [Context])."}},required:["summary"],additionalProperties:!1},permission:"none"},{name:"update_task",description:"Update a task's state (mark completed, cancel, record hours, write a result_summary). Status: queued|active|completed|cancelled.",input_schema:{type:"object",properties:{task_id:{type:"string"},status:{type:"string",enum:["queued","active","completed","cancelled"]},summary:{type:"string"},result_summary:{type:"string"},hours_spent:{type:"number"}},required:["task_id"],additionalProperties:!1},permission:"none"},{name:"add_deliverable",description:"Record a shipped artefact against a task (repo URL, preview URL, design file, document, etc.). type: repo|preview|design|artifact|document|screenshot|figma|spreadsheet|presentation|video|audio|image|other.",input_schema:{type:"object",properties:{task_id:{type:"string"},type:{type:"string",enum:["repo","preview","design","artifact","document","screenshot","figma","spreadsheet","presentation","video","audio","image","other"]},label:{type:"string",description:"Human label, e.g. 'Staging \u2014 workspace v2'."},url:{type:"string",description:"Public URL of the artefact."},file_size:{type:"number"}},required:["task_id","type","label","url"],additionalProperties:!1},permission:"none"},{name:"list_attachments",description:"List files the user has uploaded to the workspace. Filter by project_id and/or task_id.",input_schema:{type:"object",properties:{project_id:{type:"string"},task_id:{type:"string"}},additionalProperties:!1},permission:"none"},{name:"get_credit_balance",description:"Get the user's live credit balance and 7-day burn rate. Use when the user asks 'how much do I have left' or before starting a big task.",input_schema:{type:"object",properties:{},additionalProperties:!1},permission:"none"}];async function ct(r,e,t){let o=process.env.ACME_AGENT_TOOLS_SECRET||process.env.AGENTX_TOOLS_SECRET||process.env.TELEGRAM_BOT_API_SECRET;if(!o)return{content:JSON.stringify({ok:!1,error:"ACME_AGENT_TOOLS_SECRET not set on this host"}),is_error:!0};let s=`${(t.apiUrl||process.env.ACME_API_URL||"https://example.com").replace(/\/$/,"")}/api/agent/tools`,i={tool:r,user_id:t.userId,...e||{}},c=Number(process.env.ACME_TOOL_TIMEOUT_MS||3e4),a=new AbortController,p=setTimeout(()=>a.abort(),c);try{let l=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,"X-Agent-Id":t.agentId||"acme-public"},body:JSON.stringify(i),signal:a.signal}),d=await l.text(),u=4*1024,m=d.length>u?d.slice(0,u)+"\u2026(truncated)":d;return l.ok?{content:m,is_error:!1}:{content:m,is_error:!0}}catch(l){let d=l?.name==="AbortError";return{content:JSON.stringify({ok:!1,error:d?`acme tool RPC timed out after ${c}ms`:"acme tool RPC failed",detail:l?.message||"unknown"}),is_error:!0}}finally{clearTimeout(p)}}function lt(r){return Nt.includes(r)}var se=class{cwd;options;constructor(e,t={}){this.cwd=e,this.options=t}async execute(e){if(b.context("tool-executor",`executing: ${e.name}`),this.options.abortSignal?.aborted)return{tool_use_id:e.id,content:"Task cancelled before tool dispatch.",is_error:!0};if(f.has("pre:tool-call")){let o=await f.execute("pre:tool-call",{event:"pre:tool-call",toolName:e.name,toolInput:e.input,cwd:this.cwd});if(o.blocked)return{tool_use_id:e.id,content:o.message||`Tool ${e.name} blocked by pre:tool-call hook`,is_error:!0}}let t;try{if(this.options.acmeContext&<(e.name)){let o=await ct(e.name,e.input,this.options.acmeContext);t={tool_use_id:e.id,content:o.content,is_error:o.is_error}}else switch(e.name){case"read_file":t=await this.readFile(e);break;case"search_files":t=await this.searchFiles(e);break;case"list_directory":t=await this.listDirectory(e);break;case"run_command":t=await this.runCommand(e);break;case"edit_file":t=await this.editFile(e);break;case"create_files":t=await this.createFiles(e);break;case"ask_user":t=await this.askUser(e);break;case"spawn_agent":t=await this.spawnAgent(e);break;default:t={tool_use_id:e.id,content:`Unknown tool: ${e.name}`,is_error:!0}}}catch(o){t={tool_use_id:e.id,content:`Error executing ${e.name}: ${o.message}`,is_error:!0}}return f.has("post:tool-call")&&await f.execute("post:tool-call",{event:"post:tool-call",toolName:e.name,toolInput:e.input,toolResult:t.content,cwd:this.cwd}),t}async readFile(e){let t=String(e.input.path||""),o=Number(e.input.max_lines)||500,n=ge.resolve(this.cwd,t),s=await re.readFile(n,"utf8"),i=s.split(`
|
|
35
|
+
`),a=i.length>o?i.slice(0,o).join(`
|
|
36
|
+
`)+`
|
|
37
|
+
|
|
38
|
+
... (truncated, ${i.length-o} more lines)`:s;return{tool_use_id:e.id,content:a}}async searchFiles(e){let t=String(e.input.pattern||"**/*"),o=e.input.content_regex?String(e.input.content_regex):void 0,n=Number(e.input.max_results)||50,s=await pt(t,{cwd:this.cwd,ignore:["node_modules/**",".git/**","dist/**",".next/**"],dot:!1});if(!o){let a=s.slice(0,n);return{tool_use_id:e.id,content:a.length?a.join(`
|
|
39
|
+
`)+(s.length>n?`
|
|
40
|
+
|
|
41
|
+
... (${s.length-n} more files)`:""):"No files matched the pattern."}}let i=new RegExp(o,"gm"),c=[];for(let a of s){if(c.length>=n)break;try{let l=(await re.readFile(ge.resolve(this.cwd,a),"utf8")).split(`
|
|
42
|
+
`);for(let d=0;d<l.length&&!(c.length>=n);d++)i.test(l[d])&&c.push(`${a}:${d+1}: ${l[d]}`),i.lastIndex=0}catch{}}return{tool_use_id:e.id,content:c.length?c.join(`
|
|
43
|
+
`):"No matches found."}}async listDirectory(e){let t=String(e.input.path||"."),o=!!e.input.recursive,n=Number(e.input.max_depth)||3,s=ge.resolve(this.cwd,t);if(o){let p=await pt("**/*",{cwd:s,onlyFiles:!1,markDirectories:!0,deep:n,ignore:["node_modules/**",".git/**","dist/**",".next/**"]});return{tool_use_id:e.id,content:p.length?p.join(`
|
|
44
|
+
`):"Empty directory."}}let c=(await re.readdir(s,{withFileTypes:!0})).map(a=>a.isDirectory()?`${a.name}/`:a.name);return{tool_use_id:e.id,content:c.length?c.join(`
|
|
45
|
+
`):"Empty directory."}}async runCommand(e){let t=String(e.input.command||""),o=Number(e.input.timeout)||3e4;if(await W.checkCommand(t)==="deny")return{tool_use_id:e.id,content:`Command blocked by permissions (mode: ${W.getMode()}): ${t}`,is_error:!0};if(f.has("pre:command")){let a=await f.execute("pre:command",{event:"pre:command",command:t,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`Command blocked by pre:command hook: ${t}`,is_error:!0}}let s=await Gt("sh",["-c",t],{cwd:this.cwd,timeout:o,reject:!1,stdin:"ignore",signal:this.options.abortSignal}),i=[s.stdout,s.stderr].filter(Boolean).join(`
|
|
46
|
+
`),c=i.length>1e4?i.slice(0,1e4)+`
|
|
47
|
+
|
|
48
|
+
... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
|
|
49
|
+
${c}`,is_error:!0}:{tool_use_id:e.id,content:c||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,n=ge.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await W.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(f.has("pre:file-write")){let a=await f.execute("pre:file-write",{event:"pre:file-write",file:n,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await re.readFile(n,"utf8"),c=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),c.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):c.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await re.writeFile(n,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:n,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
|
|
50
|
+
${c.join(`
|
|
51
|
+
`)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-2SJHSSJS.js"),{getGlobalRegistry:i}=await import("./registry-LE6FWYZC.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
|
|
52
|
+
|
|
53
|
+
${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,n=t;return o?.length&&(n+=`
|
|
54
|
+
Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:n}}};async function Ae(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,cwd:s,maxIterations:i=20,enabledTools:c,interactive:a=!0,overwrite:p=!1,dryRun:l=!1,onProgress:d,abortSignal:u}=r,m=u?{...n,abortSignal:u}:n;if(!e.generateRaw)return dt(r);let I=new se(s,{interactive:a,overwrite:p,dryRun:l,acmeContext:r.acmeContext,abortSignal:u}),D=be(c);if(r.acmeContext)for(let g of at)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(r.mcpTools?.length)for(let g of r.mcpTools)D.push({name:g.name,description:g.description,input_schema:g.input_schema}),E.add(g.name);let C=o.filter(g=>g.role!=="system").map(g=>({role:g.role,content:g.content})),B=[],G=0,F=0,A=0,O="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),b.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let T=null,U=null,v="";for await(let x of e.generateRawStream(C,t,D,m))x.type==="text_delta"?(v+=x.text,d?.({type:"text_delta",text:x.text})):x.type==="thinking_delta"?d?.({type:"thinking_delta",text:x.text}):x.type==="raw_result"?T=x.result:x.type==="error"&&(U=x.error);if(U&&!T)throw new Error(U);if(!T)throw new Error("generateRawStream returned no raw_result event");g=T,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(T){if(T.message?.includes("not available"))return dt(r);throw T}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,A+=g.usage.output_tokens;let P=g._streamedText;for(let T of g.content)T.type==="text"&&(O+=T.text,P===void 0&&d?.({type:"text_delta",text:T.text}));if(P!==void 0&&delete g._streamedText,g.stop_reason==="end_turn"||g.stop_reason==="max_tokens")break;if(g.stop_reason==="tool_use"){let T=g.content.filter(v=>v.type==="tool_use");if(T.length===0)break;C.push({role:"assistant",content:g.content});let U=[];for(let v of T){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),b.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&r.mcpDispatch){let h=await r.mcpDispatch(v.name,v.input);x={tool_use_id:v.id,content:h.content,is_error:h.isError}}else x=await I.execute({name:v.name,id:v.id,input:v.input});d?.({type:"tool_result",name:v.name,id:v.id,content:x.content.slice(0,200),is_error:x.is_error}),x.files?.length&&(B.push(...x.files),d?.({type:"files_created",files:x.files})),x.followUp&&(j=x.followUp),U.push({type:"tool_result",tool_use_id:x.tool_use_id,content:x.content,is_error:x.is_error})}if(C.push({role:"user",content:U}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:O,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:A||void 0,iterations:_}}async function dt(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,maxIterations:s=5}=r,c=[{role:"system",content:t+`
|
|
55
|
+
|
|
56
|
+
`+xe()},...o.filter(m=>m.role!=="system")],a=[],p=0,l="",d,u=0;for(;u<s;){u++,b.step(u,`Legacy loop step (model: ${n.model||"default"})`);let m=await e.generate(c,n);if(p+=m.tokensUsed||0,l=m.content,m.files.length&&a.push(...m.files),m.followUp){d=m.followUp;break}if(m.files.length===0&&u>1||!(m.content.includes("[CONTINUE]")||m.content.includes("Next, I'll")||m.content.includes("Now let me")||m.content.includes("I'll also generate")))break;let D=m.files.map(E=>`Created: ${E.path}${E.description?` \u2014 ${E.description}`:""}`).join(`
|
|
57
|
+
`);c.push({role:"assistant",content:m.content+(D?`
|
|
58
|
+
|
|
59
|
+
Files created:
|
|
60
|
+
${D}`:"")}),c.push({role:"user",content:"Continue generating the remaining files. Build on what you've already created. When finished, do not include [CONTINUE] in your response."})}return{files:a,content:l,followUp:d,tokensUsed:p,iterations:u}}function Oe(r){return typeof r.generateRaw=="function"}import{spawn as Ft}from"child_process";var Lt="2024-11-05",ut=15e3,qt=12e4,Bt="mcp__";function Wt(r){return r.type==="http"}var je=class{constructor(e,t){this.name=e;this.proc=Ft(t.command,t.args??[],{stdio:["pipe","pipe","pipe"],env:{...process.env,...t.env??{}}}),this.proc.stdout.setEncoding("utf-8"),this.proc.stdout.on("data",o=>this.onData(o)),this.proc.stderr.setEncoding("utf-8"),this.proc.stderr.on("data",o=>b.context("mcp",`${e} stderr: ${o.trimEnd()}`)),this.proc.on("exit",o=>{this.closed=!0,b.context("mcp",`${e}: exited (code=${o})`);for(let[,n]of this.pending)clearTimeout(n.timer),n.reject(new Error(`mcp server "${e}" exited`));this.pending.clear()}),this.proc.on("error",o=>{b.context("mcp",`${e}: spawn error: ${o.message}`)})}proc;buffer="";nextId=1;pending=new Map;closed=!1;request(e,t,o){if(this.closed)return Promise.reject(new Error(`mcp server "${this.name}" is closed`));let n=this.nextId++,s=JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:t})+`
|
|
61
|
+
`;return new Promise((i,c)=>{let a=setTimeout(()=>{this.pending.delete(n),c(new Error(`mcp "${this.name}" ${e} timeout after ${o}ms`))},o);this.pending.set(n,{resolve:i,reject:c,timer:a});try{this.proc.stdin.write(s)}catch(p){clearTimeout(a),this.pending.delete(n),c(new Error(`mcp "${this.name}" write failed: ${p.message}`))}})}notify(e,t){if(this.closed)return;let o=JSON.stringify({jsonrpc:"2.0",method:e,params:t??{}})+`
|
|
62
|
+
`;try{this.proc.stdin.write(o)}catch{}}close(){if(!this.closed){this.closed=!0;try{this.proc.kill("SIGTERM")}catch{}}}onData(e){for(this.buffer+=e;;){let t=this.buffer.indexOf(`
|
|
63
|
+
`);if(t<0)break;let o=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!o)continue;let n;try{n=JSON.parse(o)}catch(s){b.context("mcp",`${this.name}: parse error: ${s.message} (line: ${o.slice(0,200)})`);continue}if(typeof n.id=="number"&&this.pending.has(n.id)){let s=this.pending.get(n.id);this.pending.delete(n.id),clearTimeout(s.timer),n.error?s.reject(new Error(`${n.error.code}: ${n.error.message}`)):s.resolve(n.result)}}}},Ie=class{constructor(e,t){this.name=e;this.spec=t}nextId=1;sessionId=null;closed=!1;async request(e,t,o){if(this.closed)throw new Error(`mcp server "${this.name}" is closed`);let n=this.nextId++,s=JSON.stringify({jsonrpc:"2.0",id:n,method:e,params:t}),i={"Content-Type":"application/json",Accept:"application/json, text/event-stream",...this.spec.headers??{}};this.sessionId&&(i["Mcp-Session-Id"]=this.sessionId);let c=new AbortController,a=setTimeout(()=>c.abort(new Error(`timeout after ${o}ms`)),o);a.unref?.();let p;try{p=await fetch(this.spec.url,{method:"POST",headers:i,body:s,signal:c.signal})}catch(m){throw clearTimeout(a),m?.name==="AbortError"?new Error(`mcp "${this.name}" ${e} timeout after ${o}ms`):new Error(`mcp "${this.name}" ${e} fetch failed: ${m?.message??m}`)}let l=p.headers.get("mcp-session-id");if(l&&(this.sessionId=l),!p.ok){clearTimeout(a);let m=await p.text().catch(()=>"");throw new Error(`mcp "${this.name}" HTTP ${p.status}: ${m.slice(0,300)}`)}let d=(p.headers.get("content-type")||"").toLowerCase(),u;try{d.includes("text/event-stream")?u=await zt(p,n):u=await p.json()}catch(m){throw clearTimeout(a),new Error(`mcp "${this.name}" ${e} response parse failed: ${m?.message??m}`)}finally{clearTimeout(a)}if(!u||typeof u!="object")throw new Error(`mcp "${this.name}" ${e} returned non-object body`);if(u.error)throw new Error(`${u.error.code}: ${u.error.message}`);return u.result}notify(e,t){if(this.closed)return;let o={"Content-Type":"application/json",Accept:"application/json, text/event-stream",...this.spec.headers??{}};this.sessionId&&(o["Mcp-Session-Id"]=this.sessionId),fetch(this.spec.url,{method:"POST",headers:o,body:JSON.stringify({jsonrpc:"2.0",method:e,params:t??{}})}).catch(n=>{b.context("mcp",`${this.name}: notify ${e} failed: ${n?.message??n}`)})}close(){if(!this.closed&&(this.closed=!0,this.sessionId)){let e={"Mcp-Session-Id":this.sessionId,...this.spec.headers??{}};fetch(this.spec.url,{method:"DELETE",headers:e}).catch(()=>{})}}};async function zt(r,e){let t=r.body?.getReader();if(!t)throw new Error("SSE response had no body");let o=new TextDecoder,n="";try{for(;;){let{done:s,value:i}=await t.read();if(s)break;n+=o.decode(i,{stream:!0});let c;for(;(c=n.indexOf(`
|
|
64
|
+
|
|
65
|
+
`))>=0;){let a=n.slice(0,c);n=n.slice(c+2);let p=[];for(let u of a.split(`
|
|
66
|
+
`)){let m=u.replace(/\r$/,"");m.startsWith("data:")&&p.push(m.slice(5).trim())}if(!p.length)continue;let l=p.join(`
|
|
67
|
+
`);if(!l||l==="[DONE]")continue;let d;try{d=JSON.parse(l)}catch{continue}if(d&&d.id===e)return d}}}finally{try{t.cancel().catch(()=>{})}catch{}}throw new Error(`SSE stream ended without a response for id=${e}`)}var Ue=class{constructor(e,t){this.name=e;this.transport=Wt(t)?new Ie(e,t):new je(e,t)}transport;async initialize(){await this.transport.request("initialize",{protocolVersion:Lt,capabilities:{},clientInfo:{name:"agentx-orchestrator",version:"0.1.0"}},ut),this.transport.notify("notifications/initialized")}async listTools(){return((await this.transport.request("tools/list",{},ut)).tools??[]).map(t=>({name:t.name,description:t.description??"",input_schema:t.inputSchema??{type:"object",properties:{}}}))}async callTool(e,t){let o=await this.transport.request("tools/call",{name:e,arguments:t??{}},qt),n=[];for(let s of o.content??[])s?.type==="text"&&typeof s.text=="string"?n.push(s.text):n.push(JSON.stringify(s));return{content:n.join(`
|
|
68
|
+
`)||"(no output)",isError:o.isError}}close(){this.transport.close()}};async function He(r){let e=new Map,t=[],o=new Map;for(let[n,s]of Object.entries(r)){let i=new Ue(n,s);try{await i.initialize();let c=await i.listTools();for(let a of c){let p=`${Bt}${n}__${a.name}`;t.push({name:p,description:a.description||`${n}.${a.name}`,input_schema:a.input_schema}),o.set(p,{client:i,remote:a.name})}e.set(n,i)}catch(c){b.context("mcp",`${n}: skipped \u2014 ${c.message}`),i.close()}}return{tools:t,async dispatch(n,s){let i=o.get(n);if(!i)return{content:`Unknown MCP tool: ${n}`,isError:!0};try{return await i.client.callTool(i.remote,s)}catch(c){return{content:`MCP call failed: ${c.message}`,isError:!0}}},close(){for(let n of e.values())n.close()}}}var he=class{queue=[];resolvers=[];closed=!1;push(e){if(this.closed)return;let t=this.resolvers.shift();if(t){t({value:e,done:!1});return}this.queue.push(e)}close(){if(!this.closed){this.closed=!0;for(let e of this.resolvers.splice(0))e({value:void 0,done:!0})}}async next(){return this.queue.length?{value:this.queue.shift(),done:!1}:this.closed?{value:void 0,done:!0}:new Promise(e=>{this.resolvers.push(e)})}async*[Symbol.asyncIterator](){for(;;){let{value:e,done:t}=await this.next();if(t)return;yield e}}};async function mt(r,e,t){let o=qe.parse(t||{}),n=new ne(r);await n.load();let[s,i,c]=await Promise.all([Ge(r),We(r),Le(r)]),a="";if(o.context7.enabled)try{a=await Ve(s,e,o.context7.apiKey)}catch{}let p=n.buildMemoryContext(e),l=Ee(r);return b.context("memory",p?"loaded":"empty"),b.context("instructions",l?"loaded from project":"none"),{techStack:s,schemas:i,skills:c,docs:a,config:o,memoryContext:p,projectInstructions:l}}async function Zn(r){let{task:e,cwd:t,overwrite:o=!1,dryRun:n=!1,provider:s="claude-code",model:i,apiKey:c,context7:a=!0,interactive:p=!0}=r,l=e;if(f.has("pre:prompt")){let h=await f.execute("pre:prompt",{event:"pre:prompt",task:e,cwd:t});if(h.blocked)throw new Error(h.message||"Blocked by pre:prompt hook");h.modified?.task&&(l=String(h.modified.task))}if(f.has("pre:generate")){let h=await f.execute("pre:generate",{event:"pre:generate",task:l,cwd:t});if(h.blocked)throw new Error(h.message||"Blocked by pre:generate hook")}R.info("Analyzing project...");let d=await mt(t,l,{provider:s,context7:{enabled:a,apiKey:c}}),u=Pe(r.outputType,l);R.info(`Output type: ${u}`);let m=_e(d.skills,l,u);m.length&&R.info(`Loaded ${m.length} relevant skill(s): ${m.map(h=>h.skill.frontmatter.name).join(", ")}`);let I=ft(d,u,m.map(h=>h.skill));if(!await we(c))throw new Error("No credentials configured. Run `agentx model` to set up.");let E=ve(s,c,r.providerOpts||{}),C=i||Q()?.model,B=[...r.sessionMessages||[],{role:"user",content:l}];R.info("Generating...");let G=Oe(E),F=r.maxSteps??(G?20:5),A=r.mcpServers&&Object.keys(r.mcpServers).length>0?await He(r.mcpServers):void 0,O;try{O=await Ae({provider:E,systemPrompt:I,messages:[{role:"system",content:I},...B],providerOptions:{model:C,maxTokens:8192},cwd:t,maxIterations:F,enabledTools:d.config.agentic.enabledTools.filter(h=>!d.config.agentic.disabledTools.includes(h)),interactive:p,overwrite:o,dryRun:n,acmeContext:r.acmeContext,abortSignal:r.abortSignal,mcpTools:A?.tools,mcpDispatch:A?A.dispatch.bind(A):void 0,onProgress:h=>{h.type==="iteration_start"&&h.iteration>1&&R.info(`Step ${h.iteration}/${F}...`),h.type==="tool_call"&&b.step(0,`Tool: ${h.name}`)}})}finally{A?.close()}if(O.tokensUsed){let h=C||"claude-sonnet-4-20250514",V=Math.round(O.tokensUsed*.3),Y=O.tokensUsed-V;te.recordStep(1,h,V,Y)}let{content:j}=O,{followUp:_,tokensUsed:g,inputTokens:M,outputTokens:P}=O;if(O.iterations>1&&R.info(`Completed in ${O.iterations} step(s)`),f.has("post:response")){let h=await f.execute("post:response",{event:"post:response",content:j,task:l,cwd:t});if(h.blocked)throw new Error(h.message||"Blocked by post:response hook");h.modified?.content&&(j=String(h.modified.content))}if(_&&p)return{files:{written:[],skipped:[],errors:[]},content:j,outputType:u,followUp:_,tokensUsed:g,inputTokens:M,outputTokens:P};let T=new Map;for(let h of O.files)T.set(h.path,h);let U=fe(u,d.techStack,r.outputDir),v=await me(Array.from(T.values()),{cwd:t,overwrite:o,dryRun:n,outputDir:U}),x;if(r.heal!==!1&&!n&&v.written.length>0){let{HealEngine:h}=await import("./heal-FVLBHYP7.js");x=await new h(t,{enabled:!0,testCommand:r.healConfig?.testCommand,buildCommand:r.healConfig?.buildCommand,lintCommand:r.healConfig?.lintCommand,maxAttempts:r.healConfig?.maxAttempts??3,provider:s,model:C,apiKey:c}).detectAndHeal(v.written,l),!x.healed&&x.error&&await f.execute("on:error",{event:"on:error",error:new Error(x.error),task:l,cwd:t})}return f.has("post:generate")&&await f.execute("post:generate",{event:"post:generate",task:l,content:j,cwd:t}),{files:v,content:j,outputType:u,tokensUsed:g,inputTokens:M,outputTokens:P,healResult:x}}async function*er(r){let{task:e,cwd:t,overwrite:o=!1,dryRun:n=!1,provider:s="claude-code",model:i,apiKey:c,context7:a=!0,interactive:p=!0}=r,l=e;if(f.has("pre:prompt")){let y=await f.execute("pre:prompt",{event:"pre:prompt",task:e,cwd:t});if(y.blocked){yield{type:"error",error:y.message||"Blocked by pre:prompt hook"};return}y.modified?.task&&(l=String(y.modified.task))}if(f.has("pre:generate")){let y=await f.execute("pre:generate",{event:"pre:generate",task:l,cwd:t});if(y.blocked){yield{type:"error",error:y.message||"Blocked by pre:generate hook"};return}}let d=await mt(t,l,{provider:s,context7:{enabled:a,apiKey:c}}),u=Pe(r.outputType,l);yield{type:"context_ready",outputType:u};let m=_e(d.skills,l,u),I=ft(d,u,m.map(y=>y.skill));if(!await we(c)){yield{type:"error",error:"No credentials configured. Run `agentx model` to set up."};return}let E=ve(s,c,r.providerOpts||{}),C=i||Q()?.model,B=Oe(E),G=r.maxSteps??(B?20:5),F=[...r.sessionMessages||[],{role:"user",content:l}];if(B){let y=new he,S,k,H;if(r.mcpServers&&Object.keys(r.mcpServers).length>0)try{H=await He(r.mcpServers)}catch(w){yield{type:"error",error:`MCP pool startup failed: ${w.message}`};return}let ie=(async()=>{try{S=await Ae({provider:E,systemPrompt:I,messages:[{role:"system",content:I},...F],providerOptions:{model:C,maxTokens:8192},cwd:t,maxIterations:G,abortSignal:r.abortSignal,enabledTools:d.config.agentic.enabledTools.filter(w=>!d.config.agentic.disabledTools.includes(w)),interactive:p,overwrite:o,dryRun:n,acmeContext:r.acmeContext,mcpTools:H?.tools,mcpDispatch:H?H.dispatch.bind(H):void 0,onProgress:w=>{w.type==="text_delta"&&y.push({type:"text_delta",text:w.text}),w.type==="thinking_delta"&&y.push({type:"thinking_delta",text:w.text}),w.type==="iteration_start"&&y.push({type:"iteration",iteration:w.iteration}),w.type==="tool_call"&&y.push({type:"tool_call",name:w.name,id:w.id}),w.type==="tool_result"&&y.push({type:"tool_result",name:w.name,id:w.id,is_error:w.is_error}),w.type==="files_created"&&y.push({type:"step_complete",step:0,filesCount:w.files.length})}})}catch(w){k=w}finally{H?.close(),y.close()}})();for await(let w of y)yield w;if(await ie,k){yield{type:"error",error:k instanceof Error?k.message:String(k)};return}if(!S){yield{type:"error",error:"Agentic loop failed without a result"};return}yield{type:"done",result:{content:S.content,files:S.files,tokensUsed:S.tokensUsed,followUp:S.followUp}};let{content:L}=S;if(f.has("post:response")){let w=await f.execute("post:response",{event:"post:response",content:L,task:l,cwd:t});if(w.blocked){yield{type:"error",error:w.message||"Blocked by post:response hook"};return}w.modified?.content&&(L=String(w.modified.content))}if(S.followUp&&p){yield{type:"generate_result",result:{files:{written:[],skipped:[],errors:[]},content:L,outputType:u,followUp:S.followUp,tokensUsed:S.tokensUsed,inputTokens:S.inputTokens,outputTokens:S.outputTokens}};return}let ae=new Map;for(let w of S.files)ae.set(w.path,w);let De=fe(u,d.techStack,r.outputDir),z=await me(Array.from(ae.values()),{cwd:t,overwrite:o,dryRun:n,outputDir:De}),J;if(r.heal!==!1&&!n&&z.written.length>0){let{HealEngine:w}=await import("./heal-FVLBHYP7.js");J=await new w(t,{enabled:!0,testCommand:r.healConfig?.testCommand,buildCommand:r.healConfig?.buildCommand,lintCommand:r.healConfig?.lintCommand,maxAttempts:r.healConfig?.maxAttempts??3,provider:s,model:C,apiKey:c}).detectAndHeal(z.written,l)}f.has("post:generate")&&await f.execute("post:generate",{event:"post:generate",task:l,content:L,cwd:t}),yield{type:"generate_result",result:{files:z,content:L,outputType:u,tokensUsed:S.tokensUsed,inputTokens:S.inputTokens,outputTokens:S.outputTokens,healResult:J}};return}let A=[{role:"system",content:I},...F],O=[],j=0,_="",g,M=0;M++,b.step(M,`Starting generation (model: ${C||"default"})`);let P;if(E.stream){let y="",S;for await(let k of E.stream(A,{model:C,maxTokens:8192}))yield k,k.type==="text_delta"&&(y+=k.text),k.type==="done"&&(S=k.result);P=S||{content:y,files:[],tokensUsed:0}}else{let y=await E.generate(A,{model:C,maxTokens:8192});y.content&&(yield{type:"text_delta",text:y.content}),yield{type:"done",result:y},P=y}j+=P.tokensUsed||0,_=P.content;let T=P.tokensUsed||0,U=C||"claude-sonnet-4-20250514",v=Math.round(T*.3),x=T-v;if(te.recordStep(M,U,v,x),b.api("generate",U,T),b.step(M,`Generated ${P.files.length} file(s), ${T} tokens`),P.files.length&&O.push(...P.files),P.followUp&&(g=P.followUp),yield{type:"step_complete",step:M,filesCount:P.files.length},!g&&(_.includes("[CONTINUE]")||_.includes("Next, I'll")||_.includes("Now let me")||_.includes("I'll also generate"))&&P.files.length>0){let S=P.files.map(k=>`Created: ${k.path}${k.description?` \u2014 ${k.description}`:""}`).join(`
|
|
69
|
+
`);for(A.push({role:"assistant",content:_+(S?`
|
|
70
|
+
|
|
71
|
+
Files created:
|
|
72
|
+
${S}`:"")}),A.push({role:"user",content:"Continue generating the remaining files. Build on what you've already created. When finished, do not include [CONTINUE] in your response."});M<G;){M++,b.step(M,`Starting generation (model: ${C||"default"})`);let k=await E.generate(A,{model:C,maxTokens:8192});j+=k.tokensUsed||0,_=k.content;let H=k.tokensUsed||0,ie=C||"claude-sonnet-4-20250514",L=Math.round(H*.3),ae=H-L;if(te.recordStep(M,ie,L,ae),b.api("generate",ie,H),b.step(M,`Generated ${k.files.length} file(s), ${H} tokens`),k.files.length&&O.push(...k.files),yield{type:"step_complete",step:M,filesCount:k.files.length},k.followUp){g=k.followUp;break}if(k.files.length===0&&M>1||!(k.content.includes("[CONTINUE]")||k.content.includes("Next, I'll")||k.content.includes("Now let me")||k.content.includes("I'll also generate")))break;let z=k.files.map(J=>`Created: ${J.path}${J.description?` \u2014 ${J.description}`:""}`).join(`
|
|
73
|
+
`);A.push({role:"assistant",content:k.content+(z?`
|
|
74
|
+
|
|
75
|
+
Files created:
|
|
76
|
+
${z}`:"")}),A.push({role:"user",content:"Continue generating the remaining files. Build on what you've already created. When finished, do not include [CONTINUE] in your response."})}}if(f.has("post:response")){let y=await f.execute("post:response",{event:"post:response",content:_,task:l,cwd:t});if(y.blocked){yield{type:"error",error:y.message||"Blocked by post:response hook"};return}y.modified?.content&&(_=String(y.modified.content))}if(g&&p){yield{type:"generate_result",result:{files:{written:[],skipped:[],errors:[]},content:_,outputType:u,followUp:g,tokensUsed:j}};return}let h=new Map;for(let y of O)h.set(y.path,y);let V=fe(u,d.techStack,r.outputDir),Y=await me(Array.from(h.values()),{cwd:t,overwrite:o,dryRun:n,outputDir:V}),X;if(r.heal!==!1&&!n&&Y.written.length>0){let{HealEngine:y}=await import("./heal-FVLBHYP7.js");X=await new y(t,{enabled:!0,testCommand:r.healConfig?.testCommand,buildCommand:r.healConfig?.buildCommand,lintCommand:r.healConfig?.lintCommand,maxAttempts:r.healConfig?.maxAttempts??3,provider:s,model:C,apiKey:c}).detectAndHeal(Y.written,l),!X.healed&&X.error&&await f.execute("on:error",{event:"on:error",error:new Error(X.error),task:l,cwd:t})}f.has("post:generate")&&await f.execute("post:generate",{event:"post:generate",task:l,content:_,cwd:t}),yield{type:"generate_result",result:{files:Y,content:_,outputType:u,tokensUsed:j,healResult:X}}}function ft(r,e,t){let o=[];o.push(`You are agentx, an agentic code generation tool. You generate high-quality, production-ready output for any tech stack.
|
|
77
|
+
|
|
78
|
+
Your primary tool is \`create_files\` \u2014 use it to output all generated code, documents, and configs as files.
|
|
79
|
+
If the request is ambiguous or you need critical information to proceed correctly, use \`ask_user\` to ask a clarifying question.
|
|
80
|
+
|
|
81
|
+
You also have tools to inspect the codebase before generating code:
|
|
82
|
+
- \`read_file\` \u2014 read existing files to understand patterns, styles, and implementations
|
|
83
|
+
- \`search_files\` \u2014 search for files by glob pattern, optionally grep content with regex
|
|
84
|
+
- \`list_directory\` \u2014 explore the project structure
|
|
85
|
+
- \`run_command\` \u2014 run shell commands (build, test, lint, etc.)
|
|
86
|
+
- \`edit_file\` \u2014 apply targeted search/replace edits to existing files
|
|
87
|
+
|
|
88
|
+
AGENTIC WORKFLOW:
|
|
89
|
+
- Before generating code, use \`read_file\` and \`search_files\` to understand the existing codebase
|
|
90
|
+
- Match the project's existing patterns, naming conventions, and code style
|
|
91
|
+
- After creating files, consider running tests or build commands to verify correctness
|
|
92
|
+
- Use \`edit_file\` for small, targeted changes instead of rewriting entire files
|
|
93
|
+
|
|
94
|
+
IMPORTANT RULES:
|
|
95
|
+
- Generate complete, working code \u2014 not stubs or placeholders
|
|
96
|
+
- Follow the project's existing patterns and conventions
|
|
97
|
+
- Use the detected tech stack to choose the right language, framework, and patterns
|
|
98
|
+
- File paths should be relative to the project root
|
|
99
|
+
- Include all necessary imports
|
|
100
|
+
- Do NOT add unnecessary dependencies
|
|
101
|
+
|
|
102
|
+
MULTI-STEP GENERATION:
|
|
103
|
+
For complex tasks that require multiple related files (e.g., schema + API + UI + tests), you can chain steps:
|
|
104
|
+
- Generate the foundational files first (schemas, types, configs)
|
|
105
|
+
- Include "[CONTINUE]" in your response text when there are more files to generate
|
|
106
|
+
- In subsequent steps, you'll see what was already created \u2014 build on it
|
|
107
|
+
- When all files are generated, do NOT include "[CONTINUE]"
|
|
108
|
+
- This enables you to generate a schema first, then an API that references it, then a UI that calls the API`),o.push(`# Project Tech Stack
|
|
109
|
+
${Fe(r.techStack)}`);let n=Object.keys(r.techStack.dependencies).slice(0,30);n.length&&o.push(`# Key Dependencies
|
|
110
|
+
${n.join(", ")}`);let s=ze(r.schemas);return s&&o.push(`# Project Schemas
|
|
111
|
+
${s}`),t.length&&o.push(`# Active Skills
|
|
112
|
+
Follow these skill instructions when applicable:
|
|
113
|
+
|
|
114
|
+
`+t.map(i=>`## Skill: ${i.frontmatter.name}
|
|
115
|
+
${i.frontmatter.description}
|
|
116
|
+
|
|
117
|
+
${i.instructions}`).join(`
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
`)),r.docs&&o.push(r.docs),r.projectInstructions&&o.push(`# Project Instructions
|
|
122
|
+
${r.projectInstructions}`),r.memoryContext&&o.push(r.memoryContext),o.push(`# Output Type: ${e}
|
|
123
|
+
Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
|
|
124
|
+
|
|
125
|
+
`)}export{qe as a,Vt as b,Yt as c,We as d,ze as e,Ve as f,Ye as g,Pe as h,ee as i,Re as j,le as k,te as l,Tt as m,oe as n,Mt as o,f as p,et as q,tt as r,Me as s,de as t,W as u,ne as v,it as w,Ee as x,$e as y,se as z,mt as A,Zn as B,er as C};
|
|
126
|
+
//# sourceMappingURL=chunk-MHIMGM4G.js.map
|