@q00bs/agent-sdk 1.0.4 → 1.0.6
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 +1391 -0
- package/dist/Q00bsAgent.d.ts +51 -77
- package/dist/Q00bsAgent.d.ts.map +1 -1
- package/dist/Q00bsAgent.js +192 -157
- package/dist/Q00bsAgent.js.map +1 -1
- package/dist/client.d.ts +23 -30
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +19 -29
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +152 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/Q00bsAgent.d.ts
CHANGED
|
@@ -5,63 +5,43 @@
|
|
|
5
5
|
* modules (trust, escrow, consensus, discovery) behind a clean interface.
|
|
6
6
|
*
|
|
7
7
|
* WHAT THIS CLASS DOES:
|
|
8
|
-
* -
|
|
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
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* MODE 2 — Privy Server Wallet (recommended for ClawBot / OpenClaw agents):
|
|
19
|
-
* Pass `privy` in config (appId + appSecret). The SDK creates a Privy-managed
|
|
20
|
-
* wallet with spending policies. No private keys in your code.
|
|
21
|
-
* 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.
|
|
22
17
|
*
|
|
23
18
|
* SECURITY GUARANTEES:
|
|
24
|
-
* -
|
|
25
|
-
* - In Mode 2: 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.
|
|
26
20
|
* - All state-changing operations go through on-chain contracts.
|
|
27
21
|
* - Spend limits are enforced at 3 layers: Privy policy → SDK pre-check → on-chain.
|
|
28
22
|
* - Trust paths are verified on-chain through the q00b graph before communication.
|
|
29
23
|
*
|
|
30
|
-
* USAGE
|
|
24
|
+
* USAGE:
|
|
31
25
|
* ```ts
|
|
32
26
|
* const agent = new Q00bsAgent({
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* registryAddress: '0x...',
|
|
36
|
-
* });
|
|
37
|
-
* await agent.initialize();
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* USAGE (Mode 2 — Privy, recommended):
|
|
41
|
-
* ```ts
|
|
42
|
-
* const agent = new Q00bsAgent({
|
|
43
|
-
* privy: {
|
|
44
|
-
* appId: process.env.PRIVY_APP_ID!,
|
|
45
|
-
* appSecret: process.env.PRIVY_APP_SECRET!,
|
|
46
|
-
* walletId: process.env.PRIVY_WALLET_ID, // optional, creates new if omitted
|
|
47
|
-
* },
|
|
48
|
-
* rpcUrl: process.env.BASE_RPC_URL!,
|
|
49
|
-
* registryAddress: '0x...',
|
|
27
|
+
* trustApiUrl: 'https://q00bs-trust-api.onrender.com',
|
|
28
|
+
* walletId: process.env.Q00BS_WALLET_ID, // optional — creates new if omitted
|
|
50
29
|
* });
|
|
51
30
|
* await agent.initialize();
|
|
31
|
+
* // → Wallet created under Q00bs' Privy app
|
|
32
|
+
* // → Store agent.walletId for next session
|
|
52
33
|
* ```
|
|
53
34
|
*/
|
|
54
|
-
import { PrivyWalletManager } from './privy';
|
|
55
35
|
import { ERC8004Manager } from './erc8004';
|
|
56
|
-
import type { AgentConfig, AgentRecord, TrustPath, AgentQuery, DiscoveredAgent, CreateEscrowParams, EscrowRecord, ConsensusParams, ConsensusResult, ConsensusRecord,
|
|
36
|
+
import type { AgentConfig, AgentRecord, TrustPath, AgentQuery, DiscoveredAgent, CreateEscrowParams, EscrowRecord, ConsensusParams, ConsensusResult, ConsensusRecord, ERC8004Identity, ERC8004ReputationSummary, ERC8004Feedback, GiveFeedbackParams } from './types';
|
|
57
37
|
export declare class Q00bsAgent {
|
|
58
38
|
private config;
|
|
59
39
|
private logger;
|
|
60
40
|
private publicClient;
|
|
61
41
|
private walletClient?;
|
|
62
42
|
private walletAddress;
|
|
43
|
+
private _walletId?;
|
|
63
44
|
private privyManager?;
|
|
64
|
-
private _walletMode;
|
|
65
45
|
private trustResolver;
|
|
66
46
|
private escrowManager?;
|
|
67
47
|
private consensusManager?;
|
|
@@ -73,47 +53,46 @@ export declare class Q00bsAgent {
|
|
|
73
53
|
get agentId(): number | undefined;
|
|
74
54
|
/** Whether initialize() has been called. */
|
|
75
55
|
get initialized(): boolean;
|
|
76
|
-
/** The agent's wallet address (
|
|
56
|
+
/** The agent's wallet address (created by Q00bs' Privy infrastructure). */
|
|
77
57
|
get address(): string;
|
|
78
|
-
/**
|
|
79
|
-
get
|
|
80
|
-
/** Whether this agent uses a Privy-managed wallet (Mode 2). */
|
|
81
|
-
get isPrivyMode(): boolean;
|
|
82
|
-
/** The Privy wallet manager (only available in Mode 2). */
|
|
83
|
-
get privyWallet(): PrivyWalletManager | undefined;
|
|
58
|
+
/** The wallet ID for this agent. Store this to reuse the wallet across sessions. */
|
|
59
|
+
get walletId(): string | undefined;
|
|
84
60
|
/** The ERC-8004 manager (available if erc8004 config is set or after initialize). */
|
|
85
61
|
get erc8004(): ERC8004Manager | undefined;
|
|
86
62
|
/**
|
|
87
63
|
* Create a new Q00bsAgent.
|
|
88
64
|
*
|
|
89
|
-
* @param config - Agent configuration. Must include
|
|
65
|
+
* @param config - Agent configuration. Must include `trustApiUrl`.
|
|
90
66
|
*
|
|
91
67
|
* NOTE: This does NOT connect to the blockchain yet. Call initialize() next.
|
|
92
68
|
*/
|
|
93
69
|
constructor(config: AgentConfig);
|
|
70
|
+
/**
|
|
71
|
+
* Make an authenticated request to the Q00bs Trust API.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
private apiCall;
|
|
94
75
|
/**
|
|
95
76
|
* Initialize blockchain connections and sub-modules.
|
|
96
77
|
* Must be called before any other method.
|
|
97
78
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
79
|
+
* If no walletId is set, creates a new wallet via the Q00bs Trust API.
|
|
80
|
+
* All wallets are managed by Q00bs' Privy infrastructure — you never
|
|
81
|
+
* need Privy credentials.
|
|
100
82
|
*
|
|
101
|
-
* @
|
|
102
|
-
* @throws If configuration is invalid.
|
|
83
|
+
* @throws If configuration is invalid or API is unreachable.
|
|
103
84
|
*/
|
|
104
|
-
initialize(
|
|
85
|
+
initialize(): Promise<void>;
|
|
105
86
|
/**
|
|
106
87
|
* Register this agent on-chain on one side of the owner's q00b.
|
|
107
88
|
*
|
|
89
|
+
* Routes through the Q00bs Trust API, which handles the on-chain transaction
|
|
90
|
+
* using Q00bs' Privy infrastructure. No Privy credentials needed.
|
|
91
|
+
*
|
|
108
92
|
* @param ownerQ00bAddress - The q00b contract address owned by this agent's human.
|
|
109
93
|
* @param sidePosition - Which side of the q00b (0-5) to occupy.
|
|
110
94
|
* @returns The new agent's on-chain ID.
|
|
111
95
|
*
|
|
112
|
-
* IMPORTANT: The transaction sender must be the q00b OWNER (not the agent wallet).
|
|
113
|
-
* In practice, the owner calls registerAgent() from their wallet, passing
|
|
114
|
-
* the agent's wallet address. This method is for convenience when the owner's
|
|
115
|
-
* private key is used.
|
|
116
|
-
*
|
|
117
96
|
* @example
|
|
118
97
|
* ```ts
|
|
119
98
|
* const agentId = await agent.register('0xMyQ00bAddress', 0);
|
|
@@ -198,43 +177,38 @@ export declare class Q00bsAgent {
|
|
|
198
177
|
*/
|
|
199
178
|
getConsensusRequest(requestId: number): Promise<ConsensusRecord>;
|
|
200
179
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @returns The Privy wallet info, or undefined if not in Privy mode.
|
|
204
|
-
*/
|
|
205
|
-
getPrivyWalletInfo(): PrivyWalletInfo | undefined;
|
|
206
|
-
/**
|
|
207
|
-
* Update the spending policy on this agent's Privy wallet (Mode 2 only).
|
|
208
|
-
*
|
|
209
|
-
* Use this to dynamically adjust limits — for example, after the agent
|
|
210
|
-
* gains more trust or is granted higher permissions by its owner.
|
|
180
|
+
* Update the spending policy on this agent's wallet.
|
|
211
181
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
182
|
+
* Routes through the Q00bs Trust API. Use this to dynamically adjust
|
|
183
|
+
* limits — for example, after the agent gains more trust.
|
|
214
184
|
*
|
|
215
|
-
* @
|
|
216
|
-
*
|
|
217
|
-
* await agent.updatePrivyPolicy({
|
|
218
|
-
* name: 'Elevated Limits',
|
|
219
|
-
* rules: [
|
|
220
|
-
* { type: 'max_transaction_value', value: '0.5' },
|
|
221
|
-
* { type: 'daily_spend_limit', value: '5.0' },
|
|
222
|
-
* ],
|
|
223
|
-
* });
|
|
224
|
-
* ```
|
|
185
|
+
* @param policy - Policy parameters to update.
|
|
186
|
+
* @throws If wallet is not initialized or API call fails.
|
|
225
187
|
*/
|
|
226
|
-
|
|
188
|
+
updateWalletPolicy(policy: {
|
|
189
|
+
maxTransactionValue?: string;
|
|
190
|
+
dailySpendLimit?: string;
|
|
191
|
+
}): Promise<void>;
|
|
227
192
|
/**
|
|
228
193
|
* Sign a message with this agent's wallet.
|
|
229
194
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* - Mode 2: Uses Privy's signMessage API
|
|
195
|
+
* Routes through the Q00bs Trust API for signing. The private key
|
|
196
|
+
* never leaves Q00bs' Privy infrastructure.
|
|
233
197
|
*
|
|
234
198
|
* @param message - The message to sign.
|
|
235
199
|
* @returns The signature hex string.
|
|
236
200
|
*/
|
|
237
201
|
signMessage(message: string): Promise<string>;
|
|
202
|
+
/**
|
|
203
|
+
* Send a transaction through the Q00bs Trust API.
|
|
204
|
+
* All transactions are policy-checked before broadcast.
|
|
205
|
+
*
|
|
206
|
+
* @param to - Destination address.
|
|
207
|
+
* @param value - ETH value in wei (optional).
|
|
208
|
+
* @param data - Encoded calldata (optional).
|
|
209
|
+
* @returns Transaction hash.
|
|
210
|
+
*/
|
|
211
|
+
sendTransaction(to: string, value?: string, data?: string): Promise<string>;
|
|
238
212
|
/**
|
|
239
213
|
* Register this agent's ERC-8004 identity in the IdentityRegistry.
|
|
240
214
|
*
|
package/dist/Q00bsAgent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Q00bsAgent.d.ts","sourceRoot":"","sources":["../src/Q00bsAgent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Q00bsAgent.d.ts","sourceRoot":"","sources":["../src/Q00bsAgent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAWH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAc3C,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,SAAS,EACT,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EAKf,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAMjB,qBAAa,UAAU;IAErB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,MAAM,CAAS;IAGvB,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,YAAY,CAAC,CAA0C;IAC/D,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAS;IAG3B,OA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