@noxsoft/anima 2.0.3 → 2.0.4

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 (405) hide show
  1. package/README.md +1260 -28
  2. package/dist/{accounts-CP1IAWeM.js → accounts-D8CPKNkN.js} +3 -3
  3. package/dist/{acp-cli-0JY_DUDb.js → acp-cli-ByK6lS6c.js} +14 -14
  4. package/dist/{acp-cli-BUGHeckb.js → acp-cli-CaQCjIw4.js} +1 -1
  5. package/dist/{agent-eLix7YLB.js → agent-BgIkqd3F.js} +3 -3
  6. package/dist/{agent-DwTJ59DW.js → agent-N5BDcge4.js} +17 -17
  7. package/dist/{agent-events-COLRhRBH.js → agent-events-COH7NDW2.js} +2 -2
  8. package/dist/{agent-scope-OZi7lb8S.js → agent-scope-DZgptr9J.js} +4 -4
  9. package/dist/{agent-scope-CcE0DhlL.js → agent-scope-cj2QCT6R.js} +3 -3
  10. package/dist/{agents-D57WX9dn.js → agents-NEudYMdg.js} +16 -16
  11. package/dist/{agents.config-Dvo2ULxs.js → agents.config-Bujs-NIy.js} +2 -2
  12. package/dist/{audit-BvPmfYxY.js → audit-C-UJhfdv.js} +5 -5
  13. package/dist/{audit-CmL_VKW9.js → audit-CeCO7SK5.js} +21 -21
  14. package/dist/{auth-lZ26wsbN.js → auth-DMPZWzEa.js} +3 -3
  15. package/dist/{auth-choice-DbU0S_0Q.js → auth-choice-5VnaGMD-.js} +4 -4
  16. package/dist/{auth-choice-8JX4OqDS.js → auth-choice-DA2k4vs8.js} +9 -9
  17. package/dist/{auth-health-CeDOBbt0.js → auth-health-B7FqA26_.js} +1 -1
  18. package/dist/{auth-profiles-BVZBTuls.js → auth-profiles-BDrNYX_n.js} +12 -12
  19. package/dist/{auth-profiles-CC3TFfvS.js → auth-profiles-CxSHydjn.js} +4 -4
  20. package/dist/{banner-DDcACdvK.js → banner-BtDZPRzi.js} +1 -1
  21. package/dist/{browser-cli-BZ38kv8Y.js → browser-cli-8yQMpxb8.js} +3 -3
  22. package/dist/{browser-cli-CYOmCXxE.js → browser-cli-Czg3JtDH.js} +18 -18
  23. package/dist/build-info.json +3 -3
  24. package/dist/bundled/boot-md/handler.js +15 -15
  25. package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
  26. package/dist/bundled/command-logger/handler.js +1 -1
  27. package/dist/bundled/session-memory/handler.js +5 -5
  28. package/dist/{call-CTMQygkz.js → call-BIzCaKZb.js} +6 -6
  29. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  30. package/dist/{catalog-BAayBt1L.js → catalog-DMfEg-oK.js} +2 -2
  31. package/dist/{channel-options-M44Z9-3q.js → channel-options-BrtCtyrT.js} +3 -3
  32. package/dist/{channel-selection-DfGpCyh2.js → channel-selection-Bbm1lq3P.js} +2 -2
  33. package/dist/{channel-web-Q-STsf5N.js → channel-web-DrsT6OAE.js} +4 -4
  34. package/dist/{channels-cli-zIOBobe6.js → channels-cli-Juyh1S6n.js} +74 -74
  35. package/dist/{channels-cli-SPO9rJnF.js → channels-cli-zNvi1m5c.js} +20 -20
  36. package/dist/{channels-status-issues-DBc1pU_R.js → channels-status-issues-CqzqshW4.js} +1 -1
  37. package/dist/{chrome-DlcCwfo_.js → chrome-C4dOMO8z.js} +3 -3
  38. package/dist/{chrome-mUDT-mA5.js → chrome-DdcDzAtH.js} +11 -11
  39. package/dist/{chunk-mxPVo000.js → chunk-D2nLsrEW.js} +3 -3
  40. package/dist/{clack-prompter-B0kl7shw.js → clack-prompter-BI3RDW5w.js} +4 -4
  41. package/dist/{clack-prompter-Ct2BYIXW.js → clack-prompter-Dwr1m_IZ.js} +3 -3
  42. package/dist/cli/daemon-cli.js +1 -1
  43. package/dist/cli-C3cpDaz8.js +99 -0
  44. package/dist/{cli-AYZaZSSx.js → cli-CjWUGdGC.js} +7 -7
  45. package/dist/{cli-session-CqlE2JFo.js → cli-session-BVjY_XrW.js} +1 -1
  46. package/dist/{cli-session-C70q07GT.js → cli-session-gtuYN2Iq.js} +23 -23
  47. package/dist/{client-C1avc0vD.js → client-Dswwze5_.js} +4 -4
  48. package/dist/{clipboard-BbGnZskJ.js → clipboard-BZKS9O1u.js} +1 -1
  49. package/dist/{command-registry-CSbw6FZC.js → command-registry-BBvNvysr.js} +13 -13
  50. package/dist/{commands-D7CbOdcS.js → commands-AZ3n8Y2c.js} +6 -6
  51. package/dist/{commands-D5PGoVW4.js → commands-BMnD_QRY.js} +6 -6
  52. package/dist/{commands-registry-sLFieXCB.js → commands-registry-cFqZ6Ib4.js} +2 -2
  53. package/dist/{common-D6bu0zHC.js → common-DJbnT8ws.js} +2 -2
  54. package/dist/{completion-cli-_SwCoFq6.js → completion-cli-BADRBcIl.js} +4 -4
  55. package/dist/{completion-cli-BFdiNmVD.js → completion-cli-DMQgiObF.js} +1 -1
  56. package/dist/{config-BeuAT94o.js → config-CU-Axg8P.js} +5 -5
  57. package/dist/{config-cli-DhdAhW1h.js → config-cli-BPlbwiuA.js} +9 -9
  58. package/dist/{config-cli-NqEQjCzV.js → config-cli-DXgZJkPU.js} +1 -1
  59. package/dist/{config-guard-B1rmR88x.js → config-guard-Ba49JNds.js} +4 -4
  60. package/dist/{config-guard-BCUt7Re8.js → config-guard-Cu0qMKZJ.js} +4 -4
  61. package/dist/{config-C96685Kz.js → config-kVVm5EYV.js} +34 -34
  62. package/dist/{config-sync-CoIIbEOe.js → config-sync-CzLnLTXt.js} +2 -2
  63. package/dist/{config-sync-DvAttep0.js → config-sync-DuydxPWx.js} +2 -2
  64. package/dist/{configure-B2vlJbd2.js → configure-CHgacLyi.js} +14 -14
  65. package/dist/{configure-FENKo5hf.js → configure-DfHXDa1L.js} +21 -21
  66. package/dist/{context-ChaAWbwZ.js → context-DzgXOckU.js} +3 -3
  67. package/dist/{control-service-DXYImShH.js → control-service-8_wKHwBa.js} +4 -4
  68. package/dist/{control-service-X_1FRl7x.js → control-service-BtL1Jto_.js} +2 -2
  69. package/dist/{cron-cli-ByPSA5ZE.js → cron-cli-BCzSR2c0.js} +19 -19
  70. package/dist/{cron-cli-B6jMeNqC.js → cron-cli-CCWNkykU.js} +1 -1
  71. package/dist/{daemon-cli-CKOoYhs-.js → daemon-cli-Bjkbu9Vy.js} +21 -21
  72. package/dist/{daemon-cli-Bf0Q00vC.js → daemon-cli-CmlHcC1J.js} +9 -9
  73. package/dist/{daemon-runtime-cglglYsH.js → daemon-runtime-rUTqCVwJ.js} +4 -4
  74. package/dist/{deliver-DujkDzqg.js → deliver-CePITOl8.js} +15 -15
  75. package/dist/{deliver-DiIOZFml.js → deliver-DFnVaetP.js} +8 -8
  76. package/dist/{deps-Bim542L5.js → deps-CeEKhrp7.js} +1 -1
  77. package/dist/{devices-cli-BbUrME_U.js → devices-cli-DQrDMrZH.js} +1 -1
  78. package/dist/{devices-cli-qvEFBnyH.js → devices-cli-Oe-A1Dv0.js} +12 -12
  79. package/dist/{diagnostics-DlIw6fqD.js → diagnostics-DxMFrBLO.js} +1 -1
  80. package/dist/{diagnostics-BCxobJaf.js → diagnostics-m79ZlMmZ.js} +1 -1
  81. package/dist/{directory-cli-VreWAdNS.js → directory-cli-BL6h8cGF.js} +2 -2
  82. package/dist/{directory-cli-BjnpktnO.js → directory-cli-Cjgmi_sj.js} +14 -14
  83. package/dist/{dispatcher-DbDPyVIX.js → dispatcher-DAFbQM-c.js} +1 -1
  84. package/dist/{dispatcher-CoqsaA3f.js → dispatcher-DNd40gUn.js} +2 -2
  85. package/dist/dist-CqDI82ei.js +929 -0
  86. package/dist/dist-DnHRxR5U.js +929 -0
  87. package/dist/{dns-cli-B-lWrEam.js → dns-cli-CFtV3BXK.js} +2 -2
  88. package/dist/{dns-cli-CRKIrBD6.js → dns-cli-NyIHvQ5S.js} +10 -10
  89. package/dist/{dock-Dmxj3en_.js → dock-BdXLb5oY.js} +4 -4
  90. package/dist/{docs-cli-Bn-mDvE1.js → docs-cli-D_cmJDSr.js} +7 -7
  91. package/dist/{doctor-DdOw46pE.js → doctor-BpGxKrBl.js} +23 -23
  92. package/dist/{doctor-CeIWEOAK.js → doctor-D12wNQPU.js} +41 -41
  93. package/dist/{doctor-completion-CBANZ9T9.js → doctor-completion-DeOfofek.js} +4 -4
  94. package/dist/{doctor-completion-aDHxGApN.js → doctor-completion-DwjqdEcK.js} +2 -2
  95. package/dist/{doctor-config-flow-Dxjx2igu.js → doctor-config-flow-BI3mpkbd.js} +9 -9
  96. package/dist/{doctor-config-flow-Bb8TQwYh.js → doctor-config-flow-wMHheFkC.js} +2 -2
  97. package/dist/{engine-B9avUJL5.js → engine-BCtL-AMw.js} +5 -5
  98. package/dist/{engine-BiUQ25D4.js → engine-Bk_UT413.js} +5 -5
  99. package/dist/entry.js +1 -1
  100. package/dist/{exec-tTxVr8zb.js → exec-B7sUS164.js} +17 -17
  101. package/dist/{exec-approvals-CdLmKX2R.js → exec-approvals-CroGJRUg.js} +2 -2
  102. package/dist/{exec-approvals-cli-5-h9moQI.js → exec-approvals-cli-BTxF_RsH.js} +6 -6
  103. package/dist/{exec-approvals-cli-Cne9mMrK.js → exec-approvals-cli-n1gyGwH2.js} +19 -19
  104. package/dist/{frontmatter-YijVi0FQ.js → frontmatter-BmHq0vRD.js} +2 -2
  105. package/dist/{gateway-cli-DboOVUi8.js → gateway-cli-DDBadlrS.js} +128 -128
  106. package/dist/{gateway-cli-BZpKEMGi.js → gateway-cli-IZNkOMBe.js} +62 -62
  107. package/dist/{gateway-rpc-C3eniXwh.js → gateway-rpc-L2PVSqGj.js} +3 -3
  108. package/dist/{github-copilot-auth-AdaPw_fF.js → github-copilot-auth-DKyqDaGU.js} +2 -2
  109. package/dist/{github-copilot-auth-C2cJr55I.js → github-copilot-auth-DXpOMSd3.js} +3 -3
  110. package/dist/{gmail-setup-utils-BPo_LkKI.js → gmail-setup-utils-BKNczIJ9.js} +3 -3
  111. package/dist/{health-CdHDOLo6.js → health-Bm8ZTvC3.js} +4 -4
  112. package/dist/{health-WvhhwAnn.js → health-DUf1gt4E.js} +17 -17
  113. package/dist/{health-format-CdP99j3Y.js → health-format-uzh1xYLD.js} +2 -2
  114. package/dist/{heartbeat-visibility-B4oqf1qY.js → heartbeat-visibility-1TJb1Zao.js} +1 -1
  115. package/dist/{heartbeat-visibility-ClqnPSqo.js → heartbeat-visibility-CwodtdcX.js} +1 -1
  116. package/dist/{helpers-ZKNRexvX.js → helpers-N-uSFKOn.js} +1 -1
  117. package/dist/{hooks-cli-DfR8cmrL.js → hooks-cli-1POsXqOl.js} +11 -11
  118. package/dist/{hooks-cli-DTMS4Ly9.js → hooks-cli-BGjILbze.js} +58 -58
  119. package/dist/{hooks-status-LVJDILL8.js → hooks-status-DE07n5RC.js} +1 -1
  120. package/dist/{hooks-status-B-e96dZj.js → hooks-status-Du-d1jde.js} +4 -4
  121. package/dist/{image-ops-Dlt3T7th.js → image-ops-Bp0C6Mvr.js} +1 -1
  122. package/dist/index.js +12 -12
  123. package/dist/{init-Bm04RagW.js → init-9A0s7bWG.js} +2 -2
  124. package/dist/{init-CaJBf4p1.js → init-DoyCHJDC.js} +3 -3
  125. package/dist/{installs-D-cPGdCw.js → installs-D1C9wHAq.js} +5 -5
  126. package/dist/{installs-DCTtAJP8.js → installs-Dh4dHayM.js} +2 -2
  127. package/dist/{ipv4-loTbB6OD.js → ipv4-DCItfaJo.js} +15 -15
  128. package/dist/{ipv4-CoPxliya.js → ipv4-DSOUVx0i.js} +8 -8
  129. package/dist/{lifecycle-core-Cu_h9gos.js → lifecycle-core-BY4WIf9g.js} +5 -5
  130. package/dist/{lifecycle-core-BZo7U2jW.js → lifecycle-core-TQKyXO-6.js} +8 -8
  131. package/dist/{links-BfjHVTB_.js → links-CNu_8RZl.js} +1 -1
  132. package/dist/llm-slug-generator.js +4 -4
  133. package/dist/{logging-DB6BQmhi.js → logging-C7lb3Vjc.js} +1 -1
  134. package/dist/{login-CnNpZKOD.js → login-DXWKewA2.js} +3 -3
  135. package/dist/{login-D4n2DJtf.js → login-pPs3UO38.js} +5 -5
  136. package/dist/{login-qr-CaB_Oi7G.js → login-qr-GF2JMIy-.js} +9 -9
  137. package/dist/{login-qr-D3xv0VnI.js → login-qr-ZYYKD6Yt.js} +7 -7
  138. package/dist/{logs-cli-CFX-tr6f.js → logs-cli-CzXbX8HZ.js} +14 -14
  139. package/dist/{logs-cli-NXQfed5q.js → logs-cli-D9ngH9PF.js} +2 -2
  140. package/dist/{manager-D_engjHC.js → manager-BD5rA3w0.js} +9 -9
  141. package/dist/{manager-iFc0bAWS.js → manager-DRWMWM--.js} +7 -7
  142. package/dist/{manifest-registry-D4lM2RdV.js → manifest-registry-DbvPaBXY.js} +1 -1
  143. package/dist/{markdown-tables-Bhes7rr4.js → markdown-tables-CqwihY2m.js} +2 -2
  144. package/dist/{media-Bu2L8c_7.js → media-lUqN-0O9.js} +6 -6
  145. package/dist/{memory-cli-CvrdGRvA.js → memory-cli-BLXSpgnN.js} +13 -13
  146. package/dist/{memory-cli-D6v61Mts.js → memory-cli-BcGVkkRJ.js} +1 -1
  147. package/dist/{migrate-BR6iAIjO.js → migrate-BpVOar4L.js} +3 -3
  148. package/dist/{migrate-D0EcMs0f.js → migrate-CkgGDkWy.js} +2 -2
  149. package/dist/{models-D11W7O93.js → models-CExsNQPH.js} +22 -22
  150. package/dist/{models-cli-ClFZ55qZ.js → models-cli-Ba3Jmwev.js} +18 -18
  151. package/dist/{models-cli-BfBH9dWH.js → models-cli-iDAlsbL2.js} +64 -64
  152. package/dist/{net-B5lXhYLV.js → net-0A_zcaQD.js} +1 -1
  153. package/dist/{node-cli-kxhgdSNi.js → node-cli-ATmwCXIk.js} +33 -33
  154. package/dist/{node-cli-Cgn2mwSW.js → node-cli-DYFR_V25.js} +12 -12
  155. package/dist/{node-service-BFxHJsno.js → node-service-CN4LqR1A.js} +2 -2
  156. package/dist/{node-service-BL8qVG1X.js → node-service-CWt3MdSC.js} +1 -1
  157. package/dist/{nodes-cli-deMLu7ch.js → nodes-cli-BeVmhTz3.js} +18 -18
  158. package/dist/{nodes-cli-De6Ta7GH.js → nodes-cli-QeJIfa18.js} +2 -2
  159. package/dist/{nodes-screen-BST4qOFR.js → nodes-screen-DHyWAlla.js} +1 -1
  160. package/dist/{note-BtE8fGoO.js → note-CSlg2BnB.js} +1 -1
  161. package/dist/{note-uiuPxhyX.js → note-Ctvglhp1.js} +1 -1
  162. package/dist/{npm-registry-spec-za3itb5Y.js → npm-registry-spec-PxisIMts.js} +1 -1
  163. package/dist/{onboard-DPEqxVx4.js → onboard-DeruD10m.js} +13 -13
  164. package/dist/{onboard-BGv6xY1s.js → onboard-SAcu5N6N.js} +18 -18
  165. package/dist/{onboard-channels-DEfpenNa.js → onboard-channels-C4iSfFXR.js} +4 -4
  166. package/dist/{onboard-channels-BsTwWmEt.js → onboard-channels-oVTVgoyg.js} +10 -10
  167. package/dist/{onboard-helpers-CwcaOee8.js → onboard-helpers-B8roRwLP.js} +11 -11
  168. package/dist/{onboard-helpers-Cz42ASwv.js → onboard-helpers-Dgh26hgP.js} +2 -2
  169. package/dist/{onboarding-BxYOAHWD.js → onboarding-Bi-ac8we.js} +16 -16
  170. package/dist/{onboarding-DvitiaRS.js → onboarding-C2gjB2u8.js} +23 -23
  171. package/dist/{orchestrator-BKzmyBWy.js → orchestrator-DlbAYMQP.js} +4 -4
  172. package/dist/{orchestrator-BN3QCz2s.js → orchestrator-DlwVRVDA.js} +4 -4
  173. package/dist/{outbound-Csw4yAYo.js → outbound-CkKgc6iR.js} +5 -5
  174. package/dist/{outbound-L1IT5jN_.js → outbound-Vfm5yDh3.js} +4 -4
  175. package/dist/{outbound-send-deps-CmzQCbSX.js → outbound-send-deps-DDjiMfEL.js} +6 -6
  176. package/dist/{pairing-cli-CSRakAu-.js → pairing-cli-CJYeuEik.js} +13 -13
  177. package/dist/{pairing-cli-BmPkji_u.js → pairing-cli-mqopHI8s.js} +1 -1
  178. package/dist/{pairing-store-uUh4DCdc.js → pairing-store-DoNj00-X.js} +3 -3
  179. package/dist/{path-env-Bu6k0jDQ.js → path-env-C_xpiG8l.js} +1 -1
  180. package/dist/{paths-Ba-yiqjy.js → paths-B1vRVCad.js} +2 -2
  181. package/dist/{paths-C1R4gjRm.js → paths-DA9WYabg.js} +5 -5
  182. package/dist/{paths-CxRf2rBG.js → paths-DfQGx0_k.js} +1 -1
  183. package/dist/{pi-auth-json-C2miwJYp.js → pi-auth-json-DOPW3e4X.js} +4 -4
  184. package/dist/{pi-auth-json-I3iYPRAb.js → pi-auth-json-lae_wwwo.js} +5 -5
  185. package/dist/{pi-model-discovery-eIc-PHaM.js → pi-model-discovery-7q0GxMrp.js} +1 -1
  186. package/dist/{pi-tools.policy-DhmYCpdW.js → pi-tools.policy-xYdDLEv9.js} +5 -5
  187. package/dist/{plugin-auto-enable-DVD5Kls3.js → plugin-auto-enable-CViVVWgg.js} +4 -4
  188. package/dist/{plugin-registry-NbbyJq_D.js → plugin-registry-B4Aw2hzq.js} +2 -2
  189. package/dist/{plugins-DdzdfeTc.js → plugins-DtghNRtM.js} +1 -1
  190. package/dist/{plugins-cli-Cs_jfROZ.js → plugins-cli-4vWTmOAb.js} +13 -13
  191. package/dist/{plugins-cli-D0jU5_VE.js → plugins-cli-CdTMbP0X.js} +59 -59
  192. package/dist/{ports-Co1kd5qX.js → ports-BtZx-JKD.js} +2 -2
  193. package/dist/{ports-B3Vuo92o.js → ports-vd93M_Pt.js} +3 -3
  194. package/dist/{program-Db2-b8Np.js → program-CX3aUVeb.js} +64 -64
  195. package/dist/{program-context-DR1cx29i.js → program-context-BPos0ivo.js} +38 -38
  196. package/dist/{pw-ai-MrkdzeIJ.js → pw-ai-4QbK5YFe.js} +3 -3
  197. package/dist/{pw-ai-DM3CIGyg.js → pw-ai-C83HBue2.js} +6 -6
  198. package/dist/{qmd-manager-Dgo23O3Q.js → qmd-manager-CPypGJ0P.js} +6 -6
  199. package/dist/{qmd-manager-Cur_Ekn0.js → qmd-manager-CRrSkfia.js} +7 -7
  200. package/dist/{register.agent-E1qzojq2.js → register.agent-DDY8KJhn.js} +76 -76
  201. package/dist/{register.agent-B4CGE-cp.js → register.agent-DKawm-9d.js} +26 -26
  202. package/dist/{register.anima-BETuBtyq.js → register.anima-CEWUo29k.js} +17 -17
  203. package/dist/{register.anima-C2coCJM_.js → register.anima-DBWz2rk_.js} +17 -17
  204. package/dist/{register.configure-DqYNhIQj.js → register.configure-BX67qV8k.js} +30 -30
  205. package/dist/register.configure-CWsySuiq.js +101 -0
  206. package/dist/{register.maintenance-DC9IhZ2x.js → register.maintenance-0k-ZNhDg.js} +31 -31
  207. package/dist/{register.maintenance-RuiaMHu7.js → register.maintenance-BIwx1fzX.js} +82 -82
  208. package/dist/{register.message-BRP5Y8SN.js → register.message-CXPsoakA.js} +59 -59
  209. package/dist/{register.message-CL5mFcq-.js → register.message-DA3jvfgI.js} +11 -11
  210. package/dist/{register.onboard-DFjl0E_x.js → register.onboard-C4HG7Hqv.js} +36 -36
  211. package/dist/{register.onboard-CdvtyeLg.js → register.onboard-GOpdif-j.js} +86 -86
  212. package/dist/{register.setup-CuNhw63j.js → register.setup-B17vZT7C.js} +87 -87
  213. package/dist/{register.setup-CVhekh_d.js → register.setup-GJyUDCqh.js} +37 -37
  214. package/dist/{register.status-health-sessions-BdyiNJFD.js → register.status-health-sessions-D5876dGx.js} +24 -24
  215. package/dist/{register.status-health-sessions-l7qnXORD.js → register.status-health-sessions-lOewVIZR.js} +73 -73
  216. package/dist/{register.subclis-Bj3GU0St.js → register.subclis-Dwnujj5C.js} +29 -29
  217. package/dist/{reply-C9A7Npep.js → reply-CR5T_oQJ.js} +10 -10
  218. package/dist/{reply-prefix-m-Nj9VGi.js → reply-prefix-BcrS4Umd.js} +1 -1
  219. package/dist/{reply-prefix-XqRfG1QY.js → reply-prefix-Btb5o2NH.js} +2 -2
  220. package/dist/{reply-Brlv-JC-.js → reply-r089HuRA.js} +69 -69
  221. package/dist/{routes-CooYoUCb.js → routes-B4czFzIb.js} +1 -1
  222. package/dist/{routes-C5ylAnNV.js → routes-ucJWAk5O.js} +8 -8
  223. package/dist/{rpc-BoNfgecI.js → rpc-BnKxnQ0v.js} +4 -4
  224. package/dist/{run-main-DKNJvJ7W.js → run-main-B74kv84C.js} +79 -79
  225. package/dist/{sandbox-D8pgNhTE.js → sandbox-CJTS3er6.js} +6 -6
  226. package/dist/{sandbox-cli-BlWdpX1h.js → sandbox-cli-CrkjyU5M.js} +3 -3
  227. package/dist/{sandbox-cli-BeOQ8G6W.js → sandbox-cli-D1r5y6Sz.js} +29 -29
  228. package/dist/{security-cli-CcYc8gKu.js → security-cli-BZUdnkhn.js} +34 -34
  229. package/dist/{security-cli-CRSXFNRa.js → security-cli-DS09ebvA.js} +5 -5
  230. package/dist/{server-context-Du3Gdqy1.js → server-context-C0xZbYhg.js} +3 -3
  231. package/dist/{server-context-Cu88BsgT.js → server-context-DVh2z7om.js} +9 -9
  232. package/dist/{server-node-events-DCY3mm-A.js → server-node-events-bu9lpkMH.js} +4 -4
  233. package/dist/{server-node-events-0Una3QLI.js → server-node-events-i1Rrww31.js} +28 -28
  234. package/dist/{service-BNVpYcQe.js → service-CJJwLEor.js} +2 -2
  235. package/dist/{service-CpG4hCVW.js → service-DxLxBhaU.js} +1 -1
  236. package/dist/{service-audit-DP4USmzf.js → service-audit-DB4Y3Ekp.js} +4 -4
  237. package/dist/{service-audit-B3atdWsy.js → service-audit-M8y4TXVb.js} +3 -3
  238. package/dist/{session-B6T_f3RF.js → session-CGxOLFs2.js} +9 -9
  239. package/dist/{session-cost-usage-BwiTZuKl.js → session-cost-usage-qdfsGU2a.js} +3 -3
  240. package/dist/{session-xQxk_AyT.js → session-yOhWcsD2.js} +4 -4
  241. package/dist/{sessions-BQUf6xj_.js → sessions-BgLN4KFr.js} +6 -6
  242. package/dist/{sessions-B9VnNnIk.js → sessions-CnRjwdVr.js} +8 -8
  243. package/dist/{sessions-G7nfpjc6.js → sessions-wRKla1Qh.js} +25 -25
  244. package/dist/{shared-uOwPcrN5.js → shared-DS3UaJSP.js} +1 -1
  245. package/dist/{shared-BcqU-KU2.js → shared-Qpt4hUDi.js} +3 -3
  246. package/dist/{shared-CkGP1Gie.js → shared-kzrojZ1B.js} +5 -5
  247. package/dist/{skill-scanner-CkaVLABv.js → skill-scanner-DLJji5Ye.js} +1 -1
  248. package/dist/{skills-B5LQx4lT.js → skills-BWFIEp4j.js} +3 -3
  249. package/dist/{skills-cli-CBFbV14l.js → skills-cli-BY53ILm2.js} +5 -5
  250. package/dist/{skills-cli-gGWq4bgb.js → skills-cli-CO3gxl8A.js} +13 -13
  251. package/dist/{skills-status-DaLLXtp7.js → skills-status-DX5pcqY3.js} +1 -1
  252. package/dist/{skills-status-JQluhU-P.js → skills-status-zhcKzGkp.js} +3 -3
  253. package/dist/{sqlite-BukcjdJa.js → sqlite-B6MojU1I.js} +2 -2
  254. package/dist/{sqlite-BiXgPbCK.js → sqlite-CuprTGR7.js} +4 -4
  255. package/dist/{start-DaXwIgOn.js → start-Cu3aLoSf.js} +10 -10
  256. package/dist/{start-Fy8lVmlo.js → start-Dz7tMAl8.js} +10 -10
  257. package/dist/{status-XzLCn872.js → status-CaSxhxfV.js} +16 -16
  258. package/dist/{status-DbxQqh2e.js → status-D2C0JCX3.js} +33 -33
  259. package/dist/{status-iUSfyst3.js → status-DlFMsQzh.js} +3 -3
  260. package/dist/{status-C7YN9z1q.js → status-G0CITnKR.js} +1 -1
  261. package/dist/{status.update-ZVrSK04Z.js → status.update-CHjhVxJY.js} +4 -4
  262. package/dist/{status.update-DEtEANLh.js → status.update-DVFelehi.js} +1 -1
  263. package/dist/{subagent-registry-DKRVOkTv.js → subagent-registry-3Xb4el-8.js} +11 -11
  264. package/dist/{subagent-registry-BJzLJ6FY.js → subagent-registry-DNDhbHWi.js} +12 -12
  265. package/dist/{system-cli-CYypNnD9.js → system-cli-B5mt0FWa.js} +1 -1
  266. package/dist/{system-cli-VMfIEGoj.js → system-cli-Dg3UQ3Zz.js} +12 -12
  267. package/dist/{systemd-BSrHDyeU.js → systemd-RpPE0XGg.js} +2 -2
  268. package/dist/{systemd-hints-J3cHYZVZ.js → systemd-hints-vRInKcz9.js} +1 -1
  269. package/dist/{systemd-linger-CmyqQkeC.js → systemd-linger-Dzyxqsod.js} +2 -2
  270. package/dist/{systemd-linger-B4wBMvpg.js → systemd-linger-EujbmI5A.js} +2 -2
  271. package/dist/{table-DoiRPsn0.js → table-DhXHfRX2.js} +1 -1
  272. package/dist/{timeout-CswI_K-U.js → timeout-Ddn-5kAO.js} +2 -2
  273. package/dist/{tokens-C-X7wDKj.js → tokens-BaM53PEx.js} +1 -1
  274. package/dist/{trash-BJLK1vMn.js → trash-Bmxs1Rnm.js} +1 -1
  275. package/dist/{tui-cli-DN5WL85n.js → tui-cli-B9Sq5-cC.js} +1 -1
  276. package/dist/{tui-cli-BcsdagN8.js → tui-cli-Dw7v4JoJ.js} +18 -18
  277. package/dist/{tui-BfPtiXD1.js → tui-mUwDwqvd.js} +12 -12
  278. package/dist/{update-TxptCqk7.js → update-DF0GHG0j.js} +3 -3
  279. package/dist/{update-DhOF8e0Q.js → update-DoZLVjva.js} +1 -1
  280. package/dist/{update-check-DmODY9MR.js → update-check-D5qAKes7.js} +3 -3
  281. package/dist/{update-cli-DXAbudd9.js → update-cli-BNu2Oi7H.js} +39 -39
  282. package/dist/{update-cli-BVeg9il9.js → update-cli-D36AmALA.js} +91 -91
  283. package/dist/{update-runner-B2bjvdxa.js → update-runner-CNQQaTwA.js} +5 -5
  284. package/dist/{update-runner-CTCGT1OS.js → update-runner-CvxZmbu-.js} +3 -3
  285. package/dist/{usage-kVpWUUrn.js → usage-BGCwNnjk.js} +25 -25
  286. package/dist/{web-BGf92cSU.js → web-B5QG839O.js} +100 -100
  287. package/dist/{web-C4FxauVQ.js → web-Cmnvk9v0.js} +60 -60
  288. package/dist/{web-B1OjU-Gf.js → web-Cv2KnTnL.js} +9 -9
  289. package/dist/{webhooks-cli-bEG0ADkY.js → webhooks-cli-B6y89Pj_.js} +1 -1
  290. package/dist/{webhooks-cli-l0yqYtZW.js → webhooks-cli-BDzHON4w.js} +10 -10
  291. package/dist/{whatsapp-actions-CvnLgxjq.js → whatsapp-actions-C_5MwVxM.js} +10 -10
  292. package/dist/{whatsapp-actions-CwSwIOO3.js → whatsapp-actions-zTiVOoOV.js} +16 -16
  293. package/dist/{widearea-dns-NsEUNYwz.js → widearea-dns-CF1gxpJ-.js} +1 -1
  294. package/dist/{workspace-BTjqqJY-.js → workspace-DLna1IxR.js} +5 -5
  295. package/dist/{ws-log-N8R5MvGE.js → ws-log-Q4wO1Ztb.js} +2 -2
  296. package/package.json +1 -2
  297. package/dist/cli-XuLBXSur.js +0 -99
  298. package/dist/register.configure-D5huhRa3.js +0 -101
  299. /package/dist/{agents.config-DWZdxlQw.js → agents.config-jp7OLssr.js} +0 -0
  300. /package/dist/{auth-health-CP4Id2rW.js → auth-health-VO_MPqVX.js} +0 -0
  301. /package/dist/{auto-update-CUeF99gI.js → auto-update-CpF0fycd.js} +0 -0
  302. /package/dist/{auto-update-cgkp9ZTJ.js → auto-update-DNWdO7uF.js} +0 -0
  303. /package/dist/{brew-CVZkr0GU.js → brew-nqf_MiE4.js} +0 -0
  304. /package/dist/{budget-DxYQSekw.js → budget-CPedI-qW.js} +0 -0
  305. /package/dist/{budget-BWBp8Res.js → budget-CRpvqDRX.js} +0 -0
  306. /package/dist/{channels-status-issues-DwHRoeWL.js → channels-status-issues-DdJdO866.js} +0 -0
  307. /package/dist/{cli-utils-DtAxdCte.js → cli-utils-C1YHVD4o.js} +0 -0
  308. /package/dist/{clipboard-SCV-0V39.js → clipboard-DES8b1AM.js} +0 -0
  309. /package/dist/{command-format-DAaqLG8J.js → command-format-G6N2zghg.js} +0 -0
  310. /package/dist/{command-options-CSbuuqHr.js → command-options-BbponVnw.js} +0 -0
  311. /package/dist/{command-options-Cp1tf96a.js → command-options-s0gnvXnS.js} +0 -0
  312. /package/dist/{constants-O8yBqCBv.js → constants-Dhb6zSIV.js} +0 -0
  313. /package/dist/{daemon-runtime-C9KTe-Gn.js → daemon-runtime-C0tz7VAC.js} +0 -0
  314. /package/dist/{dangerous-tools-5ObDWy1N.js → dangerous-tools-DGTtJ_JR.js} +0 -0
  315. /package/dist/{dangerous-tools-Jwr7jqNw.js → dangerous-tools-DxrfTOfT.js} +0 -0
  316. /package/dist/{delivery-queue-B6IHz4Ry.js → delivery-queue-Bxm0nzw7.js} +0 -0
  317. /package/dist/{display-BDOsXu8F.js → display-Jy3UdGzA.js} +0 -0
  318. /package/dist/{docs-cli-B02Wm6DH.js → docs-cli-CrOaIK_H.js} +0 -0
  319. /package/dist/{errors-CHow2wtt.js → errors-CKaCqKga.js} +0 -0
  320. /package/dist/{exec-BizYYQgP.js → exec-DDmuVVNq.js} +0 -0
  321. /package/dist/{format-Mq6iU0_5.js → format-ByEjgyTF.js} +0 -0
  322. /package/dist/{format-duration-DhWzz_5b.js → format-duration-Aaj5tjJd.js} +0 -0
  323. /package/dist/{format-relative-C6kUHuOj.js → format-relative-79_Y1n2Y.js} +0 -0
  324. /package/dist/{gateway-rpc-QOe014D_.js → gateway-rpc-Dtx8HN-n.js} +0 -0
  325. /package/dist/{gmail-setup-utils-Bn8x7djJ.js → gmail-setup-utils-co0ppccC.js} +0 -0
  326. /package/dist/{health-format-DteBvzWP.js → health-format-BksT6F68.js} +0 -0
  327. /package/dist/{help-format-DUBI91Ti.js → help-format-BMKzarov.js} +0 -0
  328. /package/dist/{help-format-C4eJQd8a.js → help-format-C6cv_aZp.js} +0 -0
  329. /package/dist/{helpers-eJFa4K6r.js → helpers-DpEB9Mh0.js} +0 -0
  330. /package/dist/{helpers-DLgbkcEn.js → helpers-FMld9sBT.js} +0 -0
  331. /package/dist/{input-provenance-DJBdpeKk.js → input-provenance-Cy_KnBlP.js} +0 -0
  332. /package/dist/{is-main-Dt9DTcH1.js → is-main-yjaVwMtJ.js} +0 -0
  333. /package/dist/{loader-l2OBdJ8x.js → loader-Br7Vr0zn.js} +0 -0
  334. /package/dist/{loader-BoYxRfcW.js → loader-CkmOrXcC.js} +0 -0
  335. /package/dist/{logging-BuRtGUH1.js → logging-BIeRw0WR.js} +0 -0
  336. /package/dist/{logging-BdnOSVPD.js → logging-CY-Q5cwf.js} +0 -0
  337. /package/dist/{login-qr-Cc2QmLhD.js → login-qr-CevLD8cV.js} +0 -0
  338. /package/dist/{message-channel-w4F2b2F6.js → message-channel-dua8OOGJ.js} +0 -0
  339. /package/dist/{mime-B1ZoR53M.js → mime-CBg4KybI.js} +0 -0
  340. /package/dist/{model-param-b-DPwyNGn8.js → model-param-b-DW9f0NN8.js} +0 -0
  341. /package/dist/{node-match-8XZnaid6.js → node-match-BV8bTBd4.js} +0 -0
  342. /package/dist/{normalize-GDK8JTNW.js → normalize-_lmlBOW9.js} +0 -0
  343. /package/dist/{npm-registry-spec-DvJxezSJ.js → npm-registry-spec-DQd4M22q.js} +0 -0
  344. /package/dist/{openclaw-root-C85WMnVV.js → openclaw-root-JPvmPTf7.js} +0 -0
  345. /package/dist/{outbound-send-deps-ANnAhImn.js → outbound-send-deps-BfUvuWGa.js} +0 -0
  346. /package/dist/{parse-6-2MDhdT.js → parse-CZRwKocn.js} +0 -0
  347. /package/dist/{parse-log-line-Bqh1SSzC.js → parse-log-line-CvrZEK6A.js} +0 -0
  348. /package/dist/{parse-log-line-DUZCjXbl.js → parse-log-line-mLdat0AH.js} +0 -0
  349. /package/dist/{parse-port-BKB9Exlg.js → parse-port-BSOOdo7I.js} +0 -0
  350. /package/dist/{parse-port-DrfvwwiL.js → parse-port-Y0NK62x1.js} +0 -0
  351. /package/dist/{parse-timeout-Di_tcEmi.js → parse-timeout-DVPQ3n9j.js} +0 -0
  352. /package/dist/{paths-DcVEkYX5.js → paths-DHjlJ6cn.js} +0 -0
  353. /package/dist/{pi-auth-json-B1M8W1pO.js → pi-auth-json-MruLmI_X.js} +0 -0
  354. /package/dist/{pi-model-discovery-DsRqYJLy.js → pi-model-discovery-DzEIEgHL.js} +0 -0
  355. /package/dist/{plugin-auto-enable-d9eDmGOX.js → plugin-auto-enable-CjZ238UI.js} +0 -0
  356. /package/dist/{plugins-CDJw924T.js → plugins-D6PBOdkn.js} +0 -0
  357. /package/dist/{program-context-Bvn8046-.js → program-context-Q1hkT73c.js} +0 -0
  358. /package/dist/{progress-CbZ2D53A.js → progress-C9Ha1NJh.js} +0 -0
  359. /package/dist/{prompt-style-D6u56SjJ.js → prompt-style-Cm4wOtKm.js} +0 -0
  360. /package/dist/{prompt-style-DKy6qQxR.js → prompt-style-DQi8j03a.js} +0 -0
  361. /package/dist/{prompts-BI__va99.js → prompts-BEHxUC3w.js} +0 -0
  362. /package/dist/{prompts-_dDWkCAz.js → prompts-CSOhuiqe.js} +0 -0
  363. /package/dist/{pw-ai-CbEgFH-G.js → pw-ai-BWz3Cxt7.js} +0 -0
  364. /package/dist/{qmd-manager-DPslO6i9.js → qmd-manager-BcMeZiGD.js} +0 -0
  365. /package/dist/{queue-D_u34pbL.js → queue-BJGo7kAB.js} +0 -0
  366. /package/dist/{queue-PG591iID.js → queue-DYgUbdoq.js} +0 -0
  367. /package/dist/{redact-ClVwO7Nn.js → redact-CyKvdFrg.js} +0 -0
  368. /package/dist/{registry-Bs_DJK9E.js → registry-C5MAYD4V.js} +0 -0
  369. /package/dist/{registry-D_zlP1U-.js → registry-CRrXXVs0.js} +0 -0
  370. /package/dist/{requirements-BzZxj2Wu.js → requirements-CGkxTCu4.js} +0 -0
  371. /package/dist/{requirements-DIW1svgA.js → requirements-CIDaOcbO.js} +0 -0
  372. /package/dist/{rpc-aBUUQWC3.js → rpc-DgE-xnyx.js} +0 -0
  373. /package/dist/{runtime-guard-DeOXA_86.js → runtime-guard-nL3Lp8T-.js} +0 -0
  374. /package/dist/{secret-equal-Dghy3xsA.js → secret-equal-DJpmLXlG.js} +0 -0
  375. /package/dist/{send-BhAfdGII.js → send-CTcxgDDU.js} +0 -0
  376. /package/dist/{send-ga9udK1_.js → send-DPezUR3-.js} +0 -0
  377. /package/dist/{send-C2t9xpXI.js → send-DZQTaG7-.js} +0 -0
  378. /package/dist/{send-DigO-i9j.js → send-VDff2gra.js} +0 -0
  379. /package/dist/{send-Dz2BDHll.js → send-bgQNV8d1.js} +0 -0
  380. /package/dist/{session-key-BGiG_JcT.js → session-key-CQT-NR6w.js} +0 -0
  381. /package/dist/{shared-DwguvoZP.js → shared-DxNHzky3.js} +0 -0
  382. /package/dist/{shell-argv-CAq1mLa2.js → shell-argv-n9IueeJQ.js} +0 -0
  383. /package/dist/{skill-scanner-Coo4QoCd.js → skill-scanner-o6NgVMD9.js} +0 -0
  384. /package/dist/{status-CMnlcBVc.js → status-C53kTIXF.js} +0 -0
  385. /package/dist/{status-tDZPwewW.js → status-CZDDA_Sy.js} +0 -0
  386. /package/dist/{system-run-command-X9lDJIy0.js → system-run-command-BCjUffN9.js} +0 -0
  387. /package/dist/{system-run-command-DGk7dwQP.js → system-run-command-CqAqKL9K.js} +0 -0
  388. /package/dist/{systemd-BVVNFIBH.js → systemd-B43AvOGx.js} +0 -0
  389. /package/dist/{systemd-hints-Mpt5QteE.js → systemd-hints-DMJT-Bbc.js} +0 -0
  390. /package/dist/{table-B_wVcaLO.js → table-bWCLW-3P.js} +0 -0
  391. /package/dist/{tailnet-CuiNECdL.js → tailnet-Ciwjv243.js} +0 -0
  392. /package/dist/{templates-CeYJjVzw.js → templates-37RKpACb.js} +0 -0
  393. /package/dist/{templates-I3Z0xplD.js → templates-DPalk30o.js} +0 -0
  394. /package/dist/{thinking-BXEswx1X.js → thinking-2hxwmvTl.js} +0 -0
  395. /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
  396. /package/dist/{transcript-tools-DuyYOkUq.js → transcript-tools-D4Lbxlka.js} +0 -0
  397. /package/dist/{tui-r0_5VL_h.js → tui-BHgBWhHE.js} +0 -0
  398. /package/dist/{update-check-DlDloai0.js → update-check-Bt1dVPVN.js} +0 -0
  399. /package/dist/{usage-format-BAirWUSO.js → usage-format-6Uar63S0.js} +0 -0
  400. /package/dist/{utils-C9sj30YY.js → utils-DT8uXjFS.js} +0 -0
  401. /package/dist/{whatsapp-actions-DsoA_Bad.js → whatsapp-actions-hgYA12To.js} +0 -0
  402. /package/dist/{widearea-dns-1txrPZ0I.js → widearea-dns-BeIdnISJ.js} +0 -0
  403. /package/dist/{ws-log-BffL5dN_.js → ws-log-xF0kxDzp.js} +0 -0
  404. /package/dist/{wsl-CqyuRvtM.js → wsl-CrPvx2kZ.js} +0 -0
  405. /package/dist/{wsl-ymJYvc9Q.js → wsl-UvJ5dHah.js} +0 -0
@@ -0,0 +1,929 @@
1
+ import { EventEmitter } from "events";
2
+ import { execFile, spawn } from "child_process";
3
+ import * as fs from "fs";
4
+ import * as path from "path";
5
+ import { fileURLToPath } from "url";
6
+ import * as os from "os";
7
+ import * as crypto from "crypto";
8
+
9
+ //#region node_modules/.pnpm/file+..+svrn-node_typescript@5.9.3_zod@4.3.6/node_modules/@noxsoft/svrn-node/dist/index.js
10
+ var ALL_TASK_TYPES = [
11
+ "ping",
12
+ "relay",
13
+ "compute",
14
+ "store",
15
+ "validate"
16
+ ];
17
+ var DEFAULT_CONFIG = {
18
+ enabled: true,
19
+ dataDir: getDefaultDataDir(),
20
+ coordinatorUrl: "https://svrn.noxsoft.net",
21
+ resources: {
22
+ maxCpuPercent: 50,
23
+ maxRamMB: 512,
24
+ maxBandwidthMbps: 10,
25
+ maxDiskGB: 5
26
+ },
27
+ taskTypes: [...ALL_TASK_TYPES],
28
+ autoUpdate: {
29
+ enabled: true,
30
+ checkIntervalHours: 6,
31
+ autoRestart: true,
32
+ channel: "stable"
33
+ },
34
+ heartbeatIntervalSec: 30,
35
+ showEarnings: true
36
+ };
37
+ function getDefaultDataDir() {
38
+ return `${process.env["HOME"] || process.env["USERPROFILE"] || "/tmp"}/.svrn-node`;
39
+ }
40
+ function resolveConfig(partial) {
41
+ if (!partial) return { ...DEFAULT_CONFIG };
42
+ return {
43
+ ...DEFAULT_CONFIG,
44
+ ...partial,
45
+ resources: {
46
+ ...DEFAULT_CONFIG.resources,
47
+ ...partial.resources ?? {}
48
+ },
49
+ autoUpdate: {
50
+ ...DEFAULT_CONFIG.autoUpdate,
51
+ ...partial.autoUpdate ?? {}
52
+ },
53
+ taskTypes: partial.taskTypes ?? [...ALL_TASK_TYPES]
54
+ };
55
+ }
56
+ var PACKAGE_NAME = "@noxsoft/svrn-node";
57
+ var REGISTRY_BASE = "https://registry.npmjs.org";
58
+ var AutoUpdater = class extends EventEmitter {
59
+ config;
60
+ currentVersion;
61
+ checkTimer = null;
62
+ logFile;
63
+ checking = false;
64
+ constructor(config, dataDir) {
65
+ super();
66
+ this.config = config;
67
+ this.currentVersion = this.readCurrentVersion();
68
+ this.logFile = path.join(dataDir, "updates.log");
69
+ fs.mkdirSync(dataDir, { recursive: true });
70
+ }
71
+ /** Start the periodic update check loop. */
72
+ start() {
73
+ if (!this.config.enabled) return;
74
+ this.check();
75
+ const intervalMs = this.config.checkIntervalHours * 60 * 60 * 1e3;
76
+ this.checkTimer = setInterval(() => void this.check(), intervalMs);
77
+ }
78
+ /** Stop the update check loop. */
79
+ stop() {
80
+ if (this.checkTimer) {
81
+ clearInterval(this.checkTimer);
82
+ this.checkTimer = null;
83
+ }
84
+ }
85
+ /** Get the current installed version. */
86
+ getVersion() {
87
+ return this.currentVersion;
88
+ }
89
+ /** Manually trigger an update check. Returns info if update found, null otherwise. */
90
+ async check() {
91
+ if (this.checking) return null;
92
+ this.checking = true;
93
+ try {
94
+ const tag = this.config.channel === "beta" ? "beta" : "latest";
95
+ const latestVersion = await this.fetchLatestVersion(tag);
96
+ if (!latestVersion) return null;
97
+ if (this.isNewer(latestVersion, this.currentVersion)) {
98
+ const info = {
99
+ currentVersion: this.currentVersion,
100
+ latestVersion,
101
+ channel: this.config.channel,
102
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
103
+ };
104
+ this.emit("update-available", info);
105
+ this.log(`Update available: ${this.currentVersion} -> ${latestVersion}`);
106
+ if (this.config.autoRestart) {
107
+ await this.installUpdate(latestVersion);
108
+ this.log(`Update installed: ${latestVersion}`);
109
+ this.emit("update-installed", info);
110
+ this.restartProcess();
111
+ }
112
+ return info;
113
+ }
114
+ return null;
115
+ } catch (error) {
116
+ const msg = error instanceof Error ? error.message : String(error);
117
+ this.log(`Update check failed: ${msg}`);
118
+ this.emit("update-error", error);
119
+ return null;
120
+ } finally {
121
+ this.checking = false;
122
+ }
123
+ }
124
+ /**
125
+ * Install a specific version and restart (for manual `svrn-node update`).
126
+ * Returns the UpdateInfo if an update was installed, null if already current.
127
+ */
128
+ async installAndRestart() {
129
+ const tag = this.config.channel === "beta" ? "beta" : "latest";
130
+ const latestVersion = await this.fetchLatestVersion(tag);
131
+ if (!latestVersion) {
132
+ this.log("No version found on npm — package may not be published yet.");
133
+ return null;
134
+ }
135
+ if (!this.isNewer(latestVersion, this.currentVersion)) return null;
136
+ const info = {
137
+ currentVersion: this.currentVersion,
138
+ latestVersion,
139
+ channel: this.config.channel,
140
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
141
+ };
142
+ await this.installUpdate(latestVersion);
143
+ this.log(`Update installed: ${latestVersion}`);
144
+ this.emit("update-installed", info);
145
+ return info;
146
+ }
147
+ /**
148
+ * Fetch the latest version from the npm registry HTTP API.
149
+ * Uses simple fetch — no npm CLI needed for checking.
150
+ *
151
+ * For the 'stable' channel, fetches the 'latest' dist-tag.
152
+ * For the 'beta' channel, fetches the 'beta' dist-tag.
153
+ */
154
+ async fetchLatestVersion(tag) {
155
+ try {
156
+ const url = `${REGISTRY_BASE}/${encodeURIComponent(PACKAGE_NAME)}/${tag}`;
157
+ const response = await fetch(url, {
158
+ headers: { Accept: "application/json" },
159
+ signal: AbortSignal.timeout(15e3)
160
+ });
161
+ if (!response.ok) {
162
+ if (response.status === 404) return null;
163
+ return null;
164
+ }
165
+ return (await response.json()).version ?? null;
166
+ } catch {
167
+ return null;
168
+ }
169
+ }
170
+ /** Install the specified version via npm. */
171
+ installUpdate(version) {
172
+ return new Promise((resolve, reject) => {
173
+ const thisDir = path.dirname(fileURLToPath(import.meta.url));
174
+ const isGlobal = thisDir.includes("/lib/node_modules/") || thisDir.includes("\\node_modules\\");
175
+ execFile("npm", isGlobal ? [
176
+ "install",
177
+ "-g",
178
+ `${PACKAGE_NAME}@${version}`
179
+ ] : ["install", `${PACKAGE_NAME}@${version}`], {
180
+ timeout: 12e4,
181
+ cwd: isGlobal ? void 0 : this.findProjectRoot(thisDir) ?? void 0
182
+ }, (error) => {
183
+ if (error) {
184
+ reject(/* @__PURE__ */ new Error(`Failed to install update: ${error.message}`));
185
+ return;
186
+ }
187
+ resolve();
188
+ });
189
+ });
190
+ }
191
+ /**
192
+ * Restart the process by exec-ing the svrn-node binary.
193
+ * This replaces the current process entirely with the new version.
194
+ */
195
+ restartProcess() {
196
+ this.log("Restarting with updated binary...");
197
+ if (!process.argv[1]) {
198
+ this.log("Cannot determine binary path for restart — manual restart required.");
199
+ return;
200
+ }
201
+ const args = process.argv.slice(1);
202
+ try {
203
+ spawn(process.execPath, args, {
204
+ detached: true,
205
+ stdio: "inherit"
206
+ }).unref();
207
+ process.exit(0);
208
+ } catch (error) {
209
+ const msg = error instanceof Error ? error.message : String(error);
210
+ this.log(`Restart failed: ${msg} \u2014 manual restart required.`);
211
+ }
212
+ }
213
+ /** Read the current package version from package.json. */
214
+ readCurrentVersion() {
215
+ try {
216
+ let dir = path.dirname(fileURLToPath(import.meta.url));
217
+ for (let i = 0; i < 5; i++) {
218
+ const pkgPath = path.join(dir, "package.json");
219
+ if (fs.existsSync(pkgPath)) {
220
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
221
+ if (pkg.name === PACKAGE_NAME) return pkg.version ?? "0.0.0";
222
+ }
223
+ dir = path.dirname(dir);
224
+ }
225
+ } catch {}
226
+ return "0.0.0";
227
+ }
228
+ /** Compare semver strings. Returns true if `a` is newer than `b`. */
229
+ isNewer(a, b) {
230
+ const parse = (v) => v.replace(/[^0-9.]/g, "").split(".").map(Number);
231
+ const [aMajor = 0, aMinor = 0, aPatch = 0] = parse(a);
232
+ const [bMajor = 0, bMinor = 0, bPatch = 0] = parse(b);
233
+ if (aMajor !== bMajor) return aMajor > bMajor;
234
+ if (aMinor !== bMinor) return aMinor > bMinor;
235
+ return aPatch > bPatch;
236
+ }
237
+ /** Find the nearest ancestor directory containing package.json. */
238
+ findProjectRoot(startDir) {
239
+ let dir = startDir;
240
+ for (let i = 0; i < 10; i++) {
241
+ const pkgPath = path.join(dir, "package.json");
242
+ if (fs.existsSync(pkgPath)) {
243
+ if (JSON.parse(fs.readFileSync(pkgPath, "utf-8")).name !== PACKAGE_NAME) return dir;
244
+ }
245
+ const parent = path.dirname(dir);
246
+ if (parent === dir) break;
247
+ dir = parent;
248
+ }
249
+ return null;
250
+ }
251
+ /** Append a log entry to the updates log file. */
252
+ log(message) {
253
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
254
+ `;
255
+ try {
256
+ fs.appendFileSync(this.logFile, line);
257
+ } catch {}
258
+ }
259
+ };
260
+ var UCU_TO_USD = .001;
261
+ var EarningsTracker = class {
262
+ ledgerFile;
263
+ sessionStart;
264
+ sessionEarnings = 0;
265
+ sessionTasks = 0;
266
+ allTimeEarnings = 0;
267
+ allTimeTasks = 0;
268
+ todayEarnings = 0;
269
+ todayTasks = 0;
270
+ todayDate;
271
+ constructor(dataDir) {
272
+ this.ledgerFile = path.join(dataDir, "earnings-ledger.jsonl");
273
+ this.sessionStart = (/* @__PURE__ */ new Date()).toISOString();
274
+ this.todayDate = this.utcDateString();
275
+ fs.mkdirSync(dataDir, { recursive: true });
276
+ this.loadHistorical();
277
+ }
278
+ /** Record earnings for a completed task. */
279
+ record(taskType, taskId, amount, durationMs) {
280
+ const entry = {
281
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
282
+ taskType,
283
+ taskId,
284
+ amount,
285
+ duration: durationMs
286
+ };
287
+ this.sessionEarnings += amount;
288
+ this.sessionTasks += 1;
289
+ this.allTimeEarnings += amount;
290
+ this.allTimeTasks += 1;
291
+ const today = this.utcDateString();
292
+ if (today !== this.todayDate) {
293
+ this.todayEarnings = 0;
294
+ this.todayTasks = 0;
295
+ this.todayDate = today;
296
+ }
297
+ this.todayEarnings += amount;
298
+ this.todayTasks += 1;
299
+ try {
300
+ fs.appendFileSync(this.ledgerFile, JSON.stringify(entry) + "\n");
301
+ } catch {}
302
+ }
303
+ /** Get a summary of earnings. */
304
+ getSummary() {
305
+ const today = this.utcDateString();
306
+ if (today !== this.todayDate) {
307
+ this.todayEarnings = 0;
308
+ this.todayTasks = 0;
309
+ this.todayDate = today;
310
+ }
311
+ const hoursToday = this.hoursSinceSessionStart();
312
+ const hourlyRate = hoursToday > 0 ? this.sessionEarnings / hoursToday : 0;
313
+ const estimatedMonthlyUCU = hourlyRate * 24 * 30;
314
+ const estimatedAnnualUCU = hourlyRate * 24 * 365;
315
+ return {
316
+ session: round(this.sessionEarnings),
317
+ today: round(this.todayEarnings),
318
+ allTime: round(this.allTimeEarnings),
319
+ tasksThisSession: this.sessionTasks,
320
+ tasksToday: this.todayTasks,
321
+ tasksAllTime: this.allTimeTasks,
322
+ estimatedMonthlySavingsUSD: round(estimatedMonthlyUCU * UCU_TO_USD),
323
+ estimatedAnnualSavingsUSD: round(estimatedAnnualUCU * UCU_TO_USD)
324
+ };
325
+ }
326
+ /** Get raw ledger entries for a date range. */
327
+ getLedger(fromDate, toDate) {
328
+ if (!fs.existsSync(this.ledgerFile)) return [];
329
+ const lines = fs.readFileSync(this.ledgerFile, "utf-8").trim().split("\n");
330
+ const entries = [];
331
+ for (const line of lines) {
332
+ if (!line.trim()) continue;
333
+ try {
334
+ const entry = JSON.parse(line);
335
+ if (fromDate && entry.timestamp < fromDate) continue;
336
+ if (toDate && entry.timestamp > toDate) continue;
337
+ entries.push(entry);
338
+ } catch {}
339
+ }
340
+ return entries;
341
+ }
342
+ loadHistorical() {
343
+ if (!fs.existsSync(this.ledgerFile)) return;
344
+ const today = this.utcDateString();
345
+ const lines = fs.readFileSync(this.ledgerFile, "utf-8").trim().split("\n");
346
+ for (const line of lines) {
347
+ if (!line.trim()) continue;
348
+ try {
349
+ const entry = JSON.parse(line);
350
+ this.allTimeEarnings += entry.amount;
351
+ this.allTimeTasks += 1;
352
+ if (entry.timestamp.startsWith(today)) {
353
+ this.todayEarnings += entry.amount;
354
+ this.todayTasks += 1;
355
+ }
356
+ } catch {}
357
+ }
358
+ }
359
+ utcDateString() {
360
+ return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
361
+ }
362
+ hoursSinceSessionStart() {
363
+ return (Date.now() - new Date(this.sessionStart).getTime()) / (1e3 * 60 * 60);
364
+ }
365
+ };
366
+ function round(n, decimals = 4) {
367
+ const factor = 10 ** decimals;
368
+ return Math.round(n * factor) / factor;
369
+ }
370
+ var ResourceMonitor = class {
371
+ limits;
372
+ lastCpuInfo = null;
373
+ lastCpuTime = 0;
374
+ pollTimer = null;
375
+ currentSnapshot;
376
+ bytesTransferred = 0;
377
+ lastBandwidthCheck = Date.now();
378
+ constructor(limits) {
379
+ this.limits = limits;
380
+ this.currentSnapshot = {
381
+ cpuPercent: 0,
382
+ ramMB: 0,
383
+ bandwidthMbps: 0,
384
+ timestamp: Date.now()
385
+ };
386
+ }
387
+ /** Start polling resource usage. */
388
+ start(intervalMs = 2e3) {
389
+ this.lastCpuInfo = os.cpus();
390
+ this.lastCpuTime = Date.now();
391
+ this.poll();
392
+ this.pollTimer = setInterval(() => this.poll(), intervalMs);
393
+ }
394
+ /** Stop polling. */
395
+ stop() {
396
+ if (this.pollTimer) {
397
+ clearInterval(this.pollTimer);
398
+ this.pollTimer = null;
399
+ }
400
+ }
401
+ /** Record bytes transferred for bandwidth estimation. */
402
+ recordBytes(bytes) {
403
+ this.bytesTransferred += bytes;
404
+ }
405
+ /** Get the latest resource snapshot. */
406
+ getSnapshot() {
407
+ return { ...this.currentSnapshot };
408
+ }
409
+ /** Check whether we have capacity to accept a new task. */
410
+ hasCapacity() {
411
+ const snap = this.currentSnapshot;
412
+ return snap.cpuPercent < this.limits.maxCpuPercent && snap.ramMB < this.limits.maxRamMB && snap.bandwidthMbps < this.limits.maxBandwidthMbps;
413
+ }
414
+ /** Get the current resource limits. */
415
+ getLimits() {
416
+ return { ...this.limits };
417
+ }
418
+ /** Update limits at runtime (e.g. user changes config). */
419
+ updateLimits(limits) {
420
+ this.limits = {
421
+ ...this.limits,
422
+ ...limits
423
+ };
424
+ }
425
+ poll() {
426
+ const now = Date.now();
427
+ const cpus2 = os.cpus();
428
+ let cpuPercent = 0;
429
+ if (this.lastCpuInfo && cpus2.length > 0) {
430
+ let totalDiff = 0;
431
+ let idleDiff = 0;
432
+ for (let i = 0; i < cpus2.length; i++) {
433
+ const prev = this.lastCpuInfo[i];
434
+ const curr = cpus2[i];
435
+ if (!prev || !curr) continue;
436
+ const prevTotal = prev.times.user + prev.times.nice + prev.times.sys + prev.times.idle + prev.times.irq;
437
+ const currTotal = curr.times.user + curr.times.nice + curr.times.sys + curr.times.idle + curr.times.irq;
438
+ totalDiff += currTotal - prevTotal;
439
+ idleDiff += curr.times.idle - prev.times.idle;
440
+ }
441
+ if (totalDiff > 0) cpuPercent = Math.round((totalDiff - idleDiff) / totalDiff * 100);
442
+ }
443
+ this.lastCpuInfo = cpus2;
444
+ this.lastCpuTime = now;
445
+ const ramMB = Math.round(process.memoryUsage.rss() / (1024 * 1024));
446
+ const bwElapsed = (now - this.lastBandwidthCheck) / 1e3;
447
+ let bandwidthMbps = 0;
448
+ if (bwElapsed > 0) {
449
+ bandwidthMbps = Math.round(this.bytesTransferred * 8 / (bwElapsed * 1e6) * 100) / 100;
450
+ this.bytesTransferred = 0;
451
+ this.lastBandwidthCheck = now;
452
+ }
453
+ this.currentSnapshot = {
454
+ cpuPercent,
455
+ ramMB,
456
+ bandwidthMbps,
457
+ timestamp: now
458
+ };
459
+ }
460
+ };
461
+ var TaskProcessor = class {
462
+ monitor;
463
+ activeTasks = /* @__PURE__ */ new Map();
464
+ signFn;
465
+ constructor(monitor, signFn) {
466
+ this.monitor = monitor;
467
+ this.signFn = signFn;
468
+ }
469
+ /** Check whether the node can accept a task right now. */
470
+ canAccept(task) {
471
+ if (!this.monitor.hasCapacity()) return false;
472
+ if (Date.now() > task.deadline) return false;
473
+ if (this.activeTasks.size >= 5) return false;
474
+ return true;
475
+ }
476
+ /** Process a task and return the result. */
477
+ async process(task) {
478
+ this.activeTasks.set(task.id, task);
479
+ const start = Date.now();
480
+ try {
481
+ let output;
482
+ switch (task.payload.kind) {
483
+ case "ping":
484
+ output = await this.processPing(task.payload);
485
+ break;
486
+ case "relay":
487
+ output = await this.processRelay(task.payload);
488
+ break;
489
+ case "compute":
490
+ output = await this.processCompute(task.payload);
491
+ break;
492
+ case "store":
493
+ output = await this.processStore(task.payload);
494
+ break;
495
+ case "validate":
496
+ output = this.processValidate(task.payload);
497
+ break;
498
+ default: throw new Error(`Unknown task type: ${task.payload.kind}`);
499
+ }
500
+ const durationMs = Date.now() - start;
501
+ const proof = this.generateProof(task.id, output, durationMs);
502
+ return {
503
+ taskId: task.id,
504
+ success: true,
505
+ output,
506
+ durationMs,
507
+ proof
508
+ };
509
+ } catch (error) {
510
+ const durationMs = Date.now() - start;
511
+ return {
512
+ taskId: task.id,
513
+ success: false,
514
+ output: error instanceof Error ? error.message : "Unknown error",
515
+ durationMs,
516
+ proof: ""
517
+ };
518
+ } finally {
519
+ this.activeTasks.delete(task.id);
520
+ }
521
+ }
522
+ /** Get number of currently active tasks. */
523
+ getActiveCount() {
524
+ return this.activeTasks.size;
525
+ }
526
+ async processPing(payload) {
527
+ const start = Date.now();
528
+ try {
529
+ const response = await fetch(payload.target, {
530
+ method: "HEAD",
531
+ signal: AbortSignal.timeout(1e4)
532
+ });
533
+ const latencyMs = Date.now() - start;
534
+ const success = response.status === payload.expectedStatusCode;
535
+ return JSON.stringify({
536
+ status: response.status,
537
+ latencyMs,
538
+ success
539
+ });
540
+ } catch (error) {
541
+ const latencyMs = Date.now() - start;
542
+ return JSON.stringify({
543
+ status: 0,
544
+ latencyMs,
545
+ success: false,
546
+ error: error instanceof Error ? error.message : "timeout"
547
+ });
548
+ }
549
+ }
550
+ async processRelay(payload) {
551
+ const sourceResp = await fetch(payload.sourceUrl, { signal: AbortSignal.timeout(3e4) });
552
+ if (!sourceResp.ok) throw new Error(`Source fetch failed: ${sourceResp.status}`);
553
+ const body = await sourceResp.arrayBuffer();
554
+ this.monitor.recordBytes(body.byteLength);
555
+ const destResp = await fetch(payload.destinationUrl, {
556
+ method: "POST",
557
+ body,
558
+ signal: AbortSignal.timeout(3e4)
559
+ });
560
+ this.monitor.recordBytes(body.byteLength);
561
+ return JSON.stringify({
562
+ bytesRelayed: body.byteLength,
563
+ destinationStatus: destResp.status,
564
+ success: destResp.ok
565
+ });
566
+ }
567
+ async processCompute(payload) {
568
+ const timeoutMs = Math.min(payload.timeoutMs, 3e4);
569
+ return new Promise((resolve, reject) => {
570
+ const timer = setTimeout(() => {
571
+ reject(/* @__PURE__ */ new Error("Compute task timed out"));
572
+ }, timeoutMs);
573
+ try {
574
+ const hash = crypto.createHash("sha256").update(payload.workload).update(payload.input).digest("hex");
575
+ clearTimeout(timer);
576
+ resolve(JSON.stringify({
577
+ resultHash: hash,
578
+ inputLength: payload.input.length
579
+ }));
580
+ } catch (error) {
581
+ clearTimeout(timer);
582
+ reject(error);
583
+ }
584
+ });
585
+ }
586
+ async processStore(payload) {
587
+ const data = Buffer.from(payload.data, "base64");
588
+ const hash = crypto.createHash("sha256").update(data).digest("hex");
589
+ this.monitor.recordBytes(data.byteLength);
590
+ return JSON.stringify({
591
+ chunkId: payload.chunkId,
592
+ sizeBytes: data.byteLength,
593
+ hash,
594
+ ttlSec: payload.ttlSec,
595
+ stored: true
596
+ });
597
+ }
598
+ processValidate(payload) {
599
+ const actualHash = crypto.createHash("sha256").update(payload.resultData).digest("hex");
600
+ const valid = actualHash === payload.expectedHash;
601
+ return JSON.stringify({
602
+ resultId: payload.resultId,
603
+ expectedHash: payload.expectedHash,
604
+ actualHash,
605
+ valid
606
+ });
607
+ }
608
+ /** Generate a signed proof-of-work for the completed task. */
609
+ generateProof(taskId, output, durationMs) {
610
+ const proofData = `${taskId}:${crypto.createHash("sha256").update(output).digest("hex")}:${durationMs}`;
611
+ return `${proofData}:${this.signFn(proofData).toString("base64")}`;
612
+ }
613
+ };
614
+ var UCUWallet = class _UCUWallet {
615
+ publicKey;
616
+ privateKey;
617
+ balance = 0;
618
+ pendingBalance = 0;
619
+ totalEarned = 0;
620
+ lastPayout = null;
621
+ stateFile;
622
+ constructor(publicKey, privateKey, stateFile) {
623
+ this.publicKey = publicKey;
624
+ this.privateKey = privateKey;
625
+ this.stateFile = stateFile;
626
+ }
627
+ /**
628
+ * Load or create a wallet from the given data directory.
629
+ * If a keypair exists on disk, it is loaded. Otherwise a new
630
+ * Ed25519 keypair is generated and saved.
631
+ */
632
+ static async init(dataDir) {
633
+ const keyFile = path.join(dataDir, "wallet.key");
634
+ const stateFile = path.join(dataDir, "wallet.json");
635
+ fs.mkdirSync(dataDir, { recursive: true });
636
+ let publicKey;
637
+ let privateKey;
638
+ if (fs.existsSync(keyFile)) {
639
+ const raw = fs.readFileSync(keyFile, "utf-8");
640
+ const parsed = JSON.parse(raw);
641
+ publicKey = parsed.publicKey;
642
+ privateKey = crypto.createPrivateKey({
643
+ key: Buffer.from(parsed.privateKey, "base64"),
644
+ format: "der",
645
+ type: "pkcs8"
646
+ });
647
+ } else {
648
+ const pair = crypto.generateKeyPairSync("ed25519");
649
+ const pubDer = pair.publicKey.export({
650
+ type: "spki",
651
+ format: "der"
652
+ }).toString("base64");
653
+ const privDer = pair.privateKey.export({
654
+ type: "pkcs8",
655
+ format: "der"
656
+ }).toString("base64");
657
+ publicKey = pubDer;
658
+ privateKey = pair.privateKey;
659
+ fs.writeFileSync(keyFile, JSON.stringify({
660
+ publicKey: pubDer,
661
+ privateKey: privDer
662
+ }), { mode: 384 });
663
+ }
664
+ const wallet = new _UCUWallet(publicKey, privateKey, stateFile);
665
+ if (fs.existsSync(stateFile)) try {
666
+ const saved = JSON.parse(fs.readFileSync(stateFile, "utf-8"));
667
+ wallet.balance = saved.balance ?? 0;
668
+ wallet.pendingBalance = saved.pendingBalance ?? 0;
669
+ wallet.totalEarned = saved.totalEarned ?? 0;
670
+ wallet.lastPayout = saved.lastPayout ?? null;
671
+ } catch {}
672
+ return wallet;
673
+ }
674
+ /** Get the node's public key (base64 DER). */
675
+ getPublicKey() {
676
+ return this.publicKey;
677
+ }
678
+ /** Get a short node ID derived from the public key. */
679
+ getNodeId() {
680
+ return `svrn-${crypto.createHash("sha256").update(this.publicKey).digest("hex").slice(0, 12)}`;
681
+ }
682
+ /** Sign arbitrary data with the node's private key. */
683
+ sign(data) {
684
+ return crypto.sign(null, Buffer.from(data), this.privateKey);
685
+ }
686
+ /** Credit UCU for a completed task. */
687
+ credit(amount) {
688
+ this.balance += amount;
689
+ this.totalEarned += amount;
690
+ this.lastPayout = (/* @__PURE__ */ new Date()).toISOString();
691
+ this.persist();
692
+ }
693
+ /** Move amount from balance to pending (e.g. withdrawal request). */
694
+ reserve(amount) {
695
+ if (amount > this.balance) return false;
696
+ this.balance -= amount;
697
+ this.pendingBalance += amount;
698
+ this.persist();
699
+ return true;
700
+ }
701
+ /** Confirm a pending withdrawal. */
702
+ confirmWithdrawal(amount) {
703
+ this.pendingBalance = Math.max(0, this.pendingBalance - amount);
704
+ this.persist();
705
+ }
706
+ /** Get the current wallet state. */
707
+ getState() {
708
+ return {
709
+ publicKey: this.publicKey,
710
+ balance: this.balance,
711
+ pendingBalance: this.pendingBalance,
712
+ totalEarned: this.totalEarned,
713
+ lastPayout: this.lastPayout
714
+ };
715
+ }
716
+ /** Persist wallet state to disk. */
717
+ persist() {
718
+ try {
719
+ fs.writeFileSync(this.stateFile, JSON.stringify({
720
+ publicKey: this.publicKey,
721
+ balance: this.balance,
722
+ pendingBalance: this.pendingBalance,
723
+ totalEarned: this.totalEarned,
724
+ lastPayout: this.lastPayout
725
+ }, null, 2));
726
+ } catch {}
727
+ }
728
+ };
729
+ var SVRNNode = class extends EventEmitter {
730
+ config;
731
+ state = "stopped";
732
+ startTime = 0;
733
+ wallet;
734
+ monitor;
735
+ processor;
736
+ earnings;
737
+ updater;
738
+ heartbeatTimer = null;
739
+ coordinatorConnected = false;
740
+ constructor(config) {
741
+ super();
742
+ this.config = resolveConfig(config);
743
+ }
744
+ /** Start the SVRN node. */
745
+ async start() {
746
+ if (this.state !== "stopped") throw new Error(`Cannot start: node is ${this.state}`);
747
+ this.state = "starting";
748
+ this.emit("state-change", this.state);
749
+ this.wallet = await UCUWallet.init(this.config.dataDir);
750
+ this.monitor = new ResourceMonitor(this.config.resources);
751
+ this.processor = new TaskProcessor(this.monitor, (data) => this.wallet.sign(data));
752
+ this.earnings = new EarningsTracker(this.config.dataDir);
753
+ this.updater = new AutoUpdater(this.config.autoUpdate, this.config.dataDir);
754
+ this.updater.on("update-available", (info) => {
755
+ this.emit("update-available", info);
756
+ });
757
+ this.updater.on("update-installed", (info) => {
758
+ this.emit("update-installed", info);
759
+ });
760
+ this.monitor.start();
761
+ this.updater.start();
762
+ this.startHeartbeat();
763
+ this.startTime = Date.now();
764
+ this.state = "running";
765
+ this.emit("state-change", this.state);
766
+ this.emit("started", this.getNodeId());
767
+ }
768
+ /** Stop the SVRN node gracefully. */
769
+ async stop() {
770
+ if (this.state !== "running") return;
771
+ this.state = "stopping";
772
+ this.emit("state-change", this.state);
773
+ if (this.heartbeatTimer) {
774
+ clearInterval(this.heartbeatTimer);
775
+ this.heartbeatTimer = null;
776
+ }
777
+ this.monitor.stop();
778
+ this.updater.stop();
779
+ await this.deregisterFromCoordinator().catch(() => {});
780
+ this.state = "stopped";
781
+ this.emit("state-change", this.state);
782
+ this.emit("stopped");
783
+ }
784
+ /** Get the node's unique ID. */
785
+ getNodeId() {
786
+ return this.config.nodeId ?? this.wallet?.getNodeId() ?? "unknown";
787
+ }
788
+ /** Get the current node status. */
789
+ getStatus() {
790
+ const uptime = this.state === "running" ? Math.floor((Date.now() - this.startTime) / 1e3) : 0;
791
+ return {
792
+ state: this.state,
793
+ nodeId: this.getNodeId(),
794
+ uptime,
795
+ resources: this.monitor?.getSnapshot() ?? {
796
+ cpuPercent: 0,
797
+ ramMB: 0,
798
+ bandwidthMbps: 0,
799
+ timestamp: Date.now()
800
+ },
801
+ earnings: this.earnings?.getSummary() ?? {
802
+ session: 0,
803
+ today: 0,
804
+ allTime: 0,
805
+ tasksThisSession: 0,
806
+ tasksToday: 0,
807
+ tasksAllTime: 0,
808
+ estimatedMonthlySavingsUSD: 0,
809
+ estimatedAnnualSavingsUSD: 0
810
+ },
811
+ wallet: this.wallet?.getState() ?? {
812
+ publicKey: "",
813
+ balance: 0,
814
+ pendingBalance: 0,
815
+ totalEarned: 0,
816
+ lastPayout: null
817
+ },
818
+ activeTasks: this.processor?.getActiveCount() ?? 0,
819
+ version: this.updater?.getVersion() ?? "0.0.0",
820
+ connectedToCoordinator: this.coordinatorConnected
821
+ };
822
+ }
823
+ /** Get earnings summary. */
824
+ getEarnings() {
825
+ return this.earnings.getSummary();
826
+ }
827
+ /** Get wallet state. */
828
+ getWallet() {
829
+ return this.wallet.getState();
830
+ }
831
+ /** Get resource snapshot. */
832
+ getResources() {
833
+ return this.monitor.getSnapshot();
834
+ }
835
+ /** Get the list of accepted task types. */
836
+ getTaskTypes() {
837
+ return [...this.config.taskTypes];
838
+ }
839
+ /** Manually trigger an update check. */
840
+ async checkForUpdates() {
841
+ return this.updater.check();
842
+ }
843
+ /** Submit a task to this node for processing. */
844
+ async submitTask(task) {
845
+ if (this.state !== "running") throw new Error("Node is not running");
846
+ if (!this.processor.canAccept(task)) throw new Error("Node cannot accept task: at capacity or deadline passed");
847
+ this.emit("task-received", task);
848
+ const result = await this.processor.process(task);
849
+ if (result.success) {
850
+ this.wallet.credit(task.rewardUCU);
851
+ this.earnings.record(task.type, task.id, task.rewardUCU, result.durationMs);
852
+ this.emit("task-completed", result);
853
+ } else this.emit("task-failed", result);
854
+ return result;
855
+ }
856
+ startHeartbeat() {
857
+ this.registerWithCoordinator();
858
+ this.heartbeatTimer = setInterval(() => void this.sendHeartbeat(), this.config.heartbeatIntervalSec * 1e3);
859
+ }
860
+ async registerWithCoordinator() {
861
+ try {
862
+ const response = await fetch(`${this.config.coordinatorUrl}/api/nodes/register`, {
863
+ method: "POST",
864
+ headers: { "Content-Type": "application/json" },
865
+ body: JSON.stringify({
866
+ nodeId: this.getNodeId(),
867
+ publicKey: this.wallet.getPublicKey(),
868
+ capabilities: this.config.taskTypes,
869
+ resources: this.monitor.getSnapshot(),
870
+ version: this.updater.getVersion()
871
+ }),
872
+ signal: AbortSignal.timeout(1e4)
873
+ });
874
+ this.coordinatorConnected = response.ok;
875
+ if (response.ok) this.emit("coordinator-connected");
876
+ } catch {
877
+ this.coordinatorConnected = false;
878
+ }
879
+ }
880
+ async sendHeartbeat() {
881
+ try {
882
+ const response = await fetch(`${this.config.coordinatorUrl}/api/nodes/heartbeat`, {
883
+ method: "POST",
884
+ headers: { "Content-Type": "application/json" },
885
+ body: JSON.stringify({
886
+ nodeId: this.getNodeId(),
887
+ resources: this.monitor.getSnapshot(),
888
+ activeTasks: this.processor.getActiveCount(),
889
+ earnings: this.earnings.getSummary()
890
+ }),
891
+ signal: AbortSignal.timeout(1e4)
892
+ });
893
+ const wasConnected = this.coordinatorConnected;
894
+ this.coordinatorConnected = response.ok;
895
+ if (!wasConnected && response.ok) this.emit("coordinator-connected");
896
+ else if (wasConnected && !response.ok) this.emit("coordinator-disconnected");
897
+ if (response.ok) {
898
+ const data = await response.json();
899
+ if (data.tasks && Array.isArray(data.tasks)) for (const task of data.tasks) this.submitTask(task);
900
+ }
901
+ } catch {
902
+ if (this.coordinatorConnected) {
903
+ this.coordinatorConnected = false;
904
+ this.emit("coordinator-disconnected");
905
+ }
906
+ }
907
+ }
908
+ async deregisterFromCoordinator() {
909
+ try {
910
+ await fetch(`${this.config.coordinatorUrl}/api/nodes/deregister`, {
911
+ method: "POST",
912
+ headers: { "Content-Type": "application/json" },
913
+ body: JSON.stringify({ nodeId: this.getNodeId() }),
914
+ signal: AbortSignal.timeout(5e3)
915
+ });
916
+ } catch {}
917
+ }
918
+ };
919
+ function createNode(config) {
920
+ return new SVRNNode(config);
921
+ }
922
+ async function startNode(config) {
923
+ const node = createNode(config);
924
+ await node.start();
925
+ return node;
926
+ }
927
+
928
+ //#endregion
929
+ export { ALL_TASK_TYPES, AutoUpdater, DEFAULT_CONFIG, EarningsTracker, ResourceMonitor, SVRNNode, TaskProcessor, UCUWallet, createNode, resolveConfig, startNode };