@q00bs/agent-sdk 1.0.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/dist/Q00bsAgent.d.ts +331 -0
- package/dist/Q00bsAgent.d.ts.map +1 -0
- package/dist/Q00bsAgent.js +695 -0
- package/dist/Q00bsAgent.js.map +1 -0
- package/dist/abis/AgentEscrow.d.ts +336 -0
- package/dist/abis/AgentEscrow.d.ts.map +1 -0
- package/dist/abis/AgentEscrow.js +206 -0
- package/dist/abis/AgentEscrow.js.map +1 -0
- package/dist/abis/AgentRegistry.d.ts +496 -0
- package/dist/abis/AgentRegistry.d.ts.map +1 -0
- package/dist/abis/AgentRegistry.js +280 -0
- package/dist/abis/AgentRegistry.js.map +1 -0
- package/dist/abis/ConsensusModule.d.ts +270 -0
- package/dist/abis/ConsensusModule.d.ts.map +1 -0
- package/dist/abis/ConsensusModule.js +157 -0
- package/dist/abis/ConsensusModule.js.map +1 -0
- package/dist/abis/ERC8004Identity.d.ts +293 -0
- package/dist/abis/ERC8004Identity.d.ts.map +1 -0
- package/dist/abis/ERC8004Identity.js +223 -0
- package/dist/abis/ERC8004Identity.js.map +1 -0
- package/dist/abis/ERC8004Reputation.d.ts +362 -0
- package/dist/abis/ERC8004Reputation.d.ts.map +1 -0
- package/dist/abis/ERC8004Reputation.js +229 -0
- package/dist/abis/ERC8004Reputation.js.map +1 -0
- package/dist/abis/ERC8004Validation.d.ts +234 -0
- package/dist/abis/ERC8004Validation.d.ts.map +1 -0
- package/dist/abis/ERC8004Validation.js +162 -0
- package/dist/abis/ERC8004Validation.js.map +1 -0
- package/dist/abis/Q00bFactory.d.ts +123 -0
- package/dist/abis/Q00bFactory.d.ts.map +1 -0
- package/dist/abis/Q00bFactory.js +65 -0
- package/dist/abis/Q00bFactory.js.map +1 -0
- package/dist/abis/TheQ00bs.d.ts +119 -0
- package/dist/abis/TheQ00bs.d.ts.map +1 -0
- package/dist/abis/TheQ00bs.js +73 -0
- package/dist/abis/TheQ00bs.js.map +1 -0
- package/dist/abis/index.d.ts +9 -0
- package/dist/abis/index.d.ts.map +1 -0
- package/dist/abis/index.js +17 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/client.d.ts +111 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +134 -0
- package/dist/client.js.map +1 -0
- package/dist/consensus.d.ts +85 -0
- package/dist/consensus.d.ts.map +1 -0
- package/dist/consensus.js +227 -0
- package/dist/consensus.js.map +1 -0
- package/dist/constants.d.ts +85 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +113 -0
- package/dist/constants.js.map +1 -0
- package/dist/discovery.d.ts +70 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +214 -0
- package/dist/discovery.js.map +1 -0
- package/dist/erc8004.d.ts +311 -0
- package/dist/erc8004.d.ts.map +1 -0
- package/dist/erc8004.js +824 -0
- package/dist/erc8004.js.map +1 -0
- package/dist/errors.d.ts +107 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +210 -0
- package/dist/errors.js.map +1 -0
- package/dist/escrow.d.ts +86 -0
- package/dist/escrow.d.ts.map +1 -0
- package/dist/escrow.js +267 -0
- package/dist/escrow.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/privy.d.ts +197 -0
- package/dist/privy.d.ts.map +1 -0
- package/dist/privy.js +524 -0
- package/dist/privy.js.map +1 -0
- package/dist/trust.d.ts +49 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +117 -0
- package/dist/trust.js.map +1 -0
- package/dist/types.d.ts +472 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +36 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @q00bs/agent-sdk — Consensus Module
|
|
4
|
+
*
|
|
5
|
+
* Handles multi-agent voting for high-stakes actions.
|
|
6
|
+
*
|
|
7
|
+
* WHEN IS CONSENSUS NEEDED?
|
|
8
|
+
* Actions above certain ETH thresholds require approval from peer agents
|
|
9
|
+
* in the initiator's trust network. This prevents rogue agents from
|
|
10
|
+
* unilaterally making expensive decisions.
|
|
11
|
+
*
|
|
12
|
+
* Value ≤ 0.01 ETH → No consensus (auto-approved)
|
|
13
|
+
* Value ≤ 0.10 ETH → 2 of 6 peer agents must approve
|
|
14
|
+
* Value ≤ 1.00 ETH → 4 of 6 peer agents must approve
|
|
15
|
+
* Value > 1.00 ETH → 4 of 6 peer agents + the human owner must approve
|
|
16
|
+
*
|
|
17
|
+
* FLOW:
|
|
18
|
+
* 1. Initiator calls requestConsensus() → gets a requestId.
|
|
19
|
+
* 2. Peer agents in the trust network call vote() with approve/reject.
|
|
20
|
+
* 3. If human approval is required, the owner calls humanApprove().
|
|
21
|
+
* 4. Once thresholds are met, the contract sets state to APPROVED.
|
|
22
|
+
* 5. Initiator calls markExecuted() after completing the action.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ConsensusManager = void 0;
|
|
26
|
+
const viem_1 = require("viem");
|
|
27
|
+
const ConsensusModule_1 = require("./abis/ConsensusModule");
|
|
28
|
+
const errors_1 = require("./errors");
|
|
29
|
+
// Default timeout: 1 hour
|
|
30
|
+
const DEFAULT_TIMEOUT_MS = 60 * 60 * 1000;
|
|
31
|
+
// ─────────────────────────────────────────────────────────────
|
|
32
|
+
// CONSENSUS MANAGER
|
|
33
|
+
// ─────────────────────────────────────────────────────────────
|
|
34
|
+
class ConsensusManager {
|
|
35
|
+
publicClient;
|
|
36
|
+
walletClient;
|
|
37
|
+
consensusAddress;
|
|
38
|
+
logger;
|
|
39
|
+
constructor(publicClient, walletClient, consensusAddress, logger) {
|
|
40
|
+
this.publicClient = publicClient;
|
|
41
|
+
this.walletClient = walletClient;
|
|
42
|
+
this.consensusAddress = consensusAddress;
|
|
43
|
+
this.logger = logger;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Request consensus for an action.
|
|
47
|
+
*
|
|
48
|
+
* @param agentId - Your agent's on-chain ID.
|
|
49
|
+
* @param params - Action description, value, and optional timeout.
|
|
50
|
+
* @returns The new consensus request ID.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const requestId = await consensus.request(1, {
|
|
55
|
+
* actionDescription: 'Transfer 0.5 ETH to agent 7 for data processing',
|
|
56
|
+
* valueEth: '0.5',
|
|
57
|
+
* timeoutMs: 3600000, // 1 hour
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
async request(agentId, params) {
|
|
62
|
+
const actionHash = (0, viem_1.keccak256)((0, viem_1.toHex)(params.actionDescription));
|
|
63
|
+
const value = (0, viem_1.parseEther)(params.valueEth);
|
|
64
|
+
const timeoutSec = Math.floor((params.timeoutMs || DEFAULT_TIMEOUT_MS) / 1000);
|
|
65
|
+
this.logger.info(`Requesting consensus: agent ${agentId}, value ${params.valueEth} ETH, ` +
|
|
66
|
+
`timeout ${timeoutSec}s`);
|
|
67
|
+
try {
|
|
68
|
+
const hash = await this.walletClient.writeContract({
|
|
69
|
+
address: this.consensusAddress,
|
|
70
|
+
abi: ConsensusModule_1.CONSENSUS_MODULE_ABI,
|
|
71
|
+
functionName: 'requestConsensus',
|
|
72
|
+
args: [BigInt(agentId), actionHash, value, BigInt(timeoutSec)],
|
|
73
|
+
});
|
|
74
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
|
|
75
|
+
this.logger.info(`Consensus request tx confirmed in block ${receipt.blockNumber}`);
|
|
76
|
+
// Parse request ID from event
|
|
77
|
+
const requestId = this.parseRequestIdFromReceipt(receipt);
|
|
78
|
+
return requestId;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
82
|
+
throw new errors_1.ContractCallError(this.consensusAddress, 'requestConsensus', msg);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Vote on a consensus request.
|
|
87
|
+
*
|
|
88
|
+
* @param requestId - The consensus request to vote on.
|
|
89
|
+
* @param voterAgentId - Your agent's on-chain ID.
|
|
90
|
+
* @param approve - true to approve, false to reject.
|
|
91
|
+
*/
|
|
92
|
+
async vote(requestId, voterAgentId, approve) {
|
|
93
|
+
this.logger.info(`Voting on request ${requestId}: agent ${voterAgentId} → ${approve ? 'APPROVE' : 'REJECT'}`);
|
|
94
|
+
try {
|
|
95
|
+
const hash = await this.walletClient.writeContract({
|
|
96
|
+
address: this.consensusAddress,
|
|
97
|
+
abi: ConsensusModule_1.CONSENSUS_MODULE_ABI,
|
|
98
|
+
functionName: 'vote',
|
|
99
|
+
args: [BigInt(requestId), BigInt(voterAgentId), approve],
|
|
100
|
+
});
|
|
101
|
+
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
102
|
+
this.logger.info(`Vote on request ${requestId} confirmed`);
|
|
103
|
+
return hash;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
107
|
+
throw new errors_1.ContractCallError(this.consensusAddress, 'vote', msg);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Mark a consensus request as executed (after the approved action is done).
|
|
112
|
+
*
|
|
113
|
+
* @param requestId - The request to finalize.
|
|
114
|
+
*/
|
|
115
|
+
async markExecuted(requestId) {
|
|
116
|
+
this.logger.info(`Marking request ${requestId} as executed`);
|
|
117
|
+
try {
|
|
118
|
+
const hash = await this.walletClient.writeContract({
|
|
119
|
+
address: this.consensusAddress,
|
|
120
|
+
abi: ConsensusModule_1.CONSENSUS_MODULE_ABI,
|
|
121
|
+
functionName: 'markExecuted',
|
|
122
|
+
args: [BigInt(requestId)],
|
|
123
|
+
});
|
|
124
|
+
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
125
|
+
this.logger.info(`Request ${requestId} marked executed`);
|
|
126
|
+
return hash;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
130
|
+
throw new errors_1.ContractCallError(this.consensusAddress, 'markExecuted', msg);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Read a consensus request from the chain.
|
|
135
|
+
*
|
|
136
|
+
* @param requestId - The request to query.
|
|
137
|
+
*/
|
|
138
|
+
async get(requestId) {
|
|
139
|
+
const raw = await this.publicClient.readContract({
|
|
140
|
+
address: this.consensusAddress,
|
|
141
|
+
abi: ConsensusModule_1.CONSENSUS_MODULE_ABI,
|
|
142
|
+
functionName: 'getRequest',
|
|
143
|
+
args: [BigInt(requestId)],
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
id: requestId,
|
|
147
|
+
initiatorAgentId: Number(raw.initiatorAgentId),
|
|
148
|
+
actionHash: raw.actionHash,
|
|
149
|
+
value: raw.value,
|
|
150
|
+
requiredApprovals: Number(raw.requiredApprovals),
|
|
151
|
+
currentApprovals: Number(raw.currentApprovals),
|
|
152
|
+
currentRejections: Number(raw.currentRejections),
|
|
153
|
+
state: Number(raw.state),
|
|
154
|
+
createdAt: Number(raw.createdAt),
|
|
155
|
+
expiresAt: Number(raw.expiresAt),
|
|
156
|
+
humanApprovalRequired: raw.humanApprovalRequired,
|
|
157
|
+
humanApproved: raw.humanApproved,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Check if a consensus request has been approved.
|
|
162
|
+
*
|
|
163
|
+
* @param requestId - The request to check.
|
|
164
|
+
*/
|
|
165
|
+
async isApproved(requestId) {
|
|
166
|
+
return await this.publicClient.readContract({
|
|
167
|
+
address: this.consensusAddress,
|
|
168
|
+
abi: ConsensusModule_1.CONSENSUS_MODULE_ABI,
|
|
169
|
+
functionName: 'isApproved',
|
|
170
|
+
args: [BigInt(requestId)],
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Poll for consensus result (blocking, with timeout).
|
|
175
|
+
* Useful when you need to wait for peer agents to vote.
|
|
176
|
+
*
|
|
177
|
+
* @param requestId - The request to wait on.
|
|
178
|
+
* @param pollIntervalMs - How often to check (default: 10s).
|
|
179
|
+
* @param timeoutMs - Maximum wait time (default: matches request timeout).
|
|
180
|
+
*/
|
|
181
|
+
async waitForResult(requestId, pollIntervalMs = 10_000, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
182
|
+
const deadline = Date.now() + timeoutMs;
|
|
183
|
+
while (Date.now() < deadline) {
|
|
184
|
+
const record = await this.get(requestId);
|
|
185
|
+
if (record.state === 1) {
|
|
186
|
+
// APPROVED
|
|
187
|
+
return {
|
|
188
|
+
requestId,
|
|
189
|
+
approved: true,
|
|
190
|
+
approvals: record.currentApprovals,
|
|
191
|
+
rejections: record.currentRejections,
|
|
192
|
+
humanApproved: record.humanApproved,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (record.state === 2) {
|
|
196
|
+
// REJECTED
|
|
197
|
+
throw new errors_1.ConsensusRejectedError(requestId, record.currentApprovals, record.currentRejections);
|
|
198
|
+
}
|
|
199
|
+
if (record.state === 3) {
|
|
200
|
+
// EXPIRED
|
|
201
|
+
throw new errors_1.ConsensusTimeoutError(requestId);
|
|
202
|
+
}
|
|
203
|
+
// Still PENDING — wait and poll again
|
|
204
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
205
|
+
}
|
|
206
|
+
throw new errors_1.ConsensusTimeoutError(requestId);
|
|
207
|
+
}
|
|
208
|
+
// ── Private helpers ─────────────────────────────────────────
|
|
209
|
+
parseRequestIdFromReceipt(receipt) {
|
|
210
|
+
for (const log of receipt.logs) {
|
|
211
|
+
try {
|
|
212
|
+
if (log.address?.toLowerCase() === this.consensusAddress.toLowerCase()) {
|
|
213
|
+
if (log.topics && log.topics.length > 1) {
|
|
214
|
+
return Number(BigInt(log.topics[1]));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
this.logger.warn('Could not parse requestId from receipt');
|
|
223
|
+
return -1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.ConsensusManager = ConsensusManager;
|
|
227
|
+
//# sourceMappingURL=consensus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consensus.js","sourceRoot":"","sources":["../src/consensus.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAGH,+BAAoD;AACpD,4DAA8D;AAC9D,qCAIkB;AASlB,0BAA0B;AAC1B,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,gEAAgE;AAChE,oBAAoB;AACpB,gEAAgE;AAEhE,MAAa,gBAAgB;IACnB,YAAY,CAAiC;IAC7C,YAAY,CAA0C;IACtD,gBAAgB,CAAgB;IAChC,MAAM,CAAS;IAEvB,YACE,YAA4C,EAC5C,YAAqD,EACrD,gBAAwB,EACxB,MAAc;QAEd,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAiC,CAAC;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,OAAO,CAAC,OAAe,EAAE,MAAuB;QACpD,MAAM,UAAU,GAAG,IAAA,gBAAS,EAAC,IAAA,YAAK,EAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAG,IAAA,iBAAU,EAAC,MAAM,CA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AAK,CAAC,EAAE,CAAC;gBACvB,UAAU;gBACV,MAAM,IAAI,8BAAqB,CAAC,SAAS,CAAC,CAAC;YAC7C,CAAC;YAED,sCAAsC;YACtC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,IAAI,8BAAqB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,+DAA+D;IAEvD,yBAAyB,CAAC,OAAY;QAC5C,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,IAAI,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC;oBACvE,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACxC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;CACF;AApOD,4CAoOC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @q00bs/agent-sdk — Constants
|
|
3
|
+
*
|
|
4
|
+
* All chain IDs, contract addresses, and default values.
|
|
5
|
+
* Contract addresses for AgentRegistry, AgentEscrow, and ConsensusModule
|
|
6
|
+
* are placeholders until you deploy them — see the deployment guide in README.md.
|
|
7
|
+
*/
|
|
8
|
+
/** Base mainnet chain ID. */
|
|
9
|
+
export declare const BASE_CHAIN_ID = 8453;
|
|
10
|
+
/** Default Base mainnet RPC URL (public, rate-limited — use your own for production). */
|
|
11
|
+
export declare const DEFAULT_RPC_URL = "https://mainnet.base.org";
|
|
12
|
+
/**
|
|
13
|
+
* q00bFactory — LIVE on Base since Jan 15 2026.
|
|
14
|
+
* This is YOUR existing deployed contract. Do NOT change.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Q00B_FACTORY_ADDRESS = "0xe611b837E2D06f92D4a258e77fab8a26b33452b0";
|
|
17
|
+
/**
|
|
18
|
+
* Genesis Q00b — the first q00b ever deployed.
|
|
19
|
+
*/
|
|
20
|
+
export declare const GENESIS_Q00B_ADDRESS = "0x14597A318D4C03ABbB8E054d31591541E446cB54";
|
|
21
|
+
/**
|
|
22
|
+
* AgentRegistry — LIVE on Base mainnet.
|
|
23
|
+
* Deployed Feb 6 2026.
|
|
24
|
+
*/
|
|
25
|
+
export declare const AGENT_REGISTRY_ADDRESS = "0xF7c8acecdfbBEAf08F596ab1F85f68f7E6568172";
|
|
26
|
+
/**
|
|
27
|
+
* AgentEscrow — LIVE on Base mainnet.
|
|
28
|
+
* Deployed Feb 6 2026.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AGENT_ESCROW_ADDRESS = "0xe1139A7BebD89e534d4C459b252BA0963e0A0499";
|
|
31
|
+
/**
|
|
32
|
+
* ConsensusModule — LIVE on Base mainnet.
|
|
33
|
+
* Deployed Feb 6 2026.
|
|
34
|
+
*/
|
|
35
|
+
export declare const CONSENSUS_MODULE_ADDRESS = "0xcB4A36a7c99e42B3F4b1c8EE6EDD0f3A7DDEcC76";
|
|
36
|
+
/** Maximum trust score (100.00% stored as integer). */
|
|
37
|
+
export declare const MAX_TRUST_SCORE = 10000;
|
|
38
|
+
/** New agents start at 50% of their owner's trust score. */
|
|
39
|
+
export declare const INITIAL_TRUST_DIVISOR = 2;
|
|
40
|
+
/** Trust decays by 15% per hop in the q00b graph. */
|
|
41
|
+
export declare const TRUST_DECAY_PER_HOP_PERCENT = 15;
|
|
42
|
+
/** Minimum effective trust floor (10%). */
|
|
43
|
+
export declare const MIN_TRUST_FLOOR_PERCENT = 10;
|
|
44
|
+
/** Default max hops for communication. */
|
|
45
|
+
export declare const DEFAULT_MAX_HOPS = 3;
|
|
46
|
+
/** Default max single transaction value: 0.1 ETH. */
|
|
47
|
+
export declare const DEFAULT_MAX_TX_VALUE_ETH = "0.1";
|
|
48
|
+
/** Default daily spend limit: 1 ETH. */
|
|
49
|
+
export declare const DEFAULT_DAILY_LIMIT_ETH = "1";
|
|
50
|
+
/** Maximum number of sides on a q00b. */
|
|
51
|
+
export declare const MAX_Q00B_SIDES = 6;
|
|
52
|
+
/** Protocol fee in basis points (100 = 1%). */
|
|
53
|
+
export declare const PROTOCOL_FEE_BPS = 100;
|
|
54
|
+
/** Default escrow deadline: 24 hours. */
|
|
55
|
+
export declare const DEFAULT_ESCROW_DEADLINE_MS: number;
|
|
56
|
+
/** Below this ETH value, no consensus needed. */
|
|
57
|
+
export declare const LOW_RISK_THRESHOLD_ETH = "0.01";
|
|
58
|
+
/** Below this ETH value, 2/6 consensus needed. */
|
|
59
|
+
export declare const MEDIUM_RISK_THRESHOLD_ETH = "0.1";
|
|
60
|
+
/** Below this ETH value, 4/6 consensus needed. */
|
|
61
|
+
export declare const HIGH_RISK_THRESHOLD_ETH = "1";
|
|
62
|
+
/** Above HIGH_RISK, 4/6 consensus + human approval needed. */
|
|
63
|
+
/**
|
|
64
|
+
* ERC-8004 IdentityRegistry on Base mainnet.
|
|
65
|
+
* ERC-721-based agent identity registry.
|
|
66
|
+
*/
|
|
67
|
+
export declare const ERC8004_IDENTITY_REGISTRY_ADDRESS = "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
|
|
68
|
+
/**
|
|
69
|
+
* ERC-8004 ReputationRegistry on Base mainnet.
|
|
70
|
+
* Stores signed fixed-point feedback signals.
|
|
71
|
+
*/
|
|
72
|
+
export declare const ERC8004_REPUTATION_REGISTRY_ADDRESS = "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63";
|
|
73
|
+
/**
|
|
74
|
+
* ERC-8004 ValidationRegistry on Base mainnet.
|
|
75
|
+
* Hooks for validator contracts to publish results.
|
|
76
|
+
* NOTE: Address TBD — the ValidationRegistry spec is still evolving.
|
|
77
|
+
* Update this when the canonical deployment is confirmed.
|
|
78
|
+
*/
|
|
79
|
+
export declare const ERC8004_VALIDATION_REGISTRY_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
80
|
+
/**
|
|
81
|
+
* Q00bs namespace for ERC-8004 agent identifiers.
|
|
82
|
+
* Used in the identifier format: {namespace}:{chainId}:{registry}:{agentId}
|
|
83
|
+
*/
|
|
84
|
+
export declare const ERC8004_NAMESPACE = "q00bs";
|
|
85
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,6BAA6B;AAC7B,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,yFAAyF;AACzF,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAM1D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+CAA+C,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,oBAAoB,+CAA+C,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,+CAA+C,CAAC;AAEnF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+CAA+C,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,+CAA+C,CAAC;AAMrF,uDAAuD;AACvD,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,4DAA4D;AAC5D,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,qDAAqD;AACrD,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,2CAA2C;AAC3C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAM1C,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,qDAAqD;AACrD,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C,wCAAwC;AACxC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,yCAAyC;AACzC,eAAO,MAAM,cAAc,IAAI,CAAC;AAMhC,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,yCAAyC;AACzC,eAAO,MAAM,0BAA0B,QAAsB,CAAC;AAM9D,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAE7C,kDAAkD;AAClD,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAE/C,kDAAkD;AAClD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,8DAA8D;AAU9D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,+CAA+C,CAAC;AAE9F;;;GAGG;AACH,eAAO,MAAM,mCAAmC,+CAA+C,CAAC;AAEhG;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,+CAA+C,CAAC;AAEhG;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAAU,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @q00bs/agent-sdk — Constants
|
|
4
|
+
*
|
|
5
|
+
* All chain IDs, contract addresses, and default values.
|
|
6
|
+
* Contract addresses for AgentRegistry, AgentEscrow, and ConsensusModule
|
|
7
|
+
* are placeholders until you deploy them — see the deployment guide in README.md.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ERC8004_NAMESPACE = exports.ERC8004_VALIDATION_REGISTRY_ADDRESS = exports.ERC8004_REPUTATION_REGISTRY_ADDRESS = exports.ERC8004_IDENTITY_REGISTRY_ADDRESS = exports.HIGH_RISK_THRESHOLD_ETH = exports.MEDIUM_RISK_THRESHOLD_ETH = exports.LOW_RISK_THRESHOLD_ETH = exports.DEFAULT_ESCROW_DEADLINE_MS = exports.PROTOCOL_FEE_BPS = exports.MAX_Q00B_SIDES = exports.DEFAULT_DAILY_LIMIT_ETH = exports.DEFAULT_MAX_TX_VALUE_ETH = exports.DEFAULT_MAX_HOPS = exports.MIN_TRUST_FLOOR_PERCENT = exports.TRUST_DECAY_PER_HOP_PERCENT = exports.INITIAL_TRUST_DIVISOR = exports.MAX_TRUST_SCORE = exports.CONSENSUS_MODULE_ADDRESS = exports.AGENT_ESCROW_ADDRESS = exports.AGENT_REGISTRY_ADDRESS = exports.GENESIS_Q00B_ADDRESS = exports.Q00B_FACTORY_ADDRESS = exports.DEFAULT_RPC_URL = exports.BASE_CHAIN_ID = void 0;
|
|
11
|
+
// ─────────────────────────────────────────────────────────────
|
|
12
|
+
// CHAIN CONFIGURATION
|
|
13
|
+
// ─────────────────────────────────────────────────────────────
|
|
14
|
+
/** Base mainnet chain ID. */
|
|
15
|
+
exports.BASE_CHAIN_ID = 8453;
|
|
16
|
+
/** Default Base mainnet RPC URL (public, rate-limited — use your own for production). */
|
|
17
|
+
exports.DEFAULT_RPC_URL = 'https://mainnet.base.org';
|
|
18
|
+
// ─────────────────────────────────────────────────────────────
|
|
19
|
+
// DEPLOYED CONTRACT ADDRESSES (BASE MAINNET)
|
|
20
|
+
// ─────────────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* q00bFactory — LIVE on Base since Jan 15 2026.
|
|
23
|
+
* This is YOUR existing deployed contract. Do NOT change.
|
|
24
|
+
*/
|
|
25
|
+
exports.Q00B_FACTORY_ADDRESS = '0xe611b837E2D06f92D4a258e77fab8a26b33452b0';
|
|
26
|
+
/**
|
|
27
|
+
* Genesis Q00b — the first q00b ever deployed.
|
|
28
|
+
*/
|
|
29
|
+
exports.GENESIS_Q00B_ADDRESS = '0x14597A318D4C03ABbB8E054d31591541E446cB54';
|
|
30
|
+
/**
|
|
31
|
+
* AgentRegistry — LIVE on Base mainnet.
|
|
32
|
+
* Deployed Feb 6 2026.
|
|
33
|
+
*/
|
|
34
|
+
exports.AGENT_REGISTRY_ADDRESS = '0xF7c8acecdfbBEAf08F596ab1F85f68f7E6568172';
|
|
35
|
+
/**
|
|
36
|
+
* AgentEscrow — LIVE on Base mainnet.
|
|
37
|
+
* Deployed Feb 6 2026.
|
|
38
|
+
*/
|
|
39
|
+
exports.AGENT_ESCROW_ADDRESS = '0xe1139A7BebD89e534d4C459b252BA0963e0A0499';
|
|
40
|
+
/**
|
|
41
|
+
* ConsensusModule — LIVE on Base mainnet.
|
|
42
|
+
* Deployed Feb 6 2026.
|
|
43
|
+
*/
|
|
44
|
+
exports.CONSENSUS_MODULE_ADDRESS = '0xcB4A36a7c99e42B3F4b1c8EE6EDD0f3A7DDEcC76';
|
|
45
|
+
// ─────────────────────────────────────────────────────────────
|
|
46
|
+
// TRUST DEFAULTS
|
|
47
|
+
// ─────────────────────────────────────────────────────────────
|
|
48
|
+
/** Maximum trust score (100.00% stored as integer). */
|
|
49
|
+
exports.MAX_TRUST_SCORE = 10000;
|
|
50
|
+
/** New agents start at 50% of their owner's trust score. */
|
|
51
|
+
exports.INITIAL_TRUST_DIVISOR = 2;
|
|
52
|
+
/** Trust decays by 15% per hop in the q00b graph. */
|
|
53
|
+
exports.TRUST_DECAY_PER_HOP_PERCENT = 15;
|
|
54
|
+
/** Minimum effective trust floor (10%). */
|
|
55
|
+
exports.MIN_TRUST_FLOOR_PERCENT = 10;
|
|
56
|
+
// ─────────────────────────────────────────────────────────────
|
|
57
|
+
// AGENT DEFAULTS
|
|
58
|
+
// ─────────────────────────────────────────────────────────────
|
|
59
|
+
/** Default max hops for communication. */
|
|
60
|
+
exports.DEFAULT_MAX_HOPS = 3;
|
|
61
|
+
/** Default max single transaction value: 0.1 ETH. */
|
|
62
|
+
exports.DEFAULT_MAX_TX_VALUE_ETH = '0.1';
|
|
63
|
+
/** Default daily spend limit: 1 ETH. */
|
|
64
|
+
exports.DEFAULT_DAILY_LIMIT_ETH = '1';
|
|
65
|
+
/** Maximum number of sides on a q00b. */
|
|
66
|
+
exports.MAX_Q00B_SIDES = 6;
|
|
67
|
+
// ─────────────────────────────────────────────────────────────
|
|
68
|
+
// ESCROW DEFAULTS
|
|
69
|
+
// ─────────────────────────────────────────────────────────────
|
|
70
|
+
/** Protocol fee in basis points (100 = 1%). */
|
|
71
|
+
exports.PROTOCOL_FEE_BPS = 100;
|
|
72
|
+
/** Default escrow deadline: 24 hours. */
|
|
73
|
+
exports.DEFAULT_ESCROW_DEADLINE_MS = 24 * 60 * 60 * 1000;
|
|
74
|
+
// ─────────────────────────────────────────────────────────────
|
|
75
|
+
// CONSENSUS THRESHOLDS
|
|
76
|
+
// ─────────────────────────────────────────────────────────────
|
|
77
|
+
/** Below this ETH value, no consensus needed. */
|
|
78
|
+
exports.LOW_RISK_THRESHOLD_ETH = '0.01';
|
|
79
|
+
/** Below this ETH value, 2/6 consensus needed. */
|
|
80
|
+
exports.MEDIUM_RISK_THRESHOLD_ETH = '0.1';
|
|
81
|
+
/** Below this ETH value, 4/6 consensus needed. */
|
|
82
|
+
exports.HIGH_RISK_THRESHOLD_ETH = '1';
|
|
83
|
+
/** Above HIGH_RISK, 4/6 consensus + human approval needed. */
|
|
84
|
+
// ─────────────────────────────────────────────────────────────
|
|
85
|
+
// ERC-8004 TRUSTLESS AGENTS (BASE MAINNET)
|
|
86
|
+
// ─────────────────────────────────────────────────────────────
|
|
87
|
+
//
|
|
88
|
+
// Canonical registry addresses deployed by the ERC-8004 team.
|
|
89
|
+
// These are the OFFICIAL addresses on Base mainnet.
|
|
90
|
+
// Reference: https://www.8004.org/build
|
|
91
|
+
/**
|
|
92
|
+
* ERC-8004 IdentityRegistry on Base mainnet.
|
|
93
|
+
* ERC-721-based agent identity registry.
|
|
94
|
+
*/
|
|
95
|
+
exports.ERC8004_IDENTITY_REGISTRY_ADDRESS = '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432';
|
|
96
|
+
/**
|
|
97
|
+
* ERC-8004 ReputationRegistry on Base mainnet.
|
|
98
|
+
* Stores signed fixed-point feedback signals.
|
|
99
|
+
*/
|
|
100
|
+
exports.ERC8004_REPUTATION_REGISTRY_ADDRESS = '0x8004BAa17C55a88189AE136b182e5fdA19dE9b63';
|
|
101
|
+
/**
|
|
102
|
+
* ERC-8004 ValidationRegistry on Base mainnet.
|
|
103
|
+
* Hooks for validator contracts to publish results.
|
|
104
|
+
* NOTE: Address TBD — the ValidationRegistry spec is still evolving.
|
|
105
|
+
* Update this when the canonical deployment is confirmed.
|
|
106
|
+
*/
|
|
107
|
+
exports.ERC8004_VALIDATION_REGISTRY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
108
|
+
/**
|
|
109
|
+
* Q00bs namespace for ERC-8004 agent identifiers.
|
|
110
|
+
* Used in the identifier format: {namespace}:{chainId}:{registry}:{agentId}
|
|
111
|
+
*/
|
|
112
|
+
exports.ERC8004_NAMESPACE = 'q00bs';
|
|
113
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,gEAAgE;AAChE,sBAAsB;AACtB,gEAAgE;AAEhE,6BAA6B;AAChB,QAAA,aAAa,GAAG,IAAI,CAAC;AAElC,yFAAyF;AAC5E,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAE1D,gEAAgE;AAChE,6CAA6C;AAC7C,gEAAgE;AAEhE;;;GAGG;AACU,QAAA,oBAAoB,GAAG,4CAA4C,CAAC;AAEjF;;GAEG;AACU,QAAA,oBAAoB,GAAG,4CAA4C,CAAC;AAEjF;;;GAGG;AACU,QAAA,sBAAsB,GAAG,4CAA4C,CAAC;AAEnF;;;GAGG;AACU,QAAA,oBAAoB,GAAG,4CAA4C,CAAC;AAEjF;;;GAGG;AACU,QAAA,wBAAwB,GAAG,4CAA4C,CAAC;AAErF,gEAAgE;AAChE,iBAAiB;AACjB,gEAAgE;AAEhE,uDA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|
1
|
+
/**
|
|
2
|
+
* @q00bs/agent-sdk — Discovery Module
|
|
3
|
+
*
|
|
4
|
+
* Finds other registered agents on-chain based on trust proximity,
|
|
5
|
+
* activity status, and capabilities.
|
|
6
|
+
*
|
|
7
|
+
* HOW DISCOVERY WORKS:
|
|
8
|
+
* 1. Read totalSupply() from AgentRegistry to know how many agents exist.
|
|
9
|
+
* 2. Iterate through agents, filtering by:
|
|
10
|
+
* - Active + not frozen
|
|
11
|
+
* - Connected to the querying agent (trust path exists)
|
|
12
|
+
* - Minimum trust score
|
|
13
|
+
* - Max hops
|
|
14
|
+
* 3. Sort results by trust score (default) or recency.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: For large agent populations, this on-chain iteration won't scale.
|
|
17
|
+
* The Trust API server (api/) provides an indexed, paginated version.
|
|
18
|
+
* This SDK module works well for <1000 agents.
|
|
19
|
+
*/
|
|
20
|
+
import type { PublicClient, Chain, Transport } from 'viem';
|
|
21
|
+
import type { AgentQuery, DiscoveredAgent, AgentRecord, Logger } from './types';
|
|
22
|
+
import { TrustResolver } from './trust';
|
|
23
|
+
export declare class AgentDiscovery {
|
|
24
|
+
private client;
|
|
25
|
+
private registryAddress;
|
|
26
|
+
private trustResolver;
|
|
27
|
+
private logger;
|
|
28
|
+
constructor(client: PublicClient<Transport, Chain>, registryAddress: string, trustResolver: TrustResolver, logger: Logger);
|
|
29
|
+
/**
|
|
30
|
+
* Search for agents that match given criteria.
|
|
31
|
+
*
|
|
32
|
+
* @param myAgentId - Your agent's on-chain ID (used for trust-path filtering).
|
|
33
|
+
* @param query - Filters: minimum trust, max hops, limit, sort order.
|
|
34
|
+
* @returns Array of discovered agents, sorted by effective trust (descending).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const agents = await discovery.find(1, {
|
|
39
|
+
* minTrustScore: 50,
|
|
40
|
+
* maxHops: 2,
|
|
41
|
+
* limit: 10,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
find(myAgentId: number, query?: AgentQuery): Promise<DiscoveredAgent[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a single agent by its on-chain ID.
|
|
48
|
+
*
|
|
49
|
+
* @param agentId - The agent's on-chain ID.
|
|
50
|
+
* @returns The agent record, or null if not found.
|
|
51
|
+
*/
|
|
52
|
+
getAgent(agentId: number): Promise<AgentRecord | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Get an agent by its wallet address.
|
|
55
|
+
*
|
|
56
|
+
* @param wallet - The agent's wallet address.
|
|
57
|
+
* @returns Object with { id, agent } or null if not found.
|
|
58
|
+
*/
|
|
59
|
+
getAgentByWallet(wallet: string): Promise<{
|
|
60
|
+
id: number;
|
|
61
|
+
agent: AgentRecord;
|
|
62
|
+
} | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if a specific agent is active and not frozen.
|
|
65
|
+
*
|
|
66
|
+
* @param agentId - The agent's on-chain ID.
|
|
67
|
+
*/
|
|
68
|
+
isActive(agentId: number): Promise<boolean>;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAOxC,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAS;gBAGrB,MAAM,EAAE,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,EACtC,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM;IAQhB;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,UAAe,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAmFjF;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA8B5D;;;;;OAKG;IACG,gBAAgB,CACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,CAAA;KAAE,GAAG,IAAI,CAAC;IA8BrD;;;;OAIG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAYlD"}
|