@prktsol/prkt 1.0.0 → 1.0.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/.env.devnet.all-protocols.example +5 -0
- package/.env.example +7 -0
- package/CLI.md +24 -0
- package/CLI_QUICKSTART.md +16 -0
- package/README.md +59 -12
- package/dist/agent/AgentManager.d.ts +61 -0
- package/dist/agent/AgentRuntime.d.ts +28 -0
- package/dist/agent/DecisionEngine.d.ts +51 -0
- package/dist/agent/MockPriceFeed.d.ts +10 -0
- package/dist/agent/intents/types.d.ts +35 -0
- package/dist/agent/new-index.d.ts +9 -0
- package/dist/agent/policyFactory.d.ts +2 -0
- package/dist/agent/registry/AgentRegistry.d.ts +11 -0
- package/dist/agent/runner/AgentRunner.d.ts +51 -0
- package/dist/agent/runner/AgentRunner.js +59 -2
- package/dist/agent/strategies/MemoHeartbeatStrategy.d.ts +6 -0
- package/dist/agent/strategies/SimpleScriptedTransferStrategy.d.ts +12 -0
- package/dist/agent/strategies/TokenRebalancerStrategy.d.ts +13 -0
- package/dist/agent/strategies/TreasuryDistributorStrategy.d.ts +12 -0
- package/dist/agent/strategies/UniversalDeFiStrategy.d.ts +22 -0
- package/dist/agent/types/AgentContext.d.ts +28 -0
- package/dist/anchoring/SessionAnchor.d.ts +42 -0
- package/dist/anchoring/SessionAnchor.js +161 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +157 -16
- package/dist/cli/services/activityStore.d.ts +8 -0
- package/dist/cli/services/agentRegistry.d.ts +20 -0
- package/dist/cli/services/agentRuntime.d.ts +6 -0
- package/dist/cli/services/storagePaths.d.ts +8 -0
- package/dist/cli/services/strategyFactory.d.ts +5 -0
- package/dist/cli/services/walletCrypto.d.ts +12 -0
- package/dist/cli/services/walletRegistry.d.ts +26 -0
- package/dist/cli/types.d.ts +68 -0
- package/dist/cli/utils/completion.d.ts +4 -0
- package/dist/cli/utils/output.d.ts +5 -0
- package/dist/cli/utils/output.js +4 -1
- package/dist/compression/AuditLogManager.d.ts +9 -0
- package/dist/compression/AuditLogManager.js +86 -0
- package/dist/compression/PolicyAccountManager.d.ts +11 -0
- package/dist/compression/PolicyAccountManager.js +113 -0
- package/dist/compression/types.d.ts +20 -0
- package/dist/compression/types.js +2 -0
- package/dist/config/PRKTConfig.d.ts +17 -0
- package/dist/config/PRKTConfig.js +19 -0
- package/dist/config/agentPolicies.d.ts +14 -0
- package/dist/config/env.d.ts +39 -0
- package/dist/config/env.js +37 -0
- package/dist/config/policyPresets.d.ts +22 -0
- package/dist/core/balances/BalanceService.d.ts +14 -0
- package/dist/core/funding/DevnetFundingService.d.ts +38 -0
- package/dist/core/funding/DevnetFundingService.js +73 -6
- package/dist/core/idempotency/ExecutionIdempotencyGuard.d.ts +39 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/rpc/RpcClient.d.ts +21 -0
- package/dist/core/rpc/RpcClient.js +35 -0
- package/dist/core/rpc/RpcFailoverClient.d.ts +42 -0
- package/dist/core/tokens/TokenService.d.ts +40 -0
- package/dist/core/transactions/PostTransactionVerifier.d.ts +47 -0
- package/dist/core/transactions/TransactionService.d.ts +46 -0
- package/dist/core/types/services.d.ts +27 -0
- package/dist/core/wallet/WalletManager.d.ts +21 -0
- package/dist/defi/DeFiCoordinator.d.ts +24 -0
- package/dist/defi/DeFiExecutor.d.ts +15 -0
- package/dist/defi/DeFiPolicyGuard.d.ts +7 -0
- package/dist/defi/adapters/JupiterAdapter.d.ts +5 -0
- package/dist/defi/adapters/KaminoAdapter.d.ts +6 -0
- package/dist/defi/adapters/MarinadeAdapter.d.ts +5 -0
- package/dist/defi/adapters/RaydiumAdapter.d.ts +20 -0
- package/dist/defi/kamino/kaminoInstructionCompat.d.ts +3 -0
- package/dist/defi/kamino/kaminoLiveConfig.d.ts +14 -0
- package/dist/defi/kamino/loadKaminoMarketWithFallback.d.ts +11 -0
- package/dist/defi/lp/LpInstructionBuilder.d.ts +15 -0
- package/dist/defi/lp/RaydiumLpInstructionBuilder.d.ts +28 -0
- package/dist/defi/lp/raydiumDevnetConfig.d.ts +11 -0
- package/dist/defi/protocols.d.ts +8 -0
- package/dist/defi/types.d.ts +65 -0
- package/dist/defi/universal/UniversalDeFiOrchestrator.d.ts +24 -0
- package/dist/defi/universal/UniversalDeFiOrchestrator.js +157 -0
- package/dist/defi/universal/adapters.d.ts +25 -0
- package/dist/defi/universal/index.d.ts +2 -0
- package/dist/defi/universal/liveExecutors.d.ts +23 -0
- package/dist/defi/universal/types.d.ts +45 -0
- package/dist/demo/scenarios/multiAgentDevnetScenario.d.ts +5 -0
- package/dist/demo/scripts/runMultiAgentDevnetDemo.d.ts +1 -0
- package/dist/dex/JupiterSwapClient.d.ts +28 -0
- package/dist/dex/SwapExecutor.d.ts +36 -0
- package/dist/errors/PRKTError.d.ts +15 -0
- package/dist/errors/PRKTError.js +38 -0
- package/dist/evm/EvmAdapter.d.ts +45 -0
- package/dist/evm/EvmAdapter.js +2 -0
- package/dist/evm/NeonWalletBridge.d.ts +9 -0
- package/dist/evm/NeonWalletBridge.js +40 -0
- package/dist/evm/adapters/AaveAdapter.d.ts +17 -0
- package/dist/evm/adapters/AaveAdapter.js +100 -0
- package/dist/evm/adapters/UniswapV3Adapter.d.ts +18 -0
- package/dist/evm/adapters/UniswapV3Adapter.js +146 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +35 -20
- package/dist/kora/KoraRpcClient.d.ts +14 -0
- package/dist/kora/KoraSigner.d.ts +22 -0
- package/dist/kora/KoraSigner.js +33 -10
- package/dist/kora/gaslessDemo.d.ts +9 -0
- package/dist/onchain/index.d.ts +2 -0
- package/dist/onchain/index.js +17 -0
- package/dist/onchain/policyGuardProgram.d.ts +86 -0
- package/dist/onchain/policyGuardProgram.js +248 -0
- package/dist/policy/PolicyGuard.d.ts +13 -0
- package/dist/policy/emergencyLock.d.ts +4 -0
- package/dist/policy/engine/PolicyEngine.d.ts +28 -0
- package/dist/policy/engine/PolicyEngine.js +109 -1
- package/dist/policy/errors.d.ts +3 -0
- package/dist/policy/index.d.ts +3 -0
- package/dist/policy/sandbox/SandboxExecutor.d.ts +44 -0
- package/dist/policy/sandbox/SandboxExecutor.js +245 -3
- package/dist/policy/types/policy.d.ts +55 -0
- package/dist/scripts/devnetFunding.d.ts +9 -0
- package/dist/scripts/devnetFunding.js +0 -1
- package/dist/scripts/devnetWalletPreflight.d.ts +8 -0
- package/dist/scripts/localnetCheck.d.ts +1 -0
- package/dist/scripts/managedAgentWallet.d.ts +34 -0
- package/dist/scripts/mode.d.ts +2 -0
- package/dist/scripts/releaseReadiness.d.ts +9 -0
- package/dist/scripts/runAgentUniversalDeFi.d.ts +1 -0
- package/dist/scripts/runAutonomousAgentWalletDevnet.d.ts +1 -0
- package/dist/scripts/runAutonomousAgentWalletDevnet.js +1 -1
- package/dist/scripts/runAutonomousPortfolioDevnet.d.ts +1 -0
- package/dist/scripts/runAutonomousPortfolioDevnet.js +1 -1
- package/dist/scripts/runBorrowStrategy.d.ts +1 -0
- package/dist/scripts/runDeFiSuite.d.ts +1 -0
- package/dist/scripts/runDemoRehearsal.d.ts +1 -0
- package/dist/scripts/runDemoRehearsal.js +39 -10
- package/dist/scripts/runDevnetFeatureMatrix.d.ts +43 -0
- package/dist/scripts/runDevnetFeatureMatrix.js +787 -0
- package/dist/scripts/runDevnetWalletDemo.d.ts +1 -0
- package/dist/scripts/runGaslessMemo.d.ts +1 -0
- package/dist/scripts/runGaslessMemo.js +9 -1
- package/dist/scripts/runGaslessWalletDemo.d.ts +1 -0
- package/dist/scripts/runGaslessWalletDemo.js +9 -1
- package/dist/scripts/runKaminoDevnet.d.ts +1 -0
- package/dist/scripts/runKaminoDevnet.js +82 -42
- package/dist/scripts/runLpStrategy.d.ts +1 -0
- package/dist/scripts/runMarinadeDevnet.d.ts +1 -0
- package/dist/scripts/runOnchainPolicyGuardDevnet.d.ts +1 -0
- package/dist/scripts/runOnchainPolicyGuardDevnet.js +113 -0
- package/dist/scripts/runOrcaLpDevnet.d.ts +1 -0
- package/dist/scripts/runRaydiumLpDevnet.d.ts +1 -0
- package/dist/scripts/runReleaseReadiness.d.ts +1 -0
- package/dist/scripts/runStakeStrategy.d.ts +1 -0
- package/dist/scripts/runStatus.d.ts +1 -0
- package/dist/scripts/runStatus.js +22 -0
- package/dist/scripts/runStressTest.d.ts +1 -0
- package/dist/scripts/runTradeLoop.d.ts +1 -0
- package/dist/scripts/runUniversalDeFiDemo.d.ts +1 -0
- package/dist/scripts/runYieldStrategy.d.ts +1 -0
- package/dist/scripts/runtimeFactory.d.ts +8 -0
- package/dist/scripts/shared.d.ts +3 -0
- package/dist/scripts/shared.js +1 -0
- package/dist/scripts/simulateAttack.d.ts +1 -0
- package/dist/scripts/simulateSwarm.d.ts +1 -0
- package/dist/simulation/attack.d.ts +8 -0
- package/dist/solana/memoLedger.d.ts +33 -0
- package/dist/solana/memoLedger.js +205 -0
- package/dist/solana/programs.d.ts +6 -0
- package/dist/spl/TokenWallet.d.ts +18 -0
- package/dist/types/policy.d.ts +23 -0
- package/dist/wallet/WalletManager.d.ts +1 -0
- package/dist/zk/PolicyCircuit.d.ts +48 -0
- package/dist/zk/PolicyCircuit.js +171 -0
- package/dist/zk/ProofAnchor.d.ts +33 -0
- package/dist/zk/ProofAnchor.js +109 -0
- package/dist/zkCompression/CompressedCommitmentAnchor.d.ts +31 -0
- package/dist/zkCompression/CompressedCommitmentAnchor.js +90 -0
- package/dist/zkCompression/CompressedDataAccount.d.ts +45 -0
- package/dist/zkCompression/CompressedDataAccount.js +349 -0
- package/dist/zkCompression/LocalPayloadRegistry.d.ts +23 -0
- package/dist/zkCompression/LocalPayloadRegistry.js +53 -0
- package/package.json +20 -4
|
@@ -1,20 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SandboxExecutor = void 0;
|
|
4
|
+
const AuditLogManager_1 = require("../../compression/AuditLogManager");
|
|
5
|
+
const PolicyCircuit_1 = require("../../zk/PolicyCircuit");
|
|
6
|
+
const ProofAnchor_1 = require("../../zk/ProofAnchor");
|
|
7
|
+
const PRKTConfig_1 = require("../../config/PRKTConfig");
|
|
8
|
+
const env_1 = require("../../config/env");
|
|
9
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
10
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
11
|
+
const ethers_1 = require("ethers");
|
|
12
|
+
const NeonWalletBridge_1 = require("../../evm/NeonWalletBridge");
|
|
13
|
+
const WalletManager_1 = require("../../core/wallet/WalletManager");
|
|
4
14
|
class SandboxExecutor {
|
|
5
15
|
policyEngine;
|
|
6
16
|
transactionService;
|
|
7
17
|
approvalMode;
|
|
8
18
|
approvalCallback;
|
|
19
|
+
auditLogManager;
|
|
20
|
+
proofAnchor;
|
|
21
|
+
useCompression;
|
|
22
|
+
useZkProofs;
|
|
9
23
|
constructor(policyEngine, transactionService, approvalMode, approvalCallback) {
|
|
10
24
|
this.policyEngine = policyEngine;
|
|
11
25
|
this.transactionService = transactionService;
|
|
12
26
|
this.approvalMode = approvalMode;
|
|
13
27
|
this.approvalCallback = approvalCallback;
|
|
28
|
+
this.useCompression = PRKTConfig_1.defaultPRKTConfig.zkCompression.enabled;
|
|
29
|
+
this.useZkProofs = PRKTConfig_1.defaultPRKTConfig.zkPolicyProofs.enabled;
|
|
30
|
+
this.auditLogManager = new AuditLogManager_1.AuditLogManager(PRKTConfig_1.defaultPRKTConfig.zkCompression.rpcEndpoint);
|
|
31
|
+
this.proofAnchor = new ProofAnchor_1.ProofAnchor(PRKTConfig_1.defaultPRKTConfig.zkCompression.rpcEndpoint);
|
|
14
32
|
}
|
|
15
33
|
async executePreparedTransaction(input) {
|
|
16
34
|
const inspection = this.policyEngine.inspect(input.transaction, input.inspectionContext);
|
|
35
|
+
const agentId = this.policyEngine.getAuditTrail().at(-1)?.agentId ?? "unknown-agent";
|
|
36
|
+
const auditSigner = this.resolveProofSigner(input.solanaKeypair);
|
|
17
37
|
if (!inspection.allowed) {
|
|
38
|
+
if (this.useCompression) {
|
|
39
|
+
await this.auditLogManager.appendAuditEntry({
|
|
40
|
+
agentId,
|
|
41
|
+
timestamp: Date.now(),
|
|
42
|
+
intentType: "UNKNOWN",
|
|
43
|
+
approved: false,
|
|
44
|
+
rejectionReason: inspection.reasons.join("; "),
|
|
45
|
+
simulationResult: "skipped"
|
|
46
|
+
}, auditSigner).catch(() => { }); // catch to not block execution
|
|
47
|
+
}
|
|
18
48
|
return {
|
|
19
49
|
inspection,
|
|
20
50
|
signature: null,
|
|
@@ -23,6 +53,16 @@ class SandboxExecutor {
|
|
|
23
53
|
}
|
|
24
54
|
const simulation = await this.transactionService.simulate(input.transaction);
|
|
25
55
|
if (simulation.err) {
|
|
56
|
+
if (this.useCompression) {
|
|
57
|
+
await this.auditLogManager.appendAuditEntry({
|
|
58
|
+
agentId,
|
|
59
|
+
timestamp: Date.now(),
|
|
60
|
+
intentType: "UNKNOWN",
|
|
61
|
+
approved: false,
|
|
62
|
+
rejectionReason: "simulation failed",
|
|
63
|
+
simulationResult: "failed"
|
|
64
|
+
}, auditSigner).catch(() => { });
|
|
65
|
+
}
|
|
26
66
|
return {
|
|
27
67
|
inspection: {
|
|
28
68
|
...inspection,
|
|
@@ -46,7 +86,7 @@ class SandboxExecutor {
|
|
|
46
86
|
};
|
|
47
87
|
}
|
|
48
88
|
const approved = await this.approvalCallback({
|
|
49
|
-
agentId
|
|
89
|
+
agentId,
|
|
50
90
|
inspection,
|
|
51
91
|
transaction: input.transaction
|
|
52
92
|
});
|
|
@@ -62,15 +102,217 @@ class SandboxExecutor {
|
|
|
62
102
|
};
|
|
63
103
|
}
|
|
64
104
|
}
|
|
105
|
+
let proofSigner;
|
|
106
|
+
let zkProof;
|
|
107
|
+
if (this.useZkProofs) {
|
|
108
|
+
proofSigner = this.resolveProofSigner(input.solanaKeypair);
|
|
109
|
+
const state = this.buildProofState(false);
|
|
110
|
+
try {
|
|
111
|
+
const proofResult = await PolicyCircuit_1.PolicyCircuit.prove(input.transaction, state, "EXECUTE", BigInt(inspection.details.totalSolSpendLamports), proofSigner);
|
|
112
|
+
zkProof = proofResult.proof;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!(error instanceof PolicyCircuit_1.PolicyViolation)) {
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
inspection: {
|
|
120
|
+
...inspection,
|
|
121
|
+
allowed: false,
|
|
122
|
+
reasons: [...inspection.reasons, `Policy attestation rejected: ${error.message}`]
|
|
123
|
+
},
|
|
124
|
+
signature: null,
|
|
125
|
+
simulationLogs: simulation.logs
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
65
129
|
const send = await this.transactionService.sendAndConfirm({
|
|
66
130
|
confirmationStrategy: input.confirmationStrategy,
|
|
67
131
|
transaction: input.transaction
|
|
68
132
|
});
|
|
69
|
-
this.policyEngine.recordBroadcast(send.signature);
|
|
133
|
+
this.policyEngine.recordBroadcast(send.signature, Number(inspection.details.totalSolSpendLamports) / 1_000_000_000);
|
|
134
|
+
if (zkProof && send.signature) {
|
|
135
|
+
await this.proofAnchor.anchorProof(zkProof, send.signature, proofSigner);
|
|
136
|
+
}
|
|
137
|
+
if (this.useCompression && send.signature) {
|
|
138
|
+
await this.auditLogManager.appendAuditEntry({
|
|
139
|
+
agentId,
|
|
140
|
+
timestamp: Date.now(),
|
|
141
|
+
intentType: "EXECUTE",
|
|
142
|
+
approved: true,
|
|
143
|
+
simulationResult: "success",
|
|
144
|
+
txSignature: send.signature
|
|
145
|
+
}, auditSigner).catch(() => { });
|
|
146
|
+
}
|
|
70
147
|
return {
|
|
71
148
|
inspection,
|
|
72
149
|
signature: send.signature,
|
|
73
|
-
simulationLogs: simulation.logs
|
|
150
|
+
simulationLogs: simulation.logs,
|
|
151
|
+
zkProof
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async executePreparedEvmTransaction(input) {
|
|
155
|
+
const inspection = this.policyEngine.inspectEvm(input.transaction);
|
|
156
|
+
const agentId = this.policyEngine.getAuditTrail().at(-1)?.agentId ?? "unknown-agent";
|
|
157
|
+
const auditSigner = this.resolveProofSigner(input.solanaKeypair);
|
|
158
|
+
if (!inspection.allowed) {
|
|
159
|
+
if (this.useCompression) {
|
|
160
|
+
await this.auditLogManager.appendAuditEntry({
|
|
161
|
+
agentId,
|
|
162
|
+
timestamp: Date.now(),
|
|
163
|
+
intentType: "EXECUTE_EVM",
|
|
164
|
+
approved: false,
|
|
165
|
+
rejectionReason: inspection.reason ?? inspection.reasons.join("; "),
|
|
166
|
+
simulationResult: "skipped"
|
|
167
|
+
}, auditSigner).catch(() => { });
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
allowed: false,
|
|
171
|
+
reason: inspection.reason ?? inspection.reasons.join("; "),
|
|
172
|
+
signature: null
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(PRKTConfig_1.defaultPRKTConfig.evmAdapters.neonRpcEndpoint);
|
|
176
|
+
try {
|
|
177
|
+
await provider.call({
|
|
178
|
+
...input.transaction,
|
|
179
|
+
from: input.transaction.from ?? input.address
|
|
180
|
+
});
|
|
181
|
+
await provider.estimateGas({
|
|
182
|
+
...input.transaction,
|
|
183
|
+
from: input.transaction.from ?? input.address
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
const reason = error instanceof Error ? error.message : "eth_call reverted";
|
|
188
|
+
if (this.useCompression) {
|
|
189
|
+
await this.auditLogManager.appendAuditEntry({
|
|
190
|
+
agentId,
|
|
191
|
+
timestamp: Date.now(),
|
|
192
|
+
intentType: "EXECUTE_EVM",
|
|
193
|
+
approved: false,
|
|
194
|
+
rejectionReason: reason,
|
|
195
|
+
simulationResult: "failed"
|
|
196
|
+
}, auditSigner).catch(() => { });
|
|
197
|
+
}
|
|
198
|
+
return { signature: null, allowed: false, reason };
|
|
199
|
+
}
|
|
200
|
+
if (this.approvalMode === "live") {
|
|
201
|
+
if (!this.approvalCallback) {
|
|
202
|
+
return { signature: null, allowed: false, reason: "live approval callback missing" };
|
|
203
|
+
}
|
|
204
|
+
const approved = await this.approvalCallback({
|
|
205
|
+
agentId,
|
|
206
|
+
inspection,
|
|
207
|
+
transaction: input.transaction
|
|
208
|
+
});
|
|
209
|
+
if (!approved) {
|
|
210
|
+
return { signature: null, allowed: false, reason: "manual approval rejected" };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!(0, env_1.isNeonBroadcastEnabled)()) {
|
|
214
|
+
const reason = "NEON_BROADCAST_DISABLED";
|
|
215
|
+
if (this.useCompression) {
|
|
216
|
+
await this.auditLogManager.appendAuditEntry({
|
|
217
|
+
agentId,
|
|
218
|
+
timestamp: Date.now(),
|
|
219
|
+
intentType: "EXECUTE_EVM",
|
|
220
|
+
approved: false,
|
|
221
|
+
rejectionReason: reason,
|
|
222
|
+
simulationResult: "skipped"
|
|
223
|
+
}, auditSigner).catch(() => { });
|
|
224
|
+
}
|
|
225
|
+
return { signature: null, allowed: false, reason };
|
|
226
|
+
}
|
|
227
|
+
let proofSigner;
|
|
228
|
+
let zkProof;
|
|
229
|
+
if (this.useZkProofs) {
|
|
230
|
+
proofSigner = this.resolveProofSigner(input.solanaKeypair);
|
|
231
|
+
const state = this.buildProofState(true);
|
|
232
|
+
try {
|
|
233
|
+
const proofResult = await PolicyCircuit_1.PolicyCircuit.prove({
|
|
234
|
+
address: input.address,
|
|
235
|
+
transaction: this.serializeEvmTransaction(input.transaction)
|
|
236
|
+
}, state, "EXECUTE_EVM", BigInt(inspection.details.totalSolSpendLamports), proofSigner);
|
|
237
|
+
zkProof = proofResult.proof;
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (!(error instanceof PolicyCircuit_1.PolicyViolation)) {
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
return { signature: null, allowed: false, reason: error.message };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// Wrap and sign
|
|
247
|
+
const bridge = new NeonWalletBridge_1.NeonWalletBridge(PRKTConfig_1.defaultPRKTConfig.evmAdapters.neonRpcEndpoint);
|
|
248
|
+
const signedTransaction = await bridge.signEvmTransaction({
|
|
249
|
+
...input.transaction,
|
|
250
|
+
from: input.transaction.from ?? input.address
|
|
251
|
+
}, input.solanaKeypair ?? web3_js_1.Keypair.generate());
|
|
252
|
+
const broadcast = await provider.broadcastTransaction(signedTransaction);
|
|
253
|
+
await broadcast.wait();
|
|
254
|
+
const signature = broadcast.hash;
|
|
255
|
+
this.policyEngine.recordBroadcast(signature, Number(inspection.details.totalSolSpendLamports) / 1_000_000_000);
|
|
256
|
+
if (zkProof && signature) {
|
|
257
|
+
await this.proofAnchor.anchorProof(zkProof, signature, proofSigner);
|
|
258
|
+
}
|
|
259
|
+
if (this.useCompression && signature) {
|
|
260
|
+
await this.auditLogManager.appendAuditEntry({
|
|
261
|
+
agentId,
|
|
262
|
+
timestamp: Date.now(),
|
|
263
|
+
intentType: "EXECUTE_EVM",
|
|
264
|
+
approved: true,
|
|
265
|
+
simulationResult: "success",
|
|
266
|
+
txSignature: signature
|
|
267
|
+
}, auditSigner);
|
|
268
|
+
}
|
|
269
|
+
return { signature, allowed: true, zkProof };
|
|
270
|
+
}
|
|
271
|
+
resolveProofSigner(preferred) {
|
|
272
|
+
if (preferred) {
|
|
273
|
+
return preferred;
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
return WalletManager_1.WalletManager.loadOrGenerate().payer;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return web3_js_1.Keypair.generate();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
serializeEvmTransaction(transaction) {
|
|
283
|
+
return Object.fromEntries(Object.entries(transaction).map(([key, value]) => {
|
|
284
|
+
if (typeof value === "bigint") {
|
|
285
|
+
return [key, value.toString()];
|
|
286
|
+
}
|
|
287
|
+
return [key, value ?? null];
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
buildProofState(includeEvmAllowlist) {
|
|
291
|
+
const policyConfig = this.policyEngine.getPolicyConfig();
|
|
292
|
+
const now = Date.now();
|
|
293
|
+
const sessionExpiry = Date.parse(policyConfig.sessionExpiresAtIso8601);
|
|
294
|
+
const sessionTtlMinutes = Number.isNaN(sessionExpiry)
|
|
295
|
+
? 0
|
|
296
|
+
: Math.max(0, Math.ceil((sessionExpiry - now) / 60_000));
|
|
297
|
+
return {
|
|
298
|
+
agentId: policyConfig.agentId,
|
|
299
|
+
dailySpendLimit: new anchor_1.BN(policyConfig.limits.maxSolPerTxLamports.toString()),
|
|
300
|
+
killSwitchActive: false,
|
|
301
|
+
lastResetTimestamp: now,
|
|
302
|
+
programAllowlist: includeEvmAllowlist
|
|
303
|
+
? []
|
|
304
|
+
: policyConfig.rules.allowedProgramIds
|
|
305
|
+
.map((programId) => {
|
|
306
|
+
try {
|
|
307
|
+
return new web3_js_1.PublicKey(programId);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
.filter((programId) => programId !== null),
|
|
314
|
+
sessionTTL: sessionTtlMinutes,
|
|
315
|
+
spentToday: new anchor_1.BN(Math.round(this.policyEngine.getSpentToday() * 1_000_000_000))
|
|
74
316
|
};
|
|
75
317
|
}
|
|
76
318
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PublicKey, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
export type ApprovalMode = "sandbox" | "live";
|
|
3
|
+
export type PolicyLimits = {
|
|
4
|
+
maxSolPerTxLamports: number;
|
|
5
|
+
maxSplPerTxRawAmount: bigint;
|
|
6
|
+
maxTransactionsPerSession: number;
|
|
7
|
+
maxTransactionsPerDay: number;
|
|
8
|
+
};
|
|
9
|
+
export type PolicyRules = {
|
|
10
|
+
allowOpaqueProgramIds?: string[];
|
|
11
|
+
allowedCloseAccountDestinations?: string[];
|
|
12
|
+
allowedProgramIds: string[];
|
|
13
|
+
allowedMintAddresses: string[];
|
|
14
|
+
denyUnknownInstructionsByDefault: boolean;
|
|
15
|
+
requireSimulationSuccess: boolean;
|
|
16
|
+
rejectSuspiciousBalanceDeltas: boolean;
|
|
17
|
+
allowedTransferDestinations?: string[];
|
|
18
|
+
};
|
|
19
|
+
export type PolicyConfig = {
|
|
20
|
+
agentId: string;
|
|
21
|
+
approvalMode: ApprovalMode;
|
|
22
|
+
limits: PolicyLimits;
|
|
23
|
+
rules: PolicyRules;
|
|
24
|
+
sessionExpiresAtIso8601: string;
|
|
25
|
+
};
|
|
26
|
+
export type TxInspectionContext = {
|
|
27
|
+
expectedBalanceDeltas?: Array<{
|
|
28
|
+
account: PublicKey;
|
|
29
|
+
mint?: PublicKey;
|
|
30
|
+
maxNegativeDeltaRaw: bigint;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
export type TxInspectionResult = {
|
|
34
|
+
allowed: boolean;
|
|
35
|
+
reason?: string;
|
|
36
|
+
reasons: string[];
|
|
37
|
+
details: {
|
|
38
|
+
totalSolSpendLamports: bigint;
|
|
39
|
+
totalSplSpendRaw: bigint;
|
|
40
|
+
programsSeen: string[];
|
|
41
|
+
mintsSeen: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type SecurityAuditEntry = {
|
|
45
|
+
agentId: string;
|
|
46
|
+
timestampIso8601: string;
|
|
47
|
+
decision: "allow" | "deny";
|
|
48
|
+
reason: string;
|
|
49
|
+
txSignature?: string;
|
|
50
|
+
};
|
|
51
|
+
export type ApprovalCallback = (input: {
|
|
52
|
+
agentId: string;
|
|
53
|
+
inspection: TxInspectionResult;
|
|
54
|
+
transaction: VersionedTransaction;
|
|
55
|
+
}) => Promise<boolean>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BalanceService } from "../core/balances/BalanceService";
|
|
2
|
+
import { DevnetFundingService } from "../core/funding/DevnetFundingService";
|
|
3
|
+
import { WalletManager } from "../wallet/WalletManager";
|
|
4
|
+
export declare function ensureWalletHasMinimumSol(input: {
|
|
5
|
+
balanceService: BalanceService;
|
|
6
|
+
fundingService: DevnetFundingService;
|
|
7
|
+
minimumSol: number;
|
|
8
|
+
publicKey: WalletManager["publicKey"];
|
|
9
|
+
}): Promise<void>;
|
|
@@ -4,7 +4,6 @@ exports.ensureWalletHasMinimumSol = ensureWalletHasMinimumSol;
|
|
|
4
4
|
const SOL_BALANCE_TOLERANCE = 0.000001;
|
|
5
5
|
async function ensureWalletHasMinimumSol(input) {
|
|
6
6
|
const funding = await input.fundingService.ensureMinimumSol({
|
|
7
|
-
airdropAmountSol: 1,
|
|
8
7
|
balanceService: input.balanceService,
|
|
9
8
|
minimumSol: input.minimumSol,
|
|
10
9
|
recipient: input.publicKey
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const REQUIRED_STARTING_SOL = 0.12;
|
|
2
|
+
export declare const MAX_STARTING_WSOL_FOR_WRAP_DEMO = 0.0099;
|
|
3
|
+
export declare function assertDeterministicWrapPreflight(input: {
|
|
4
|
+
maxStartingWsol?: number;
|
|
5
|
+
requiredStartingSol?: number;
|
|
6
|
+
startingSolBalance: number;
|
|
7
|
+
startingWsolBalance: number;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { AgentRegistryStore } from "../cli/services/agentRegistry";
|
|
3
|
+
import { WalletRegistry } from "../cli/services/walletRegistry";
|
|
4
|
+
import type { StoredAgentRecord, StoredWalletRecord } from "../cli/types";
|
|
5
|
+
import { BalanceService } from "../core/balances/BalanceService";
|
|
6
|
+
import { DevnetFundingService } from "../core/funding/DevnetFundingService";
|
|
7
|
+
import { WalletManager } from "../wallet/WalletManager";
|
|
8
|
+
export type ManagedAgentWallet = {
|
|
9
|
+
agent: StoredAgentRecord;
|
|
10
|
+
agentName: string;
|
|
11
|
+
createdAgent: boolean;
|
|
12
|
+
createdWallet: boolean;
|
|
13
|
+
recoveryKey: string | null;
|
|
14
|
+
wallet: StoredWalletRecord;
|
|
15
|
+
walletManager: WalletManager;
|
|
16
|
+
};
|
|
17
|
+
export declare function getManagedAgentName(input: {
|
|
18
|
+
defaultAgentName: string;
|
|
19
|
+
env?: NodeJS.ProcessEnv;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function getManagedOwnerId(env?: NodeJS.ProcessEnv): string | undefined;
|
|
22
|
+
export declare function resolveManagedAgentWallet(input: {
|
|
23
|
+
agentName: string;
|
|
24
|
+
ownerId?: string;
|
|
25
|
+
agentRegistry?: AgentRegistryStore;
|
|
26
|
+
walletRegistry?: WalletRegistry;
|
|
27
|
+
}): ManagedAgentWallet;
|
|
28
|
+
export declare function ensureManagedAgentWalletFunding(input: {
|
|
29
|
+
balanceService: BalanceService;
|
|
30
|
+
fundingService: DevnetFundingService;
|
|
31
|
+
minimumSol: number;
|
|
32
|
+
publicKey: PublicKey;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
export declare function logManagedAgentWallet(input: ManagedAgentWallet): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type CheckResult = {
|
|
2
|
+
detail: string;
|
|
3
|
+
ok: boolean;
|
|
4
|
+
title: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function runCommandCheck(command: string, args: string[]): CheckResult;
|
|
7
|
+
export declare function evaluateProductionTodo(todoPath?: string): CheckResult;
|
|
8
|
+
export declare function findOpenBlockingTodoItems(markdown: string): string[];
|
|
9
|
+
export declare function runReadinessChecks(): CheckResult[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -16,7 +16,7 @@ const managedAgentWallet_1 = require("./managedAgentWallet");
|
|
|
16
16
|
const mode_1 = require("./mode");
|
|
17
17
|
const shared_1 = require("./shared");
|
|
18
18
|
const DEFAULT_AGENT_NAME = "agent-autonomous-wallet";
|
|
19
|
-
const REQUIRED_FUNDING_SOL = 0.
|
|
19
|
+
const REQUIRED_FUNDING_SOL = 0.3;
|
|
20
20
|
const DEFAULT_STAKE_SOL = 0.15;
|
|
21
21
|
async function main() {
|
|
22
22
|
(0, mode_1.printDemoMode)("LIVE", "Autonomous agent wallet: provision or load the assigned agent wallet, fund on devnet, execute live Marinade stake, and verify owner stop control");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -28,7 +28,7 @@ const shared_1 = require("./shared");
|
|
|
28
28
|
const managedAgentWallet_1 = require("./managedAgentWallet");
|
|
29
29
|
const mode_1 = require("./mode");
|
|
30
30
|
const DEFAULT_AGENT_NAME = "autonomous-portfolio-devnet";
|
|
31
|
-
const REQUIRED_FUNDING_SOL =
|
|
31
|
+
const REQUIRED_FUNDING_SOL = 0.4;
|
|
32
32
|
const DEFAULT_SWAP_SOL = 0.01;
|
|
33
33
|
const DEFAULT_ORCA_LP_SOL = 0.05;
|
|
34
34
|
const ORCA_DEVNET_PROGRAM_ID = new web3_js_1.PublicKey("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,7 +7,6 @@ const fs_1 = require("fs");
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const env_1 = require("../config/env");
|
|
10
|
-
const env_2 = require("../config/env");
|
|
11
10
|
function runCommand(command, args) {
|
|
12
11
|
const result = (0, child_process_1.spawnSync)([command, ...args].join(" "), {
|
|
13
12
|
shell: true,
|
|
@@ -24,8 +23,7 @@ function runPreflightChecks() {
|
|
|
24
23
|
const rpcUrl = (0, env_1.getRpcUrl)();
|
|
25
24
|
const cluster = (0, env_1.detectClusterFromRpcUrl)(rpcUrl);
|
|
26
25
|
const usdcMint = (0, env_1.getUsdcMintAddress)();
|
|
27
|
-
const
|
|
28
|
-
const remoteSigner = (0, env_1.getRemoteSignerConfig)();
|
|
26
|
+
const signerCheck = resolveSignerCheck();
|
|
29
27
|
checks.push({
|
|
30
28
|
detail: rpcUrl,
|
|
31
29
|
ok: cluster === "devnet",
|
|
@@ -51,12 +49,8 @@ function runPreflightChecks() {
|
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
checks.push({
|
|
54
|
-
detail:
|
|
55
|
-
|
|
56
|
-
: secretKey
|
|
57
|
-
? "local demo key present"
|
|
58
|
-
: "missing signer config",
|
|
59
|
-
ok: Boolean(remoteSigner) || Boolean(secretKey),
|
|
52
|
+
detail: signerCheck.detail,
|
|
53
|
+
ok: signerCheck.ok,
|
|
60
54
|
title: "signer configuration is present"
|
|
61
55
|
});
|
|
62
56
|
checks.push({
|
|
@@ -67,6 +61,39 @@ function runPreflightChecks() {
|
|
|
67
61
|
checks.push(runCommand("npm", ["run", "release:check"]));
|
|
68
62
|
return checks;
|
|
69
63
|
}
|
|
64
|
+
function resolveSignerCheck() {
|
|
65
|
+
try {
|
|
66
|
+
const remoteSigner = (0, env_1.getRemoteSignerConfig)();
|
|
67
|
+
if (remoteSigner) {
|
|
68
|
+
return {
|
|
69
|
+
detail: `remote signer ${remoteSigner.publicKey.toBase58()}`,
|
|
70
|
+
ok: true
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if ((0, env_1.getOptionalDevnetTreasurySecretKey)()) {
|
|
74
|
+
return {
|
|
75
|
+
detail: "devnet treasury key present",
|
|
76
|
+
ok: true
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if ((0, env_1.getOptionalSecretKey)()) {
|
|
80
|
+
return {
|
|
81
|
+
detail: "local demo key present",
|
|
82
|
+
ok: true
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
detail: "missing signer config",
|
|
87
|
+
ok: false
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return {
|
|
92
|
+
detail: error instanceof Error ? error.message : "invalid signer config",
|
|
93
|
+
ok: false
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
70
97
|
function writeSessionArtifact(checks) {
|
|
71
98
|
const artifactDir = path_1.default.join(process.cwd(), "artifacts");
|
|
72
99
|
if (!(0, fs_1.existsSync)(artifactDir)) {
|
|
@@ -77,6 +104,7 @@ function writeSessionArtifact(checks) {
|
|
|
77
104
|
cluster: (0, env_1.detectClusterFromRpcUrl)((0, env_1.getRpcUrl)()),
|
|
78
105
|
generatedAtIso8601: new Date().toISOString(),
|
|
79
106
|
recommendedLiveRunOrder: [
|
|
107
|
+
"npm run demo:feature-matrix:devnet",
|
|
80
108
|
"npm run wallet:devnet",
|
|
81
109
|
"npm run defi:lp:devnet",
|
|
82
110
|
"npm run simulate-attack",
|
|
@@ -106,6 +134,7 @@ function main() {
|
|
|
106
134
|
return;
|
|
107
135
|
}
|
|
108
136
|
console.log("Demo rehearsal preflight passed.");
|
|
109
|
-
console.log("Next: run the recommended live order
|
|
137
|
+
console.log("Next: run the recommended live order, starting with the devnet feature matrix.");
|
|
138
|
+
console.log("Record resulting signatures and artifact paths in artifacts/bounty-evidence.md.");
|
|
110
139
|
}
|
|
111
140
|
main();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type MatrixStep = {
|
|
2
|
+
category: string;
|
|
3
|
+
detail: string;
|
|
4
|
+
name: string;
|
|
5
|
+
status: "ok" | "warn" | "fail" | "skip";
|
|
6
|
+
};
|
|
7
|
+
type MatrixSummary = {
|
|
8
|
+
advanced?: {
|
|
9
|
+
agentId: string;
|
|
10
|
+
commitment: string;
|
|
11
|
+
policyAccountSignature: string;
|
|
12
|
+
proofSignature: string;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
sessionSignature: string;
|
|
15
|
+
};
|
|
16
|
+
cluster: string;
|
|
17
|
+
generatedAtIso8601: string;
|
|
18
|
+
names: {
|
|
19
|
+
agent: string;
|
|
20
|
+
gaslessAgent: string;
|
|
21
|
+
owner: string;
|
|
22
|
+
wallet: string;
|
|
23
|
+
};
|
|
24
|
+
steps: MatrixStep[];
|
|
25
|
+
};
|
|
26
|
+
type MatrixArtifacts = {
|
|
27
|
+
jsonPath: string;
|
|
28
|
+
markdownPath: string;
|
|
29
|
+
};
|
|
30
|
+
type StepCounts = {
|
|
31
|
+
fail: number;
|
|
32
|
+
ok: number;
|
|
33
|
+
skip: number;
|
|
34
|
+
total: number;
|
|
35
|
+
warn: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function extractJsonPayload(stdout: string): unknown;
|
|
38
|
+
export declare function createIntentFile(agentPublicKey: string): string;
|
|
39
|
+
export declare function summarizeSteps(steps: MatrixStep[]): StepCounts;
|
|
40
|
+
export declare function renderMarkdownReport(summary: MatrixSummary): string;
|
|
41
|
+
export declare function writeArtifacts(summary: MatrixSummary): MatrixArtifacts;
|
|
42
|
+
export declare function runDevnetFeatureMatrix(): Promise<MatrixArtifacts>;
|
|
43
|
+
export {};
|