@xylabs/aries 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/README.md +693 -0
  2. package/dist/actions/audit/auditPaths.mjs +22 -0
  3. package/dist/actions/audit/auditPaths.mjs.map +1 -0
  4. package/dist/actions/audit/index.mjs +739 -0
  5. package/dist/actions/audit/index.mjs.map +1 -0
  6. package/dist/actions/audit/installPlugin.mjs +298 -0
  7. package/dist/actions/audit/installPlugin.mjs.map +1 -0
  8. package/dist/actions/audit/listSessions.mjs +93 -0
  9. package/dist/actions/audit/listSessions.mjs.map +1 -0
  10. package/dist/actions/audit/openAuditDir.mjs +44 -0
  11. package/dist/actions/audit/openAuditDir.mjs.map +1 -0
  12. package/dist/actions/audit/searchAudit.mjs +77 -0
  13. package/dist/actions/audit/searchAudit.mjs.map +1 -0
  14. package/dist/actions/audit/showAiMeta.mjs +105 -0
  15. package/dist/actions/audit/showAiMeta.mjs.map +1 -0
  16. package/dist/actions/audit/showSession.mjs +105 -0
  17. package/dist/actions/audit/showSession.mjs.map +1 -0
  18. package/dist/actions/audit/statusAudit.mjs +98 -0
  19. package/dist/actions/audit/statusAudit.mjs.map +1 -0
  20. package/dist/actions/clamp/clampAudit.mjs +53 -0
  21. package/dist/actions/clamp/clampAudit.mjs.map +1 -0
  22. package/dist/actions/clamp/index.mjs +2258 -0
  23. package/dist/actions/clamp/index.mjs.map +1 -0
  24. package/dist/actions/clamp/ipcServer.mjs +55 -0
  25. package/dist/actions/clamp/ipcServer.mjs.map +1 -0
  26. package/dist/actions/clamp/policyManagement.mjs +144 -0
  27. package/dist/actions/clamp/policyManagement.mjs.map +1 -0
  28. package/dist/actions/clamp/promptUser.mjs +91 -0
  29. package/dist/actions/clamp/promptUser.mjs.map +1 -0
  30. package/dist/actions/clamp/runClamped.mjs +2107 -0
  31. package/dist/actions/clamp/runClamped.mjs.map +1 -0
  32. package/dist/actions/clamp/sandboxExec.mjs +1612 -0
  33. package/dist/actions/clamp/sandboxExec.mjs.map +1 -0
  34. package/dist/actions/clamp/shellEnvSetup.mjs +59 -0
  35. package/dist/actions/clamp/shellEnvSetup.mjs.map +1 -0
  36. package/dist/actions/clamp/shimGenerator.mjs +68 -0
  37. package/dist/actions/clamp/shimGenerator.mjs.map +1 -0
  38. package/dist/actions/clamp/terminalRenderer.mjs +145 -0
  39. package/dist/actions/clamp/terminalRenderer.mjs.map +1 -0
  40. package/dist/actions/datalake/audit/auditLog.mjs +191 -0
  41. package/dist/actions/datalake/audit/auditLog.mjs.map +1 -0
  42. package/dist/actions/datalake/createDatalake.mjs +127 -0
  43. package/dist/actions/datalake/createDatalake.mjs.map +1 -0
  44. package/dist/actions/datalake/describeDatalake.mjs +159 -0
  45. package/dist/actions/datalake/describeDatalake.mjs.map +1 -0
  46. package/dist/actions/datalake/destroyDatalake.mjs +34 -0
  47. package/dist/actions/datalake/destroyDatalake.mjs.map +1 -0
  48. package/dist/actions/datalake/dev/downDevServer.mjs +102 -0
  49. package/dist/actions/datalake/dev/downDevServer.mjs.map +1 -0
  50. package/dist/actions/datalake/dev/index.mjs +369 -0
  51. package/dist/actions/datalake/dev/index.mjs.map +1 -0
  52. package/dist/actions/datalake/dev/logsDevServer.mjs +44 -0
  53. package/dist/actions/datalake/dev/logsDevServer.mjs.map +1 -0
  54. package/dist/actions/datalake/dev/paths.mjs +25 -0
  55. package/dist/actions/datalake/dev/paths.mjs.map +1 -0
  56. package/dist/actions/datalake/dev/resetDevServer.mjs +118 -0
  57. package/dist/actions/datalake/dev/resetDevServer.mjs.map +1 -0
  58. package/dist/actions/datalake/dev/resolveServerBin.mjs +26 -0
  59. package/dist/actions/datalake/dev/resolveServerBin.mjs.map +1 -0
  60. package/dist/actions/datalake/dev/state.mjs +62 -0
  61. package/dist/actions/datalake/dev/state.mjs.map +1 -0
  62. package/dist/actions/datalake/dev/statusDevServer.mjs +101 -0
  63. package/dist/actions/datalake/dev/statusDevServer.mjs.map +1 -0
  64. package/dist/actions/datalake/dev/upDevServer.mjs +221 -0
  65. package/dist/actions/datalake/dev/upDevServer.mjs.map +1 -0
  66. package/dist/actions/datalake/dev/waitForHealth.mjs +22 -0
  67. package/dist/actions/datalake/dev/waitForHealth.mjs.map +1 -0
  68. package/dist/actions/datalake/formatters.mjs +90 -0
  69. package/dist/actions/datalake/formatters.mjs.map +1 -0
  70. package/dist/actions/datalake/grantAccess.mjs +116 -0
  71. package/dist/actions/datalake/grantAccess.mjs.map +1 -0
  72. package/dist/actions/datalake/index.mjs +361 -0
  73. package/dist/actions/datalake/index.mjs.map +1 -0
  74. package/dist/actions/datalake/listDatalakes.mjs +54 -0
  75. package/dist/actions/datalake/listDatalakes.mjs.map +1 -0
  76. package/dist/actions/datalake/login.mjs +20 -0
  77. package/dist/actions/datalake/login.mjs.map +1 -0
  78. package/dist/actions/datalake/logout.mjs +11 -0
  79. package/dist/actions/datalake/logout.mjs.map +1 -0
  80. package/dist/actions/datalake/mintToken.mjs +37 -0
  81. package/dist/actions/datalake/mintToken.mjs.map +1 -0
  82. package/dist/actions/datalake/parseSize.mjs +21 -0
  83. package/dist/actions/datalake/parseSize.mjs.map +1 -0
  84. package/dist/actions/datalake/payloads/fetchPayload.mjs +76 -0
  85. package/dist/actions/datalake/payloads/fetchPayload.mjs.map +1 -0
  86. package/dist/actions/datalake/payloads/index.mjs +271 -0
  87. package/dist/actions/datalake/payloads/index.mjs.map +1 -0
  88. package/dist/actions/datalake/payloads/mintAndConnect.mjs +46 -0
  89. package/dist/actions/datalake/payloads/mintAndConnect.mjs.map +1 -0
  90. package/dist/actions/datalake/payloads/parsePayloadsFile.mjs +71 -0
  91. package/dist/actions/datalake/payloads/parsePayloadsFile.mjs.map +1 -0
  92. package/dist/actions/datalake/payloads/pushPayloads.mjs +181 -0
  93. package/dist/actions/datalake/payloads/pushPayloads.mjs.map +1 -0
  94. package/dist/actions/datalake/payloads/tailPayloads.mjs +106 -0
  95. package/dist/actions/datalake/payloads/tailPayloads.mjs.map +1 -0
  96. package/dist/actions/datalake/resolveTarget.mjs +15 -0
  97. package/dist/actions/datalake/resolveTarget.mjs.map +1 -0
  98. package/dist/actions/datalake/revokeAccess.mjs +108 -0
  99. package/dist/actions/datalake/revokeAccess.mjs.map +1 -0
  100. package/dist/actions/datalake/useDatalake.mjs +22 -0
  101. package/dist/actions/datalake/useDatalake.mjs.map +1 -0
  102. package/dist/actions/detect/detectAiClients.mjs +405 -0
  103. package/dist/actions/detect/detectAiClients.mjs.map +1 -0
  104. package/dist/actions/detect/index.mjs +405 -0
  105. package/dist/actions/detect/index.mjs.map +1 -0
  106. package/dist/actions/hash/algorithms/blockhash.mjs +61 -0
  107. package/dist/actions/hash/algorithms/blockhash.mjs.map +1 -0
  108. package/dist/actions/hash/algorithms/chromaprint.mjs +205 -0
  109. package/dist/actions/hash/algorithms/chromaprint.mjs.map +1 -0
  110. package/dist/actions/hash/algorithms/dhash.mjs +75 -0
  111. package/dist/actions/hash/algorithms/dhash.mjs.map +1 -0
  112. package/dist/actions/hash/algorithms/index.mjs +818 -0
  113. package/dist/actions/hash/algorithms/index.mjs.map +1 -0
  114. package/dist/actions/hash/algorithms/nilsimsa.mjs +27 -0
  115. package/dist/actions/hash/algorithms/nilsimsa.mjs.map +1 -0
  116. package/dist/actions/hash/algorithms/pdq.mjs +83 -0
  117. package/dist/actions/hash/algorithms/pdq.mjs.map +1 -0
  118. package/dist/actions/hash/algorithms/phash.mjs +71 -0
  119. package/dist/actions/hash/algorithms/phash.mjs.map +1 -0
  120. package/dist/actions/hash/algorithms/sha256.mjs +24 -0
  121. package/dist/actions/hash/algorithms/sha256.mjs.map +1 -0
  122. package/dist/actions/hash/algorithms/ssdeep.mjs +203 -0
  123. package/dist/actions/hash/algorithms/ssdeep.mjs.map +1 -0
  124. package/dist/actions/hash/algorithms/tlsh.mjs +66 -0
  125. package/dist/actions/hash/algorithms/tlsh.mjs.map +1 -0
  126. package/dist/actions/hash/algorithms/types.mjs +1 -0
  127. package/dist/actions/hash/algorithms/types.mjs.map +1 -0
  128. package/dist/actions/hash/algorithms/videoFrames.mjs +404 -0
  129. package/dist/actions/hash/algorithms/videoFrames.mjs.map +1 -0
  130. package/dist/actions/hash/algorithms/xyo.mjs +30 -0
  131. package/dist/actions/hash/algorithms/xyo.mjs.map +1 -0
  132. package/dist/actions/hash/compareHashes.mjs +823 -0
  133. package/dist/actions/hash/compareHashes.mjs.map +1 -0
  134. package/dist/actions/hash/hashInput.mjs +868 -0
  135. package/dist/actions/hash/hashInput.mjs.map +1 -0
  136. package/dist/actions/hash/index.mjs +881 -0
  137. package/dist/actions/hash/index.mjs.map +1 -0
  138. package/dist/actions/hash/lib/hamming.mjs +44 -0
  139. package/dist/actions/hash/lib/hamming.mjs.map +1 -0
  140. package/dist/actions/hash/lib/levenshtein.mjs +36 -0
  141. package/dist/actions/hash/lib/levenshtein.mjs.map +1 -0
  142. package/dist/actions/hash/lib/runBinary.mjs +54 -0
  143. package/dist/actions/hash/lib/runBinary.mjs.map +1 -0
  144. package/dist/actions/hash/lib/which.mjs +36 -0
  145. package/dist/actions/hash/lib/which.mjs.map +1 -0
  146. package/dist/actions/hash/lib/withTempfile.mjs +19 -0
  147. package/dist/actions/hash/lib/withTempfile.mjs.map +1 -0
  148. package/dist/actions/index.mjs +4615 -0
  149. package/dist/actions/index.mjs.map +1 -0
  150. package/dist/actions/printVersion.mjs +12 -0
  151. package/dist/actions/printVersion.mjs.map +1 -0
  152. package/dist/actions/sync/index.mjs +51 -0
  153. package/dist/actions/sync/index.mjs.map +1 -0
  154. package/dist/actions/sync/syncAiConfig.mjs +51 -0
  155. package/dist/actions/sync/syncAiConfig.mjs.map +1 -0
  156. package/dist/actions/wallet/account/deriveAndAdd.mjs +394 -0
  157. package/dist/actions/wallet/account/deriveAndAdd.mjs.map +1 -0
  158. package/dist/actions/wallet/account/getActiveWallet.mjs +338 -0
  159. package/dist/actions/wallet/account/getActiveWallet.mjs.map +1 -0
  160. package/dist/actions/wallet/account/labelAccount.mjs +389 -0
  161. package/dist/actions/wallet/account/labelAccount.mjs.map +1 -0
  162. package/dist/actions/wallet/account/listAccounts.mjs +374 -0
  163. package/dist/actions/wallet/account/listAccounts.mjs.map +1 -0
  164. package/dist/actions/wallet/account/removeAccount.mjs +384 -0
  165. package/dist/actions/wallet/account/removeAccount.mjs.map +1 -0
  166. package/dist/actions/wallet/account/showAccount.mjs +368 -0
  167. package/dist/actions/wallet/account/showAccount.mjs.map +1 -0
  168. package/dist/actions/wallet/addressBook/storage.mjs +110 -0
  169. package/dist/actions/wallet/addressBook/storage.mjs.map +1 -0
  170. package/dist/actions/wallet/backup/exportBackup.mjs +93 -0
  171. package/dist/actions/wallet/backup/exportBackup.mjs.map +1 -0
  172. package/dist/actions/wallet/backup/importBackup.mjs +142 -0
  173. package/dist/actions/wallet/backup/importBackup.mjs.map +1 -0
  174. package/dist/actions/wallet/balance/getBalance.mjs +434 -0
  175. package/dist/actions/wallet/balance/getBalance.mjs.map +1 -0
  176. package/dist/actions/wallet/client/walletClient.mjs +64 -0
  177. package/dist/actions/wallet/client/walletClient.mjs.map +1 -0
  178. package/dist/actions/wallet/contact/contactActions.mjs +120 -0
  179. package/dist/actions/wallet/contact/contactActions.mjs.map +1 -0
  180. package/dist/actions/wallet/contact/storage.mjs +69 -0
  181. package/dist/actions/wallet/contact/storage.mjs.map +1 -0
  182. package/dist/actions/wallet/index.mjs +1439 -0
  183. package/dist/actions/wallet/index.mjs.map +1 -0
  184. package/dist/actions/wallet/network/networkActions.mjs +137 -0
  185. package/dist/actions/wallet/network/networkActions.mjs.map +1 -0
  186. package/dist/actions/wallet/network/storage.mjs +93 -0
  187. package/dist/actions/wallet/network/storage.mjs.map +1 -0
  188. package/dist/actions/wallet/password/changePassword.mjs +282 -0
  189. package/dist/actions/wallet/password/changePassword.mjs.map +1 -0
  190. package/dist/actions/wallet/password/getActiveKey.mjs +297 -0
  191. package/dist/actions/wallet/password/getActiveKey.mjs.map +1 -0
  192. package/dist/actions/wallet/password/initOrUnlock.mjs +337 -0
  193. package/dist/actions/wallet/password/initOrUnlock.mjs.map +1 -0
  194. package/dist/actions/wallet/password/passwordStorage.mjs +69 -0
  195. package/dist/actions/wallet/password/passwordStorage.mjs.map +1 -0
  196. package/dist/actions/wallet/password/setPassword.mjs +138 -0
  197. package/dist/actions/wallet/password/setPassword.mjs.map +1 -0
  198. package/dist/actions/wallet/password/validatePassword.mjs +123 -0
  199. package/dist/actions/wallet/password/validatePassword.mjs.map +1 -0
  200. package/dist/actions/wallet/passwordKey.mjs +87 -0
  201. package/dist/actions/wallet/passwordKey.mjs.map +1 -0
  202. package/dist/actions/wallet/paths.mjs +26 -0
  203. package/dist/actions/wallet/paths.mjs.map +1 -0
  204. package/dist/actions/wallet/prompt.mjs +93 -0
  205. package/dist/actions/wallet/prompt.mjs.map +1 -0
  206. package/dist/actions/wallet/seedPhrase/createPhrase.mjs +392 -0
  207. package/dist/actions/wallet/seedPhrase/createPhrase.mjs.map +1 -0
  208. package/dist/actions/wallet/seedPhrase/exportPhrase.mjs +334 -0
  209. package/dist/actions/wallet/seedPhrase/exportPhrase.mjs.map +1 -0
  210. package/dist/actions/wallet/seedPhrase/idGen.mjs +11 -0
  211. package/dist/actions/wallet/seedPhrase/idGen.mjs.map +1 -0
  212. package/dist/actions/wallet/seedPhrase/importPhrase.mjs +393 -0
  213. package/dist/actions/wallet/seedPhrase/importPhrase.mjs.map +1 -0
  214. package/dist/actions/wallet/seedPhrase/listPhrases.mjs +62 -0
  215. package/dist/actions/wallet/seedPhrase/listPhrases.mjs.map +1 -0
  216. package/dist/actions/wallet/seedPhrase/phraseStorage.mjs +89 -0
  217. package/dist/actions/wallet/seedPhrase/phraseStorage.mjs.map +1 -0
  218. package/dist/actions/wallet/seedPhrase/removePhrase.mjs +366 -0
  219. package/dist/actions/wallet/seedPhrase/removePhrase.mjs.map +1 -0
  220. package/dist/actions/wallet/seedPhrase/renamePhrase.mjs +78 -0
  221. package/dist/actions/wallet/seedPhrase/renamePhrase.mjs.map +1 -0
  222. package/dist/actions/wallet/seedPhrase/types.mjs +1 -0
  223. package/dist/actions/wallet/seedPhrase/types.mjs.map +1 -0
  224. package/dist/actions/wallet/seedPhrase/usePhrase.mjs +83 -0
  225. package/dist/actions/wallet/seedPhrase/usePhrase.mjs.map +1 -0
  226. package/dist/actions/wallet/session/machineId.mjs +145 -0
  227. package/dist/actions/wallet/session/machineId.mjs.map +1 -0
  228. package/dist/actions/wallet/session/sessionCache.mjs +221 -0
  229. package/dist/actions/wallet/session/sessionCache.mjs.map +1 -0
  230. package/dist/actions/wallet/session/unlock.mjs +307 -0
  231. package/dist/actions/wallet/session/unlock.mjs.map +1 -0
  232. package/dist/actions/wallet/sign/signPayload.mjs +637 -0
  233. package/dist/actions/wallet/sign/signPayload.mjs.map +1 -0
  234. package/dist/actions/wallet/storage.mjs +51 -0
  235. package/dist/actions/wallet/storage.mjs.map +1 -0
  236. package/dist/actions/wallet/transaction/broadcastTransaction.mjs +453 -0
  237. package/dist/actions/wallet/transaction/broadcastTransaction.mjs.map +1 -0
  238. package/dist/actions/wallet/transaction/sendTransaction.mjs +457 -0
  239. package/dist/actions/wallet/transaction/sendTransaction.mjs.map +1 -0
  240. package/dist/actions/wallet/transaction/signTransactionFile.mjs +378 -0
  241. package/dist/actions/wallet/transaction/signTransactionFile.mjs.map +1 -0
  242. package/dist/actions/xyo/index.mjs +138 -0
  243. package/dist/actions/xyo/index.mjs.map +1 -0
  244. package/dist/actions/xyo/transaction/index.mjs +138 -0
  245. package/dist/actions/xyo/transaction/index.mjs.map +1 -0
  246. package/dist/actions/xyo/transaction/validateTransactions.mjs +138 -0
  247. package/dist/actions/xyo/transaction/validateTransactions.mjs.map +1 -0
  248. package/dist/aries.mjs +8466 -0
  249. package/dist/aries.mjs.map +1 -0
  250. package/dist/bin/aries.mjs +8472 -0
  251. package/dist/bin/aries.mjs.map +1 -0
  252. package/dist/commands/aiCommand.mjs +492 -0
  253. package/dist/commands/aiCommand.mjs.map +1 -0
  254. package/dist/commands/auditAiCommand.mjs +119 -0
  255. package/dist/commands/auditAiCommand.mjs.map +1 -0
  256. package/dist/commands/auditCommand.mjs +857 -0
  257. package/dist/commands/auditCommand.mjs.map +1 -0
  258. package/dist/commands/auditInstallCommand.mjs +324 -0
  259. package/dist/commands/auditInstallCommand.mjs.map +1 -0
  260. package/dist/commands/auditListCommand.mjs +107 -0
  261. package/dist/commands/auditListCommand.mjs.map +1 -0
  262. package/dist/commands/auditOpenCommand.mjs +51 -0
  263. package/dist/commands/auditOpenCommand.mjs.map +1 -0
  264. package/dist/commands/auditSearchCommand.mjs +98 -0
  265. package/dist/commands/auditSearchCommand.mjs.map +1 -0
  266. package/dist/commands/auditShowCommand.mjs +123 -0
  267. package/dist/commands/auditShowCommand.mjs.map +1 -0
  268. package/dist/commands/auditStatusCommand.mjs +105 -0
  269. package/dist/commands/auditStatusCommand.mjs.map +1 -0
  270. package/dist/commands/clampCommand.mjs +2328 -0
  271. package/dist/commands/clampCommand.mjs.map +1 -0
  272. package/dist/commands/clampPolicyCommand.mjs +184 -0
  273. package/dist/commands/clampPolicyCommand.mjs.map +1 -0
  274. package/dist/commands/clampPolicyInitCommand.mjs +63 -0
  275. package/dist/commands/clampPolicyInitCommand.mjs.map +1 -0
  276. package/dist/commands/clampPolicyListCommand.mjs +56 -0
  277. package/dist/commands/clampPolicyListCommand.mjs.map +1 -0
  278. package/dist/commands/clampPolicyShowCommand.mjs +83 -0
  279. package/dist/commands/clampPolicyShowCommand.mjs.map +1 -0
  280. package/dist/commands/clampRunCommand.mjs +2137 -0
  281. package/dist/commands/clampRunCommand.mjs.map +1 -0
  282. package/dist/commands/datalakeAuditCommand.mjs +273 -0
  283. package/dist/commands/datalakeAuditCommand.mjs.map +1 -0
  284. package/dist/commands/datalakeCommand.mjs +1637 -0
  285. package/dist/commands/datalakeCommand.mjs.map +1 -0
  286. package/dist/commands/datalakeCreateCommand.mjs +189 -0
  287. package/dist/commands/datalakeCreateCommand.mjs.map +1 -0
  288. package/dist/commands/datalakeDescribeCommand.mjs +172 -0
  289. package/dist/commands/datalakeDescribeCommand.mjs.map +1 -0
  290. package/dist/commands/datalakeDestroyCommand.mjs +53 -0
  291. package/dist/commands/datalakeDestroyCommand.mjs.map +1 -0
  292. package/dist/commands/datalakeDevCommand.mjs +470 -0
  293. package/dist/commands/datalakeDevCommand.mjs.map +1 -0
  294. package/dist/commands/datalakeDevDownCommand.mjs +111 -0
  295. package/dist/commands/datalakeDevDownCommand.mjs.map +1 -0
  296. package/dist/commands/datalakeDevLogsCommand.mjs +65 -0
  297. package/dist/commands/datalakeDevLogsCommand.mjs.map +1 -0
  298. package/dist/commands/datalakeDevResetCommand.mjs +125 -0
  299. package/dist/commands/datalakeDevResetCommand.mjs.map +1 -0
  300. package/dist/commands/datalakeDevStatusCommand.mjs +110 -0
  301. package/dist/commands/datalakeDevStatusCommand.mjs.map +1 -0
  302. package/dist/commands/datalakeDevUpCommand.mjs +268 -0
  303. package/dist/commands/datalakeDevUpCommand.mjs.map +1 -0
  304. package/dist/commands/datalakeFetchCommand.mjs +106 -0
  305. package/dist/commands/datalakeFetchCommand.mjs.map +1 -0
  306. package/dist/commands/datalakeGrantCommand.mjs +147 -0
  307. package/dist/commands/datalakeGrantCommand.mjs.map +1 -0
  308. package/dist/commands/datalakeListCommand.mjs +61 -0
  309. package/dist/commands/datalakeListCommand.mjs.map +1 -0
  310. package/dist/commands/datalakeLoginCommand.mjs +39 -0
  311. package/dist/commands/datalakeLoginCommand.mjs.map +1 -0
  312. package/dist/commands/datalakeLogoutCommand.mjs +20 -0
  313. package/dist/commands/datalakeLogoutCommand.mjs.map +1 -0
  314. package/dist/commands/datalakePushCommand.mjs +214 -0
  315. package/dist/commands/datalakePushCommand.mjs.map +1 -0
  316. package/dist/commands/datalakeRevokeCommand.mjs +127 -0
  317. package/dist/commands/datalakeRevokeCommand.mjs.map +1 -0
  318. package/dist/commands/datalakeTailCommand.mjs +144 -0
  319. package/dist/commands/datalakeTailCommand.mjs.map +1 -0
  320. package/dist/commands/datalakeTokenCommand.mjs +61 -0
  321. package/dist/commands/datalakeTokenCommand.mjs.map +1 -0
  322. package/dist/commands/datalakeUseCommand.mjs +35 -0
  323. package/dist/commands/datalakeUseCommand.mjs.map +1 -0
  324. package/dist/commands/detectCommand.mjs +419 -0
  325. package/dist/commands/detectCommand.mjs.map +1 -0
  326. package/dist/commands/hashCommand.mjs +976 -0
  327. package/dist/commands/hashCommand.mjs.map +1 -0
  328. package/dist/commands/hashCompareCommand.mjs +865 -0
  329. package/dist/commands/hashCompareCommand.mjs.map +1 -0
  330. package/dist/commands/index.mjs +8461 -0
  331. package/dist/commands/index.mjs.map +1 -0
  332. package/dist/commands/syncCommand.mjs +66 -0
  333. package/dist/commands/syncCommand.mjs.map +1 -0
  334. package/dist/commands/versionCommand.mjs +24 -0
  335. package/dist/commands/versionCommand.mjs.map +1 -0
  336. package/dist/commands/walletAccountCommand.mjs +536 -0
  337. package/dist/commands/walletAccountCommand.mjs.map +1 -0
  338. package/dist/commands/walletAccountDeriveCommand.mjs +415 -0
  339. package/dist/commands/walletAccountDeriveCommand.mjs.map +1 -0
  340. package/dist/commands/walletAccountLabelCommand.mjs +405 -0
  341. package/dist/commands/walletAccountLabelCommand.mjs.map +1 -0
  342. package/dist/commands/walletAccountListCommand.mjs +381 -0
  343. package/dist/commands/walletAccountListCommand.mjs.map +1 -0
  344. package/dist/commands/walletAccountRemoveCommand.mjs +396 -0
  345. package/dist/commands/walletAccountRemoveCommand.mjs.map +1 -0
  346. package/dist/commands/walletAccountShowCommand.mjs +380 -0
  347. package/dist/commands/walletAccountShowCommand.mjs.map +1 -0
  348. package/dist/commands/walletBackupCommand.mjs +222 -0
  349. package/dist/commands/walletBackupCommand.mjs.map +1 -0
  350. package/dist/commands/walletBackupExportCommand.mjs +107 -0
  351. package/dist/commands/walletBackupExportCommand.mjs.map +1 -0
  352. package/dist/commands/walletBackupImportCommand.mjs +154 -0
  353. package/dist/commands/walletBackupImportCommand.mjs.map +1 -0
  354. package/dist/commands/walletBalanceCommand.mjs +448 -0
  355. package/dist/commands/walletBalanceCommand.mjs.map +1 -0
  356. package/dist/commands/walletCommand.mjs +1968 -0
  357. package/dist/commands/walletCommand.mjs.map +1 -0
  358. package/dist/commands/walletContactAddCommand.mjs +111 -0
  359. package/dist/commands/walletContactAddCommand.mjs.map +1 -0
  360. package/dist/commands/walletContactCommand.mjs +184 -0
  361. package/dist/commands/walletContactCommand.mjs.map +1 -0
  362. package/dist/commands/walletContactListCommand.mjs +66 -0
  363. package/dist/commands/walletContactListCommand.mjs.map +1 -0
  364. package/dist/commands/walletContactRemoveCommand.mjs +97 -0
  365. package/dist/commands/walletContactRemoveCommand.mjs.map +1 -0
  366. package/dist/commands/walletContactRenameCommand.mjs +114 -0
  367. package/dist/commands/walletContactRenameCommand.mjs.map +1 -0
  368. package/dist/commands/walletCreateCommand.mjs +407 -0
  369. package/dist/commands/walletCreateCommand.mjs.map +1 -0
  370. package/dist/commands/walletExportCommand.mjs +345 -0
  371. package/dist/commands/walletExportCommand.mjs.map +1 -0
  372. package/dist/commands/walletImportCommand.mjs +413 -0
  373. package/dist/commands/walletImportCommand.mjs.map +1 -0
  374. package/dist/commands/walletListCommand.mjs +69 -0
  375. package/dist/commands/walletListCommand.mjs.map +1 -0
  376. package/dist/commands/walletLockCommand.mjs +56 -0
  377. package/dist/commands/walletLockCommand.mjs.map +1 -0
  378. package/dist/commands/walletNetworkAddCommand.mjs +131 -0
  379. package/dist/commands/walletNetworkAddCommand.mjs.map +1 -0
  380. package/dist/commands/walletNetworkCommand.mjs +206 -0
  381. package/dist/commands/walletNetworkCommand.mjs.map +1 -0
  382. package/dist/commands/walletNetworkListCommand.mjs +104 -0
  383. package/dist/commands/walletNetworkListCommand.mjs.map +1 -0
  384. package/dist/commands/walletNetworkRemoveCommand.mjs +112 -0
  385. package/dist/commands/walletNetworkRemoveCommand.mjs.map +1 -0
  386. package/dist/commands/walletNetworkUseCommand.mjs +110 -0
  387. package/dist/commands/walletNetworkUseCommand.mjs.map +1 -0
  388. package/dist/commands/walletPasswordChangeCommand.mjs +291 -0
  389. package/dist/commands/walletPasswordChangeCommand.mjs.map +1 -0
  390. package/dist/commands/walletPasswordCommand.mjs +301 -0
  391. package/dist/commands/walletPasswordCommand.mjs.map +1 -0
  392. package/dist/commands/walletRemoveCommand.mjs +378 -0
  393. package/dist/commands/walletRemoveCommand.mjs.map +1 -0
  394. package/dist/commands/walletRenameCommand.mjs +94 -0
  395. package/dist/commands/walletRenameCommand.mjs.map +1 -0
  396. package/dist/commands/walletSignCommand.mjs +662 -0
  397. package/dist/commands/walletSignCommand.mjs.map +1 -0
  398. package/dist/commands/walletTxBroadcastCommand.mjs +473 -0
  399. package/dist/commands/walletTxBroadcastCommand.mjs.map +1 -0
  400. package/dist/commands/walletTxCommand.mjs +612 -0
  401. package/dist/commands/walletTxCommand.mjs.map +1 -0
  402. package/dist/commands/walletTxSendCommand.mjs +492 -0
  403. package/dist/commands/walletTxSendCommand.mjs.map +1 -0
  404. package/dist/commands/walletTxSignCommand.mjs +403 -0
  405. package/dist/commands/walletTxSignCommand.mjs.map +1 -0
  406. package/dist/commands/walletUnlockCommand.mjs +308 -0
  407. package/dist/commands/walletUnlockCommand.mjs.map +1 -0
  408. package/dist/commands/walletUseCommand.mjs +95 -0
  409. package/dist/commands/walletUseCommand.mjs.map +1 -0
  410. package/dist/commands/xyoCommand.mjs +188 -0
  411. package/dist/commands/xyoCommand.mjs.map +1 -0
  412. package/dist/commands/xyoTxCommand.mjs +178 -0
  413. package/dist/commands/xyoTxCommand.mjs.map +1 -0
  414. package/dist/commands/xyoTxValidateCommand.mjs +168 -0
  415. package/dist/commands/xyoTxValidateCommand.mjs.map +1 -0
  416. package/dist/index.d.ts +3 -0
  417. package/dist/index.mjs +8466 -0
  418. package/dist/index.mjs.map +1 -0
  419. package/dist/types/modules.d.mjs +1 -0
  420. package/dist/types/modules.d.mjs.map +1 -0
  421. package/package.json +197 -0
@@ -0,0 +1,2137 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+ var __commonJS = (cb, mod) => function __require2() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+
12
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js
13
+ var require_utils = __commonJS({
14
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js"(exports) {
15
+ "use strict";
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.loadNativeModule = exports.assign = void 0;
18
+ function assign(target) {
19
+ var sources = [];
20
+ for (var _i = 1; _i < arguments.length; _i++) {
21
+ sources[_i - 1] = arguments[_i];
22
+ }
23
+ sources.forEach(function(source) {
24
+ return Object.keys(source).forEach(function(key) {
25
+ return target[key] = source[key];
26
+ });
27
+ });
28
+ return target;
29
+ }
30
+ exports.assign = assign;
31
+ function loadNativeModule(name) {
32
+ var dirs = ["build/Release", "build/Debug", "prebuilds/" + process.platform + "-" + process.arch];
33
+ var relative = ["..", "."];
34
+ var lastError;
35
+ for (var _i = 0, dirs_1 = dirs; _i < dirs_1.length; _i++) {
36
+ var d = dirs_1[_i];
37
+ for (var _a = 0, relative_1 = relative; _a < relative_1.length; _a++) {
38
+ var r = relative_1[_a];
39
+ var dir = r + "/" + d + "/";
40
+ try {
41
+ return { dir, module: __require(dir + "/" + name + ".node") };
42
+ } catch (e) {
43
+ lastError = e;
44
+ }
45
+ }
46
+ }
47
+ throw new Error("Failed to load native module: " + name + ".node, checked: " + dirs.join(", ") + ": " + lastError);
48
+ }
49
+ exports.loadNativeModule = loadNativeModule;
50
+ }
51
+ });
52
+
53
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js
54
+ var require_eventEmitter2 = __commonJS({
55
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js"(exports) {
56
+ "use strict";
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.EventEmitter2 = void 0;
59
+ var EventEmitter2 = (
60
+ /** @class */
61
+ (function() {
62
+ function EventEmitter22() {
63
+ this._listeners = [];
64
+ }
65
+ Object.defineProperty(EventEmitter22.prototype, "event", {
66
+ get: function() {
67
+ var _this = this;
68
+ if (!this._event) {
69
+ this._event = function(listener) {
70
+ _this._listeners.push(listener);
71
+ var disposable = {
72
+ dispose: function() {
73
+ for (var i = 0; i < _this._listeners.length; i++) {
74
+ if (_this._listeners[i] === listener) {
75
+ _this._listeners.splice(i, 1);
76
+ return;
77
+ }
78
+ }
79
+ }
80
+ };
81
+ return disposable;
82
+ };
83
+ }
84
+ return this._event;
85
+ },
86
+ enumerable: false,
87
+ configurable: true
88
+ });
89
+ EventEmitter22.prototype.fire = function(data) {
90
+ var queue = [];
91
+ for (var i = 0; i < this._listeners.length; i++) {
92
+ queue.push(this._listeners[i]);
93
+ }
94
+ for (var i = 0; i < queue.length; i++) {
95
+ queue[i].call(void 0, data);
96
+ }
97
+ };
98
+ return EventEmitter22;
99
+ })()
100
+ );
101
+ exports.EventEmitter2 = EventEmitter2;
102
+ }
103
+ });
104
+
105
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js
106
+ var require_terminal = __commonJS({
107
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js"(exports) {
108
+ "use strict";
109
+ Object.defineProperty(exports, "__esModule", { value: true });
110
+ exports.Terminal = exports.DEFAULT_ROWS = exports.DEFAULT_COLS = void 0;
111
+ var events_1 = __require("events");
112
+ var eventEmitter2_1 = require_eventEmitter2();
113
+ exports.DEFAULT_COLS = 80;
114
+ exports.DEFAULT_ROWS = 24;
115
+ var FLOW_CONTROL_PAUSE = "";
116
+ var FLOW_CONTROL_RESUME = "";
117
+ var Terminal2 = (
118
+ /** @class */
119
+ (function() {
120
+ function Terminal3(opt) {
121
+ this._pid = 0;
122
+ this._fd = 0;
123
+ this._cols = 0;
124
+ this._rows = 0;
125
+ this._readable = false;
126
+ this._writable = false;
127
+ this._onData = new eventEmitter2_1.EventEmitter2();
128
+ this._onExit = new eventEmitter2_1.EventEmitter2();
129
+ this._internalee = new events_1.EventEmitter();
130
+ this.handleFlowControl = !!(opt === null || opt === void 0 ? void 0 : opt.handleFlowControl);
131
+ this._flowControlPause = (opt === null || opt === void 0 ? void 0 : opt.flowControlPause) || FLOW_CONTROL_PAUSE;
132
+ this._flowControlResume = (opt === null || opt === void 0 ? void 0 : opt.flowControlResume) || FLOW_CONTROL_RESUME;
133
+ if (!opt) {
134
+ return;
135
+ }
136
+ this._checkType("name", opt.name ? opt.name : void 0, "string");
137
+ this._checkType("cols", opt.cols ? opt.cols : void 0, "number");
138
+ this._checkType("rows", opt.rows ? opt.rows : void 0, "number");
139
+ this._checkType("cwd", opt.cwd ? opt.cwd : void 0, "string");
140
+ this._checkType("env", opt.env ? opt.env : void 0, "object");
141
+ this._checkType("uid", opt.uid ? opt.uid : void 0, "number");
142
+ this._checkType("gid", opt.gid ? opt.gid : void 0, "number");
143
+ this._checkType("encoding", opt.encoding ? opt.encoding : void 0, "string");
144
+ }
145
+ Object.defineProperty(Terminal3.prototype, "onData", {
146
+ get: function() {
147
+ return this._onData.event;
148
+ },
149
+ enumerable: false,
150
+ configurable: true
151
+ });
152
+ Object.defineProperty(Terminal3.prototype, "onExit", {
153
+ get: function() {
154
+ return this._onExit.event;
155
+ },
156
+ enumerable: false,
157
+ configurable: true
158
+ });
159
+ Object.defineProperty(Terminal3.prototype, "pid", {
160
+ get: function() {
161
+ return this._pid;
162
+ },
163
+ enumerable: false,
164
+ configurable: true
165
+ });
166
+ Object.defineProperty(Terminal3.prototype, "cols", {
167
+ get: function() {
168
+ return this._cols;
169
+ },
170
+ enumerable: false,
171
+ configurable: true
172
+ });
173
+ Object.defineProperty(Terminal3.prototype, "rows", {
174
+ get: function() {
175
+ return this._rows;
176
+ },
177
+ enumerable: false,
178
+ configurable: true
179
+ });
180
+ Terminal3.prototype.write = function(data) {
181
+ if (this.handleFlowControl) {
182
+ if (data === this._flowControlPause) {
183
+ this.pause();
184
+ return;
185
+ }
186
+ if (data === this._flowControlResume) {
187
+ this.resume();
188
+ return;
189
+ }
190
+ }
191
+ this._write(data);
192
+ };
193
+ Terminal3.prototype._forwardEvents = function() {
194
+ var _this = this;
195
+ this.on("data", function(e) {
196
+ return _this._onData.fire(e);
197
+ });
198
+ this.on("exit", function(exitCode, signal) {
199
+ return _this._onExit.fire({ exitCode, signal });
200
+ });
201
+ };
202
+ Terminal3.prototype._checkType = function(name, value, type, allowArray) {
203
+ if (allowArray === void 0) {
204
+ allowArray = false;
205
+ }
206
+ if (value === void 0) {
207
+ return;
208
+ }
209
+ if (allowArray) {
210
+ if (Array.isArray(value)) {
211
+ value.forEach(function(v, i) {
212
+ if (typeof v !== type) {
213
+ throw new Error(name + "[" + i + "] must be a " + type + " (not a " + typeof v[i] + ")");
214
+ }
215
+ });
216
+ return;
217
+ }
218
+ }
219
+ if (typeof value !== type) {
220
+ throw new Error(name + " must be a " + type + " (not a " + typeof value + ")");
221
+ }
222
+ };
223
+ Terminal3.prototype.end = function(data) {
224
+ this._socket.end(data);
225
+ };
226
+ Terminal3.prototype.pipe = function(dest, options) {
227
+ return this._socket.pipe(dest, options);
228
+ };
229
+ Terminal3.prototype.pause = function() {
230
+ return this._socket.pause();
231
+ };
232
+ Terminal3.prototype.resume = function() {
233
+ return this._socket.resume();
234
+ };
235
+ Terminal3.prototype.setEncoding = function(encoding) {
236
+ if (this._socket._decoder) {
237
+ delete this._socket._decoder;
238
+ }
239
+ if (encoding) {
240
+ this._socket.setEncoding(encoding);
241
+ }
242
+ };
243
+ Terminal3.prototype.addListener = function(eventName, listener) {
244
+ this.on(eventName, listener);
245
+ };
246
+ Terminal3.prototype.on = function(eventName, listener) {
247
+ if (eventName === "close") {
248
+ this._internalee.on("close", listener);
249
+ return;
250
+ }
251
+ this._socket.on(eventName, listener);
252
+ };
253
+ Terminal3.prototype.emit = function(eventName) {
254
+ var args = [];
255
+ for (var _i = 1; _i < arguments.length; _i++) {
256
+ args[_i - 1] = arguments[_i];
257
+ }
258
+ if (eventName === "close") {
259
+ return this._internalee.emit.apply(this._internalee, arguments);
260
+ }
261
+ return this._socket.emit.apply(this._socket, arguments);
262
+ };
263
+ Terminal3.prototype.listeners = function(eventName) {
264
+ return this._socket.listeners(eventName);
265
+ };
266
+ Terminal3.prototype.removeListener = function(eventName, listener) {
267
+ this._socket.removeListener(eventName, listener);
268
+ };
269
+ Terminal3.prototype.removeAllListeners = function(eventName) {
270
+ this._socket.removeAllListeners(eventName);
271
+ };
272
+ Terminal3.prototype.once = function(eventName, listener) {
273
+ this._socket.once(eventName, listener);
274
+ };
275
+ Terminal3.prototype._close = function() {
276
+ this._socket.readable = false;
277
+ this.write = function() {
278
+ };
279
+ this.end = function() {
280
+ };
281
+ this._writable = false;
282
+ this._readable = false;
283
+ };
284
+ Terminal3.prototype._parseEnv = function(env) {
285
+ var keys = Object.keys(env || {});
286
+ var pairs = [];
287
+ for (var i = 0; i < keys.length; i++) {
288
+ if (keys[i] === void 0) {
289
+ continue;
290
+ }
291
+ pairs.push(keys[i] + "=" + env[keys[i]]);
292
+ }
293
+ return pairs;
294
+ };
295
+ return Terminal3;
296
+ })()
297
+ );
298
+ exports.Terminal = Terminal2;
299
+ }
300
+ });
301
+
302
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js
303
+ var require_conout = __commonJS({
304
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js"(exports) {
305
+ "use strict";
306
+ Object.defineProperty(exports, "__esModule", { value: true });
307
+ exports.getWorkerPipeName = void 0;
308
+ function getWorkerPipeName(conoutPipeName) {
309
+ return conoutPipeName + "-worker";
310
+ }
311
+ exports.getWorkerPipeName = getWorkerPipeName;
312
+ }
313
+ });
314
+
315
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js
316
+ var require_windowsConoutConnection = __commonJS({
317
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js"(exports) {
318
+ "use strict";
319
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
320
+ function adopt(value) {
321
+ return value instanceof P ? value : new P(function(resolve) {
322
+ resolve(value);
323
+ });
324
+ }
325
+ return new (P || (P = Promise))(function(resolve, reject) {
326
+ function fulfilled(value) {
327
+ try {
328
+ step(generator.next(value));
329
+ } catch (e) {
330
+ reject(e);
331
+ }
332
+ }
333
+ function rejected(value) {
334
+ try {
335
+ step(generator["throw"](value));
336
+ } catch (e) {
337
+ reject(e);
338
+ }
339
+ }
340
+ function step(result) {
341
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
342
+ }
343
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
344
+ });
345
+ };
346
+ var __generator = exports && exports.__generator || function(thisArg, body) {
347
+ var _ = { label: 0, sent: function() {
348
+ if (t[0] & 1) throw t[1];
349
+ return t[1];
350
+ }, trys: [], ops: [] }, f, y, t, g;
351
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
352
+ return this;
353
+ }), g;
354
+ function verb(n) {
355
+ return function(v) {
356
+ return step([n, v]);
357
+ };
358
+ }
359
+ function step(op) {
360
+ if (f) throw new TypeError("Generator is already executing.");
361
+ while (_) try {
362
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
363
+ if (y = 0, t) op = [op[0] & 2, t.value];
364
+ switch (op[0]) {
365
+ case 0:
366
+ case 1:
367
+ t = op;
368
+ break;
369
+ case 4:
370
+ _.label++;
371
+ return { value: op[1], done: false };
372
+ case 5:
373
+ _.label++;
374
+ y = op[1];
375
+ op = [0];
376
+ continue;
377
+ case 7:
378
+ op = _.ops.pop();
379
+ _.trys.pop();
380
+ continue;
381
+ default:
382
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
383
+ _ = 0;
384
+ continue;
385
+ }
386
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
387
+ _.label = op[1];
388
+ break;
389
+ }
390
+ if (op[0] === 6 && _.label < t[1]) {
391
+ _.label = t[1];
392
+ t = op;
393
+ break;
394
+ }
395
+ if (t && _.label < t[2]) {
396
+ _.label = t[2];
397
+ _.ops.push(op);
398
+ break;
399
+ }
400
+ if (t[2]) _.ops.pop();
401
+ _.trys.pop();
402
+ continue;
403
+ }
404
+ op = body.call(thisArg, _);
405
+ } catch (e) {
406
+ op = [6, e];
407
+ y = 0;
408
+ } finally {
409
+ f = t = 0;
410
+ }
411
+ if (op[0] & 5) throw op[1];
412
+ return { value: op[0] ? op[1] : void 0, done: true };
413
+ }
414
+ };
415
+ Object.defineProperty(exports, "__esModule", { value: true });
416
+ exports.ConoutConnection = void 0;
417
+ var worker_threads_1 = __require("worker_threads");
418
+ var conout_1 = require_conout();
419
+ var path_1 = __require("path");
420
+ var eventEmitter2_1 = require_eventEmitter2();
421
+ var FLUSH_DATA_INTERVAL = 1e3;
422
+ var ConoutConnection = (
423
+ /** @class */
424
+ (function() {
425
+ function ConoutConnection2(_conoutPipeName, _useConptyDll) {
426
+ var _this = this;
427
+ this._conoutPipeName = _conoutPipeName;
428
+ this._useConptyDll = _useConptyDll;
429
+ this._isDisposed = false;
430
+ this._onReady = new eventEmitter2_1.EventEmitter2();
431
+ var workerData = {
432
+ conoutPipeName: _conoutPipeName
433
+ };
434
+ var scriptPath = __dirname.replace("node_modules.asar", "node_modules.asar.unpacked");
435
+ this._worker = new worker_threads_1.Worker(path_1.join(scriptPath, "worker/conoutSocketWorker.js"), { workerData });
436
+ this._worker.on("message", function(message) {
437
+ switch (message) {
438
+ case 1:
439
+ _this._onReady.fire();
440
+ return;
441
+ default:
442
+ console.warn("Unexpected ConoutWorkerMessage", message);
443
+ }
444
+ });
445
+ }
446
+ Object.defineProperty(ConoutConnection2.prototype, "onReady", {
447
+ get: function() {
448
+ return this._onReady.event;
449
+ },
450
+ enumerable: false,
451
+ configurable: true
452
+ });
453
+ ConoutConnection2.prototype.dispose = function() {
454
+ if (!this._useConptyDll && this._isDisposed) {
455
+ return;
456
+ }
457
+ this._isDisposed = true;
458
+ this._drainDataAndClose();
459
+ };
460
+ ConoutConnection2.prototype.connectSocket = function(socket) {
461
+ socket.connect(conout_1.getWorkerPipeName(this._conoutPipeName));
462
+ };
463
+ ConoutConnection2.prototype._drainDataAndClose = function() {
464
+ var _this = this;
465
+ if (this._drainTimeout) {
466
+ clearTimeout(this._drainTimeout);
467
+ }
468
+ this._drainTimeout = setTimeout(function() {
469
+ return _this._destroySocket();
470
+ }, FLUSH_DATA_INTERVAL);
471
+ };
472
+ ConoutConnection2.prototype._destroySocket = function() {
473
+ return __awaiter(this, void 0, void 0, function() {
474
+ return __generator(this, function(_a) {
475
+ switch (_a.label) {
476
+ case 0:
477
+ return [4, this._worker.terminate()];
478
+ case 1:
479
+ _a.sent();
480
+ return [
481
+ 2
482
+ /*return*/
483
+ ];
484
+ }
485
+ });
486
+ });
487
+ };
488
+ return ConoutConnection2;
489
+ })()
490
+ );
491
+ exports.ConoutConnection = ConoutConnection;
492
+ }
493
+ });
494
+
495
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js
496
+ var require_windowsPtyAgent = __commonJS({
497
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js"(exports) {
498
+ "use strict";
499
+ Object.defineProperty(exports, "__esModule", { value: true });
500
+ exports.argsToCommandLine = exports.WindowsPtyAgent = void 0;
501
+ var fs = __require("fs");
502
+ var os = __require("os");
503
+ var path5 = __require("path");
504
+ var child_process_1 = __require("child_process");
505
+ var net_1 = __require("net");
506
+ var windowsConoutConnection_1 = require_windowsConoutConnection();
507
+ var utils_1 = require_utils();
508
+ var conptyNative;
509
+ var winptyNative;
510
+ var FLUSH_DATA_INTERVAL = 1e3;
511
+ var WindowsPtyAgent = (
512
+ /** @class */
513
+ (function() {
514
+ function WindowsPtyAgent2(file, args, env, cwd, cols, rows, debug, _useConpty, _useConptyDll, conptyInheritCursor) {
515
+ var _this = this;
516
+ if (_useConptyDll === void 0) {
517
+ _useConptyDll = false;
518
+ }
519
+ if (conptyInheritCursor === void 0) {
520
+ conptyInheritCursor = false;
521
+ }
522
+ this._useConpty = _useConpty;
523
+ this._useConptyDll = _useConptyDll;
524
+ this._pid = 0;
525
+ this._innerPid = 0;
526
+ if (this._useConpty === void 0 || this._useConpty === true) {
527
+ this._useConpty = this._getWindowsBuildNumber() >= 18309;
528
+ }
529
+ if (this._useConpty) {
530
+ if (!conptyNative) {
531
+ conptyNative = utils_1.loadNativeModule("conpty").module;
532
+ }
533
+ } else {
534
+ if (!winptyNative) {
535
+ winptyNative = utils_1.loadNativeModule("pty").module;
536
+ }
537
+ }
538
+ this._ptyNative = this._useConpty ? conptyNative : winptyNative;
539
+ cwd = path5.resolve(cwd);
540
+ var commandLine = argsToCommandLine(file, args);
541
+ var term;
542
+ if (this._useConpty) {
543
+ term = this._ptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll);
544
+ } else {
545
+ term = this._ptyNative.startProcess(file, commandLine, env, cwd, cols, rows, debug);
546
+ this._pid = term.pid;
547
+ this._innerPid = term.innerPid;
548
+ }
549
+ this._fd = term.fd;
550
+ this._pty = term.pty;
551
+ this._outSocket = new net_1.Socket();
552
+ this._outSocket.setEncoding("utf8");
553
+ this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout, this._useConptyDll);
554
+ this._conoutSocketWorker.onReady(function() {
555
+ _this._conoutSocketWorker.connectSocket(_this._outSocket);
556
+ });
557
+ this._outSocket.on("connect", function() {
558
+ _this._outSocket.emit("ready_datapipe");
559
+ });
560
+ var inSocketFD = fs.openSync(term.conin, "w");
561
+ this._inSocket = new net_1.Socket({
562
+ fd: inSocketFD,
563
+ readable: false,
564
+ writable: true
565
+ });
566
+ this._inSocket.setEncoding("utf8");
567
+ if (this._useConpty) {
568
+ var connect = this._ptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function(c) {
569
+ return _this._$onProcessExit(c);
570
+ });
571
+ this._innerPid = connect.pid;
572
+ }
573
+ }
574
+ Object.defineProperty(WindowsPtyAgent2.prototype, "inSocket", {
575
+ get: function() {
576
+ return this._inSocket;
577
+ },
578
+ enumerable: false,
579
+ configurable: true
580
+ });
581
+ Object.defineProperty(WindowsPtyAgent2.prototype, "outSocket", {
582
+ get: function() {
583
+ return this._outSocket;
584
+ },
585
+ enumerable: false,
586
+ configurable: true
587
+ });
588
+ Object.defineProperty(WindowsPtyAgent2.prototype, "fd", {
589
+ get: function() {
590
+ return this._fd;
591
+ },
592
+ enumerable: false,
593
+ configurable: true
594
+ });
595
+ Object.defineProperty(WindowsPtyAgent2.prototype, "innerPid", {
596
+ get: function() {
597
+ return this._innerPid;
598
+ },
599
+ enumerable: false,
600
+ configurable: true
601
+ });
602
+ Object.defineProperty(WindowsPtyAgent2.prototype, "pty", {
603
+ get: function() {
604
+ return this._pty;
605
+ },
606
+ enumerable: false,
607
+ configurable: true
608
+ });
609
+ WindowsPtyAgent2.prototype.resize = function(cols, rows) {
610
+ if (this._useConpty) {
611
+ if (this._exitCode !== void 0) {
612
+ throw new Error("Cannot resize a pty that has already exited");
613
+ }
614
+ this._ptyNative.resize(this._pty, cols, rows, this._useConptyDll);
615
+ return;
616
+ }
617
+ this._ptyNative.resize(this._pid, cols, rows);
618
+ };
619
+ WindowsPtyAgent2.prototype.clear = function() {
620
+ if (this._useConpty) {
621
+ this._ptyNative.clear(this._pty, this._useConptyDll);
622
+ }
623
+ };
624
+ WindowsPtyAgent2.prototype.kill = function() {
625
+ var _this = this;
626
+ if (this._useConpty) {
627
+ if (!this._useConptyDll) {
628
+ this._inSocket.readable = false;
629
+ this._outSocket.readable = false;
630
+ this._getConsoleProcessList().then(function(consoleProcessList) {
631
+ consoleProcessList.forEach(function(pid) {
632
+ try {
633
+ process.kill(pid);
634
+ } catch (e) {
635
+ }
636
+ });
637
+ });
638
+ this._ptyNative.kill(this._pty, this._useConptyDll);
639
+ this._conoutSocketWorker.dispose();
640
+ } else {
641
+ this._inSocket.destroy();
642
+ this._ptyNative.kill(this._pty, this._useConptyDll);
643
+ this._outSocket.on("data", function() {
644
+ _this._conoutSocketWorker.dispose();
645
+ });
646
+ }
647
+ } else {
648
+ var processList = this._ptyNative.getProcessList(this._pid);
649
+ this._ptyNative.kill(this._pid, this._innerPid);
650
+ processList.forEach(function(pid) {
651
+ try {
652
+ process.kill(pid);
653
+ } catch (e) {
654
+ }
655
+ });
656
+ }
657
+ };
658
+ WindowsPtyAgent2.prototype._getConsoleProcessList = function() {
659
+ var _this = this;
660
+ return new Promise(function(resolve) {
661
+ var agent = child_process_1.fork(path5.join(__dirname, "conpty_console_list_agent"), [_this._innerPid.toString()]);
662
+ agent.on("message", function(message) {
663
+ clearTimeout(timeout);
664
+ resolve(message.consoleProcessList);
665
+ });
666
+ var timeout = setTimeout(function() {
667
+ agent.kill();
668
+ resolve([_this._innerPid]);
669
+ }, 5e3);
670
+ });
671
+ };
672
+ Object.defineProperty(WindowsPtyAgent2.prototype, "exitCode", {
673
+ get: function() {
674
+ if (this._useConpty) {
675
+ return this._exitCode;
676
+ }
677
+ var winptyExitCode = this._ptyNative.getExitCode(this._innerPid);
678
+ return winptyExitCode === -1 ? void 0 : winptyExitCode;
679
+ },
680
+ enumerable: false,
681
+ configurable: true
682
+ });
683
+ WindowsPtyAgent2.prototype._getWindowsBuildNumber = function() {
684
+ var osVersion = /(\d+)\.(\d+)\.(\d+)/g.exec(os.release());
685
+ var buildNumber = 0;
686
+ if (osVersion && osVersion.length === 4) {
687
+ buildNumber = parseInt(osVersion[3]);
688
+ }
689
+ return buildNumber;
690
+ };
691
+ WindowsPtyAgent2.prototype._generatePipeName = function() {
692
+ return "conpty-" + Math.random() * 1e7;
693
+ };
694
+ WindowsPtyAgent2.prototype._$onProcessExit = function(exitCode) {
695
+ var _this = this;
696
+ this._exitCode = exitCode;
697
+ if (!this._useConptyDll) {
698
+ this._flushDataAndCleanUp();
699
+ this._outSocket.on("data", function() {
700
+ return _this._flushDataAndCleanUp();
701
+ });
702
+ }
703
+ };
704
+ WindowsPtyAgent2.prototype._flushDataAndCleanUp = function() {
705
+ var _this = this;
706
+ if (this._useConptyDll) {
707
+ return;
708
+ }
709
+ if (this._closeTimeout) {
710
+ clearTimeout(this._closeTimeout);
711
+ }
712
+ this._closeTimeout = setTimeout(function() {
713
+ return _this._cleanUpProcess();
714
+ }, FLUSH_DATA_INTERVAL);
715
+ };
716
+ WindowsPtyAgent2.prototype._cleanUpProcess = function() {
717
+ if (this._useConptyDll) {
718
+ return;
719
+ }
720
+ this._inSocket.readable = false;
721
+ this._outSocket.readable = false;
722
+ this._outSocket.destroy();
723
+ };
724
+ return WindowsPtyAgent2;
725
+ })()
726
+ );
727
+ exports.WindowsPtyAgent = WindowsPtyAgent;
728
+ function argsToCommandLine(file, args) {
729
+ if (isCommandLine(args)) {
730
+ if (args.length === 0) {
731
+ return file;
732
+ }
733
+ return argsToCommandLine(file, []) + " " + args;
734
+ }
735
+ var argv = [file];
736
+ Array.prototype.push.apply(argv, args);
737
+ var result = "";
738
+ for (var argIndex = 0; argIndex < argv.length; argIndex++) {
739
+ if (argIndex > 0) {
740
+ result += " ";
741
+ }
742
+ var arg = argv[argIndex];
743
+ var hasLopsidedEnclosingQuote = xOr(arg[0] !== '"', arg[arg.length - 1] !== '"');
744
+ var hasNoEnclosingQuotes = arg[0] !== '"' && arg[arg.length - 1] !== '"';
745
+ var quote = arg === "" || (arg.indexOf(" ") !== -1 || arg.indexOf(" ") !== -1) && (arg.length > 1 && (hasLopsidedEnclosingQuote || hasNoEnclosingQuotes));
746
+ if (quote) {
747
+ result += '"';
748
+ }
749
+ var bsCount = 0;
750
+ for (var i = 0; i < arg.length; i++) {
751
+ var p = arg[i];
752
+ if (p === "\\") {
753
+ bsCount++;
754
+ } else if (p === '"') {
755
+ result += repeatText("\\", bsCount * 2 + 1);
756
+ result += '"';
757
+ bsCount = 0;
758
+ } else {
759
+ result += repeatText("\\", bsCount);
760
+ bsCount = 0;
761
+ result += p;
762
+ }
763
+ }
764
+ if (quote) {
765
+ result += repeatText("\\", bsCount * 2);
766
+ result += '"';
767
+ } else {
768
+ result += repeatText("\\", bsCount);
769
+ }
770
+ }
771
+ return result;
772
+ }
773
+ exports.argsToCommandLine = argsToCommandLine;
774
+ function isCommandLine(args) {
775
+ return typeof args === "string";
776
+ }
777
+ function repeatText(text, count) {
778
+ var result = "";
779
+ for (var i = 0; i < count; i++) {
780
+ result += text;
781
+ }
782
+ return result;
783
+ }
784
+ function xOr(arg1, arg2) {
785
+ return arg1 && !arg2 || !arg1 && arg2;
786
+ }
787
+ }
788
+ });
789
+
790
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js
791
+ var require_windowsTerminal = __commonJS({
792
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js"(exports) {
793
+ "use strict";
794
+ var __extends = exports && exports.__extends || /* @__PURE__ */ (function() {
795
+ var extendStatics = function(d, b) {
796
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
797
+ d2.__proto__ = b2;
798
+ } || function(d2, b2) {
799
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
800
+ };
801
+ return extendStatics(d, b);
802
+ };
803
+ return function(d, b) {
804
+ extendStatics(d, b);
805
+ function __() {
806
+ this.constructor = d;
807
+ }
808
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
809
+ };
810
+ })();
811
+ Object.defineProperty(exports, "__esModule", { value: true });
812
+ exports.WindowsTerminal = void 0;
813
+ var terminal_1 = require_terminal();
814
+ var windowsPtyAgent_1 = require_windowsPtyAgent();
815
+ var utils_1 = require_utils();
816
+ var DEFAULT_FILE = "cmd.exe";
817
+ var DEFAULT_NAME = "Windows Shell";
818
+ var WindowsTerminal = (
819
+ /** @class */
820
+ (function(_super) {
821
+ __extends(WindowsTerminal2, _super);
822
+ function WindowsTerminal2(file, args, opt) {
823
+ var _this = _super.call(this, opt) || this;
824
+ _this._checkType("args", args, "string", true);
825
+ args = args || [];
826
+ file = file || DEFAULT_FILE;
827
+ opt = opt || {};
828
+ opt.env = opt.env || process.env;
829
+ if (opt.encoding) {
830
+ console.warn("Setting encoding on Windows is not supported");
831
+ }
832
+ var env = utils_1.assign({}, opt.env);
833
+ _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
834
+ _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
835
+ var cwd = opt.cwd || process.cwd();
836
+ var name = opt.name || env.TERM || DEFAULT_NAME;
837
+ var parsedEnv = _this._parseEnv(env);
838
+ _this._isReady = false;
839
+ _this._deferreds = [];
840
+ _this._agent = new windowsPtyAgent_1.WindowsPtyAgent(file, args, parsedEnv, cwd, _this._cols, _this._rows, false, opt.useConpty, opt.useConptyDll, opt.conptyInheritCursor);
841
+ _this._socket = _this._agent.outSocket;
842
+ _this._pid = _this._agent.innerPid;
843
+ _this._fd = _this._agent.fd;
844
+ _this._pty = _this._agent.pty;
845
+ _this._socket.on("ready_datapipe", function() {
846
+ _this._socket.once("data", function() {
847
+ if (!_this._isReady) {
848
+ _this._isReady = true;
849
+ _this._deferreds.forEach(function(fn) {
850
+ fn.run();
851
+ });
852
+ _this._deferreds = [];
853
+ }
854
+ });
855
+ _this._socket.on("error", function(err) {
856
+ _this._close();
857
+ if (err.code) {
858
+ if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO"))
859
+ return;
860
+ }
861
+ if (_this.listeners("error").length < 2) {
862
+ throw err;
863
+ }
864
+ });
865
+ _this._socket.on("close", function() {
866
+ _this.emit("exit", _this._agent.exitCode);
867
+ _this._close();
868
+ });
869
+ });
870
+ _this._file = file;
871
+ _this._name = name;
872
+ _this._readable = true;
873
+ _this._writable = true;
874
+ _this._forwardEvents();
875
+ return _this;
876
+ }
877
+ WindowsTerminal2.prototype._write = function(data) {
878
+ this._defer(this._doWrite, data);
879
+ };
880
+ WindowsTerminal2.prototype._doWrite = function(data) {
881
+ this._agent.inSocket.write(data);
882
+ };
883
+ WindowsTerminal2.open = function(options) {
884
+ throw new Error("open() not supported on windows, use Fork() instead.");
885
+ };
886
+ WindowsTerminal2.prototype.resize = function(cols, rows) {
887
+ var _this = this;
888
+ if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
889
+ throw new Error("resizing must be done using positive cols and rows");
890
+ }
891
+ this._deferNoArgs(function() {
892
+ _this._agent.resize(cols, rows);
893
+ _this._cols = cols;
894
+ _this._rows = rows;
895
+ });
896
+ };
897
+ WindowsTerminal2.prototype.clear = function() {
898
+ var _this = this;
899
+ this._deferNoArgs(function() {
900
+ _this._agent.clear();
901
+ });
902
+ };
903
+ WindowsTerminal2.prototype.destroy = function() {
904
+ var _this = this;
905
+ this._deferNoArgs(function() {
906
+ _this.kill();
907
+ });
908
+ };
909
+ WindowsTerminal2.prototype.kill = function(signal) {
910
+ var _this = this;
911
+ this._deferNoArgs(function() {
912
+ if (signal) {
913
+ throw new Error("Signals not supported on windows.");
914
+ }
915
+ _this._close();
916
+ _this._agent.kill();
917
+ });
918
+ };
919
+ WindowsTerminal2.prototype._deferNoArgs = function(deferredFn) {
920
+ var _this = this;
921
+ if (this._isReady) {
922
+ deferredFn.call(this);
923
+ return;
924
+ }
925
+ this._deferreds.push({
926
+ run: function() {
927
+ return deferredFn.call(_this);
928
+ }
929
+ });
930
+ };
931
+ WindowsTerminal2.prototype._defer = function(deferredFn, arg) {
932
+ var _this = this;
933
+ if (this._isReady) {
934
+ deferredFn.call(this, arg);
935
+ return;
936
+ }
937
+ this._deferreds.push({
938
+ run: function() {
939
+ return deferredFn.call(_this, arg);
940
+ }
941
+ });
942
+ };
943
+ Object.defineProperty(WindowsTerminal2.prototype, "process", {
944
+ get: function() {
945
+ return this._name;
946
+ },
947
+ enumerable: false,
948
+ configurable: true
949
+ });
950
+ Object.defineProperty(WindowsTerminal2.prototype, "master", {
951
+ get: function() {
952
+ throw new Error("master is not supported on Windows");
953
+ },
954
+ enumerable: false,
955
+ configurable: true
956
+ });
957
+ Object.defineProperty(WindowsTerminal2.prototype, "slave", {
958
+ get: function() {
959
+ throw new Error("slave is not supported on Windows");
960
+ },
961
+ enumerable: false,
962
+ configurable: true
963
+ });
964
+ return WindowsTerminal2;
965
+ })(terminal_1.Terminal)
966
+ );
967
+ exports.WindowsTerminal = WindowsTerminal;
968
+ }
969
+ });
970
+
971
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js
972
+ var require_unixTerminal = __commonJS({
973
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js"(exports) {
974
+ "use strict";
975
+ var __extends = exports && exports.__extends || /* @__PURE__ */ (function() {
976
+ var extendStatics = function(d, b) {
977
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
978
+ d2.__proto__ = b2;
979
+ } || function(d2, b2) {
980
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
981
+ };
982
+ return extendStatics(d, b);
983
+ };
984
+ return function(d, b) {
985
+ extendStatics(d, b);
986
+ function __() {
987
+ this.constructor = d;
988
+ }
989
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
990
+ };
991
+ })();
992
+ Object.defineProperty(exports, "__esModule", { value: true });
993
+ exports.UnixTerminal = void 0;
994
+ var fs = __require("fs");
995
+ var path5 = __require("path");
996
+ var tty = __require("tty");
997
+ var terminal_1 = require_terminal();
998
+ var utils_1 = require_utils();
999
+ var native = utils_1.loadNativeModule("pty");
1000
+ var pty = native.module;
1001
+ var helperPath = native.dir + "/spawn-helper";
1002
+ helperPath = path5.resolve(__dirname, helperPath);
1003
+ helperPath = helperPath.replace("app.asar", "app.asar.unpacked");
1004
+ helperPath = helperPath.replace("node_modules.asar", "node_modules.asar.unpacked");
1005
+ var DEFAULT_FILE = "sh";
1006
+ var DEFAULT_NAME = "xterm";
1007
+ var DESTROY_SOCKET_TIMEOUT_MS = 200;
1008
+ var UnixTerminal = (
1009
+ /** @class */
1010
+ (function(_super) {
1011
+ __extends(UnixTerminal2, _super);
1012
+ function UnixTerminal2(file, args, opt) {
1013
+ var _a, _b;
1014
+ var _this = _super.call(this, opt) || this;
1015
+ _this._boundClose = false;
1016
+ _this._emittedClose = false;
1017
+ if (typeof args === "string") {
1018
+ throw new Error("args as a string is not supported on unix.");
1019
+ }
1020
+ args = args || [];
1021
+ file = file || DEFAULT_FILE;
1022
+ opt = opt || {};
1023
+ opt.env = opt.env || process.env;
1024
+ _this._cols = opt.cols || terminal_1.DEFAULT_COLS;
1025
+ _this._rows = opt.rows || terminal_1.DEFAULT_ROWS;
1026
+ var uid = (_a = opt.uid) !== null && _a !== void 0 ? _a : -1;
1027
+ var gid = (_b = opt.gid) !== null && _b !== void 0 ? _b : -1;
1028
+ var env = utils_1.assign({}, opt.env);
1029
+ if (opt.env === process.env) {
1030
+ _this._sanitizeEnv(env);
1031
+ }
1032
+ var cwd = opt.cwd || process.cwd();
1033
+ env.PWD = cwd;
1034
+ var name = opt.name || env.TERM || DEFAULT_NAME;
1035
+ env.TERM = name;
1036
+ var parsedEnv = _this._parseEnv(env);
1037
+ var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
1038
+ var onexit = function(code, signal) {
1039
+ if (!_this._emittedClose) {
1040
+ if (_this._boundClose) {
1041
+ return;
1042
+ }
1043
+ _this._boundClose = true;
1044
+ var timeout_1 = setTimeout(function() {
1045
+ timeout_1 = null;
1046
+ _this._socket.destroy();
1047
+ }, DESTROY_SOCKET_TIMEOUT_MS);
1048
+ _this.once("close", function() {
1049
+ if (timeout_1 !== null) {
1050
+ clearTimeout(timeout_1);
1051
+ }
1052
+ _this.emit("exit", code, signal);
1053
+ });
1054
+ return;
1055
+ }
1056
+ _this.emit("exit", code, signal);
1057
+ };
1058
+ var term = pty.fork(file, args, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, encoding === "utf8", helperPath, onexit);
1059
+ _this._socket = new tty.ReadStream(term.fd);
1060
+ if (encoding !== null) {
1061
+ _this._socket.setEncoding(encoding);
1062
+ }
1063
+ _this._writeStream = new CustomWriteStream(term.fd, encoding || void 0);
1064
+ _this._socket.on("error", function(err) {
1065
+ if (err.code) {
1066
+ if (~err.code.indexOf("EAGAIN")) {
1067
+ return;
1068
+ }
1069
+ }
1070
+ _this._close();
1071
+ if (!_this._emittedClose) {
1072
+ _this._emittedClose = true;
1073
+ _this.emit("close");
1074
+ }
1075
+ if (err.code) {
1076
+ if (~err.code.indexOf("errno 5") || ~err.code.indexOf("EIO")) {
1077
+ return;
1078
+ }
1079
+ }
1080
+ if (_this.listeners("error").length < 2) {
1081
+ throw err;
1082
+ }
1083
+ });
1084
+ _this._pid = term.pid;
1085
+ _this._fd = term.fd;
1086
+ _this._pty = term.pty;
1087
+ _this._file = file;
1088
+ _this._name = name;
1089
+ _this._readable = true;
1090
+ _this._writable = true;
1091
+ _this._socket.on("close", function() {
1092
+ if (_this._emittedClose) {
1093
+ return;
1094
+ }
1095
+ _this._emittedClose = true;
1096
+ _this._close();
1097
+ _this.emit("close");
1098
+ });
1099
+ _this._forwardEvents();
1100
+ return _this;
1101
+ }
1102
+ Object.defineProperty(UnixTerminal2.prototype, "master", {
1103
+ get: function() {
1104
+ return this._master;
1105
+ },
1106
+ enumerable: false,
1107
+ configurable: true
1108
+ });
1109
+ Object.defineProperty(UnixTerminal2.prototype, "slave", {
1110
+ get: function() {
1111
+ return this._slave;
1112
+ },
1113
+ enumerable: false,
1114
+ configurable: true
1115
+ });
1116
+ UnixTerminal2.prototype._write = function(data) {
1117
+ this._writeStream.write(data);
1118
+ };
1119
+ Object.defineProperty(UnixTerminal2.prototype, "fd", {
1120
+ /* Accessors */
1121
+ get: function() {
1122
+ return this._fd;
1123
+ },
1124
+ enumerable: false,
1125
+ configurable: true
1126
+ });
1127
+ Object.defineProperty(UnixTerminal2.prototype, "ptsName", {
1128
+ get: function() {
1129
+ return this._pty;
1130
+ },
1131
+ enumerable: false,
1132
+ configurable: true
1133
+ });
1134
+ UnixTerminal2.open = function(opt) {
1135
+ var self = Object.create(UnixTerminal2.prototype);
1136
+ opt = opt || {};
1137
+ if (arguments.length > 1) {
1138
+ opt = {
1139
+ cols: arguments[1],
1140
+ rows: arguments[2]
1141
+ };
1142
+ }
1143
+ var cols = opt.cols || terminal_1.DEFAULT_COLS;
1144
+ var rows = opt.rows || terminal_1.DEFAULT_ROWS;
1145
+ var encoding = opt.encoding === void 0 ? "utf8" : opt.encoding;
1146
+ var term = pty.open(cols, rows);
1147
+ self._master = new tty.ReadStream(term.master);
1148
+ if (encoding !== null) {
1149
+ self._master.setEncoding(encoding);
1150
+ }
1151
+ self._master.resume();
1152
+ self._slave = new tty.ReadStream(term.slave);
1153
+ if (encoding !== null) {
1154
+ self._slave.setEncoding(encoding);
1155
+ }
1156
+ self._slave.resume();
1157
+ self._socket = self._master;
1158
+ self._pid = -1;
1159
+ self._fd = term.master;
1160
+ self._pty = term.pty;
1161
+ self._file = process.argv[0] || "node";
1162
+ self._name = process.env.TERM || "";
1163
+ self._readable = true;
1164
+ self._writable = true;
1165
+ self._socket.on("error", function(err) {
1166
+ self._close();
1167
+ if (self.listeners("error").length < 2) {
1168
+ throw err;
1169
+ }
1170
+ });
1171
+ self._socket.on("close", function() {
1172
+ self._close();
1173
+ });
1174
+ return self;
1175
+ };
1176
+ UnixTerminal2.prototype.destroy = function() {
1177
+ var _this = this;
1178
+ this._close();
1179
+ this._socket.once("close", function() {
1180
+ _this.kill("SIGHUP");
1181
+ });
1182
+ this._socket.destroy();
1183
+ this._writeStream.dispose();
1184
+ };
1185
+ UnixTerminal2.prototype.kill = function(signal) {
1186
+ try {
1187
+ process.kill(this.pid, signal || "SIGHUP");
1188
+ } catch (e) {
1189
+ }
1190
+ };
1191
+ Object.defineProperty(UnixTerminal2.prototype, "process", {
1192
+ /**
1193
+ * Gets the name of the process.
1194
+ */
1195
+ get: function() {
1196
+ if (process.platform === "darwin") {
1197
+ var title = pty.process(this._fd);
1198
+ return title !== "kernel_task" ? title : this._file;
1199
+ }
1200
+ return pty.process(this._fd, this._pty) || this._file;
1201
+ },
1202
+ enumerable: false,
1203
+ configurable: true
1204
+ });
1205
+ UnixTerminal2.prototype.resize = function(cols, rows) {
1206
+ if (cols <= 0 || rows <= 0 || isNaN(cols) || isNaN(rows) || cols === Infinity || rows === Infinity) {
1207
+ throw new Error("resizing must be done using positive cols and rows");
1208
+ }
1209
+ pty.resize(this._fd, cols, rows);
1210
+ this._cols = cols;
1211
+ this._rows = rows;
1212
+ };
1213
+ UnixTerminal2.prototype.clear = function() {
1214
+ };
1215
+ UnixTerminal2.prototype._sanitizeEnv = function(env) {
1216
+ delete env["TMUX"];
1217
+ delete env["TMUX_PANE"];
1218
+ delete env["STY"];
1219
+ delete env["WINDOW"];
1220
+ delete env["WINDOWID"];
1221
+ delete env["TERMCAP"];
1222
+ delete env["COLUMNS"];
1223
+ delete env["LINES"];
1224
+ };
1225
+ return UnixTerminal2;
1226
+ })(terminal_1.Terminal)
1227
+ );
1228
+ exports.UnixTerminal = UnixTerminal;
1229
+ var CustomWriteStream = (
1230
+ /** @class */
1231
+ (function() {
1232
+ function CustomWriteStream2(_fd, _encoding) {
1233
+ this._fd = _fd;
1234
+ this._encoding = _encoding;
1235
+ this._writeQueue = [];
1236
+ }
1237
+ CustomWriteStream2.prototype.dispose = function() {
1238
+ clearImmediate(this._writeImmediate);
1239
+ this._writeImmediate = void 0;
1240
+ };
1241
+ CustomWriteStream2.prototype.write = function(data) {
1242
+ var buffer = typeof data === "string" ? Buffer.from(data, this._encoding) : Buffer.from(data);
1243
+ if (buffer.byteLength !== 0) {
1244
+ this._writeQueue.push({ buffer, offset: 0 });
1245
+ if (this._writeQueue.length === 1) {
1246
+ this._processWriteQueue();
1247
+ }
1248
+ }
1249
+ };
1250
+ CustomWriteStream2.prototype._processWriteQueue = function() {
1251
+ var _this = this;
1252
+ this._writeImmediate = void 0;
1253
+ if (this._writeQueue.length === 0) {
1254
+ return;
1255
+ }
1256
+ var task = this._writeQueue[0];
1257
+ fs.write(this._fd, task.buffer, task.offset, function(err, written) {
1258
+ if (err) {
1259
+ if ("code" in err && err.code === "EAGAIN") {
1260
+ _this._writeImmediate = setImmediate(function() {
1261
+ return _this._processWriteQueue();
1262
+ });
1263
+ } else {
1264
+ _this._writeQueue.length = 0;
1265
+ console.error("Unhandled pty write error", err);
1266
+ }
1267
+ return;
1268
+ }
1269
+ task.offset += written;
1270
+ if (task.offset >= task.buffer.byteLength) {
1271
+ _this._writeQueue.shift();
1272
+ }
1273
+ _this._processWriteQueue();
1274
+ });
1275
+ };
1276
+ return CustomWriteStream2;
1277
+ })()
1278
+ );
1279
+ }
1280
+ });
1281
+
1282
+ // ../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js
1283
+ var require_lib = __commonJS({
1284
+ "../../node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js"(exports) {
1285
+ "use strict";
1286
+ Object.defineProperty(exports, "__esModule", { value: true });
1287
+ exports.native = exports.open = exports.createTerminal = exports.fork = exports.spawn = void 0;
1288
+ var utils_1 = require_utils();
1289
+ var terminalCtor;
1290
+ if (process.platform === "win32") {
1291
+ terminalCtor = require_windowsTerminal().WindowsTerminal;
1292
+ } else {
1293
+ terminalCtor = require_unixTerminal().UnixTerminal;
1294
+ }
1295
+ function spawn2(file, args, opt) {
1296
+ return new terminalCtor(file, args, opt);
1297
+ }
1298
+ exports.spawn = spawn2;
1299
+ function fork(file, args, opt) {
1300
+ return new terminalCtor(file, args, opt);
1301
+ }
1302
+ exports.fork = fork;
1303
+ function createTerminal(file, args, opt) {
1304
+ return new terminalCtor(file, args, opt);
1305
+ }
1306
+ exports.createTerminal = createTerminal;
1307
+ function open(options) {
1308
+ return terminalCtor.open(options);
1309
+ }
1310
+ exports.open = open;
1311
+ exports.native = process.platform !== "win32" ? utils_1.loadNativeModule("pty").module : null;
1312
+ }
1313
+ });
1314
+
1315
+ // src/actions/clamp/clampAudit.ts
1316
+ import { writeAuditEntry } from "@xylabs/aries-audit-core";
1317
+ import { CLAMP_AUDIT_SCHEMA } from "@xylabs/aries-clamp-core";
1318
+ function logClampPermission(options) {
1319
+ writeAuditEntry({
1320
+ ai: { product: "clamp", provider: "aries" },
1321
+ client: { name: "@xylabs/aries", version: "0.1.0" },
1322
+ cwd: process.cwd(),
1323
+ data: {
1324
+ args: options.args,
1325
+ command: options.command,
1326
+ decision: options.decision,
1327
+ policy: options.policy.name
1328
+ },
1329
+ event: "ClampPermission",
1330
+ schema: CLAMP_AUDIT_SCHEMA,
1331
+ sessionId: options.sessionId,
1332
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1333
+ });
1334
+ }
1335
+ function logClampStart(options) {
1336
+ writeAuditEntry({
1337
+ ai: { product: "clamp", provider: "aries" },
1338
+ client: { name: "@xylabs/aries", version: "0.1.0" },
1339
+ cwd: process.cwd(),
1340
+ data: {
1341
+ command: options.command,
1342
+ policy: options.policy.name
1343
+ },
1344
+ event: "ClampStart",
1345
+ schema: CLAMP_AUDIT_SCHEMA,
1346
+ sessionId: options.sessionId,
1347
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1348
+ });
1349
+ }
1350
+ function logClampStop(options) {
1351
+ writeAuditEntry({
1352
+ ai: { product: "clamp", provider: "aries" },
1353
+ client: { name: "@xylabs/aries", version: "0.1.0" },
1354
+ cwd: process.cwd(),
1355
+ data: { exitCode: options.exitCode },
1356
+ event: "ClampStop",
1357
+ schema: CLAMP_AUDIT_SCHEMA,
1358
+ sessionId: options.sessionId,
1359
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1360
+ });
1361
+ }
1362
+
1363
+ // src/actions/clamp/ipcServer.ts
1364
+ import {
1365
+ createServer
1366
+ } from "net";
1367
+ function createIpcServer(options) {
1368
+ const { socketPath, onPermissionRequest } = options;
1369
+ const server = createServer((socket) => {
1370
+ let data = "";
1371
+ socket.on("data", (chunk) => {
1372
+ data += chunk.toString();
1373
+ const newlineIdx = data.indexOf("\n");
1374
+ if (newlineIdx === -1) return;
1375
+ const line = data.slice(0, newlineIdx);
1376
+ data = data.slice(newlineIdx + 1);
1377
+ let request;
1378
+ try {
1379
+ request = JSON.parse(line);
1380
+ } catch {
1381
+ socket.end(JSON.stringify({
1382
+ allowed: false,
1383
+ reason: "Invalid request",
1384
+ requestId: "unknown",
1385
+ type: "permission-response"
1386
+ }) + "\n");
1387
+ return;
1388
+ }
1389
+ onPermissionRequest(request).then((response) => {
1390
+ socket.end(JSON.stringify(response) + "\n");
1391
+ }).catch(() => {
1392
+ const errorResponse = {
1393
+ allowed: false,
1394
+ reason: "Internal error",
1395
+ requestId: request.requestId,
1396
+ type: "permission-response"
1397
+ };
1398
+ socket.end(JSON.stringify(errorResponse) + "\n");
1399
+ });
1400
+ });
1401
+ socket.on("error", () => {
1402
+ });
1403
+ });
1404
+ const listening = new Promise((resolve, reject) => {
1405
+ server.listen(socketPath, () => resolve());
1406
+ server.on("error", reject);
1407
+ });
1408
+ return {
1409
+ close: () => server.close(),
1410
+ listening,
1411
+ server
1412
+ };
1413
+ }
1414
+
1415
+ // src/actions/clamp/promptUser.ts
1416
+ import {
1417
+ closeSync,
1418
+ openSync,
1419
+ writeSync
1420
+ } from "fs";
1421
+ import { createInterface } from "readline";
1422
+ import { ReadStream } from "tty";
1423
+ function parseAnswer(answer) {
1424
+ const trimmed = answer.trim().toLowerCase();
1425
+ if (trimmed === "y" || trimmed === "yes") return "allow-once";
1426
+ if (trimmed === "a" || trimmed === "always") return "allow-always";
1427
+ return "deny";
1428
+ }
1429
+ function promptViaTty(fullCommand) {
1430
+ let readFd;
1431
+ let writeFd;
1432
+ try {
1433
+ readFd = openSync("/dev/tty", "r");
1434
+ writeFd = openSync("/dev/tty", "w");
1435
+ } catch {
1436
+ return Promise.resolve("deny");
1437
+ }
1438
+ const ttyIn = new ReadStream(readFd);
1439
+ writeSync(writeFd, `
1440
+ [clamp] "${fullCommand}" \u2014 Allow? [y/N/a(lways)] `);
1441
+ const rl = createInterface({ input: ttyIn, terminal: false });
1442
+ return new Promise((resolve) => {
1443
+ const cleanup = () => {
1444
+ rl.close();
1445
+ ttyIn.destroy();
1446
+ try {
1447
+ closeSync(writeFd);
1448
+ } catch {
1449
+ }
1450
+ };
1451
+ rl.once("line", (answer) => {
1452
+ cleanup();
1453
+ resolve(parseAnswer(answer));
1454
+ });
1455
+ rl.once("close", () => resolve("deny"));
1456
+ ttyIn.on("error", () => {
1457
+ cleanup();
1458
+ resolve("deny");
1459
+ });
1460
+ });
1461
+ }
1462
+ function promptViaRenderer(fullCommand, renderer) {
1463
+ const promptText = `[clamp] "${fullCommand}" \u2014 Allow? [y/N/a(lways)] `;
1464
+ renderer.setStatusLine(promptText);
1465
+ let readFd;
1466
+ try {
1467
+ readFd = openSync("/dev/tty", "r");
1468
+ } catch {
1469
+ renderer.setStatusLine("[clamp] No TTY \u2014 denied");
1470
+ return Promise.resolve("deny");
1471
+ }
1472
+ const ttyIn = new ReadStream(readFd);
1473
+ const rl = createInterface({ input: ttyIn, terminal: false });
1474
+ return new Promise((resolve) => {
1475
+ const cleanup = () => {
1476
+ rl.close();
1477
+ ttyIn.destroy();
1478
+ renderer.setStatusLine("[clamp] Ready");
1479
+ };
1480
+ rl.once("line", (answer) => {
1481
+ const decision = parseAnswer(answer);
1482
+ cleanup();
1483
+ resolve(decision);
1484
+ });
1485
+ rl.once("close", () => {
1486
+ cleanup();
1487
+ resolve("deny");
1488
+ });
1489
+ ttyIn.on("error", () => {
1490
+ cleanup();
1491
+ resolve("deny");
1492
+ });
1493
+ });
1494
+ }
1495
+ async function promptUser(command, args, renderer) {
1496
+ const fullCommand = [command, ...args].join(" ");
1497
+ if (renderer) {
1498
+ return promptViaRenderer(fullCommand, renderer);
1499
+ }
1500
+ return promptViaTty(fullCommand);
1501
+ }
1502
+
1503
+ // src/actions/clamp/runClamped.ts
1504
+ import { randomUUID } from "crypto";
1505
+ import { rmSync as rmSync3, unlinkSync } from "fs";
1506
+ import { tmpdir as tmpdir4 } from "os";
1507
+ import path4 from "path";
1508
+ import {
1509
+ CLAMP_IPC_ENV,
1510
+ CLAMP_ORIGINAL_PATH_ENV,
1511
+ CLAMP_SESSION_ENV,
1512
+ loadPolicy,
1513
+ matchProcess
1514
+ } from "@xylabs/aries-clamp-core";
1515
+ import chalk2 from "chalk";
1516
+
1517
+ // src/actions/clamp/sandboxExec.ts
1518
+ import { spawn } from "child_process";
1519
+ import {
1520
+ mkdtempSync,
1521
+ rmSync,
1522
+ writeFileSync
1523
+ } from "fs";
1524
+ import { tmpdir } from "os";
1525
+ import path from "path";
1526
+ import { detectPlatform, generateMacOSProfile } from "@xylabs/aries-clamp-core";
1527
+ import chalk from "chalk";
1528
+
1529
+ // src/actions/clamp/terminalRenderer.ts
1530
+ import pkg from "@xterm/headless";
1531
+ var { Terminal } = pkg;
1532
+ var STATUS_BAR_HEIGHT = 2;
1533
+ var ESC = "\x1B[";
1534
+ var moveTo = (row, col) => `${ESC}${row};${col}H`;
1535
+ var resetStyle = `${ESC}0m`;
1536
+ var hideCursor = `${ESC}?25l`;
1537
+ var showCursor = `${ESC}?25h`;
1538
+ var clearScreen = `${ESC}2J`;
1539
+ var setBg = (r, g, b) => `${ESC}48;2;${r};${g};${b}m`;
1540
+ var setFg = (r, g, b) => `${ESC}38;2;${r};${g};${b}m`;
1541
+ var fgPalette = (n) => `${ESC}38;5;${n}m`;
1542
+ var bgPalette = (n) => `${ESC}48;5;${n}m`;
1543
+ var bold = `${ESC}1m`;
1544
+ var dim = `${ESC}2m`;
1545
+ var italic = `${ESC}3m`;
1546
+ var underline = `${ESC}4m`;
1547
+ var inverse = `${ESC}7m`;
1548
+ var strikethrough = `${ESC}9m`;
1549
+ function getCellStyle(cell) {
1550
+ if (!cell) return {
1551
+ attrs: "",
1552
+ bg: "",
1553
+ fg: ""
1554
+ };
1555
+ let fg = "";
1556
+ let bg = "";
1557
+ let attrs = "";
1558
+ if (cell.isFgRGB()) {
1559
+ const color = cell.getFgColor();
1560
+ fg = setFg(color >> 16 & 255, color >> 8 & 255, color & 255);
1561
+ } else if (cell.getFgColorMode() !== 0) {
1562
+ fg = fgPalette(cell.getFgColor());
1563
+ }
1564
+ if (cell.isBgRGB()) {
1565
+ const color = cell.getBgColor();
1566
+ bg = setBg(color >> 16 & 255, color >> 8 & 255, color & 255);
1567
+ } else if (cell.getBgColorMode() !== 0) {
1568
+ bg = bgPalette(cell.getBgColor());
1569
+ }
1570
+ if (cell.isBold()) attrs += bold;
1571
+ if (cell.isDim()) attrs += dim;
1572
+ if (cell.isItalic()) attrs += italic;
1573
+ if (cell.isUnderline()) attrs += underline;
1574
+ if (cell.isInverse()) attrs += inverse;
1575
+ if (cell.isStrikethrough()) attrs += strikethrough;
1576
+ return {
1577
+ attrs,
1578
+ bg,
1579
+ fg
1580
+ };
1581
+ }
1582
+ function createTerminalRenderer() {
1583
+ const realCols = process.stdout.columns ?? 80;
1584
+ const realRows = process.stdout.rows ?? 24;
1585
+ const innerRows = realRows - STATUS_BAR_HEIGHT;
1586
+ const terminal = new Terminal({
1587
+ cols: realCols,
1588
+ rows: innerRows
1589
+ });
1590
+ let statusLine = "";
1591
+ let renderScheduled = false;
1592
+ function renderBuffer() {
1593
+ const buf = terminal.buffer.active;
1594
+ const cols = terminal.cols;
1595
+ const rows = terminal.rows;
1596
+ const output = [hideCursor];
1597
+ for (let y = 0; y < rows; y++) {
1598
+ const line = buf.getLine(y);
1599
+ output.push(moveTo(y + 1, 1));
1600
+ if (!line) {
1601
+ output.push(resetStyle + " ".repeat(cols));
1602
+ continue;
1603
+ }
1604
+ let lineStr = "";
1605
+ let lastStyle = "";
1606
+ for (let x = 0; x < cols; x++) {
1607
+ const cell = line.getCell(x);
1608
+ if (!cell || cell.getWidth() === 0) continue;
1609
+ const style = getCellStyle(cell);
1610
+ const styleStr = resetStyle + style.fg + style.bg + style.attrs;
1611
+ if (styleStr !== lastStyle) {
1612
+ lineStr += styleStr;
1613
+ lastStyle = styleStr;
1614
+ }
1615
+ const ch = cell.getChars();
1616
+ lineStr += ch || " ";
1617
+ }
1618
+ output.push(lineStr + resetStyle);
1619
+ }
1620
+ const statusRow = realRows - 1;
1621
+ output.push(
1622
+ moveTo(statusRow, 1),
1623
+ resetStyle + dim + "\u2500".repeat(realCols) + resetStyle,
1624
+ moveTo(statusRow + 1, 1),
1625
+ resetStyle,
1626
+ statusLine.padEnd(realCols).slice(0, realCols),
1627
+ resetStyle
1628
+ );
1629
+ const cursorY = buf.cursorY + 1;
1630
+ const cursorX = buf.cursorX + 1;
1631
+ output.push(moveTo(cursorY, cursorX), showCursor);
1632
+ process.stdout.write(output.join(""));
1633
+ }
1634
+ function scheduleRender() {
1635
+ if (renderScheduled) return;
1636
+ renderScheduled = true;
1637
+ setImmediate(() => {
1638
+ renderScheduled = false;
1639
+ renderBuffer();
1640
+ });
1641
+ }
1642
+ function handleResize() {
1643
+ const newCols = process.stdout.columns ?? 80;
1644
+ const newRows = process.stdout.rows ?? 24;
1645
+ const newInnerRows = newRows - STATUS_BAR_HEIGHT;
1646
+ terminal.resize(newCols, newInnerRows);
1647
+ process.stdout.write(clearScreen);
1648
+ scheduleRender();
1649
+ }
1650
+ process.stdout.on("resize", handleResize);
1651
+ process.stdout.write(clearScreen + moveTo(1, 1));
1652
+ return {
1653
+ destroy: () => {
1654
+ process.stdout.removeListener("resize", handleResize);
1655
+ process.stdout.write(clearScreen + moveTo(1, 1) + showCursor + resetStyle);
1656
+ terminal.dispose();
1657
+ },
1658
+ render: scheduleRender,
1659
+ setStatusLine: (line) => {
1660
+ statusLine = line;
1661
+ scheduleRender();
1662
+ },
1663
+ terminal,
1664
+ write: (data) => {
1665
+ terminal.write(data);
1666
+ scheduleRender();
1667
+ }
1668
+ };
1669
+ }
1670
+
1671
+ // src/actions/clamp/sandboxExec.ts
1672
+ function createMacOSSandbox(policy) {
1673
+ const profileContent = generateMacOSProfile(policy, process.cwd());
1674
+ const profileDir = mkdtempSync(path.join(tmpdir(), "aries-clamp-sb-"));
1675
+ const profilePath = path.join(profileDir, "sandbox.sb");
1676
+ writeFileSync(profilePath, profileContent, "utf8");
1677
+ console.error(chalk.gray("[clamp] macOS sandbox enabled"));
1678
+ return {
1679
+ args: ["-f", profilePath],
1680
+ cleanup: () => {
1681
+ try {
1682
+ rmSync(profileDir, { force: true, recursive: true });
1683
+ } catch {
1684
+ }
1685
+ }
1686
+ };
1687
+ }
1688
+ function resolveSpawnCommand(command, args, policy) {
1689
+ const platform = detectPlatform();
1690
+ const cleanupFns = [];
1691
+ if (platform === "darwin" && policy.filesystem) {
1692
+ const sandbox = createMacOSSandbox(policy);
1693
+ cleanupFns.push(sandbox.cleanup);
1694
+ return {
1695
+ cleanupFns,
1696
+ spawnArgs: [...sandbox.args, command, ...args],
1697
+ spawnCommand: "sandbox-exec"
1698
+ };
1699
+ }
1700
+ if (platform === "linux" && policy.filesystem) {
1701
+ console.error(chalk.yellow("[clamp] Linux filesystem sandbox: Landlock integration pending"));
1702
+ } else if (policy.filesystem) {
1703
+ console.error(chalk.yellow(`[clamp] OS filesystem sandbox not available on ${platform}`));
1704
+ }
1705
+ return {
1706
+ cleanupFns,
1707
+ spawnArgs: args,
1708
+ spawnCommand: command
1709
+ };
1710
+ }
1711
+ function cleanEnvRecord(env) {
1712
+ const clean = {};
1713
+ for (const [k, v] of Object.entries(env)) {
1714
+ if (v !== void 0) clean[k] = v;
1715
+ }
1716
+ return clean;
1717
+ }
1718
+ function spawnWithRenderedPty(spawnCommand, spawnArgs, env) {
1719
+ try {
1720
+ const pty = require_lib();
1721
+ const renderer = createTerminalRenderer();
1722
+ const innerRows = (process.stdout.rows ?? 24) - 2;
1723
+ const ptyProcess = pty.spawn(spawnCommand, spawnArgs, {
1724
+ cols: process.stdout.columns ?? 80,
1725
+ cwd: process.cwd(),
1726
+ env,
1727
+ name: process.env.TERM ?? "xterm-256color",
1728
+ rows: innerRows
1729
+ });
1730
+ let paused = false;
1731
+ ptyProcess.onData((data) => {
1732
+ if (!paused) {
1733
+ renderer.write(data);
1734
+ }
1735
+ });
1736
+ if (process.stdin.isTTY) process.stdin.setRawMode(true);
1737
+ process.stdin.resume();
1738
+ const onStdin = (data) => {
1739
+ ptyProcess.write(data.toString());
1740
+ };
1741
+ process.stdin.on("data", onStdin);
1742
+ const onResize = () => {
1743
+ const newInnerRows = (process.stdout.rows ?? 24) - 2;
1744
+ ptyProcess.resize(process.stdout.columns ?? 80, newInnerRows);
1745
+ };
1746
+ process.stdout.on("resize", onResize);
1747
+ const exitCode = new Promise((resolve) => {
1748
+ ptyProcess.onExit(({ exitCode: code }) => {
1749
+ process.stdin.removeListener("data", onStdin);
1750
+ process.stdout.removeListener("resize", onResize);
1751
+ if (process.stdin.isTTY) process.stdin.setRawMode(false);
1752
+ process.stdin.pause();
1753
+ renderer.destroy();
1754
+ resolve(code);
1755
+ });
1756
+ });
1757
+ return {
1758
+ cleanup: () => {
1759
+ },
1760
+ exitCode,
1761
+ ok: true,
1762
+ pause: () => {
1763
+ paused = true;
1764
+ },
1765
+ renderer,
1766
+ resume: () => {
1767
+ paused = false;
1768
+ renderer.render();
1769
+ }
1770
+ };
1771
+ } catch {
1772
+ return { ok: false };
1773
+ }
1774
+ }
1775
+ function spawnFallback(spawnCommand, spawnArgs, env) {
1776
+ console.error(chalk.yellow("[clamp] PTY unavailable, falling back to basic stdio passthrough"));
1777
+ const child = spawn(spawnCommand, spawnArgs, { env, stdio: "inherit" });
1778
+ const exitCode = new Promise((resolve) => {
1779
+ child.on("close", (code) => resolve(code));
1780
+ child.on("error", () => resolve(1));
1781
+ });
1782
+ const noop = () => {
1783
+ };
1784
+ return {
1785
+ cleanup: noop,
1786
+ exitCode,
1787
+ pause: noop,
1788
+ renderer: void 0,
1789
+ resume: noop
1790
+ };
1791
+ }
1792
+ function spawnSandboxed(options) {
1793
+ const { env, policy } = options;
1794
+ const {
1795
+ spawnCommand,
1796
+ spawnArgs,
1797
+ cleanupFns
1798
+ } = resolveSpawnCommand(options.command, options.args, policy);
1799
+ const cleanEnv = cleanEnvRecord(env);
1800
+ const ptyResult = spawnWithRenderedPty(spawnCommand, spawnArgs, cleanEnv);
1801
+ const result = ptyResult.ok ? ptyResult : spawnFallback(spawnCommand, spawnArgs, env);
1802
+ const originalCleanup = result.cleanup;
1803
+ return {
1804
+ ...result,
1805
+ cleanup: () => {
1806
+ originalCleanup();
1807
+ for (const fn of cleanupFns) fn();
1808
+ }
1809
+ };
1810
+ }
1811
+
1812
+ // src/actions/clamp/shellEnvSetup.ts
1813
+ import {
1814
+ mkdtempSync as mkdtempSync2,
1815
+ rmSync as rmSync2,
1816
+ writeFileSync as writeFileSync2
1817
+ } from "fs";
1818
+ import { homedir, tmpdir as tmpdir2 } from "os";
1819
+ import path2 from "path";
1820
+ function createShellEnvOverrides(shimDir) {
1821
+ const tmpDir = mkdtempSync2(path2.join(tmpdir2(), "aries-clamp-env-"));
1822
+ const home = homedir();
1823
+ const zshenv = [
1824
+ "# Aries Clamp: source real .zshenv then re-prepend shim dir",
1825
+ `[ -f "${home}/.zshenv" ] && ZDOTDIR="${home}" source "${home}/.zshenv"`,
1826
+ `export PATH="${shimDir}:\${PATH}"`
1827
+ ].join("\n") + "\n";
1828
+ writeFileSync2(path2.join(tmpDir, ".zshenv"), zshenv, "utf8");
1829
+ const zshrc = [
1830
+ "# Aries Clamp: source real .zshrc then re-prepend shim dir",
1831
+ `[ -f "${home}/.zshrc" ] && ZDOTDIR="${home}" source "${home}/.zshrc"`,
1832
+ `export PATH="${shimDir}:\${PATH}"`
1833
+ ].join("\n") + "\n";
1834
+ writeFileSync2(path2.join(tmpDir, ".zshrc"), zshrc, "utf8");
1835
+ const zprofile = [
1836
+ "# Aries Clamp: source real .zprofile then re-prepend shim dir",
1837
+ `[ -f "${home}/.zprofile" ] && ZDOTDIR="${home}" source "${home}/.zprofile"`,
1838
+ `export PATH="${shimDir}:\${PATH}"`
1839
+ ].join("\n") + "\n";
1840
+ writeFileSync2(path2.join(tmpDir, ".zprofile"), zprofile, "utf8");
1841
+ const bashEnv = [
1842
+ "# Aries Clamp: prepend shim dir to PATH",
1843
+ `export PATH="${shimDir}:\${PATH}"`
1844
+ ].join("\n") + "\n";
1845
+ const bashEnvPath = path2.join(tmpDir, "bash_env.sh");
1846
+ writeFileSync2(bashEnvPath, bashEnv, "utf8");
1847
+ const bashrc = [
1848
+ "# Aries Clamp: source real .bashrc then re-prepend shim dir",
1849
+ `[ -f "${home}/.bashrc" ] && source "${home}/.bashrc"`,
1850
+ `export PATH="${shimDir}:\${PATH}"`
1851
+ ].join("\n") + "\n";
1852
+ writeFileSync2(path2.join(tmpDir, ".bashrc"), bashrc, "utf8");
1853
+ return {
1854
+ cleanup: () => {
1855
+ try {
1856
+ rmSync2(tmpDir, { force: true, recursive: true });
1857
+ } catch {
1858
+ }
1859
+ },
1860
+ env: {
1861
+ BASH_ENV: bashEnvPath,
1862
+ ENV: bashEnvPath,
1863
+ ZDOTDIR: tmpDir
1864
+ }
1865
+ };
1866
+ }
1867
+
1868
+ // src/actions/clamp/shimGenerator.ts
1869
+ import {
1870
+ chmodSync,
1871
+ existsSync,
1872
+ mkdtempSync as mkdtempSync3,
1873
+ writeFileSync as writeFileSync3
1874
+ } from "fs";
1875
+ import { createRequire } from "module";
1876
+ import { tmpdir as tmpdir3 } from "os";
1877
+ import path3 from "path";
1878
+ var DANGEROUS_COMMANDS = [
1879
+ "chmod",
1880
+ "chown",
1881
+ "curl",
1882
+ "docker",
1883
+ "kill",
1884
+ "killall",
1885
+ "mv",
1886
+ "pkill",
1887
+ "rm",
1888
+ "rmdir",
1889
+ "sudo",
1890
+ "wget"
1891
+ ];
1892
+ function getGatekeeperPath() {
1893
+ const require2 = createRequire(import.meta.url);
1894
+ try {
1895
+ const pluginPkg = require2.resolve("@xylabs/aries-clamp-plugin/package.json");
1896
+ return path3.join(path3.dirname(pluginPkg), "dist", "shim", "gatekeeper.mjs");
1897
+ } catch {
1898
+ const candidates = [
1899
+ path3.resolve("packages", "clamp-plugin", "dist", "shim", "gatekeeper.mjs"),
1900
+ path3.resolve("node_modules", "@xylabs", "aries-clamp-plugin", "dist", "shim", "gatekeeper.mjs")
1901
+ ];
1902
+ for (const candidate of candidates) {
1903
+ if (existsSync(candidate)) return candidate;
1904
+ }
1905
+ throw new Error("Could not find gatekeeper.mjs \u2014 is @xylabs/aries-clamp-plugin built?");
1906
+ }
1907
+ }
1908
+ async function generateShimDirectory(policy) {
1909
+ const shimDir = mkdtempSync3(path3.join(tmpdir3(), "aries-clamp-"));
1910
+ const gatekeeperPath = getGatekeeperPath();
1911
+ const nodePath = process.execPath;
1912
+ const commands = /* @__PURE__ */ new Set();
1913
+ const processRules = policy.process;
1914
+ if (processRules) {
1915
+ for (const cmd of processRules.allow ?? []) commands.add(cmd);
1916
+ for (const cmd of processRules.prompt ?? []) commands.add(cmd);
1917
+ for (const cmd of processRules.deny ?? []) commands.add(cmd);
1918
+ }
1919
+ for (const cmd of DANGEROUS_COMMANDS) {
1920
+ commands.add(cmd);
1921
+ }
1922
+ for (const cmd of commands) {
1923
+ const shimPath = path3.join(shimDir, cmd);
1924
+ const script = `#!/bin/sh
1925
+ exec "${nodePath}" "${gatekeeperPath}" "${cmd}" "$@"
1926
+ `;
1927
+ writeFileSync3(shimPath, script, "utf8");
1928
+ chmodSync(shimPath, 493);
1929
+ }
1930
+ return shimDir;
1931
+ }
1932
+
1933
+ // src/actions/clamp/runClamped.ts
1934
+ function printDryRun(command, args, policy, auditEnabled) {
1935
+ console.log(chalk2.cyan("\n[clamp] Dry run \u2014 would sandbox with:\n"));
1936
+ console.log(chalk2.white(` Command: ${command} ${args.join(" ")}`));
1937
+ console.log(chalk2.white(` Policy: ${policy.name}`));
1938
+ console.log(chalk2.white(` Default action: ${policy.defaultAction ?? "prompt"}`));
1939
+ console.log(chalk2.white(` Audit: ${auditEnabled ? "enabled" : "disabled"}`));
1940
+ if (policy.process) {
1941
+ console.log(chalk2.green(` Allowed: ${policy.process.allow?.join(", ") ?? "(none)"}`));
1942
+ console.log(chalk2.yellow(` Prompted: ${policy.process.prompt?.join(", ") ?? "(none)"}`));
1943
+ console.log(chalk2.red(` Denied: ${policy.process.deny?.join(", ") ?? "(none)"}`));
1944
+ }
1945
+ if (policy.filesystem) {
1946
+ console.log(chalk2.white(" Filesystem sandbox: enabled"));
1947
+ }
1948
+ console.log("");
1949
+ }
1950
+ async function resolveDecision(command, args, alwaysAllow, renderer) {
1951
+ const answer = await promptUser(command, args, renderer);
1952
+ if (answer === "allow-always") {
1953
+ alwaysAllow.add(command);
1954
+ return "prompted-allow";
1955
+ }
1956
+ return answer === "allow-once" ? "prompted-allow" : "prompted-deny";
1957
+ }
1958
+ function createPermissionHandler(policy, sessionId, auditEnabled, alwaysAllow, sandboxRef) {
1959
+ const defaultAction = policy.defaultAction ?? "prompt";
1960
+ return async (request) => {
1961
+ const {
1962
+ command: reqCommand,
1963
+ args: reqArgs,
1964
+ requestId
1965
+ } = request;
1966
+ if (alwaysAllow.has(reqCommand)) {
1967
+ if (auditEnabled) {
1968
+ logClampPermission({
1969
+ args: reqArgs,
1970
+ command: reqCommand,
1971
+ decision: "allowed",
1972
+ policy,
1973
+ sessionId
1974
+ });
1975
+ }
1976
+ return {
1977
+ allowed: true,
1978
+ requestId,
1979
+ type: "permission-response"
1980
+ };
1981
+ }
1982
+ const level = matchProcess(reqCommand, policy.process, defaultAction);
1983
+ if (level === "allow" || level === "deny") {
1984
+ const decision2 = level === "allow" ? "allowed" : "denied";
1985
+ if (auditEnabled) {
1986
+ logClampPermission({
1987
+ args: reqArgs,
1988
+ command: reqCommand,
1989
+ decision: decision2,
1990
+ policy,
1991
+ sessionId
1992
+ });
1993
+ }
1994
+ return {
1995
+ allowed: level === "allow",
1996
+ reason: level === "deny" ? `Policy "${policy.name}": deny` : void 0,
1997
+ requestId,
1998
+ type: "permission-response"
1999
+ };
2000
+ }
2001
+ sandboxRef.sandbox?.pause();
2002
+ const decision = await resolveDecision(reqCommand, reqArgs, alwaysAllow, sandboxRef.sandbox?.renderer);
2003
+ sandboxRef.sandbox?.resume();
2004
+ if (auditEnabled) {
2005
+ logClampPermission({
2006
+ args: reqArgs,
2007
+ command: reqCommand,
2008
+ decision,
2009
+ policy,
2010
+ sessionId
2011
+ });
2012
+ }
2013
+ const allowed = decision === "prompted-allow";
2014
+ return {
2015
+ allowed,
2016
+ reason: allowed ? void 0 : `Policy "${policy.name}": denied by user`,
2017
+ requestId,
2018
+ type: "permission-response"
2019
+ };
2020
+ };
2021
+ }
2022
+ function buildChildEnv(shimDir, socketPath, sessionId, shellEnv) {
2023
+ const originalPath = process.env.PATH ?? "";
2024
+ return {
2025
+ ...process.env,
2026
+ ...shellEnv,
2027
+ PATH: `${shimDir}${path4.delimiter}${originalPath}`,
2028
+ [CLAMP_IPC_ENV]: socketPath,
2029
+ [CLAMP_ORIGINAL_PATH_ENV]: originalPath,
2030
+ [CLAMP_SESSION_ENV]: sessionId
2031
+ };
2032
+ }
2033
+ function cleanupResources(socketPath, shimDir) {
2034
+ try {
2035
+ unlinkSync(socketPath);
2036
+ } catch {
2037
+ }
2038
+ try {
2039
+ rmSync3(shimDir, { force: true, recursive: true });
2040
+ } catch {
2041
+ }
2042
+ }
2043
+ function parseArgs(argv) {
2044
+ return {
2045
+ args: argv.args ?? [],
2046
+ auditEnabled: argv.audit !== false,
2047
+ command: argv.command,
2048
+ dryRun: argv["dry-run"] ?? false,
2049
+ policyOption: argv.policy
2050
+ };
2051
+ }
2052
+ async function runClamped(argv) {
2053
+ const {
2054
+ command,
2055
+ args,
2056
+ policyOption,
2057
+ auditEnabled,
2058
+ dryRun
2059
+ } = parseArgs(argv);
2060
+ let policy;
2061
+ try {
2062
+ policy = loadPolicy({ path: policyOption });
2063
+ } catch (err) {
2064
+ console.error(chalk2.red(`Failed to load policy: ${String(err)}`));
2065
+ process.exit(1);
2066
+ }
2067
+ if (dryRun) {
2068
+ printDryRun(command, args, policy, auditEnabled);
2069
+ return;
2070
+ }
2071
+ const sessionId = randomUUID();
2072
+ const shimDir = await generateShimDirectory(policy);
2073
+ const shellOverrides = createShellEnvOverrides(shimDir);
2074
+ const socketPath = path4.join(tmpdir4(), `aries-clamp-${process.pid}-${randomUUID().slice(0, 8)}.sock`);
2075
+ const sandboxRef = {};
2076
+ const handler = createPermissionHandler(policy, sessionId, auditEnabled, /* @__PURE__ */ new Set(), sandboxRef);
2077
+ const ipcHandle = createIpcServer({ onPermissionRequest: handler, socketPath });
2078
+ await ipcHandle.listening;
2079
+ if (auditEnabled) logClampStart({
2080
+ command,
2081
+ policy,
2082
+ sessionId
2083
+ });
2084
+ console.error(chalk2.cyan(`[clamp] Session ${sessionId.slice(0, 8)} \u2014 policy: ${policy.name}`));
2085
+ const childEnv = buildChildEnv(shimDir, socketPath, sessionId, shellOverrides.env);
2086
+ const sandbox = spawnSandboxed({
2087
+ args,
2088
+ command,
2089
+ env: childEnv,
2090
+ policy
2091
+ });
2092
+ sandboxRef.sandbox = sandbox;
2093
+ sandbox.renderer?.setStatusLine(`[clamp] policy: ${policy.name} | allowed: 0 | denied: 0`);
2094
+ const exitCode = await sandbox.exitCode;
2095
+ sandbox.cleanup();
2096
+ shellOverrides.cleanup();
2097
+ ipcHandle.close();
2098
+ cleanupResources(socketPath, shimDir);
2099
+ if (auditEnabled) logClampStop({ exitCode, sessionId });
2100
+ console.error(chalk2.gray(`
2101
+ [clamp] Session ended (exit code: ${exitCode})`));
2102
+ process.exit(exitCode ?? 1);
2103
+ }
2104
+
2105
+ // src/commands/clampRunCommand.ts
2106
+ var clampRunCommand = {
2107
+ builder: (yargs) => yargs.positional("command", {
2108
+ demandOption: true,
2109
+ describe: "Command to run inside the sandbox",
2110
+ type: "string"
2111
+ }).positional("args", {
2112
+ array: true,
2113
+ describe: "Arguments for the command",
2114
+ type: "string"
2115
+ }).option("policy", {
2116
+ alias: "p",
2117
+ describe: "Policy file path or name",
2118
+ type: "string"
2119
+ }).option("audit", {
2120
+ default: true,
2121
+ describe: "Enable audit logging",
2122
+ type: "boolean"
2123
+ }).option("dry-run", {
2124
+ default: false,
2125
+ describe: "Show what would be sandboxed without running",
2126
+ type: "boolean"
2127
+ }),
2128
+ command: "run <command> [args..]",
2129
+ describe: "Run a command inside the clamp sandbox",
2130
+ handler: async (argv) => {
2131
+ await runClamped(argv);
2132
+ }
2133
+ };
2134
+ export {
2135
+ clampRunCommand
2136
+ };
2137
+ //# sourceMappingURL=clampRunCommand.mjs.map