///
The Quicksilver SDK empowers developers to define and manage sophisticated economic agents through a fluent Domain-Specific Language (DSL). This page delves into how to create main accounts, delegate
35 views
~35 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The Quicksilver SDK empowers developers to define and manage sophisticated economic agents through a fluent Domain-Specific Language (DSL). This page delves into how to create main accounts, delegate sub-agents, manage their limits, and retrieve their balances using the SDK's powerful active Account model.
This example is derived from examples/1-accounts-and-delegation.ts.
Traditionally, interacting with an API for accounts might involve generic REST calls to create, update, or fetch data. The Quicksilver SDK introduces Active Accounts, which are not merely data containers but intelligent objects equipped with methods to perform actions directly on themselves, such as delegate(), updateLimits(), or getBalance(). This transforms your code into a more intuitive and expressive representation of your economic logic.
Let's walk through the process of setting up a main AI agent and delegating sub-agents with specific permissions.
As with any interaction with the Quicksilver Engine, the first step is to initialize the QuicksilverClient. For development and testing, the sandbox environment is recommended. You can find more details on client initialization in the [Getting Started with Quicksilver SDK] guide.
The client.accounts.create() method is used to provision new accounts. When creating a new account, you provide a name, an account_type, and optionally define limits. The SDK directly returns an active Account model, ready for interaction. Notice how root accounts (accounts without a parent_id) are automatically marked as verified by the system for immediate use.
One of the core features for agent-based commerce is the ability to delegate responsibilities to sub-agents. The Account model's delegate() method provides a fluent way to create new AgentDelegated accounts directly from a parent Account. This establishes a hierarchical relationship and automatically applies specified limits to the sub-agent.
This fluent delegation pattern simplifies the creation of complex organizational structures for your AI agents, allowing you to manage permissions and budgets effectively.
The active Account model allows you to easily fetch a list of its direct delegated sub-agents using the getChildren() method. This returns an array of Account objects, each representing a child account.
Managing financial exposure and control is crucial. The updateLimits() method on an active Account model enables you to dynamically adjust the spending limits (daily, per transaction, or total) for that account.
To monitor the financial status of any account, the getBalance() method provides its current balance and currency.
examples/1-accounts-and-delegation.ts)This example demonstrates the power of the Quicksilver SDK's active Account model and its fluent API for managing accounts and their delegated sub-agents. By interacting directly with Account objects, developers can write cleaner, more expressive, and type-safe code that truly reflects the hierarchical nature of agent commerce. You can learn more about the methods available on the Account model in the [Account Model API Reference].