aptos-x402 2.2.2 → 2.2.4
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/CHANGELOG.md +126 -0
- package/COMPOSER_IMPLEMENTATION.md +203 -0
- package/components/auth/LoginModal.tsx +82 -0
- package/components/auth/SessionProvider.tsx +11 -0
- package/components/auth/UserMenu.tsx +8 -0
- package/components/auth/UserMenuClient.tsx +117 -0
- package/components/composer/AgentCard.tsx +362 -0
- package/components/composer/AgentCardSkeleton.tsx +59 -0
- package/components/composer/AgentCreationWizard.tsx +311 -0
- package/components/composer/ApiSelector.tsx +230 -0
- package/components/composer/ChatInterface.tsx +605 -0
- package/components/composer/ChatInterfaceSkeleton.tsx +75 -0
- package/components/composer/ComposerClient.tsx +201 -0
- package/components/composer/FundingModal.tsx +143 -0
- package/components/composer/WaitlistModal.tsx +149 -0
- package/components/composer/WalletCard.tsx +152 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/card.tsx +92 -0
- package/components/ui/dialog.tsx +141 -0
- package/components/ui/input.tsx +27 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +185 -0
- package/components/ui/separator.tsx +26 -0
- package/components/ui/tabs.tsx +64 -0
- package/components/wallet/WalletProvider.tsx +20 -0
- package/components.json +22 -0
- package/contracts/arc8004/Move.toml +30 -0
- package/contracts/arc8004/sources/agent_identity.move +229 -0
- package/contracts/arc8004/sources/reputation.move +287 -0
- package/contracts/arc8004/sources/validation.move +228 -0
- package/drizzle/0000_nappy_kid_colt.sql +32 -0
- package/drizzle/0001_salty_spyke.sql +6 -0
- package/drizzle/0002_sloppy_the_twelve.sql +9 -0
- package/drizzle/0003_parched_cammi.sql +8 -0
- package/drizzle/0004_unusual_triton.sql +1 -0
- package/drizzle/0005_zippy_bulldozer.sql +66 -0
- package/drizzle/0006_auth_and_agent_wallets.sql +92 -0
- package/drizzle/0007_arc8004_tables.sql +144 -0
- package/drizzle/meta/0000_snapshot.json +211 -0
- package/drizzle/meta/0001_snapshot.json +303 -0
- package/drizzle/meta/0002_snapshot.json +364 -0
- package/drizzle/meta/0003_snapshot.json +427 -0
- package/drizzle/meta/0004_snapshot.json +433 -0
- package/drizzle/meta/0005_snapshot.json +901 -0
- package/drizzle/meta/_journal.json +55 -0
- package/drizzle.config.ts +11 -0
- package/integration/aptos-x402.mdc +413 -0
- package/package.json +1 -6
- package/proxy.ts +182 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/logo_dark.svg +5 -0
- package/public/logo_white.png +0 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/tsconfig.sdk.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/lib/aptos-utils.d.ts +0 -47
- package/dist/lib/aptos-utils.d.ts.map +0 -1
- package/dist/lib/aptos-utils.js +0 -126
- package/dist/lib/aptos-utils.js.map +0 -1
- package/dist/lib/arc8004/chain/index.d.ts +0 -10
- package/dist/lib/arc8004/chain/index.d.ts.map +0 -1
- package/dist/lib/arc8004/chain/index.js +0 -9
- package/dist/lib/arc8004/chain/index.js.map +0 -1
- package/dist/lib/arc8004/chain/types.d.ts +0 -190
- package/dist/lib/arc8004/chain/types.d.ts.map +0 -1
- package/dist/lib/arc8004/chain/types.js +0 -278
- package/dist/lib/arc8004/chain/types.js.map +0 -1
- package/dist/lib/arc8004/identity/agent-card.d.ts +0 -66
- package/dist/lib/arc8004/identity/agent-card.d.ts.map +0 -1
- package/dist/lib/arc8004/identity/agent-card.js +0 -141
- package/dist/lib/arc8004/identity/agent-card.js.map +0 -1
- package/dist/lib/arc8004/identity/index.d.ts +0 -7
- package/dist/lib/arc8004/identity/index.d.ts.map +0 -1
- package/dist/lib/arc8004/identity/index.js +0 -7
- package/dist/lib/arc8004/identity/index.js.map +0 -1
- package/dist/lib/arc8004/identity/registry.d.ts +0 -73
- package/dist/lib/arc8004/identity/registry.d.ts.map +0 -1
- package/dist/lib/arc8004/identity/registry.js +0 -447
- package/dist/lib/arc8004/identity/registry.js.map +0 -1
- package/dist/lib/arc8004/index.d.ts +0 -49
- package/dist/lib/arc8004/index.d.ts.map +0 -1
- package/dist/lib/arc8004/index.js +0 -54
- package/dist/lib/arc8004/index.js.map +0 -1
- package/dist/lib/arc8004/reputation/index.d.ts +0 -7
- package/dist/lib/arc8004/reputation/index.d.ts.map +0 -1
- package/dist/lib/arc8004/reputation/index.js +0 -7
- package/dist/lib/arc8004/reputation/index.js.map +0 -1
- package/dist/lib/arc8004/reputation/registry.d.ts +0 -60
- package/dist/lib/arc8004/reputation/registry.d.ts.map +0 -1
- package/dist/lib/arc8004/reputation/registry.js +0 -373
- package/dist/lib/arc8004/reputation/registry.js.map +0 -1
- package/dist/lib/arc8004/reputation/scoring.d.ts +0 -60
- package/dist/lib/arc8004/reputation/scoring.d.ts.map +0 -1
- package/dist/lib/arc8004/reputation/scoring.js +0 -130
- package/dist/lib/arc8004/reputation/scoring.js.map +0 -1
- package/dist/lib/arc8004/storage/index.d.ts +0 -44
- package/dist/lib/arc8004/storage/index.d.ts.map +0 -1
- package/dist/lib/arc8004/storage/index.js +0 -76
- package/dist/lib/arc8004/storage/index.js.map +0 -1
- package/dist/lib/arc8004/storage/memory.d.ts +0 -114
- package/dist/lib/arc8004/storage/memory.d.ts.map +0 -1
- package/dist/lib/arc8004/storage/memory.js +0 -458
- package/dist/lib/arc8004/storage/memory.js.map +0 -1
- package/dist/lib/arc8004/storage/postgres.d.ts +0 -93
- package/dist/lib/arc8004/storage/postgres.d.ts.map +0 -1
- package/dist/lib/arc8004/storage/postgres.js +0 -637
- package/dist/lib/arc8004/storage/postgres.js.map +0 -1
- package/dist/lib/arc8004/storage/types.d.ts +0 -201
- package/dist/lib/arc8004/storage/types.d.ts.map +0 -1
- package/dist/lib/arc8004/storage/types.js +0 -12
- package/dist/lib/arc8004/storage/types.js.map +0 -1
- package/dist/lib/arc8004/types.d.ts +0 -323
- package/dist/lib/arc8004/types.d.ts.map +0 -1
- package/dist/lib/arc8004/types.js +0 -75
- package/dist/lib/arc8004/types.js.map +0 -1
- package/dist/lib/arc8004/validation/index.d.ts +0 -6
- package/dist/lib/arc8004/validation/index.d.ts.map +0 -1
- package/dist/lib/arc8004/validation/index.js +0 -6
- package/dist/lib/arc8004/validation/index.js.map +0 -1
- package/dist/lib/arc8004/validation/registry.d.ts +0 -72
- package/dist/lib/arc8004/validation/registry.d.ts.map +0 -1
- package/dist/lib/arc8004/validation/registry.js +0 -268
- package/dist/lib/arc8004/validation/registry.js.map +0 -1
- package/dist/lib/db/index.d.ts +0 -12
- package/dist/lib/db/index.d.ts.map +0 -1
- package/dist/lib/db/index.js +0 -33
- package/dist/lib/db/index.js.map +0 -1
- package/dist/lib/db/schema.d.ts +0 -2086
- package/dist/lib/db/schema.d.ts.map +0 -1
- package/dist/lib/db/schema.js +0 -220
- package/dist/lib/db/schema.js.map +0 -1
- package/dist/lib/facilitator-client.d.ts +0 -89
- package/dist/lib/facilitator-client.d.ts.map +0 -1
- package/dist/lib/facilitator-client.js +0 -140
- package/dist/lib/facilitator-client.js.map +0 -1
- package/dist/lib/index.d.ts +0 -44
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -56
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/services/geomi-gas-station.d.ts +0 -33
- package/dist/lib/services/geomi-gas-station.d.ts.map +0 -1
- package/dist/lib/services/geomi-gas-station.js +0 -97
- package/dist/lib/services/geomi-gas-station.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -6
- package/dist/lib/utils.js.map +0 -1
- package/dist/lib/x402-axios.d.ts +0 -45
- package/dist/lib/x402-axios.d.ts.map +0 -1
- package/dist/lib/x402-axios.js +0 -242
- package/dist/lib/x402-axios.js.map +0 -1
- package/dist/lib/x402-middleware.d.ts +0 -11
- package/dist/lib/x402-middleware.d.ts.map +0 -1
- package/dist/lib/x402-middleware.js +0 -183
- package/dist/lib/x402-middleware.js.map +0 -1
- package/dist/lib/x402-protocol-types.d.ts +0 -177
- package/dist/lib/x402-protocol-types.d.ts.map +0 -1
- package/dist/lib/x402-protocol-types.js +0 -63
- package/dist/lib/x402-protocol-types.js.map +0 -1
- package/dist/lib/x402-types.d.ts +0 -83
- package/dist/lib/x402-types.d.ts.map +0 -1
- package/dist/lib/x402-types.js +0 -30
- package/dist/lib/x402-types.js.map +0 -1
- package/dist/src/arc8004/client.d.ts +0 -313
- package/dist/src/arc8004/client.d.ts.map +0 -1
- package/dist/src/arc8004/client.js +0 -586
- package/dist/src/arc8004/client.js.map +0 -1
- package/dist/src/arc8004/index.d.ts +0 -54
- package/dist/src/arc8004/index.d.ts.map +0 -1
- package/dist/src/arc8004/index.js +0 -57
- package/dist/src/arc8004/index.js.map +0 -1
- package/dist/src/components/ui/shadcn-io/code-block/index.d.ts +0 -67
- package/dist/src/components/ui/shadcn-io/code-block/index.d.ts.map +0 -1
- package/dist/src/components/ui/shadcn-io/code-block/index.js +0 -209
- package/dist/src/components/ui/shadcn-io/code-block/index.js.map +0 -1
- package/dist/src/components/ui/shadcn-io/code-block/index.jsx +0 -227
- package/dist/src/components/ui/shadcn-io/code-block/index.jsx.map +0 -1
- package/dist/src/components/ui/shadcn-io/code-block/server.d.ts +0 -10
- package/dist/src/components/ui/shadcn-io/code-block/server.d.ts.map +0 -1
- package/dist/src/components/ui/shadcn-io/code-block/server.js +0 -35
- package/dist/src/components/ui/shadcn-io/code-block/server.js.map +0 -1
- package/dist/src/components/ui/shadcn-io/code-block/server.jsx +0 -34
- package/dist/src/components/ui/shadcn-io/code-block/server.jsx.map +0 -1
- package/dist/src/index.d.ts +0 -11
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -13
- package/dist/src/index.js.map +0 -1
- package/dist/src/server/index.d.ts +0 -6
- package/dist/src/server/index.d.ts.map +0 -1
- package/dist/src/server/index.js +0 -5
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/next.d.ts +0 -44
- package/dist/src/server/next.d.ts.map +0 -1
- package/dist/src/server/next.js +0 -220
- package/dist/src/server/next.js.map +0 -1
- package/dist/src/types/config.d.ts +0 -43
- package/dist/src/types/config.d.ts.map +0 -1
- package/dist/src/types/config.js +0 -6
- package/dist/src/types/config.js.map +0 -1
- package/dist/src/types/index.d.ts +0 -9
- package/dist/src/types/index.d.ts.map +0 -1
- package/dist/src/types/index.js +0 -7
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/protocol.d.ts +0 -119
- package/dist/src/types/protocol.d.ts.map +0 -1
- package/dist/src/types/protocol.js +0 -12
- package/dist/src/types/protocol.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.2.4] - 2026-01-17
|
|
6
|
+
|
|
7
|
+
### 🐛 Bug Fixes
|
|
8
|
+
- Fixed npm package missing README and CHANGELOG
|
|
9
|
+
|
|
10
|
+
## [2.2.3] - 2026-01-17
|
|
11
|
+
|
|
12
|
+
### 🐛 Bug Fixes
|
|
13
|
+
- Fixed minor typo in CHANGELOG
|
|
14
|
+
|
|
15
|
+
## [2.2.2] - 2026-01-17
|
|
16
|
+
|
|
17
|
+
### 📚 Documentation
|
|
18
|
+
- Removed v1 deprecation warning from README
|
|
19
|
+
|
|
20
|
+
## [2.2.1] - 2026-01-17
|
|
21
|
+
|
|
22
|
+
### 📚 Documentation
|
|
23
|
+
- Fixed README examples: Removed non-existent `x402axios.create()` references
|
|
24
|
+
- Clarified v2 protocol changes: Header-based architecture, standard headers (no "X-" prefix), fungible assets
|
|
25
|
+
- Updated "What's new" section with accurate v2.2.0 features
|
|
26
|
+
|
|
27
|
+
## [2.2.0] - 2026-01-17
|
|
28
|
+
|
|
29
|
+
### 🌟 New Features (v2 Protocol)
|
|
30
|
+
- **Protocol Standards**: Removed "X-" prefix from headers (now `PAYMENT-SIGNATURE`).
|
|
31
|
+
- **Header-Based Architecture**: Moved payment specifications and proofs to headers.
|
|
32
|
+
- **Fungible Assets**: Native support for USDC transfers on Aptos (via `primary_fungible_store`).
|
|
33
|
+
- **Geomi Gas Sponsorship**: Facilitator-sponsored gas fees for better UX.
|
|
34
|
+
- **ARC-8004**: Added Agent Trust Layer (Identity, Reputation, Validation).
|
|
35
|
+
|
|
36
|
+
### ⚡ Improvements
|
|
37
|
+
- **Performance**: Faster settlement times and bug fixes.
|
|
38
|
+
- **Bug Fixes**: Resolved performance bottlenecks and improved type safety.
|
|
39
|
+
|
|
40
|
+
## [1.0.2] - 2025-01-10
|
|
41
|
+
|
|
42
|
+
### ⚡ Performance Optimizations
|
|
43
|
+
- **Hex Encoding**: Replaced base64 encoding with hex for transaction/signature (faster, more compact)
|
|
44
|
+
- Direct JSON payment header (no outer base64 encoding)
|
|
45
|
+
- ~1-2ms improvement per request
|
|
46
|
+
- **Removed Verification Caching**: Eliminated middleware verification cache overhead (~5ms saved)
|
|
47
|
+
- **Skipped Middleware Validation**: Removed redundant validation checks in middleware (~2-5ms saved)
|
|
48
|
+
- Single source of truth: facilitator handles all validation
|
|
49
|
+
- **HTTP/2 Keep-Alive**: Added persistent connections for facilitator calls
|
|
50
|
+
- ~50-100ms improvement on subsequent requests
|
|
51
|
+
- Connection pooling and multiplexing support
|
|
52
|
+
|
|
53
|
+
### 📊 Performance Impact
|
|
54
|
+
- **First call**: ~8-12ms faster
|
|
55
|
+
- **Subsequent calls**: ~58-112ms faster (with HTTP/2 keep-alive)
|
|
56
|
+
- **Total improvement**: Combined with previous optimizations (async confirmation, simulation-only verification)
|
|
57
|
+
|
|
58
|
+
### 🔧 Technical Changes
|
|
59
|
+
- Updated all components to use consistent hex + JSON format
|
|
60
|
+
- Client (`x402axios`): Hex encoding for transaction/signature
|
|
61
|
+
- Middleware: Direct JSON parsing (no base64 decode)
|
|
62
|
+
- Facilitator endpoints: Hex decoding for transaction/signature
|
|
63
|
+
- Improved code consistency across client, middleware, and facilitator
|
|
64
|
+
- Better debugging with hex encoding (more human-readable)
|
|
65
|
+
|
|
66
|
+
### 🐛 Bug Fixes
|
|
67
|
+
- Fixed TypeScript build error in middleware (type assertion for SettleResponse)
|
|
68
|
+
- Ensured all components use the same encoding format
|
|
69
|
+
|
|
70
|
+
### ⚠️ Breaking Changes
|
|
71
|
+
- **Not backward compatible**: Old clients sending base64 will fail
|
|
72
|
+
- All components must be updated together (client, middleware, facilitator)
|
|
73
|
+
|
|
74
|
+
## [0.2.0] - 2024-12-19
|
|
75
|
+
|
|
76
|
+
### 🚀 Major Features
|
|
77
|
+
- **Axios-Compatible Interface**: Complete rewrite of x402axios to work exactly like axios
|
|
78
|
+
- Support for all axios methods: `.get()`, `.post()`, `.put()`, `.patch()`, `.delete()`, `.head()`, `.options()`
|
|
79
|
+
- Full axios configuration support: `timeout`, `headers`, `baseURL`, `params`, etc.
|
|
80
|
+
- `x402axios.create()` for creating instances with default configs
|
|
81
|
+
- Backward compatible with existing API
|
|
82
|
+
|
|
83
|
+
### 🔧 Improvements
|
|
84
|
+
- **Zero Fallbacks Policy**: Removed all silent fallbacks to testnet
|
|
85
|
+
- Throws clear errors when environment variables are missing
|
|
86
|
+
- No more silent defaults that could cause confusion
|
|
87
|
+
- **Dynamic Explorer Links**: Explorer URLs now correctly reflect the network used
|
|
88
|
+
- Mainnet transactions show `?network=mainnet`
|
|
89
|
+
- Testnet transactions show `?network=testnet`
|
|
90
|
+
- No more hardcoded testnet links
|
|
91
|
+
- **Enhanced Error Handling**: Better error messages and validation
|
|
92
|
+
- Clear indication when network configuration is missing
|
|
93
|
+
- Proper error propagation throughout the payment flow
|
|
94
|
+
|
|
95
|
+
### 🛠️ Technical Changes
|
|
96
|
+
- **Type Safety**: Full TypeScript support with proper interfaces
|
|
97
|
+
- `AxiosRequestConfig` interface for request configuration
|
|
98
|
+
- `AxiosResponse` interface for response handling
|
|
99
|
+
- Backward compatible `X402Response` alias
|
|
100
|
+
- **Network Detection**: Automatic network detection from 402 responses
|
|
101
|
+
- No hardcoded network assumptions
|
|
102
|
+
- Proper network mapping and validation
|
|
103
|
+
- **Documentation**: Comprehensive updates to all documentation
|
|
104
|
+
- Updated examples to use new axios interface
|
|
105
|
+
- Enhanced API reference with new types
|
|
106
|
+
- Improved quickstart guides
|
|
107
|
+
|
|
108
|
+
### 🐛 Bug Fixes
|
|
109
|
+
- Fixed recipient/sender address mismatch issue
|
|
110
|
+
- Corrected network configuration handling
|
|
111
|
+
- Fixed explorer URL generation for different networks
|
|
112
|
+
- Resolved environment variable loading issues
|
|
113
|
+
|
|
114
|
+
### 📚 Documentation
|
|
115
|
+
- Updated all code examples to use new axios interface
|
|
116
|
+
- Enhanced README with axios compatibility section
|
|
117
|
+
- Updated API reference with new types and methods
|
|
118
|
+
- Improved quickstart guides and troubleshooting
|
|
119
|
+
|
|
120
|
+
## [0.1.3] - 2024-12-18
|
|
121
|
+
|
|
122
|
+
### Features
|
|
123
|
+
- Initial release with basic x402 payment functionality
|
|
124
|
+
- Next.js middleware for payment protection
|
|
125
|
+
- Basic x402axios wrapper for payment handling
|
|
126
|
+
- Facilitator service for payment verification and settlement
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Agent Composer Platform - Implementation Summary
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Successfully implemented a complete Agent Composer platform that allows users to create AI agents, assign them APIs/tools, fund them with APT (testnet), and interact with them through a chat interface. Agents autonomously make payments through the x402 protocol when calling APIs.
|
|
5
|
+
|
|
6
|
+
## Implementation Details
|
|
7
|
+
|
|
8
|
+
### 1. Storage Layer (`lib/storage/`)
|
|
9
|
+
- **agents.ts**: File-based JSON storage for agent configurations
|
|
10
|
+
- CRUD operations for agents
|
|
11
|
+
- Private key storage (server-side only, never exposed to client)
|
|
12
|
+
- Client-safe agent retrieval (excludes private keys)
|
|
13
|
+
|
|
14
|
+
- **chats.ts**: File-based JSON storage for chat conversations
|
|
15
|
+
- Thread management per agent
|
|
16
|
+
- Message history with metadata (API calls, payment hashes, errors)
|
|
17
|
+
|
|
18
|
+
- **apis.ts**: Hardcoded API registry
|
|
19
|
+
- Weather API (existing `/api/protected/weather`)
|
|
20
|
+
- Example APIs for testing (stocks, search)
|
|
21
|
+
- Category-based filtering and search functionality
|
|
22
|
+
|
|
23
|
+
### 2. Agent Utilities (`lib/agent/`)
|
|
24
|
+
- **wallet.ts**: Wallet management utilities
|
|
25
|
+
- Agent wallet generation using `Account.generate()`
|
|
26
|
+
- Balance checking via Aptos SDK
|
|
27
|
+
- Faucet funding helper (for development)
|
|
28
|
+
|
|
29
|
+
- **executor.ts**: Agent execution logic
|
|
30
|
+
- Simple query parsing (keyword-based API selection)
|
|
31
|
+
- API calling via x402axios with agent's private key
|
|
32
|
+
- Error handling for insufficient funds and API failures
|
|
33
|
+
|
|
34
|
+
### 3. API Endpoints (`app/api/`)
|
|
35
|
+
- **GET /api/apis**: List available APIs (with category/search filtering)
|
|
36
|
+
- **GET /api/agents**: List all agents (client-safe, no private keys)
|
|
37
|
+
- **POST /api/agents**: Create new agent (generates wallet automatically)
|
|
38
|
+
- **GET /api/agents/[agentId]**: Get agent details
|
|
39
|
+
- **PATCH /api/agents/[agentId]**: Update agent settings
|
|
40
|
+
- **DELETE /api/agents/[agentId]**: Delete agent
|
|
41
|
+
- **GET /api/agents/[agentId]/balance**: Get agent wallet balance
|
|
42
|
+
- **GET /api/agents/[agentId]/chat**: Get chat history
|
|
43
|
+
- **POST /api/agents/[agentId]/chat**: Send message and execute agent query
|
|
44
|
+
|
|
45
|
+
### 4. UI Components (`components/composer/`)
|
|
46
|
+
- **AgentCard.tsx**: Agent display card with wallet info, balance, and actions
|
|
47
|
+
- **AgentCreationWizard.tsx**: 3-step wizard for creating agents
|
|
48
|
+
- Step 1: Display settings (name, description, image, visibility)
|
|
49
|
+
- Step 2: API/tool selection
|
|
50
|
+
- Step 3: Review and create
|
|
51
|
+
- **ApiSelector.tsx**: Searchable, filterable API browser with category tags
|
|
52
|
+
- **FundingModal.tsx**: Modal for viewing wallet address and funding agent
|
|
53
|
+
- **ChatInterface.tsx**: Full chat UI with message history, balance display, and funding integration
|
|
54
|
+
|
|
55
|
+
### 5. Pages (`app/composer/`)
|
|
56
|
+
- **page.tsx**: Main composer dashboard showing all user agents
|
|
57
|
+
- **create/page.tsx**: Agent creation page
|
|
58
|
+
- **[agentId]/page.tsx**: Agent chat interface
|
|
59
|
+
- **[agentId]/settings/page.tsx**: Agent settings and wallet management
|
|
60
|
+
|
|
61
|
+
### 6. Navigation
|
|
62
|
+
- Updated Navbar to include "Composer" link
|
|
63
|
+
|
|
64
|
+
### 7. Storage Configuration
|
|
65
|
+
- Added `.composer-data/` to `.gitignore` for local storage files
|
|
66
|
+
|
|
67
|
+
## Key Features Implemented
|
|
68
|
+
|
|
69
|
+
1. **Agent Creation**
|
|
70
|
+
- Multi-step wizard with progress indicator
|
|
71
|
+
- Wallet generation (automatic Aptos wallet per agent)
|
|
72
|
+
- API selection from registry
|
|
73
|
+
- Public/private visibility settings
|
|
74
|
+
|
|
75
|
+
2. **Agent Management**
|
|
76
|
+
- List view with balance display
|
|
77
|
+
- Edit agent settings
|
|
78
|
+
- Delete agents
|
|
79
|
+
- Wallet information display
|
|
80
|
+
|
|
81
|
+
3. **Funding System**
|
|
82
|
+
- Display agent wallet address (copyable)
|
|
83
|
+
- Real-time balance checking
|
|
84
|
+
- Direct link to Aptos testnet faucet
|
|
85
|
+
- Balance refresh functionality
|
|
86
|
+
|
|
87
|
+
4. **Chat Interface**
|
|
88
|
+
- Real-time messaging with agent
|
|
89
|
+
- Message history persistence
|
|
90
|
+
- Payment hash display for API calls
|
|
91
|
+
- Error handling with user-friendly messages
|
|
92
|
+
- Insufficient funds detection and funding prompts
|
|
93
|
+
|
|
94
|
+
5. **Agent Execution**
|
|
95
|
+
- Simple keyword-based query parsing
|
|
96
|
+
- Automatic API selection based on query
|
|
97
|
+
- x402 payment handling (automatic via x402axios)
|
|
98
|
+
- Error handling and user feedback
|
|
99
|
+
|
|
100
|
+
## Technical Stack
|
|
101
|
+
|
|
102
|
+
- **Storage**: File-based JSON (`.composer-data/` directory)
|
|
103
|
+
- **Wallet**: Aptos SDK (`@aptos-labs/ts-sdk`)
|
|
104
|
+
- **Payments**: x402 protocol via `x402axios`
|
|
105
|
+
- **UI**: Next.js 15, React 19, Tailwind CSS, shadcn/ui components
|
|
106
|
+
- **Network**: Aptos testnet (for development)
|
|
107
|
+
|
|
108
|
+
## Security Considerations
|
|
109
|
+
|
|
110
|
+
- Private keys stored server-side only (never exposed to client)
|
|
111
|
+
- Client-safe agent retrieval (excludes private keys)
|
|
112
|
+
- Server-side validation for API calls
|
|
113
|
+
- Balance checks before executing transactions
|
|
114
|
+
|
|
115
|
+
## Usage Flow
|
|
116
|
+
|
|
117
|
+
1. User navigates to `/composer`
|
|
118
|
+
2. Clicks "Create Agent"
|
|
119
|
+
3. Fills in agent details (name, description, visibility)
|
|
120
|
+
4. Selects APIs/tools for the agent
|
|
121
|
+
5. Reviews and creates agent (wallet auto-generated)
|
|
122
|
+
6. Funds agent wallet with APT (testnet)
|
|
123
|
+
7. Starts chatting with agent
|
|
124
|
+
8. Agent automatically calls APIs and makes payments via x402 protocol
|
|
125
|
+
|
|
126
|
+
## File Structure
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
lib/
|
|
130
|
+
storage/
|
|
131
|
+
agents.ts # Agent CRUD operations
|
|
132
|
+
chats.ts # Chat history storage
|
|
133
|
+
apis.ts # API registry
|
|
134
|
+
agent/
|
|
135
|
+
wallet.ts # Wallet utilities
|
|
136
|
+
executor.ts # Agent execution logic
|
|
137
|
+
|
|
138
|
+
app/
|
|
139
|
+
api/
|
|
140
|
+
apis/
|
|
141
|
+
route.ts # API listing endpoint
|
|
142
|
+
agents/
|
|
143
|
+
route.ts # Agent CRUD endpoints
|
|
144
|
+
[agentId]/
|
|
145
|
+
route.ts # Individual agent endpoints
|
|
146
|
+
balance/
|
|
147
|
+
route.ts # Balance checking
|
|
148
|
+
chat/
|
|
149
|
+
route.ts # Chat message handling
|
|
150
|
+
composer/
|
|
151
|
+
page.tsx # Main dashboard
|
|
152
|
+
create/
|
|
153
|
+
page.tsx # Agent creation
|
|
154
|
+
[agentId]/
|
|
155
|
+
page.tsx # Chat interface
|
|
156
|
+
settings/
|
|
157
|
+
page.tsx # Agent settings
|
|
158
|
+
|
|
159
|
+
components/
|
|
160
|
+
composer/
|
|
161
|
+
AgentCard.tsx
|
|
162
|
+
AgentCreationWizard.tsx
|
|
163
|
+
ApiSelector.tsx
|
|
164
|
+
FundingModal.tsx
|
|
165
|
+
ChatInterface.tsx
|
|
166
|
+
ui/
|
|
167
|
+
input.tsx # Input component (new)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Environment Variables
|
|
171
|
+
|
|
172
|
+
- `NEXT_PUBLIC_BASE_URL`: Base URL for API endpoints (optional, defaults to localhost:3000)
|
|
173
|
+
- `FACILITATOR_URL`: x402 facilitator service URL (existing)
|
|
174
|
+
- `PAYMENT_RECIPIENT_ADDRESS`: Payment recipient address (existing)
|
|
175
|
+
- `APTOS_NETWORK`: Aptos network (testnet/mainnet) (existing)
|
|
176
|
+
|
|
177
|
+
## Testing Recommendations
|
|
178
|
+
|
|
179
|
+
1. Create an agent and verify wallet generation
|
|
180
|
+
2. Fund agent wallet via testnet faucet
|
|
181
|
+
3. Test chat interface with weather queries
|
|
182
|
+
4. Verify x402 payments are processed correctly
|
|
183
|
+
5. Test error handling (insufficient funds scenario)
|
|
184
|
+
6. Test agent deletion and cleanup
|
|
185
|
+
|
|
186
|
+
## Future Enhancements (Out of Scope for MVP)
|
|
187
|
+
|
|
188
|
+
- LLM integration for smarter query understanding
|
|
189
|
+
- Public agent marketplace
|
|
190
|
+
- Usage analytics dashboard
|
|
191
|
+
- API cost estimation before calls
|
|
192
|
+
- Multi-agent workflows
|
|
193
|
+
- Agent templates/presets
|
|
194
|
+
- On-chain storage for agent metadata (mentioned by user)
|
|
195
|
+
|
|
196
|
+
## Notes
|
|
197
|
+
|
|
198
|
+
- All agent data stored locally in `.composer-data/` directory
|
|
199
|
+
- Private keys are stored in plain text (consider encryption for production)
|
|
200
|
+
- Base URL detection works in browser and server contexts
|
|
201
|
+
- Simple keyword-based API selection (can be enhanced with LLM later)
|
|
202
|
+
|
|
203
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { signIn } from 'next-auth/react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Button } from '@/components/ui/button';
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogContent,
|
|
9
|
+
DialogDescription,
|
|
10
|
+
DialogHeader,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
} from '@/components/ui/dialog';
|
|
13
|
+
import { Loader2 } from 'lucide-react';
|
|
14
|
+
import { SiGoogle, SiGithub } from '@icons-pack/react-simple-icons';
|
|
15
|
+
|
|
16
|
+
interface LoginModalProps {
|
|
17
|
+
open: boolean;
|
|
18
|
+
onOpenChange: (open: boolean) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function LoginModal({ open, onOpenChange }: LoginModalProps) {
|
|
22
|
+
const [loading, setLoading] = useState<'google' | 'github' | null>(null);
|
|
23
|
+
|
|
24
|
+
const handleSignIn = async (provider: 'google' | 'github') => {
|
|
25
|
+
setLoading(provider);
|
|
26
|
+
try {
|
|
27
|
+
await signIn(provider, { callbackUrl: '/' });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Sign in error:', error);
|
|
30
|
+
setLoading(null);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
36
|
+
<DialogContent className="sm:max-w-[380px] p-6 bg-white border border-zinc-200 shadow-xl rounded-xl">
|
|
37
|
+
<DialogHeader className="space-y-1 pb-2">
|
|
38
|
+
<DialogTitle className="text-lg font-semibold text-zinc-900">
|
|
39
|
+
Sign in
|
|
40
|
+
</DialogTitle>
|
|
41
|
+
<DialogDescription className="text-sm text-zinc-500">
|
|
42
|
+
Continue to Agent Composer (Beta)
|
|
43
|
+
</DialogDescription>
|
|
44
|
+
</DialogHeader>
|
|
45
|
+
|
|
46
|
+
<div className="space-y-3 pt-2">
|
|
47
|
+
<Button
|
|
48
|
+
onClick={() => handleSignIn('google')}
|
|
49
|
+
disabled={loading !== null}
|
|
50
|
+
variant="outline"
|
|
51
|
+
className="w-full h-11 bg-white hover:bg-zinc-50 text-zinc-900 border border-zinc-200 font-medium"
|
|
52
|
+
>
|
|
53
|
+
{loading === 'google' ? (
|
|
54
|
+
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
|
|
55
|
+
) : (
|
|
56
|
+
<SiGoogle className="w-4 h-4 mr-2" />
|
|
57
|
+
)}
|
|
58
|
+
Continue with Google
|
|
59
|
+
</Button>
|
|
60
|
+
|
|
61
|
+
<div className="relative">
|
|
62
|
+
<Button
|
|
63
|
+
disabled={true}
|
|
64
|
+
variant="outline"
|
|
65
|
+
className="w-full h-11 bg-zinc-50 text-zinc-400 border border-zinc-100 cursor-not-allowed font-medium"
|
|
66
|
+
>
|
|
67
|
+
<SiGithub className="w-4 h-4 mr-2 opacity-50" />
|
|
68
|
+
Continue with GitHub
|
|
69
|
+
</Button>
|
|
70
|
+
<span className="absolute right-3 top-1/2 -translate-y-1/2 text-[10px] px-1.5 py-0.5 bg-zinc-200 text-zinc-500 rounded font-medium">
|
|
71
|
+
Soon
|
|
72
|
+
</span>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<p className="text-[11px] text-zinc-400 text-center pt-3">
|
|
77
|
+
By continuing, you agree to our Terms & Privacy Policy
|
|
78
|
+
</p>
|
|
79
|
+
</DialogContent>
|
|
80
|
+
</Dialog>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { SessionProvider as NextAuthSessionProvider } from 'next-auth/react';
|
|
4
|
+
|
|
5
|
+
export function SessionProvider({ children }: { children: React.ReactNode }) {
|
|
6
|
+
return <NextAuthSessionProvider>{children}</NextAuthSessionProvider>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { signOut } from 'next-auth/react';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { Button } from '@/components/ui/button';
|
|
6
|
+
import { LogOut, User, ChevronDown } from 'lucide-react';
|
|
7
|
+
import { useState, useRef, useEffect } from 'react';
|
|
8
|
+
import { LoginModal } from './LoginModal';
|
|
9
|
+
import type { Session } from 'next-auth';
|
|
10
|
+
|
|
11
|
+
interface UserMenuClientProps {
|
|
12
|
+
session: Session | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function UserMenuClient({ session }: UserMenuClientProps) {
|
|
16
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
+
const [loginModalOpen, setLoginModalOpen] = useState(false);
|
|
18
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
function handleClickOutside(event: MouseEvent) {
|
|
22
|
+
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
|
23
|
+
setIsOpen(false);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
27
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
if (!session) {
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<Button
|
|
34
|
+
variant="outline"
|
|
35
|
+
size="sm"
|
|
36
|
+
className="border-zinc-200"
|
|
37
|
+
onClick={() => setLoginModalOpen(true)}
|
|
38
|
+
>
|
|
39
|
+
Sign In
|
|
40
|
+
</Button>
|
|
41
|
+
<LoginModal open={loginModalOpen} onOpenChange={setLoginModalOpen} />
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="relative" ref={menuRef}>
|
|
48
|
+
<button
|
|
49
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
50
|
+
className="flex items-center gap-2 px-3 py-1.5 rounded-full bg-zinc-100 hover:bg-zinc-200 transition-colors"
|
|
51
|
+
>
|
|
52
|
+
{session.user?.image ? (
|
|
53
|
+
<img
|
|
54
|
+
src={session.user.image}
|
|
55
|
+
alt={session.user.name || 'User'}
|
|
56
|
+
className="w-7 h-7 rounded-full"
|
|
57
|
+
/>
|
|
58
|
+
) : (
|
|
59
|
+
<div className="w-7 h-7 rounded-full bg-zinc-900 flex items-center justify-center text-white text-sm font-medium">
|
|
60
|
+
{session.user?.name?.charAt(0) || 'U'}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
<span className="text-sm font-medium text-zinc-900 hidden sm:inline">
|
|
64
|
+
{session.user?.name?.split(' ')[0] || 'User'}
|
|
65
|
+
</span>
|
|
66
|
+
<ChevronDown className="w-4 h-4 text-zinc-500" />
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
{isOpen && (
|
|
70
|
+
<div className="absolute right-0 mt-2 w-72 rounded-xl bg-white shadow-lg border border-zinc-200 py-2 z-50">
|
|
71
|
+
<div className="px-4 py-3 border-b border-zinc-100">
|
|
72
|
+
<div className="flex items-center gap-3">
|
|
73
|
+
{session.user?.image ? (
|
|
74
|
+
<img
|
|
75
|
+
src={session.user.image}
|
|
76
|
+
alt={session.user.name || 'User'}
|
|
77
|
+
className="w-10 h-10 rounded-full"
|
|
78
|
+
/>
|
|
79
|
+
) : (
|
|
80
|
+
<div className="w-10 h-10 rounded-full bg-zinc-900 flex items-center justify-center text-white font-medium">
|
|
81
|
+
{session.user?.name?.charAt(0) || 'U'}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
<div className="flex-1 min-w-0">
|
|
85
|
+
<p className="text-sm font-medium text-zinc-900 truncate">
|
|
86
|
+
{session.user?.name || 'User'}
|
|
87
|
+
</p>
|
|
88
|
+
<p className="text-xs text-zinc-500 truncate">
|
|
89
|
+
{session.user?.email}
|
|
90
|
+
</p>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div className="px-2 py-2">
|
|
96
|
+
<Link
|
|
97
|
+
href="/composer"
|
|
98
|
+
onClick={() => setIsOpen(false)}
|
|
99
|
+
className="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-zinc-50 transition-colors"
|
|
100
|
+
>
|
|
101
|
+
<User className="w-4 h-4 text-zinc-500" />
|
|
102
|
+
<span className="text-sm text-zinc-700">My Agents</span>
|
|
103
|
+
</Link>
|
|
104
|
+
<button
|
|
105
|
+
onClick={() => signOut({ callbackUrl: '/' })}
|
|
106
|
+
className="w-full flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-red-50 transition-colors text-red-600"
|
|
107
|
+
>
|
|
108
|
+
<LogOut className="w-4 h-4" />
|
|
109
|
+
<span className="text-sm">Sign Out</span>
|
|
110
|
+
</button>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
)}
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|