svf agi solver
AGI Solver is a backend system written in TypeScript designed to reliably fulfill on-chain interaction requests (Agent Generated Intents) for AI agents. It serves as a critical bridge between AI agents and blockchain interactions, ensuring reliable execution of complex on-chain operations.
-
Clone the repository
-
Set up environment variables:
cp .env.example .env
cd contracts cp .env.example .env -
Deploy contracts
start an anvil node first
anvil
then install the dependencies under the
contracts/foler:forge installfinally, under root directory
make deploy -
Start solver
make start -
Publish an agi
#e.g. make sellTokenA
See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md.
Thanks! π
π This package was templated with
create-typescript-appusing the Bingo engine.
The AGI Queue Manager is a system that manages the processing queue of Agent Generated Intents (AGIs). It handles the lifecycle of AGI tasks from creation to completion, including asset withdrawal, swapping, and deposit operations.
- Items are added to queue via
add(agiId) - When processing starts, items are moved to end of queue before processing
- Items are only removed from queue when fully completed (status 2)
- Tasks that have failed swaps after MAX_RETRIES attempts will be skipped and removed from queue
- Withdraw asset from contract
- Contract status becomes 1
- Set internal status to 3 (SwapInitiated)
- Begin swap operation
- Perform swap operation
- Set internal status to 4 (SwapCompleted) when swap is done
- Deposit swapped assets back to the contract
- Set internal status to 2 (ProceedsReceived)
- Clean up internal state
- Remove from queue
- Use contract status as primary source of truth
- Only use internal SwapCompleted status when:
- Contract status is 1 (DispensedPendingProceeds)
- And we have an internal status (not undefined)
- Wait for transaction confirmation before proceeding
- Handle transaction failures gracefully
- Keep items in queue until fully processed
- Process one item at a time
- Move items to end of queue before processing
- Only remove items when fully completed
- Maintain FIFO order while allowing other items to be processed
The queue manager is implemented in TypeScript and uses a combination of contract interactions and internal state management to track the progress of each AGI task. It includes retry mechanisms for failed operations and maintains a strict order of operations to ensure the integrity of the asset swapping process.
- Automatic retry of failed operations
- Transaction confirmation waiting
- FIFO queue processing
- State management for both contract and internal states
- Error handling and logging
- Configurable retry limits and delays
- Failed swaps are retried up to MAX_RETRIES times
- Tasks exceeding retry limits are removed from the queue
- Transaction failures are handled gracefully with appropriate logging
- System maintains queue integrity even during failures