@agirails/sdk 2.0.1-beta → 2.0.2
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/LICENSE +190 -0
- package/README.md +116 -108
- package/bin/actp +10 -0
- package/dist/ACTPClient.d.ts +456 -33
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +477 -93
- package/dist/ACTPClient.js.map +1 -1
- package/dist/abi/AgentRegistry.json +782 -0
- package/dist/abi/EscrowVault.json +106 -38
- package/dist/abi/IdentityRegistry.json +316 -0
- package/dist/adapters/BaseAdapter.d.ts +231 -0
- package/dist/adapters/BaseAdapter.d.ts.map +1 -0
- package/dist/adapters/BaseAdapter.js +393 -0
- package/dist/adapters/BaseAdapter.js.map +1 -0
- package/dist/adapters/BeginnerAdapter.d.ts +152 -0
- package/dist/adapters/BeginnerAdapter.d.ts.map +1 -0
- package/dist/adapters/BeginnerAdapter.js +168 -0
- package/dist/adapters/BeginnerAdapter.js.map +1 -0
- package/dist/adapters/IntermediateAdapter.d.ts +211 -0
- package/dist/adapters/IntermediateAdapter.d.ts.map +1 -0
- package/dist/adapters/IntermediateAdapter.js +260 -0
- package/dist/adapters/IntermediateAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +15 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +26 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/builders/DeliveryProofBuilder.d.ts +60 -1
- package/dist/builders/DeliveryProofBuilder.d.ts.map +1 -1
- package/dist/builders/DeliveryProofBuilder.js +81 -5
- package/dist/builders/DeliveryProofBuilder.js.map +1 -1
- package/dist/builders/QuoteBuilder.d.ts +101 -0
- package/dist/builders/QuoteBuilder.d.ts.map +1 -1
- package/dist/builders/QuoteBuilder.js +120 -3
- package/dist/builders/QuoteBuilder.js.map +1 -1
- package/dist/builders/index.d.ts +4 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +4 -0
- package/dist/builders/index.js.map +1 -1
- package/dist/cli/commands/balance.d.ts +13 -0
- package/dist/cli/commands/balance.d.ts.map +1 -0
- package/dist/cli/commands/balance.js +89 -0
- package/dist/cli/commands/balance.js.map +1 -0
- package/dist/cli/commands/batch.d.ts +24 -0
- package/dist/cli/commands/batch.d.ts.map +1 -0
- package/dist/cli/commands/batch.js +424 -0
- package/dist/cli/commands/batch.js.map +1 -0
- package/dist/cli/commands/config.d.ts +13 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +192 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/init.d.ts +19 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +143 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/mint.d.ts +13 -0
- package/dist/cli/commands/mint.d.ts.map +1 -0
- package/dist/cli/commands/mint.js +91 -0
- package/dist/cli/commands/mint.js.map +1 -0
- package/dist/cli/commands/pay.d.ts +18 -0
- package/dist/cli/commands/pay.d.ts.map +1 -0
- package/dist/cli/commands/pay.js +87 -0
- package/dist/cli/commands/pay.js.map +1 -0
- package/dist/cli/commands/simulate.d.ts +32 -0
- package/dist/cli/commands/simulate.d.ts.map +1 -0
- package/dist/cli/commands/simulate.js +290 -0
- package/dist/cli/commands/simulate.js.map +1 -0
- package/dist/cli/commands/time.d.ts +29 -0
- package/dist/cli/commands/time.d.ts.map +1 -0
- package/dist/cli/commands/time.js +252 -0
- package/dist/cli/commands/time.js.map +1 -0
- package/dist/cli/commands/tx.d.ts +16 -0
- package/dist/cli/commands/tx.d.ts.map +1 -0
- package/dist/cli/commands/tx.js +379 -0
- package/dist/cli/commands/tx.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +20 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +160 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/index.d.ts +17 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +104 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/client.d.ts +70 -0
- package/dist/cli/utils/client.d.ts.map +1 -0
- package/dist/cli/utils/client.js +240 -0
- package/dist/cli/utils/client.js.map +1 -0
- package/dist/cli/utils/config.d.ts +91 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +240 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/cli/utils/output.d.ts +174 -0
- package/dist/cli/utils/output.d.ts.map +1 -0
- package/dist/cli/utils/output.js +380 -0
- package/dist/cli/utils/output.js.map +1 -0
- package/dist/config/networks.d.ts +28 -0
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +60 -12
- package/dist/config/networks.js.map +1 -1
- package/dist/errors/index.d.ts +165 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +260 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +61 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -36
- package/dist/index.js.map +1 -1
- package/dist/level0/Provider.d.ts +106 -0
- package/dist/level0/Provider.d.ts.map +1 -0
- package/dist/level0/Provider.js +10 -0
- package/dist/level0/Provider.js.map +1 -0
- package/dist/level0/ServiceDirectory.d.ts +74 -0
- package/dist/level0/ServiceDirectory.d.ts.map +1 -0
- package/dist/level0/ServiceDirectory.js +122 -0
- package/dist/level0/ServiceDirectory.js.map +1 -0
- package/dist/level0/index.d.ts +10 -0
- package/dist/level0/index.d.ts.map +1 -0
- package/dist/level0/index.js +15 -0
- package/dist/level0/index.js.map +1 -0
- package/dist/level0/provide.d.ts +51 -0
- package/dist/level0/provide.d.ts.map +1 -0
- package/dist/level0/provide.js +113 -0
- package/dist/level0/provide.js.map +1 -0
- package/dist/level0/request.d.ts +53 -0
- package/dist/level0/request.d.ts.map +1 -0
- package/dist/level0/request.js +462 -0
- package/dist/level0/request.js.map +1 -0
- package/dist/level1/Agent.d.ts +472 -0
- package/dist/level1/Agent.d.ts.map +1 -0
- package/dist/level1/Agent.js +1091 -0
- package/dist/level1/Agent.js.map +1 -0
- package/dist/level1/index.d.ts +10 -0
- package/dist/level1/index.d.ts.map +1 -0
- package/dist/level1/index.js +30 -0
- package/dist/level1/index.js.map +1 -0
- package/dist/level1/pricing/PriceCalculator.d.ts +62 -0
- package/dist/level1/pricing/PriceCalculator.d.ts.map +1 -0
- package/dist/level1/pricing/PriceCalculator.js +237 -0
- package/dist/level1/pricing/PriceCalculator.js.map +1 -0
- package/dist/level1/pricing/PricingStrategy.d.ts +179 -0
- package/dist/level1/pricing/PricingStrategy.d.ts.map +1 -0
- package/dist/level1/pricing/PricingStrategy.js +11 -0
- package/dist/level1/pricing/PricingStrategy.js.map +1 -0
- package/dist/level1/types/Job.d.ts +166 -0
- package/dist/level1/types/Job.d.ts.map +1 -0
- package/dist/level1/types/Job.js +11 -0
- package/dist/level1/types/Job.js.map +1 -0
- package/dist/level1/types/Options.d.ts +258 -0
- package/dist/level1/types/Options.d.ts.map +1 -0
- package/dist/level1/types/Options.js +8 -0
- package/dist/level1/types/Options.js.map +1 -0
- package/dist/level1/types/index.d.ts +8 -0
- package/dist/level1/types/index.d.ts.map +1 -0
- package/dist/level1/types/index.js +8 -0
- package/dist/level1/types/index.js.map +1 -0
- package/dist/protocol/ACTPKernel.d.ts +229 -2
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +367 -33
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/protocol/AgentRegistry.d.ts +177 -0
- package/dist/protocol/AgentRegistry.d.ts.map +1 -0
- package/dist/protocol/AgentRegistry.js +449 -0
- package/dist/protocol/AgentRegistry.js.map +1 -0
- package/dist/protocol/DIDManager.d.ts +289 -0
- package/dist/protocol/DIDManager.d.ts.map +1 -0
- package/dist/protocol/DIDManager.js +481 -0
- package/dist/protocol/DIDManager.js.map +1 -0
- package/dist/protocol/DIDResolver.d.ts +236 -0
- package/dist/protocol/DIDResolver.d.ts.map +1 -0
- package/dist/protocol/DIDResolver.js +495 -0
- package/dist/protocol/DIDResolver.js.map +1 -0
- package/dist/protocol/EASHelper.d.ts +57 -2
- package/dist/protocol/EASHelper.d.ts.map +1 -1
- package/dist/protocol/EASHelper.js +230 -37
- package/dist/protocol/EASHelper.js.map +1 -1
- package/dist/protocol/EscrowVault.d.ts +93 -2
- package/dist/protocol/EscrowVault.d.ts.map +1 -1
- package/dist/protocol/EscrowVault.js +122 -33
- package/dist/protocol/EscrowVault.js.map +1 -1
- package/dist/protocol/EventMonitor.d.ts +45 -1
- package/dist/protocol/EventMonitor.d.ts.map +1 -1
- package/dist/protocol/EventMonitor.js +64 -8
- package/dist/protocol/EventMonitor.js.map +1 -1
- package/dist/protocol/MessageSigner.d.ts +116 -2
- package/dist/protocol/MessageSigner.d.ts.map +1 -1
- package/dist/protocol/MessageSigner.js +215 -9
- package/dist/protocol/MessageSigner.js.map +1 -1
- package/dist/protocol/ProofGenerator.d.ts +93 -0
- package/dist/protocol/ProofGenerator.d.ts.map +1 -1
- package/dist/protocol/ProofGenerator.js +194 -9
- package/dist/protocol/ProofGenerator.js.map +1 -1
- package/dist/protocol/QuoteBuilder.d.ts +8 -0
- package/dist/protocol/QuoteBuilder.d.ts.map +1 -1
- package/dist/protocol/QuoteBuilder.js +8 -0
- package/dist/protocol/QuoteBuilder.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts +360 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -0
- package/dist/runtime/BlockchainRuntime.js +767 -0
- package/dist/runtime/BlockchainRuntime.js.map +1 -0
- package/dist/runtime/IACTPRuntime.d.ts +271 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -0
- package/dist/runtime/IACTPRuntime.js +15 -0
- package/dist/runtime/IACTPRuntime.js.map +1 -0
- package/dist/runtime/MockRuntime.d.ts +445 -0
- package/dist/runtime/MockRuntime.d.ts.map +1 -0
- package/dist/runtime/MockRuntime.js +1065 -0
- package/dist/runtime/MockRuntime.js.map +1 -0
- package/dist/runtime/MockStateManager.d.ts +233 -0
- package/dist/runtime/MockStateManager.d.ts.map +1 -0
- package/dist/runtime/MockStateManager.js +533 -0
- package/dist/runtime/MockStateManager.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +42 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/types/MockState.d.ts +167 -0
- package/dist/runtime/types/MockState.d.ts.map +1 -0
- package/dist/runtime/types/MockState.js +43 -0
- package/dist/runtime/types/MockState.js.map +1 -0
- package/dist/types/agent.d.ts +76 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +8 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/did.d.ts +192 -0
- package/dist/types/did.d.ts.map +1 -0
- package/dist/types/did.js +38 -0
- package/dist/types/did.js.map +1 -0
- package/dist/types/eip712.d.ts +34 -0
- package/dist/types/eip712.d.ts.map +1 -1
- package/dist/types/eip712.js +31 -5
- package/dist/types/eip712.js.map +1 -1
- package/dist/types/escrow.d.ts +17 -10
- package/dist/types/escrow.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/message.d.ts +32 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js +4 -0
- package/dist/types/message.js.map +1 -1
- package/dist/types/state.d.ts +28 -0
- package/dist/types/state.d.ts.map +1 -1
- package/dist/types/state.js +37 -6
- package/dist/types/state.js.map +1 -1
- package/dist/types/transaction.d.ts +17 -0
- package/dist/types/transaction.d.ts.map +1 -1
- package/dist/utils/ErrorRecoveryGuide.d.ts +125 -0
- package/dist/utils/ErrorRecoveryGuide.d.ts.map +1 -0
- package/dist/utils/ErrorRecoveryGuide.js +579 -0
- package/dist/utils/ErrorRecoveryGuide.js.map +1 -0
- package/dist/utils/Helpers.d.ts +453 -0
- package/dist/utils/Helpers.d.ts.map +1 -0
- package/dist/utils/Helpers.js +623 -0
- package/dist/utils/Helpers.js.map +1 -0
- package/dist/utils/IPFSClient.d.ts +113 -0
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +128 -7
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/utils/Logger.d.ts +195 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +382 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/NonceManager.d.ts +234 -1
- package/dist/utils/NonceManager.d.ts.map +1 -1
- package/dist/utils/NonceManager.js +372 -7
- package/dist/utils/NonceManager.js.map +1 -1
- package/dist/utils/RateLimiter.d.ts +253 -0
- package/dist/utils/RateLimiter.d.ts.map +1 -0
- package/dist/utils/RateLimiter.js +424 -0
- package/dist/utils/RateLimiter.js.map +1 -0
- package/dist/utils/ReceivedNonceTracker.d.ts +175 -0
- package/dist/utils/ReceivedNonceTracker.d.ts.map +1 -1
- package/dist/utils/ReceivedNonceTracker.js +261 -5
- package/dist/utils/ReceivedNonceTracker.js.map +1 -1
- package/dist/utils/SDKLifecycle.d.ts +156 -0
- package/dist/utils/SDKLifecycle.d.ts.map +1 -0
- package/dist/utils/SDKLifecycle.js +347 -0
- package/dist/utils/SDKLifecycle.js.map +1 -0
- package/dist/utils/SecureNonce.d.ts +57 -0
- package/dist/utils/SecureNonce.d.ts.map +1 -0
- package/dist/utils/SecureNonce.js +80 -0
- package/dist/utils/SecureNonce.js.map +1 -0
- package/dist/utils/Semaphore.d.ts +123 -0
- package/dist/utils/Semaphore.d.ts.map +1 -0
- package/dist/utils/Semaphore.js +247 -0
- package/dist/utils/Semaphore.js.map +1 -0
- package/dist/utils/UsedAttestationTracker.d.ts +167 -0
- package/dist/utils/UsedAttestationTracker.d.ts.map +1 -0
- package/dist/utils/UsedAttestationTracker.js +309 -0
- package/dist/utils/UsedAttestationTracker.js.map +1 -0
- package/dist/utils/canonicalJson.d.ts +22 -0
- package/dist/utils/canonicalJson.d.ts.map +1 -1
- package/dist/utils/canonicalJson.js +26 -3
- package/dist/utils/canonicalJson.js.map +1 -1
- package/dist/utils/computeTypeHash.d.ts +14 -0
- package/dist/utils/computeTypeHash.d.ts.map +1 -1
- package/dist/utils/computeTypeHash.js +19 -2
- package/dist/utils/computeTypeHash.js.map +1 -1
- package/dist/utils/fsSafe.d.ts +14 -0
- package/dist/utils/fsSafe.d.ts.map +1 -0
- package/dist/utils/fsSafe.js +89 -0
- package/dist/utils/fsSafe.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +51 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/security.d.ts +147 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +391 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/validation.d.ts +40 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +184 -7
- package/dist/utils/validation.js.map +1 -1
- package/package.json +54 -37
- package/src/ACTPClient.ts +692 -178
- package/src/abi/AgentRegistry.json +782 -0
- package/src/abi/EscrowVault.json +106 -38
- package/src/abi/IdentityRegistry.json +316 -0
- package/src/adapters/BaseAdapter.ts +473 -0
- package/src/adapters/BeginnerAdapter.ts +232 -0
- package/src/adapters/IntermediateAdapter.ts +316 -0
- package/src/adapters/index.ts +25 -0
- package/src/builders/DeliveryProofBuilder.ts +3 -2
- package/src/cli/commands/balance.ts +110 -0
- package/src/cli/commands/batch.ts +487 -0
- package/src/cli/commands/config.ts +231 -0
- package/src/cli/commands/init.ts +161 -0
- package/src/cli/commands/mint.ts +116 -0
- package/src/cli/commands/pay.ts +113 -0
- package/src/cli/commands/simulate.ts +345 -0
- package/src/cli/commands/time.ts +303 -0
- package/src/cli/commands/tx.ts +448 -0
- package/src/cli/commands/watch.ts +211 -0
- package/src/cli/index.ts +116 -0
- package/src/cli/utils/client.ts +249 -0
- package/src/cli/utils/config.ts +282 -0
- package/src/cli/utils/output.ts +465 -0
- package/src/config/networks.ts +32 -9
- package/src/errors/index.ts +298 -1
- package/src/index.ts +207 -71
- package/src/level0/Provider.ts +117 -0
- package/src/level0/ServiceDirectory.ts +131 -0
- package/src/level0/index.ts +10 -0
- package/src/level0/provide.ts +131 -0
- package/src/level0/request.ts +494 -0
- package/src/level1/Agent.ts +1432 -0
- package/src/level1/index.ts +10 -0
- package/src/level1/pricing/PriceCalculator.ts +255 -0
- package/src/level1/pricing/PricingStrategy.ts +198 -0
- package/src/level1/types/Job.ts +179 -0
- package/src/level1/types/Options.ts +291 -0
- package/src/level1/types/index.ts +8 -0
- package/src/protocol/ACTPKernel.ts +175 -23
- package/src/protocol/AgentRegistry.ts +559 -0
- package/src/protocol/DIDManager.ts +629 -0
- package/src/protocol/DIDResolver.ts +554 -0
- package/src/protocol/EASHelper.ts +230 -46
- package/src/protocol/EscrowVault.ts +68 -50
- package/src/protocol/EventMonitor.ts +44 -15
- package/src/protocol/MessageSigner.ts +193 -13
- package/src/protocol/ProofGenerator.ts +223 -4
- package/src/runtime/BlockchainRuntime.ts +993 -0
- package/src/runtime/IACTPRuntime.ts +284 -0
- package/src/runtime/MockRuntime.ts +1244 -0
- package/src/runtime/MockStateManager.ts +576 -0
- package/src/runtime/index.ts +25 -0
- package/src/runtime/types/MockState.ts +227 -0
- package/src/types/agent.ts +79 -0
- package/src/types/did.ts +223 -0
- package/src/types/escrow.ts +12 -11
- package/src/types/index.ts +5 -1
- package/src/types/state.ts +12 -3
- package/src/types/transaction.ts +4 -1
- package/src/utils/ErrorRecoveryGuide.ts +675 -0
- package/src/utils/Helpers.ts +688 -0
- package/src/utils/IPFSClient.ts +122 -5
- package/src/utils/Logger.ts +484 -0
- package/src/utils/NonceManager.ts +305 -8
- package/src/utils/RateLimiter.ts +534 -0
- package/src/utils/ReceivedNonceTracker.ts +170 -0
- package/src/utils/SDKLifecycle.ts +416 -0
- package/src/utils/SecureNonce.ts +78 -0
- package/src/utils/Semaphore.ts +276 -0
- package/src/utils/UsedAttestationTracker.ts +387 -0
- package/src/utils/fsSafe.ts +75 -0
- package/src/utils/index.ts +80 -0
- package/src/utils/security.ts +418 -0
- package/src/utils/validation.ts +164 -0
- package/src/__tests__/ProofGenerator.test.ts +0 -124
- package/src/__tests__/QuoteBuilder.test.ts +0 -516
- package/src/__tests__/StateMachine.test.ts +0 -82
- package/src/__tests__/builders/DeliveryProofBuilder.test.ts +0 -581
- package/src/__tests__/integration/ACTPClient.test.ts +0 -263
- package/src/__tests__/integration.test.ts +0 -289
- package/src/__tests__/protocol/EASHelper.test.ts +0 -472
- package/src/__tests__/protocol/EventMonitor.test.ts +0 -382
- package/src/__tests__/security/ACTPKernel.security.test.ts +0 -1167
- package/src/__tests__/security/EscrowVault.security.test.ts +0 -570
- package/src/__tests__/security/MessageSigner.security.test.ts +0 -286
- package/src/__tests__/security/NonceReplay.security.test.ts +0 -501
- package/src/__tests__/security/validation.security.test.ts +0 -376
- package/src/__tests__/utils/IPFSClient.test.ts +0 -262
- package/src/__tests__/utils/NonceManager.test.ts +0 -205
- package/src/__tests__/utils/canonicalJson.test.ts +0 -153
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI Configuration Management
|
|
4
|
+
*
|
|
5
|
+
* Handles reading/writing CLI configuration stored in .actp/config.json.
|
|
6
|
+
* Supports mock, testnet, and mainnet modes with mode-specific validation.
|
|
7
|
+
*
|
|
8
|
+
* @module cli/utils/config
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.addToGitignore = exports.validateConfigForMode = exports.validatePrivateKey = exports.validateAddress = exports.setConfigValue = exports.getConfigValue = exports.updateConfig = exports.saveConfig = exports.loadConfig = exports.isInitialized = exports.getConfigPath = exports.getActpDir = exports.CONFIG_DEFAULTS = void 0;
|
|
35
|
+
const fs = __importStar(require("fs"));
|
|
36
|
+
const path = __importStar(require("path"));
|
|
37
|
+
/**
|
|
38
|
+
* Default configuration values
|
|
39
|
+
*/
|
|
40
|
+
exports.CONFIG_DEFAULTS = {
|
|
41
|
+
mode: 'mock',
|
|
42
|
+
address: '',
|
|
43
|
+
version: '1.0',
|
|
44
|
+
};
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Paths
|
|
47
|
+
// ============================================================================
|
|
48
|
+
/**
|
|
49
|
+
* Get the .actp directory path
|
|
50
|
+
*/
|
|
51
|
+
function getActpDir(projectRoot = process.cwd()) {
|
|
52
|
+
return path.join(projectRoot, '.actp');
|
|
53
|
+
}
|
|
54
|
+
exports.getActpDir = getActpDir;
|
|
55
|
+
/**
|
|
56
|
+
* Get the config.json path
|
|
57
|
+
*/
|
|
58
|
+
function getConfigPath(projectRoot = process.cwd()) {
|
|
59
|
+
return path.join(getActpDir(projectRoot), 'config.json');
|
|
60
|
+
}
|
|
61
|
+
exports.getConfigPath = getConfigPath;
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Config Operations
|
|
64
|
+
// ============================================================================
|
|
65
|
+
/**
|
|
66
|
+
* Check if ACTP is initialized in the current directory
|
|
67
|
+
*/
|
|
68
|
+
function isInitialized(projectRoot = process.cwd()) {
|
|
69
|
+
return fs.existsSync(getConfigPath(projectRoot));
|
|
70
|
+
}
|
|
71
|
+
exports.isInitialized = isInitialized;
|
|
72
|
+
/**
|
|
73
|
+
* Load configuration from disk
|
|
74
|
+
*
|
|
75
|
+
* SECURITY: Warns about private key storage in config file.
|
|
76
|
+
*
|
|
77
|
+
* @throws Error if config doesn't exist or is corrupted
|
|
78
|
+
*/
|
|
79
|
+
function loadConfig(projectRoot = process.cwd()) {
|
|
80
|
+
const configPath = getConfigPath(projectRoot);
|
|
81
|
+
if (!fs.existsSync(configPath)) {
|
|
82
|
+
throw new Error('ACTP not initialized in this directory.\n' +
|
|
83
|
+
'Run "actp init" to initialize.');
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const raw = fs.readFileSync(configPath, 'utf-8');
|
|
87
|
+
const config = JSON.parse(raw);
|
|
88
|
+
// Validate required fields
|
|
89
|
+
if (!config.mode) {
|
|
90
|
+
throw new Error('Config missing required field: mode');
|
|
91
|
+
}
|
|
92
|
+
if (!config.address) {
|
|
93
|
+
throw new Error('Config missing required field: address');
|
|
94
|
+
}
|
|
95
|
+
// SECURITY FIX (L-2): Warn about private key storage in config file
|
|
96
|
+
if (config.privateKey) {
|
|
97
|
+
console.warn('\x1b[33m%s\x1b[0m', 'WARNING: Private key stored in config file.');
|
|
98
|
+
console.warn('\x1b[33m%s\x1b[0m', ' Consider using ACTP_PRIVATE_KEY environment variable instead.');
|
|
99
|
+
console.warn('\x1b[33m%s\x1b[0m', ' Run: export ACTP_PRIVATE_KEY=<your-key>');
|
|
100
|
+
}
|
|
101
|
+
return config;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error instanceof SyntaxError) {
|
|
105
|
+
throw new Error(`Config file corrupted: ${configPath}\n` +
|
|
106
|
+
'Delete it manually or run "actp init --force"');
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.loadConfig = loadConfig;
|
|
112
|
+
/**
|
|
113
|
+
* Save configuration to disk
|
|
114
|
+
*
|
|
115
|
+
* Creates .actp directory if it doesn't exist.
|
|
116
|
+
* Uses atomic write (temp file + rename).
|
|
117
|
+
*/
|
|
118
|
+
function saveConfig(config, projectRoot = process.cwd()) {
|
|
119
|
+
const actpDir = getActpDir(projectRoot);
|
|
120
|
+
const configPath = getConfigPath(projectRoot);
|
|
121
|
+
const tempPath = `${configPath}.tmp`;
|
|
122
|
+
// Ensure .actp directory exists
|
|
123
|
+
if (!fs.existsSync(actpDir)) {
|
|
124
|
+
fs.mkdirSync(actpDir, { recursive: true, mode: 0o755 });
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
// Atomic write: write to temp, then rename
|
|
128
|
+
const json = JSON.stringify(config, null, 2);
|
|
129
|
+
fs.writeFileSync(tempPath, json, { encoding: 'utf-8', mode: 0o600 }); // Secure permissions
|
|
130
|
+
fs.renameSync(tempPath, configPath);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
// Clean up temp file on error
|
|
134
|
+
if (fs.existsSync(tempPath)) {
|
|
135
|
+
try {
|
|
136
|
+
fs.unlinkSync(tempPath);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Ignore cleanup errors
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.saveConfig = saveConfig;
|
|
146
|
+
/**
|
|
147
|
+
* Update specific config values
|
|
148
|
+
*
|
|
149
|
+
* Loads existing config, merges updates, and saves.
|
|
150
|
+
*/
|
|
151
|
+
function updateConfig(updates, projectRoot = process.cwd()) {
|
|
152
|
+
const config = loadConfig(projectRoot);
|
|
153
|
+
const updated = { ...config, ...updates };
|
|
154
|
+
saveConfig(updated, projectRoot);
|
|
155
|
+
return updated;
|
|
156
|
+
}
|
|
157
|
+
exports.updateConfig = updateConfig;
|
|
158
|
+
/**
|
|
159
|
+
* Get a specific config value
|
|
160
|
+
*/
|
|
161
|
+
function getConfigValue(key, projectRoot = process.cwd()) {
|
|
162
|
+
const config = loadConfig(projectRoot);
|
|
163
|
+
return config[key];
|
|
164
|
+
}
|
|
165
|
+
exports.getConfigValue = getConfigValue;
|
|
166
|
+
/**
|
|
167
|
+
* Set a specific config value
|
|
168
|
+
*/
|
|
169
|
+
function setConfigValue(key, value, projectRoot = process.cwd()) {
|
|
170
|
+
updateConfig({ [key]: value }, projectRoot);
|
|
171
|
+
}
|
|
172
|
+
exports.setConfigValue = setConfigValue;
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// Validation
|
|
175
|
+
// ============================================================================
|
|
176
|
+
/**
|
|
177
|
+
* Validate Ethereum address format
|
|
178
|
+
*/
|
|
179
|
+
function validateAddress(address) {
|
|
180
|
+
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
181
|
+
}
|
|
182
|
+
exports.validateAddress = validateAddress;
|
|
183
|
+
/**
|
|
184
|
+
* Validate private key format (64 hex chars, optionally with 0x prefix)
|
|
185
|
+
*/
|
|
186
|
+
function validatePrivateKey(key) {
|
|
187
|
+
// Remove 0x prefix if present
|
|
188
|
+
const normalized = key.startsWith('0x') ? key.slice(2) : key;
|
|
189
|
+
return /^[a-fA-F0-9]{64}$/.test(normalized);
|
|
190
|
+
}
|
|
191
|
+
exports.validatePrivateKey = validatePrivateKey;
|
|
192
|
+
/**
|
|
193
|
+
* Validate config for the specified mode
|
|
194
|
+
*
|
|
195
|
+
* @throws Error if config is invalid for the mode
|
|
196
|
+
*/
|
|
197
|
+
function validateConfigForMode(config) {
|
|
198
|
+
// All modes require a valid address
|
|
199
|
+
if (!validateAddress(config.address)) {
|
|
200
|
+
throw new Error(`Invalid address: "${config.address}"\n` +
|
|
201
|
+
'Expected 0x-prefixed 40-character hex string.');
|
|
202
|
+
}
|
|
203
|
+
// Testnet and mainnet require private key
|
|
204
|
+
if (config.mode !== 'mock') {
|
|
205
|
+
if (!config.privateKey) {
|
|
206
|
+
throw new Error(`Private key required for ${config.mode} mode.\n` +
|
|
207
|
+
'Run: actp config set privateKey <your-private-key>');
|
|
208
|
+
}
|
|
209
|
+
if (!validatePrivateKey(config.privateKey)) {
|
|
210
|
+
throw new Error('Invalid private key format.\n' +
|
|
211
|
+
'Expected 64-character hex string (with or without 0x prefix).');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.validateConfigForMode = validateConfigForMode;
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Gitignore Management
|
|
218
|
+
// ============================================================================
|
|
219
|
+
/**
|
|
220
|
+
* Add .actp to .gitignore if not already present
|
|
221
|
+
*/
|
|
222
|
+
function addToGitignore(projectRoot = process.cwd()) {
|
|
223
|
+
const gitignorePath = path.join(projectRoot, '.gitignore');
|
|
224
|
+
let content = '';
|
|
225
|
+
if (fs.existsSync(gitignorePath)) {
|
|
226
|
+
content = fs.readFileSync(gitignorePath, 'utf-8');
|
|
227
|
+
}
|
|
228
|
+
// Check if .actp is already in gitignore
|
|
229
|
+
if (content.includes('.actp')) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
// Add .actp to gitignore
|
|
233
|
+
const newContent = content +
|
|
234
|
+
(content.endsWith('\n') ? '' : '\n') +
|
|
235
|
+
'# ACTP local state (contains mock blockchain state)\n' +
|
|
236
|
+
'.actp/\n';
|
|
237
|
+
fs.writeFileSync(gitignorePath, newContent, 'utf-8');
|
|
238
|
+
}
|
|
239
|
+
exports.addToGitignore = addToGitignore;
|
|
240
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli/utils/config.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AA+B7B;;GAEG;AACU,QAAA,eAAe,GAAc;IACxC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,+EAA+E;AAC/E,QAAQ;AACR,+EAA+E;AAE/E;;GAEG;AACH,SAAgB,UAAU,CAAC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAC5D,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAC/D,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC,CAAC;AAC3D,CAAC;AAFD,sCAEC;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,SAAgB,aAAa,CAAC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAC/D,OAAO,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;AACnD,CAAC;AAFD,sCAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAC5D,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAE9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;Q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AAC;QAED,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CACb,+BAA+B;gBAC7B,+DAA+D,CAClE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAzBD,sDAyBC;AAED,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,SAAgB,cAAc,CAAC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAChE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAE3D,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,yCAAyC;IACzC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IAED,yBAAyB;IACzB,MAAM,UAAU,GACd,OAAO;QACP,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACpC,uDAAuD;QACvD,UAAU,CAAC;IAEb,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AArBD,wCAqBC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Output Formatting Utilities
|
|
3
|
+
*
|
|
4
|
+
* Handles multi-mode output for human and machine consumption.
|
|
5
|
+
* Supports three output modes:
|
|
6
|
+
* - human: Colorful, formatted output for terminal users
|
|
7
|
+
* - json: Machine-readable JSON for scripting
|
|
8
|
+
* - quiet: Minimal output (just the essential value)
|
|
9
|
+
*
|
|
10
|
+
* @module cli/utils/output
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Output mode for CLI commands
|
|
14
|
+
*/
|
|
15
|
+
export type OutputMode = 'human' | 'json' | 'quiet';
|
|
16
|
+
/**
|
|
17
|
+
* Structured error for JSON output
|
|
18
|
+
*/
|
|
19
|
+
export interface CLIError {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
details?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Transaction display format
|
|
26
|
+
*/
|
|
27
|
+
export interface TransactionDisplay {
|
|
28
|
+
txId: string;
|
|
29
|
+
state: string;
|
|
30
|
+
requester: string;
|
|
31
|
+
provider: string;
|
|
32
|
+
amount: string;
|
|
33
|
+
deadline: string;
|
|
34
|
+
escrowId?: string | null;
|
|
35
|
+
createdAt?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare const fmt: {
|
|
38
|
+
bold: (s: string) => string;
|
|
39
|
+
dim: (s: string) => string;
|
|
40
|
+
underline: (s: string) => string;
|
|
41
|
+
red: (s: string) => string;
|
|
42
|
+
green: (s: string) => string;
|
|
43
|
+
yellow: (s: string) => string;
|
|
44
|
+
blue: (s: string) => string;
|
|
45
|
+
magenta: (s: string) => string;
|
|
46
|
+
cyan: (s: string) => string;
|
|
47
|
+
white: (s: string) => string;
|
|
48
|
+
gray: (s: string) => string;
|
|
49
|
+
success: (s: string) => string;
|
|
50
|
+
error: (s: string) => string;
|
|
51
|
+
warning: (s: string) => string;
|
|
52
|
+
info: (s: string) => string;
|
|
53
|
+
label: (s: string) => string;
|
|
54
|
+
value: (s: string) => string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Format transaction state with appropriate color
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatState(state: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Output formatter for CLI commands
|
|
62
|
+
*
|
|
63
|
+
* Provides consistent output across all commands with support for
|
|
64
|
+
* human-readable, JSON, and quiet modes.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const output = new Output('human');
|
|
69
|
+
*
|
|
70
|
+
* // Success message
|
|
71
|
+
* output.success('Transaction created!');
|
|
72
|
+
*
|
|
73
|
+
* // Key-value output
|
|
74
|
+
* output.keyValue('Transaction ID', txId);
|
|
75
|
+
*
|
|
76
|
+
* // JSON output (in json mode, prints JSON)
|
|
77
|
+
* output.result({ txId, state: 'INITIATED' });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare class Output {
|
|
81
|
+
readonly mode: OutputMode;
|
|
82
|
+
constructor(mode?: OutputMode);
|
|
83
|
+
/**
|
|
84
|
+
* Print a line (human mode only)
|
|
85
|
+
*/
|
|
86
|
+
print(message: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Print success message
|
|
89
|
+
*/
|
|
90
|
+
success(message: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Print error message
|
|
93
|
+
*/
|
|
94
|
+
error(message: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Print warning message
|
|
97
|
+
*/
|
|
98
|
+
warning(message: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Print info message
|
|
101
|
+
*/
|
|
102
|
+
info(message: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Print a blank line (human mode only)
|
|
105
|
+
*/
|
|
106
|
+
blank(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Print a key-value pair
|
|
109
|
+
*/
|
|
110
|
+
keyValue(key: string, value: string | number | boolean): void;
|
|
111
|
+
/**
|
|
112
|
+
* Print a section header
|
|
113
|
+
*/
|
|
114
|
+
section(title: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Print a transaction in human-readable format
|
|
117
|
+
*/
|
|
118
|
+
transaction(tx: TransactionDisplay): void;
|
|
119
|
+
/**
|
|
120
|
+
* Print a table of transactions
|
|
121
|
+
*/
|
|
122
|
+
transactionTable(transactions: TransactionDisplay[]): void;
|
|
123
|
+
/**
|
|
124
|
+
* Output a result object
|
|
125
|
+
*
|
|
126
|
+
* - human mode: Pretty prints with colors
|
|
127
|
+
* - json mode: Outputs JSON
|
|
128
|
+
* - quiet mode: Outputs just the primary value (first key or specified)
|
|
129
|
+
*/
|
|
130
|
+
result(data: Record<string, unknown>, options?: {
|
|
131
|
+
quietKey?: string;
|
|
132
|
+
}): void;
|
|
133
|
+
/**
|
|
134
|
+
* Output raw value (for quiet mode piping)
|
|
135
|
+
*/
|
|
136
|
+
raw(value: string): void;
|
|
137
|
+
/**
|
|
138
|
+
* Output a structured error
|
|
139
|
+
*/
|
|
140
|
+
errorResult(error: CLIError): void;
|
|
141
|
+
/**
|
|
142
|
+
* Start a spinner (human mode only)
|
|
143
|
+
*
|
|
144
|
+
* Returns a stop function to call when done.
|
|
145
|
+
* No-op in json/quiet modes.
|
|
146
|
+
*/
|
|
147
|
+
spinner(message: string): {
|
|
148
|
+
stop: (success?: boolean) => void;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Set the global output mode
|
|
153
|
+
*/
|
|
154
|
+
export declare function setOutputMode(mode: OutputMode): void;
|
|
155
|
+
/**
|
|
156
|
+
* Get the global output instance
|
|
157
|
+
*/
|
|
158
|
+
export declare function getOutput(): Output;
|
|
159
|
+
/**
|
|
160
|
+
* Standard exit codes for CLI commands
|
|
161
|
+
*
|
|
162
|
+
* Following Unix conventions and extending for ACTP-specific states.
|
|
163
|
+
*/
|
|
164
|
+
export declare const ExitCode: {
|
|
165
|
+
readonly SUCCESS: 0;
|
|
166
|
+
readonly ERROR: 1;
|
|
167
|
+
readonly PENDING: 2;
|
|
168
|
+
readonly INVALID_INPUT: 3;
|
|
169
|
+
readonly NOT_INITIALIZED: 4;
|
|
170
|
+
readonly NETWORK_ERROR: 5;
|
|
171
|
+
readonly TIMEOUT: 6;
|
|
172
|
+
};
|
|
173
|
+
export type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];
|
|
174
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmDD,eAAO,MAAM,GAAG;cACJ,MAAM;aACP,MAAM;mBACA,MAAM;aAEZ,MAAM;eACJ,MAAM;gBACL,MAAM;cACR,MAAM;iBACH,MAAM;cACT,MAAM;eACL,MAAM;cACP,MAAM;iBAGH,MAAM;eACR,MAAM;iBACJ,MAAM;cACT,MAAM;eACL,MAAM;eACN,MAAM;CAClB,CAAC;AAMF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBjD;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,MAAM;IACjB,SAAgB,IAAI,EAAE,UAAU,CAAC;gBAErB,IAAI,GAAE,UAAoB;IAQtC;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM5B;;OAEG;IACH,OAAO,CAAC,OAAO,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