@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,955 +0,0 @@
1
- /**
2
- * @aria/tools - Shell tool executors
3
- *
4
- * Implementation of shell operations for ARIA tool system.
5
- */
6
- import { spawn } from "node:child_process";
7
- import { constants as osConstants } from "node:os";
8
- import { success, fail, getErrorMessage } from "./utils.js";
9
- import { classifyCommand, classifyExecInvocation } from "./shell-safety.js";
10
- /**
11
- * Environment variables that are dangerous in ALL contexts — including
12
- * the host's own process.env. These enable code injection or library
13
- * hijacking and should never reach child processes.
14
- */
15
- export const BLOCKED_ENV_VARS = new Set([
16
- "LD_PRELOAD",
17
- "LD_LIBRARY_PATH",
18
- "DYLD_INSERT_LIBRARIES",
19
- "DYLD_FRAMEWORK_PATH",
20
- "DYLD_LIBRARY_PATH",
21
- "BASH_ENV",
22
- "ENV",
23
- "CDPATH",
24
- "GLOBIGNORE",
25
- "PROMPT_COMMAND",
26
- "SHELLOPTS",
27
- "BASHOPTS",
28
- // Git context hijacks: inherited vars can redirect repository resolution.
29
- "GIT_DIR",
30
- "GIT_WORK_TREE",
31
- "GIT_INDEX_FILE",
32
- "GIT_OBJECT_DIRECTORY",
33
- "GIT_ALTERNATE_OBJECT_DIRECTORIES",
34
- "GIT_COMMON_DIR",
35
- "GIT_PREFIX",
36
- "GIT_INTERNAL_SUPER_PREFIX",
37
- "GIT_CONFIG",
38
- "GIT_CONFIG_GLOBAL",
39
- "GIT_CONFIG_SYSTEM",
40
- "GIT_CONFIG_COUNT",
41
- "GIT_CEILING_DIRECTORIES",
42
- ]);
43
- /**
44
- * Git environment keys that can redirect repository/config context or mutate
45
- * commit identity unexpectedly when inherited by child processes.
46
- *
47
- * NOTE: We intentionally keep transport/debug keys like GIT_SSH_COMMAND and
48
- * GIT_TRACE untouched to avoid breaking legitimate workflows.
49
- */
50
- const GIT_BLOCKED_EXACT_KEYS = new Set([
51
- "GIT_DIR",
52
- "GIT_WORK_TREE",
53
- "GIT_INDEX_FILE",
54
- "GIT_INDEX_VERSION",
55
- "GIT_COMMON_DIR",
56
- "GIT_OBJECT_DIRECTORY",
57
- "GIT_ALTERNATE_OBJECT_DIRECTORIES",
58
- "GIT_CEILING_DIRECTORIES",
59
- "GIT_DISCOVERY_ACROSS_FILESYSTEM",
60
- "GIT_NAMESPACE",
61
- "GIT_CONFIG",
62
- "GIT_CONFIG_GLOBAL",
63
- "GIT_CONFIG_SYSTEM",
64
- "GIT_CONFIG_NOSYSTEM",
65
- "GIT_CONFIG_COUNT",
66
- "GIT_CONFIG_PARAMETERS",
67
- ]);
68
- const GIT_BLOCKED_PREFIXES = [
69
- "GIT_CONFIG_KEY_",
70
- "GIT_CONFIG_VALUE_",
71
- "GIT_AUTHOR_",
72
- "GIT_COMMITTER_",
73
- ];
74
- export function isBlockedGitEnvVar(key) {
75
- const upper = key.toUpperCase();
76
- if (GIT_BLOCKED_EXACT_KEYS.has(upper)) {
77
- return true;
78
- }
79
- return GIT_BLOCKED_PREFIXES.some((prefix) => upper.startsWith(prefix));
80
- }
81
- /**
82
- * Strip git-context env keys from a source env object.
83
- */
84
- export function sanitizeGitEnv(env = process.env) {
85
- const sanitized = {};
86
- for (const [key, value] of Object.entries(env)) {
87
- if (value === undefined)
88
- continue;
89
- if (isBlockedGitEnvVar(key))
90
- continue;
91
- sanitized[key] = value;
92
- }
93
- return sanitized;
94
- }
95
- /**
96
- * Additional variables blocked from tool-injected input (inputEnv, ctx.env)
97
- * but NOT from process.env. The host's PATH/HOME/SHELL are legitimate —
98
- * only tool-provided overrides are dangerous (hijacking resolution paths).
99
- */
100
- export const BLOCKED_INPUT_ENV_VARS = new Set([
101
- ...BLOCKED_ENV_VARS,
102
- // Executable/module resolution hijacks (aria-mx5)
103
- "PATH",
104
- "NODE_OPTIONS",
105
- "NODE_PATH",
106
- "PYTHONPATH",
107
- // Shell/environment manipulation
108
- "IFS",
109
- "HOME",
110
- "SHELL",
111
- "EDITOR",
112
- "VISUAL",
113
- // Java runtime hijacks (aria-skg)
114
- "JAVA_TOOL_OPTIONS",
115
- "_JAVA_OPTIONS",
116
- "CLASSPATH",
117
- // Ruby runtime hijacks (aria-skg)
118
- "RUBYOPT",
119
- "GEM_HOME",
120
- "GEM_PATH",
121
- // Perl runtime hijacks (aria-skg)
122
- "PERL5OPT",
123
- "PERL5LIB",
124
- // Python startup hijack (aria-skg) — PYTHONPATH already covered above
125
- "PYTHONSTARTUP",
126
- ]);
127
- function isBlockedProcessEnvVar(key) {
128
- return BLOCKED_ENV_VARS.has(key.toUpperCase()) || isBlockedGitEnvVar(key);
129
- }
130
- function isBlockedInputEnvVar(key) {
131
- return BLOCKED_INPUT_ENV_VARS.has(key.toUpperCase()) || isBlockedGitEnvVar(key);
132
- }
133
- /**
134
- * Merges environment variables from context and input.
135
- *
136
- * Three-tier filtering:
137
- * - process.env: filtered through BLOCKED_ENV_VARS (injection-only vars like LD_PRELOAD)
138
- * - ctx.env / inputEnv: filtered through BLOCKED_INPUT_ENV_VARS (also blocks PATH/HOME/SHELL hijacking)
139
- */
140
- export function mergeEnv(ctx, inputEnv) {
141
- let sanitizedInput = inputEnv;
142
- if (inputEnv) {
143
- sanitizedInput = {};
144
- for (const [key, value] of Object.entries(inputEnv)) {
145
- if (isBlockedInputEnvVar(key)) {
146
- continue;
147
- }
148
- sanitizedInput[key] = value;
149
- }
150
- }
151
- let sanitizedCtxEnv = ctx.env;
152
- if (ctx.env) {
153
- sanitizedCtxEnv = {};
154
- for (const [key, value] of Object.entries(ctx.env)) {
155
- if (isBlockedInputEnvVar(key)) {
156
- continue;
157
- }
158
- sanitizedCtxEnv[key] = value;
159
- }
160
- }
161
- // Filter process.env through the base blocklist only — the host's
162
- // PATH/HOME/SHELL are legitimate and needed by child processes.
163
- const sanitizedProcessEnv = {};
164
- for (const [key, value] of Object.entries(process.env)) {
165
- if (value === undefined)
166
- continue;
167
- if (isBlockedProcessEnvVar(key)) {
168
- continue;
169
- }
170
- sanitizedProcessEnv[key] = value;
171
- }
172
- return {
173
- ...sanitizedProcessEnv,
174
- ...sanitizedCtxEnv,
175
- ...sanitizedInput,
176
- };
177
- }
178
- /**
179
- * Sanitize environment for child processes without requiring a ToolContext.
180
- *
181
- * Applies the same two-tier filtering as mergeEnv:
182
- * - process.env is filtered through BLOCKED_ENV_VARS
183
- * - inputEnv (caller-supplied overrides) is filtered through BLOCKED_INPUT_ENV_VARS
184
- *
185
- * Intended for executors (e.g. PTY) that do not have a ToolContext.
186
- */
187
- export function sanitizeEnv(inputEnv) {
188
- // Filter process.env through the base blocklist
189
- const sanitizedProcessEnv = {};
190
- for (const [key, value] of Object.entries(process.env)) {
191
- if (value === undefined)
192
- continue;
193
- if (isBlockedProcessEnvVar(key)) {
194
- continue;
195
- }
196
- sanitizedProcessEnv[key] = value;
197
- }
198
- // Filter inputEnv through the stricter input blocklist
199
- let sanitizedInput;
200
- if (inputEnv) {
201
- sanitizedInput = {};
202
- for (const [key, value] of Object.entries(inputEnv)) {
203
- if (isBlockedInputEnvVar(key)) {
204
- continue;
205
- }
206
- sanitizedInput[key] = value;
207
- }
208
- }
209
- return {
210
- ...sanitizedProcessEnv,
211
- ...sanitizedInput,
212
- };
213
- }
214
- /**
215
- * Executes a command through bash shell.
216
- * Supports shell features like pipes, redirection, and variable expansion.
217
- */
218
- export async function executeBash(input, ctx) {
219
- // Shell safety: block catastrophic commands before any execution
220
- const risk = classifyCommand(input.command);
221
- if (risk === "blocked") {
222
- return fail(`Command blocked by shell safety policy: ${input.command}`);
223
- }
224
- // Check if already aborted before starting
225
- if (ctx.abortSignal?.aborted) {
226
- return fail("Command cancelled");
227
- }
228
- const cwd = input.cwd ?? ctx.workingDir;
229
- const env = mergeEnv(ctx, input.env);
230
- const timeout = input.timeout ?? 120_000;
231
- return executeExec({
232
- program: "/bin/bash",
233
- args: ["-lc", input.command],
234
- cwd,
235
- env: input.env,
236
- timeout,
237
- }, {
238
- ...ctx,
239
- workingDir: cwd,
240
- env,
241
- });
242
- }
243
- function signalExecProcessTree(pid, signal, detachedProcessGroup) {
244
- if (!pid) {
245
- return;
246
- }
247
- if (detachedProcessGroup) {
248
- try {
249
- process.kill(-pid, signal);
250
- return;
251
- }
252
- catch {
253
- // Fall back to the leader PID if the process group is already gone or unsupported.
254
- }
255
- }
256
- try {
257
- process.kill(pid, signal);
258
- }
259
- catch {
260
- // Process may already be dead.
261
- }
262
- }
263
- function isExecProcessTreeAlive(pid, detachedProcessGroup) {
264
- if (!pid) {
265
- return false;
266
- }
267
- if (detachedProcessGroup) {
268
- try {
269
- process.kill(-pid, 0);
270
- return true;
271
- }
272
- catch {
273
- // Fall through to the leader PID check in case the group probe is unsupported.
274
- }
275
- }
276
- try {
277
- process.kill(pid, 0);
278
- return true;
279
- }
280
- catch {
281
- return false;
282
- }
283
- }
284
- async function waitForExecProcessTreeExit(pid, detachedProcessGroup, timeoutMs = 1_000) {
285
- if (!pid) {
286
- return;
287
- }
288
- const deadline = Date.now() + timeoutMs;
289
- while (Date.now() < deadline) {
290
- if (!isExecProcessTreeAlive(pid, detachedProcessGroup)) {
291
- return;
292
- }
293
- await new Promise((resolve) => setTimeout(resolve, 25));
294
- }
295
- }
296
- /**
297
- * Executes a program directly without shell interpretation.
298
- * Safer than bash as it doesn't expand shell metacharacters.
299
- */
300
- export async function executeExec(input, ctx) {
301
- const args = input.args ?? [];
302
- // Shell safety: block catastrophic commands before any execution.
303
- // For explicit shell wrappers (e.g. bash -c ...), classify payload command.
304
- const reconstructed = [input.program, ...args].join(" ");
305
- const risk = classifyExecInvocation(input.program, args);
306
- if (risk === "blocked") {
307
- return fail(`Command blocked by shell safety policy: ${reconstructed}`, {
308
- stdout: "",
309
- stderr: "",
310
- exitCode: 1,
311
- });
312
- }
313
- // Check if already aborted before starting
314
- if (ctx.abortSignal?.aborted) {
315
- return fail("Command cancelled", {
316
- stdout: "",
317
- stderr: "",
318
- exitCode: 1,
319
- });
320
- }
321
- const cwd = input.cwd ?? ctx.workingDir;
322
- const env = mergeEnv(ctx, input.env);
323
- const timeout = input.timeout ?? 120_000;
324
- return new Promise((resolve) => {
325
- const detachedProcessGroup = process.platform !== "win32";
326
- const proc = spawn(input.program, args, {
327
- cwd,
328
- env,
329
- detached: detachedProcessGroup,
330
- });
331
- // Track PID in process registry for cleanup on session close
332
- if (proc.pid && ctx.processRegistry) {
333
- ctx.processRegistry.add(proc.pid, {
334
- command: input.program,
335
- args,
336
- cwd,
337
- interactive: false,
338
- });
339
- }
340
- let stdout = "";
341
- let stderr = "";
342
- let timedOut = false;
343
- let cancelled = false;
344
- let resolved = false;
345
- let timeoutId;
346
- let killTimeoutId;
347
- const doResolve = (result, exit) => {
348
- if (resolved)
349
- return;
350
- resolved = true;
351
- if (timeoutId)
352
- clearTimeout(timeoutId);
353
- if (killTimeoutId)
354
- clearTimeout(killTimeoutId);
355
- // Clean up abort listener
356
- if (ctx.abortSignal && onAbort) {
357
- ctx.abortSignal.removeEventListener("abort", onAbort);
358
- }
359
- // Keep detached process groups tracked until the whole group is gone.
360
- ctx.processRegistry?.recordExitMetadata?.(proc.pid ?? 0, exit);
361
- if (proc.pid &&
362
- ctx.processRegistry &&
363
- !(detachedProcessGroup && isExecProcessTreeAlive(proc.pid, detachedProcessGroup))) {
364
- ctx.processRegistry.remove(proc.pid, exit);
365
- }
366
- resolve(result);
367
- };
368
- // Wire abort signal to kill the process
369
- let onAbort;
370
- if (ctx.abortSignal) {
371
- onAbort = () => {
372
- cancelled = true;
373
- signalExecProcessTree(proc.pid, "SIGTERM", detachedProcessGroup);
374
- // Follow up with SIGKILL if SIGTERM doesn't work
375
- killTimeoutId = setTimeout(() => {
376
- signalExecProcessTree(proc.pid, "SIGKILL", detachedProcessGroup);
377
- }, 1000);
378
- };
379
- ctx.abortSignal.addEventListener("abort", onAbort, { once: true });
380
- }
381
- if (timeout) {
382
- timeoutId = setTimeout(() => {
383
- timedOut = true;
384
- signalExecProcessTree(proc.pid, "SIGTERM", detachedProcessGroup);
385
- // If SIGTERM doesn't work, follow up with SIGKILL after 1 second
386
- killTimeoutId = setTimeout(() => {
387
- signalExecProcessTree(proc.pid, "SIGKILL", detachedProcessGroup);
388
- }, 1000);
389
- }, timeout);
390
- }
391
- proc.stdout?.on("data", (data) => {
392
- stdout += data.toString();
393
- });
394
- proc.stderr?.on("data", (data) => {
395
- stderr += data.toString();
396
- });
397
- proc.on("error", (err) => {
398
- const exitCode = typeof err === "object" &&
399
- err &&
400
- "code" in err &&
401
- err.code === "ENOENT"
402
- ? 127
403
- : 1;
404
- doResolve(fail(getErrorMessage(err), {
405
- stdout: "",
406
- stderr,
407
- exitCode,
408
- }));
409
- });
410
- proc.on("close", (code, signal) => {
411
- void (async () => {
412
- if (cancelled || timedOut) {
413
- if (killTimeoutId) {
414
- clearTimeout(killTimeoutId);
415
- killTimeoutId = undefined;
416
- }
417
- signalExecProcessTree(proc.pid, "SIGKILL", detachedProcessGroup);
418
- await waitForExecProcessTreeExit(proc.pid, detachedProcessGroup);
419
- }
420
- if (cancelled) {
421
- doResolve(fail("Command cancelled", {
422
- stdout,
423
- stderr,
424
- exitCode: code ?? 1,
425
- }), { exitCode: code, signal });
426
- return;
427
- }
428
- if (timedOut) {
429
- doResolve(fail("Command timed out", {
430
- stdout,
431
- stderr,
432
- exitCode: code ?? 1,
433
- }), { exitCode: code, signal });
434
- return;
435
- }
436
- if (signal) {
437
- const signaledExitCode = osConstants.signals[signal] ?? 1;
438
- doResolve(fail(`Command exited due to signal ${signal}`, {
439
- stdout,
440
- stderr,
441
- exitCode: code ?? signaledExitCode,
442
- }), { exitCode: code, signal });
443
- return;
444
- }
445
- const exitCode = code ?? 0;
446
- if (exitCode === 0) {
447
- doResolve(success("Command executed successfully", {
448
- stdout,
449
- stderr,
450
- exitCode,
451
- }), { exitCode, signal });
452
- }
453
- else {
454
- doResolve(fail(`Command exited with code ${exitCode}`, {
455
- stdout,
456
- stderr,
457
- exitCode,
458
- }), { exitCode, signal });
459
- }
460
- })();
461
- });
462
- });
463
- }
464
- /**
465
- * Spawns a background process and returns immediately with its PID.
466
- * The process is detached and will continue running after the parent exits.
467
- */
468
- export async function executeSpawn(input, ctx) {
469
- // Shell safety: block catastrophic commands before spawning.
470
- // Detached processes are especially dangerous — they outlive the session.
471
- // For explicit shell wrappers (e.g. bash -c ...), classify payload command.
472
- const args = input.args ?? [];
473
- const reconstructed = [input.program, ...args].join(" ");
474
- const risk = classifyExecInvocation(input.program, args);
475
- if (risk === "blocked") {
476
- return fail(`Command blocked by shell safety policy: ${reconstructed}`);
477
- }
478
- // Check if already aborted before spawning
479
- if (ctx.abortSignal?.aborted) {
480
- return fail("Command cancelled");
481
- }
482
- // Check for interactive mode — use PTY instead of detached spawn
483
- if (input.interactive === true) {
484
- if (!ctx.ptySessionStore) {
485
- return fail("PTY session store not available — interactive mode requires runner wiring");
486
- }
487
- // Import createPTYSession dynamically to avoid circular deps at module level
488
- const { createPTYSession } = await import("./pty.js");
489
- const session = await createPTYSession({
490
- command: input.program,
491
- args: input.args,
492
- cwd: input.cwd ?? ctx.workingDir,
493
- env: mergeEnv(ctx, input.env),
494
- });
495
- const pid = session.pid;
496
- if (!pid) {
497
- session.close();
498
- return fail("Failed to start interactive session: no PID");
499
- }
500
- // Register in both stores
501
- ctx.ptySessionStore.add(pid, session);
502
- if (ctx.processRegistry) {
503
- ctx.processRegistry.add(pid, {
504
- command: input.program,
505
- args: input.args ?? [],
506
- cwd: input.cwd ?? ctx.workingDir,
507
- interactive: true,
508
- });
509
- }
510
- const deregisterInteractiveSession = () => {
511
- ctx.ptySessionStore?.remove(pid);
512
- if (ctx.processRegistry?.has(pid)) {
513
- ctx.processRegistry.remove(pid, {
514
- exitCode: session.exitCode ?? null,
515
- });
516
- }
517
- };
518
- if (!session.isRunning) {
519
- deregisterInteractiveSession();
520
- }
521
- else {
522
- const lifecycleCheckInterval = setInterval(() => {
523
- if (!session.isRunning) {
524
- clearInterval(lifecycleCheckInterval);
525
- deregisterInteractiveSession();
526
- }
527
- }, 50);
528
- lifecycleCheckInterval.unref?.();
529
- // Wire abort signal to PTY cleanup so ESC/Ctrl+C kills the session
530
- if (ctx.abortSignal) {
531
- const onAbort = () => {
532
- clearInterval(lifecycleCheckInterval);
533
- session.close();
534
- deregisterInteractiveSession();
535
- };
536
- ctx.abortSignal.addEventListener("abort", onAbort, { once: true });
537
- }
538
- }
539
- return success(`Started interactive session with PID ${pid}`, { pid });
540
- }
541
- const cwd = input.cwd ?? ctx.workingDir;
542
- const env = mergeEnv(ctx, input.env);
543
- return new Promise((resolve) => {
544
- let resolved = false;
545
- let fallbackTimeoutId;
546
- const doResolve = (result) => {
547
- if (resolved)
548
- return;
549
- resolved = true;
550
- if (fallbackTimeoutId)
551
- clearTimeout(fallbackTimeoutId);
552
- resolve(result);
553
- };
554
- // Wire abort signal to kill the spawned process.
555
- // The listener is NOT removed in doResolve because the spawned process
556
- // outlives the function call. The { once: true } option auto-cleans it.
557
- let spawnedPid;
558
- if (ctx.abortSignal) {
559
- ctx.abortSignal.addEventListener("abort", () => {
560
- if (spawnedPid) {
561
- try {
562
- // Kill the process group (negative PID) since process is detached
563
- process.kill(-spawnedPid, "SIGTERM");
564
- }
565
- catch {
566
- try {
567
- process.kill(spawnedPid, "SIGTERM");
568
- }
569
- catch {
570
- // Process may already be dead
571
- }
572
- }
573
- }
574
- }, { once: true });
575
- }
576
- try {
577
- const proc = spawn(input.program, args, {
578
- cwd,
579
- env,
580
- detached: true,
581
- stdio: "ignore",
582
- });
583
- // Handle spawn errors (e.g., program not found)
584
- proc.on("error", (err) => {
585
- doResolve(fail(getErrorMessage(err)));
586
- });
587
- // If we have a PID, the spawn was successful
588
- if (proc.pid) {
589
- spawnedPid = proc.pid;
590
- proc.on("exit", (code, signal) => {
591
- ctx.processRegistry?.recordExitMetadata?.(proc.pid, {
592
- exitCode: code,
593
- signal,
594
- });
595
- if (ctx.processRegistry && !isExecProcessTreeAlive(proc.pid, true)) {
596
- ctx.processRegistry.remove(proc.pid, {
597
- exitCode: code,
598
- signal,
599
- });
600
- }
601
- });
602
- // Track PID in process registry for cleanup on session close.
603
- // Spawned (detached) processes are never deregistered here —
604
- // they live until exit, killAll(), or the user explicitly kills them.
605
- if (ctx.processRegistry) {
606
- ctx.processRegistry.add(proc.pid, {
607
- command: input.program,
608
- args,
609
- cwd,
610
- interactive: false,
611
- });
612
- }
613
- // Unref to allow parent to exit independently
614
- proc.unref();
615
- doResolve(success(`Spawned process with PID ${proc.pid}`, {
616
- pid: proc.pid,
617
- }));
618
- }
619
- else {
620
- // This shouldn't normally happen, but handle it just in case
621
- // Wait briefly for error event
622
- fallbackTimeoutId = setTimeout(() => {
623
- doResolve(fail("Failed to spawn process: no PID returned"));
624
- }, 100);
625
- }
626
- }
627
- catch (err) {
628
- doResolve(fail(getErrorMessage(err)));
629
- }
630
- });
631
- }
632
- /**
633
- * Sends a signal to terminate a process by PID.
634
- */
635
- export async function executeKill(input, ctx) {
636
- const signal = input.signal ?? "SIGTERM";
637
- try {
638
- // Validate and normalize the signal
639
- const validatedSignal = validateSignal(signal);
640
- if (validatedSignal === undefined) {
641
- return fail(`Invalid signal: ${signal}`);
642
- }
643
- // Use process-tree signaling only for ARIA-tracked processes. Generic pid
644
- // kills must preserve pid-only semantics for foreign process groups.
645
- if (ctx.processRegistry?.has(input.pid)) {
646
- signalProcessTree(input.pid, validatedSignal);
647
- }
648
- else {
649
- process.kill(input.pid, validatedSignal);
650
- }
651
- // Keep tracked processes authoritative until exit is actually observed.
652
- const registry = ctx.processRegistry;
653
- if (registry?.waitForExit && shouldUntrackAfterSignal(validatedSignal)) {
654
- await registry.waitForExit(input.pid, 2_000);
655
- }
656
- const signalName = typeof validatedSignal === "number" ? signal : validatedSignal;
657
- return success(`Sent ${signalName} to process ${input.pid}`, {
658
- pid: input.pid,
659
- signal: signalName,
660
- });
661
- }
662
- catch (err) {
663
- if (err instanceof Error && "code" in err) {
664
- const nodeErr = err;
665
- if (nodeErr.code === "ESRCH") {
666
- return fail(`Process not found: ${input.pid}`);
667
- }
668
- if (nodeErr.code === "EPERM") {
669
- return fail(`Permission denied to kill process: ${input.pid}`);
670
- }
671
- }
672
- return fail(getErrorMessage(err));
673
- }
674
- }
675
- /**
676
- * Valid signal names that can be used with process.kill.
677
- */
678
- const VALID_SIGNALS = [
679
- "SIGHUP",
680
- "SIGINT",
681
- "SIGQUIT",
682
- "SIGILL",
683
- "SIGTRAP",
684
- "SIGABRT",
685
- "SIGBUS",
686
- "SIGFPE",
687
- "SIGKILL",
688
- "SIGUSR1",
689
- "SIGSEGV",
690
- "SIGUSR2",
691
- "SIGPIPE",
692
- "SIGALRM",
693
- "SIGTERM",
694
- "SIGSTKFLT",
695
- "SIGCHLD",
696
- "SIGCONT",
697
- "SIGSTOP",
698
- "SIGTSTP",
699
- "SIGTTIN",
700
- "SIGTTOU",
701
- "SIGURG",
702
- "SIGXCPU",
703
- "SIGXFSZ",
704
- "SIGVTALRM",
705
- "SIGPROF",
706
- "SIGWINCH",
707
- "SIGIO",
708
- "SIGPWR",
709
- "SIGSYS",
710
- ];
711
- const NON_TERMINATING_SIGNALS = new Set([
712
- "SIGCHLD",
713
- "SIGCONT",
714
- "SIGSTOP",
715
- "SIGTSTP",
716
- "SIGTTIN",
717
- "SIGTTOU",
718
- "SIGURG",
719
- "SIGWINCH",
720
- ]);
721
- /**
722
- * Type guard to check if a string is a valid signal name.
723
- */
724
- function isValidSignalName(signal) {
725
- return VALID_SIGNALS.includes(signal.toUpperCase());
726
- }
727
- /**
728
- * Validates a signal and returns either the validated signal name or number.
729
- * Returns undefined for invalid signals.
730
- */
731
- function validateSignal(signal) {
732
- // Handle numeric signal
733
- if (/^\d+$/.test(signal)) {
734
- const num = parseInt(signal, 10);
735
- if (num >= 1 && num <= 31) {
736
- return num;
737
- }
738
- return undefined;
739
- }
740
- // Handle signal names
741
- const upperSignal = signal.toUpperCase();
742
- if (isValidSignalName(upperSignal)) {
743
- return upperSignal;
744
- }
745
- return undefined;
746
- }
747
- function shouldUntrackAfterSignal(signal) {
748
- if (typeof signal === "number") {
749
- const signalName = resolveSignalName(signal);
750
- if (!signalName) {
751
- // Unknown numeric signals are treated conservatively.
752
- return false;
753
- }
754
- return !NON_TERMINATING_SIGNALS.has(signalName);
755
- }
756
- return !NON_TERMINATING_SIGNALS.has(signal);
757
- }
758
- function signalProcessTree(pid, signal) {
759
- try {
760
- if (pid > 0) {
761
- process.kill(-pid, signal);
762
- return;
763
- }
764
- }
765
- catch {
766
- // Fall back to the tracked pid itself when there is no process group to target.
767
- }
768
- process.kill(pid, signal);
769
- }
770
- function resolveSignalName(signal) {
771
- for (const [name, value] of Object.entries(osConstants.signals)) {
772
- if (value === signal) {
773
- return name;
774
- }
775
- }
776
- return undefined;
777
- }
778
- function hasLegacyGetAll(registry) {
779
- return typeof registry.getAll === "function";
780
- }
781
- export async function executeListProcesses(rawInput, ctx) {
782
- const input = toRecord(rawInput);
783
- const includeExited = typeof input?.includeExited === "boolean" ? input.includeExited : false;
784
- if (!ctx.processRegistry) {
785
- return fail("Process registry not available");
786
- }
787
- const registry = ctx.processRegistry;
788
- const processes = typeof registry.listProcesses === "function"
789
- ? registry.listProcesses({ includeExited })
790
- : hasLegacyGetAll(registry)
791
- ? registry.getAll().map((pid) => ({
792
- pid,
793
- command: null,
794
- args: [],
795
- cwd: null,
796
- interactive: false,
797
- startedAt: new Date().toISOString(),
798
- runtimeMs: 0,
799
- status: "running",
800
- exitCode: null,
801
- signal: null,
802
- endedAt: null,
803
- }))
804
- : [];
805
- return success(`Found ${processes.length} tracked process${processes.length === 1 ? "" : "es"}`, {
806
- processes,
807
- count: processes.length,
808
- });
809
- }
810
- export async function executeWaitProcess(rawInput, ctx) {
811
- const input = toRecord(rawInput);
812
- if (!input) {
813
- return fail("Invalid input: expected an object");
814
- }
815
- const pid = typeof input.pid === "number" ? input.pid : NaN;
816
- if (!pid || pid <= 0 || !Number.isInteger(pid)) {
817
- return fail("Invalid PID: must be a positive integer");
818
- }
819
- if (pid === process.pid) {
820
- return fail("Cannot wait on own process");
821
- }
822
- const timeoutMsInput = input.timeoutMs;
823
- if (timeoutMsInput !== undefined &&
824
- (typeof timeoutMsInput !== "number" || Number.isNaN(timeoutMsInput))) {
825
- return fail("Invalid timeoutMs: must be a number");
826
- }
827
- const timeoutInput = input.timeout;
828
- if (timeoutInput !== undefined &&
829
- (typeof timeoutInput !== "number" || Number.isNaN(timeoutInput))) {
830
- return fail("Invalid timeout: must be a number");
831
- }
832
- const timeoutMs = Math.min(Math.max(0, timeoutMsInput ?? timeoutInput ?? 30_000), 300_000);
833
- if (!ctx.processRegistry) {
834
- return fail("Process registry not available");
835
- }
836
- if (typeof ctx.processRegistry.waitForExit !== "function") {
837
- return fail("Process registry does not support waiting");
838
- }
839
- const startedAt = Date.now();
840
- const waitResult = await ctx.processRegistry.waitForExit(pid, timeoutMs);
841
- const waitedMs = Math.max(0, Date.now() - startedAt);
842
- if (waitResult.status === "not_found" || !waitResult.process) {
843
- return fail(`Process not tracked: ${pid}`, {
844
- pid,
845
- exited: false,
846
- status: "not_found",
847
- timedOut: false,
848
- waitedMs,
849
- });
850
- }
851
- const data = mapWaitResult(waitResult, waitedMs);
852
- if (waitResult.status === "running" || waitResult.timedOut) {
853
- return fail(`Timed out waiting for process ${pid}`, data);
854
- }
855
- return success(`Process ${pid} exited`, data);
856
- }
857
- function mapWaitResult(waitResult, waitedMs) {
858
- const processInfo = waitResult.process;
859
- const status = waitResult.status === "exited" ? "exited" : "running";
860
- return {
861
- pid: waitResult.pid,
862
- status,
863
- exited: status === "exited",
864
- timedOut: waitResult.timedOut,
865
- waitedMs,
866
- command: processInfo.command,
867
- args: processInfo.args,
868
- cwd: processInfo.cwd,
869
- interactive: processInfo.interactive,
870
- startedAt: processInfo.startedAt,
871
- endedAt: processInfo.endedAt,
872
- runtimeMs: processInfo.runtimeMs,
873
- exitCode: processInfo.exitCode,
874
- signal: processInfo.signal,
875
- };
876
- }
877
- function toRecord(rawInput) {
878
- if (!rawInput || typeof rawInput !== "object") {
879
- return undefined;
880
- }
881
- return rawInput;
882
- }
883
- /**
884
- * Sends input to an interactive PTY session by PID.
885
- * Requires the process to have been spawned with interactive=true.
886
- */
887
- export async function executeWriteStdin(rawInput, ctx) {
888
- // Validate input shape at runtime
889
- if (!rawInput || typeof rawInput !== "object") {
890
- return fail("Invalid input: expected an object");
891
- }
892
- const input = rawInput;
893
- const pid = typeof input.pid === "number" ? input.pid : NaN;
894
- const inputStr = typeof input.input === "string" ? input.input : undefined;
895
- const timeout = typeof input.timeout === "number" ? input.timeout : undefined;
896
- // Validate PID
897
- if (!pid || pid <= 0 || !Number.isInteger(pid)) {
898
- return fail("Invalid PID: must be a positive integer");
899
- }
900
- if (pid === process.pid) {
901
- return fail("Cannot write to own process");
902
- }
903
- // Validate input string
904
- if (inputStr === undefined) {
905
- return fail("Input must be a string");
906
- }
907
- // Look up PTY session store
908
- if (!ctx.ptySessionStore) {
909
- return fail("PTY session store not available");
910
- }
911
- if (!ctx.ptySessionStore.has(pid)) {
912
- return fail(`No interactive session found for PID ${pid}. Use spawn with interactive=true first.`);
913
- }
914
- // The ptySessionStore ref uses `unknown` return to avoid circular deps,
915
- // but the concrete store returns PTYSession instances.
916
- const session = ctx.ptySessionStore.get(pid);
917
- if (!session) {
918
- return fail(`No interactive session found for PID ${pid}. Use spawn with interactive=true first.`);
919
- }
920
- if (!session.isRunning) {
921
- return fail(`Process ${pid} has exited (code: ${session.exitCode ?? "unknown"})`);
922
- }
923
- try {
924
- // Capture output length before write to extract new output after
925
- const outputLenBefore = session.output.length;
926
- // Write input to the PTY session
927
- session.write(inputStr);
928
- // If timeout specified, poll for new output with early return
929
- if (timeout && timeout > 0) {
930
- const waitMs = Math.min(timeout, 30_000);
931
- const deadline = Date.now() + waitMs;
932
- const pollInterval = 50; // Check every 50ms
933
- while (Date.now() < deadline) {
934
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
935
- if (session.output.length > outputLenBefore)
936
- break;
937
- if (!session.isRunning)
938
- break;
939
- }
940
- }
941
- // Extract output produced after the write
942
- const fullOutput = session.output;
943
- const newOutput = fullOutput.slice(outputLenBefore);
944
- // Cap returned output to 10KB to avoid bloating tool results
945
- const cappedOutput = newOutput.length > 10_000 ? newOutput.slice(-10_000) : newOutput;
946
- return success(`Wrote ${inputStr.length} bytes to PID ${pid}`, {
947
- output: cappedOutput,
948
- });
949
- }
950
- catch (error) {
951
- const msg = error instanceof Error ? error.message : String(error);
952
- return fail(`Failed to write to PID ${pid}: ${msg}`);
953
- }
954
- }
955
- //# sourceMappingURL=shell.js.map