@aria-cli/tools 1.0.13 → 1.0.14

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 (465) hide show
  1. package/dist/ask-user-interaction.d.ts +0 -1
  2. package/dist/cache/web-cache.d.ts +0 -1
  3. package/dist/definitions/arion.d.ts +0 -1
  4. package/dist/definitions/browser/browser.d.ts +0 -1
  5. package/dist/definitions/browser/index.d.ts +0 -1
  6. package/dist/definitions/browser/pw-downloads.d.ts +0 -1
  7. package/dist/definitions/browser/pw-interactions.d.ts +0 -1
  8. package/dist/definitions/browser/pw-responses.d.ts +0 -1
  9. package/dist/definitions/browser/pw-session.d.ts +0 -1
  10. package/dist/definitions/browser/pw-shared.d.ts +0 -1
  11. package/dist/definitions/browser/pw-snapshot.d.ts +0 -1
  12. package/dist/definitions/browser/pw-state.d.ts +0 -1
  13. package/dist/definitions/browser/types.d.ts +0 -1
  14. package/dist/definitions/code-intelligence.d.ts +0 -1
  15. package/dist/definitions/core.d.ts +0 -1
  16. package/dist/definitions/delegation.d.ts +0 -1
  17. package/dist/definitions/deploy.d.ts +0 -1
  18. package/dist/definitions/filesystem.d.ts +0 -1
  19. package/dist/definitions/frg.d.ts +0 -1
  20. package/dist/definitions/index.d.ts +0 -1
  21. package/dist/definitions/memory.d.ts +0 -1
  22. package/dist/definitions/messaging.d.ts +0 -1
  23. package/dist/definitions/meta.d.ts +0 -1
  24. package/dist/definitions/network.d.ts +0 -1
  25. package/dist/definitions/outlook.d.ts +0 -1
  26. package/dist/definitions/patch/apply-patch.d.ts +0 -1
  27. package/dist/definitions/patch/fuzzy-match.d.ts +0 -1
  28. package/dist/definitions/patch/index.d.ts +0 -1
  29. package/dist/definitions/patch/patch-parser.d.ts +0 -1
  30. package/dist/definitions/patch/sandbox-paths.d.ts +0 -1
  31. package/dist/definitions/process/index.d.ts +0 -1
  32. package/dist/definitions/process/process-registry.d.ts +0 -1
  33. package/dist/definitions/process/process.d.ts +0 -1
  34. package/dist/definitions/process/pty-keys.d.ts +0 -1
  35. package/dist/definitions/process/session-slug.d.ts +0 -1
  36. package/dist/definitions/quip.d.ts +0 -1
  37. package/dist/definitions/search.d.ts +0 -1
  38. package/dist/definitions/session-history.d.ts +0 -1
  39. package/dist/definitions/shell.d.ts +0 -1
  40. package/dist/definitions/slack.d.ts +0 -1
  41. package/dist/definitions/web.d.ts +0 -1
  42. package/dist/executors/apply-patch.d.ts +0 -1
  43. package/dist/executors/arion.d.ts +0 -1
  44. package/dist/executors/code-intelligence.d.ts +0 -1
  45. package/dist/executors/deploy.d.ts +0 -1
  46. package/dist/executors/filesystem.d.ts +0 -1
  47. package/dist/executors/frg-freshness.d.ts +0 -1
  48. package/dist/executors/frg.d.ts +0 -1
  49. package/dist/executors/index.d.ts +0 -1
  50. package/dist/executors/learning-meta.d.ts +0 -1
  51. package/dist/executors/lsp-client.d.ts +0 -1
  52. package/dist/executors/memory.d.ts +0 -1
  53. package/dist/executors/meta.d.ts +0 -1
  54. package/dist/executors/process-registry.d.ts +0 -1
  55. package/dist/executors/pty-session-store.d.ts +0 -1
  56. package/dist/executors/pty.d.ts +0 -1
  57. package/dist/executors/restart.d.ts +0 -1
  58. package/dist/executors/search-freshness.d.ts +0 -1
  59. package/dist/executors/search-types.d.ts +0 -1
  60. package/dist/executors/search.d.ts +0 -1
  61. package/dist/executors/self-diagnose.d.ts +0 -1
  62. package/dist/executors/session-history.d.ts +0 -1
  63. package/dist/executors/shell-safety.d.ts +0 -1
  64. package/dist/executors/shell.d.ts +0 -1
  65. package/dist/executors/utils.d.ts +0 -1
  66. package/dist/executors/web.d.ts +0 -1
  67. package/dist/extraction/content-extraction.d.ts +0 -1
  68. package/dist/extraction/index.d.ts +0 -1
  69. package/dist/headless-control-contract.d.ts +0 -1
  70. package/dist/index.d.ts +0 -1
  71. package/dist/index.js +378 -71
  72. package/dist/local-control-http-auth.d.ts +0 -1
  73. package/dist/mcp/client.d.ts +0 -1
  74. package/dist/mcp/connection.d.ts +0 -1
  75. package/dist/mcp/index.d.ts +0 -1
  76. package/dist/mcp/jsonrpc.d.ts +0 -1
  77. package/dist/mcp/types.d.ts +0 -1
  78. package/dist/network-control-adapter.d.ts +0 -1
  79. package/dist/network-runtime/address-types.d.ts +0 -1
  80. package/dist/network-runtime/db-owner-fencing.d.ts +0 -1
  81. package/dist/network-runtime/delivery-receipts.d.ts +0 -1
  82. package/dist/network-runtime/direct-endpoint-authority.d.ts +0 -1
  83. package/dist/network-runtime/index.d.ts +0 -1
  84. package/dist/network-runtime/index.js +8 -13
  85. package/dist/network-runtime/local-control-contract.d.ts +0 -1
  86. package/dist/network-runtime/node-store-contract.d.ts +0 -1
  87. package/dist/network-runtime/pair-route-contract.d.ts +0 -1
  88. package/dist/network-runtime/peer-capabilities.d.ts +0 -1
  89. package/dist/network-runtime/peer-principal-ref.d.ts +0 -1
  90. package/dist/network-runtime/peer-state-machine.d.ts +0 -1
  91. package/dist/network-runtime/protocol-schemas.d.ts +0 -1
  92. package/dist/network-runtime/runtime-bootstrap-contract.d.ts +0 -1
  93. package/dist/outlook/desktop-session.d.ts +0 -1
  94. package/dist/policy.d.ts +0 -1
  95. package/dist/providers/brave.d.ts +0 -1
  96. package/dist/providers/duckduckgo.d.ts +0 -1
  97. package/dist/providers/exa.d.ts +0 -1
  98. package/dist/providers/firecrawl.d.ts +0 -1
  99. package/dist/providers/index.d.ts +0 -1
  100. package/dist/providers/jina.d.ts +0 -1
  101. package/dist/providers/router.d.ts +0 -1
  102. package/dist/providers/search-provider.d.ts +0 -1
  103. package/dist/providers/tavily.d.ts +0 -1
  104. package/dist/quip/desktop-session.d.ts +0 -1
  105. package/dist/registry/index.d.ts +0 -1
  106. package/dist/registry/registry.d.ts +0 -1
  107. package/dist/runtime-socket-local-control-client.d.ts +0 -1
  108. package/dist/security/dns-normalization.d.ts +0 -1
  109. package/dist/security/dns-pinning.d.ts +0 -1
  110. package/dist/security/external-content.d.ts +0 -1
  111. package/dist/security/ssrf.d.ts +0 -1
  112. package/dist/slack/desktop-session.d.ts +0 -1
  113. package/dist/tool-factory.d.ts +0 -1
  114. package/dist/types.d.ts +0 -1
  115. package/dist/utils/retry.d.ts +0 -1
  116. package/dist/utils/safe-parse-json.d.ts +0 -1
  117. package/dist/utils/url.d.ts +0 -1
  118. package/dist-cjs/index.js +107 -107
  119. package/dist-cjs/network-runtime/index.js +3 -3
  120. package/package.json +9 -7
  121. package/dist/.tsbuildinfo +0 -1
  122. package/dist/ask-user-interaction.d.ts.map +0 -1
  123. package/dist/ask-user-interaction.js +0 -23
  124. package/dist/ask-user-interaction.js.map +0 -1
  125. package/dist/cache/web-cache.d.ts.map +0 -1
  126. package/dist/cache/web-cache.js +0 -67
  127. package/dist/cache/web-cache.js.map +0 -1
  128. package/dist/definitions/arion.d.ts.map +0 -1
  129. package/dist/definitions/arion.js +0 -105
  130. package/dist/definitions/arion.js.map +0 -1
  131. package/dist/definitions/browser/browser.d.ts.map +0 -1
  132. package/dist/definitions/browser/browser.js +0 -419
  133. package/dist/definitions/browser/browser.js.map +0 -1
  134. package/dist/definitions/browser/index.d.ts.map +0 -1
  135. package/dist/definitions/browser/index.js +0 -5
  136. package/dist/definitions/browser/index.js.map +0 -1
  137. package/dist/definitions/browser/pw-downloads.d.ts.map +0 -1
  138. package/dist/definitions/browser/pw-downloads.js +0 -115
  139. package/dist/definitions/browser/pw-downloads.js.map +0 -1
  140. package/dist/definitions/browser/pw-interactions.d.ts.map +0 -1
  141. package/dist/definitions/browser/pw-interactions.js +0 -200
  142. package/dist/definitions/browser/pw-interactions.js.map +0 -1
  143. package/dist/definitions/browser/pw-responses.d.ts.map +0 -1
  144. package/dist/definitions/browser/pw-responses.js +0 -77
  145. package/dist/definitions/browser/pw-responses.js.map +0 -1
  146. package/dist/definitions/browser/pw-session.d.ts.map +0 -1
  147. package/dist/definitions/browser/pw-session.js +0 -311
  148. package/dist/definitions/browser/pw-session.js.map +0 -1
  149. package/dist/definitions/browser/pw-shared.d.ts.map +0 -1
  150. package/dist/definitions/browser/pw-shared.js +0 -67
  151. package/dist/definitions/browser/pw-shared.js.map +0 -1
  152. package/dist/definitions/browser/pw-snapshot.d.ts.map +0 -1
  153. package/dist/definitions/browser/pw-snapshot.js +0 -302
  154. package/dist/definitions/browser/pw-snapshot.js.map +0 -1
  155. package/dist/definitions/browser/pw-state.d.ts.map +0 -1
  156. package/dist/definitions/browser/pw-state.js +0 -63
  157. package/dist/definitions/browser/pw-state.js.map +0 -1
  158. package/dist/definitions/browser/types.d.ts.map +0 -1
  159. package/dist/definitions/browser/types.js +0 -5
  160. package/dist/definitions/browser/types.js.map +0 -1
  161. package/dist/definitions/code-intelligence.d.ts.map +0 -1
  162. package/dist/definitions/code-intelligence.js +0 -471
  163. package/dist/definitions/code-intelligence.js.map +0 -1
  164. package/dist/definitions/core.d.ts.map +0 -1
  165. package/dist/definitions/core.js +0 -110
  166. package/dist/definitions/core.js.map +0 -1
  167. package/dist/definitions/delegation.d.ts.map +0 -1
  168. package/dist/definitions/delegation.js +0 -513
  169. package/dist/definitions/delegation.js.map +0 -1
  170. package/dist/definitions/deploy.d.ts.map +0 -1
  171. package/dist/definitions/deploy.js +0 -66
  172. package/dist/definitions/deploy.js.map +0 -1
  173. package/dist/definitions/filesystem.d.ts.map +0 -1
  174. package/dist/definitions/filesystem.js +0 -197
  175. package/dist/definitions/filesystem.js.map +0 -1
  176. package/dist/definitions/frg.d.ts.map +0 -1
  177. package/dist/definitions/frg.js +0 -64
  178. package/dist/definitions/frg.js.map +0 -1
  179. package/dist/definitions/index.d.ts.map +0 -1
  180. package/dist/definitions/index.js +0 -21
  181. package/dist/definitions/index.js.map +0 -1
  182. package/dist/definitions/memory.d.ts.map +0 -1
  183. package/dist/definitions/memory.js +0 -124
  184. package/dist/definitions/memory.js.map +0 -1
  185. package/dist/definitions/messaging.d.ts.map +0 -1
  186. package/dist/definitions/messaging.js +0 -626
  187. package/dist/definitions/messaging.js.map +0 -1
  188. package/dist/definitions/meta.d.ts.map +0 -1
  189. package/dist/definitions/meta.js +0 -350
  190. package/dist/definitions/meta.js.map +0 -1
  191. package/dist/definitions/network.d.ts.map +0 -1
  192. package/dist/definitions/network.js +0 -160
  193. package/dist/definitions/network.js.map +0 -1
  194. package/dist/definitions/outlook.d.ts.map +0 -1
  195. package/dist/definitions/outlook.js +0 -278
  196. package/dist/definitions/outlook.js.map +0 -1
  197. package/dist/definitions/patch/apply-patch.d.ts.map +0 -1
  198. package/dist/definitions/patch/apply-patch.js +0 -185
  199. package/dist/definitions/patch/apply-patch.js.map +0 -1
  200. package/dist/definitions/patch/fuzzy-match.d.ts.map +0 -1
  201. package/dist/definitions/patch/fuzzy-match.js +0 -167
  202. package/dist/definitions/patch/fuzzy-match.js.map +0 -1
  203. package/dist/definitions/patch/index.d.ts.map +0 -1
  204. package/dist/definitions/patch/index.js +0 -2
  205. package/dist/definitions/patch/index.js.map +0 -1
  206. package/dist/definitions/patch/patch-parser.d.ts.map +0 -1
  207. package/dist/definitions/patch/patch-parser.js +0 -208
  208. package/dist/definitions/patch/patch-parser.js.map +0 -1
  209. package/dist/definitions/patch/sandbox-paths.d.ts.map +0 -1
  210. package/dist/definitions/patch/sandbox-paths.js +0 -106
  211. package/dist/definitions/patch/sandbox-paths.js.map +0 -1
  212. package/dist/definitions/process/index.d.ts.map +0 -1
  213. package/dist/definitions/process/index.js +0 -5
  214. package/dist/definitions/process/index.js.map +0 -1
  215. package/dist/definitions/process/process-registry.d.ts.map +0 -1
  216. package/dist/definitions/process/process-registry.js +0 -214
  217. package/dist/definitions/process/process-registry.js.map +0 -1
  218. package/dist/definitions/process/process.d.ts.map +0 -1
  219. package/dist/definitions/process/process.js +0 -387
  220. package/dist/definitions/process/process.js.map +0 -1
  221. package/dist/definitions/process/pty-keys.d.ts.map +0 -1
  222. package/dist/definitions/process/pty-keys.js +0 -255
  223. package/dist/definitions/process/pty-keys.js.map +0 -1
  224. package/dist/definitions/process/session-slug.d.ts.map +0 -1
  225. package/dist/definitions/process/session-slug.js +0 -143
  226. package/dist/definitions/process/session-slug.js.map +0 -1
  227. package/dist/definitions/quip.d.ts.map +0 -1
  228. package/dist/definitions/quip.js +0 -196
  229. package/dist/definitions/quip.js.map +0 -1
  230. package/dist/definitions/search.d.ts.map +0 -1
  231. package/dist/definitions/search.js +0 -61
  232. package/dist/definitions/search.js.map +0 -1
  233. package/dist/definitions/session-history.d.ts.map +0 -1
  234. package/dist/definitions/session-history.js +0 -70
  235. package/dist/definitions/session-history.js.map +0 -1
  236. package/dist/definitions/shell.d.ts.map +0 -1
  237. package/dist/definitions/shell.js +0 -182
  238. package/dist/definitions/shell.js.map +0 -1
  239. package/dist/definitions/slack.d.ts.map +0 -1
  240. package/dist/definitions/slack.js +0 -181
  241. package/dist/definitions/slack.js.map +0 -1
  242. package/dist/definitions/web.d.ts.map +0 -1
  243. package/dist/definitions/web.js +0 -110
  244. package/dist/definitions/web.js.map +0 -1
  245. package/dist/executors/apply-patch.d.ts.map +0 -1
  246. package/dist/executors/apply-patch.js +0 -902
  247. package/dist/executors/apply-patch.js.map +0 -1
  248. package/dist/executors/arion.d.ts.map +0 -1
  249. package/dist/executors/arion.js +0 -120
  250. package/dist/executors/arion.js.map +0 -1
  251. package/dist/executors/code-intelligence.d.ts.map +0 -1
  252. package/dist/executors/code-intelligence.js +0 -883
  253. package/dist/executors/code-intelligence.js.map +0 -1
  254. package/dist/executors/deploy.d.ts.map +0 -1
  255. package/dist/executors/deploy.js +0 -849
  256. package/dist/executors/deploy.js.map +0 -1
  257. package/dist/executors/filesystem.d.ts.map +0 -1
  258. package/dist/executors/filesystem.js +0 -1123
  259. package/dist/executors/filesystem.js.map +0 -1
  260. package/dist/executors/frg-freshness.d.ts.map +0 -1
  261. package/dist/executors/frg-freshness.js +0 -577
  262. package/dist/executors/frg-freshness.js.map +0 -1
  263. package/dist/executors/frg.d.ts.map +0 -1
  264. package/dist/executors/frg.js +0 -299
  265. package/dist/executors/frg.js.map +0 -1
  266. package/dist/executors/index.d.ts.map +0 -1
  267. package/dist/executors/index.js +0 -47
  268. package/dist/executors/index.js.map +0 -1
  269. package/dist/executors/learning-meta.d.ts.map +0 -1
  270. package/dist/executors/learning-meta.js +0 -1147
  271. package/dist/executors/learning-meta.js.map +0 -1
  272. package/dist/executors/lsp-client.d.ts.map +0 -1
  273. package/dist/executors/lsp-client.js +0 -297
  274. package/dist/executors/lsp-client.js.map +0 -1
  275. package/dist/executors/memory.d.ts.map +0 -1
  276. package/dist/executors/memory.js +0 -751
  277. package/dist/executors/memory.js.map +0 -1
  278. package/dist/executors/meta.d.ts.map +0 -1
  279. package/dist/executors/meta.js +0 -221
  280. package/dist/executors/meta.js.map +0 -1
  281. package/dist/executors/process-registry.d.ts.map +0 -1
  282. package/dist/executors/process-registry.js +0 -466
  283. package/dist/executors/process-registry.js.map +0 -1
  284. package/dist/executors/pty-session-store.d.ts.map +0 -1
  285. package/dist/executors/pty-session-store.js +0 -31
  286. package/dist/executors/pty-session-store.js.map +0 -1
  287. package/dist/executors/pty.d.ts.map +0 -1
  288. package/dist/executors/pty.js +0 -272
  289. package/dist/executors/pty.js.map +0 -1
  290. package/dist/executors/restart.d.ts.map +0 -1
  291. package/dist/executors/restart.js +0 -120
  292. package/dist/executors/restart.js.map +0 -1
  293. package/dist/executors/search-freshness.d.ts.map +0 -1
  294. package/dist/executors/search-freshness.js +0 -196
  295. package/dist/executors/search-freshness.js.map +0 -1
  296. package/dist/executors/search-types.d.ts.map +0 -1
  297. package/dist/executors/search-types.js +0 -53
  298. package/dist/executors/search-types.js.map +0 -1
  299. package/dist/executors/search.d.ts.map +0 -1
  300. package/dist/executors/search.js +0 -67
  301. package/dist/executors/search.js.map +0 -1
  302. package/dist/executors/self-diagnose.d.ts.map +0 -1
  303. package/dist/executors/self-diagnose.js +0 -399
  304. package/dist/executors/self-diagnose.js.map +0 -1
  305. package/dist/executors/session-history.d.ts.map +0 -1
  306. package/dist/executors/session-history.js +0 -284
  307. package/dist/executors/session-history.js.map +0 -1
  308. package/dist/executors/shell-safety.d.ts.map +0 -1
  309. package/dist/executors/shell-safety.js +0 -474
  310. package/dist/executors/shell-safety.js.map +0 -1
  311. package/dist/executors/shell.d.ts.map +0 -1
  312. package/dist/executors/shell.js +0 -955
  313. package/dist/executors/shell.js.map +0 -1
  314. package/dist/executors/utils.d.ts.map +0 -1
  315. package/dist/executors/utils.js +0 -34
  316. package/dist/executors/utils.js.map +0 -1
  317. package/dist/executors/web.d.ts.map +0 -1
  318. package/dist/executors/web.js +0 -543
  319. package/dist/executors/web.js.map +0 -1
  320. package/dist/extraction/content-extraction.d.ts.map +0 -1
  321. package/dist/extraction/content-extraction.js +0 -236
  322. package/dist/extraction/content-extraction.js.map +0 -1
  323. package/dist/extraction/index.d.ts.map +0 -1
  324. package/dist/extraction/index.js +0 -5
  325. package/dist/extraction/index.js.map +0 -1
  326. package/dist/headless-control-contract.d.ts.map +0 -1
  327. package/dist/headless-control-contract.js +0 -968
  328. package/dist/headless-control-contract.js.map +0 -1
  329. package/dist/index.d.ts.map +0 -1
  330. package/dist/index.js.map +0 -1
  331. package/dist/local-control-http-auth.d.ts.map +0 -1
  332. package/dist/local-control-http-auth.js +0 -3
  333. package/dist/local-control-http-auth.js.map +0 -1
  334. package/dist/mcp/client.d.ts.map +0 -1
  335. package/dist/mcp/client.js +0 -182
  336. package/dist/mcp/client.js.map +0 -1
  337. package/dist/mcp/connection.d.ts.map +0 -1
  338. package/dist/mcp/connection.js +0 -481
  339. package/dist/mcp/connection.js.map +0 -1
  340. package/dist/mcp/index.d.ts.map +0 -1
  341. package/dist/mcp/index.js +0 -11
  342. package/dist/mcp/index.js.map +0 -1
  343. package/dist/mcp/jsonrpc.d.ts.map +0 -1
  344. package/dist/mcp/jsonrpc.js +0 -145
  345. package/dist/mcp/jsonrpc.js.map +0 -1
  346. package/dist/mcp/types.d.ts.map +0 -1
  347. package/dist/mcp/types.js +0 -8
  348. package/dist/mcp/types.js.map +0 -1
  349. package/dist/network-control-adapter.d.ts.map +0 -1
  350. package/dist/network-control-adapter.js +0 -73
  351. package/dist/network-control-adapter.js.map +0 -1
  352. package/dist/network-runtime/address-types.d.ts.map +0 -1
  353. package/dist/network-runtime/address-types.js +0 -166
  354. package/dist/network-runtime/address-types.js.map +0 -1
  355. package/dist/network-runtime/db-owner-fencing.d.ts.map +0 -1
  356. package/dist/network-runtime/db-owner-fencing.js +0 -70
  357. package/dist/network-runtime/db-owner-fencing.js.map +0 -1
  358. package/dist/network-runtime/delivery-receipts.d.ts.map +0 -1
  359. package/dist/network-runtime/delivery-receipts.js +0 -268
  360. package/dist/network-runtime/delivery-receipts.js.map +0 -1
  361. package/dist/network-runtime/direct-endpoint-authority.d.ts.map +0 -1
  362. package/dist/network-runtime/direct-endpoint-authority.js +0 -26
  363. package/dist/network-runtime/direct-endpoint-authority.js.map +0 -1
  364. package/dist/network-runtime/index.d.ts.map +0 -1
  365. package/dist/network-runtime/index.js.map +0 -1
  366. package/dist/network-runtime/local-control-contract.d.ts.map +0 -1
  367. package/dist/network-runtime/local-control-contract.js +0 -628
  368. package/dist/network-runtime/local-control-contract.js.map +0 -1
  369. package/dist/network-runtime/node-store-contract.d.ts.map +0 -1
  370. package/dist/network-runtime/node-store-contract.js +0 -35
  371. package/dist/network-runtime/node-store-contract.js.map +0 -1
  372. package/dist/network-runtime/pair-route-contract.d.ts.map +0 -1
  373. package/dist/network-runtime/pair-route-contract.js +0 -78
  374. package/dist/network-runtime/pair-route-contract.js.map +0 -1
  375. package/dist/network-runtime/peer-capabilities.d.ts.map +0 -1
  376. package/dist/network-runtime/peer-capabilities.js +0 -29
  377. package/dist/network-runtime/peer-capabilities.js.map +0 -1
  378. package/dist/network-runtime/peer-principal-ref.d.ts.map +0 -1
  379. package/dist/network-runtime/peer-principal-ref.js +0 -13
  380. package/dist/network-runtime/peer-principal-ref.js.map +0 -1
  381. package/dist/network-runtime/peer-state-machine.d.ts.map +0 -1
  382. package/dist/network-runtime/peer-state-machine.js +0 -122
  383. package/dist/network-runtime/peer-state-machine.js.map +0 -1
  384. package/dist/network-runtime/protocol-schemas.d.ts.map +0 -1
  385. package/dist/network-runtime/protocol-schemas.js +0 -206
  386. package/dist/network-runtime/protocol-schemas.js.map +0 -1
  387. package/dist/network-runtime/runtime-bootstrap-contract.d.ts.map +0 -1
  388. package/dist/network-runtime/runtime-bootstrap-contract.js +0 -61
  389. package/dist/network-runtime/runtime-bootstrap-contract.js.map +0 -1
  390. package/dist/outlook/desktop-session.d.ts.map +0 -1
  391. package/dist/outlook/desktop-session.js +0 -280
  392. package/dist/outlook/desktop-session.js.map +0 -1
  393. package/dist/policy.d.ts.map +0 -1
  394. package/dist/policy.js +0 -150
  395. package/dist/policy.js.map +0 -1
  396. package/dist/providers/brave.d.ts.map +0 -1
  397. package/dist/providers/brave.js +0 -63
  398. package/dist/providers/brave.js.map +0 -1
  399. package/dist/providers/duckduckgo.d.ts.map +0 -1
  400. package/dist/providers/duckduckgo.js +0 -177
  401. package/dist/providers/duckduckgo.js.map +0 -1
  402. package/dist/providers/exa.d.ts.map +0 -1
  403. package/dist/providers/exa.js +0 -64
  404. package/dist/providers/exa.js.map +0 -1
  405. package/dist/providers/firecrawl.d.ts.map +0 -1
  406. package/dist/providers/firecrawl.js +0 -56
  407. package/dist/providers/firecrawl.js.map +0 -1
  408. package/dist/providers/index.d.ts.map +0 -1
  409. package/dist/providers/index.js +0 -8
  410. package/dist/providers/index.js.map +0 -1
  411. package/dist/providers/jina.d.ts.map +0 -1
  412. package/dist/providers/jina.js +0 -50
  413. package/dist/providers/jina.js.map +0 -1
  414. package/dist/providers/router.d.ts.map +0 -1
  415. package/dist/providers/router.js +0 -97
  416. package/dist/providers/router.js.map +0 -1
  417. package/dist/providers/search-provider.d.ts.map +0 -1
  418. package/dist/providers/search-provider.js +0 -33
  419. package/dist/providers/search-provider.js.map +0 -1
  420. package/dist/providers/tavily.d.ts.map +0 -1
  421. package/dist/providers/tavily.js +0 -55
  422. package/dist/providers/tavily.js.map +0 -1
  423. package/dist/quip/desktop-session.d.ts.map +0 -1
  424. package/dist/quip/desktop-session.js +0 -318
  425. package/dist/quip/desktop-session.js.map +0 -1
  426. package/dist/registry/index.d.ts.map +0 -1
  427. package/dist/registry/index.js +0 -2
  428. package/dist/registry/index.js.map +0 -1
  429. package/dist/registry/registry.d.ts.map +0 -1
  430. package/dist/registry/registry.js +0 -757
  431. package/dist/registry/registry.js.map +0 -1
  432. package/dist/runtime-socket-local-control-client.d.ts.map +0 -1
  433. package/dist/runtime-socket-local-control-client.js +0 -331
  434. package/dist/runtime-socket-local-control-client.js.map +0 -1
  435. package/dist/security/dns-normalization.d.ts.map +0 -1
  436. package/dist/security/dns-normalization.js +0 -20
  437. package/dist/security/dns-normalization.js.map +0 -1
  438. package/dist/security/dns-pinning.d.ts.map +0 -1
  439. package/dist/security/dns-pinning.js +0 -124
  440. package/dist/security/dns-pinning.js.map +0 -1
  441. package/dist/security/external-content.d.ts.map +0 -1
  442. package/dist/security/external-content.js +0 -92
  443. package/dist/security/external-content.js.map +0 -1
  444. package/dist/security/ssrf.d.ts.map +0 -1
  445. package/dist/security/ssrf.js +0 -182
  446. package/dist/security/ssrf.js.map +0 -1
  447. package/dist/slack/desktop-session.d.ts.map +0 -1
  448. package/dist/slack/desktop-session.js +0 -325
  449. package/dist/slack/desktop-session.js.map +0 -1
  450. package/dist/tool-factory.d.ts.map +0 -1
  451. package/dist/tool-factory.js +0 -48
  452. package/dist/tool-factory.js.map +0 -1
  453. package/dist/types.d.ts.map +0 -1
  454. package/dist/types.js +0 -8
  455. package/dist/types.js.map +0 -1
  456. package/dist/utils/retry.d.ts.map +0 -1
  457. package/dist/utils/retry.js +0 -133
  458. package/dist/utils/retry.js.map +0 -1
  459. package/dist/utils/safe-parse-json.d.ts.map +0 -1
  460. package/dist/utils/safe-parse-json.js +0 -161
  461. package/dist/utils/safe-parse-json.js.map +0 -1
  462. package/dist/utils/url.d.ts.map +0 -1
  463. package/dist/utils/url.js +0 -20
  464. package/dist/utils/url.js.map +0 -1
  465. package/dist-cjs/.tsbuildinfo +0 -1
@@ -1,849 +0,0 @@
1
- /**
2
- * @aria/tools - Deploy tool executor
3
- *
4
- * Deploys ARIA to a remote machine via SSH. Handles OS detection,
5
- * Node.js installation, repo setup, keypair generation, TLS cert
6
- * discovery/provisioning, firewall configuration, config writing,
7
- * daemon startup, and health check.
8
- */
9
- import { spawn } from "node:child_process";
10
- import { success, fail } from "./utils.js";
11
- // ============================================================================
12
- // Pure Helper Functions (exported for testing)
13
- // ============================================================================
14
- /**
15
- * Detect OS type from `uname -s` output.
16
- */
17
- export function detectOS(unameOutput) {
18
- const trimmed = unameOutput.trim();
19
- if (!trimmed || trimmed === "UNKNOWN") {
20
- return { os: "unknown" };
21
- }
22
- if (trimmed === "Linux") {
23
- return { os: "linux" };
24
- }
25
- if (trimmed === "Darwin") {
26
- return { os: "darwin" };
27
- }
28
- // MINGW, MSYS, CYGWIN, or Windows-style output
29
- if (/^(MINGW|MSYS|CYGWIN)/i.test(trimmed) || /windows/i.test(trimmed)) {
30
- return { os: "windows" };
31
- }
32
- return { os: "unknown" };
33
- }
34
- /**
35
- * Detect Linux distribution from /etc/os-release content.
36
- * Returns the package manager type to use.
37
- */
38
- export function detectLinuxDistro(osReleaseContent) {
39
- const lower = osReleaseContent.toLowerCase();
40
- // Extract ID and ID_LIKE fields
41
- const idMatch = lower.match(/^id=(.+)$/m);
42
- const idLikeMatch = lower.match(/^id_like=(.+)$/m);
43
- const id = idMatch?.[1]?.replace(/"/g, "").trim() ?? "";
44
- const idLike = idLikeMatch?.[1]?.replace(/"/g, "").trim() ?? "";
45
- // Alpine
46
- if (id === "alpine") {
47
- return "apk";
48
- }
49
- // Debian/Ubuntu family
50
- if (id === "debian" ||
51
- id === "ubuntu" ||
52
- idLike.includes("debian") ||
53
- idLike.includes("ubuntu")) {
54
- return "apt";
55
- }
56
- // RHEL/Fedora/CentOS/Amazon Linux family
57
- if (id === "fedora" ||
58
- id === "rhel" ||
59
- id === "centos" ||
60
- id === "amzn" ||
61
- id === "rocky" ||
62
- id === "almalinux" ||
63
- idLike.includes("fedora") ||
64
- idLike.includes("rhel") ||
65
- idLike.includes("centos") ||
66
- idLike.includes("suse")) {
67
- return "dnf";
68
- }
69
- // Default to apt (nvm-based install works universally)
70
- return "apt";
71
- }
72
- /**
73
- * Get the shell command to install Node.js for a given OS and distro.
74
- */
75
- export function getNodeInstallCommand(osInfo, distro) {
76
- switch (osInfo.os) {
77
- case "linux":
78
- switch (distro) {
79
- case "apk":
80
- return "apk add --no-cache nodejs npm";
81
- case "dnf":
82
- return "dnf module install -y nodejs:22 || dnf install -y nodejs";
83
- case "apt":
84
- default:
85
- return ("curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && " +
86
- 'export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" && nvm install 22');
87
- }
88
- case "darwin":
89
- return ("command -v brew >/dev/null && brew install node@22 || " +
90
- "{ curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && " +
91
- 'export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" && nvm install 22; }');
92
- case "windows":
93
- return "winget install --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements";
94
- default:
95
- throw new Error(`Unsupported OS: ${osInfo.os}. Deploy supports Linux, macOS, and Windows.`);
96
- }
97
- }
98
- /**
99
- * Generate firewall commands to open ARIA ports (443/tcp + 51820/udp).
100
- */
101
- export function getFirewallCommands(firewallType) {
102
- switch (firewallType) {
103
- case "ufw":
104
- return "ufw allow 443/tcp && ufw allow 51820/udp";
105
- case "iptables":
106
- return ("iptables -A INPUT -p tcp --dport 443 -j ACCEPT && " +
107
- "iptables -A INPUT -p udp --dport 51820 -j ACCEPT");
108
- case "firewalld":
109
- return ("firewall-cmd --permanent --add-port=443/tcp && " +
110
- "firewall-cmd --permanent --add-port=51820/udp && " +
111
- "firewall-cmd --reload");
112
- case "windows":
113
- return ('netsh advfirewall firewall add rule name="ARIA HTTPS" dir=in action=allow protocol=tcp localport=443 && ' +
114
- 'netsh advfirewall firewall add rule name="ARIA WireGuard" dir=in action=allow protocol=udp localport=51820');
115
- case "none":
116
- return "";
117
- }
118
- }
119
- /**
120
- * Parse TLS cert discovery output from the remote host.
121
- * The discovery script outputs JSON: { found, type?, cert?, key? }
122
- */
123
- export function discoverTlsCerts(sshOutput) {
124
- if (!sshOutput || !sshOutput.trim()) {
125
- return { found: false };
126
- }
127
- try {
128
- const data = JSON.parse(sshOutput.trim());
129
- if (data.found === true && data.cert && data.key) {
130
- return {
131
- found: true,
132
- type: data.type,
133
- cert: data.cert,
134
- key: data.key,
135
- };
136
- }
137
- return { found: false };
138
- }
139
- catch {
140
- return { found: false };
141
- }
142
- }
143
- /**
144
- * Build the config JSON object for ~/.aria/config.json.
145
- */
146
- export function buildConfigJson(params) {
147
- const config = {
148
- arion_name: params.arionName,
149
- };
150
- if (params.coordinationUrl) {
151
- config.coordination_url = params.coordinationUrl;
152
- }
153
- if (params.tlsCert && params.tlsKey) {
154
- config.tls = {
155
- cert: params.tlsCert,
156
- key: params.tlsKey,
157
- };
158
- }
159
- return config;
160
- }
161
- /**
162
- * Construct the health check URL for the deployed daemon.
163
- */
164
- export function buildHealthCheckUrl(host, port) {
165
- const p = port ?? 443;
166
- return `https://${host}:${p}/api/v1/network/peers`;
167
- }
168
- function buildRemoteRuntimePidLookupCommand(repoDir) {
169
- return `
170
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
171
- cd ${repoDir} && node --input-type=module <<'NODE'
172
- import { resolveOrCreateNode, resolveRuntimeRootDirectory, readRuntimeOwnerRecord } from "./packages/server/dist/index.js";
173
- const ariaHome = process.env.ARIA_HOME || (process.env.HOME + "/.aria");
174
- const resolved = await resolveOrCreateNode({ ariaHome });
175
- const record = readRuntimeOwnerRecord(resolveRuntimeRootDirectory(), resolved.nodeId);
176
- if (record?.runtimePid) {
177
- console.log(String(record.runtimePid));
178
- }
179
- NODE
180
- `;
181
- }
182
- function buildRemoteRuntimeStatusLookupCommand(repoDir) {
183
- return `
184
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
185
- cd ${repoDir} && node --input-type=module <<'NODE'
186
- import { createRuntimeSocketLocalControlClient } from "./packages/tools/dist/index.js";
187
- import { resolveOrCreateNode, resolveRuntimeRootDirectory, readRuntimeOwnerRecord } from "./packages/server/dist/index.js";
188
- const ariaHome = process.env.ARIA_HOME || (process.env.HOME + "/.aria");
189
- const resolved = await resolveOrCreateNode({ ariaHome });
190
- const record = readRuntimeOwnerRecord(resolveRuntimeRootDirectory(), resolved.nodeId);
191
- if (!record?.runtimeSocket) {
192
- process.exit(1);
193
- }
194
- const client = createRuntimeSocketLocalControlClient({ runtimeSocket: record.runtimeSocket });
195
- const status = await client.getRuntimeStatus();
196
- console.log(JSON.stringify(status));
197
- NODE
198
- `;
199
- }
200
- // ============================================================================
201
- // Input Validators (A1 — prevent shell injection)
202
- // ============================================================================
203
- /**
204
- * Validate git repo URL — must be HTTPS with no shell metacharacters.
205
- */
206
- export function validateRepoUrl(url) {
207
- if (!url)
208
- return null;
209
- if (!/^https?:\/\/[a-zA-Z0-9.-]+\/[a-zA-Z0-9_.\/-]+(?:\.git)?$/.test(url)) {
210
- return "Invalid repo URL format. Use 'https://host/org/repo.git'.";
211
- }
212
- return null;
213
- }
214
- /**
215
- * Validate branch name — alphanumeric, dots, slashes, hyphens, underscores.
216
- * Rejects shell metacharacters and path traversal.
217
- */
218
- export function validateBranch(branch) {
219
- if (!branch)
220
- return null;
221
- if (!/^[a-zA-Z0-9_.\/-]+$/.test(branch) || branch.includes("..")) {
222
- return "Invalid branch name. Alphanumeric, dots, slashes, hyphens only.";
223
- }
224
- return null;
225
- }
226
- /**
227
- * Validate arion name — alphanumeric, underscores, hyphens only.
228
- */
229
- export function validateArionName(name) {
230
- if (!name)
231
- return null;
232
- if (!/^[a-zA-Z0-9_-]+$/.test(name)) {
233
- return "Invalid arion name. Alphanumeric, underscores, hyphens only.";
234
- }
235
- return null;
236
- }
237
- /**
238
- * Validate SSH key path — reject traversal and shell metacharacters.
239
- */
240
- export function validateSshKeyPath(keyPath) {
241
- if (!keyPath)
242
- return null;
243
- if (keyPath.includes("..") || /[;|&`$(){}!<>]/.test(keyPath)) {
244
- return "Invalid SSH key path. No traversal or shell metacharacters.";
245
- }
246
- return null;
247
- }
248
- /**
249
- * Validate git commit hash — must be 7-64 lowercase hex characters.
250
- * Rejects non-hex, too-short, and shell injection attempts.
251
- */
252
- export function validateCommitHash(hash) {
253
- if (!hash)
254
- return null;
255
- if (!/^[a-f0-9]{7,64}$/.test(hash)) {
256
- return "Invalid commit hash. Must be 7-64 lowercase hex characters.";
257
- }
258
- return null;
259
- }
260
- /**
261
- * Pinned pnpm version — matches packageManager field in root package.json.
262
- * Prevents unpinned `pnpm@latest` from pulling a compromised version.
263
- */
264
- export const PINNED_PNPM_VERSION = "10.28.2";
265
- /**
266
- * Get firewall undo commands to reverse port-opening rules.
267
- */
268
- export function getFirewallUndoCommands(firewallType) {
269
- switch (firewallType) {
270
- case "ufw":
271
- return "ufw delete allow 443/tcp && ufw delete allow 51820/udp";
272
- case "iptables":
273
- return ("iptables -D INPUT -p tcp --dport 443 -j ACCEPT && " +
274
- "iptables -D INPUT -p udp --dport 51820 -j ACCEPT");
275
- case "firewalld":
276
- return ("firewall-cmd --permanent --remove-port=443/tcp && " +
277
- "firewall-cmd --permanent --remove-port=51820/udp && " +
278
- "firewall-cmd --reload");
279
- case "windows":
280
- return ('netsh advfirewall firewall delete rule name="ARIA HTTPS" && ' +
281
- 'netsh advfirewall firewall delete rule name="ARIA WireGuard"');
282
- case "none":
283
- return "";
284
- }
285
- }
286
- /**
287
- * Build rollback commands from recorded deploy steps.
288
- * Returns commands in reverse order (last step undone first).
289
- * Skips steps with empty undoCmd.
290
- */
291
- export function buildRollbackCommands(steps) {
292
- return steps
293
- .filter((s) => s.undoCmd.length > 0)
294
- .reverse()
295
- .map((s) => s.undoCmd);
296
- }
297
- // ============================================================================
298
- // Idempotency — Deep Merge Config (A3)
299
- // ============================================================================
300
- /**
301
- * Deep-merge two config objects. Preserves nested objects from existing config
302
- * while applying updates. Does not mutate inputs.
303
- */
304
- export function deepMergeConfig(existing, update) {
305
- const result = {};
306
- // Copy all existing keys
307
- for (const key of Object.keys(existing)) {
308
- const val = existing[key];
309
- if (val !== null && typeof val === "object" && !Array.isArray(val)) {
310
- result[key] = { ...val };
311
- }
312
- else {
313
- result[key] = val;
314
- }
315
- }
316
- // Apply updates
317
- for (const key of Object.keys(update)) {
318
- const updateVal = update[key];
319
- const existingVal = result[key];
320
- if (updateVal !== null &&
321
- typeof updateVal === "object" &&
322
- !Array.isArray(updateVal) &&
323
- existingVal !== null &&
324
- typeof existingVal === "object" &&
325
- !Array.isArray(existingVal)) {
326
- // Recursive merge for nested objects
327
- result[key] = deepMergeConfig(existingVal, updateVal);
328
- }
329
- else {
330
- result[key] = updateVal;
331
- }
332
- }
333
- return result;
334
- }
335
- // ============================================================================
336
- // Key Permissions (A3)
337
- // ============================================================================
338
- /**
339
- * Get chmod commands to restrict key and config file permissions to owner-only.
340
- */
341
- export function getKeyPermissionCommands() {
342
- return "chmod 600 ~/.aria/signing-key.json && chmod 600 ~/.aria/config.json";
343
- }
344
- // ============================================================================
345
- // SSH Helper
346
- // ============================================================================
347
- /**
348
- * Validate SSH target format — prevent command injection.
349
- */
350
- function validateTarget(target) {
351
- if (!target) {
352
- return "target is required (e.g. 'user@host')";
353
- }
354
- // Block shell metacharacters that could enable injection
355
- if (/[;|&`$(){}!<>\s]/.test(target)) {
356
- return "Invalid target format. Use 'user@host' or 'hostname'.";
357
- }
358
- return null;
359
- }
360
- /**
361
- * Execute a command on the remote host via SSH.
362
- * Returns { stdout, stderr, exitCode }.
363
- */
364
- export function sshExec(target, command, options) {
365
- return new Promise((resolve, reject) => {
366
- const args = [
367
- "-o",
368
- "StrictHostKeyChecking=accept-new",
369
- "-o",
370
- "ConnectTimeout=10",
371
- "-o",
372
- "BatchMode=yes",
373
- ];
374
- if (options?.sshKeyPath) {
375
- args.push("-i", options.sshKeyPath);
376
- }
377
- args.push(target, command);
378
- const child = spawn("ssh", args, {
379
- stdio: ["ignore", "pipe", "pipe"],
380
- });
381
- let stdout = "";
382
- let stderr = "";
383
- child.stdout.on("data", (data) => {
384
- stdout += data.toString();
385
- });
386
- child.stderr.on("data", (data) => {
387
- stderr += data.toString();
388
- });
389
- const timeoutMs = options?.timeoutMs ?? 120_000;
390
- const timer = setTimeout(() => {
391
- child.kill("SIGTERM");
392
- reject(new Error(`SSH command timed out after ${timeoutMs}ms: ${command}`));
393
- }, timeoutMs);
394
- if (options?.abortSignal) {
395
- options.abortSignal.addEventListener("abort", () => {
396
- child.kill("SIGTERM");
397
- clearTimeout(timer);
398
- reject(new Error("SSH command aborted"));
399
- }, { once: true });
400
- }
401
- child.on("close", (code) => {
402
- clearTimeout(timer);
403
- resolve({ stdout: stdout.trim(), stderr: stderr.trim(), exitCode: code ?? 1 });
404
- });
405
- child.on("error", (err) => {
406
- clearTimeout(timer);
407
- reject(err);
408
- });
409
- });
410
- }
411
- // ============================================================================
412
- // TLS Discovery Script (run on remote host)
413
- // ============================================================================
414
- const TLS_DISCOVERY_SCRIPT = `
415
- node -e "
416
- const fs = require('fs');
417
- const path = require('path');
418
-
419
- // Check Let's Encrypt first
420
- const leDirs = ['/etc/letsencrypt/live'];
421
- for (const dir of leDirs) {
422
- try {
423
- const domains = fs.readdirSync(dir).filter(d => !d.startsWith('.'));
424
- for (const domain of domains) {
425
- const cert = path.join(dir, domain, 'fullchain.pem');
426
- const key = path.join(dir, domain, 'privkey.pem');
427
- if (fs.existsSync(cert) && fs.existsSync(key)) {
428
- console.log(JSON.stringify({ found: true, type: 'letsencrypt', cert, key }));
429
- process.exit(0);
430
- }
431
- }
432
- } catch {}
433
- }
434
-
435
- // Check standard SSL locations
436
- const sslPairs = [
437
- ['/etc/ssl/certs/server.crt', '/etc/ssl/private/server.key'],
438
- ['/etc/ssl/certs/aria.crt', '/etc/ssl/private/aria.key'],
439
- ];
440
- for (const [cert, key] of sslPairs) {
441
- if (fs.existsSync(cert) && fs.existsSync(key)) {
442
- console.log(JSON.stringify({ found: true, type: 'real-ca', cert, key }));
443
- process.exit(0);
444
- }
445
- }
446
-
447
- console.log(JSON.stringify({ found: false }));
448
- "
449
- `;
450
- // ============================================================================
451
- // Firewall Detection Script (run on remote host)
452
- // ============================================================================
453
- const FIREWALL_DETECT_SCRIPT = `
454
- if command -v ufw >/dev/null 2>&1; then echo "ufw"
455
- elif command -v firewall-cmd >/dev/null 2>&1; then echo "firewalld"
456
- elif command -v iptables >/dev/null 2>&1; then echo "iptables"
457
- else echo "none"
458
- fi
459
- `;
460
- // ============================================================================
461
- // Deploy Executor
462
- // ============================================================================
463
- /**
464
- * Deploy ARIA to a remote machine via SSH.
465
- *
466
- * Steps:
467
- * 1. SSH connectivity check
468
- * 2. OS detection (uname -s)
469
- * 3. Linux distro detection (for package manager selection)
470
- * 4. Install Node.js 20+ if missing
471
- * 5. Enable corepack + pnpm
472
- * 6. Clone or update repo
473
- * 7. pnpm install && pnpm build
474
- * 8. Generate Ed25519 signing keypair if not present
475
- * 9. TLS cert discovery + optional provisioning
476
- * 10. Firewall port opening (443/tcp + 51820/udp)
477
- * 11. Write ~/.aria/config.json
478
- * 12. Start daemon on port 443
479
- * 13. Health check (curl endpoint)
480
- */
481
- export async function executeDeploy(input, ctx) {
482
- // Validate all inputs before any SSH calls (A1 — prevent shell injection)
483
- const targetError = validateTarget(input.target);
484
- if (targetError) {
485
- return fail(targetError);
486
- }
487
- const repoErr = validateRepoUrl(input.repo_url ?? "");
488
- if (repoErr)
489
- return fail(repoErr);
490
- const branchErr = validateBranch(input.branch ?? "");
491
- if (branchErr)
492
- return fail(branchErr);
493
- const nameErr = validateArionName(input.arion_name ?? "");
494
- if (nameErr)
495
- return fail(nameErr);
496
- const keyErr = validateSshKeyPath(input.ssh_key_path ?? "");
497
- if (keyErr)
498
- return fail(keyErr);
499
- const hashErr = validateCommitHash(input.commit_hash ?? "");
500
- if (hashErr)
501
- return fail(hashErr);
502
- const sshOpts = { sshKeyPath: input.ssh_key_path, abortSignal: ctx.abortSignal };
503
- const branch = input.branch ?? "main";
504
- const repoUrl = input.repo_url ?? "https://github.com/aria-ai/aria.git";
505
- // Request user confirmation — this is a dangerous operation
506
- const confirmed = await ctx.confirm(`Deploy ARIA to ${input.target}? This will install Node.js, clone the repo, build, and start the daemon.`);
507
- if (!confirmed) {
508
- return fail("User cancelled deployment");
509
- }
510
- // Track mutating steps for rollback on failure (A2)
511
- const completedSteps = [];
512
- let deployFailed = false;
513
- try {
514
- // Step 1: SSH connectivity check
515
- const connectivity = await sshExec(input.target, "echo ARIA_SSH_OK", sshOpts);
516
- if (connectivity.exitCode !== 0 || !connectivity.stdout.includes("ARIA_SSH_OK")) {
517
- return fail(`SSH connectivity failed to ${input.target}: ${connectivity.stderr || "no response"}`);
518
- }
519
- // Step 2: Detect OS
520
- const osResult = await sshExec(input.target, "uname -s 2>/dev/null || echo UNKNOWN", sshOpts);
521
- const osInfo = detectOS(osResult.stdout);
522
- if (osInfo.os === "unknown") {
523
- return fail(`Unsupported OS detected from uname: ${osResult.stdout.trim()}`);
524
- }
525
- // Step 3: Detect Linux distro for package manager selection
526
- let distro = "apt";
527
- if (osInfo.os === "linux") {
528
- const distroResult = await sshExec(input.target, "cat /etc/os-release 2>/dev/null || echo ''", sshOpts);
529
- distro = detectLinuxDistro(distroResult.stdout);
530
- }
531
- // Step 4: Install Node.js 20+ if not present
532
- const nodeCheck = await sshExec(input.target, 'node --version 2>/dev/null || echo "NO_NODE"', sshOpts);
533
- const hasNode = nodeCheck.stdout.startsWith("v") && parseInt(nodeCheck.stdout.slice(1), 10) >= 20;
534
- if (!hasNode) {
535
- const installCmd = getNodeInstallCommand(osInfo, distro);
536
- const installResult = await sshExec(input.target, installCmd, {
537
- ...sshOpts,
538
- timeoutMs: 300_000,
539
- });
540
- if (installResult.exitCode !== 0) {
541
- return fail(`Node.js installation failed: ${installResult.stderr}`);
542
- }
543
- }
544
- // Step 5: Enable corepack + pnpm (pinned version — never use @latest)
545
- const corepackCmd = `export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; corepack enable && corepack prepare pnpm@${PINNED_PNPM_VERSION} --activate`;
546
- const corepackResult = await sshExec(input.target, corepackCmd, sshOpts);
547
- if (corepackResult.exitCode !== 0) {
548
- return fail(`corepack/pnpm setup failed: ${corepackResult.stderr}`);
549
- }
550
- // Step 6: Clone or update repo
551
- const repoDir = "~/aria";
552
- const cloneCmd = `
553
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
554
- if [ -d ${repoDir}/.git ]; then
555
- cd ${repoDir} && git fetch origin && git checkout ${branch} && git pull origin ${branch}
556
- else
557
- git clone --branch ${branch} ${repoUrl} ${repoDir}
558
- fi
559
- `;
560
- const cloneResult = await sshExec(input.target, cloneCmd, {
561
- ...sshOpts,
562
- timeoutMs: 180_000,
563
- });
564
- if (cloneResult.exitCode !== 0) {
565
- return fail(`Repo clone/update failed: ${cloneResult.stderr}`);
566
- }
567
- // Step 6b: Pin to exact commit hash if provided (prevents MITM on branch refs)
568
- if (input.commit_hash) {
569
- const checkoutResult = await sshExec(input.target, `cd ${repoDir} && git checkout ${input.commit_hash}`, sshOpts);
570
- if (checkoutResult.exitCode !== 0) {
571
- return fail(`Commit hash checkout failed: ${checkoutResult.stderr}`);
572
- }
573
- }
574
- // Step 6c: Verify GPG signature on HEAD if requested
575
- if (input.verify_signatures) {
576
- const gpgResult = await sshExec(input.target, `cd ${repoDir} && git verify-commit HEAD`, sshOpts);
577
- if (gpgResult.exitCode !== 0) {
578
- return fail(`GPG signature verification failed: ${gpgResult.stderr}. ` +
579
- `Set verify_signatures=false to skip.`);
580
- }
581
- }
582
- // Step 7: pnpm install && pnpm build
583
- const buildCmd = `
584
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
585
- cd ${repoDir} && pnpm install --frozen-lockfile && pnpm store verify && pnpm build
586
- `;
587
- const buildResult = await sshExec(input.target, buildCmd, {
588
- ...sshOpts,
589
- timeoutMs: 600_000,
590
- });
591
- if (buildResult.exitCode !== 0) {
592
- return fail(`Build failed: ${buildResult.stderr}`);
593
- }
594
- // Step 8: Generate Ed25519 signing keypair if not present
595
- const keypairCmd = `
596
- mkdir -p ~/.aria
597
- if [ ! -f ~/.aria/signing-key.json ]; then
598
- node -e "
599
- const crypto = require('crypto');
600
- const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');
601
- const pub = publicKey.export({ type: 'spki', format: 'der' }).toString('base64');
602
- const priv = privateKey.export({ type: 'pkcs8', format: 'der' }).toString('base64');
603
- const fp = crypto.createHash('sha256').update(Buffer.from(pub, 'base64')).digest('hex');
604
- const data = JSON.stringify({ publicKey: pub, privateKey: priv, fingerprint: fp }, null, 2);
605
- require('fs').writeFileSync(process.env.HOME + '/.aria/signing-key.json', data, { mode: 0o600 });
606
- console.log(JSON.stringify({ publicKey: pub, fingerprint: fp }));
607
- "
608
- else
609
- node -e "
610
- const data = JSON.parse(require('fs').readFileSync(process.env.HOME + '/.aria/signing-key.json', 'utf8'));
611
- console.log(JSON.stringify({ publicKey: data.publicKey, fingerprint: data.fingerprint }));
612
- "
613
- fi
614
- `;
615
- const keypairResult = await sshExec(input.target, keypairCmd, sshOpts);
616
- if (keypairResult.exitCode !== 0) {
617
- return fail(`Keypair generation failed: ${keypairResult.stderr}`);
618
- }
619
- completedSteps.push({ name: "keypair", undoCmd: "" }); // keypair is not rolled back (idempotent)
620
- // A3: Set key file permissions (chmod 600)
621
- const chmodKeyResult = await sshExec(input.target, "chmod 600 ~/.aria/signing-key.json", sshOpts);
622
- if (chmodKeyResult.exitCode !== 0) {
623
- // Non-fatal — best effort
624
- }
625
- let fingerprint = null;
626
- try {
627
- const keypairData = JSON.parse(keypairResult.stdout);
628
- fingerprint = keypairData.fingerprint ?? null;
629
- }
630
- catch {
631
- // Non-fatal — fingerprint is informational
632
- }
633
- // Step 9: TLS cert discovery + optional provisioning
634
- const tlsResult = await sshExec(input.target, TLS_DISCOVERY_SCRIPT, sshOpts);
635
- let tlsInfo = discoverTlsCerts(tlsResult.stdout);
636
- let tlsType = null;
637
- if (tlsInfo.found && tlsInfo.type) {
638
- tlsType = tlsInfo.type;
639
- }
640
- else {
641
- // Try Let's Encrypt auto-provisioning
642
- const hostnameResult = await sshExec(input.target, "hostname -f 2>/dev/null || hostname", sshOpts);
643
- const hostname = hostnameResult.stdout.trim();
644
- // Only attempt certbot if we have a domain name (not just an IP)
645
- if (hostname && !/^[\d.]+$/.test(hostname) && !/^[\da-f:]+$/i.test(hostname)) {
646
- const certbotResult = await sshExec(input.target, `command -v certbot >/dev/null 2>&1 && certbot certonly --standalone -d ${hostname} --non-interactive --agree-tos --register-unsafely-without-email 2>&1 || echo "NO_CERTBOT"`, { ...sshOpts, timeoutMs: 120_000 });
647
- if (certbotResult.exitCode === 0 && !certbotResult.stdout.includes("NO_CERTBOT")) {
648
- tlsInfo = {
649
- found: true,
650
- type: "letsencrypt",
651
- cert: `/etc/letsencrypt/live/${hostname}/fullchain.pem`,
652
- key: `/etc/letsencrypt/live/${hostname}/privkey.pem`,
653
- };
654
- tlsType = "letsencrypt";
655
- }
656
- }
657
- // Fall back to ARIA private CA
658
- if (!tlsType) {
659
- const privateCaCmd = `
660
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
661
- cd ~/aria && node -e "
662
- const { ensureMeshCerts } = require('./packages/server/dist/tls/mesh-certs.js');
663
- ensureMeshCerts().then(r => console.log(JSON.stringify({ cert: r.certPath, key: r.keyPath })));
664
- " 2>/dev/null || echo '{"cert":"~/.aria/tls/server.crt","key":"~/.aria/tls/server.key"}'
665
- `;
666
- const privateCaResult = await sshExec(input.target, privateCaCmd, sshOpts);
667
- try {
668
- const caPaths = JSON.parse(privateCaResult.stdout);
669
- tlsInfo = {
670
- found: true,
671
- type: "private-ca",
672
- cert: caPaths.cert,
673
- key: caPaths.key,
674
- };
675
- tlsType = "private-ca";
676
- }
677
- catch {
678
- // TLS setup failed, proceed without — daemon may still start on HTTP
679
- }
680
- }
681
- }
682
- // Step 10: Firewall port opening (A2 — tracked for rollback)
683
- let firewallType = "none";
684
- if (osInfo.os === "linux") {
685
- const fwDetect = await sshExec(input.target, FIREWALL_DETECT_SCRIPT, sshOpts);
686
- firewallType = fwDetect.stdout.trim();
687
- const fwCmds = getFirewallCommands(firewallType);
688
- if (fwCmds) {
689
- const fwResult = await sshExec(input.target, fwCmds, sshOpts);
690
- if (fwResult.exitCode === 0) {
691
- completedSteps.push({
692
- name: "firewall",
693
- undoCmd: getFirewallUndoCommands(firewallType),
694
- });
695
- }
696
- // Best-effort — don't fail the deploy if firewall commands fail (may need sudo)
697
- }
698
- }
699
- // Derive arion name from target hostname if not provided
700
- const host = input.target.includes("@") ? input.target.split("@")[1] : input.target;
701
- const arionName = input.arion_name ?? host.replace(/[^a-zA-Z0-9-]/g, "-");
702
- // Step 11: Write ~/.aria/config.json (A3 — deep merge for idempotency)
703
- const configObj = buildConfigJson({
704
- arionName,
705
- coordinationUrl: input.coordination_url,
706
- tlsCert: tlsInfo.found ? tlsInfo.cert : undefined,
707
- tlsKey: tlsInfo.found ? tlsInfo.key : undefined,
708
- });
709
- const configJson = JSON.stringify(configObj);
710
- // Escape for shell — replace single quotes
711
- const escapedConfig = configJson.replace(/'/g, "'\\''");
712
- const configCmd = `
713
- mkdir -p ~/.aria
714
- if [ -f ~/.aria/config.json ]; then
715
- node -e "
716
- const fs = require('fs');
717
- const existing = JSON.parse(fs.readFileSync(process.env.HOME + '/.aria/config.json', 'utf8'));
718
- const updates = JSON.parse('${escapedConfig}');
719
- // Deep merge: preserve nested objects
720
- function deepMerge(target, source) {
721
- for (const key of Object.keys(source)) {
722
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key]) &&
723
- target[key] && typeof target[key] === 'object' && !Array.isArray(target[key])) {
724
- deepMerge(target[key], source[key]);
725
- } else {
726
- target[key] = source[key];
727
- }
728
- }
729
- return target;
730
- }
731
- deepMerge(existing, updates);
732
- fs.writeFileSync(process.env.HOME + '/.aria/config.json', JSON.stringify(existing, null, 2), { mode: 0o600 });
733
- "
734
- else
735
- echo '${escapedConfig}' > ~/.aria/config.json && chmod 600 ~/.aria/config.json
736
- fi
737
- `;
738
- const configResult = await sshExec(input.target, configCmd, sshOpts);
739
- if (configResult.exitCode !== 0) {
740
- deployFailed = true;
741
- return fail(`Config write failed: ${configResult.stderr}`);
742
- }
743
- completedSteps.push({ name: "config", undoCmd: "rm -f ~/.aria/config.json" });
744
- // A3: Set config file permissions (chmod 600)
745
- await sshExec(input.target, "chmod 600 ~/.aria/config.json", sshOpts);
746
- // Step 12: Start daemon (nohup, backgrounded) on port 443
747
- const runtimePidLookupCmd = buildRemoteRuntimePidLookupCommand(repoDir);
748
- const runtimeStatusLookupCmd = buildRemoteRuntimeStatusLookupCommand(repoDir);
749
- const daemonCmd = `
750
- # Kill existing daemon if running
751
- PID=$(${runtimePidLookupCmd} 2>/dev/null || true)
752
- [ -n "$PID" ] && kill "$PID" 2>/dev/null || true
753
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
754
- cd ${repoDir}
755
- nohup node packages/cli/bin/aria.js daemon --arion ${arionName} --port 443 > ~/.aria/daemon.log 2>&1 &
756
- echo $!
757
- `;
758
- const daemonResult = await sshExec(input.target, daemonCmd, sshOpts);
759
- if (daemonResult.exitCode !== 0) {
760
- deployFailed = true;
761
- return fail(`Daemon start failed: ${daemonResult.stderr}`);
762
- }
763
- completedSteps.push({
764
- name: "daemon",
765
- undoCmd: `PID=$(${runtimePidLookupCmd} 2>/dev/null || true); [ -n "$PID" ] && kill "$PID" 2>/dev/null || true`,
766
- });
767
- // Step 13: Health check — wait for runtime owner/socket status then verify endpoint (A3 — mandatory)
768
- const healthCmd = `
769
- for i in $(seq 1 15); do
770
- STATUS=$(${runtimeStatusLookupCmd} 2>/dev/null || true)
771
- if [ -n "$STATUS" ]; then
772
- echo "$STATUS"
773
- exit 0
774
- fi
775
- sleep 1
776
- done
777
- echo "TIMEOUT"
778
- exit 1
779
- `;
780
- const healthResult = await sshExec(input.target, healthCmd, {
781
- ...sshOpts,
782
- timeoutMs: 30_000,
783
- });
784
- let port = null;
785
- if (healthResult.exitCode === 0 && !healthResult.stdout.includes("TIMEOUT")) {
786
- try {
787
- const runtimeStatus = JSON.parse(healthResult.stdout);
788
- port = runtimeStatus.port ?? null;
789
- }
790
- catch {
791
- // Non-fatal
792
- }
793
- }
794
- // A3: Mandatory health check — verify HTTP(S) endpoint returns 2xx
795
- if (port) {
796
- const healthUrl = buildHealthCheckUrl(host, port);
797
- const curlCmd = `curl -sSk -o /dev/null -w "%{http_code}" ${healthUrl} 2>/dev/null || echo "000"`;
798
- const curlResult = await sshExec(input.target, curlCmd, {
799
- ...sshOpts,
800
- timeoutMs: 10_000,
801
- });
802
- const httpCode = parseInt(curlResult.stdout.trim(), 10);
803
- if (isNaN(httpCode) || httpCode < 200 || httpCode >= 300) {
804
- deployFailed = true;
805
- return fail(`Health check failed: ${healthUrl} returned HTTP ${curlResult.stdout.trim()}. ` +
806
- `Check ~/.aria/daemon.log on ${input.target}.`);
807
- }
808
- }
809
- else if (healthResult.exitCode !== 0) {
810
- deployFailed = true;
811
- return fail(`Health check failed: runtime owner/socket status not available within 15s. ` +
812
- `Check ~/.aria/daemon.log on ${input.target}.`);
813
- }
814
- const output = {
815
- success: true,
816
- host,
817
- port,
818
- fingerprint,
819
- arionName,
820
- tlsType,
821
- };
822
- const statusLine = `Daemon running (port ${port ?? "unknown"})`;
823
- const tlsLine = tlsType ? `TLS: ${tlsType}` : "TLS: none (HTTP only)";
824
- return success(`ARIA deployed to ${input.target}.\n` +
825
- `Arion: ${arionName}\n` +
826
- `Fingerprint: ${fingerprint ?? "unknown"}\n` +
827
- `${tlsLine}\n` +
828
- `${statusLine}`, output);
829
- }
830
- catch (error) {
831
- deployFailed = true;
832
- return fail(`Deploy failed: ${error instanceof Error ? error.message : String(error)}`);
833
- }
834
- finally {
835
- // A2: Rollback on failure — undo completed steps in reverse order
836
- if (deployFailed && completedSteps.length > 0) {
837
- const rollbackCmds = buildRollbackCommands(completedSteps);
838
- for (const cmd of rollbackCmds) {
839
- try {
840
- await sshExec(input.target, cmd, sshOpts);
841
- }
842
- catch {
843
- // Best-effort rollback — don't throw during cleanup
844
- }
845
- }
846
- }
847
- }
848
- }
849
- //# sourceMappingURL=deploy.js.map