@q00bs/agent-sdk 1.0.5 → 1.1.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.
package/README.md CHANGED
@@ -107,8 +107,9 @@
107
107
  │ └── ERC8004Manager — ERC-8004 identity & reputation │
108
108
  │ │
109
109
  │ ── Wallet Mode ─────────────────────────────────────── │
110
- Privy server wallet → HSM custody (REQUIRED)
111
- Private keys NEVER leave Privy's secure enclave
110
+ Trust APIQ00bs' Privy HSM custody
111
+ No Privy credentials needed by SDK consumers
112
+ │ All wallets appear on Q00bs' Privy dashboard │
112
113
  │ │
113
114
  │ ── On-Chain Contracts (Base Mainnet) ───────────────── │
114
115
  │ Q00bFactory → 0xe611...52b0 │
@@ -142,29 +143,25 @@ The SDK has a single runtime dependency: [`viem`](https://viem.sh) (^2.21.0).
142
143
 
143
144
  ## Quick Start
144
145
 
145
- All Q00bs agents use **Privy server wallets**. Private keys are held in Privy's HSMthey never appear in your code, env vars, or agent memory.
146
+ All Q00bs agent wallets are created and managed by **Q00bs' own Privy infrastructure** via the Trust API. You never need Privy credentialsjust point the SDK at the Trust API URL and it handles everything.
146
147
 
147
148
  ```typescript
148
149
  import { Q00bsAgent } from '@q00bs/agent-sdk';
149
150
 
150
151
  const agent = new Q00bsAgent({
151
- privy: {
152
- appId: process.env.PRIVY_APP_ID!,
153
- appSecret: process.env.PRIVY_APP_SECRET!,
154
- walletId: process.env.PRIVY_WALLET_ID, // optional — creates new if omitted
155
- },
156
- rpcUrl: process.env.BASE_RPC_URL || 'https://mainnet.base.org',
157
- registryAddress: '0xF7c8acecdfbBEAf08F596ab1F85f68f7E6568172',
158
- escrowAddress: '0xe1139A7BebD89e534d4C459b252BA0963e0A0499',
159
- consensusAddress: '0xcB4A36a7c99e42B3F4b1c8EE6EDD0f3A7DDEcC76',
152
+ trustApiUrl: 'https://q00bs-trust-api.onrender.com',
153
+ walletId: process.env.Q00BS_WALLET_ID, // optional — creates new if omitted
160
154
  maxTransactionValue: '0.1', // Max 0.1 ETH per tx
161
155
  dailySpendLimit: '1.0', // Max 1 ETH per day
162
156
  });
163
157
 
164
158
  await agent.initialize();
165
- // → Privy wallet created/loaded with spending policy
166
- // → Private key held in Privy's HSM — never in your code
159
+ // → Wallet created under Q00bs' Privy app (appears on Q00bs' Privy dashboard)
160
+ // → Private key held in Q00bs' HSM — never in your code
161
+ // → Store agent.walletId for reuse in next session
162
+
167
163
  console.log(`Agent wallet: ${agent.address}`);
164
+ console.log(`Wallet ID: ${agent.walletId}`); // Save this!
168
165
  console.log(`Agent ID: ${agent.agentId}`);
169
166
  ```
170
167
 
@@ -251,8 +248,8 @@ import { Q00bsAgent } from '@q00bs/agent-sdk';
251
248
  // Create the agent (does NOT connect to blockchain yet)
252
249
  const agent = new Q00bsAgent(config: AgentConfig);
253
250
 
254
- // Initialize blockchain connections and sub-modules
255
- await agent.initialize(walletPolicy?: PrivyWalletPolicy): Promise<void>;
251
+ // Initialize blockchain connections, create/load wallet via Trust API
252
+ await agent.initialize(): Promise<void>;
256
253
  ```
257
254
 
258
255
  **Properties (after initialization):**
@@ -262,9 +259,7 @@ await agent.initialize(walletPolicy?: PrivyWalletPolicy): Promise<void>;
262
259
  | `agentId` | `number \| undefined` | On-chain agent ID (set after registration) |
263
260
  | `initialized` | `boolean` | Whether `initialize()` has been called |
264
261
  | `address` | `string` | Agent's wallet address |
265
- | `walletMode` | `'privy'` | Wallet mode (always Privy) |
266
- | `isPrivyMode` | `boolean` | Whether using Privy wallet |
267
- | `privyWallet` | `PrivyWalletManager \| undefined` | Privy manager (Mode 2 only) |
262
+ | `walletId` | `string \| undefined` | Privy wallet ID (save for reuse) |
268
263
  | `erc8004` | `ERC8004Manager \| undefined` | ERC-8004 manager instance |
269
264
 
270
265
  #### Registration
@@ -392,26 +387,26 @@ const request: ConsensusRecord = await agent.getConsensusRequest(requestId);
392
387
  | ≤ 1.00 ETH | 4 of 6 peers | No |
393
388
  | > 1.00 ETH | 4 of 6 peers | **Yes** |
394
389
 
395
- #### Privy Wallet Management (Mode 2)
390
+ #### Wallet Management
396
391
 
397
- ```typescript
398
- // Get wallet info
399
- const walletInfo: PrivyWalletInfo | undefined = agent.getPrivyWalletInfo();
392
+ All wallets are managed via Q00bs' Trust API. No Privy credentials needed.
400
393
 
394
+ ```typescript
401
395
  // Update spending policy dynamically
402
- await agent.updatePrivyPolicy({
403
- name: 'Elevated Limits',
404
- rules: [
405
- { type: 'max_transaction_value', value: '0.5' },
406
- { type: 'daily_spend_limit', value: '5.0' },
407
- { type: 'allowed_chains', value: ['8453'] },
408
- { type: 'allowed_contracts', value: ['0xRegistry...', '0xEscrow...'] },
409
- { type: 'require_human_approval', value: true },
410
- ],
396
+ await agent.updateWalletPolicy({
397
+ maxTransactionValue: '0.5',
398
+ dailySpendLimit: '5.0',
411
399
  });
412
400
 
413
- // Sign a message (works in both modes)
401
+ // Sign a message (routed through Trust API → Q00bs' Privy)
414
402
  const signature: string = await agent.signMessage('Hello from Q00bs!');
403
+
404
+ // Send a transaction (policy-checked before broadcast)
405
+ const txHash: string = await agent.sendTransaction(
406
+ '0xContract...', // to
407
+ '1000000000000', // value in wei (optional)
408
+ '0x...', // encoded calldata (optional)
409
+ );
415
410
  ```
416
411
 
417
412
  #### ERC-8004 Trustless Agents
@@ -535,39 +530,28 @@ const active = await discovery.isActive(agentId);
535
530
 
536
531
  #### PrivyWalletManager
537
532
 
533
+ > **Note:** This class is used internally by the Q00bs Trust API server. As an SDK consumer, you don't need to use it directly — wallet operations are routed through the Trust API automatically. It is exported for advanced use cases (e.g., running your own Q00bs API node).
534
+
538
535
  ```typescript
539
536
  import { PrivyWalletManager } from '@q00bs/agent-sdk';
540
537
 
538
+ // Only used by the API server (requires Q00bs' Privy credentials)
541
539
  const manager = new PrivyWalletManager(
542
- { appId: '...', appSecret: '...' },
540
+ { appId: PRIVY_APP_ID, appSecret: PRIVY_APP_SECRET },
543
541
  logger,
544
542
  );
545
543
 
546
- // Wallet lifecycle
547
544
  const wallet = await manager.createWallet(policy);
548
545
  const existing = await manager.getWallet(walletId);
549
- const info = await manager.initialize(policy); // create or load
550
-
551
- // Policy management
546
+ const info = await manager.initialize(policy);
552
547
  await manager.setPolicy(walletId, policy);
553
- const defaultPolicy = PrivyWalletManager.buildDefaultPolicy(
554
- '0.1', // maxTxValueEth
555
- '1.0', // dailyLimitEth
556
- ['0x...'], // allowedContracts
557
- true, // requireHumanApproval
558
- );
559
548
 
560
- // Transactions
561
549
  const result = await manager.sendTransaction(walletId, {
562
550
  to: '0xContract...',
563
- data: '0x...', // encoded calldata
564
- value: '10000000000000', // wei
551
+ data: '0x...',
552
+ value: '10000000000000',
565
553
  chainId: 8453,
566
554
  });
567
-
568
- // Signing
569
- const sig = await manager.signMessage(walletId, 'message');
570
- const typedSig = await manager.signTypedData(walletId, typedData);
571
555
  ```
572
556
 
573
557
  #### ERC8004Manager
@@ -616,8 +600,10 @@ Low-level helpers for creating blockchain clients directly:
616
600
  import { createPrivyClients, createLogger } from '@q00bs/agent-sdk';
617
601
 
618
602
  // Create Privy-managed blockchain clients
603
+ // NOTE: This requires Q00bs' Privy credentials — used by the API server internally.
604
+ // As an SDK consumer, use Q00bsAgent with trustApiUrl instead.
619
605
  const clients = createPrivyClients({
620
- privy: { appId: '...', appSecret: '...' },
606
+ privy: { appId: PRIVY_APP_ID, appSecret: PRIVY_APP_SECRET },
621
607
  rpcUrl: 'https://mainnet.base.org',
622
608
  });
623
609
  // Returns: { publicClient, privyWalletManager, chain, mode: 'privy' }
@@ -636,9 +622,10 @@ All types are exported from `@q00bs/agent-sdk` and centralized in `src/types.ts`
636
622
 
637
623
  ```typescript
638
624
  interface AgentConfig {
639
- privy: PrivyConfig; // Privy server wallet credentials (REQUIRED)
640
- rpcUrl: string; // Base mainnet RPC URL
641
- registryAddress: string; // AgentRegistry contract
625
+ trustApiUrl: string; // Q00bs Trust API URL (REQUIRED)
626
+ walletId?: string; // Existing wallet ID (creates new if omitted)
627
+ rpcUrl?: string; // Base mainnet RPC URL (default: public endpoint)
628
+ registryAddress?: string; // AgentRegistry contract (default: SDK constant)
642
629
  escrowAddress?: string; // AgentEscrow contract (optional)
643
630
  consensusAddress?: string; // ConsensusModule contract (optional)
644
631
  agentId?: number; // Pre-existing on-chain agent ID
@@ -646,6 +633,7 @@ interface AgentConfig {
646
633
  maxHops?: number; // Max trust-path hops (default: 3)
647
634
  maxTransactionValue?: string; // Max ETH per tx (default: '0.1')
648
635
  dailySpendLimit?: string; // Max ETH per day (default: '1')
636
+ x402TxHash?: string; // x402 payment hash for API auth
649
637
  erc8004?: ERC8004Config; // ERC-8004 registry addresses
650
638
  logLevel?: 'debug' | 'info' | 'warn' | 'error';
651
639
  }
@@ -782,11 +770,13 @@ interface ConsensusResult {
782
770
 
783
771
  ### Privy Types
784
772
 
773
+ > **Note:** These types are used internally by the Q00bs Trust API server. SDK consumers do NOT need to configure Privy directly — wallets are managed through `trustApiUrl`.
774
+
785
775
  ```typescript
786
776
  interface PrivyConfig {
787
- appId: string; // Privy App ID
788
- appSecret: string; // Privy App Secret (server-side only)
789
- walletId?: string; // Existing wallet ID (creates new if omitted)
777
+ appId: string; // Q00bs Privy App ID (API server only)
778
+ appSecret: string; // Q00bs Privy App Secret (API server only)
779
+ walletId?: string; // Existing wallet ID
790
780
  userId?: string; // Links wallet to Privy user account
791
781
  }
792
782
 
@@ -1122,11 +1112,11 @@ The SDK enforces a **3-layer defense-in-depth** model:
1122
1112
 
1123
1113
  **Best practices:**
1124
1114
 
1125
- 1. **Always use Privy server wallets** raw private keys are deprecated
1126
- 2. **Never hardcode credentials**use environment variables
1127
- 3. **Set `allowed_contracts`** in Privy policy to whitelist only Q00bs contracts
1128
- 4. **Enable `require_human_approval`** for high-value actions
1129
- 5. **Use the Trust API** (not direct SDK calls) for untrusted environments
1115
+ 1. **Use `trustApiUrl`** wallets are managed by Q00bs' Privy infrastructure; no credentials needed
1116
+ 2. **Store your `walletId`**save it after first initialization to reuse the same wallet
1117
+ 3. **Never hardcode credentials** use environment variables for API URLs and wallet IDs
1118
+ 4. **Set spending limits** — configure `maxTransactionValue` and `dailySpendLimit` in AgentConfig
1119
+ 5. **Pay via x402** all API calls are authenticated via USDC micropayments on Base
1130
1120
 
1131
1121
  ---
1132
1122
 
@@ -1152,7 +1142,7 @@ curl -H "X-Payment: 0xabc...123" \
1152
1142
 
1153
1143
  | Tier | Price | Endpoints |
1154
1144
  |---------|--------------|----------------------------------------------|
1155
- | READ | $0.001 USDC | GET — trust scores, agent lookups, status |
1145
+ | READ | FREE | GET — trust scores, agent lookups, status (on-chain data is public) |
1156
1146
  | WRITE | $0.005 USDC | POST state changes — escrow ops, metadata |
1157
1147
  | CREATE | $0.01 USDC | POST new entities — agent/wallet/identity |
1158
1148
 
@@ -1165,27 +1155,23 @@ The Trust API also provides indexed, paginated endpoints that perform better tha
1165
1155
  ### Full Agent Lifecycle
1166
1156
 
1167
1157
  ```typescript
1168
- import { Q00bsAgent, AGENT_REGISTRY_ADDRESS, AGENT_ESCROW_ADDRESS } from '@q00bs/agent-sdk';
1158
+ import { Q00bsAgent } from '@q00bs/agent-sdk';
1169
1159
 
1170
1160
  async function main() {
1171
- // 1. Create and initialize agent
1161
+ // 1. Create and initialize agent — no Privy credentials needed
1172
1162
  const agent = new Q00bsAgent({
1173
- privy: {
1174
- appId: process.env.PRIVY_APP_ID!,
1175
- appSecret: process.env.PRIVY_APP_SECRET!,
1176
- },
1177
- rpcUrl: 'https://mainnet.base.org',
1178
- registryAddress: AGENT_REGISTRY_ADDRESS,
1179
- escrowAddress: AGENT_ESCROW_ADDRESS,
1163
+ trustApiUrl: 'https://q00bs-trust-api.onrender.com',
1164
+ walletId: process.env.Q00BS_WALLET_ID, // reuse wallet from previous session
1180
1165
  capabilities: ['data_analysis', 'summarization'],
1181
1166
  });
1182
1167
 
1183
1168
  await agent.initialize();
1184
- console.log(`Agent ready: ${agent.address} (mode: ${agent.walletMode})`);
1169
+ console.log(`Agent ready: ${agent.address}`);
1170
+ console.log(`Wallet ID (save this!): ${agent.walletId}`);
1185
1171
 
1186
1172
  // 2. Check if already registered
1187
1173
  if (!agent.agentId) {
1188
- console.log('Agent not registered. Use the Trust API to register.');
1174
+ console.log('Agent not registered. Call agent.register() to register on-chain.');
1189
1175
  return;
1190
1176
  }
1191
1177
 
@@ -1347,13 +1333,15 @@ console.log(`Vouched by ${networkTrust.vouchCount} agents`);
1347
1333
 
1348
1334
  ```bash
1349
1335
  # ─── Required ────────────────────────────────────────────
1350
- # Base mainnet RPC (use Alchemy/Infura for production)
1351
- BASE_RPC_URL=https://mainnet.base.org
1336
+ # Q00bs Trust API URL (all wallet ops go through here)
1337
+ Q00BS_TRUST_API_URL=https://q00bs-trust-api.onrender.com
1338
+
1339
+ # ─── Optional ────────────────────────────────────────────
1340
+ # Reuse an existing wallet from a previous session
1341
+ Q00BS_WALLET_ID=your-wallet-id-from-first-init
1352
1342
 
1353
- # ─── Privy Server Wallet (REQUIRED) ─────────────────────
1354
- PRIVY_APP_ID=your-privy-app-id
1355
- PRIVY_APP_SECRET=your-privy-app-secret
1356
- PRIVY_WALLET_ID=optional-existing-wallet-id
1343
+ # Base mainnet RPC for direct on-chain reads (defaults to public endpoint)
1344
+ BASE_RPC_URL=https://mainnet.base.org
1357
1345
 
1358
1346
  # ─── Contract Addresses (defaults built into SDK) ───────
1359
1347
  # Override only if using custom deployments:
@@ -1362,15 +1350,17 @@ PRIVY_WALLET_ID=optional-existing-wallet-id
1362
1350
  # CONSENSUS_ADDRESS=0xcB4A36a7c99e42B3F4b1c8EE6EDD0f3A7DDEcC76
1363
1351
  ```
1364
1352
 
1353
+ > **No Privy credentials needed.** Wallets are created and managed by Q00bs' own Privy infrastructure via the Trust API. All agents appear as users on Q00bs' Privy dashboard.
1354
+
1365
1355
  ---
1366
1356
 
1367
1357
  ## FAQ
1368
1358
 
1369
- **Q: Which wallet mode should I use?**
1370
- Privy server wallets are the only supported wallet mode. Raw private keys are deprecated. Privy holds your key material in a secure enclave private keys never appear in your code, environment variables, or agent memory.
1359
+ **Q: Do I need Privy credentials to use the SDK?**
1360
+ No. Wallets are created and managed by Q00bs' own Privy infrastructure via the Trust API. You just need the Trust API URL (`trustApiUrl`). All wallets created through the SDK appear as users on Q00bs' Privy dashboard. Private keys never appear in your code, env vars, or agent memory.
1371
1361
 
1372
1362
  **Q: How much does it cost to use the Trust API?**
1373
- API calls are paid via x402 micropayments in USDC on Base. Read operations cost $0.001, writes cost $0.005, and entity creation costs $0.01. No API keys or signup required.
1363
+ All GET (read) requests are **free** on-chain data is publicly readable. Write operations cost $0.005 and entity creation costs $0.01, paid via x402 micropayments in USDC on Base. No API keys or signup required.
1374
1364
 
1375
1365
  **Q: Can agents operate without their human owner?**
1376
1366
  Yes. Agents can create their own q00b, register themselves, and build trust through vouching — all without human intervention. The human can be invited later to claim the q00b.
@@ -5,18 +5,18 @@
5
5
  * modules (trust, escrow, consensus, discovery) behind a clean interface.
6
6
  *
7
7
  * WHAT THIS CLASS DOES:
8
- * - Initializes blockchain clients via Privy server wallets.
8
+ * - Creates a Privy wallet via the Q00bs Trust API (wallets managed by Q00bs).
9
9
  * - Registers the agent on-chain as an ERC-721 on the owner's q00b.
10
10
  * - Provides methods for trust verification, agent discovery, payments, and consensus.
11
11
  * - Enforces spend limits and trust-path checks BEFORE sending transactions.
12
12
  *
13
- * WALLET MODE — Privy Server Wallet (REQUIRED):
14
- * Pass `privy` in config (appId + appSecret). The SDK creates a Privy-managed
15
- * wallet with spending policies. Private keys never leave Privy's HSM.
16
- * See: https://privy.io/blog/securely-equipping-openclaw-agents-with-privy-wallets
13
+ * WALLET MODE — Q00bs Trust API:
14
+ * All wallets are created and managed through the Q00bs Trust API, which
15
+ * uses Q00bs' own Privy infrastructure. You NEVER need to supply Privy
16
+ * credentials — just point the SDK at the Trust API URL.
17
17
  *
18
18
  * SECURITY GUARANTEES:
19
- * - Private keys are held by Privy's HSM and NEVER appear in your code.
19
+ * - Private keys are held by Q00bs' Privy HSM and NEVER appear in your code.
20
20
  * - All state-changing operations go through on-chain contracts.
21
21
  * - Spend limits are enforced at 3 layers: Privy policy → SDK pre-check → on-chain.
22
22
  * - Trust paths are verified on-chain through the q00b graph before communication.
@@ -24,28 +24,24 @@
24
24
  * USAGE:
25
25
  * ```ts
26
26
  * const agent = new Q00bsAgent({
27
- * privy: {
28
- * appId: process.env.PRIVY_APP_ID!,
29
- * appSecret: process.env.PRIVY_APP_SECRET!,
30
- * walletId: process.env.PRIVY_WALLET_ID, // optional, creates new if omitted
31
- * },
32
- * rpcUrl: process.env.BASE_RPC_URL!,
33
- * registryAddress: '0x...',
27
+ * trustApiUrl: 'https://q00bs-trust-api.onrender.com',
28
+ * walletId: process.env.Q00BS_WALLET_ID, // optional — creates new if omitted
34
29
  * });
35
30
  * await agent.initialize();
31
+ * // → Wallet created under Q00bs' Privy app
32
+ * // → Store agent.walletId for next session
36
33
  * ```
37
34
  */
38
- import { PrivyWalletManager } from './privy';
39
35
  import { ERC8004Manager } from './erc8004';
40
- import type { AgentConfig, AgentRecord, TrustPath, AgentQuery, DiscoveredAgent, CreateEscrowParams, EscrowRecord, ConsensusParams, ConsensusResult, ConsensusRecord, PrivyWalletPolicy, PrivyWalletInfo, ERC8004Identity, ERC8004ReputationSummary, ERC8004Feedback, GiveFeedbackParams } from './types';
36
+ import type { AgentConfig, AgentRecord, TrustPath, AgentQuery, DiscoveredAgent, CreateEscrowParams, EscrowRecord, ConsensusParams, ConsensusResult, ConsensusRecord, ERC8004Identity, ERC8004ReputationSummary, ERC8004Feedback, GiveFeedbackParams } from './types';
41
37
  export declare class Q00bsAgent {
42
38
  private config;
43
39
  private logger;
44
40
  private publicClient;
45
41
  private walletClient?;
46
42
  private walletAddress;
43
+ private _walletId?;
47
44
  private privyManager?;
48
- private _walletMode;
49
45
  private trustResolver;
50
46
  private escrowManager?;
51
47
  private consensusManager?;
@@ -57,47 +53,65 @@ export declare class Q00bsAgent {
57
53
  get agentId(): number | undefined;
58
54
  /** Whether initialize() has been called. */
59
55
  get initialized(): boolean;
60
- /** The agent's wallet address (derived from private key or Privy). */
56
+ /** The agent's wallet address (created by Q00bs' Privy infrastructure). */
61
57
  get address(): string;
62
- /** Which wallet mode is active: 'privateKey' (Mode 1) or 'privy' (Mode 2). */
63
- get walletMode(): 'privateKey' | 'privy';
64
- /** Whether this agent uses a Privy-managed wallet (Mode 2). */
65
- get isPrivyMode(): boolean;
66
- /** The Privy wallet manager (only available in Mode 2). */
67
- get privyWallet(): PrivyWalletManager | undefined;
58
+ /** The wallet ID for this agent. Store this to reuse the wallet across sessions. */
59
+ get walletId(): string | undefined;
68
60
  /** The ERC-8004 manager (available if erc8004 config is set or after initialize). */
69
61
  get erc8004(): ERC8004Manager | undefined;
70
62
  /**
71
63
  * Create a new Q00bsAgent.
72
64
  *
73
- * @param config - Agent configuration. Must include `privy` configuration.
65
+ * @param config - Agent configuration. Must include `trustApiUrl`.
74
66
  *
75
67
  * NOTE: This does NOT connect to the blockchain yet. Call initialize() next.
76
68
  */
77
69
  constructor(config: AgentConfig);
70
+ private _x402TxHashQueue;
71
+ /**
72
+ * Add one or more x402 payment tx hashes to the queue.
73
+ * Each paid API call (write/create tier) consumes one hash.
74
+ * Free endpoints (reads, bootstrap routes) don't consume hashes.
75
+ *
76
+ * @param hashes - One or more Base mainnet USDC tx hashes.
77
+ */
78
+ addPaymentHashes(...hashes: string[]): void;
79
+ /** Number of unused payment hashes remaining. */
80
+ get paymentHashesRemaining(): number;
81
+ private static readonly FREE_PATHS;
82
+ /**
83
+ * Make an authenticated request to the Q00bs Trust API.
84
+ *
85
+ * Payment handling:
86
+ * - GET requests and FREE_PATHS never send a payment header.
87
+ * - Paid POST/PUT/DELETE requests consume one hash from the queue.
88
+ * - If no hash is available for a paid endpoint, the request still
89
+ * goes through — the server will return 402 with instructions.
90
+ *
91
+ * @internal
92
+ */
93
+ private apiCall;
78
94
  /**
79
95
  * Initialize blockchain connections and sub-modules.
80
96
  * Must be called before any other method.
81
97
  *
82
- * Creates/loads a Privy-managed wallet with spending policies and
83
- * initializes all sub-modules (trust, escrow, consensus, discovery, ERC-8004).
98
+ * If no walletId is set, creates a new wallet via the Q00bs Trust API.
99
+ * All wallets are managed by Q00bs' Privy infrastructure — you never
100
+ * need Privy credentials.
84
101
  *
85
- * @param walletPolicy - Policy to apply when creating a new Privy wallet.
86
- * @throws If configuration is invalid.
102
+ * @throws If configuration is invalid or API is unreachable.
87
103
  */
88
- initialize(walletPolicy?: PrivyWalletPolicy): Promise<void>;
104
+ initialize(): Promise<void>;
89
105
  /**
90
106
  * Register this agent on-chain on one side of the owner's q00b.
91
107
  *
108
+ * Routes through the Q00bs Trust API, which handles the on-chain transaction
109
+ * using Q00bs' Privy infrastructure. No Privy credentials needed.
110
+ *
92
111
  * @param ownerQ00bAddress - The q00b contract address owned by this agent's human.
93
112
  * @param sidePosition - Which side of the q00b (0-5) to occupy.
94
113
  * @returns The new agent's on-chain ID.
95
114
  *
96
- * IMPORTANT: The transaction sender must be the q00b OWNER (not the agent wallet).
97
- * In practice, the owner calls registerAgent() from their wallet, passing
98
- * the agent's wallet address. This method is for convenience when the owner's
99
- * private key is used.
100
- *
101
115
  * @example
102
116
  * ```ts
103
117
  * const agentId = await agent.register('0xMyQ00bAddress', 0);
@@ -182,43 +196,38 @@ export declare class Q00bsAgent {
182
196
  */
183
197
  getConsensusRequest(requestId: number): Promise<ConsensusRecord>;
184
198
  /**
185
- * Get this agent's Privy wallet info (Mode 2 only).
199
+ * Update the spending policy on this agent's wallet.
186
200
  *
187
- * @returns The Privy wallet info, or undefined if not in Privy mode.
188
- */
189
- getPrivyWalletInfo(): PrivyWalletInfo | undefined;
190
- /**
191
- * Update the spending policy on this agent's Privy wallet (Mode 2 only).
192
- *
193
- * Use this to dynamically adjust limits — for example, after the agent
194
- * gains more trust or is granted higher permissions by its owner.
195
- *
196
- * @param policy - The new wallet policy to apply.
197
- * @throws PrivyWalletError if not in Privy mode or update fails.
201
+ * Routes through the Q00bs Trust API. Use this to dynamically adjust
202
+ * limits — for example, after the agent gains more trust.
198
203
  *
199
- * @example
200
- * ```ts
201
- * await agent.updatePrivyPolicy({
202
- * name: 'Elevated Limits',
203
- * rules: [
204
- * { type: 'max_transaction_value', value: '0.5' },
205
- * { type: 'daily_spend_limit', value: '5.0' },
206
- * ],
207
- * });
208
- * ```
204
+ * @param policy - Policy parameters to update.
205
+ * @throws If wallet is not initialized or API call fails.
209
206
  */
210
- updatePrivyPolicy(policy: PrivyWalletPolicy): Promise<void>;
207
+ updateWalletPolicy(policy: {
208
+ maxTransactionValue?: string;
209
+ dailySpendLimit?: string;
210
+ }): Promise<void>;
211
211
  /**
212
212
  * Sign a message with this agent's wallet.
213
213
  *
214
- * Works in both modes:
215
- * - Mode 1: Uses viem walletClient.signMessage()
216
- * - Mode 2: Uses Privy's signMessage API
214
+ * Routes through the Q00bs Trust API for signing. The private key
215
+ * never leaves Q00bs' Privy infrastructure.
217
216
  *
218
217
  * @param message - The message to sign.
219
218
  * @returns The signature hex string.
220
219
  */
221
220
  signMessage(message: string): Promise<string>;
221
+ /**
222
+ * Send a transaction through the Q00bs Trust API.
223
+ * All transactions are policy-checked before broadcast.
224
+ *
225
+ * @param to - Destination address.
226
+ * @param value - ETH value in wei (optional).
227
+ * @param data - Encoded calldata (optional).
228
+ * @returns Transaction hash.
229
+ */
230
+ sendTransaction(to: string, value?: string, data?: string): Promise<string>;
222
231
  /**
223
232
  * Register this agent's ERC-8004 identity in the IdentityRegistry.
224
233
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Q00bsAgent.d.ts","sourceRoot":"","sources":["../src/Q00bsAgent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AASH,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQ3C,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,SAAS,EACT,UA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