agentvault 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/.dfx/local/network-id +4 -0
  2. package/.next/trace +2 -0
  3. package/.vercel/README.txt +11 -0
  4. package/.vercel/project.json +1 -0
  5. package/AGENTS.md +43 -0
  6. package/CHANGELOG.md +196 -0
  7. package/LICENSE +21 -0
  8. package/PLAN_VAULT_INTEGRATION.md +318 -0
  9. package/README.md +253 -0
  10. package/backups/agentvault-backup-test-agent-2026-02-12T17-54-28-967Z.json +28 -0
  11. package/backups/agentvault-backup-test-agent-2026-02-12T17-54-29-032Z.backup +1 -0
  12. package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-373Z.json +28 -0
  13. package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-428Z.backup +1 -0
  14. package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-132Z.json +28 -0
  15. package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-247Z.backup +1 -0
  16. package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-216Z.json +28 -0
  17. package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-283Z.backup +1 -0
  18. package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-772Z.backup +1 -0
  19. package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-793Z.json +28 -0
  20. package/backups/test-backup.json +28 -0
  21. package/dist/cli/commands/approve.d.ts +4 -0
  22. package/dist/cli/commands/approve.js +232 -0
  23. package/dist/cli/commands/archive.d.ts +4 -0
  24. package/dist/cli/commands/archive.js +192 -0
  25. package/dist/cli/commands/backup.d.ts +4 -0
  26. package/dist/cli/commands/backup.js +164 -0
  27. package/dist/cli/commands/cloud-backup.d.ts +4 -0
  28. package/dist/cli/commands/cloud-backup.js +221 -0
  29. package/dist/cli/commands/cycles.d.ts +8 -0
  30. package/dist/cli/commands/cycles.js +83 -0
  31. package/dist/cli/commands/decrypt.d.ts +16 -0
  32. package/dist/cli/commands/decrypt.js +101 -0
  33. package/dist/cli/commands/deploy.d.ts +32 -0
  34. package/dist/cli/commands/deploy.js +208 -0
  35. package/dist/cli/commands/exec.d.ts +26 -0
  36. package/dist/cli/commands/exec.js +109 -0
  37. package/dist/cli/commands/fetch.d.ts +23 -0
  38. package/dist/cli/commands/fetch.js +164 -0
  39. package/dist/cli/commands/health.d.ts +8 -0
  40. package/dist/cli/commands/health.js +72 -0
  41. package/dist/cli/commands/identity.d.ts +8 -0
  42. package/dist/cli/commands/identity.js +140 -0
  43. package/dist/cli/commands/inference.d.ts +4 -0
  44. package/dist/cli/commands/inference.js +225 -0
  45. package/dist/cli/commands/info.d.ts +8 -0
  46. package/dist/cli/commands/info.js +59 -0
  47. package/dist/cli/commands/init.d.ts +19 -0
  48. package/dist/cli/commands/init.js +135 -0
  49. package/dist/cli/commands/instrument.d.ts +8 -0
  50. package/dist/cli/commands/instrument.js +35 -0
  51. package/dist/cli/commands/list.d.ts +36 -0
  52. package/dist/cli/commands/list.js +173 -0
  53. package/dist/cli/commands/logs.d.ts +8 -0
  54. package/dist/cli/commands/logs.js +96 -0
  55. package/dist/cli/commands/monitor.d.ts +8 -0
  56. package/dist/cli/commands/monitor.js +84 -0
  57. package/dist/cli/commands/network.d.ts +14 -0
  58. package/dist/cli/commands/network.js +258 -0
  59. package/dist/cli/commands/package.d.ts +36 -0
  60. package/dist/cli/commands/package.js +188 -0
  61. package/dist/cli/commands/profile.d.ts +8 -0
  62. package/dist/cli/commands/profile.js +76 -0
  63. package/dist/cli/commands/promote.d.ts +8 -0
  64. package/dist/cli/commands/promote.js +89 -0
  65. package/dist/cli/commands/rebuild.d.ts +21 -0
  66. package/dist/cli/commands/rebuild.js +140 -0
  67. package/dist/cli/commands/rollback.d.ts +8 -0
  68. package/dist/cli/commands/rollback.js +120 -0
  69. package/dist/cli/commands/show.d.ts +36 -0
  70. package/dist/cli/commands/show.js +200 -0
  71. package/dist/cli/commands/stats.d.ts +8 -0
  72. package/dist/cli/commands/stats.js +34 -0
  73. package/dist/cli/commands/status.d.ts +14 -0
  74. package/dist/cli/commands/status.js +83 -0
  75. package/dist/cli/commands/test.d.ts +8 -0
  76. package/dist/cli/commands/test.js +109 -0
  77. package/dist/cli/commands/tokens.d.ts +8 -0
  78. package/dist/cli/commands/tokens.js +62 -0
  79. package/dist/cli/commands/trace.d.ts +8 -0
  80. package/dist/cli/commands/trace.js +68 -0
  81. package/dist/cli/commands/wallet-export.d.ts +13 -0
  82. package/dist/cli/commands/wallet-export.js +140 -0
  83. package/dist/cli/commands/wallet-history.d.ts +10 -0
  84. package/dist/cli/commands/wallet-history.js +127 -0
  85. package/dist/cli/commands/wallet-import.d.ts +10 -0
  86. package/dist/cli/commands/wallet-import.js +209 -0
  87. package/dist/cli/commands/wallet-multi-send.d.ts +17 -0
  88. package/dist/cli/commands/wallet-multi-send.js +195 -0
  89. package/dist/cli/commands/wallet-process-queue.d.ts +19 -0
  90. package/dist/cli/commands/wallet-process-queue.js +209 -0
  91. package/dist/cli/commands/wallet-sign.d.ts +13 -0
  92. package/dist/cli/commands/wallet-sign.js +207 -0
  93. package/dist/cli/commands/wallet.d.ts +12 -0
  94. package/dist/cli/commands/wallet.js +794 -0
  95. package/dist/cli/index.d.ts +10 -0
  96. package/dist/cli/index.js +96 -0
  97. package/dist/vitest.config.d.ts +3 -0
  98. package/dist/vitest.config.js +14 -0
  99. package/fixup_1_0_OSS_release.md +136 -0
  100. package/fixup_REALEASE_PRD.md +136 -0
  101. package/package.json +79 -0
  102. package/pnpm-workspace.yaml +5 -0
  103. package/scripts/dev-dashboard.mjs +84 -0
  104. package/site/README.md +63 -0
  105. package/site/docusaurus.config.ts +148 -0
  106. package/site/package-lock.json +18383 -0
  107. package/site/package.json +47 -0
  108. package/site/sidebars.ts +86 -0
  109. package/site/static/.gitkeep +0 -0
  110. package/site/static/img/logo.svg +28 -0
  111. package/site/static/img/og-image.svg +35 -0
  112. package/src/archival/archive-manager.ts +372 -0
  113. package/src/archival/arweave-client.ts +289 -0
  114. package/src/archival/index.ts +8 -0
  115. package/src/backup/backup.ts +315 -0
  116. package/src/backup/index.ts +7 -0
  117. package/src/cloud-storage/cloud-sync.ts +461 -0
  118. package/src/cloud-storage/index.ts +11 -0
  119. package/src/cloud-storage/provider-detector.ts +198 -0
  120. package/src/cloud-storage/types.ts +104 -0
  121. package/src/debugging/index.ts +6 -0
  122. package/src/debugging/logs.ts +193 -0
  123. package/src/debugging/types.ts +100 -0
  124. package/src/deployment/deployer.ts +274 -0
  125. package/src/deployment/icpClient.ts +620 -0
  126. package/src/deployment/index.ts +46 -0
  127. package/src/deployment/promotion.ts +161 -0
  128. package/src/deployment/types.ts +111 -0
  129. package/src/icp/batch.ts +374 -0
  130. package/src/icp/cycles.ts +50 -0
  131. package/src/icp/environment.ts +215 -0
  132. package/src/icp/icpcli.ts +438 -0
  133. package/src/icp/icwasm.ts +222 -0
  134. package/src/icp/identity.ts +77 -0
  135. package/src/icp/index.ts +94 -0
  136. package/src/icp/optimization.ts +242 -0
  137. package/src/icp/tokens.ts +36 -0
  138. package/src/icp/tool-detector.ts +110 -0
  139. package/src/icp/types.ts +574 -0
  140. package/src/index.ts +25 -0
  141. package/src/inference/bittensor-client.ts +304 -0
  142. package/src/inference/index.ts +8 -0
  143. package/src/inference/inference-manager.ts +327 -0
  144. package/src/metrics/index.ts +7 -0
  145. package/src/metrics/metrics.ts +186 -0
  146. package/src/monitoring/alerting.ts +190 -0
  147. package/src/monitoring/health.ts +197 -0
  148. package/src/monitoring/index.ts +38 -0
  149. package/src/monitoring/info.ts +114 -0
  150. package/src/monitoring/types.ts +99 -0
  151. package/src/network/index.ts +5 -0
  152. package/src/network/network-config.ts +129 -0
  153. package/src/packaging/compiler.ts +647 -0
  154. package/src/packaging/config-persistence.ts +135 -0
  155. package/src/packaging/config-schemas.ts +156 -0
  156. package/src/packaging/detector.ts +220 -0
  157. package/src/packaging/index.ts +90 -0
  158. package/src/packaging/packager.ts +118 -0
  159. package/src/packaging/parsers/clawdbot.ts +278 -0
  160. package/src/packaging/parsers/cline.ts +223 -0
  161. package/src/packaging/parsers/generic.ts +266 -0
  162. package/src/packaging/parsers/goose.ts +214 -0
  163. package/src/packaging/parsers/index.ts +11 -0
  164. package/src/packaging/serializer.ts +260 -0
  165. package/src/packaging/types.ts +144 -0
  166. package/src/packaging/wasmedge-compiler.ts +406 -0
  167. package/src/security/index.ts +17 -0
  168. package/src/security/multisig.ts +415 -0
  169. package/src/security/types.ts +416 -0
  170. package/src/security/vetkeys.ts +655 -0
  171. package/src/testing/index.ts +6 -0
  172. package/src/testing/local-runner.ts +264 -0
  173. package/src/testing/types.ts +104 -0
  174. package/src/wallet/cbor-serializer.ts +323 -0
  175. package/src/wallet/chain-dispatcher.ts +313 -0
  176. package/src/wallet/cross-chain-aggregator.ts +346 -0
  177. package/src/wallet/index.ts +76 -0
  178. package/src/wallet/key-derivation.ts +425 -0
  179. package/src/wallet/providers/base-provider.ts +154 -0
  180. package/src/wallet/providers/cketh-provider.ts +434 -0
  181. package/src/wallet/providers/polkadot-provider.ts +503 -0
  182. package/src/wallet/providers/solana-provider.ts +490 -0
  183. package/src/wallet/transaction-queue.ts +284 -0
  184. package/src/wallet/types.ts +178 -0
  185. package/src/wallet/vetkeys-adapter.ts +431 -0
  186. package/src/wallet/wallet-manager.ts +597 -0
  187. package/src/wallet/wallet-storage.ts +380 -0
  188. package/vercel.json +8 -0
@@ -0,0 +1,4 @@
1
+ {
2
+ "created": "2025-02-01 19:25:23.320109 +00:00:00",
3
+ "settings_digest": "a2c7b27b81377d6b5f7e38775792e6f435f034f3afc27553f2f3eed938fb7e9b"
4
+ }
package/.next/trace ADDED
@@ -0,0 +1,2 @@
1
+ [{"name":"next-dev","duration":358444,"timestamp":25456549822,"id":1,"tags":{},"startTime":1771290476315,"traceId":"bd0fc21499a468eb"}]
2
+ [{"name":"generate-buildid","duration":73,"timestamp":25762683733,"id":4,"parentId":1,"tags":{},"startTime":1771290782449,"traceId":"e1799c79029c02c3"},{"name":"load-custom-routes","duration":105,"timestamp":25762683837,"id":5,"parentId":1,"tags":{},"startTime":1771290782449,"traceId":"e1799c79029c02c3"},{"name":"next-build","duration":35672,"timestamp":25762648918,"id":1,"tags":{"buildMode":"default","isTurboBuild":"false","version":"15.1.4"},"startTime":1771290782414,"traceId":"e1799c79029c02c3"}]
@@ -0,0 +1,11 @@
1
+ > Why do I have a folder named ".vercel" in my project?
2
+ The ".vercel" folder is created when you link a directory to a Vercel project.
3
+
4
+ > What does the "project.json" file contain?
5
+ The "project.json" file contains:
6
+ - The ID of the Vercel project that you linked ("projectId")
7
+ - The ID of the user or team your Vercel project is owned by ("orgId")
8
+
9
+ > Should I commit the ".vercel" folder?
10
+ No, you should not share the ".vercel" folder with anyone.
11
+ Upon creation, it will be automatically added to your ".gitignore" file.
@@ -0,0 +1 @@
1
+ {"projectId":"prj_EhiMuGMYk4R83zWMg37kvloXRNpm","orgId":"team_nZSD33w3Dm3KxfwYqgrL4THr","projectName":"agentvault"}
package/AGENTS.md ADDED
@@ -0,0 +1,43 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ - `src/`: core TypeScript library (packaging, deployment, security, monitoring, wallet, ICP tooling).
5
+ - `cli/`: CLI entry points and command handlers (`cli/commands/*.ts`).
6
+ - `canister/`: Motoko canister code and Candid interfaces.
7
+ - `tests/`: Vitest suite (unit, integration, CLI, deployment, packaging).
8
+ - `examples/`: sample agent projects and configs.
9
+ - `docs/`, `AI_DOCS/`: product and design docs.
10
+ - `dist/`, `dist-cli/`: build outputs (generated, do not edit).
11
+ - Root configs: `dfx.json`, `icp.yaml`, `tsconfig.json`, `eslint.config.js`.
12
+
13
+ ## Build, Test, and Development Commands
14
+ - `npm run dev`: run the local dev entry with `tsx` watch.
15
+ - `npm run build`: compile TypeScript to `dist/`.
16
+ - `npm run start`: run the built app from `dist/`.
17
+ - `npm run test`: run Vitest in CI mode.
18
+ - `npm run test:watch`: run Vitest in watch mode.
19
+ - `npm run typecheck`: TypeScript typecheck without emit.
20
+ - `npm run lint` / `npm run lint:fix`: lint and auto-fix with ESLint.
21
+
22
+ ## Coding Style & Naming Conventions
23
+ - TypeScript, ESM (`module`/`moduleResolution: NodeNext`), ES2022 target.
24
+ - 2-space indentation; keep exports explicit.
25
+ - Use `camelCase` for variables/functions, `PascalCase` for types/classes.
26
+ - Unused args should be prefixed with `_` (ESLint allows this).
27
+ - Keep CLI command files in `cli/commands/` named with kebab-case (e.g., `wallet-import.ts`).
28
+
29
+ ## Testing Guidelines
30
+ - Framework: Vitest.
31
+ - Test files live under `tests/` and end with `*.test.ts`.
32
+ - Group by domain: `tests/cli/`, `tests/deployment/`, `tests/icp/`, `tests/unit/`.
33
+ - Prefer small, isolated tests for helpers and broader integration tests for CLI flows.
34
+
35
+ ## Commit & Pull Request Guidelines
36
+ - Commit messages in this repo are plain, sentence-case descriptions (no strict prefix).
37
+ - Keep the first line concise; add details in the body if needed.
38
+ - PRs should include: summary of changes, relevant test output, and linked issues.
39
+ - Add screenshots only when UX or CLI output changes are user-facing.
40
+
41
+ ## Security & Configuration Tips
42
+ - Do not commit secrets; keep keys and seed phrases out of git.
43
+ - Use `dfx` for local canister work and keep `dfx.json` in sync with canister changes.
package/CHANGELOG.md ADDED
@@ -0,0 +1,196 @@
1
+ # CHANGELOG
2
+
3
+ All notable changes to AgentVault will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
+
7
+ ## [1.0.0] - 2025-02-12 - v1.0.0 Final Release
8
+
9
+ ### Added
10
+ - Complete core flow: init → package → deploy → exec → show → fetch
11
+ - Real ICP canister deployment via dfx integration
12
+ - Multi-chain wallet support (ICP, Ethereum, Polkadot, Solana)
13
+ - VetKeys threshold key derivation for secure secrets
14
+ - AES-256-GCM encryption with timing-safe HMAC verification
15
+ - Comprehensive CLI with 36 commands
16
+ - Next.js web dashboard with 8 pages
17
+ - Monitoring system with health checks and alerts
18
+ - Arweave archival integration
19
+ - Bittensor inference integration
20
+ - Environment variable configuration for all RPC endpoints
21
+ - Cryptographically secure random generation for share IDs
22
+ - `backup export --canister-id` option to include live canister state (tasks, memory, context)
23
+ - `promote --wasm-path` option for actual canister deployment during promotion
24
+
25
+ ### Changed
26
+ - ICP client now uses real dfx commands for deployment
27
+ - WASM hash calculation uses proper SHA-256
28
+ - VetKeys IV generation uses crypto.randomBytes
29
+ - Memory thresholds now correctly use 4GB max canister limit
30
+ - Cycle parsing uses correct multipliers (T=10^12, G=10^9, M=10^6, K=10^3)
31
+ - Encryption uses timing-safe comparison to prevent timing attacks
32
+
33
+ ### Fixed
34
+ - Math.random() replaced with crypto.randomBytes in vetkeys.ts
35
+ - All hardcoded localhost URLs now use environment variables
36
+ - ESM compatibility for arweave and bittensor clients
37
+ - Principal validation regex accepts valid ICP formats
38
+ - Webapp components now use real API hooks instead of mock data
39
+
40
+ ### Security
41
+ - Timing-safe HMAC verification in encryption.ts
42
+ - Secure IV generation in vetkeys.ts
43
+ - Environment variable configuration for sensitive endpoints
44
+ - Threshold signatures properly validate canister connection
45
+
46
+ ### Experimental Features
47
+ The following commands are marked [Experimental] and under active development:
48
+ - `inference` - Bittensor network integration
49
+ - `archive` - Arweave archival
50
+ - `approve` - Multi-signature workflows
51
+ - `profile` - Canister profiling
52
+ - `trace` - Execution traces
53
+ - `wallet-multi-send` - Multi-chain transactions
54
+ - `wallet-process-queue` - Transaction queue processing
55
+
56
+ ## [Unreleased]
57
+
58
+ ## [1.0.0] - 2025-02-10 - Phase 5: Production Release
59
+
60
+ ### Added
61
+ - Production-ready AI agent platform for Internet Computer
62
+ - Complete web dashboard with agent management
63
+ - Multi-chain wallet support (ICP, Polkadot, Solana)
64
+ - Batched canister deployment operations
65
+ - Arweave archival for permanent storage
66
+ - Bittensor inference integration
67
+ - Multi-sig approval workflows
68
+ - Automated backup and restore
69
+ - Real-time monitoring and metrics
70
+ - Comprehensive CLI with 36 commands
71
+ - TypeScript/ESLint configuration
72
+ - CI/CD pipeline with GitHub Actions
73
+
74
+ ### Changed
75
+ - Upgraded from development to production-ready state
76
+ - Added comprehensive documentation for users and developers
77
+ - Configured production deployment settings
78
+ - Established automated testing and release process
79
+
80
+ ### Fixed
81
+ - Pre-existing test errors resolved
82
+ - CI/CD workflows configured
83
+ - Package configuration for npm publishing
84
+ - Production dfx.json and icp.yaml created
85
+
86
+ ### Removed
87
+ - Pre-existing test file with errors removed
88
+ - Stale backup file cleaned up
89
+
90
+ ---
91
+
92
+ ## [1.0.0-rc.1] - 2025-02-09 - Phase 5: Documentation
93
+
94
+ ### Added
95
+ - User guide: Getting started, deployment, wallets, backups
96
+ - Developer guide: Architecture, extending agents, canister development
97
+ - Troubleshooting guide with comprehensive solutions
98
+ - Web dashboard guide
99
+
100
+ ---
101
+
102
+ ## [1.0.0-rc.2] - 2025-02-08 - Phase 5: Testing & CI/CD
103
+
104
+ ### Added
105
+ - GitHub Actions workflows: test, test-webapp, release
106
+ - Automated testing on every push/PR
107
+ - Coverage reporting with Codecov
108
+ - Automated npm publishing
109
+
110
+ ---
111
+
112
+ ## [1.0.0-rc.3] - 2025-02-07 - Phase 5: Package Config
113
+
114
+ ### Added
115
+ - Package files configuration
116
+ - npm keywords for searchability
117
+ - Repository, bugs, homepage fields
118
+ - Engine strictness (Node.js 18+)
119
+ - License specification
120
+
121
+ ---
122
+
123
+ ## [0.4.1] - 2025-02-06 - Phase 4: Webapp & Backend
124
+
125
+ ### Added
126
+ - Next.js 15 + React 19 web dashboard
127
+ - 8 dashboard pages (canisters, agents, tasks, logs, wallets, networks, backups, settings)
128
+ - 18 API routes
129
+ - 21 UI components (agents, tasks, logs, wallets, common)
130
+ - 6 custom hooks for data fetching
131
+ - 2 context providers (theme, ICP)
132
+ - 4 utility modules (types, api-client, utils, icp-connection)
133
+
134
+ ---
135
+
136
+ ## [0.4.0] - 2025-02-05 - Phase 4: Archival & Inference
137
+
138
+ ### Added
139
+ - Arweave client for permanent storage
140
+ - Archive manager for local backup management
141
+ - Bittensor client for AI inference
142
+ - CLI commands: archive, inference, approve
143
+
144
+ ---
145
+
146
+ ## [0.3.0] - 2025-02-04 - Phase 4: Wallet & Multi-sig
147
+
148
+ ### Added
149
+ - Multi-chain wallet system
150
+ - Hardware wallet support
151
+ - Transaction queue and history
152
+ - Multi-signature approval workflows
153
+ - CLI commands: wallet-export, wallet-import, wallet-history, wallet-sign, wallet-multi-send, wallet-process-queue
154
+
155
+ ---
156
+
157
+ ## [0.2.0] - 2025-02-03 - Phase 4: Testing & Monitoring
158
+
159
+ ### Added
160
+ - Vitest testing framework
161
+ - Coverage reporting
162
+ - Monitoring system with health checks and alerts
163
+ - CLI commands: monitor, health, info, instrument
164
+
165
+ ---
166
+
167
+ ## [0.1.0] - 2025-02-02 - Phase 4: Metrics & Backup
168
+
169
+ ### Added
170
+ - Metrics collection and aggregation
171
+ - Backup system with local and Arweave
172
+ - CLI commands: backup, status, show
173
+
174
+ ---
175
+
176
+ ## [0.0.1] - 2025-02-01 - Phase 3: Deployment
177
+
178
+ ### Added
179
+ - Batched canister operations
180
+ - Topological sort for dependencies
181
+ - CLI commands: deploy, promote, rebuild, rollback
182
+
183
+ ---
184
+
185
+ ## [0.0.0] - 2025-01-25 - Initial Release
186
+
187
+ ### Added
188
+ - Initial agent packaging system
189
+ - Basic deployment capabilities
190
+ - Wallet integration stubs
191
+ - Monitoring and metrics foundation
192
+ - Documentation structure
193
+
194
+ ---
195
+
196
+ ## [Unreleased]
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AgentVault Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,318 @@
1
+ # AgentVault Vault Integration Plan
2
+ **Date:** February 11, 2026
3
+ **Priority:** High
4
+ **Est. Effort:** 3-5 days
5
+
6
+ ---
7
+
8
+ ## Executive Summary
9
+
10
+ Integrate HashiCorp-style vault functionality into AgentVault for secure credential management. This replaces insecure credential sharing (pasting keys, storing passwords in .env files) with a proper vault that supports:
11
+
12
+ - **Scoped access** — Least-privilege principle
13
+ - **Audit trails** — Track who accessed what and when
14
+ - **TTL/secrets** — Time-limited credentials that auto-expire
15
+ - **Injection prevention** — Secrets never exposed to agents or CLI processes
16
+ - **Version control** — Track changes to secrets, allow rollbacks
17
+
18
+ ---
19
+
20
+ ## Current State Assessment
21
+
22
+ ### ✅ What's Already Built
23
+ - **CLI framework** (`cli/commands/`) — Ready for extension
24
+ - **Local state management** — `.agentvault/`, `agent.config.json`, `canister_ids.json`
25
+ - **Agent config parsing** — Robust YAML/JSON config loading
26
+ - **TypeScript interfaces** — Core types defined in `src/lib/types.ts`
27
+
28
+ ### ❌ What's Missing
29
+ - **Vault client** — No integration with external vault service
30
+ - **Secrets storage** — Credentials hardcoded or stored in `.env` files
31
+ - **Vault-aware CLI commands** — Commands don't know about vault
32
+ - **Webapp vault integration** — Dashboard doesn't connect to vault
33
+ - **Audit logging** — No tracking of vault access events
34
+ - **Secret injection** — Secrets loaded directly without TTL or versioning
35
+
36
+ ---
37
+
38
+ ## Proposed Architecture
39
+
40
+ ```
41
+ ┌─────────────────────────────────────────────────────────────────┐
42
+ │ AgentVault CLI │
43
+ │ │
44
+ │ ┌──────────────────────────────────────────────────────┐ │
45
+ │ │ Commands Layer │ │
46
+ │ │ │ │
47
+ │ │ init │ status │ fetch │ exec │ │ │
48
+ │ │ │ │ │ │ │ │ │
49
+ │ └────────┬─────────┴──────────┬────────┘ │ │
50
+ │ │ │ │ │ │ │
51
+ │ ▼ ▼ ▼ │ │ │
52
+ │ ┌────────────────────────────────────────────────────┐ │ │
53
+ │ │ Vault Client (New) │ │ │
54
+ │ │ - Connect to HashiCorp Vault │ │ │
55
+ │ │ - Read/write secrets with scoping │ │ │
56
+ │ │ - Audit trail for all operations │ │ │
57
+ │ │ - TTL/expiration management │ │ │
58
+ │ │ - Version control for secrets │ │ │
59
+ │ └────────────────┬─────────────────────────────┘ │ │
60
+ │ │ │ │ │
61
+ │ ▼ ▼ │ │ │
62
+ │ ┌─────────────────────────────────────────────────┐ │ │
63
+ │ │ Webapp (Dashboard) │ │ │
64
+ │ │ - Optional: Connect to vault │ │ │
65
+ │ │ - View vault secrets (read-only) │ │ │
66
+ │ │ - Manage vault connection settings │ │ │
67
+ │ │ - View audit logs │ │ │
68
+ │ └───────────────────────────────────────────────────┘ │ │
69
+ │ │
70
+ │ ┌────────────────────┐ │ │ │
71
+ │ │ Agent Vault Repo │ │ │ │
72
+ │ │ │ │ │ │
73
+ │ │ │ │ │ │
74
+ └─────────────────────────┴───────────────────────────────────────┘ │ └────────┴────────────┘
75
+ └─────────────────────────────────────────────────────────────────────┘
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Implementation Plan
81
+
82
+ ### Phase 1: Vault Client Library (Day 1)
83
+
84
+ **Goal:** Create TypeScript client for HashiCorp Vault with full feature parity.
85
+
86
+ **File:** `src/lib/vault-client.ts`
87
+
88
+ **Features:**
89
+ 1. **Connection Management**
90
+ - Connect to vault (HTTPS with optional headers)
91
+ - Health checks with retries
92
+ - Graceful fallback when vault is unavailable
93
+
94
+ 2. **Secret Operations**
95
+ - `getSecret(path, version?)` — Read secret with versioning
96
+ - `setSecret(path, value, options?)` — Write secret with TTL, metadata
97
+ - `deleteSecret(path, version?)` — Delete secret, create new version
98
+ - `listSecrets(path?)` — List all secrets with versions
99
+ - `revokeSecret(path, version?)` — Immediately revoke secret
100
+
101
+ 3. **Access Control**
102
+ - `getPolicies()` — Retrieve access policies
103
+ - `checkAccess(policy, resource)` — Check if user has access
104
+
105
+ 4. **Audit Logging**
106
+ - `getAuditLog(from?, to?)` — Retrieve audit trail
107
+ - Local caching for offline operations
108
+
109
+ **Integration Points:**
110
+ - Extend `AgentConfig` to support `vaultUri?`
111
+ - Update `init()` command to prompt for vault connection
112
+ - Modify `deploy()` to optionally read wallet keys from vault
113
+
114
+ ---
115
+
116
+ ### Phase 2: CLI Command Extensions (Day 1)
117
+
118
+ **Goal:** Add vault-aware commands that use Vault Client.
119
+
120
+ **New Commands:**
121
+
122
+ 1. **`cli/commands/vault.ts`** (New file)
123
+ - `vault: connect <url>` — Connect to vault
124
+ - `vault: status` — Show vault connection status
125
+ - `vault: ls` — List secrets (with versions)
126
+ - `vault: get <path>` — Get secret value
127
+ - `vault: set <path> <value>` — Set secret
128
+ - `vault: rm <path>` — Delete secret
129
+ - `vault: refresh` — Reconnect/validate vault connection
130
+
131
+ 2. **Update `cli/commands/init.ts`**
132
+ - Prompt: "Connect to vault? (optional)"
133
+ - Store `vaultUri` and `vaultToken` in `agent.config.json`
134
+
135
+ 3. **Update existing commands**
136
+ - `deploy()` — Read wallet keys from vault if available
137
+ - `exec()` — Support `--vault` flag for secret injection
138
+ - `fetch()` and `status()` — Show vault source for secrets
139
+
140
+ ---
141
+
142
+ ### Phase 3: Webapp Integration (Day 2)
143
+
144
+ **Goal:** Optional vault integration in dashboard.
145
+
146
+ **New Files:**
147
+
148
+ 1. **`webapp/src/providers/VaultProvider.tsx`** (New provider)
149
+ - Vault connection state
150
+ - Methods: `connect()`, `disconnect()`, `isConnected()`, `getSecret()`
151
+
152
+ 2. **`webapp/src/hooks/useVault.ts`** (New hook)
153
+ - Consume VaultProvider across app
154
+ - Handle vault unavailability gracefully
155
+
156
+ 3. **`webapp/src/app/(dashboard)/settings/page.tsx`** (Update)
157
+ - Add vault connection settings form:
158
+ - Vault URL
159
+ - Connection status indicator
160
+ - Test connection button
161
+ - Disconnect button
162
+
163
+ 4. **`webapp/src/components/common/VaultStatus.tsx`** (New component)
164
+ - Badge showing "Vault" or "Local" status
165
+
166
+ ---
167
+
168
+ ### Phase 4: Configuration & Migration (Day 2-3)
169
+
170
+ **Goal:** Existing user support and migration path.
171
+
172
+ **Migration Options:**
173
+
174
+ 1. **Option A: Automatic Migration** (Recommended)
175
+ - Detect existing `.agentvault/` config
176
+ - Prompt: "Would you like to connect to HashiCorp Vault?"
177
+ - Create vault connection with `vault: connect`
178
+ - Migrate secrets to vault automatically
179
+
180
+ 2. **Option B: Manual Setup** (For Control)
181
+ - Add `VAULT_URI` and `VAULT_TOKEN` to `.agentvault/config.yaml`
182
+ - User manually runs `agentvault vault: connect`
183
+ - Explicit control over when vault is used
184
+
185
+ ---
186
+
187
+ ## Secret Schema (Local File Fallback)
188
+
189
+ If vault is unavailable, fall back to encrypted local storage:
190
+
191
+ **File:** `~/.agentvault/secrets.json`
192
+
193
+ **Schema:**
194
+ ```json
195
+ {
196
+ "$schema": "https://agentvault.com/schema/v1",
197
+ "secrets": {
198
+ "claude_api_key": {
199
+ "value": "sk-...",
200
+ "version": "v1",
201
+ "created_at": "2026-02-11T...",
202
+ "last_access": "2026-02-11T...",
203
+ "metadata": {
204
+ "purpose": "AI inference",
205
+ "source": "user_provided"
206
+ }
207
+ },
208
+ "wallet_private_key": {
209
+ "value": "0x...",
210
+ "version": "v1",
211
+ "created_at": "2026-02-11T...",
212
+ "metadata": {
213
+ "chain": "ethereum",
214
+ "purpose": "agent_wallet"
215
+ }
216
+ }
217
+ },
218
+ "$version": "v1"
219
+ }
220
+ ```
221
+
222
+ **Features:**
223
+ - AES-256 encryption with PBKDF2
224
+ - Version history (up to 10 versions per secret)
225
+ - Last-access timestamps
226
+ - Purpose/metadata tagging
227
+ - Read/write via VaultClient (primary) or local fallback
228
+
229
+ ---
230
+
231
+ ## Security Considerations
232
+
233
+ ### ✅ Benefits
234
+ - **No more pasting keys** — Secret exposure eliminated
235
+ - **Audit trails** — All vault operations logged
236
+ - **Scoped access** — Agents only access what they need
237
+ - **Revocation** — Compromised secrets can be revoked immediately
238
+ - **TTL policies** — Secrets auto-expire, reducing risk window
239
+
240
+ ### ⚠️ Risks to Mitigate
241
+ - **Vault dependency** — If vault is down, agent operations fail
242
+ - Mitigation: Local encrypted file fallback
243
+ - Mitigation: Cache secrets in memory during vault connections
244
+ - **Token compromise** — If vault token stolen, attacker has access
245
+ - Mitigation: Token rotation workflow (admin revokes, user generates new)
246
+ - **DoS attacks** — Vault rate limits could block legitimate agents
247
+ - Mitigation: Exponential backoff, local caching
248
+
249
+ ---
250
+
251
+ ## Testing Strategy
252
+
253
+ ### Unit Tests
254
+ ```typescript
255
+ // tests/vault-client.test.ts
256
+ describe('Vault Client', () => {
257
+ it('connects to vault', async () => {
258
+ const client = new VaultClient('http://localhost:8200');
259
+ await client.connect('test-token');
260
+ expect(client.isConnected()).toBe(true);
261
+ });
262
+
263
+ it('handles vault unavailability', async () => {
264
+ const client = new VaultClient('http://localhost:8200');
265
+ await client.connect('test-token');
266
+ expect(await client.getSecret('/test')).toEqual('test-value');
267
+ });
268
+ });
269
+ ```
270
+
271
+ ### Integration Tests
272
+ ```bash
273
+ # Test vault integration with CLI
274
+ agentvault deploy --vault-secret /claude_api_key
275
+ agentvault deploy --vault-secret /wallet_private_key
276
+ agentvault exec --agent-id abc123 --vault-secret /api_key
277
+ ```
278
+
279
+ ---
280
+
281
+ ## Success Criteria
282
+
283
+ - [ ] Vault client library created with full feature parity
284
+ - [ ] CLI commands extended with vault operations
285
+ - [ ] Webapp vault provider added (optional integration)
286
+ - [ ] Vault connection settings in dashboard
287
+ - [ ] Migration guide for existing users
288
+ - [ ] Local encrypted secrets fallback implemented
289
+ - [ ] All tests passing (existing + new vault tests)
290
+ - [ ] Documentation updated
291
+
292
+ ---
293
+
294
+ ## Open Questions
295
+
296
+ 1. **Vault service?** Should we self-host HashiCorp Vault, use HCP Vault, or integrate with existing vault service?
297
+
298
+ 2. **Migration priority?** Should vault integration be opt-in (manual) or automatic for new users?
299
+
300
+ 3. **Scope granularity?** How detailed should secret scoping be? (per-secret, per-app, per-user?)
301
+
302
+ 4. **TTL defaults?** What should default secret expiration be? (1 hour, 24 hours, 7 days?)
303
+
304
+ ---
305
+
306
+ ## Next Steps
307
+
308
+ 1. **Review and approve** this plan with user
309
+ 2. **Create implementation branch:** `feature/vault-integration`
310
+ 3. **Implement Phase 1** (Vault Client Library)
311
+ 4. **Implement Phase 2** (CLI Commands)
312
+ 5. **Implement Phase 3** (Webapp Integration)
313
+ 6. **Test thoroughly** (unit + integration + migration)
314
+ 7. **Merge to main** when ready
315
+
316
+ ---
317
+
318
+ *This plan balances feature completeness with pragmatic implementation, considering both new users (need migration) and existing workflows (local fallback).*