@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.
- package/README.md +693 -0
- package/dist/actions/audit/auditPaths.mjs +22 -0
- package/dist/actions/audit/auditPaths.mjs.map +1 -0
- package/dist/actions/audit/index.mjs +739 -0
- package/dist/actions/audit/index.mjs.map +1 -0
- package/dist/actions/audit/installPlugin.mjs +298 -0
- package/dist/actions/audit/installPlugin.mjs.map +1 -0
- package/dist/actions/audit/listSessions.mjs +93 -0
- package/dist/actions/audit/listSessions.mjs.map +1 -0
- package/dist/actions/audit/openAuditDir.mjs +44 -0
- package/dist/actions/audit/openAuditDir.mjs.map +1 -0
- package/dist/actions/audit/searchAudit.mjs +77 -0
- package/dist/actions/audit/searchAudit.mjs.map +1 -0
- package/dist/actions/audit/showAiMeta.mjs +105 -0
- package/dist/actions/audit/showAiMeta.mjs.map +1 -0
- package/dist/actions/audit/showSession.mjs +105 -0
- package/dist/actions/audit/showSession.mjs.map +1 -0
- package/dist/actions/audit/statusAudit.mjs +98 -0
- package/dist/actions/audit/statusAudit.mjs.map +1 -0
- package/dist/actions/clamp/clampAudit.mjs +53 -0
- package/dist/actions/clamp/clampAudit.mjs.map +1 -0
- package/dist/actions/clamp/index.mjs +2258 -0
- package/dist/actions/clamp/index.mjs.map +1 -0
- package/dist/actions/clamp/ipcServer.mjs +55 -0
- package/dist/actions/clamp/ipcServer.mjs.map +1 -0
- package/dist/actions/clamp/policyManagement.mjs +144 -0
- package/dist/actions/clamp/policyManagement.mjs.map +1 -0
- package/dist/actions/clamp/promptUser.mjs +91 -0
- package/dist/actions/clamp/promptUser.mjs.map +1 -0
- package/dist/actions/clamp/runClamped.mjs +2107 -0
- package/dist/actions/clamp/runClamped.mjs.map +1 -0
- package/dist/actions/clamp/sandboxExec.mjs +1612 -0
- package/dist/actions/clamp/sandboxExec.mjs.map +1 -0
- package/dist/actions/clamp/shellEnvSetup.mjs +59 -0
- package/dist/actions/clamp/shellEnvSetup.mjs.map +1 -0
- package/dist/actions/clamp/shimGenerator.mjs +68 -0
- package/dist/actions/clamp/shimGenerator.mjs.map +1 -0
- package/dist/actions/clamp/terminalRenderer.mjs +145 -0
- package/dist/actions/clamp/terminalRenderer.mjs.map +1 -0
- package/dist/actions/datalake/audit/auditLog.mjs +191 -0
- package/dist/actions/datalake/audit/auditLog.mjs.map +1 -0
- package/dist/actions/datalake/createDatalake.mjs +127 -0
- package/dist/actions/datalake/createDatalake.mjs.map +1 -0
- package/dist/actions/datalake/describeDatalake.mjs +159 -0
- package/dist/actions/datalake/describeDatalake.mjs.map +1 -0
- package/dist/actions/datalake/destroyDatalake.mjs +34 -0
- package/dist/actions/datalake/destroyDatalake.mjs.map +1 -0
- package/dist/actions/datalake/dev/downDevServer.mjs +102 -0
- package/dist/actions/datalake/dev/downDevServer.mjs.map +1 -0
- package/dist/actions/datalake/dev/index.mjs +369 -0
- package/dist/actions/datalake/dev/index.mjs.map +1 -0
- package/dist/actions/datalake/dev/logsDevServer.mjs +44 -0
- package/dist/actions/datalake/dev/logsDevServer.mjs.map +1 -0
- package/dist/actions/datalake/dev/paths.mjs +25 -0
- package/dist/actions/datalake/dev/paths.mjs.map +1 -0
- package/dist/actions/datalake/dev/resetDevServer.mjs +118 -0
- package/dist/actions/datalake/dev/resetDevServer.mjs.map +1 -0
- package/dist/actions/datalake/dev/resolveServerBin.mjs +26 -0
- package/dist/actions/datalake/dev/resolveServerBin.mjs.map +1 -0
- package/dist/actions/datalake/dev/state.mjs +62 -0
- package/dist/actions/datalake/dev/state.mjs.map +1 -0
- package/dist/actions/datalake/dev/statusDevServer.mjs +101 -0
- package/dist/actions/datalake/dev/statusDevServer.mjs.map +1 -0
- package/dist/actions/datalake/dev/upDevServer.mjs +221 -0
- package/dist/actions/datalake/dev/upDevServer.mjs.map +1 -0
- package/dist/actions/datalake/dev/waitForHealth.mjs +22 -0
- package/dist/actions/datalake/dev/waitForHealth.mjs.map +1 -0
- package/dist/actions/datalake/formatters.mjs +90 -0
- package/dist/actions/datalake/formatters.mjs.map +1 -0
- package/dist/actions/datalake/grantAccess.mjs +116 -0
- package/dist/actions/datalake/grantAccess.mjs.map +1 -0
- package/dist/actions/datalake/index.mjs +361 -0
- package/dist/actions/datalake/index.mjs.map +1 -0
- package/dist/actions/datalake/listDatalakes.mjs +54 -0
- package/dist/actions/datalake/listDatalakes.mjs.map +1 -0
- package/dist/actions/datalake/login.mjs +20 -0
- package/dist/actions/datalake/login.mjs.map +1 -0
- package/dist/actions/datalake/logout.mjs +11 -0
- package/dist/actions/datalake/logout.mjs.map +1 -0
- package/dist/actions/datalake/mintToken.mjs +37 -0
- package/dist/actions/datalake/mintToken.mjs.map +1 -0
- package/dist/actions/datalake/parseSize.mjs +21 -0
- package/dist/actions/datalake/parseSize.mjs.map +1 -0
- package/dist/actions/datalake/payloads/fetchPayload.mjs +76 -0
- package/dist/actions/datalake/payloads/fetchPayload.mjs.map +1 -0
- package/dist/actions/datalake/payloads/index.mjs +271 -0
- package/dist/actions/datalake/payloads/index.mjs.map +1 -0
- package/dist/actions/datalake/payloads/mintAndConnect.mjs +46 -0
- package/dist/actions/datalake/payloads/mintAndConnect.mjs.map +1 -0
- package/dist/actions/datalake/payloads/parsePayloadsFile.mjs +71 -0
- package/dist/actions/datalake/payloads/parsePayloadsFile.mjs.map +1 -0
- package/dist/actions/datalake/payloads/pushPayloads.mjs +181 -0
- package/dist/actions/datalake/payloads/pushPayloads.mjs.map +1 -0
- package/dist/actions/datalake/payloads/tailPayloads.mjs +106 -0
- package/dist/actions/datalake/payloads/tailPayloads.mjs.map +1 -0
- package/dist/actions/datalake/resolveTarget.mjs +15 -0
- package/dist/actions/datalake/resolveTarget.mjs.map +1 -0
- package/dist/actions/datalake/revokeAccess.mjs +108 -0
- package/dist/actions/datalake/revokeAccess.mjs.map +1 -0
- package/dist/actions/datalake/useDatalake.mjs +22 -0
- package/dist/actions/datalake/useDatalake.mjs.map +1 -0
- package/dist/actions/detect/detectAiClients.mjs +405 -0
- package/dist/actions/detect/detectAiClients.mjs.map +1 -0
- package/dist/actions/detect/index.mjs +405 -0
- package/dist/actions/detect/index.mjs.map +1 -0
- package/dist/actions/hash/algorithms/blockhash.mjs +61 -0
- package/dist/actions/hash/algorithms/blockhash.mjs.map +1 -0
- package/dist/actions/hash/algorithms/chromaprint.mjs +205 -0
- package/dist/actions/hash/algorithms/chromaprint.mjs.map +1 -0
- package/dist/actions/hash/algorithms/dhash.mjs +75 -0
- package/dist/actions/hash/algorithms/dhash.mjs.map +1 -0
- package/dist/actions/hash/algorithms/index.mjs +818 -0
- package/dist/actions/hash/algorithms/index.mjs.map +1 -0
- package/dist/actions/hash/algorithms/nilsimsa.mjs +27 -0
- package/dist/actions/hash/algorithms/nilsimsa.mjs.map +1 -0
- package/dist/actions/hash/algorithms/pdq.mjs +83 -0
- package/dist/actions/hash/algorithms/pdq.mjs.map +1 -0
- package/dist/actions/hash/algorithms/phash.mjs +71 -0
- package/dist/actions/hash/algorithms/phash.mjs.map +1 -0
- package/dist/actions/hash/algorithms/sha256.mjs +24 -0
- package/dist/actions/hash/algorithms/sha256.mjs.map +1 -0
- package/dist/actions/hash/algorithms/ssdeep.mjs +203 -0
- package/dist/actions/hash/algorithms/ssdeep.mjs.map +1 -0
- package/dist/actions/hash/algorithms/tlsh.mjs +66 -0
- package/dist/actions/hash/algorithms/tlsh.mjs.map +1 -0
- package/dist/actions/hash/algorithms/types.mjs +1 -0
- package/dist/actions/hash/algorithms/types.mjs.map +1 -0
- package/dist/actions/hash/algorithms/videoFrames.mjs +404 -0
- package/dist/actions/hash/algorithms/videoFrames.mjs.map +1 -0
- package/dist/actions/hash/algorithms/xyo.mjs +30 -0
- package/dist/actions/hash/algorithms/xyo.mjs.map +1 -0
- package/dist/actions/hash/compareHashes.mjs +823 -0
- package/dist/actions/hash/compareHashes.mjs.map +1 -0
- package/dist/actions/hash/hashInput.mjs +868 -0
- package/dist/actions/hash/hashInput.mjs.map +1 -0
- package/dist/actions/hash/index.mjs +881 -0
- package/dist/actions/hash/index.mjs.map +1 -0
- package/dist/actions/hash/lib/hamming.mjs +44 -0
- package/dist/actions/hash/lib/hamming.mjs.map +1 -0
- package/dist/actions/hash/lib/levenshtein.mjs +36 -0
- package/dist/actions/hash/lib/levenshtein.mjs.map +1 -0
- package/dist/actions/hash/lib/runBinary.mjs +54 -0
- package/dist/actions/hash/lib/runBinary.mjs.map +1 -0
- package/dist/actions/hash/lib/which.mjs +36 -0
- package/dist/actions/hash/lib/which.mjs.map +1 -0
- package/dist/actions/hash/lib/withTempfile.mjs +19 -0
- package/dist/actions/hash/lib/withTempfile.mjs.map +1 -0
- package/dist/actions/index.mjs +4615 -0
- package/dist/actions/index.mjs.map +1 -0
- package/dist/actions/printVersion.mjs +12 -0
- package/dist/actions/printVersion.mjs.map +1 -0
- package/dist/actions/sync/index.mjs +51 -0
- package/dist/actions/sync/index.mjs.map +1 -0
- package/dist/actions/sync/syncAiConfig.mjs +51 -0
- package/dist/actions/sync/syncAiConfig.mjs.map +1 -0
- package/dist/actions/wallet/account/deriveAndAdd.mjs +394 -0
- package/dist/actions/wallet/account/deriveAndAdd.mjs.map +1 -0
- package/dist/actions/wallet/account/getActiveWallet.mjs +338 -0
- package/dist/actions/wallet/account/getActiveWallet.mjs.map +1 -0
- package/dist/actions/wallet/account/labelAccount.mjs +389 -0
- package/dist/actions/wallet/account/labelAccount.mjs.map +1 -0
- package/dist/actions/wallet/account/listAccounts.mjs +374 -0
- package/dist/actions/wallet/account/listAccounts.mjs.map +1 -0
- package/dist/actions/wallet/account/removeAccount.mjs +384 -0
- package/dist/actions/wallet/account/removeAccount.mjs.map +1 -0
- package/dist/actions/wallet/account/showAccount.mjs +368 -0
- package/dist/actions/wallet/account/showAccount.mjs.map +1 -0
- package/dist/actions/wallet/addressBook/storage.mjs +110 -0
- package/dist/actions/wallet/addressBook/storage.mjs.map +1 -0
- package/dist/actions/wallet/backup/exportBackup.mjs +93 -0
- package/dist/actions/wallet/backup/exportBackup.mjs.map +1 -0
- package/dist/actions/wallet/backup/importBackup.mjs +142 -0
- package/dist/actions/wallet/backup/importBackup.mjs.map +1 -0
- package/dist/actions/wallet/balance/getBalance.mjs +434 -0
- package/dist/actions/wallet/balance/getBalance.mjs.map +1 -0
- package/dist/actions/wallet/client/walletClient.mjs +64 -0
- package/dist/actions/wallet/client/walletClient.mjs.map +1 -0
- package/dist/actions/wallet/contact/contactActions.mjs +120 -0
- package/dist/actions/wallet/contact/contactActions.mjs.map +1 -0
- package/dist/actions/wallet/contact/storage.mjs +69 -0
- package/dist/actions/wallet/contact/storage.mjs.map +1 -0
- package/dist/actions/wallet/index.mjs +1439 -0
- package/dist/actions/wallet/index.mjs.map +1 -0
- package/dist/actions/wallet/network/networkActions.mjs +137 -0
- package/dist/actions/wallet/network/networkActions.mjs.map +1 -0
- package/dist/actions/wallet/network/storage.mjs +93 -0
- package/dist/actions/wallet/network/storage.mjs.map +1 -0
- package/dist/actions/wallet/password/changePassword.mjs +282 -0
- package/dist/actions/wallet/password/changePassword.mjs.map +1 -0
- package/dist/actions/wallet/password/getActiveKey.mjs +297 -0
- package/dist/actions/wallet/password/getActiveKey.mjs.map +1 -0
- package/dist/actions/wallet/password/initOrUnlock.mjs +337 -0
- package/dist/actions/wallet/password/initOrUnlock.mjs.map +1 -0
- package/dist/actions/wallet/password/passwordStorage.mjs +69 -0
- package/dist/actions/wallet/password/passwordStorage.mjs.map +1 -0
- package/dist/actions/wallet/password/setPassword.mjs +138 -0
- package/dist/actions/wallet/password/setPassword.mjs.map +1 -0
- package/dist/actions/wallet/password/validatePassword.mjs +123 -0
- package/dist/actions/wallet/password/validatePassword.mjs.map +1 -0
- package/dist/actions/wallet/passwordKey.mjs +87 -0
- package/dist/actions/wallet/passwordKey.mjs.map +1 -0
- package/dist/actions/wallet/paths.mjs +26 -0
- package/dist/actions/wallet/paths.mjs.map +1 -0
- package/dist/actions/wallet/prompt.mjs +93 -0
- package/dist/actions/wallet/prompt.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/createPhrase.mjs +392 -0
- package/dist/actions/wallet/seedPhrase/createPhrase.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/exportPhrase.mjs +334 -0
- package/dist/actions/wallet/seedPhrase/exportPhrase.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/idGen.mjs +11 -0
- package/dist/actions/wallet/seedPhrase/idGen.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/importPhrase.mjs +393 -0
- package/dist/actions/wallet/seedPhrase/importPhrase.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/listPhrases.mjs +62 -0
- package/dist/actions/wallet/seedPhrase/listPhrases.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/phraseStorage.mjs +89 -0
- package/dist/actions/wallet/seedPhrase/phraseStorage.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/removePhrase.mjs +366 -0
- package/dist/actions/wallet/seedPhrase/removePhrase.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/renamePhrase.mjs +78 -0
- package/dist/actions/wallet/seedPhrase/renamePhrase.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/types.mjs +1 -0
- package/dist/actions/wallet/seedPhrase/types.mjs.map +1 -0
- package/dist/actions/wallet/seedPhrase/usePhrase.mjs +83 -0
- package/dist/actions/wallet/seedPhrase/usePhrase.mjs.map +1 -0
- package/dist/actions/wallet/session/machineId.mjs +145 -0
- package/dist/actions/wallet/session/machineId.mjs.map +1 -0
- package/dist/actions/wallet/session/sessionCache.mjs +221 -0
- package/dist/actions/wallet/session/sessionCache.mjs.map +1 -0
- package/dist/actions/wallet/session/unlock.mjs +307 -0
- package/dist/actions/wallet/session/unlock.mjs.map +1 -0
- package/dist/actions/wallet/sign/signPayload.mjs +637 -0
- package/dist/actions/wallet/sign/signPayload.mjs.map +1 -0
- package/dist/actions/wallet/storage.mjs +51 -0
- package/dist/actions/wallet/storage.mjs.map +1 -0
- package/dist/actions/wallet/transaction/broadcastTransaction.mjs +453 -0
- package/dist/actions/wallet/transaction/broadcastTransaction.mjs.map +1 -0
- package/dist/actions/wallet/transaction/sendTransaction.mjs +457 -0
- package/dist/actions/wallet/transaction/sendTransaction.mjs.map +1 -0
- package/dist/actions/wallet/transaction/signTransactionFile.mjs +378 -0
- package/dist/actions/wallet/transaction/signTransactionFile.mjs.map +1 -0
- package/dist/actions/xyo/index.mjs +138 -0
- package/dist/actions/xyo/index.mjs.map +1 -0
- package/dist/actions/xyo/transaction/index.mjs +138 -0
- package/dist/actions/xyo/transaction/index.mjs.map +1 -0
- package/dist/actions/xyo/transaction/validateTransactions.mjs +138 -0
- package/dist/actions/xyo/transaction/validateTransactions.mjs.map +1 -0
- package/dist/aries.mjs +8466 -0
- package/dist/aries.mjs.map +1 -0
- package/dist/bin/aries.mjs +8472 -0
- package/dist/bin/aries.mjs.map +1 -0
- package/dist/commands/aiCommand.mjs +492 -0
- package/dist/commands/aiCommand.mjs.map +1 -0
- package/dist/commands/auditAiCommand.mjs +119 -0
- package/dist/commands/auditAiCommand.mjs.map +1 -0
- package/dist/commands/auditCommand.mjs +857 -0
- package/dist/commands/auditCommand.mjs.map +1 -0
- package/dist/commands/auditInstallCommand.mjs +324 -0
- package/dist/commands/auditInstallCommand.mjs.map +1 -0
- package/dist/commands/auditListCommand.mjs +107 -0
- package/dist/commands/auditListCommand.mjs.map +1 -0
- package/dist/commands/auditOpenCommand.mjs +51 -0
- package/dist/commands/auditOpenCommand.mjs.map +1 -0
- package/dist/commands/auditSearchCommand.mjs +98 -0
- package/dist/commands/auditSearchCommand.mjs.map +1 -0
- package/dist/commands/auditShowCommand.mjs +123 -0
- package/dist/commands/auditShowCommand.mjs.map +1 -0
- package/dist/commands/auditStatusCommand.mjs +105 -0
- package/dist/commands/auditStatusCommand.mjs.map +1 -0
- package/dist/commands/clampCommand.mjs +2328 -0
- package/dist/commands/clampCommand.mjs.map +1 -0
- package/dist/commands/clampPolicyCommand.mjs +184 -0
- package/dist/commands/clampPolicyCommand.mjs.map +1 -0
- package/dist/commands/clampPolicyInitCommand.mjs +63 -0
- package/dist/commands/clampPolicyInitCommand.mjs.map +1 -0
- package/dist/commands/clampPolicyListCommand.mjs +56 -0
- package/dist/commands/clampPolicyListCommand.mjs.map +1 -0
- package/dist/commands/clampPolicyShowCommand.mjs +83 -0
- package/dist/commands/clampPolicyShowCommand.mjs.map +1 -0
- package/dist/commands/clampRunCommand.mjs +2137 -0
- package/dist/commands/clampRunCommand.mjs.map +1 -0
- package/dist/commands/datalakeAuditCommand.mjs +273 -0
- package/dist/commands/datalakeAuditCommand.mjs.map +1 -0
- package/dist/commands/datalakeCommand.mjs +1637 -0
- package/dist/commands/datalakeCommand.mjs.map +1 -0
- package/dist/commands/datalakeCreateCommand.mjs +189 -0
- package/dist/commands/datalakeCreateCommand.mjs.map +1 -0
- package/dist/commands/datalakeDescribeCommand.mjs +172 -0
- package/dist/commands/datalakeDescribeCommand.mjs.map +1 -0
- package/dist/commands/datalakeDestroyCommand.mjs +53 -0
- package/dist/commands/datalakeDestroyCommand.mjs.map +1 -0
- package/dist/commands/datalakeDevCommand.mjs +470 -0
- package/dist/commands/datalakeDevCommand.mjs.map +1 -0
- package/dist/commands/datalakeDevDownCommand.mjs +111 -0
- package/dist/commands/datalakeDevDownCommand.mjs.map +1 -0
- package/dist/commands/datalakeDevLogsCommand.mjs +65 -0
- package/dist/commands/datalakeDevLogsCommand.mjs.map +1 -0
- package/dist/commands/datalakeDevResetCommand.mjs +125 -0
- package/dist/commands/datalakeDevResetCommand.mjs.map +1 -0
- package/dist/commands/datalakeDevStatusCommand.mjs +110 -0
- package/dist/commands/datalakeDevStatusCommand.mjs.map +1 -0
- package/dist/commands/datalakeDevUpCommand.mjs +268 -0
- package/dist/commands/datalakeDevUpCommand.mjs.map +1 -0
- package/dist/commands/datalakeFetchCommand.mjs +106 -0
- package/dist/commands/datalakeFetchCommand.mjs.map +1 -0
- package/dist/commands/datalakeGrantCommand.mjs +147 -0
- package/dist/commands/datalakeGrantCommand.mjs.map +1 -0
- package/dist/commands/datalakeListCommand.mjs +61 -0
- package/dist/commands/datalakeListCommand.mjs.map +1 -0
- package/dist/commands/datalakeLoginCommand.mjs +39 -0
- package/dist/commands/datalakeLoginCommand.mjs.map +1 -0
- package/dist/commands/datalakeLogoutCommand.mjs +20 -0
- package/dist/commands/datalakeLogoutCommand.mjs.map +1 -0
- package/dist/commands/datalakePushCommand.mjs +214 -0
- package/dist/commands/datalakePushCommand.mjs.map +1 -0
- package/dist/commands/datalakeRevokeCommand.mjs +127 -0
- package/dist/commands/datalakeRevokeCommand.mjs.map +1 -0
- package/dist/commands/datalakeTailCommand.mjs +144 -0
- package/dist/commands/datalakeTailCommand.mjs.map +1 -0
- package/dist/commands/datalakeTokenCommand.mjs +61 -0
- package/dist/commands/datalakeTokenCommand.mjs.map +1 -0
- package/dist/commands/datalakeUseCommand.mjs +35 -0
- package/dist/commands/datalakeUseCommand.mjs.map +1 -0
- package/dist/commands/detectCommand.mjs +419 -0
- package/dist/commands/detectCommand.mjs.map +1 -0
- package/dist/commands/hashCommand.mjs +976 -0
- package/dist/commands/hashCommand.mjs.map +1 -0
- package/dist/commands/hashCompareCommand.mjs +865 -0
- package/dist/commands/hashCompareCommand.mjs.map +1 -0
- package/dist/commands/index.mjs +8461 -0
- package/dist/commands/index.mjs.map +1 -0
- package/dist/commands/syncCommand.mjs +66 -0
- package/dist/commands/syncCommand.mjs.map +1 -0
- package/dist/commands/versionCommand.mjs +24 -0
- package/dist/commands/versionCommand.mjs.map +1 -0
- package/dist/commands/walletAccountCommand.mjs +536 -0
- package/dist/commands/walletAccountCommand.mjs.map +1 -0
- package/dist/commands/walletAccountDeriveCommand.mjs +415 -0
- package/dist/commands/walletAccountDeriveCommand.mjs.map +1 -0
- package/dist/commands/walletAccountLabelCommand.mjs +405 -0
- package/dist/commands/walletAccountLabelCommand.mjs.map +1 -0
- package/dist/commands/walletAccountListCommand.mjs +381 -0
- package/dist/commands/walletAccountListCommand.mjs.map +1 -0
- package/dist/commands/walletAccountRemoveCommand.mjs +396 -0
- package/dist/commands/walletAccountRemoveCommand.mjs.map +1 -0
- package/dist/commands/walletAccountShowCommand.mjs +380 -0
- package/dist/commands/walletAccountShowCommand.mjs.map +1 -0
- package/dist/commands/walletBackupCommand.mjs +222 -0
- package/dist/commands/walletBackupCommand.mjs.map +1 -0
- package/dist/commands/walletBackupExportCommand.mjs +107 -0
- package/dist/commands/walletBackupExportCommand.mjs.map +1 -0
- package/dist/commands/walletBackupImportCommand.mjs +154 -0
- package/dist/commands/walletBackupImportCommand.mjs.map +1 -0
- package/dist/commands/walletBalanceCommand.mjs +448 -0
- package/dist/commands/walletBalanceCommand.mjs.map +1 -0
- package/dist/commands/walletCommand.mjs +1968 -0
- package/dist/commands/walletCommand.mjs.map +1 -0
- package/dist/commands/walletContactAddCommand.mjs +111 -0
- package/dist/commands/walletContactAddCommand.mjs.map +1 -0
- package/dist/commands/walletContactCommand.mjs +184 -0
- package/dist/commands/walletContactCommand.mjs.map +1 -0
- package/dist/commands/walletContactListCommand.mjs +66 -0
- package/dist/commands/walletContactListCommand.mjs.map +1 -0
- package/dist/commands/walletContactRemoveCommand.mjs +97 -0
- package/dist/commands/walletContactRemoveCommand.mjs.map +1 -0
- package/dist/commands/walletContactRenameCommand.mjs +114 -0
- package/dist/commands/walletContactRenameCommand.mjs.map +1 -0
- package/dist/commands/walletCreateCommand.mjs +407 -0
- package/dist/commands/walletCreateCommand.mjs.map +1 -0
- package/dist/commands/walletExportCommand.mjs +345 -0
- package/dist/commands/walletExportCommand.mjs.map +1 -0
- package/dist/commands/walletImportCommand.mjs +413 -0
- package/dist/commands/walletImportCommand.mjs.map +1 -0
- package/dist/commands/walletListCommand.mjs +69 -0
- package/dist/commands/walletListCommand.mjs.map +1 -0
- package/dist/commands/walletLockCommand.mjs +56 -0
- package/dist/commands/walletLockCommand.mjs.map +1 -0
- package/dist/commands/walletNetworkAddCommand.mjs +131 -0
- package/dist/commands/walletNetworkAddCommand.mjs.map +1 -0
- package/dist/commands/walletNetworkCommand.mjs +206 -0
- package/dist/commands/walletNetworkCommand.mjs.map +1 -0
- package/dist/commands/walletNetworkListCommand.mjs +104 -0
- package/dist/commands/walletNetworkListCommand.mjs.map +1 -0
- package/dist/commands/walletNetworkRemoveCommand.mjs +112 -0
- package/dist/commands/walletNetworkRemoveCommand.mjs.map +1 -0
- package/dist/commands/walletNetworkUseCommand.mjs +110 -0
- package/dist/commands/walletNetworkUseCommand.mjs.map +1 -0
- package/dist/commands/walletPasswordChangeCommand.mjs +291 -0
- package/dist/commands/walletPasswordChangeCommand.mjs.map +1 -0
- package/dist/commands/walletPasswordCommand.mjs +301 -0
- package/dist/commands/walletPasswordCommand.mjs.map +1 -0
- package/dist/commands/walletRemoveCommand.mjs +378 -0
- package/dist/commands/walletRemoveCommand.mjs.map +1 -0
- package/dist/commands/walletRenameCommand.mjs +94 -0
- package/dist/commands/walletRenameCommand.mjs.map +1 -0
- package/dist/commands/walletSignCommand.mjs +662 -0
- package/dist/commands/walletSignCommand.mjs.map +1 -0
- package/dist/commands/walletTxBroadcastCommand.mjs +473 -0
- package/dist/commands/walletTxBroadcastCommand.mjs.map +1 -0
- package/dist/commands/walletTxCommand.mjs +612 -0
- package/dist/commands/walletTxCommand.mjs.map +1 -0
- package/dist/commands/walletTxSendCommand.mjs +492 -0
- package/dist/commands/walletTxSendCommand.mjs.map +1 -0
- package/dist/commands/walletTxSignCommand.mjs +403 -0
- package/dist/commands/walletTxSignCommand.mjs.map +1 -0
- package/dist/commands/walletUnlockCommand.mjs +308 -0
- package/dist/commands/walletUnlockCommand.mjs.map +1 -0
- package/dist/commands/walletUseCommand.mjs +95 -0
- package/dist/commands/walletUseCommand.mjs.map +1 -0
- package/dist/commands/xyoCommand.mjs +188 -0
- package/dist/commands/xyoCommand.mjs.map +1 -0
- package/dist/commands/xyoTxCommand.mjs +178 -0
- package/dist/commands/xyoTxCommand.mjs.map +1 -0
- package/dist/commands/xyoTxValidateCommand.mjs +168 -0
- package/dist/commands/xyoTxValidateCommand.mjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +8466 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/modules.d.mjs +1 -0
- package/dist/types/modules.d.mjs.map +1 -0
- package/package.json +197 -0
|
@@ -0,0 +1,2258 @@
|
|
|
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 path6 = __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 = path6.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(path6.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 path6 = __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 = path6.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/policyManagement.ts
|
|
1416
|
+
import {
|
|
1417
|
+
existsSync,
|
|
1418
|
+
readdirSync,
|
|
1419
|
+
readFileSync,
|
|
1420
|
+
writeFileSync
|
|
1421
|
+
} from "fs";
|
|
1422
|
+
import path from "path";
|
|
1423
|
+
import { CLAMP_POLICY_DIR } from "@xylabs/aries-clamp-core";
|
|
1424
|
+
import chalk from "chalk";
|
|
1425
|
+
function listPolicies() {
|
|
1426
|
+
const policies = [];
|
|
1427
|
+
if (existsSync(CLAMP_POLICY_DIR)) {
|
|
1428
|
+
for (const file of readdirSync(CLAMP_POLICY_DIR)) {
|
|
1429
|
+
if (file.endsWith(".json")) {
|
|
1430
|
+
policies.push({
|
|
1431
|
+
name: file.replace(/\.json$/, ""),
|
|
1432
|
+
source: CLAMP_POLICY_DIR
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
const localPath = path.join(process.cwd(), ".aries-clamp.json");
|
|
1438
|
+
if (existsSync(localPath)) {
|
|
1439
|
+
try {
|
|
1440
|
+
const policy = JSON.parse(readFileSync(localPath, "utf8"));
|
|
1441
|
+
policies.push({ name: policy.name ?? "(local)", source: localPath });
|
|
1442
|
+
} catch {
|
|
1443
|
+
policies.push({ name: "(local - parse error)", source: localPath });
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
if (policies.length === 0) {
|
|
1447
|
+
console.log(chalk.yellow("No policies found."));
|
|
1448
|
+
console.log(chalk.gray(` Policy directory: ${CLAMP_POLICY_DIR}`));
|
|
1449
|
+
console.log(chalk.gray(' Run "aries clamp policy init" to create a starter policy.'));
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
console.log(chalk.cyan("\nAvailable policies:\n"));
|
|
1453
|
+
for (const p of policies) {
|
|
1454
|
+
console.log(` ${chalk.white(p.name)} ${chalk.gray(`(${p.source})`)}`);
|
|
1455
|
+
}
|
|
1456
|
+
console.log("");
|
|
1457
|
+
}
|
|
1458
|
+
function printAccessRules(label, rules) {
|
|
1459
|
+
if (!rules) return;
|
|
1460
|
+
console.log(chalk.white(` ${label}:`));
|
|
1461
|
+
if (rules.allow?.length) console.log(chalk.white(` allow: ${rules.allow.join(", ")}`));
|
|
1462
|
+
if (rules.prompt?.length) console.log(chalk.yellow(` prompt: ${rules.prompt.join(", ")}`));
|
|
1463
|
+
if (rules.deny?.length) console.log(chalk.red(` deny: ${rules.deny.join(", ")}`));
|
|
1464
|
+
}
|
|
1465
|
+
function printProcessRules(policy) {
|
|
1466
|
+
if (!policy.process) return;
|
|
1467
|
+
console.log(chalk.green("\n Process rules:"));
|
|
1468
|
+
if (policy.process.allow?.length) {
|
|
1469
|
+
console.log(chalk.white(` allow: ${policy.process.allow.join(", ")}`));
|
|
1470
|
+
}
|
|
1471
|
+
if (policy.process.prompt?.length) {
|
|
1472
|
+
console.log(chalk.yellow(` prompt: ${policy.process.prompt.join(", ")}`));
|
|
1473
|
+
}
|
|
1474
|
+
if (policy.process.deny?.length) {
|
|
1475
|
+
console.log(chalk.red(` deny: ${policy.process.deny.join(", ")}`));
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function printFilesystemRules(policy) {
|
|
1479
|
+
if (!policy.filesystem) return;
|
|
1480
|
+
console.log(chalk.green("\n Filesystem rules:"));
|
|
1481
|
+
printAccessRules("read", policy.filesystem.read);
|
|
1482
|
+
printAccessRules("write", policy.filesystem.write);
|
|
1483
|
+
}
|
|
1484
|
+
function resolvePolicyPath(name) {
|
|
1485
|
+
const namedPath = path.join(CLAMP_POLICY_DIR, `${name}.json`);
|
|
1486
|
+
if (existsSync(namedPath)) return namedPath;
|
|
1487
|
+
if (existsSync(name)) return name;
|
|
1488
|
+
return void 0;
|
|
1489
|
+
}
|
|
1490
|
+
function showPolicy(name) {
|
|
1491
|
+
const policyPath = resolvePolicyPath(name);
|
|
1492
|
+
if (!policyPath) {
|
|
1493
|
+
console.error(chalk.red(`Policy not found: ${name}`));
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
const policy = JSON.parse(readFileSync(policyPath, "utf8"));
|
|
1497
|
+
console.log(chalk.cyan(`
|
|
1498
|
+
Policy: ${policy.name}`));
|
|
1499
|
+
if (policy.description) {
|
|
1500
|
+
console.log(chalk.gray(` ${policy.description}`));
|
|
1501
|
+
}
|
|
1502
|
+
console.log("");
|
|
1503
|
+
console.log(chalk.white(` Default action: ${policy.defaultAction ?? "prompt"}`));
|
|
1504
|
+
console.log(chalk.white(` Audit: ${policy.audit === false ? "disabled" : "enabled"}`));
|
|
1505
|
+
printProcessRules(policy);
|
|
1506
|
+
printFilesystemRules(policy);
|
|
1507
|
+
if (policy.network) {
|
|
1508
|
+
console.log(chalk.green(`
|
|
1509
|
+
Network: ${policy.network.allow ? "allowed" : "denied"}`));
|
|
1510
|
+
}
|
|
1511
|
+
console.log("");
|
|
1512
|
+
}
|
|
1513
|
+
function initPolicy() {
|
|
1514
|
+
const targetPath = path.join(process.cwd(), ".aries-clamp.json");
|
|
1515
|
+
if (existsSync(targetPath)) {
|
|
1516
|
+
console.error(chalk.yellow(".aries-clamp.json already exists in this directory."));
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
const starterPolicy = {
|
|
1520
|
+
audit: true,
|
|
1521
|
+
defaultAction: "prompt",
|
|
1522
|
+
description: "Starter clamp policy",
|
|
1523
|
+
filesystem: {
|
|
1524
|
+
write: {
|
|
1525
|
+
allow: ["./src/**", "./tests/**"],
|
|
1526
|
+
deny: ["/etc/**", "/usr/**"]
|
|
1527
|
+
}
|
|
1528
|
+
},
|
|
1529
|
+
name: "local",
|
|
1530
|
+
process: {
|
|
1531
|
+
allow: [
|
|
1532
|
+
"node",
|
|
1533
|
+
"npm",
|
|
1534
|
+
"pnpm",
|
|
1535
|
+
"git",
|
|
1536
|
+
"tsc",
|
|
1537
|
+
"ls",
|
|
1538
|
+
"cat",
|
|
1539
|
+
"echo"
|
|
1540
|
+
],
|
|
1541
|
+
deny: ["sudo", "docker"],
|
|
1542
|
+
prompt: [
|
|
1543
|
+
"rm",
|
|
1544
|
+
"curl",
|
|
1545
|
+
"wget",
|
|
1546
|
+
"chmod"
|
|
1547
|
+
]
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
writeFileSync(targetPath, JSON.stringify(starterPolicy, null, 2) + "\n", "utf8");
|
|
1551
|
+
console.log(chalk.green(`Created ${targetPath}`));
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
// src/actions/clamp/promptUser.ts
|
|
1555
|
+
import {
|
|
1556
|
+
closeSync,
|
|
1557
|
+
openSync,
|
|
1558
|
+
writeSync
|
|
1559
|
+
} from "fs";
|
|
1560
|
+
import { createInterface } from "readline";
|
|
1561
|
+
import { ReadStream } from "tty";
|
|
1562
|
+
function parseAnswer(answer) {
|
|
1563
|
+
const trimmed = answer.trim().toLowerCase();
|
|
1564
|
+
if (trimmed === "y" || trimmed === "yes") return "allow-once";
|
|
1565
|
+
if (trimmed === "a" || trimmed === "always") return "allow-always";
|
|
1566
|
+
return "deny";
|
|
1567
|
+
}
|
|
1568
|
+
function promptViaTty(fullCommand) {
|
|
1569
|
+
let readFd;
|
|
1570
|
+
let writeFd;
|
|
1571
|
+
try {
|
|
1572
|
+
readFd = openSync("/dev/tty", "r");
|
|
1573
|
+
writeFd = openSync("/dev/tty", "w");
|
|
1574
|
+
} catch {
|
|
1575
|
+
return Promise.resolve("deny");
|
|
1576
|
+
}
|
|
1577
|
+
const ttyIn = new ReadStream(readFd);
|
|
1578
|
+
writeSync(writeFd, `
|
|
1579
|
+
[clamp] "${fullCommand}" \u2014 Allow? [y/N/a(lways)] `);
|
|
1580
|
+
const rl = createInterface({ input: ttyIn, terminal: false });
|
|
1581
|
+
return new Promise((resolve) => {
|
|
1582
|
+
const cleanup = () => {
|
|
1583
|
+
rl.close();
|
|
1584
|
+
ttyIn.destroy();
|
|
1585
|
+
try {
|
|
1586
|
+
closeSync(writeFd);
|
|
1587
|
+
} catch {
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
rl.once("line", (answer) => {
|
|
1591
|
+
cleanup();
|
|
1592
|
+
resolve(parseAnswer(answer));
|
|
1593
|
+
});
|
|
1594
|
+
rl.once("close", () => resolve("deny"));
|
|
1595
|
+
ttyIn.on("error", () => {
|
|
1596
|
+
cleanup();
|
|
1597
|
+
resolve("deny");
|
|
1598
|
+
});
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
function promptViaRenderer(fullCommand, renderer) {
|
|
1602
|
+
const promptText = `[clamp] "${fullCommand}" \u2014 Allow? [y/N/a(lways)] `;
|
|
1603
|
+
renderer.setStatusLine(promptText);
|
|
1604
|
+
let readFd;
|
|
1605
|
+
try {
|
|
1606
|
+
readFd = openSync("/dev/tty", "r");
|
|
1607
|
+
} catch {
|
|
1608
|
+
renderer.setStatusLine("[clamp] No TTY \u2014 denied");
|
|
1609
|
+
return Promise.resolve("deny");
|
|
1610
|
+
}
|
|
1611
|
+
const ttyIn = new ReadStream(readFd);
|
|
1612
|
+
const rl = createInterface({ input: ttyIn, terminal: false });
|
|
1613
|
+
return new Promise((resolve) => {
|
|
1614
|
+
const cleanup = () => {
|
|
1615
|
+
rl.close();
|
|
1616
|
+
ttyIn.destroy();
|
|
1617
|
+
renderer.setStatusLine("[clamp] Ready");
|
|
1618
|
+
};
|
|
1619
|
+
rl.once("line", (answer) => {
|
|
1620
|
+
const decision = parseAnswer(answer);
|
|
1621
|
+
cleanup();
|
|
1622
|
+
resolve(decision);
|
|
1623
|
+
});
|
|
1624
|
+
rl.once("close", () => {
|
|
1625
|
+
cleanup();
|
|
1626
|
+
resolve("deny");
|
|
1627
|
+
});
|
|
1628
|
+
ttyIn.on("error", () => {
|
|
1629
|
+
cleanup();
|
|
1630
|
+
resolve("deny");
|
|
1631
|
+
});
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
async function promptUser(command, args, renderer) {
|
|
1635
|
+
const fullCommand = [command, ...args].join(" ");
|
|
1636
|
+
if (renderer) {
|
|
1637
|
+
return promptViaRenderer(fullCommand, renderer);
|
|
1638
|
+
}
|
|
1639
|
+
return promptViaTty(fullCommand);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
// src/actions/clamp/runClamped.ts
|
|
1643
|
+
import { randomUUID } from "crypto";
|
|
1644
|
+
import { rmSync as rmSync3, unlinkSync } from "fs";
|
|
1645
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
1646
|
+
import path5 from "path";
|
|
1647
|
+
import {
|
|
1648
|
+
CLAMP_IPC_ENV,
|
|
1649
|
+
CLAMP_ORIGINAL_PATH_ENV,
|
|
1650
|
+
CLAMP_SESSION_ENV,
|
|
1651
|
+
loadPolicy,
|
|
1652
|
+
matchProcess
|
|
1653
|
+
} from "@xylabs/aries-clamp-core";
|
|
1654
|
+
import chalk3 from "chalk";
|
|
1655
|
+
|
|
1656
|
+
// src/actions/clamp/sandboxExec.ts
|
|
1657
|
+
import { spawn } from "child_process";
|
|
1658
|
+
import {
|
|
1659
|
+
mkdtempSync,
|
|
1660
|
+
rmSync,
|
|
1661
|
+
writeFileSync as writeFileSync2
|
|
1662
|
+
} from "fs";
|
|
1663
|
+
import { tmpdir } from "os";
|
|
1664
|
+
import path2 from "path";
|
|
1665
|
+
import { detectPlatform, generateMacOSProfile } from "@xylabs/aries-clamp-core";
|
|
1666
|
+
import chalk2 from "chalk";
|
|
1667
|
+
|
|
1668
|
+
// src/actions/clamp/terminalRenderer.ts
|
|
1669
|
+
import pkg from "@xterm/headless";
|
|
1670
|
+
var { Terminal } = pkg;
|
|
1671
|
+
var STATUS_BAR_HEIGHT = 2;
|
|
1672
|
+
var ESC = "\x1B[";
|
|
1673
|
+
var moveTo = (row, col) => `${ESC}${row};${col}H`;
|
|
1674
|
+
var resetStyle = `${ESC}0m`;
|
|
1675
|
+
var hideCursor = `${ESC}?25l`;
|
|
1676
|
+
var showCursor = `${ESC}?25h`;
|
|
1677
|
+
var clearScreen = `${ESC}2J`;
|
|
1678
|
+
var setBg = (r, g, b) => `${ESC}48;2;${r};${g};${b}m`;
|
|
1679
|
+
var setFg = (r, g, b) => `${ESC}38;2;${r};${g};${b}m`;
|
|
1680
|
+
var fgPalette = (n) => `${ESC}38;5;${n}m`;
|
|
1681
|
+
var bgPalette = (n) => `${ESC}48;5;${n}m`;
|
|
1682
|
+
var bold = `${ESC}1m`;
|
|
1683
|
+
var dim = `${ESC}2m`;
|
|
1684
|
+
var italic = `${ESC}3m`;
|
|
1685
|
+
var underline = `${ESC}4m`;
|
|
1686
|
+
var inverse = `${ESC}7m`;
|
|
1687
|
+
var strikethrough = `${ESC}9m`;
|
|
1688
|
+
function getCellStyle(cell) {
|
|
1689
|
+
if (!cell) return {
|
|
1690
|
+
attrs: "",
|
|
1691
|
+
bg: "",
|
|
1692
|
+
fg: ""
|
|
1693
|
+
};
|
|
1694
|
+
let fg = "";
|
|
1695
|
+
let bg = "";
|
|
1696
|
+
let attrs = "";
|
|
1697
|
+
if (cell.isFgRGB()) {
|
|
1698
|
+
const color = cell.getFgColor();
|
|
1699
|
+
fg = setFg(color >> 16 & 255, color >> 8 & 255, color & 255);
|
|
1700
|
+
} else if (cell.getFgColorMode() !== 0) {
|
|
1701
|
+
fg = fgPalette(cell.getFgColor());
|
|
1702
|
+
}
|
|
1703
|
+
if (cell.isBgRGB()) {
|
|
1704
|
+
const color = cell.getBgColor();
|
|
1705
|
+
bg = setBg(color >> 16 & 255, color >> 8 & 255, color & 255);
|
|
1706
|
+
} else if (cell.getBgColorMode() !== 0) {
|
|
1707
|
+
bg = bgPalette(cell.getBgColor());
|
|
1708
|
+
}
|
|
1709
|
+
if (cell.isBold()) attrs += bold;
|
|
1710
|
+
if (cell.isDim()) attrs += dim;
|
|
1711
|
+
if (cell.isItalic()) attrs += italic;
|
|
1712
|
+
if (cell.isUnderline()) attrs += underline;
|
|
1713
|
+
if (cell.isInverse()) attrs += inverse;
|
|
1714
|
+
if (cell.isStrikethrough()) attrs += strikethrough;
|
|
1715
|
+
return {
|
|
1716
|
+
attrs,
|
|
1717
|
+
bg,
|
|
1718
|
+
fg
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
function createTerminalRenderer() {
|
|
1722
|
+
const realCols = process.stdout.columns ?? 80;
|
|
1723
|
+
const realRows = process.stdout.rows ?? 24;
|
|
1724
|
+
const innerRows = realRows - STATUS_BAR_HEIGHT;
|
|
1725
|
+
const terminal = new Terminal({
|
|
1726
|
+
cols: realCols,
|
|
1727
|
+
rows: innerRows
|
|
1728
|
+
});
|
|
1729
|
+
let statusLine = "";
|
|
1730
|
+
let renderScheduled = false;
|
|
1731
|
+
function renderBuffer() {
|
|
1732
|
+
const buf = terminal.buffer.active;
|
|
1733
|
+
const cols = terminal.cols;
|
|
1734
|
+
const rows = terminal.rows;
|
|
1735
|
+
const output = [hideCursor];
|
|
1736
|
+
for (let y = 0; y < rows; y++) {
|
|
1737
|
+
const line = buf.getLine(y);
|
|
1738
|
+
output.push(moveTo(y + 1, 1));
|
|
1739
|
+
if (!line) {
|
|
1740
|
+
output.push(resetStyle + " ".repeat(cols));
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
let lineStr = "";
|
|
1744
|
+
let lastStyle = "";
|
|
1745
|
+
for (let x = 0; x < cols; x++) {
|
|
1746
|
+
const cell = line.getCell(x);
|
|
1747
|
+
if (!cell || cell.getWidth() === 0) continue;
|
|
1748
|
+
const style = getCellStyle(cell);
|
|
1749
|
+
const styleStr = resetStyle + style.fg + style.bg + style.attrs;
|
|
1750
|
+
if (styleStr !== lastStyle) {
|
|
1751
|
+
lineStr += styleStr;
|
|
1752
|
+
lastStyle = styleStr;
|
|
1753
|
+
}
|
|
1754
|
+
const ch = cell.getChars();
|
|
1755
|
+
lineStr += ch || " ";
|
|
1756
|
+
}
|
|
1757
|
+
output.push(lineStr + resetStyle);
|
|
1758
|
+
}
|
|
1759
|
+
const statusRow = realRows - 1;
|
|
1760
|
+
output.push(
|
|
1761
|
+
moveTo(statusRow, 1),
|
|
1762
|
+
resetStyle + dim + "\u2500".repeat(realCols) + resetStyle,
|
|
1763
|
+
moveTo(statusRow + 1, 1),
|
|
1764
|
+
resetStyle,
|
|
1765
|
+
statusLine.padEnd(realCols).slice(0, realCols),
|
|
1766
|
+
resetStyle
|
|
1767
|
+
);
|
|
1768
|
+
const cursorY = buf.cursorY + 1;
|
|
1769
|
+
const cursorX = buf.cursorX + 1;
|
|
1770
|
+
output.push(moveTo(cursorY, cursorX), showCursor);
|
|
1771
|
+
process.stdout.write(output.join(""));
|
|
1772
|
+
}
|
|
1773
|
+
function scheduleRender() {
|
|
1774
|
+
if (renderScheduled) return;
|
|
1775
|
+
renderScheduled = true;
|
|
1776
|
+
setImmediate(() => {
|
|
1777
|
+
renderScheduled = false;
|
|
1778
|
+
renderBuffer();
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
function handleResize() {
|
|
1782
|
+
const newCols = process.stdout.columns ?? 80;
|
|
1783
|
+
const newRows = process.stdout.rows ?? 24;
|
|
1784
|
+
const newInnerRows = newRows - STATUS_BAR_HEIGHT;
|
|
1785
|
+
terminal.resize(newCols, newInnerRows);
|
|
1786
|
+
process.stdout.write(clearScreen);
|
|
1787
|
+
scheduleRender();
|
|
1788
|
+
}
|
|
1789
|
+
process.stdout.on("resize", handleResize);
|
|
1790
|
+
process.stdout.write(clearScreen + moveTo(1, 1));
|
|
1791
|
+
return {
|
|
1792
|
+
destroy: () => {
|
|
1793
|
+
process.stdout.removeListener("resize", handleResize);
|
|
1794
|
+
process.stdout.write(clearScreen + moveTo(1, 1) + showCursor + resetStyle);
|
|
1795
|
+
terminal.dispose();
|
|
1796
|
+
},
|
|
1797
|
+
render: scheduleRender,
|
|
1798
|
+
setStatusLine: (line) => {
|
|
1799
|
+
statusLine = line;
|
|
1800
|
+
scheduleRender();
|
|
1801
|
+
},
|
|
1802
|
+
terminal,
|
|
1803
|
+
write: (data) => {
|
|
1804
|
+
terminal.write(data);
|
|
1805
|
+
scheduleRender();
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
// src/actions/clamp/sandboxExec.ts
|
|
1811
|
+
function createMacOSSandbox(policy) {
|
|
1812
|
+
const profileContent = generateMacOSProfile(policy, process.cwd());
|
|
1813
|
+
const profileDir = mkdtempSync(path2.join(tmpdir(), "aries-clamp-sb-"));
|
|
1814
|
+
const profilePath = path2.join(profileDir, "sandbox.sb");
|
|
1815
|
+
writeFileSync2(profilePath, profileContent, "utf8");
|
|
1816
|
+
console.error(chalk2.gray("[clamp] macOS sandbox enabled"));
|
|
1817
|
+
return {
|
|
1818
|
+
args: ["-f", profilePath],
|
|
1819
|
+
cleanup: () => {
|
|
1820
|
+
try {
|
|
1821
|
+
rmSync(profileDir, { force: true, recursive: true });
|
|
1822
|
+
} catch {
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
function resolveSpawnCommand(command, args, policy) {
|
|
1828
|
+
const platform = detectPlatform();
|
|
1829
|
+
const cleanupFns = [];
|
|
1830
|
+
if (platform === "darwin" && policy.filesystem) {
|
|
1831
|
+
const sandbox = createMacOSSandbox(policy);
|
|
1832
|
+
cleanupFns.push(sandbox.cleanup);
|
|
1833
|
+
return {
|
|
1834
|
+
cleanupFns,
|
|
1835
|
+
spawnArgs: [...sandbox.args, command, ...args],
|
|
1836
|
+
spawnCommand: "sandbox-exec"
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
if (platform === "linux" && policy.filesystem) {
|
|
1840
|
+
console.error(chalk2.yellow("[clamp] Linux filesystem sandbox: Landlock integration pending"));
|
|
1841
|
+
} else if (policy.filesystem) {
|
|
1842
|
+
console.error(chalk2.yellow(`[clamp] OS filesystem sandbox not available on ${platform}`));
|
|
1843
|
+
}
|
|
1844
|
+
return {
|
|
1845
|
+
cleanupFns,
|
|
1846
|
+
spawnArgs: args,
|
|
1847
|
+
spawnCommand: command
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
function cleanEnvRecord(env) {
|
|
1851
|
+
const clean = {};
|
|
1852
|
+
for (const [k, v] of Object.entries(env)) {
|
|
1853
|
+
if (v !== void 0) clean[k] = v;
|
|
1854
|
+
}
|
|
1855
|
+
return clean;
|
|
1856
|
+
}
|
|
1857
|
+
function spawnWithRenderedPty(spawnCommand, spawnArgs, env) {
|
|
1858
|
+
try {
|
|
1859
|
+
const pty = require_lib();
|
|
1860
|
+
const renderer = createTerminalRenderer();
|
|
1861
|
+
const innerRows = (process.stdout.rows ?? 24) - 2;
|
|
1862
|
+
const ptyProcess = pty.spawn(spawnCommand, spawnArgs, {
|
|
1863
|
+
cols: process.stdout.columns ?? 80,
|
|
1864
|
+
cwd: process.cwd(),
|
|
1865
|
+
env,
|
|
1866
|
+
name: process.env.TERM ?? "xterm-256color",
|
|
1867
|
+
rows: innerRows
|
|
1868
|
+
});
|
|
1869
|
+
let paused = false;
|
|
1870
|
+
ptyProcess.onData((data) => {
|
|
1871
|
+
if (!paused) {
|
|
1872
|
+
renderer.write(data);
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
1876
|
+
process.stdin.resume();
|
|
1877
|
+
const onStdin = (data) => {
|
|
1878
|
+
ptyProcess.write(data.toString());
|
|
1879
|
+
};
|
|
1880
|
+
process.stdin.on("data", onStdin);
|
|
1881
|
+
const onResize = () => {
|
|
1882
|
+
const newInnerRows = (process.stdout.rows ?? 24) - 2;
|
|
1883
|
+
ptyProcess.resize(process.stdout.columns ?? 80, newInnerRows);
|
|
1884
|
+
};
|
|
1885
|
+
process.stdout.on("resize", onResize);
|
|
1886
|
+
const exitCode = new Promise((resolve) => {
|
|
1887
|
+
ptyProcess.onExit(({ exitCode: code }) => {
|
|
1888
|
+
process.stdin.removeListener("data", onStdin);
|
|
1889
|
+
process.stdout.removeListener("resize", onResize);
|
|
1890
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
1891
|
+
process.stdin.pause();
|
|
1892
|
+
renderer.destroy();
|
|
1893
|
+
resolve(code);
|
|
1894
|
+
});
|
|
1895
|
+
});
|
|
1896
|
+
return {
|
|
1897
|
+
cleanup: () => {
|
|
1898
|
+
},
|
|
1899
|
+
exitCode,
|
|
1900
|
+
ok: true,
|
|
1901
|
+
pause: () => {
|
|
1902
|
+
paused = true;
|
|
1903
|
+
},
|
|
1904
|
+
renderer,
|
|
1905
|
+
resume: () => {
|
|
1906
|
+
paused = false;
|
|
1907
|
+
renderer.render();
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
} catch {
|
|
1911
|
+
return { ok: false };
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
function spawnFallback(spawnCommand, spawnArgs, env) {
|
|
1915
|
+
console.error(chalk2.yellow("[clamp] PTY unavailable, falling back to basic stdio passthrough"));
|
|
1916
|
+
const child = spawn(spawnCommand, spawnArgs, { env, stdio: "inherit" });
|
|
1917
|
+
const exitCode = new Promise((resolve) => {
|
|
1918
|
+
child.on("close", (code) => resolve(code));
|
|
1919
|
+
child.on("error", () => resolve(1));
|
|
1920
|
+
});
|
|
1921
|
+
const noop = () => {
|
|
1922
|
+
};
|
|
1923
|
+
return {
|
|
1924
|
+
cleanup: noop,
|
|
1925
|
+
exitCode,
|
|
1926
|
+
pause: noop,
|
|
1927
|
+
renderer: void 0,
|
|
1928
|
+
resume: noop
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
function spawnSandboxed(options) {
|
|
1932
|
+
const { env, policy } = options;
|
|
1933
|
+
const {
|
|
1934
|
+
spawnCommand,
|
|
1935
|
+
spawnArgs,
|
|
1936
|
+
cleanupFns
|
|
1937
|
+
} = resolveSpawnCommand(options.command, options.args, policy);
|
|
1938
|
+
const cleanEnv = cleanEnvRecord(env);
|
|
1939
|
+
const ptyResult = spawnWithRenderedPty(spawnCommand, spawnArgs, cleanEnv);
|
|
1940
|
+
const result = ptyResult.ok ? ptyResult : spawnFallback(spawnCommand, spawnArgs, env);
|
|
1941
|
+
const originalCleanup = result.cleanup;
|
|
1942
|
+
return {
|
|
1943
|
+
...result,
|
|
1944
|
+
cleanup: () => {
|
|
1945
|
+
originalCleanup();
|
|
1946
|
+
for (const fn of cleanupFns) fn();
|
|
1947
|
+
}
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
// src/actions/clamp/shellEnvSetup.ts
|
|
1952
|
+
import {
|
|
1953
|
+
mkdtempSync as mkdtempSync2,
|
|
1954
|
+
rmSync as rmSync2,
|
|
1955
|
+
writeFileSync as writeFileSync3
|
|
1956
|
+
} from "fs";
|
|
1957
|
+
import { homedir, tmpdir as tmpdir2 } from "os";
|
|
1958
|
+
import path3 from "path";
|
|
1959
|
+
function createShellEnvOverrides(shimDir) {
|
|
1960
|
+
const tmpDir = mkdtempSync2(path3.join(tmpdir2(), "aries-clamp-env-"));
|
|
1961
|
+
const home = homedir();
|
|
1962
|
+
const zshenv = [
|
|
1963
|
+
"# Aries Clamp: source real .zshenv then re-prepend shim dir",
|
|
1964
|
+
`[ -f "${home}/.zshenv" ] && ZDOTDIR="${home}" source "${home}/.zshenv"`,
|
|
1965
|
+
`export PATH="${shimDir}:\${PATH}"`
|
|
1966
|
+
].join("\n") + "\n";
|
|
1967
|
+
writeFileSync3(path3.join(tmpDir, ".zshenv"), zshenv, "utf8");
|
|
1968
|
+
const zshrc = [
|
|
1969
|
+
"# Aries Clamp: source real .zshrc then re-prepend shim dir",
|
|
1970
|
+
`[ -f "${home}/.zshrc" ] && ZDOTDIR="${home}" source "${home}/.zshrc"`,
|
|
1971
|
+
`export PATH="${shimDir}:\${PATH}"`
|
|
1972
|
+
].join("\n") + "\n";
|
|
1973
|
+
writeFileSync3(path3.join(tmpDir, ".zshrc"), zshrc, "utf8");
|
|
1974
|
+
const zprofile = [
|
|
1975
|
+
"# Aries Clamp: source real .zprofile then re-prepend shim dir",
|
|
1976
|
+
`[ -f "${home}/.zprofile" ] && ZDOTDIR="${home}" source "${home}/.zprofile"`,
|
|
1977
|
+
`export PATH="${shimDir}:\${PATH}"`
|
|
1978
|
+
].join("\n") + "\n";
|
|
1979
|
+
writeFileSync3(path3.join(tmpDir, ".zprofile"), zprofile, "utf8");
|
|
1980
|
+
const bashEnv = [
|
|
1981
|
+
"# Aries Clamp: prepend shim dir to PATH",
|
|
1982
|
+
`export PATH="${shimDir}:\${PATH}"`
|
|
1983
|
+
].join("\n") + "\n";
|
|
1984
|
+
const bashEnvPath = path3.join(tmpDir, "bash_env.sh");
|
|
1985
|
+
writeFileSync3(bashEnvPath, bashEnv, "utf8");
|
|
1986
|
+
const bashrc = [
|
|
1987
|
+
"# Aries Clamp: source real .bashrc then re-prepend shim dir",
|
|
1988
|
+
`[ -f "${home}/.bashrc" ] && source "${home}/.bashrc"`,
|
|
1989
|
+
`export PATH="${shimDir}:\${PATH}"`
|
|
1990
|
+
].join("\n") + "\n";
|
|
1991
|
+
writeFileSync3(path3.join(tmpDir, ".bashrc"), bashrc, "utf8");
|
|
1992
|
+
return {
|
|
1993
|
+
cleanup: () => {
|
|
1994
|
+
try {
|
|
1995
|
+
rmSync2(tmpDir, { force: true, recursive: true });
|
|
1996
|
+
} catch {
|
|
1997
|
+
}
|
|
1998
|
+
},
|
|
1999
|
+
env: {
|
|
2000
|
+
BASH_ENV: bashEnvPath,
|
|
2001
|
+
ENV: bashEnvPath,
|
|
2002
|
+
ZDOTDIR: tmpDir
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
// src/actions/clamp/shimGenerator.ts
|
|
2008
|
+
import {
|
|
2009
|
+
chmodSync,
|
|
2010
|
+
existsSync as existsSync2,
|
|
2011
|
+
mkdtempSync as mkdtempSync3,
|
|
2012
|
+
writeFileSync as writeFileSync4
|
|
2013
|
+
} from "fs";
|
|
2014
|
+
import { createRequire } from "module";
|
|
2015
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
2016
|
+
import path4 from "path";
|
|
2017
|
+
var DANGEROUS_COMMANDS = [
|
|
2018
|
+
"chmod",
|
|
2019
|
+
"chown",
|
|
2020
|
+
"curl",
|
|
2021
|
+
"docker",
|
|
2022
|
+
"kill",
|
|
2023
|
+
"killall",
|
|
2024
|
+
"mv",
|
|
2025
|
+
"pkill",
|
|
2026
|
+
"rm",
|
|
2027
|
+
"rmdir",
|
|
2028
|
+
"sudo",
|
|
2029
|
+
"wget"
|
|
2030
|
+
];
|
|
2031
|
+
function getGatekeeperPath() {
|
|
2032
|
+
const require2 = createRequire(import.meta.url);
|
|
2033
|
+
try {
|
|
2034
|
+
const pluginPkg = require2.resolve("@xylabs/aries-clamp-plugin/package.json");
|
|
2035
|
+
return path4.join(path4.dirname(pluginPkg), "dist", "shim", "gatekeeper.mjs");
|
|
2036
|
+
} catch {
|
|
2037
|
+
const candidates = [
|
|
2038
|
+
path4.resolve("packages", "clamp-plugin", "dist", "shim", "gatekeeper.mjs"),
|
|
2039
|
+
path4.resolve("node_modules", "@xylabs", "aries-clamp-plugin", "dist", "shim", "gatekeeper.mjs")
|
|
2040
|
+
];
|
|
2041
|
+
for (const candidate of candidates) {
|
|
2042
|
+
if (existsSync2(candidate)) return candidate;
|
|
2043
|
+
}
|
|
2044
|
+
throw new Error("Could not find gatekeeper.mjs \u2014 is @xylabs/aries-clamp-plugin built?");
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
async function generateShimDirectory(policy) {
|
|
2048
|
+
const shimDir = mkdtempSync3(path4.join(tmpdir3(), "aries-clamp-"));
|
|
2049
|
+
const gatekeeperPath = getGatekeeperPath();
|
|
2050
|
+
const nodePath = process.execPath;
|
|
2051
|
+
const commands = /* @__PURE__ */ new Set();
|
|
2052
|
+
const processRules = policy.process;
|
|
2053
|
+
if (processRules) {
|
|
2054
|
+
for (const cmd of processRules.allow ?? []) commands.add(cmd);
|
|
2055
|
+
for (const cmd of processRules.prompt ?? []) commands.add(cmd);
|
|
2056
|
+
for (const cmd of processRules.deny ?? []) commands.add(cmd);
|
|
2057
|
+
}
|
|
2058
|
+
for (const cmd of DANGEROUS_COMMANDS) {
|
|
2059
|
+
commands.add(cmd);
|
|
2060
|
+
}
|
|
2061
|
+
for (const cmd of commands) {
|
|
2062
|
+
const shimPath = path4.join(shimDir, cmd);
|
|
2063
|
+
const script = `#!/bin/sh
|
|
2064
|
+
exec "${nodePath}" "${gatekeeperPath}" "${cmd}" "$@"
|
|
2065
|
+
`;
|
|
2066
|
+
writeFileSync4(shimPath, script, "utf8");
|
|
2067
|
+
chmodSync(shimPath, 493);
|
|
2068
|
+
}
|
|
2069
|
+
return shimDir;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
// src/actions/clamp/runClamped.ts
|
|
2073
|
+
function printDryRun(command, args, policy, auditEnabled) {
|
|
2074
|
+
console.log(chalk3.cyan("\n[clamp] Dry run \u2014 would sandbox with:\n"));
|
|
2075
|
+
console.log(chalk3.white(` Command: ${command} ${args.join(" ")}`));
|
|
2076
|
+
console.log(chalk3.white(` Policy: ${policy.name}`));
|
|
2077
|
+
console.log(chalk3.white(` Default action: ${policy.defaultAction ?? "prompt"}`));
|
|
2078
|
+
console.log(chalk3.white(` Audit: ${auditEnabled ? "enabled" : "disabled"}`));
|
|
2079
|
+
if (policy.process) {
|
|
2080
|
+
console.log(chalk3.green(` Allowed: ${policy.process.allow?.join(", ") ?? "(none)"}`));
|
|
2081
|
+
console.log(chalk3.yellow(` Prompted: ${policy.process.prompt?.join(", ") ?? "(none)"}`));
|
|
2082
|
+
console.log(chalk3.red(` Denied: ${policy.process.deny?.join(", ") ?? "(none)"}`));
|
|
2083
|
+
}
|
|
2084
|
+
if (policy.filesystem) {
|
|
2085
|
+
console.log(chalk3.white(" Filesystem sandbox: enabled"));
|
|
2086
|
+
}
|
|
2087
|
+
console.log("");
|
|
2088
|
+
}
|
|
2089
|
+
async function resolveDecision(command, args, alwaysAllow, renderer) {
|
|
2090
|
+
const answer = await promptUser(command, args, renderer);
|
|
2091
|
+
if (answer === "allow-always") {
|
|
2092
|
+
alwaysAllow.add(command);
|
|
2093
|
+
return "prompted-allow";
|
|
2094
|
+
}
|
|
2095
|
+
return answer === "allow-once" ? "prompted-allow" : "prompted-deny";
|
|
2096
|
+
}
|
|
2097
|
+
function createPermissionHandler(policy, sessionId, auditEnabled, alwaysAllow, sandboxRef) {
|
|
2098
|
+
const defaultAction = policy.defaultAction ?? "prompt";
|
|
2099
|
+
return async (request) => {
|
|
2100
|
+
const {
|
|
2101
|
+
command: reqCommand,
|
|
2102
|
+
args: reqArgs,
|
|
2103
|
+
requestId
|
|
2104
|
+
} = request;
|
|
2105
|
+
if (alwaysAllow.has(reqCommand)) {
|
|
2106
|
+
if (auditEnabled) {
|
|
2107
|
+
logClampPermission({
|
|
2108
|
+
args: reqArgs,
|
|
2109
|
+
command: reqCommand,
|
|
2110
|
+
decision: "allowed",
|
|
2111
|
+
policy,
|
|
2112
|
+
sessionId
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
return {
|
|
2116
|
+
allowed: true,
|
|
2117
|
+
requestId,
|
|
2118
|
+
type: "permission-response"
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
const level = matchProcess(reqCommand, policy.process, defaultAction);
|
|
2122
|
+
if (level === "allow" || level === "deny") {
|
|
2123
|
+
const decision2 = level === "allow" ? "allowed" : "denied";
|
|
2124
|
+
if (auditEnabled) {
|
|
2125
|
+
logClampPermission({
|
|
2126
|
+
args: reqArgs,
|
|
2127
|
+
command: reqCommand,
|
|
2128
|
+
decision: decision2,
|
|
2129
|
+
policy,
|
|
2130
|
+
sessionId
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
return {
|
|
2134
|
+
allowed: level === "allow",
|
|
2135
|
+
reason: level === "deny" ? `Policy "${policy.name}": deny` : void 0,
|
|
2136
|
+
requestId,
|
|
2137
|
+
type: "permission-response"
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
sandboxRef.sandbox?.pause();
|
|
2141
|
+
const decision = await resolveDecision(reqCommand, reqArgs, alwaysAllow, sandboxRef.sandbox?.renderer);
|
|
2142
|
+
sandboxRef.sandbox?.resume();
|
|
2143
|
+
if (auditEnabled) {
|
|
2144
|
+
logClampPermission({
|
|
2145
|
+
args: reqArgs,
|
|
2146
|
+
command: reqCommand,
|
|
2147
|
+
decision,
|
|
2148
|
+
policy,
|
|
2149
|
+
sessionId
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
const allowed = decision === "prompted-allow";
|
|
2153
|
+
return {
|
|
2154
|
+
allowed,
|
|
2155
|
+
reason: allowed ? void 0 : `Policy "${policy.name}": denied by user`,
|
|
2156
|
+
requestId,
|
|
2157
|
+
type: "permission-response"
|
|
2158
|
+
};
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
function buildChildEnv(shimDir, socketPath, sessionId, shellEnv) {
|
|
2162
|
+
const originalPath = process.env.PATH ?? "";
|
|
2163
|
+
return {
|
|
2164
|
+
...process.env,
|
|
2165
|
+
...shellEnv,
|
|
2166
|
+
PATH: `${shimDir}${path5.delimiter}${originalPath}`,
|
|
2167
|
+
[CLAMP_IPC_ENV]: socketPath,
|
|
2168
|
+
[CLAMP_ORIGINAL_PATH_ENV]: originalPath,
|
|
2169
|
+
[CLAMP_SESSION_ENV]: sessionId
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
function cleanupResources(socketPath, shimDir) {
|
|
2173
|
+
try {
|
|
2174
|
+
unlinkSync(socketPath);
|
|
2175
|
+
} catch {
|
|
2176
|
+
}
|
|
2177
|
+
try {
|
|
2178
|
+
rmSync3(shimDir, { force: true, recursive: true });
|
|
2179
|
+
} catch {
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
function parseArgs(argv) {
|
|
2183
|
+
return {
|
|
2184
|
+
args: argv.args ?? [],
|
|
2185
|
+
auditEnabled: argv.audit !== false,
|
|
2186
|
+
command: argv.command,
|
|
2187
|
+
dryRun: argv["dry-run"] ?? false,
|
|
2188
|
+
policyOption: argv.policy
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
async function runClamped(argv) {
|
|
2192
|
+
const {
|
|
2193
|
+
command,
|
|
2194
|
+
args,
|
|
2195
|
+
policyOption,
|
|
2196
|
+
auditEnabled,
|
|
2197
|
+
dryRun
|
|
2198
|
+
} = parseArgs(argv);
|
|
2199
|
+
let policy;
|
|
2200
|
+
try {
|
|
2201
|
+
policy = loadPolicy({ path: policyOption });
|
|
2202
|
+
} catch (err) {
|
|
2203
|
+
console.error(chalk3.red(`Failed to load policy: ${String(err)}`));
|
|
2204
|
+
process.exit(1);
|
|
2205
|
+
}
|
|
2206
|
+
if (dryRun) {
|
|
2207
|
+
printDryRun(command, args, policy, auditEnabled);
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
const sessionId = randomUUID();
|
|
2211
|
+
const shimDir = await generateShimDirectory(policy);
|
|
2212
|
+
const shellOverrides = createShellEnvOverrides(shimDir);
|
|
2213
|
+
const socketPath = path5.join(tmpdir4(), `aries-clamp-${process.pid}-${randomUUID().slice(0, 8)}.sock`);
|
|
2214
|
+
const sandboxRef = {};
|
|
2215
|
+
const handler = createPermissionHandler(policy, sessionId, auditEnabled, /* @__PURE__ */ new Set(), sandboxRef);
|
|
2216
|
+
const ipcHandle = createIpcServer({ onPermissionRequest: handler, socketPath });
|
|
2217
|
+
await ipcHandle.listening;
|
|
2218
|
+
if (auditEnabled) logClampStart({
|
|
2219
|
+
command,
|
|
2220
|
+
policy,
|
|
2221
|
+
sessionId
|
|
2222
|
+
});
|
|
2223
|
+
console.error(chalk3.cyan(`[clamp] Session ${sessionId.slice(0, 8)} \u2014 policy: ${policy.name}`));
|
|
2224
|
+
const childEnv = buildChildEnv(shimDir, socketPath, sessionId, shellOverrides.env);
|
|
2225
|
+
const sandbox = spawnSandboxed({
|
|
2226
|
+
args,
|
|
2227
|
+
command,
|
|
2228
|
+
env: childEnv,
|
|
2229
|
+
policy
|
|
2230
|
+
});
|
|
2231
|
+
sandboxRef.sandbox = sandbox;
|
|
2232
|
+
sandbox.renderer?.setStatusLine(`[clamp] policy: ${policy.name} | allowed: 0 | denied: 0`);
|
|
2233
|
+
const exitCode = await sandbox.exitCode;
|
|
2234
|
+
sandbox.cleanup();
|
|
2235
|
+
shellOverrides.cleanup();
|
|
2236
|
+
ipcHandle.close();
|
|
2237
|
+
cleanupResources(socketPath, shimDir);
|
|
2238
|
+
if (auditEnabled) logClampStop({ exitCode, sessionId });
|
|
2239
|
+
console.error(chalk3.gray(`
|
|
2240
|
+
[clamp] Session ended (exit code: ${exitCode})`));
|
|
2241
|
+
process.exit(exitCode ?? 1);
|
|
2242
|
+
}
|
|
2243
|
+
export {
|
|
2244
|
+
createIpcServer,
|
|
2245
|
+
createShellEnvOverrides,
|
|
2246
|
+
createTerminalRenderer,
|
|
2247
|
+
generateShimDirectory,
|
|
2248
|
+
initPolicy,
|
|
2249
|
+
listPolicies,
|
|
2250
|
+
logClampPermission,
|
|
2251
|
+
logClampStart,
|
|
2252
|
+
logClampStop,
|
|
2253
|
+
promptUser,
|
|
2254
|
+
runClamped,
|
|
2255
|
+
showPolicy,
|
|
2256
|
+
spawnSandboxed
|
|
2257
|
+
};
|
|
2258
|
+
//# sourceMappingURL=index.mjs.map
|