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,11 @@
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
+ ModelHealthRegistry,
4
+ classifyError
5
+ } from "./chunk-2XU2X4OI.js";
6
+ import "./chunk-NWDBD4PA.js";
7
+ export {
8
+ ModelHealthRegistry,
9
+ classifyError
10
+ };
11
+ //# sourceMappingURL=model-health-registry-35LQNVQR.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
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
+ sendNotification
4
+ } from "./chunk-AZJIODTQ.js";
5
+ import "./chunk-FMWKEPM7.js";
6
+ import "./chunk-JCJS4ZIB.js";
7
+ import "./chunk-BUUVFUPO.js";
8
+ import "./chunk-X76UX47U.js";
9
+ import "./chunk-NWDBD4PA.js";
10
+ export {
11
+ sendNotification
12
+ };
13
+ //# sourceMappingURL=notification-Y5S5MMLV.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
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
+ getEnv,
4
+ init_env_schema
5
+ } from "./chunk-JCJS4ZIB.js";
6
+ import "./chunk-BUUVFUPO.js";
7
+ import "./chunk-X76UX47U.js";
8
+ import "./chunk-NWDBD4PA.js";
9
+
10
+ // src/components/openrouter-credits.ts
11
+ init_env_schema();
12
+ async function fetchOpenRouterCredits() {
13
+ const apiKey = getEnv().getApiKey("OPENROUTER_API_KEY");
14
+ if (!apiKey) return null;
15
+ try {
16
+ const res = await fetch("https://openrouter.ai/api/v1/credits", {
17
+ headers: { Authorization: `Bearer ${apiKey}` },
18
+ signal: AbortSignal.timeout(5e3)
19
+ });
20
+ if (!res.ok) return null;
21
+ const data = await res.json();
22
+ const purchased = data.data?.total_credits ?? 0;
23
+ const used = data.data?.total_usage ?? 0;
24
+ return { purchased, used, remaining: purchased - used };
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+ export {
30
+ fetchOpenRouterCredits
31
+ };
32
+ //# sourceMappingURL=openrouter-credits-EDY7ETAU.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/openrouter-credits.ts"],
4
+ "sourcesContent": ["/**\n * openrouter-credits.ts \u2014 Fetch OpenRouter account credits via API.\n */\nimport { getEnv } from \"./env-schema.js\";\n\nexport interface OpenRouterCredits {\n purchased: number;\n used: number;\n remaining: number;\n}\n\nexport async function fetchOpenRouterCredits(): Promise<OpenRouterCredits | null> {\n const apiKey = getEnv().getApiKey(\"OPENROUTER_API_KEY\");\n if (!apiKey) return null;\n try {\n const res = await fetch(\"https://openrouter.ai/api/v1/credits\", {\n headers: { Authorization: `Bearer ${apiKey}` },\n signal: AbortSignal.timeout(5000),\n });\n if (!res.ok) return null;\n const data = await res.json() as { data?: { total_credits?: number; total_usage?: number } };\n const purchased = data.data?.total_credits ?? 0;\n const used = data.data?.total_usage ?? 0;\n return { purchased, used, remaining: purchased - used };\n } catch { return null; }\n}\n"],
5
+ "mappings": ";;;;;;;;;;AAGA;AAQA,eAAsB,yBAA4D;AAChF,QAAM,SAAS,OAAO,EAAE,UAAU,oBAAoB;AACtD,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,wCAAwC;AAAA,MAC9D,SAAS,EAAE,eAAe,UAAU,MAAM,GAAG;AAAA,MAC7C,QAAQ,YAAY,QAAQ,GAAI;AAAA,IAClC,CAAC;AACD,QAAI,CAAC,IAAI,GAAI,QAAO;AACpB,UAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAM,YAAY,KAAK,MAAM,iBAAiB;AAC9C,UAAM,OAAO,KAAK,MAAM,eAAe;AACvC,WAAO,EAAE,WAAW,MAAM,WAAW,YAAY,KAAK;AAAA,EACxD,QAAQ;AAAE,WAAO;AAAA,EAAM;AACzB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,133 @@
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 "./chunk-NWDBD4PA.js";
3
+
4
+ // src/cli/commands/passwd.ts
5
+ import { createInterface } from "node:readline";
6
+ import { existsSync, readFileSync, writeFileSync, readdirSync, statSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { homedir } from "node:os";
9
+ import { createDecipheriv, createCipheriv, randomBytes, hkdfSync } from "node:crypto";
10
+ function ask(rl, question) {
11
+ return new Promise((resolve) => rl.question(question, resolve));
12
+ }
13
+ async function passwd() {
14
+ const { deriveFromPassphrase, writeKeyVerify, validateKey, loadKeyFromFile, _resetKeyCache } = await import("abmind");
15
+ const { writeToKeyring } = await import("abmind");
16
+ const keyFile = join(homedir(), ".abmind", "secret", "abmind.key");
17
+ const verifyFile = join(homedir(), ".abmind", "secret", "key.verify");
18
+ const secretDir = join(homedir(), ".abtars", "secret");
19
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
20
+ try {
21
+ const username = await ask(rl, "Username (same on all machines): ");
22
+ if (!username.trim()) {
23
+ console.error("Username cannot be empty.");
24
+ return 1;
25
+ }
26
+ let oldKey;
27
+ const oldPass = await ask(rl, "Current passphrase (empty = migrate from key file): ");
28
+ if (oldPass) {
29
+ oldKey = deriveFromPassphrase(oldPass, username.trim());
30
+ if (!existsSync(verifyFile)) {
31
+ console.error("No key.verify file \u2014 cannot validate passphrase. Run migration with empty old passphrase first.");
32
+ return 1;
33
+ }
34
+ if (!validateKey(oldKey)) {
35
+ console.error("Wrong passphrase.");
36
+ return 1;
37
+ }
38
+ } else {
39
+ if (!existsSync(keyFile)) {
40
+ console.error(`No key file at ${keyFile} and no passphrase. Run 'abtars install' first.`);
41
+ return 1;
42
+ }
43
+ oldKey = loadKeyFromFile(keyFile);
44
+ }
45
+ const newPass = await ask(rl, "New passphrase (min 6 chars): ");
46
+ if (newPass.length < 6) {
47
+ console.error("Too short.");
48
+ return 1;
49
+ }
50
+ const confirm = await ask(rl, "Confirm: ");
51
+ if (newPass !== confirm) {
52
+ console.error("Mismatch.");
53
+ return 1;
54
+ }
55
+ const newKey = deriveFromPassphrase(newPass, username.trim());
56
+ let dbCount = 0;
57
+ try {
58
+ const memDir = process.env["ABMIND_HOME"] ?? join(homedir(), ".abmind");
59
+ const dbPath = join(memDir, "memory", "memory.db");
60
+ if (existsSync(dbPath)) {
61
+ const oldDbKey = Buffer.from(hkdfSync("sha256", oldKey, "", "abmind-secrets-v1", 32));
62
+ const newDbKey = Buffer.from(hkdfSync("sha256", newKey, "", "abmind-secrets-v1", 32));
63
+ const { loadNative } = await import("abmind");
64
+ const Database = loadNative("better-sqlite3");
65
+ const db = new Database(dbPath, { readonly: false });
66
+ const rows = db.prepare("SELECT id, content_en FROM extracted_memories WHERE classification = 3").all();
67
+ const update = db.prepare("UPDATE extracted_memories SET content_en = ? WHERE id = ?");
68
+ for (const row of rows) {
69
+ try {
70
+ const buf = Buffer.from(row.content_en, "base64");
71
+ const iv = buf.subarray(0, 12);
72
+ const tag = buf.subarray(buf.length - 16);
73
+ const ct = buf.subarray(12, buf.length - 16);
74
+ const d = createDecipheriv("aes-256-gcm", oldDbKey, iv);
75
+ d.setAuthTag(tag);
76
+ const plain = d.update(ct, void 0, "utf-8") + d.final("utf-8");
77
+ const newIv = randomBytes(12);
78
+ const c = createCipheriv("aes-256-gcm", newDbKey, newIv);
79
+ const enc = Buffer.concat([c.update(plain, "utf-8"), c.final()]);
80
+ update.run(Buffer.concat([newIv, enc, c.getAuthTag()]).toString("base64"), row.id);
81
+ dbCount++;
82
+ } catch {
83
+ }
84
+ }
85
+ db.close();
86
+ }
87
+ } catch {
88
+ }
89
+ let fileCount = 0;
90
+ if (existsSync(secretDir)) {
91
+ const oldPurpose = Buffer.from(hkdfSync("sha256", oldKey, "", "abtars-secrets-files-v1", 32));
92
+ const newPurpose = Buffer.from(hkdfSync("sha256", newKey, "", "abtars-secrets-files-v1", 32));
93
+ for (const f of readdirSync(secretDir)) {
94
+ const fp = join(secretDir, f);
95
+ if (statSync(fp).isDirectory()) continue;
96
+ const raw = readFileSync(fp, "utf-8").trim();
97
+ if (!raw.startsWith("ENC:")) continue;
98
+ try {
99
+ const buf = Buffer.from(raw.slice(4), "base64");
100
+ const iv = buf.subarray(1, 13);
101
+ const tag = buf.subarray(buf.length - 16);
102
+ const ct = buf.subarray(13, buf.length - 16);
103
+ const d = createDecipheriv("aes-256-gcm", oldPurpose, iv);
104
+ d.setAuthTag(tag);
105
+ const plain = d.update(ct, void 0, "utf-8") + d.final("utf-8");
106
+ const newIv = randomBytes(12);
107
+ const c = createCipheriv("aes-256-gcm", newPurpose, newIv);
108
+ const enc = Buffer.concat([c.update(plain, "utf-8"), c.final()]);
109
+ const blob = "ENC:" + Buffer.concat([Buffer.from([1]), newIv, enc, c.getAuthTag()]).toString("base64");
110
+ writeFileSync(fp, blob, { mode: 384 });
111
+ fileCount++;
112
+ } catch {
113
+ }
114
+ }
115
+ }
116
+ _resetKeyCache();
117
+ writeFileSync(keyFile, newKey.toString("hex") + "\n", { mode: 384 });
118
+ writeKeyVerify(newKey);
119
+ const stored = writeToKeyring(newPass);
120
+ console.log(`\u2713 Done. ${dbCount} memories + ${fileCount} secrets re-encrypted.`);
121
+ console.log(`
122
+ ABMIND_KEY=${newKey.toString("hex")}`);
123
+ if (stored) console.log("\u2713 Passphrase stored in OS keyring.");
124
+ else console.log("Set ABMIND_KEY as OS env var for daemon mode.");
125
+ return 0;
126
+ } finally {
127
+ rl.close();
128
+ }
129
+ }
130
+ export {
131
+ passwd
132
+ };
133
+ //# sourceMappingURL=passwd-RRFV4CC5.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/cli/commands/passwd.ts"],
4
+ "sourcesContent": ["/**\n * abtars passwd \u2014 set or change encryption passphrase (#607).\n *\n * - Empty old passphrase = migration from key file\n * - Non-empty old passphrase = password change\n * Re-encrypts: abmind DB memories + ~/.abtars/secret/ files.\n */\n\nimport { createInterface } from \"node:readline\";\nimport { existsSync, readFileSync, writeFileSync, readdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { createDecipheriv, createCipheriv, randomBytes, hkdfSync } from \"node:crypto\";\n\nfunction ask(rl: ReturnType<typeof createInterface>, question: string): Promise<string> {\n return new Promise(resolve => rl.question(question, resolve));\n}\n\nexport async function passwd(): Promise<number> {\n const { deriveFromPassphrase, writeKeyVerify, validateKey, loadKeyFromFile, _resetKeyCache } = await import(\"abmind\");\n const { writeToKeyring } = await import(\"abmind\");\n\n const keyFile = join(homedir(), \".abmind\", \"secret\", \"abmind.key\");\n const verifyFile = join(homedir(), \".abmind\", \"secret\", \"key.verify\");\n const secretDir = join(homedir(), \".abtars\", \"secret\");\n\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n try {\n // Username\n const username = await ask(rl, \"Username (same on all machines): \");\n if (!username.trim()) { console.error(\"Username cannot be empty.\"); return 1; }\n\n // Old key: from passphrase or from file\n let oldKey: Buffer;\n const oldPass = await ask(rl, \"Current passphrase (empty = migrate from key file): \");\n if (oldPass) {\n oldKey = deriveFromPassphrase(oldPass, username.trim());\n if (!existsSync(verifyFile)) {\n console.error(\"No key.verify file \u2014 cannot validate passphrase. Run migration with empty old passphrase first.\"); return 1;\n }\n if (!validateKey(oldKey)) {\n console.error(\"Wrong passphrase.\"); return 1;\n }\n } else {\n if (!existsSync(keyFile)) { console.error(`No key file at ${keyFile} and no passphrase. Run 'abtars install' first.`); return 1; }\n oldKey = loadKeyFromFile(keyFile);\n }\n\n // New passphrase\n const newPass = await ask(rl, \"New passphrase (min 6 chars): \");\n if (newPass.length < 6) { console.error(\"Too short.\"); return 1; }\n const confirm = await ask(rl, \"Confirm: \");\n if (newPass !== confirm) { console.error(\"Mismatch.\"); return 1; }\n\n const newKey = deriveFromPassphrase(newPass, username.trim());\n\n // Re-encrypt DB memories\n let dbCount = 0;\n try {\n const memDir = process.env[\"ABMIND_HOME\"] ?? join(homedir(), \".abmind\");\n const dbPath = join(memDir, \"memory\", \"memory.db\");\n if (existsSync(dbPath)) {\n const oldDbKey = Buffer.from(hkdfSync(\"sha256\", oldKey, \"\", \"abmind-secrets-v1\", 32));\n const newDbKey = Buffer.from(hkdfSync(\"sha256\", newKey, \"\", \"abmind-secrets-v1\", 32));\n const { loadNative } = await import(\"abmind\");\n const Database = loadNative(\"better-sqlite3\") as any;\n const db = new Database(dbPath, { readonly: false });\n const rows = db.prepare(\"SELECT id, content_en FROM extracted_memories WHERE classification = 3\").all() as Array<{ id: number; content_en: string }>;\n const update = db.prepare(\"UPDATE extracted_memories SET content_en = ? WHERE id = ?\");\n for (const row of rows) {\n try {\n const buf = Buffer.from(row.content_en, \"base64\");\n const iv = buf.subarray(0, 12);\n const tag = buf.subarray(buf.length - 16);\n const ct = buf.subarray(12, buf.length - 16);\n const d = createDecipheriv(\"aes-256-gcm\", oldDbKey, iv);\n d.setAuthTag(tag);\n const plain = d.update(ct, undefined, \"utf-8\") + d.final(\"utf-8\");\n const newIv = randomBytes(12);\n const c = createCipheriv(\"aes-256-gcm\", newDbKey, newIv);\n const enc = Buffer.concat([c.update(plain, \"utf-8\"), c.final()]);\n update.run(Buffer.concat([newIv, enc, c.getAuthTag()]).toString(\"base64\"), row.id);\n dbCount++;\n } catch { /* skip */ }\n }\n db.close();\n }\n } catch { /* DB not available */ }\n\n // Re-encrypt file-based secrets\n let fileCount = 0;\n if (existsSync(secretDir)) {\n const oldPurpose = Buffer.from(hkdfSync(\"sha256\", oldKey, \"\", \"abtars-secrets-files-v1\", 32));\n const newPurpose = Buffer.from(hkdfSync(\"sha256\", newKey, \"\", \"abtars-secrets-files-v1\", 32));\n for (const f of readdirSync(secretDir)) {\n const fp = join(secretDir, f);\n if (statSync(fp).isDirectory()) continue;\n const raw = readFileSync(fp, \"utf-8\").trim();\n if (!raw.startsWith(\"ENC:\")) continue;\n try {\n const buf = Buffer.from(raw.slice(4), \"base64\");\n const iv = buf.subarray(1, 13);\n const tag = buf.subarray(buf.length - 16);\n const ct = buf.subarray(13, buf.length - 16);\n const d = createDecipheriv(\"aes-256-gcm\", oldPurpose, iv);\n d.setAuthTag(tag);\n const plain = d.update(ct, undefined, \"utf-8\") + d.final(\"utf-8\");\n const newIv = randomBytes(12);\n const c = createCipheriv(\"aes-256-gcm\", newPurpose, newIv);\n const enc = Buffer.concat([c.update(plain, \"utf-8\"), c.final()]);\n const blob = \"ENC:\" + Buffer.concat([Buffer.from([0x01]), newIv, enc, c.getAuthTag()]).toString(\"base64\");\n writeFileSync(fp, blob, { mode: 0o600 });\n fileCount++;\n } catch { /* skip */ }\n }\n }\n\n // Finalize \u2014 write key file + key.verify atomically\n _resetKeyCache();\n writeFileSync(keyFile, newKey.toString(\"hex\") + \"\\n\", { mode: 0o600 });\n writeKeyVerify(newKey);\n const stored = writeToKeyring(newPass);\n\n console.log(`\u2713 Done. ${dbCount} memories + ${fileCount} secrets re-encrypted.`);\n console.log(`\\nABMIND_KEY=${newKey.toString(\"hex\")}`);\n if (stored) console.log(\"\u2713 Passphrase stored in OS keyring.\");\n else console.log(\"Set ABMIND_KEY as OS env var for daemon mode.\");\n return 0;\n } finally { rl.close(); }\n}\n"],
5
+ "mappings": ";;;;AAQA,SAAS,uBAAuB;AAChC,SAAS,YAAY,cAAc,eAAe,aAAa,gBAAgB;AAC/E,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,kBAAkB,gBAAgB,aAAa,gBAAgB;AAExE,SAAS,IAAI,IAAwC,UAAmC;AACtF,SAAO,IAAI,QAAQ,aAAW,GAAG,SAAS,UAAU,OAAO,CAAC;AAC9D;AAEA,eAAsB,SAA0B;AAC9C,QAAM,EAAE,sBAAsB,gBAAgB,aAAa,iBAAiB,eAAe,IAAI,MAAM,OAAO,QAAQ;AACpH,QAAM,EAAE,eAAe,IAAI,MAAM,OAAO,QAAQ;AAEhD,QAAM,UAAU,KAAK,QAAQ,GAAG,WAAW,UAAU,YAAY;AACjE,QAAM,aAAa,KAAK,QAAQ,GAAG,WAAW,UAAU,YAAY;AACpE,QAAM,YAAY,KAAK,QAAQ,GAAG,WAAW,QAAQ;AAErD,QAAM,KAAK,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC3E,MAAI;AAEF,UAAM,WAAW,MAAM,IAAI,IAAI,mCAAmC;AAClE,QAAI,CAAC,SAAS,KAAK,GAAG;AAAE,cAAQ,MAAM,2BAA2B;AAAG,aAAO;AAAA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 -0,0 +1,17 @@
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
+ abtarsHome,
4
+ ensureDir,
5
+ init_paths,
6
+ reportsDir,
7
+ setLazyRoots
8
+ } from "./chunk-X76UX47U.js";
9
+ import "./chunk-NWDBD4PA.js";
10
+ init_paths();
11
+ export {
12
+ abtarsHome,
13
+ ensureDir,
14
+ reportsDir,
15
+ setLazyRoots
16
+ };
17
+ //# sourceMappingURL=paths-G33RZWZ7.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,156 @@
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
+ init_peer_jwt,
4
+ peer_jwt_exports
5
+ } from "./chunk-RVE2N7FA.js";
6
+ import {
7
+ init_peer_config,
8
+ loadPeerConfig
9
+ } from "./chunk-W6FAL35D.js";
10
+ import "./chunk-2UPU3OW6.js";
11
+ import "./chunk-FMWKEPM7.js";
12
+ import {
13
+ init_logger,
14
+ logInfo
15
+ } from "./chunk-BUUVFUPO.js";
16
+ import "./chunk-X76UX47U.js";
17
+ import {
18
+ __require,
19
+ __toCommonJS
20
+ } from "./chunk-NWDBD4PA.js";
21
+
22
+ // src/components/peer-client.ts
23
+ init_peer_config();
24
+ init_logger();
25
+ import { request as httpsRequest } from "node:https";
26
+ var TAG = "peer-client";
27
+ var _currentHops = null;
28
+ function setCurrentPeerHops(hops) {
29
+ _currentHops = hops;
30
+ }
31
+ function getCurrentPeerHops() {
32
+ return _currentHops;
33
+ }
34
+ var PeerCallError = class extends Error {
35
+ constructor(code, message) {
36
+ super(message);
37
+ this.code = code;
38
+ this.name = "PeerCallError";
39
+ }
40
+ };
41
+ async function callPeer(peerName, prompt, hops, opts) {
42
+ const config = loadPeerConfig();
43
+ const peerKey = Object.keys(config.peers).find((k) => k.toLowerCase() === peerName.toLowerCase());
44
+ const peer = peerKey ? config.peers[peerKey] : void 0;
45
+ if (!peer) {
46
+ const available = Object.keys(config.peers).join(", ") || "(none)";
47
+ throw new PeerCallError("unknown_peer", `Unknown peer '${peerName}'. Available: ${available}`);
48
+ }
49
+ let signedPrompt = prompt;
50
+ if (config.self.signingKey) {
51
+ const { signMessage } = await import("./digital-signature-OFCGSHWO.js");
52
+ const { tag } = signMessage(config.self.signingKey, config.self.name, peerName, prompt);
53
+ signedPrompt = `${prompt} ${tag}`;
54
+ }
55
+ const start = Date.now();
56
+ try {
57
+ const response = await postCompletion(peer, peerName, signedPrompt, hops, config.timeoutMs, config.self.name);
58
+ logInfo(TAG, `PEER_CALL ${peerName} \u2014 ${prompt.length}ch \u2192 ${response.length}ch (${Date.now() - start}ms, hops=${hops})`);
59
+ return response;
60
+ } catch (err) {
61
+ if (err instanceof PeerCallError && (err.code === "unreachable" || err.code === "timeout") && peer.udpPort && !opts?.skipWakeup) {
62
+ logInfo(TAG, `Direct call failed (${err.code}) \u2014 UDP callback request \u2192 ${peerKey}`);
63
+ const { registerPending, rejectPending } = await import("./pending-callback-RIMQZ7FJ.js");
64
+ const { sendWakeup } = await import("./dns-wakeup-27M7D2MR.js");
65
+ const resultPromise = registerPending(peerKey, signedPrompt);
66
+ sendWakeup(peerKey, peer.host, peer.udpPort, peer.token);
67
+ const timeout = setTimeout(() => rejectPending(peerKey, "callback timeout (60s)"), 6e4);
68
+ try {
69
+ const answer = await resultPromise;
70
+ clearTimeout(timeout);
71
+ logInfo(TAG, `PEER_CALL ${peerName} (via callback) \u2014 ${prompt.length}ch \u2192 ${answer.length}ch (${Date.now() - start}ms)`);
72
+ return answer;
73
+ } catch (cbErr) {
74
+ clearTimeout(timeout);
75
+ throw new PeerCallError("timeout", `Callback failed: ${cbErr instanceof Error ? cbErr.message : String(cbErr)}`);
76
+ }
77
+ }
78
+ throw err;
79
+ }
80
+ }
81
+ function postCompletion(peer, peerName, prompt, hops, timeoutMs, selfName) {
82
+ const { signJwt } = (init_peer_jwt(), __toCommonJS(peer_jwt_exports));
83
+ const now = Math.floor(Date.now() / 1e3);
84
+ const jwt = signJwt({ iss: selfName, aud: peerName, iat: now, exp: now + 60 }, peer.token);
85
+ const body = JSON.stringify({
86
+ model: "default",
87
+ messages: [{ role: "user", content: prompt }]
88
+ });
89
+ return new Promise((resolve, reject) => {
90
+ const useTls = !!(peer.certFingerprint || peer.certPem);
91
+ const requestFn = useTls ? httpsRequest : __require("node:http").request;
92
+ const tlsOpts = useTls ? {
93
+ minVersion: "TLSv1.3",
94
+ rejectUnauthorized: true,
95
+ ...peer.certPem ? { ca: [peer.certPem] } : {},
96
+ checkServerIdentity: (_hostname, cert) => {
97
+ if (peer.certFingerprint && cert.fingerprint256 !== peer.certFingerprint) {
98
+ return new Error(`Cert fingerprint mismatch: expected ${peer.certFingerprint}, got ${cert.fingerprint256}`);
99
+ }
100
+ return void 0;
101
+ }
102
+ } : {};
103
+ const req = requestFn({
104
+ hostname: peer.host,
105
+ port: peer.port,
106
+ path: "/v1/chat/completions",
107
+ method: "POST",
108
+ headers: {
109
+ "Content-Type": "application/json",
110
+ "Content-Length": Buffer.byteLength(body),
111
+ "Authorization": `Bearer ${jwt}`,
112
+ "X-Peer-Hops": String(hops)
113
+ },
114
+ timeout: timeoutMs,
115
+ ...tlsOpts
116
+ }, (res) => {
117
+ let data = "";
118
+ res.on("data", (c) => data += c);
119
+ res.on("end", () => {
120
+ if (res.statusCode === 401 || res.statusCode === 403) {
121
+ reject(new PeerCallError("auth_failed", `Peer rejected auth (${res.statusCode})`));
122
+ return;
123
+ }
124
+ if (res.statusCode === 429 || res.statusCode === 508) {
125
+ reject(new PeerCallError("hop_exceeded", `Peer refused \u2014 hop limit reached`));
126
+ return;
127
+ }
128
+ if (res.statusCode && res.statusCode >= 400) {
129
+ reject(new PeerCallError("peer_error", `Peer returned ${res.statusCode}: ${data.slice(0, 200)}`));
130
+ return;
131
+ }
132
+ try {
133
+ const parsed = JSON.parse(data);
134
+ const content = parsed?.choices?.[0]?.message?.content ?? "";
135
+ resolve(content);
136
+ } catch {
137
+ reject(new PeerCallError("peer_error", `Peer returned non-JSON: ${data.slice(0, 100)}`));
138
+ }
139
+ });
140
+ });
141
+ req.on("timeout", () => {
142
+ req.destroy();
143
+ reject(new PeerCallError("timeout", `Peer '${peer.host}:${peer.port}' timed out (${timeoutMs}ms)`));
144
+ });
145
+ req.on("error", (err) => reject(new PeerCallError("unreachable", `Peer unreachable: ${err.message}`)));
146
+ req.write(body);
147
+ req.end();
148
+ });
149
+ }
150
+ export {
151
+ PeerCallError,
152
+ callPeer,
153
+ getCurrentPeerHops,
154
+ setCurrentPeerHops
155
+ };
156
+ //# sourceMappingURL=peer-client-52XYMNI7.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/peer-client.ts"],
4
+ "sourcesContent": ["/**\n * peer-client.ts \u2014 HTTP client for peer_session tool (#392).\n * POST /v1/chat/completions with bearer + X-Peer-Hops.\n */\n\nimport { request as httpsRequest } from \"node:https\";\nimport { loadPeerConfig, type PeerEntry } from \"./peer-config.js\";\nimport { logInfo } from \"./logger.js\";\n\nconst TAG = \"peer-client\";\n\nexport type PeerError = \"timeout\" | \"unreachable\" | \"hop_exceeded\" | \"auth_failed\" | \"peer_error\" | \"unknown_peer\";\n\n/**\n * Module-level hop budget for the current request. Set by agent-api-server\n * before dispatching a prompt that came with X-Peer-Hops. Read by peer_session\n * tool to know what hops value to forward. Safe in single-threaded Node\n * because agent-api-server processes one prompt at a time per session.\n */\nlet _currentHops: number | null = null;\nexport function setCurrentPeerHops(hops: number | null): void { _currentHops = hops; }\nexport function getCurrentPeerHops(): number | null { return _currentHops; }\n\nexport class PeerCallError extends Error {\n constructor(public readonly code: PeerError, message: string) {\n super(message);\n this.name = \"PeerCallError\";\n }\n}\n\n/**\n * Call a peer's /v1/chat/completions endpoint.\n * @param peerName \u2014 key in peers.json\n * @param prompt \u2014 user message to send\n * @param hops \u2014 remaining hop budget (decremented before sending)\n */\nexport async function callPeer(peerName: string, prompt: string, hops: number, opts?: { skipWakeup?: boolean }): Promise<string> {\n const config = loadPeerConfig();\n const peerKey = Object.keys(config.peers).find(k => k.toLowerCase() === peerName.toLowerCase());\n const peer = peerKey ? config.peers[peerKey] : undefined;\n if (!peer) {\n const available = Object.keys(config.peers).join(\", \") || \"(none)\";\n throw new PeerCallError(\"unknown_peer\", `Unknown peer '${peerName}'. Available: ${available}`);\n }\n\n // Sign outgoing message if we have a signing key (#416)\n let signedPrompt = prompt;\n if (config.self.signingKey) {\n const { signMessage } = await import(\"./digital-signature.js\");\n const { tag } = signMessage(config.self.signingKey, config.self.name, peerName, prompt);\n signedPrompt = `${prompt} ${tag}`;\n }\n\n const start = Date.now();\n try {\n const response = await postCompletion(peer, peerName, signedPrompt, hops, config.timeoutMs, config.self.name);\n logInfo(TAG, `PEER_CALL ${peerName} \u2014 ${prompt.length}ch \u2192 ${response.length}ch (${Date.now() - start}ms, hops=${hops})`);\n return response;\n } catch (err) {\n if (err instanceof PeerCallError && (err.code === \"unreachable\" || err.code === \"timeout\") && peer.udpPort && !opts?.skipWakeup) {\n logInfo(TAG, `Direct call failed (${err.code}) \u2014 UDP callback request \u2192 ${peerKey}`);\n const { registerPending, rejectPending } = await import(\"./pending-callback.js\");\n const { sendWakeup } = await import(\"./dns-wakeup.js\");\n const resultPromise = registerPending(peerKey!, signedPrompt);\n sendWakeup(peerKey!, peer.host, peer.udpPort, peer.token);\n // Wait up to 60s for the peer to call back with the answer\n const timeout = setTimeout(() => rejectPending(peerKey!, \"callback timeout (60s)\"), 60000);\n try {\n const answer = await resultPromise;\n clearTimeout(timeout);\n logInfo(TAG, `PEER_CALL ${peerName} (via callback) \u2014 ${prompt.length}ch \u2192 ${answer.length}ch (${Date.now() - start}ms)`);\n return answer;\n } catch (cbErr) {\n clearTimeout(timeout);\n throw new PeerCallError(\"timeout\", `Callback failed: ${cbErr instanceof Error ? cbErr.message : String(cbErr)}`);\n }\n }\n throw err;\n }\n}\n\nfunction postCompletion(peer: PeerEntry, peerName: string, prompt: string, hops: number, timeoutMs: number, selfName: string): Promise<string> {\n const { signJwt } = require(\"./peer-jwt.js\") as typeof import(\"./peer-jwt.js\");\n const now = Math.floor(Date.now() / 1000);\n const jwt = signJwt({ iss: selfName, aud: peerName, iat: now, exp: now + 60 }, peer.token);\n\n const body = JSON.stringify({\n model: \"default\",\n messages: [{ role: \"user\", content: prompt }],\n });\n\n return new Promise((resolve, reject) => {\n const useTls = !!(peer.certFingerprint || peer.certPem);\n const requestFn = useTls ? httpsRequest : require(\"node:http\").request;\n\n const tlsOpts = useTls ? {\n minVersion: \"TLSv1.3\" as const,\n rejectUnauthorized: true,\n ...(peer.certPem ? { ca: [peer.certPem] } : {}),\n checkServerIdentity: (_hostname: string, cert: { fingerprint256?: string }) => {\n if (peer.certFingerprint && cert.fingerprint256 !== peer.certFingerprint) {\n return new Error(`Cert fingerprint mismatch: expected ${peer.certFingerprint}, got ${cert.fingerprint256}`);\n }\n return undefined;\n },\n } : {};\n\n const req = requestFn({\n hostname: peer.host,\n port: peer.port,\n path: \"/v1/chat/completions\",\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Content-Length\": Buffer.byteLength(body),\n \"Authorization\": `Bearer ${jwt}`,\n \"X-Peer-Hops\": String(hops),\n },\n timeout: timeoutMs,\n ...tlsOpts,\n } as any, (res: any) => {\n let data = \"\";\n res.on(\"data\", (c: any) => data += c);\n res.on(\"end\", () => {\n if (res.statusCode === 401 || res.statusCode === 403) {\n reject(new PeerCallError(\"auth_failed\", `Peer rejected auth (${res.statusCode})`));\n return;\n }\n if (res.statusCode === 429 || res.statusCode === 508) {\n reject(new PeerCallError(\"hop_exceeded\", `Peer refused \u2014 hop limit reached`));\n return;\n }\n if (res.statusCode && res.statusCode >= 400) {\n reject(new PeerCallError(\"peer_error\", `Peer returned ${res.statusCode}: ${data.slice(0, 200)}`));\n return;\n }\n try {\n const parsed = JSON.parse(data);\n const content = parsed?.choices?.[0]?.message?.content ?? \"\";\n resolve(content);\n } catch {\n reject(new PeerCallError(\"peer_error\", `Peer returned non-JSON: ${data.slice(0, 100)}`));\n }\n });\n });\n req.on(\"timeout\", () => { req.destroy(); reject(new PeerCallError(\"timeout\", `Peer '${peer.host}:${peer.port}' timed out (${timeoutMs}ms)`)); });\n req.on(\"error\", (err: Error) => reject(new PeerCallError(\"unreachable\", `Peer unreachable: ${err.message}`)));\n req.write(body);\n req.end();\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAMA;AACA;AAFA,SAAS,WAAW,oBAAoB;AAIxC,IAAM,MAAM;AAUZ,IAAI,eAA8B;AAC3B,SAAS,mBAAmB,MAA2B;AAAE,iBAAe;AAAM;AAC9E,SAAS,qBAAoC;AAAE,SAAO;AAAc;AAEpE,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAA4B,MAAiB,SAAiB;AAC5D,UAAM,OAAO;AADa;AAE1B,SAAK,OAAO;AAAA,EACd;AACF;AAQA,eAAsB,SAAS,UAAkB,QAAgB,MAAc,MAAkD;AAC/H,QAAM,SAAS,eAAe;AAC9B,QAAM,UAAU,OAAO,KAAK,OAAO,KAAK,EAAE,KAAK,OAAK,EAAE,YAAY,MAAM,SAAS,YAAY,CAAC;AAC9F,QAAM,OAAO,UAAU,OAAO,MAAM,OAAO,IAAI;AAC/C,MAAI,CAAC,MAAM;AACT,UAAM,YAAY,OAAO,KAAK,OAAO,KAAK,EAAE,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C;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
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
+ clearPeerConfigCache,
4
+ init_peer_config,
5
+ loadPeerConfig
6
+ } from "./chunk-W6FAL35D.js";
7
+ import "./chunk-2UPU3OW6.js";
8
+ import "./chunk-BUUVFUPO.js";
9
+ import "./chunk-X76UX47U.js";
10
+ import "./chunk-NWDBD4PA.js";
11
+ init_peer_config();
12
+ export {
13
+ clearPeerConfigCache,
14
+ loadPeerConfig
15
+ };
16
+ //# sourceMappingURL=peer-config-VK6EDLN5.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,49 @@
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 "./chunk-NWDBD4PA.js";
3
+
4
+ // src/components/peer-sessions.ts
5
+ var sessions = /* @__PURE__ */ new Map();
6
+ var MAX_TURNS = 10;
7
+ var TTL_MS = 5 * 60 * 1e3;
8
+ function getOrCreateSession(sessionId, peerName) {
9
+ if (sessionId && sessions.has(sessionId)) {
10
+ const s = sessions.get(sessionId);
11
+ s.lastActivityAt = Date.now();
12
+ return s;
13
+ }
14
+ const id = sessionId ?? `pc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
15
+ const session = { id, peerName, messages: [], createdAt: Date.now(), lastActivityAt: Date.now() };
16
+ sessions.set(id, session);
17
+ return session;
18
+ }
19
+ function addTurn(session, role, content) {
20
+ session.messages.push({ role, content });
21
+ session.lastActivityAt = Date.now();
22
+ }
23
+ function isEnded(session, response) {
24
+ if (/\[NO-REPLY\]/i.test(response) || /\[END\]/i.test(response)) return { ended: true, reason: "peer-signal" };
25
+ if (session.messages.length >= MAX_TURNS * 2) return { ended: true, reason: "max-turns" };
26
+ return { ended: false };
27
+ }
28
+ function destroySession(id) {
29
+ sessions.delete(id);
30
+ }
31
+ function cleanupExpired() {
32
+ const now = Date.now();
33
+ let cleaned = 0;
34
+ for (const [id, s] of sessions) {
35
+ if (now - s.lastActivityAt > TTL_MS) {
36
+ sessions.delete(id);
37
+ cleaned++;
38
+ }
39
+ }
40
+ return cleaned;
41
+ }
42
+ export {
43
+ addTurn,
44
+ cleanupExpired,
45
+ destroySession,
46
+ getOrCreateSession,
47
+ isEnded
48
+ };
49
+ //# sourceMappingURL=peer-sessions-EAXTNQ36.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/peer-sessions.ts"],
4
+ "sourcesContent": ["/**\n * peer-sessions.ts \u2014 in-memory multi-turn peer chat sessions (#428).\n * Sessions expire after 5 min idle. Max 10 turns. No persistence.\n */\n\nexport interface PeerChatSession {\n id: string;\n peerName: string;\n messages: Array<{ role: \"user\" | \"assistant\"; content: string }>;\n createdAt: number;\n lastActivityAt: number;\n}\n\nconst sessions = new Map<string, PeerChatSession>();\nconst MAX_TURNS = 10;\nconst TTL_MS = 5 * 60 * 1000;\n\nexport function getOrCreateSession(sessionId: string | undefined, peerName: string): PeerChatSession {\n if (sessionId && sessions.has(sessionId)) {\n const s = sessions.get(sessionId)!;\n s.lastActivityAt = Date.now();\n return s;\n }\n const id = sessionId ?? `pc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;\n const session: PeerChatSession = { id, peerName, messages: [], createdAt: Date.now(), lastActivityAt: Date.now() };\n sessions.set(id, session);\n return session;\n}\n\nexport function addTurn(session: PeerChatSession, role: \"user\" | \"assistant\", content: string): void {\n session.messages.push({ role, content });\n session.lastActivityAt = Date.now();\n}\n\nexport function isEnded(session: PeerChatSession, response: string): { ended: boolean; reason?: string } {\n if (/\\[NO-REPLY\\]/i.test(response) || /\\[END\\]/i.test(response)) return { ended: true, reason: \"peer-signal\" };\n if (session.messages.length >= MAX_TURNS * 2) return { ended: true, reason: \"max-turns\" };\n return { ended: false };\n}\n\nexport function destroySession(id: string): void {\n sessions.delete(id);\n}\n\n// Cleanup expired sessions (called from heartbeat or lazily)\nexport function cleanupExpired(): number {\n const now = Date.now();\n let cleaned = 0;\n for (const [id, s] of sessions) {\n if (now - s.lastActivityAt > TTL_MS) { sessions.delete(id); cleaned++; }\n }\n return cleaned;\n}\n"],
5
+ "mappings": ";;;;AAaA,IAAM,WAAW,oBAAI,IAA6B;AAClD,IAAM,YAAY;AAClB,IAAM,SAAS,IAAI,KAAK;AAEjB,SAAS,mBAAmB,WAA+B,UAAmC;AACnG,MAAI,aAAa,SAAS,IAAI,SAAS,GAAG;AACxC,UAAM,IAAI,SAAS,IAAI,SAAS;AAChC,MAAE,iBAAiB,KAAK,IAAI;AAC5B,WAAO;AAAA,EACT;AACA,QAAM,KAAK,aAAa,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC/F,QAAM,UAA2B,EAAE,IAAI,UAAU,UAAU,CAAC,GAAG,WAAW,KAAK,IAAI,GAAG,gBAAgB,KAAK,IAAI,EAAE;AACjH,WAAS,IAAI,IAAI,OAAO;AACxB,SAAO;AACT;AAEO,SAAS,QAAQ,SAA0B,MAA4B,SAAuB;AACnG,UAAQ,SAAS,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,UAAQ,iBAAiB,KAAK,IAAI;AACpC;AAEO,SAAS,QAAQ,SAA0B,UAAuD;AACvG,MAAI,gBAAgB,KAAK,QAAQ,KAAK,WAAW,KAAK,QAAQ,EAAG,QAAO,EAAE,OAAO,MAAM,QAAQ,cAAc;AAC7G,MAAI,QAAQ,SAAS,UAAU,YAAY,EAAG,QAAO,EAAE,OAAO,MAAM,QAAQ,YAAY;AACxF,SAAO,EAAE,OAAO,MAAM;AACxB;AAEO,SAAS,eAAe,IAAkB;AAC/C,WAAS,OAAO,EAAE;AACpB;AAGO,SAAS,iBAAyB;AACvC,QAAM,MAAM,KAAK,IAAI;AACrB,MAAI,UAAU;AACd,aAAW,CAAC,IAAI,CAAC,KAAK,UAAU;AAC9B,QAAI,MAAM,EAAE,iBAAiB,QAAQ;AAAE,eAAS,OAAO,EAAE;AAAG;AAAA,IAAW;AAAA,EACzE;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,40 @@
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 "./chunk-NWDBD4PA.js";
3
+
4
+ // src/components/pending-callback.ts
5
+ var pending = /* @__PURE__ */ new Map();
6
+ function registerPending(peerName, prompt) {
7
+ if (pending.has(peerName)) pending.get(peerName).reject(new Error("superseded"));
8
+ return new Promise((resolve, reject) => {
9
+ pending.set(peerName.toLowerCase(), { prompt, resolve, reject });
10
+ });
11
+ }
12
+ function hasPending(peerName) {
13
+ return pending.has(peerName.toLowerCase());
14
+ }
15
+ function popPendingPrompt(peerName) {
16
+ const entry = pending.get(peerName.toLowerCase());
17
+ if (!entry) return null;
18
+ return entry.prompt;
19
+ }
20
+ function resolvePending(peerName, answer) {
21
+ const entry = pending.get(peerName.toLowerCase());
22
+ if (!entry) return false;
23
+ pending.delete(peerName.toLowerCase());
24
+ entry.resolve(answer);
25
+ return true;
26
+ }
27
+ function rejectPending(peerName, reason) {
28
+ const entry = pending.get(peerName.toLowerCase());
29
+ if (!entry) return;
30
+ pending.delete(peerName.toLowerCase());
31
+ entry.reject(new Error(reason));
32
+ }
33
+ export {
34
+ hasPending,
35
+ popPendingPrompt,
36
+ registerPending,
37
+ rejectPending,
38
+ resolvePending
39
+ };
40
+ //# sourceMappingURL=pending-callback-RIMQZ7FJ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/pending-callback.ts"],
4
+ "sourcesContent": ["/**\n * pending-callback.ts \u2014 Store pending prompts for callback-based A2A (#451).\n * When direct peer_session fails, the prompt is stored here. When the peer calls back,\n * agent-api-server returns the pending prompt instead of LLM-processing.\n */\n\ntype PendingEntry = { prompt: string; resolve: (answer: string) => void; reject: (err: Error) => void };\n\nconst pending = new Map<string, PendingEntry>();\n\n/** Store a pending prompt and return a promise that resolves when the answer arrives. */\nexport function registerPending(peerName: string, prompt: string): Promise<string> {\n // Clear any stale entry\n if (pending.has(peerName)) pending.get(peerName)!.reject(new Error(\"superseded\"));\n return new Promise((resolve, reject) => {\n pending.set(peerName.toLowerCase(), { prompt, resolve, reject });\n });\n}\n\n/** Check if there's a pending prompt for this peer. */\nexport function hasPending(peerName: string): boolean {\n return pending.has(peerName.toLowerCase());\n}\n\n/** Get and remove the pending prompt (peer called back). */\nexport function popPendingPrompt(peerName: string): string | null {\n const entry = pending.get(peerName.toLowerCase());\n if (!entry) return null;\n return entry.prompt;\n}\n\n/** Deliver the answer (peer sent the response back). */\nexport function resolvePending(peerName: string, answer: string): boolean {\n const entry = pending.get(peerName.toLowerCase());\n if (!entry) return false;\n pending.delete(peerName.toLowerCase());\n entry.resolve(answer);\n return true;\n}\n\n/** Timeout \u2014 reject the pending promise. */\nexport function rejectPending(peerName: string, reason: string): void {\n const entry = pending.get(peerName.toLowerCase());\n if (!entry) return;\n pending.delete(peerName.toLowerCase());\n entry.reject(new Error(reason));\n}\n"],
5
+ "mappings": ";;;;AAQA,IAAM,UAAU,oBAAI,IAA0B;AAGvC,SAAS,gBAAgB,UAAkB,QAAiC;AAEjF,MAAI,QAAQ,IAAI,QAAQ,EAAG,SAAQ,IAAI,QAAQ,EAAG,OAAO,IAAI,MAAM,YAAY,CAAC;AAChF,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,YAAQ,IAAI,SAAS,YAAY,GAAG,EAAE,QAAQ,SAAS,OAAO,CAAC;AAAA,EACjE,CAAC;AACH;AAGO,SAAS,WAAW,UAA2B;AACpD,SAAO,QAAQ,IAAI,SAAS,YAAY,CAAC;AAC3C;AAGO,SAAS,iBAAiB,UAAiC;AAChE,QAAM,QAAQ,QAAQ,IAAI,SAAS,YAAY,CAAC;AAChD,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,MAAM;AACf;AAGO,SAAS,eAAe,UAAkB,QAAyB;AACxE,QAAM,QAAQ,QAAQ,IAAI,SAAS,YAAY,CAAC;AAChD,MAAI,CAAC,MAAO,QAAO;AACnB,UAAQ,OAAO,SAAS,YAAY,CAAC;AACrC,QAAM,QAAQ,MAAM;AACpB,SAAO;AACT;AAGO,SAAS,cAAc,UAAkB,QAAsB;AACpE,QAAM,QAAQ,QAAQ,IAAI,SAAS,YAAY,CAAC;AAChD,MAAI,CAAC,MAAO;AACZ,UAAQ,OAAO,SAAS,YAAY,CAAC;AACrC,QAAM,OAAO,IAAI,MAAM,MAAM,CAAC;AAChC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,22 @@
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
+ buildTransport,
4
+ phaseTransport,
5
+ rebuildTransport
6
+ } from "./chunk-6UCRKRWR.js";
7
+ import "./chunk-BSSBCSCL.js";
8
+ import "./chunk-X6TERNVJ.js";
9
+ import "./chunk-GST5T3WZ.js";
10
+ import "./chunk-CEVRHKJY.js";
11
+ import "./chunk-M6VBAPNT.js";
12
+ import "./chunk-FMWKEPM7.js";
13
+ import "./chunk-JCJS4ZIB.js";
14
+ import "./chunk-BUUVFUPO.js";
15
+ import "./chunk-X76UX47U.js";
16
+ import "./chunk-NWDBD4PA.js";
17
+ export {
18
+ buildTransport,
19
+ phaseTransport,
20
+ rebuildTransport
21
+ };
22
+ //# sourceMappingURL=phase-transport-KYERDL2O.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }