abtars 0.1.0-alpha.1

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.
Files changed (312) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +84 -0
  3. package/bundle/_registry.generated-M4WY2MMI.js +35 -0
  4. package/bundle/_registry.generated-M4WY2MMI.js.map +7 -0
  5. package/bundle/abtars-browser.js +162 -0
  6. package/bundle/abtars-browser.js.map +7 -0
  7. package/bundle/abtars-cli.js +1438 -0
  8. package/bundle/abtars-cli.js.map +7 -0
  9. package/bundle/abtars-restart.js +12 -0
  10. package/bundle/abtars-restart.js.map +7 -0
  11. package/bundle/abtars-rss.js +165 -0
  12. package/bundle/abtars-rss.js.map +7 -0
  13. package/bundle/abtars-task.js +258 -0
  14. package/bundle/abtars-task.js.map +7 -0
  15. package/bundle/abtars.js +4072 -0
  16. package/bundle/abtars.js.map +7 -0
  17. package/bundle/agent-api-rate-limit-OQNFMXTZ.js +38 -0
  18. package/bundle/agent-api-rate-limit-OQNFMXTZ.js.map +7 -0
  19. package/bundle/agent-registry-LT4JNQH6.js +18 -0
  20. package/bundle/agent-registry-LT4JNQH6.js.map +7 -0
  21. package/bundle/agents/default.md +29 -0
  22. package/bundle/anthropic-adapter-2APTH3LA.js +40 -0
  23. package/bundle/anthropic-adapter-2APTH3LA.js.map +7 -0
  24. package/bundle/bridge-lock-transport-4AC2G5G6.js +39 -0
  25. package/bundle/bridge-lock-transport-4AC2G5G6.js.map +7 -0
  26. package/bundle/browse-delivery-JXBY36GK.js +17 -0
  27. package/bundle/browse-delivery-JXBY36GK.js.map +7 -0
  28. package/bundle/browser-ELNDVPLC.js +18 -0
  29. package/bundle/browser-ELNDVPLC.js.map +7 -0
  30. package/bundle/capability-CIL3G4FI.js +17 -0
  31. package/bundle/capability-CIL3G4FI.js.map +7 -0
  32. package/bundle/chunk-265TPOPC.js +289 -0
  33. package/bundle/chunk-265TPOPC.js.map +7 -0
  34. package/bundle/chunk-2UENBO6M.js +223 -0
  35. package/bundle/chunk-2UENBO6M.js.map +7 -0
  36. package/bundle/chunk-2UPU3OW6.js +67 -0
  37. package/bundle/chunk-2UPU3OW6.js.map +7 -0
  38. package/bundle/chunk-2XU2X4OI.js +125 -0
  39. package/bundle/chunk-2XU2X4OI.js.map +7 -0
  40. package/bundle/chunk-3B7BBE4F.js +758 -0
  41. package/bundle/chunk-3B7BBE4F.js.map +7 -0
  42. package/bundle/chunk-3E545J66.js +69 -0
  43. package/bundle/chunk-3E545J66.js.map +7 -0
  44. package/bundle/chunk-5R2ANXQ7.js +510 -0
  45. package/bundle/chunk-5R2ANXQ7.js.map +7 -0
  46. package/bundle/chunk-6CPN4IGS.js +507 -0
  47. package/bundle/chunk-6CPN4IGS.js.map +7 -0
  48. package/bundle/chunk-6NR3OHEW.js +88 -0
  49. package/bundle/chunk-6NR3OHEW.js.map +7 -0
  50. package/bundle/chunk-6SETMHNN.js +206 -0
  51. package/bundle/chunk-6SETMHNN.js.map +7 -0
  52. package/bundle/chunk-6UCRKRWR.js +644 -0
  53. package/bundle/chunk-6UCRKRWR.js.map +7 -0
  54. package/bundle/chunk-AR6GO6YC.js +83 -0
  55. package/bundle/chunk-AR6GO6YC.js.map +7 -0
  56. package/bundle/chunk-AZJIODTQ.js +54 -0
  57. package/bundle/chunk-AZJIODTQ.js.map +7 -0
  58. package/bundle/chunk-BHMZ4RCC.js +3706 -0
  59. package/bundle/chunk-BHMZ4RCC.js.map +7 -0
  60. package/bundle/chunk-BQ2L4GMG.js +9175 -0
  61. package/bundle/chunk-BQ2L4GMG.js.map +7 -0
  62. package/bundle/chunk-BSSBCSCL.js +159 -0
  63. package/bundle/chunk-BSSBCSCL.js.map +7 -0
  64. package/bundle/chunk-BUUVFUPO.js +157 -0
  65. package/bundle/chunk-BUUVFUPO.js.map +7 -0
  66. package/bundle/chunk-CEVRHKJY.js +131 -0
  67. package/bundle/chunk-CEVRHKJY.js.map +7 -0
  68. package/bundle/chunk-CWOHNFUV.js +39 -0
  69. package/bundle/chunk-CWOHNFUV.js.map +7 -0
  70. package/bundle/chunk-D2DCBO6M.js +228 -0
  71. package/bundle/chunk-D2DCBO6M.js.map +7 -0
  72. package/bundle/chunk-FMWKEPM7.js +31 -0
  73. package/bundle/chunk-FMWKEPM7.js.map +7 -0
  74. package/bundle/chunk-GRNENTPA.js +145 -0
  75. package/bundle/chunk-GRNENTPA.js.map +7 -0
  76. package/bundle/chunk-GST5T3WZ.js +93 -0
  77. package/bundle/chunk-GST5T3WZ.js.map +7 -0
  78. package/bundle/chunk-GUQVJC3U.js +299 -0
  79. package/bundle/chunk-GUQVJC3U.js.map +7 -0
  80. package/bundle/chunk-HX7Y7EYP.js +3659 -0
  81. package/bundle/chunk-HX7Y7EYP.js.map +7 -0
  82. package/bundle/chunk-JCJS4ZIB.js +296 -0
  83. package/bundle/chunk-JCJS4ZIB.js.map +7 -0
  84. package/bundle/chunk-JW6RU47G.js +184 -0
  85. package/bundle/chunk-JW6RU47G.js.map +7 -0
  86. package/bundle/chunk-LSPKJQCI.js +24 -0
  87. package/bundle/chunk-LSPKJQCI.js.map +7 -0
  88. package/bundle/chunk-M6VBAPNT.js +16 -0
  89. package/bundle/chunk-M6VBAPNT.js.map +7 -0
  90. package/bundle/chunk-MPX525QO.js +129 -0
  91. package/bundle/chunk-MPX525QO.js.map +7 -0
  92. package/bundle/chunk-MW6WDLU7.js +130 -0
  93. package/bundle/chunk-MW6WDLU7.js.map +7 -0
  94. package/bundle/chunk-NT3OBORC.js +215 -0
  95. package/bundle/chunk-NT3OBORC.js.map +7 -0
  96. package/bundle/chunk-NWDBD4PA.js +50 -0
  97. package/bundle/chunk-NWDBD4PA.js.map +7 -0
  98. package/bundle/chunk-OP7BTAWY.js +29 -0
  99. package/bundle/chunk-OP7BTAWY.js.map +7 -0
  100. package/bundle/chunk-PLCY3GFH.js +77 -0
  101. package/bundle/chunk-PLCY3GFH.js.map +7 -0
  102. package/bundle/chunk-PNEDC45Y.js +97 -0
  103. package/bundle/chunk-PNEDC45Y.js.map +7 -0
  104. package/bundle/chunk-QBGBT5QS.js +81 -0
  105. package/bundle/chunk-QBGBT5QS.js.map +7 -0
  106. package/bundle/chunk-RVE2N7FA.js +70 -0
  107. package/bundle/chunk-RVE2N7FA.js.map +7 -0
  108. package/bundle/chunk-TZHIDLDS.js +71910 -0
  109. package/bundle/chunk-TZHIDLDS.js.map +7 -0
  110. package/bundle/chunk-UCQ2WC3B.js +126 -0
  111. package/bundle/chunk-UCQ2WC3B.js.map +7 -0
  112. package/bundle/chunk-UHRP745J.js +214 -0
  113. package/bundle/chunk-UHRP745J.js.map +7 -0
  114. package/bundle/chunk-V76TVMCM.js +58 -0
  115. package/bundle/chunk-V76TVMCM.js.map +7 -0
  116. package/bundle/chunk-VVEDVGCR.js +981 -0
  117. package/bundle/chunk-VVEDVGCR.js.map +7 -0
  118. package/bundle/chunk-W6FAL35D.js +102 -0
  119. package/bundle/chunk-W6FAL35D.js.map +7 -0
  120. package/bundle/chunk-X6TERNVJ.js +15902 -0
  121. package/bundle/chunk-X6TERNVJ.js.map +7 -0
  122. package/bundle/chunk-X76UX47U.js +47 -0
  123. package/bundle/chunk-X76UX47U.js.map +7 -0
  124. package/bundle/chunk-XREWVCUO.js +518 -0
  125. package/bundle/chunk-XREWVCUO.js.map +7 -0
  126. package/bundle/chunk-Y6XAEX2Q.js +408 -0
  127. package/bundle/chunk-Y6XAEX2Q.js.map +7 -0
  128. package/bundle/chunk-YOCTDKKL.js +28 -0
  129. package/bundle/chunk-YOCTDKKL.js.map +7 -0
  130. package/bundle/chunk-ZXPXCDA6.js +160 -0
  131. package/bundle/chunk-ZXPXCDA6.js.map +7 -0
  132. package/bundle/commands-BHVUOU3V.js +31 -0
  133. package/bundle/commands-BHVUOU3V.js.map +7 -0
  134. package/bundle/completion-buffer-P253ONKF.js +13 -0
  135. package/bundle/completion-buffer-P253ONKF.js.map +7 -0
  136. package/bundle/config-RGSDAPZN.js +19 -0
  137. package/bundle/config-RGSDAPZN.js.map +7 -0
  138. package/bundle/config-show-ERTATR6E.js +40 -0
  139. package/bundle/config-show-ERTATR6E.js.map +7 -0
  140. package/bundle/context-HCEGZNDC.js +72 -0
  141. package/bundle/context-HCEGZNDC.js.map +7 -0
  142. package/bundle/delegation-tools-GYTS2D6A.js +27 -0
  143. package/bundle/delegation-tools-GYTS2D6A.js.map +7 -0
  144. package/bundle/deploy-lib-import-32ZFKHWP.js +49 -0
  145. package/bundle/deploy-lib-import-32ZFKHWP.js.map +7 -0
  146. package/bundle/digital-signature-OFCGSHWO.js +13 -0
  147. package/bundle/digital-signature-OFCGSHWO.js.map +7 -0
  148. package/bundle/direct-api-transport-YR7SXXNN.js +860 -0
  149. package/bundle/direct-api-transport-YR7SXXNN.js.map +7 -0
  150. package/bundle/discord-adapter-YYWVMPPU.js +584 -0
  151. package/bundle/discord-adapter-YYWVMPPU.js.map +7 -0
  152. package/bundle/dist-MTMKARCP.js +1969 -0
  153. package/bundle/dist-MTMKARCP.js.map +7 -0
  154. package/bundle/dns-wakeup-27M7D2MR.js +107 -0
  155. package/bundle/dns-wakeup-27M7D2MR.js.map +7 -0
  156. package/bundle/doctor-QNUSDY73.js +248 -0
  157. package/bundle/doctor-QNUSDY73.js.map +7 -0
  158. package/bundle/ensure-invariants-NMXNS476.js +49 -0
  159. package/bundle/ensure-invariants-NMXNS476.js.map +7 -0
  160. package/bundle/env-schema-2KBHBDGN.js +19 -0
  161. package/bundle/env-schema-2KBHBDGN.js.map +7 -0
  162. package/bundle/esm-DDP6NCZG.js +100663 -0
  163. package/bundle/esm-DDP6NCZG.js.map +7 -0
  164. package/bundle/fallback-policy-L4QV2PEJ.js +46 -0
  165. package/bundle/fallback-policy-L4QV2PEJ.js.map +7 -0
  166. package/bundle/health-check-SPA7NT6N.js +56 -0
  167. package/bundle/health-check-SPA7NT6N.js.map +7 -0
  168. package/bundle/hook-system-6Q5YTR53.js +17 -0
  169. package/bundle/hook-system-6Q5YTR53.js.map +7 -0
  170. package/bundle/hotskills-K7BM4YLB.js +12 -0
  171. package/bundle/hotskills-K7BM4YLB.js.map +7 -0
  172. package/bundle/install-6HRZVKUM.js +15 -0
  173. package/bundle/install-6HRZVKUM.js.map +7 -0
  174. package/bundle/install-log-IAPHYKD4.js +28 -0
  175. package/bundle/install-log-IAPHYKD4.js.map +7 -0
  176. package/bundle/install-manifest-SPQRUNXL.js +102 -0
  177. package/bundle/install-manifest-SPQRUNXL.js.map +7 -0
  178. package/bundle/install-validate-PVLZXYLQ.js +53 -0
  179. package/bundle/install-validate-PVLZXYLQ.js.map +7 -0
  180. package/bundle/irc-adapter-OI5UZSQF.js +293 -0
  181. package/bundle/irc-adapter-OI5UZSQF.js.map +7 -0
  182. package/bundle/irc-config-55YO6EGB.js +88 -0
  183. package/bundle/irc-config-55YO6EGB.js.map +7 -0
  184. package/bundle/logs-ZNYXX5PA.js +19 -0
  185. package/bundle/logs-ZNYXX5PA.js.map +7 -0
  186. package/bundle/media-utils-XNNDTYFI.js +4662 -0
  187. package/bundle/media-utils-XNNDTYFI.js.map +7 -0
  188. package/bundle/message-pipeline-LLH5SYMO.js +33 -0
  189. package/bundle/message-pipeline-LLH5SYMO.js.map +7 -0
  190. package/bundle/meta.json +41304 -0
  191. package/bundle/model-health-registry-35LQNVQR.js +11 -0
  192. package/bundle/model-health-registry-35LQNVQR.js.map +7 -0
  193. package/bundle/notification-Y5S5MMLV.js +13 -0
  194. package/bundle/notification-Y5S5MMLV.js.map +7 -0
  195. package/bundle/openrouter-credits-EDY7ETAU.js +32 -0
  196. package/bundle/openrouter-credits-EDY7ETAU.js.map +7 -0
  197. package/bundle/passwd-RRFV4CC5.js +133 -0
  198. package/bundle/passwd-RRFV4CC5.js.map +7 -0
  199. package/bundle/paths-G33RZWZ7.js +17 -0
  200. package/bundle/paths-G33RZWZ7.js.map +7 -0
  201. package/bundle/peer-client-52XYMNI7.js +156 -0
  202. package/bundle/peer-client-52XYMNI7.js.map +7 -0
  203. package/bundle/peer-config-VK6EDLN5.js +16 -0
  204. package/bundle/peer-config-VK6EDLN5.js.map +7 -0
  205. package/bundle/peer-sessions-EAXTNQ36.js +49 -0
  206. package/bundle/peer-sessions-EAXTNQ36.js.map +7 -0
  207. package/bundle/pending-callback-RIMQZ7FJ.js +40 -0
  208. package/bundle/pending-callback-RIMQZ7FJ.js.map +7 -0
  209. package/bundle/phase-transport-KYERDL2O.js +22 -0
  210. package/bundle/phase-transport-KYERDL2O.js.map +7 -0
  211. package/bundle/public/css/dashboard.css +542 -0
  212. package/bundle/public/index.html +180 -0
  213. package/bundle/public/js/app.js +437 -0
  214. package/bundle/public/memory-universe.js +384 -0
  215. package/bundle/responses-adapter-AAQTY3K4.js +30 -0
  216. package/bundle/responses-adapter-AAQTY3K4.js.map +7 -0
  217. package/bundle/restore-ZE3SEPSS.js +46 -0
  218. package/bundle/restore-ZE3SEPSS.js.map +7 -0
  219. package/bundle/self-healer-utils-DMUUXC47.js +43 -0
  220. package/bundle/self-healer-utils-DMUUXC47.js.map +7 -0
  221. package/bundle/skill-stats-LLEXEXLR.js +22 -0
  222. package/bundle/skill-stats-LLEXEXLR.js.map +7 -0
  223. package/bundle/sleep-OYIUOVQD.js +19 -0
  224. package/bundle/sleep-OYIUOVQD.js.map +7 -0
  225. package/bundle/soul-loader-54WCVNLJ.js +16 -0
  226. package/bundle/soul-loader-54WCVNLJ.js.map +7 -0
  227. package/bundle/src-JL4PVO23.js +8 -0
  228. package/bundle/src-JL4PVO23.js.map +7 -0
  229. package/bundle/sse-parser-anthropic-P7CE2MH2.js +72 -0
  230. package/bundle/sse-parser-anthropic-P7CE2MH2.js.map +7 -0
  231. package/bundle/sse-parser-responses-EQQA5FWN.js +63 -0
  232. package/bundle/sse-parser-responses-EQQA5FWN.js.map +7 -0
  233. package/bundle/ssrf-guard-FZCBYIVW.js +64 -0
  234. package/bundle/ssrf-guard-FZCBYIVW.js.map +7 -0
  235. package/bundle/start-FH3GRMJ4.js +35 -0
  236. package/bundle/start-FH3GRMJ4.js.map +7 -0
  237. package/bundle/stream-single-WSG4D53C.js +33 -0
  238. package/bundle/stream-single-WSG4D53C.js.map +7 -0
  239. package/bundle/stt-2UH3RITX.js +14 -0
  240. package/bundle/stt-2UH3RITX.js.map +7 -0
  241. package/bundle/subagent-runtime-LE2ZXH3G.js +12 -0
  242. package/bundle/subagent-runtime-LE2ZXH3G.js.map +7 -0
  243. package/bundle/system-message-T5R3EYYN.js +30 -0
  244. package/bundle/system-message-T5R3EYYN.js.map +7 -0
  245. package/bundle/system-status-KQ6KHFJ6.js +189 -0
  246. package/bundle/system-status-KQ6KHFJ6.js.map +7 -0
  247. package/bundle/task-store-K7CQDEPI.js +22 -0
  248. package/bundle/task-store-K7CQDEPI.js.map +7 -0
  249. package/bundle/telegram-adapter-2V3XUMT5.js +1060 -0
  250. package/bundle/telegram-adapter-2V3XUMT5.js.map +7 -0
  251. package/bundle/tool-registry-MU3OX4UI.js +38 -0
  252. package/bundle/tool-registry-MU3OX4UI.js.map +7 -0
  253. package/bundle/tool-sandbox-VYOK4ZOA.js +20 -0
  254. package/bundle/tool-sandbox-VYOK4ZOA.js.map +7 -0
  255. package/bundle/transport-config-YLXU33RO.js +57 -0
  256. package/bundle/transport-config-YLXU33RO.js.map +7 -0
  257. package/bundle/update-QCW5LXRN.js +13 -0
  258. package/bundle/update-QCW5LXRN.js.map +7 -0
  259. package/bundle/update-check-27KZSAP6.js +12 -0
  260. package/bundle/update-check-27KZSAP6.js.map +7 -0
  261. package/bundle/usage-tracker-OVVEVMOY.js +17 -0
  262. package/bundle/usage-tracker-OVVEVMOY.js.map +7 -0
  263. package/bundle/user-registry-D4SD73UV.js +16 -0
  264. package/bundle/user-registry-D4SD73UV.js.map +7 -0
  265. package/core/professor.json +14 -0
  266. package/core/prompts/browsing_prompt.md +39 -0
  267. package/core/prompts/compaction.md +32 -0
  268. package/core/skills/memory/classification/SKILL.md +37 -0
  269. package/core/skills/memory/memory-anomalies/SKILL.md +39 -0
  270. package/core/skills/memory/memory-search/SKILL.md +48 -0
  271. package/core/skills/memory/topic-save/SKILL.md +44 -0
  272. package/core/skills/ops/cron/SKILL.md +51 -0
  273. package/core/skills/ops/gdrive-backup/SKILL.md +15 -0
  274. package/core/skills/ops/session-start/SKILL.md +11 -0
  275. package/core/skills/ops/skill-authoring/SKILL.md +54 -0
  276. package/core/skills/ops/system-health/SKILL.md +104 -0
  277. package/core/skills/ops/troubleshooting/SKILL.md +48 -0
  278. package/core/skills/ops/trust-gating/SKILL.md +30 -0
  279. package/core/skills/tools/a2a-communication/SKILL.md +68 -0
  280. package/core/skills/tools/browse-delegate/SKILL.md +27 -0
  281. package/core/skills/tools/browser/SKILL.md +36 -0
  282. package/core/skills/tools/clawhub/SKILL.md +44 -0
  283. package/core/skills/tools/delegation/SKILL.md +48 -0
  284. package/core/skills/tools/fxtwitter/SKILL.md +52 -0
  285. package/core/skills/tools/gmail/SKILL.md +44 -0
  286. package/core/skills/tools/irc-chat/SKILL.md +84 -0
  287. package/core/skills/tools/linear/SKILL.md +90 -0
  288. package/core/skills/tools/mcporter/SKILL.md +46 -0
  289. package/core/skills/tools/model-scout/SKILL.md +132 -0
  290. package/core/skills/tools/model-scout/scout-add-model.py +67 -0
  291. package/core/skills/tools/model-scout/scout-ollama.py +116 -0
  292. package/core/skills/tools/model-scout/scout-openrouter.py +85 -0
  293. package/core/skills/tools/nlm/SKILL.md +40 -0
  294. package/core/skills/tools/todo/SKILL.md +30 -0
  295. package/core/skills/tools/twitterX/SKILL.md +52 -0
  296. package/core/skills/tools/twitterX/scripts/abtars-tweet.js +532 -0
  297. package/core/skills/tools/twitterX/scripts/package.json +1 -0
  298. package/core/skills/tools/web-fetch/SKILL.md +29 -0
  299. package/package.json +59 -0
  300. package/scripts/abtars-daemon.service +23 -0
  301. package/scripts/abtars-fetch.sh +42 -0
  302. package/scripts/abtars-watchdog.service +13 -0
  303. package/scripts/abtars.sh +14 -0
  304. package/scripts/abtars@.service +21 -0
  305. package/scripts/browser-patchright.sh +79 -0
  306. package/scripts/com.abtars.daemon.plist +24 -0
  307. package/scripts/com.abtars.watchdog.plist +27 -0
  308. package/scripts/daily-backup.sh +62 -0
  309. package/scripts/doctor.sh +553 -0
  310. package/scripts/hooks/audit-logger.sh +22 -0
  311. package/scripts/upgrade-deps.sh +64 -0
  312. package/scripts/watchdog.sh +309 -0
@@ -0,0 +1,981 @@
1
+ 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);
2
+ import {
3
+ abmind
4
+ } from "./chunk-OP7BTAWY.js";
5
+ import {
6
+ auditDeny,
7
+ checkPath,
8
+ checkTool
9
+ } from "./chunk-MPX525QO.js";
10
+ import {
11
+ bumpRead,
12
+ setProvenance
13
+ } from "./chunk-AR6GO6YC.js";
14
+ import {
15
+ getDelegationTools
16
+ } from "./chunk-UHRP745J.js";
17
+ import {
18
+ init_log_and_swallow,
19
+ logAndSwallow
20
+ } from "./chunk-FMWKEPM7.js";
21
+ import {
22
+ getEnv,
23
+ init_env_schema
24
+ } from "./chunk-JCJS4ZIB.js";
25
+ import {
26
+ init_logger,
27
+ logInfo,
28
+ logWarn,
29
+ redactSecrets
30
+ } from "./chunk-BUUVFUPO.js";
31
+ import {
32
+ abtarsHome,
33
+ init_paths
34
+ } from "./chunk-X76UX47U.js";
35
+ import {
36
+ __esm,
37
+ __export,
38
+ __toCommonJS
39
+ } from "./chunk-NWDBD4PA.js";
40
+
41
+ // src/components/guardrails.ts
42
+ var guardrails_exports = {};
43
+ __export(guardrails_exports, {
44
+ checkCommand: () => checkCommand,
45
+ checkPath: () => checkPath2,
46
+ getSecurityMode: () => getSecurityMode,
47
+ isGuardrailsActive: () => isGuardrailsActive
48
+ });
49
+ import { resolve, sep } from "node:path";
50
+ import { homedir } from "node:os";
51
+ function getSecurityMode() {
52
+ const mode = getEnv().securityMode;
53
+ return mode || "off";
54
+ }
55
+ function isGuardrailsActive() {
56
+ return getSecurityMode() !== "off";
57
+ }
58
+ function checkPath2(path, mode) {
59
+ if (!isGuardrailsActive()) return null;
60
+ const resolved = resolve(path) + (path.endsWith("/") ? sep : "");
61
+ for (const blocked of BLOCKED_PATHS) {
62
+ if (resolved.startsWith(blocked) || resolved === blocked.slice(0, -1)) {
63
+ return `Path blocked by guardrails: ${path}`;
64
+ }
65
+ }
66
+ if (mode === "write") {
67
+ for (const wb of WRITE_BLOCKED) {
68
+ if (resolved.startsWith(wb) || resolved === wb) {
69
+ return `Write blocked by guardrails: ${path}`;
70
+ }
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ function checkCommand(cmd) {
76
+ if (!isGuardrailsActive()) return null;
77
+ const trimmed = cmd.trim().toLowerCase();
78
+ for (const prefix of BLOCKED_COMMAND_PREFIXES) {
79
+ if (trimmed.startsWith(prefix.toLowerCase())) {
80
+ logWarn(TAG3, `Blocked command: ${cmd.slice(0, 100)}`);
81
+ return `Command blocked by guardrails: matches '${prefix.trim()}'`;
82
+ }
83
+ }
84
+ return null;
85
+ }
86
+ var TAG3, HOME, BLOCKED_PATHS, WRITE_BLOCKED, BLOCKED_COMMAND_PREFIXES;
87
+ var init_guardrails = __esm({
88
+ "src/components/guardrails.ts"() {
89
+ "use strict";
90
+ init_env_schema();
91
+ init_logger();
92
+ TAG3 = "guardrails";
93
+ HOME = homedir();
94
+ BLOCKED_PATHS = [
95
+ `${HOME}/.ssh${sep}`,
96
+ `${HOME}/.abtars/secret${sep}`,
97
+ `/etc${sep}`,
98
+ `/proc${sep}`,
99
+ `/sys${sep}`,
100
+ `/dev${sep}`,
101
+ `/root${sep}`,
102
+ `/run${sep}`
103
+ ];
104
+ WRITE_BLOCKED = [
105
+ `${HOME}/.abtars/config/peers.json`,
106
+ `${HOME}/.kiro${sep}`
107
+ ];
108
+ BLOCKED_COMMAND_PREFIXES = [
109
+ "sudo ",
110
+ "npm publish",
111
+ "git push ",
112
+ "chmod 777",
113
+ "rm -rf /"
114
+ ];
115
+ }
116
+ });
117
+
118
+ // src/components/transport/tool-registry.ts
119
+ init_logger();
120
+ init_log_and_swallow();
121
+ import { execFile as execFile2 } from "node:child_process";
122
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
123
+ import { join as join2 } from "node:path";
124
+ import { homedir as homedir2 } from "node:os";
125
+
126
+ // src/components/transport/skill-authoring.ts
127
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, renameSync, appendFileSync } from "node:fs";
128
+ import { join } from "node:path";
129
+ init_paths();
130
+ init_logger();
131
+ init_log_and_swallow();
132
+ var TAG = "skill-authoring";
133
+ var NAME_RE = /^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/;
134
+ var MIN_BYTES = 100;
135
+ var MAX_BYTES = 5e4;
136
+ var MAX_TAGS = 5;
137
+ function skillsDir() {
138
+ return join(abtarsHome(), "skills");
139
+ }
140
+ function selfDir() {
141
+ return join(skillsDir(), "self");
142
+ }
143
+ function trashDir() {
144
+ return join(skillsDir(), ".trash");
145
+ }
146
+ function auditLogPath() {
147
+ return join(abtarsHome(), "logs", "skill-authoring.log");
148
+ }
149
+ function audit(entry) {
150
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${entry}
151
+ `;
152
+ try {
153
+ const dir = join(abtarsHome(), "logs");
154
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
155
+ appendFileSync(auditLogPath(), line);
156
+ } catch (err) {
157
+ logAndSwallow(TAG, "audit write", err);
158
+ }
159
+ }
160
+ function validate(name, description, content) {
161
+ if (!NAME_RE.test(name)) return `Invalid name "${name}". Must be 3-64 chars, lowercase alphanumeric + hyphens, no leading/trailing hyphens.`;
162
+ const desc = description.trim();
163
+ if (desc.length < 1 || desc.length > 120) return `Description must be 1-120 chars (got ${desc.length}).`;
164
+ const bytes = Buffer.byteLength(content, "utf-8");
165
+ if (bytes < MIN_BYTES) return `Content too short (${bytes} bytes, minimum ${MIN_BYTES}). Write a useful skill, not a one-liner.`;
166
+ if (bytes > MAX_BYTES) return `Content too large (${bytes} bytes, maximum ${MAX_BYTES}). Split into a skill + references/ files.`;
167
+ const path = join(selfDir(), name, "SKILL.md");
168
+ if (existsSync(path)) return `Skill "${name}" already exists. Use skill_update to modify it.`;
169
+ const scan = abmind()?.scanForInjection(content);
170
+ if (scan && !scan.safe) return `Content blocked by injection scanner: ${scan.flags[0]?.category ?? "unknown"} (score=${scan.score}). Rephrase the content.`;
171
+ return null;
172
+ }
173
+ function parseFrontmatter(raw) {
174
+ const match = raw.match(/^---\n([\s\S]*?)\n---\n\n?([\s\S]*)$/);
175
+ if (!match) return { meta: {}, body: raw };
176
+ const meta = {};
177
+ for (const line of match[1].split("\n")) {
178
+ const idx = line.indexOf(":");
179
+ if (idx < 0) continue;
180
+ const key = line.slice(0, idx).trim();
181
+ let val = line.slice(idx + 1).trim();
182
+ if (typeof val === "string" && val.startsWith("[") && val.endsWith("]")) {
183
+ val = val.slice(1, -1).split(",").map((s) => s.trim()).filter(Boolean);
184
+ }
185
+ meta[key] = val;
186
+ }
187
+ return { meta, body: match[2] };
188
+ }
189
+ function serializeFrontmatter(meta) {
190
+ const lines = ["---"];
191
+ for (const [k, v] of Object.entries(meta)) {
192
+ if (v === void 0 || v === null) continue;
193
+ if (Array.isArray(v) && v.length > 0) {
194
+ lines.push(`${k}: [${v.join(", ")}]`);
195
+ } else if (!Array.isArray(v)) {
196
+ lines.push(`${k}: ${v}`);
197
+ }
198
+ }
199
+ lines.push("---\n\n");
200
+ return lines.join("\n");
201
+ }
202
+ function guardSelfSkill(name) {
203
+ if (!NAME_RE.test(name)) return `Invalid name "${name}".`;
204
+ const path = join(selfDir(), name, "SKILL.md");
205
+ if (!existsSync(path)) return `Skill "${name}" not found in self/.`;
206
+ return null;
207
+ }
208
+ var skillCreateTool = {
209
+ name: "skill_create",
210
+ 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.",
211
+ parameters: {
212
+ type: "object",
213
+ properties: {
214
+ name: { type: "string", description: "Skill identifier, kebab-case, e.g. 'fix-pnpm-workspace-drift'. 3-64 chars, [a-z0-9-]+." },
215
+ description: { type: "string", description: "One-line description, max 120 chars. Shown in skills_catalog." },
216
+ content: { type: "string", description: "Skill body in Markdown. Starts with # <Title>. No frontmatter \u2014 the tool writes it." },
217
+ tags: { type: "array", items: { type: "string" }, description: "Optional tags for categorization (max 5). E.g. ['tools', 'browser', 'debugging']." },
218
+ related: { type: "array", items: { type: "string" }, description: "Optional related skill names." }
219
+ },
220
+ required: ["name", "description", "content"]
221
+ },
222
+ async execute(args) {
223
+ const { name, description, content, tags, related } = args;
224
+ const error = validate(name, description, content);
225
+ if (error) {
226
+ audit(`skill_create name=${name} bytes=${content.length} ok=false error="${error}"`);
227
+ return JSON.stringify({ error });
228
+ }
229
+ const tagList = (tags ?? []).slice(0, MAX_TAGS).map((t) => t.toLowerCase().trim()).filter(Boolean);
230
+ const relList = (related ?? []).filter(Boolean);
231
+ const tagsLine = tagList.length > 0 ? `tags: [${tagList.join(", ")}]
232
+ ` : "";
233
+ const relatedLine = relList.length > 0 ? `related: [${relList.join(", ")}]
234
+ ` : "";
235
+ const frontmatter = `---
236
+ name: ${name}
237
+ description: ${description.trim()}
238
+ ${tagsLine}${relatedLine}---
239
+
240
+ `;
241
+ const fullContent = frontmatter + content;
242
+ const dir = join(selfDir(), name);
243
+ const filePath = join(dir, "SKILL.md");
244
+ const tmpPath = filePath + ".tmp";
245
+ try {
246
+ mkdirSync(dir, { recursive: true });
247
+ writeFileSync(tmpPath, fullContent, "utf-8");
248
+ renameSync(tmpPath, filePath);
249
+ } catch (err) {
250
+ const msg = err instanceof Error ? err.message : String(err);
251
+ audit(`skill_create name=${name} bytes=${content.length} ok=false error="write failed: ${msg}"`);
252
+ return JSON.stringify({ error: `Write failed: ${msg}` });
253
+ }
254
+ setProvenance(name, "agent");
255
+ audit(`skill_create name=${name} tags=[${tagList.join(",")}] bytes=${content.length} ok=true`);
256
+ logInfo(TAG, `Created skill: self/${name} (${content.length} bytes)`);
257
+ return JSON.stringify({ ok: true, path: filePath, message: `Skill "${name}" created in self/. Available in skills_catalog after /skill reload.` });
258
+ }
259
+ };
260
+ var skillUpdateTool = {
261
+ name: "skill_update",
262
+ description: "Full rewrite of an existing skill's SKILL.md in self/. Preserves frontmatter fields (tags, related, description) when omitted by caller.",
263
+ parameters: {
264
+ type: "object",
265
+ properties: {
266
+ name: { type: "string", description: "Skill name (must exist in self/)." },
267
+ description: { type: "string", description: "New description (optional \u2014 keeps existing if omitted)." },
268
+ content: { type: "string", description: "New skill body in Markdown (no frontmatter)." },
269
+ tags: { type: "array", items: { type: "string" }, description: "New tags (optional \u2014 keeps existing if omitted)." },
270
+ related: { type: "array", items: { type: "string" }, description: "New related skills (optional \u2014 keeps existing if omitted)." }
271
+ },
272
+ required: ["name", "content"]
273
+ },
274
+ async execute(args) {
275
+ const { name, content, description, tags, related } = args;
276
+ const guard = guardSelfSkill(name);
277
+ if (guard) {
278
+ audit(`skill_update name=${name} ok=false error="${guard}"`);
279
+ return JSON.stringify({ error: guard });
280
+ }
281
+ const bytes = Buffer.byteLength(content, "utf-8");
282
+ if (bytes < MIN_BYTES) return JSON.stringify({ error: `Content too short (${bytes} bytes, minimum ${MIN_BYTES}).` });
283
+ if (bytes > MAX_BYTES) return JSON.stringify({ error: `Content too large (${bytes} bytes, maximum ${MAX_BYTES}).` });
284
+ const scan = abmind()?.scanForInjection(content);
285
+ if (scan && !scan.safe) return JSON.stringify({ error: `Content blocked by injection scanner: ${scan.flags[0]?.category ?? "unknown"}.` });
286
+ const filePath = join(selfDir(), name, "SKILL.md");
287
+ const existing = readFileSync(filePath, "utf-8");
288
+ const { meta } = parseFrontmatter(existing);
289
+ const merged = { ...meta, name };
290
+ if (description !== void 0) merged["description"] = description.trim();
291
+ if (tags !== void 0) merged["tags"] = tags.slice(0, MAX_TAGS).map((t) => t.toLowerCase().trim()).filter(Boolean);
292
+ if (related !== void 0) merged["related"] = related.filter(Boolean);
293
+ const fullContent = serializeFrontmatter(merged) + content;
294
+ const tmpPath = filePath + ".tmp";
295
+ try {
296
+ writeFileSync(tmpPath, fullContent, "utf-8");
297
+ renameSync(tmpPath, filePath);
298
+ } catch (err) {
299
+ const msg = err instanceof Error ? err.message : String(err);
300
+ audit(`skill_update name=${name} ok=false error="write failed: ${msg}"`);
301
+ return JSON.stringify({ error: `Write failed: ${msg}` });
302
+ }
303
+ audit(`skill_update name=${name} bytes=${bytes} ok=true`);
304
+ logInfo(TAG, `Updated skill: self/${name} (${bytes} bytes)`);
305
+ return JSON.stringify({ ok: true, path: filePath, message: `Skill "${name}" updated.` });
306
+ }
307
+ };
308
+ var skillPatchTool = {
309
+ name: "skill_patch",
310
+ description: "Targeted find-and-replace within a skill's SKILL.md in self/. old_string must match exactly once.",
311
+ parameters: {
312
+ type: "object",
313
+ properties: {
314
+ name: { type: "string", description: "Skill name (must exist in self/)." },
315
+ old_string: { type: "string", description: "Exact string to find (must match once)." },
316
+ new_string: { type: "string", description: "Replacement string." }
317
+ },
318
+ required: ["name", "old_string", "new_string"]
319
+ },
320
+ async execute(args) {
321
+ const { name, old_string, new_string } = args;
322
+ const guard = guardSelfSkill(name);
323
+ if (guard) {
324
+ audit(`skill_patch name=${name} ok=false error="${guard}"`);
325
+ return JSON.stringify({ error: guard });
326
+ }
327
+ const filePath = join(selfDir(), name, "SKILL.md");
328
+ const existing = readFileSync(filePath, "utf-8");
329
+ const count = existing.split(old_string).length - 1;
330
+ if (count === 0) return JSON.stringify({ error: `old_string not found in skill "${name}".` });
331
+ if (count > 1) return JSON.stringify({ error: `old_string matches ${count} times \u2014 must match exactly once.` });
332
+ const patched = existing.replace(old_string, new_string);
333
+ const scan = abmind()?.scanForInjection(patched);
334
+ if (scan && !scan.safe) return JSON.stringify({ error: `Patched content blocked by injection scanner: ${scan.flags[0]?.category ?? "unknown"}.` });
335
+ const tmpPath = filePath + ".tmp";
336
+ try {
337
+ writeFileSync(tmpPath, patched, "utf-8");
338
+ renameSync(tmpPath, filePath);
339
+ } catch (err) {
340
+ const msg = err instanceof Error ? err.message : String(err);
341
+ audit(`skill_patch name=${name} ok=false error="write failed: ${msg}"`);
342
+ return JSON.stringify({ error: `Write failed: ${msg}` });
343
+ }
344
+ audit(`skill_patch name=${name} ok=true`);
345
+ logInfo(TAG, `Patched skill: self/${name}`);
346
+ return JSON.stringify({ ok: true, path: filePath, message: `Skill "${name}" patched.` });
347
+ }
348
+ };
349
+ var skillRemoveTool = {
350
+ name: "skill_remove",
351
+ description: "Soft-delete a skill from self/ by moving it to .trash/ (recoverable for 7 days).",
352
+ parameters: {
353
+ type: "object",
354
+ properties: {
355
+ name: { type: "string", description: "Skill name (must exist in self/)." }
356
+ },
357
+ required: ["name"]
358
+ },
359
+ async execute(args) {
360
+ const { name } = args;
361
+ const guard = guardSelfSkill(name);
362
+ if (guard) {
363
+ audit(`skill_remove name=${name} ok=false error="${guard}"`);
364
+ return JSON.stringify({ error: guard });
365
+ }
366
+ const srcDir = join(selfDir(), name);
367
+ const ts = Date.now();
368
+ const destDir = join(trashDir(), `${name}-${ts}`);
369
+ try {
370
+ mkdirSync(trashDir(), { recursive: true });
371
+ renameSync(srcDir, destDir);
372
+ } catch (err) {
373
+ const msg = err instanceof Error ? err.message : String(err);
374
+ audit(`skill_remove name=${name} ok=false error="move failed: ${msg}"`);
375
+ return JSON.stringify({ error: `Move failed: ${msg}` });
376
+ }
377
+ audit(`skill_remove name=${name} dest=${destDir} ok=true`);
378
+ logInfo(TAG, `Removed skill: self/${name} \u2192 .trash/`);
379
+ return JSON.stringify({ ok: true, message: `Skill "${name}" moved to .trash/. Will be pruned after 7 days.` });
380
+ }
381
+ };
382
+
383
+ // src/components/transport/mcp-tool.ts
384
+ init_logger();
385
+ init_log_and_swallow();
386
+ import { execFile } from "node:child_process";
387
+ import { promisify } from "node:util";
388
+ var execFileAsync = promisify(execFile);
389
+ var TAG2 = "mcp";
390
+ var daemonStarted = false;
391
+ async function ensureDaemon() {
392
+ if (daemonStarted) return;
393
+ try {
394
+ await execFileAsync("mcporter", ["daemon", "start"], { timeout: 1e4 });
395
+ daemonStarted = true;
396
+ logInfo(TAG2, "mcporter daemon started (on-demand)");
397
+ } catch {
398
+ logWarn(TAG2, "mcporter daemon start failed \u2014 calls may still work if already running");
399
+ daemonStarted = true;
400
+ }
401
+ }
402
+ var mcpTool = {
403
+ name: "mcp",
404
+ 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.",
405
+ parameters: {
406
+ type: "object",
407
+ properties: {
408
+ server: { type: "string", description: "Server name (e.g. 'pptx', 'atlassian')" },
409
+ tool: { type: "string", description: "Tool name (e.g. 'jira_search', 'create_presentation')" },
410
+ args: { type: "string", description: `Tool arguments as JSON string (e.g. '{"query": "assignee = me"}')` }
411
+ },
412
+ required: ["server", "tool"]
413
+ },
414
+ async execute(params) {
415
+ await ensureDaemon();
416
+ const { server, tool, args } = params;
417
+ const cliArgs = ["call", `${server}.${tool}`];
418
+ if (args) {
419
+ try {
420
+ const parsed = JSON.parse(args);
421
+ for (const [k, v] of Object.entries(parsed)) cliArgs.push(`${k}=${v}`);
422
+ } catch (err) {
423
+ logAndSwallow(TAG2, "JSON.parse mcp args", err);
424
+ cliArgs.push(args);
425
+ }
426
+ }
427
+ try {
428
+ const { stdout } = await execFileAsync("mcporter", cliArgs, { timeout: 3e4, encoding: "utf-8" });
429
+ return stdout;
430
+ } catch (err) {
431
+ const msg = err instanceof Error ? err.message : String(err);
432
+ return JSON.stringify({ error: `mcp call failed: ${msg}` });
433
+ }
434
+ }
435
+ };
436
+
437
+ // src/components/transport/tool-registry.ts
438
+ var TAG4 = "tool_registry";
439
+ var AUDIT_DIR = join2(process.env["ABTARS_HOME"] ?? join2(homedir2(), ".abtars"), "logs");
440
+ var AUDIT_PATH = join2(AUDIT_DIR, "audit.jsonl");
441
+ try {
442
+ mkdirSync2(AUDIT_DIR, { recursive: true });
443
+ } catch (err) {
444
+ logAndSwallow(TAG4, "mkdirSync audit dir", err);
445
+ }
446
+ function audit2(entry) {
447
+ try {
448
+ appendFileSync2(AUDIT_PATH, JSON.stringify(entry) + "\n");
449
+ } catch (err) {
450
+ logAndSwallow(TAG4, "audit write", err);
451
+ }
452
+ }
453
+ var BASH_TIMEOUT_MS = 3e5;
454
+ var CLI_TIMEOUT_MS = 6e4;
455
+ var BLOCKED_PATTERNS = [
456
+ /\bmain\.js\b/,
457
+ // node .../current/dist/main.js ...
458
+ /\babtars\.sh\b/,
459
+ // the launcher
460
+ /\bwatchdog\.sh\b/,
461
+ // the watchdog
462
+ /\blaunchctl\s+(load|bootstrap|kickstart|start)\b/
463
+ // launchd bridge start
464
+ ];
465
+ function isBridgeSpawnCommand(cmd) {
466
+ return BLOCKED_PATTERNS.some((p) => p.test(cmd));
467
+ }
468
+ function isBridgeKillCommand(cmd) {
469
+ const pid = process.pid;
470
+ const ppid = process.ppid;
471
+ if (new RegExp(`\\bkill\\s+(-\\d+\\s+)?${pid}\\b`).test(cmd)) return true;
472
+ if (new RegExp(`\\bkill\\s+(-\\d+\\s+)?${ppid}\\b`).test(cmd)) return true;
473
+ if (/\b(pkill|killall)\b.*\b(abtars|main\.js|watchdog)\b/.test(cmd)) return true;
474
+ if (/\bkill\b.*\$\(.*pgrep.*abtars/.test(cmd)) return true;
475
+ return false;
476
+ }
477
+ function runBash(cmd, timeout = BASH_TIMEOUT_MS, signal) {
478
+ const { checkCommand: checkCommand2 } = (init_guardrails(), __toCommonJS(guardrails_exports));
479
+ const cmdBlock = checkCommand2(cmd);
480
+ if (cmdBlock) {
481
+ logWarn("tool-registry", `Guardrails blocked: ${cmd.slice(0, 200)}`);
482
+ return Promise.resolve(JSON.stringify({ stderr: cmdBlock, exit_code: 126 }));
483
+ }
484
+ if (isBridgeSpawnCommand(cmd)) {
485
+ logWarn("tool-registry", `Blocked bridge-spawn command: ${cmd.slice(0, 200)}`);
486
+ return Promise.resolve(JSON.stringify({
487
+ 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.",
488
+ exit_code: 126
489
+ }));
490
+ }
491
+ if (isBridgeKillCommand(cmd)) {
492
+ logWarn("tool-registry", `Blocked bridge-kill command: ${cmd.slice(0, 200)}`);
493
+ return Promise.resolve(JSON.stringify({
494
+ 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.",
495
+ exit_code: 126
496
+ }));
497
+ }
498
+ return new Promise((resolve2) => {
499
+ const child = execFile2("bash", ["-c", cmd], { timeout, maxBuffer: 1024 * 1024 }, (err, stdout, stderr) => {
500
+ const result = {};
501
+ if (stdout) result["stdout"] = stdout.slice(0, 5e4);
502
+ if (stderr) result["stderr"] = stderr.slice(0, 1e4);
503
+ if (err) result["exit_code"] = err.code ?? 1;
504
+ else result["exit_code"] = 0;
505
+ resolve2(JSON.stringify(result));
506
+ });
507
+ if (signal) {
508
+ if (signal.aborted) {
509
+ child.kill("SIGTERM");
510
+ return;
511
+ }
512
+ const onAbort = () => {
513
+ child.kill("SIGTERM");
514
+ };
515
+ signal.addEventListener("abort", onAbort, { once: true });
516
+ child.on("exit", () => signal.removeEventListener("abort", onAbort));
517
+ }
518
+ });
519
+ }
520
+ var memoryBackend = null;
521
+ function setMemoryBackend(backend) {
522
+ memoryBackend = backend;
523
+ }
524
+ var _peerActivityCb = null;
525
+ function setPeerActivityCallback(cb) {
526
+ _peerActivityCb = cb;
527
+ }
528
+ var bashTool = {
529
+ name: "execute_bash",
530
+ 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.",
531
+ parameters: {
532
+ type: "object",
533
+ properties: { command: { type: "string", description: "The bash command to execute" } },
534
+ required: ["command"]
535
+ },
536
+ execute: (args, context) => runBash(args["command"] ?? "", BASH_TIMEOUT_MS, context?.signal)
537
+ };
538
+ var _storeCount = 0;
539
+ var STORE_CAP = 20;
540
+ function resetStoreCounter() {
541
+ _storeCount = 0;
542
+ }
543
+ var memoryStoreTool = {
544
+ name: "memory_store",
545
+ description: "Store a memory. Use after learning something about the user, their preferences, decisions, or facts worth remembering.",
546
+ parameters: {
547
+ type: "object",
548
+ properties: {
549
+ translated: { type: "string", description: "Memory content in English" },
550
+ original: { type: "string", description: "Memory content in original language (if not English)" },
551
+ type: { type: "string", enum: ["fact", "preference", "decision", "experience", "skill", "relationship", "goal"], description: "Memory type" },
552
+ emotion: { type: "integer", description: "Emotion score -5 to +5 (0=neutral)" },
553
+ confidence: { type: "integer", description: "Confidence 1-5 (3=default)" },
554
+ 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)" }
555
+ },
556
+ required: ["translated", "type"]
557
+ },
558
+ async execute(args, context) {
559
+ if (++_storeCount > STORE_CAP) {
560
+ return JSON.stringify({ stored: false, error: "Store limit reached for this session. Move to next task." });
561
+ }
562
+ if (memoryBackend) {
563
+ try {
564
+ const params = {
565
+ userId: context?.userId ?? "master",
566
+ contentEn: args["translated"] ?? "",
567
+ contentOriginal: args["original"] ?? args["translated"] ?? "",
568
+ memoryType: args["type"] ?? "fact",
569
+ emotionScore: parseInt(args["emotion"] ?? "0", 10),
570
+ confidence: parseInt(args["confidence"] ?? "3", 10),
571
+ classification: parseInt(args["classification"] ?? "1", 10)
572
+ };
573
+ const result = await memoryBackend.instantStore({ ...params, createdBy: "tool:memory_store" });
574
+ return JSON.stringify(result);
575
+ } catch (err) {
576
+ const msg = err instanceof Error ? err.message : String(err);
577
+ if (msg.includes("fts5") || msg.includes("corruption")) {
578
+ try {
579
+ memoryBackend.rebuildFtsIndexes();
580
+ logWarn("tool-registry", "FTS corruption detected \u2014 rebuilt indexes, retrying store");
581
+ const params = {
582
+ userId: context?.userId ?? "master",
583
+ contentEn: args["translated"] ?? "",
584
+ contentOriginal: args["original"] ?? args["translated"] ?? "",
585
+ memoryType: args["type"] ?? "fact",
586
+ emotionScore: parseInt(args["emotion"] ?? "0", 10),
587
+ confidence: parseInt(args["confidence"] ?? "3", 10),
588
+ classification: parseInt(args["classification"] ?? "1", 10)
589
+ };
590
+ const result = await memoryBackend.instantStore({ ...params, createdBy: "tool:memory_store" });
591
+ return JSON.stringify(result);
592
+ } catch (retryErr) {
593
+ }
594
+ }
595
+ return JSON.stringify({ error: msg });
596
+ }
597
+ }
598
+ let cmd = `abmind store --translated ${JSON.stringify(args["translated"] ?? "")} --type ${args["type"] ?? "fact"}`;
599
+ if (args["original"]) cmd += ` --original ${JSON.stringify(args["original"])}`;
600
+ if (args["emotion"]) cmd += ` --emotion-score ${args["emotion"]}`;
601
+ if (args["confidence"]) cmd += ` --confidence ${args["confidence"]}`;
602
+ if (args["classification"]) cmd += ` --classification ${args["classification"]}`;
603
+ return runBash(cmd, CLI_TIMEOUT_MS);
604
+ }
605
+ };
606
+ var memoryRecallTool = {
607
+ name: "memory_recall",
608
+ description: "Search memories by keyword or semantic query. Returns relevant stored memories.",
609
+ parameters: {
610
+ type: "object",
611
+ properties: {
612
+ query: { type: "string", description: "Search query" },
613
+ limit: { type: "integer", description: "Max results (default 10)" }
614
+ },
615
+ required: ["query"]
616
+ },
617
+ async execute(args, context) {
618
+ if (memoryBackend) {
619
+ try {
620
+ const result = await memoryBackend.recall({
621
+ translated: [args["query"] ?? ""],
622
+ original: args["query"] ?? "",
623
+ userId: context?.userId ?? "master",
624
+ limit: parseInt(args["limit"] ?? "10", 10)
625
+ });
626
+ return JSON.stringify(result);
627
+ } catch (err) {
628
+ return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });
629
+ }
630
+ }
631
+ let cmd = `abmind recall ${JSON.stringify(args["query"] ?? "")}`;
632
+ if (args["limit"]) cmd += ` --limit ${args["limit"]}`;
633
+ return runBash(cmd, CLI_TIMEOUT_MS);
634
+ }
635
+ };
636
+ var memoryEditTool = {
637
+ name: "memory_edit",
638
+ description: "Edit an existing memory by ID. Change content, type, emotion, confidence, or classification.",
639
+ parameters: {
640
+ type: "object",
641
+ properties: {
642
+ memory_id: { type: "integer", description: "Memory ID to edit" },
643
+ translated: { type: "string", description: "New English content" },
644
+ original: { type: "string", description: "New original language content" },
645
+ type: { type: "string", description: "New memory type" },
646
+ emotion: { type: "integer", description: "New emotion score" },
647
+ confidence: { type: "integer", description: "New confidence" },
648
+ classification: { type: "integer", description: "New classification" },
649
+ caller: { type: "string", enum: ["kp", "dreamy"], description: "Who is making the edit" }
650
+ },
651
+ required: ["memory_id"]
652
+ },
653
+ async execute(args) {
654
+ if (memoryBackend) {
655
+ try {
656
+ const result = await memoryBackend.editMemory({
657
+ memoryId: parseInt(args["memory_id"] ?? "0", 10),
658
+ contentEn: args["translated"],
659
+ contentOriginal: args["original"],
660
+ memoryType: args["type"],
661
+ emotionScore: args["emotion"] ? parseInt(args["emotion"], 10) : void 0,
662
+ confidence: args["confidence"] ? parseInt(args["confidence"], 10) : void 0,
663
+ classification: args["classification"] ? parseInt(args["classification"], 10) : void 0,
664
+ caller: args["caller"] ?? "kp"
665
+ });
666
+ return JSON.stringify(result);
667
+ } catch (err) {
668
+ return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });
669
+ }
670
+ }
671
+ let cmd = `abmind edit --memory-id ${args["memory_id"] ?? "0"}`;
672
+ if (args["translated"]) cmd += ` --translated ${JSON.stringify(args["translated"])}`;
673
+ if (args["original"]) cmd += ` --original ${JSON.stringify(args["original"])}`;
674
+ if (args["type"]) cmd += ` --type ${args["type"]}`;
675
+ if (args["emotion"]) cmd += ` --emotion-score ${args["emotion"]}`;
676
+ if (args["confidence"]) cmd += ` --confidence ${args["confidence"]}`;
677
+ if (args["classification"]) cmd += ` --classification ${args["classification"]}`;
678
+ if (args["caller"]) cmd += ` --caller ${args["caller"]}`;
679
+ return runBash(cmd, CLI_TIMEOUT_MS);
680
+ }
681
+ };
682
+ var webBrowseTool = {
683
+ name: "web_browse",
684
+ description: "Browse a URL or perform a complex multi-step web task. For quick lookups use execute_bash with curl.",
685
+ parameters: {
686
+ type: "object",
687
+ properties: {
688
+ task: { type: "string", description: "What to do on the web" },
689
+ chat_id: { type: "string", description: "Chat ID for result delivery" },
690
+ engine: { type: "string", enum: ["patchright"], description: "Browser engine (default: patchright)" }
691
+ },
692
+ required: ["task", "chat_id"]
693
+ },
694
+ execute: (args) => {
695
+ let cmd = `abtars-browse --task ${JSON.stringify(args["task"] ?? "")} --chat-id ${args["chat_id"] ?? "0"}`;
696
+ if (args["engine"]) cmd += ` --engine ${args["engine"]}`;
697
+ return runBash(cmd, CLI_TIMEOUT_MS);
698
+ }
699
+ };
700
+ var todoTool = {
701
+ name: "todo_manage",
702
+ description: "Manage TODO items. Add, complete, or list tasks.",
703
+ parameters: {
704
+ type: "object",
705
+ properties: {
706
+ action: { type: "string", enum: ["add", "done", "list", "remove"], description: "Action to perform" },
707
+ text: { type: "string", description: "TODO text (for add)" },
708
+ id: { type: "string", description: "TODO ID (for done/remove)" }
709
+ },
710
+ required: ["action"]
711
+ },
712
+ execute: (args) => {
713
+ const action = args["action"] ?? "list";
714
+ if (action === "add") return runBash(`abtars-todo add ${JSON.stringify(args["text"] ?? "")}`, CLI_TIMEOUT_MS);
715
+ if (action === "done") return runBash(`abtars-todo done ${args["id"] ?? ""}`, CLI_TIMEOUT_MS);
716
+ if (action === "remove") return runBash(`abtars-todo remove ${args["id"] ?? ""}`, CLI_TIMEOUT_MS);
717
+ return runBash("abtars-todo list", CLI_TIMEOUT_MS);
718
+ }
719
+ };
720
+ var _enqueueCron = null;
721
+ function setEnqueueCron(fn) {
722
+ _enqueueCron = fn;
723
+ }
724
+ var _ircSend = null;
725
+ function setIrcSend(fn) {
726
+ _ircSend = fn;
727
+ }
728
+ function setSecretGetDb(_db) {
729
+ }
730
+ var _sendDocument = null;
731
+ function setSendDocument(fn) {
732
+ _sendDocument = fn;
733
+ }
734
+ var sendDocumentTool = {
735
+ name: "send_document",
736
+ 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.",
737
+ parameters: {
738
+ type: "object",
739
+ properties: {
740
+ path: { type: "string", description: "Absolute path to the file" },
741
+ caption: { type: "string", description: "Optional short caption (\u22641024 chars)" }
742
+ },
743
+ required: ["path"]
744
+ },
745
+ execute: async (args) => {
746
+ const path = args["path"];
747
+ if (!path) return JSON.stringify({ error: "path is required" });
748
+ if (!_sendDocument) return JSON.stringify({ error: "Telegram not configured (sendDocument unavailable)" });
749
+ try {
750
+ const messageId = await _sendDocument(path, args["caption"]);
751
+ return JSON.stringify({ ok: true, message_id: messageId });
752
+ } catch (err) {
753
+ return JSON.stringify({ error: err instanceof Error ? err.message : String(err) });
754
+ }
755
+ }
756
+ };
757
+ var taskTool = {
758
+ name: "task_manage",
759
+ 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).",
760
+ parameters: {
761
+ type: "object",
762
+ properties: {
763
+ action: { type: "string", enum: ["add", "list", "remove", "pause", "resume", "run"], description: "Action" },
764
+ message: { type: "string", description: "Task message/command (for add)" },
765
+ schedule: { type: "string", description: "Cron schedule expression (for add)" },
766
+ type: { type: "string", enum: ["reminder", "script", "agent"], description: "Task type (for add)" },
767
+ chat_id: { type: "string", description: "Chat ID (for add)" },
768
+ id: { type: "string", description: "Task ID (for remove/pause/resume/run)" }
769
+ },
770
+ required: ["action"]
771
+ },
772
+ execute: (args) => {
773
+ const action = args["action"] ?? "list";
774
+ if (action === "list") return runBash("abtars-task list", CLI_TIMEOUT_MS);
775
+ if (action === "remove") return runBash(`abtars-task remove ${args["id"] ?? ""}`, CLI_TIMEOUT_MS);
776
+ if (action === "pause") return runBash(`abtars-task pause ${args["id"] ?? ""}`, CLI_TIMEOUT_MS);
777
+ if (action === "resume") return runBash(`abtars-task resume ${args["id"] ?? ""}`, CLI_TIMEOUT_MS);
778
+ if (action === "run") {
779
+ if (!_enqueueCron) return Promise.resolve(JSON.stringify({ error: "enqueueCron not available" }));
780
+ const err = _enqueueCron(args["id"] ?? "", true);
781
+ return Promise.resolve(JSON.stringify(err ? { error: err } : { ok: true, message: `Task ${args["id"]} enqueued for immediate execution` }));
782
+ }
783
+ let cmd = `abtars-task add --message ${JSON.stringify(args["message"] ?? "")}`;
784
+ if (args["schedule"]) cmd += ` --schedule ${JSON.stringify(args["schedule"])}`;
785
+ if (args["type"]) cmd += ` --type ${args["type"]}`;
786
+ if (args["chat_id"]) cmd += ` --chat-id ${args["chat_id"]}`;
787
+ return runBash(cmd, CLI_TIMEOUT_MS);
788
+ }
789
+ };
790
+ var peerSessionTool = {
791
+ name: "peer_session",
792
+ 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.",
793
+ parameters: {
794
+ type: "object",
795
+ properties: {
796
+ peer_name: { type: "string", description: "Name of the peer (as in peers.json)" },
797
+ message: { type: "string", description: "Your message to the peer" },
798
+ session_id: { type: "string", description: "Session ID from previous call (omit for new conversation)" }
799
+ },
800
+ required: ["peer_name", "message"]
801
+ },
802
+ async execute(args) {
803
+ const { callPeer } = await import("./peer-client-52XYMNI7.js");
804
+ const { loadPeerConfig } = await import("./peer-config-VK6EDLN5.js");
805
+ const { getOrCreateSession, addTurn, isEnded, destroySession } = await import("./peer-sessions-EAXTNQ36.js");
806
+ const peerName = args.peer_name?.trim();
807
+ const message = args.message?.trim();
808
+ if (!peerName || !message) return JSON.stringify({ error: "peer_name and message required" });
809
+ const config = loadPeerConfig();
810
+ if (peerName === config.self.name) return JSON.stringify({ error: "Cannot chat with yourself" });
811
+ if (!config.peers[peerName]) return JSON.stringify({ error: `Unknown peer: ${peerName}` });
812
+ const session = getOrCreateSession(args.session_id?.trim() || void 0, peerName);
813
+ if (session.messages.length >= 20) {
814
+ destroySession(session.id);
815
+ return JSON.stringify({ session_id: session.id, response: "[SESSION_END] Turn limit reached.", ended: true, reason: "max-turns" });
816
+ }
817
+ addTurn(session, "user", message);
818
+ const prompt = session.messages.map((m) => `${m.role === "user" ? "You" : "Peer"}: ${m.content}`).join("\n") + "\n\nRespond to the latest message.";
819
+ try {
820
+ const response = await callPeer(peerName, prompt, config.maxHops);
821
+ addTurn(session, "assistant", response);
822
+ _peerActivityCb?.(`\u{1F916} Agents: ${config.self.name} \u2194 ${peerName} session. [turn ${session.messages.length}]`);
823
+ const { ended, reason } = isEnded(session, response);
824
+ if (ended) destroySession(session.id);
825
+ return JSON.stringify({ session_id: session.id, response, ended, reason });
826
+ } catch (err) {
827
+ destroySession(session.id);
828
+ return JSON.stringify({ error: `peer_session failed: ${err instanceof Error ? err.message : String(err)}`, session_id: session.id, ended: true });
829
+ }
830
+ }
831
+ };
832
+ var peerWakeupTool = {
833
+ name: "peer_wakeup",
834
+ 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.",
835
+ parameters: {
836
+ type: "object",
837
+ properties: {
838
+ peer_name: { type: "string", description: "Name of the peer to wake up (as in peers.json)" }
839
+ },
840
+ required: ["peer_name"]
841
+ },
842
+ async execute(args) {
843
+ const { sendWakeup } = await import("./dns-wakeup-27M7D2MR.js");
844
+ const { loadPeerConfig } = await import("./peer-config-VK6EDLN5.js");
845
+ const peerName = args.peer_name?.trim();
846
+ if (!peerName) return JSON.stringify({ error: "peer_name required" });
847
+ const config = loadPeerConfig();
848
+ const peer = config.peers[peerName];
849
+ if (!peer) return JSON.stringify({ error: `Unknown peer: ${peerName}` });
850
+ const udpPort = peer.udpPort ?? 5353;
851
+ sendWakeup(config.self.name, peer.host, udpPort, peer.token);
852
+ return JSON.stringify({ ok: true, message: `Wake-up sent to ${peerName}. Expect callback within seconds.` });
853
+ }
854
+ };
855
+ var ircSendTool = {
856
+ name: "irc_send",
857
+ description: "Send a message to an IRC channel (e.g. #bridges)",
858
+ parameters: {
859
+ channel: { type: "string", description: "IRC channel (e.g. #bridges)" },
860
+ message: { type: "string", description: "Message text to send" }
861
+ },
862
+ execute: async (args) => {
863
+ if (!_ircSend) return JSON.stringify({ error: "IRC adapter not connected" });
864
+ const channel = args["channel"] ?? "";
865
+ const message = args["message"] ?? "";
866
+ if (!channel || !message) return JSON.stringify({ error: "channel and message are required" });
867
+ _ircSend(channel, message);
868
+ return JSON.stringify({ ok: true, channel, sent: message.length + " chars" });
869
+ }
870
+ };
871
+ var secretGetTool = {
872
+ name: "secret_get",
873
+ 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.",
874
+ parameters: {
875
+ properties: {
876
+ name: { type: "string", description: "Exact filename in secret/ dir (e.g. 'OPENROUTER_API_KEY', 'x-cookies.json')" }
877
+ },
878
+ required: ["name"]
879
+ },
880
+ execute: async (args) => {
881
+ const name = args.name?.trim();
882
+ if (!name) return JSON.stringify({ error: "name is required" });
883
+ try {
884
+ const { join: join3 } = await import("node:path");
885
+ const { homedir: homedir3 } = await import("node:os");
886
+ const { readFileSync: readFileSync2, existsSync: existsSync2 } = await import("node:fs");
887
+ const { createDecipheriv, hkdfSync } = await import("node:crypto");
888
+ const { loadKey } = await import("abmind");
889
+ const secretPath = join3(homedir3(), ".abtars", "secret", name);
890
+ if (!existsSync2(secretPath)) return JSON.stringify({ error: `secret '${name}' not found` });
891
+ const raw = readFileSync2(secretPath, "utf-8").trim();
892
+ if (!raw) return JSON.stringify({ error: `secret '${name}' is empty` });
893
+ let value;
894
+ if (raw.startsWith("ENC:")) {
895
+ const master = loadKey();
896
+ const key = Buffer.from(hkdfSync("sha256", master, "", "abtars-secrets-files-v1", 32));
897
+ const buf = Buffer.from(raw.slice(4), "base64");
898
+ const d = createDecipheriv("aes-256-gcm", key, buf.subarray(1, 13));
899
+ d.setAuthTag(buf.subarray(buf.length - 16));
900
+ value = d.update(buf.subarray(13, buf.length - 16), void 0, "utf-8") + d.final("utf-8");
901
+ } else {
902
+ value = raw;
903
+ }
904
+ if (!name.includes(".")) {
905
+ process.env[name] = value;
906
+ return JSON.stringify({ ok: true, env_var: `$${name}`, hint: `Use $${name} in commands. NEVER print or echo the value.` });
907
+ }
908
+ return JSON.stringify({ ok: true, content: value });
909
+ } catch (err) {
910
+ return JSON.stringify({ error: `secret_get failed: ${err instanceof Error ? err.message : String(err)}` });
911
+ }
912
+ }
913
+ };
914
+ var ALL_TOOLS = [bashTool, memoryStoreTool, memoryRecallTool, memoryEditTool, webBrowseTool, todoTool, taskTool, sendDocumentTool, peerSessionTool, peerWakeupTool, ircSendTool, secretGetTool, skillCreateTool, skillUpdateTool, skillPatchTool, skillRemoveTool, mcpTool, ...getDelegationTools()];
915
+ function getToolDefinitions() {
916
+ return ALL_TOOLS;
917
+ }
918
+ function getToolSchemas(policy) {
919
+ const tools = policy ? ALL_TOOLS.filter((t) => checkTool(t.name, policy).allowed) : ALL_TOOLS;
920
+ return tools.map((t) => ({
921
+ type: "function",
922
+ function: { name: t.name, description: t.description, parameters: t.parameters }
923
+ }));
924
+ }
925
+ function checkSkillRead(toolName, args) {
926
+ if (toolName !== "execute_bash") return;
927
+ const cmd = args["command"] ?? "";
928
+ if (cmd.includes("/.abtars/skills/") && cmd.includes("/SKILL.md")) {
929
+ const match = cmd.match(/\/.abtars\/skills\/[^/]+\/([^/]+)\/SKILL\.md/);
930
+ if (match) bumpRead(match[1]);
931
+ }
932
+ }
933
+ async function executeToolCall(name, args, context) {
934
+ if (context?.sandboxPolicy) {
935
+ const toolCheck = checkTool(name, context.sandboxPolicy);
936
+ if (!toolCheck.allowed) {
937
+ const available = ALL_TOOLS.filter((t) => checkTool(t.name, context.sandboxPolicy).allowed).map((t) => t.name);
938
+ auditDeny(name, void 0, "session", toolCheck.reason);
939
+ return JSON.stringify({ error: `Tool '${name}' not available in this session`, available_tools: available, reason: "peer_sandbox" });
940
+ }
941
+ const filePath = args["path"] ?? args["file_path"];
942
+ if (filePath) {
943
+ const mode = name.includes("read") || name === "memory_recall" ? "read" : "write";
944
+ const pathCheck = checkPath(filePath, mode, context.sandboxPolicy);
945
+ if (!pathCheck.allowed) {
946
+ auditDeny(name, filePath, "session", pathCheck.reason);
947
+ return JSON.stringify({ error: pathCheck.reason, reason: "peer_sandbox" });
948
+ }
949
+ }
950
+ }
951
+ const tool = ALL_TOOLS.find((t) => t.name === name);
952
+ if (!tool) return JSON.stringify({ error: `Unknown tool: ${name}` });
953
+ const ts = Date.now();
954
+ const storeClass = name === "abmind_store" || name === "memory_store" ? parseInt(args.classification ?? args.class ?? "1", 10) : 0;
955
+ const auditArgs = storeClass >= 2 ? `{"class":${storeClass},"[REDACTED]":true}` : redactSecrets(JSON.stringify(args));
956
+ audit2({ ts, tool: name, args: auditArgs, userId: context?.userId });
957
+ try {
958
+ const result = await tool.execute(args, context);
959
+ audit2({ ts, tool: name, status: "ok", chars: result.length });
960
+ checkSkillRead(name, args);
961
+ return result;
962
+ } catch (err) {
963
+ audit2({ ts, tool: name, status: "error", error: err instanceof Error ? err.message : String(err) });
964
+ throw err;
965
+ }
966
+ }
967
+
968
+ export {
969
+ isBridgeSpawnCommand,
970
+ setMemoryBackend,
971
+ setPeerActivityCallback,
972
+ resetStoreCounter,
973
+ setEnqueueCron,
974
+ setIrcSend,
975
+ setSecretGetDb,
976
+ setSendDocument,
977
+ getToolDefinitions,
978
+ getToolSchemas,
979
+ executeToolCall
980
+ };
981
+ //# sourceMappingURL=chunk-VVEDVGCR.js.map