@agether/sdk 2.11.0 → 2.12.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/cli.js +32 -7
- package/dist/index.d.mts +17 -7
- package/dist/index.d.ts +17 -7
- package/dist/index.js +32 -7
- package/dist/index.mjs +32 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -57,6 +57,7 @@ var init_abis = __esm({
|
|
|
57
57
|
"function totalSupply() view returns (uint256)",
|
|
58
58
|
"function exists(uint256 agentId) view returns (bool)",
|
|
59
59
|
"function register() returns (uint256 agentId)",
|
|
60
|
+
"function register(string agentURI) returns (uint256 agentId)",
|
|
60
61
|
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
|
|
61
62
|
];
|
|
62
63
|
AGETHER_4337_FACTORY_ABI = [
|
|
@@ -1763,7 +1764,7 @@ var init_AgetherClient = __esm({
|
|
|
1763
1764
|
const signer = new import_ethers2.ethers.Wallet(privateKey, provider);
|
|
1764
1765
|
return new _AgetherClient({ config, signer, agentId, _privateKey: privateKey });
|
|
1765
1766
|
}
|
|
1766
|
-
static fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
|
|
1767
|
+
static async fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
|
|
1767
1768
|
if (!signer.provider) {
|
|
1768
1769
|
throw new AgetherError("Signer must be connected to a provider", "NO_PROVIDER");
|
|
1769
1770
|
}
|
|
@@ -1775,6 +1776,14 @@ var init_AgetherClient = __esm({
|
|
|
1775
1776
|
} else {
|
|
1776
1777
|
config = typeof agentIdOrChain === "number" ? getDefaultConfig(agentIdOrChain) : agentIdOrChain;
|
|
1777
1778
|
}
|
|
1779
|
+
const network = await signer.provider.getNetwork();
|
|
1780
|
+
const actualChainId = Number(network.chainId);
|
|
1781
|
+
if (actualChainId !== config.chainId) {
|
|
1782
|
+
throw new AgetherError(
|
|
1783
|
+
`Chain mismatch: signer is on chain ${actualChainId} but config expects chain ${config.chainId}`,
|
|
1784
|
+
"CHAIN_MISMATCH"
|
|
1785
|
+
);
|
|
1786
|
+
}
|
|
1778
1787
|
return new _AgetherClient({ config, signer, agentId });
|
|
1779
1788
|
}
|
|
1780
1789
|
// ════════════════════════════════════════════════════════
|
|
@@ -1785,8 +1794,11 @@ var init_AgetherClient = __esm({
|
|
|
1785
1794
|
* If already registered, returns existing state.
|
|
1786
1795
|
*
|
|
1787
1796
|
* Sets `this.agentId` on success so subsequent operations work immediately.
|
|
1797
|
+
*
|
|
1798
|
+
* @param options.name Agent display name (stored in on-chain metadata URI)
|
|
1799
|
+
* @param options.description Agent description (defaults to 'AI agent registered via @agether/sdk')
|
|
1788
1800
|
*/
|
|
1789
|
-
async register() {
|
|
1801
|
+
async register(options) {
|
|
1790
1802
|
const eoaAddr = await this._getSignerAddress();
|
|
1791
1803
|
if (this.agentId !== void 0) {
|
|
1792
1804
|
const exists = await this.agether4337Factory.accountExists(this.agentId);
|
|
@@ -1809,10 +1821,10 @@ var init_AgetherClient = __esm({
|
|
|
1809
1821
|
if (balance > 0n) {
|
|
1810
1822
|
agentId = this.agentId;
|
|
1811
1823
|
} else {
|
|
1812
|
-
agentId = await this._mintNewIdentity();
|
|
1824
|
+
agentId = await this._mintNewIdentity(options?.name, options?.description);
|
|
1813
1825
|
}
|
|
1814
1826
|
} else {
|
|
1815
|
-
agentId = await this._mintNewIdentity();
|
|
1827
|
+
agentId = await this._mintNewIdentity(options?.name, options?.description);
|
|
1816
1828
|
}
|
|
1817
1829
|
this.agentId = agentId;
|
|
1818
1830
|
const acctExists = await this.agether4337Factory.accountExists(agentId);
|
|
@@ -1835,9 +1847,22 @@ var init_AgetherClient = __esm({
|
|
|
1835
1847
|
tx: txHash
|
|
1836
1848
|
};
|
|
1837
1849
|
}
|
|
1838
|
-
/** Mint a new ERC-8004 identity and return the agentId.
|
|
1839
|
-
|
|
1840
|
-
|
|
1850
|
+
/** Mint a new ERC-8004 identity and return the agentId.
|
|
1851
|
+
* Builds a JSON metadata document per ERC-8004 spec and encodes it as a data: URI.
|
|
1852
|
+
*/
|
|
1853
|
+
async _mintNewIdentity(name, description) {
|
|
1854
|
+
const registrationFile = JSON.stringify({
|
|
1855
|
+
type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
|
|
1856
|
+
name: name || "Unnamed Agent",
|
|
1857
|
+
description: description || "AI agent registered via @agether/sdk",
|
|
1858
|
+
active: true,
|
|
1859
|
+
registrations: [{
|
|
1860
|
+
agentId: 0,
|
|
1861
|
+
agentRegistry: `eip155:${this.config.chainId}:${this.config.contracts.identityRegistry}`
|
|
1862
|
+
}]
|
|
1863
|
+
});
|
|
1864
|
+
const agentURI = `data:application/json;base64,${Buffer.from(registrationFile).toString("base64")}`;
|
|
1865
|
+
const regTx = await this.identityRegistry["register(string)"](agentURI);
|
|
1841
1866
|
const regReceipt = await regTx.wait();
|
|
1842
1867
|
this._refreshSigner();
|
|
1843
1868
|
let agentId = 0n;
|
package/dist/index.d.mts
CHANGED
|
@@ -195,34 +195,44 @@ declare class AgetherClient {
|
|
|
195
195
|
* Create an AgetherClient from an **external signer** for a **new** agent (no agentId yet).
|
|
196
196
|
*
|
|
197
197
|
* Accepts any `ethers.AbstractSigner` — Privy, Bankr, Turnkey, MetaMask, etc.
|
|
198
|
-
* The signer **must** already be connected to a provider.
|
|
198
|
+
* The signer **must** already be connected to a provider on the correct chain.
|
|
199
|
+
*
|
|
200
|
+
* Validates that the signer's provider chain matches the requested chain.
|
|
199
201
|
*
|
|
200
202
|
* Only `register()` and `getBalances()` are available until registration completes.
|
|
201
203
|
*
|
|
202
204
|
* @example
|
|
203
205
|
* ```ts
|
|
204
|
-
* const client = AgetherClient.fromSigner(privySigner, ChainId.Base);
|
|
206
|
+
* const client = await AgetherClient.fromSigner(privySigner, ChainId.Base);
|
|
205
207
|
* const result = await client.register();
|
|
206
208
|
* ```
|
|
207
209
|
*/
|
|
208
|
-
static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient
|
|
210
|
+
static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
|
|
209
211
|
/**
|
|
210
212
|
* Create an AgetherClient from an **external signer** for an **existing** agent.
|
|
211
213
|
*
|
|
212
214
|
* @example
|
|
213
215
|
* ```ts
|
|
214
|
-
* const client = AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
|
|
216
|
+
* const client = await AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
|
|
215
217
|
* ```
|
|
216
218
|
*/
|
|
217
|
-
static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient
|
|
219
|
+
static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
|
|
218
220
|
/**
|
|
219
221
|
* Register: create ERC-8004 identity + Safe account in one flow.
|
|
220
222
|
* If already registered, returns existing state.
|
|
221
223
|
*
|
|
222
224
|
* Sets `this.agentId` on success so subsequent operations work immediately.
|
|
225
|
+
*
|
|
226
|
+
* @param options.name Agent display name (stored in on-chain metadata URI)
|
|
227
|
+
* @param options.description Agent description (defaults to 'AI agent registered via @agether/sdk')
|
|
228
|
+
*/
|
|
229
|
+
register(options?: {
|
|
230
|
+
name?: string;
|
|
231
|
+
description?: string;
|
|
232
|
+
}): Promise<RegisterResult>;
|
|
233
|
+
/** Mint a new ERC-8004 identity and return the agentId.
|
|
234
|
+
* Builds a JSON metadata document per ERC-8004 spec and encodes it as a data: URI.
|
|
223
235
|
*/
|
|
224
|
-
register(): Promise<RegisterResult>;
|
|
225
|
-
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
226
236
|
private _mintNewIdentity;
|
|
227
237
|
/**
|
|
228
238
|
* Deploy a Safe account smart wallet for the agent.
|
package/dist/index.d.ts
CHANGED
|
@@ -195,34 +195,44 @@ declare class AgetherClient {
|
|
|
195
195
|
* Create an AgetherClient from an **external signer** for a **new** agent (no agentId yet).
|
|
196
196
|
*
|
|
197
197
|
* Accepts any `ethers.AbstractSigner` — Privy, Bankr, Turnkey, MetaMask, etc.
|
|
198
|
-
* The signer **must** already be connected to a provider.
|
|
198
|
+
* The signer **must** already be connected to a provider on the correct chain.
|
|
199
|
+
*
|
|
200
|
+
* Validates that the signer's provider chain matches the requested chain.
|
|
199
201
|
*
|
|
200
202
|
* Only `register()` and `getBalances()` are available until registration completes.
|
|
201
203
|
*
|
|
202
204
|
* @example
|
|
203
205
|
* ```ts
|
|
204
|
-
* const client = AgetherClient.fromSigner(privySigner, ChainId.Base);
|
|
206
|
+
* const client = await AgetherClient.fromSigner(privySigner, ChainId.Base);
|
|
205
207
|
* const result = await client.register();
|
|
206
208
|
* ```
|
|
207
209
|
*/
|
|
208
|
-
static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient
|
|
210
|
+
static fromSigner(signer: ethers.AbstractSigner, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
|
|
209
211
|
/**
|
|
210
212
|
* Create an AgetherClient from an **external signer** for an **existing** agent.
|
|
211
213
|
*
|
|
212
214
|
* @example
|
|
213
215
|
* ```ts
|
|
214
|
-
* const client = AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
|
|
216
|
+
* const client = await AgetherClient.fromSigner(privySigner, 42n, ChainId.Base);
|
|
215
217
|
* ```
|
|
216
218
|
*/
|
|
217
|
-
static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): AgetherClient
|
|
219
|
+
static fromSigner(signer: ethers.AbstractSigner, agentId: bigint, chainIdOrConfig: ChainId | AgetherConfig): Promise<AgetherClient>;
|
|
218
220
|
/**
|
|
219
221
|
* Register: create ERC-8004 identity + Safe account in one flow.
|
|
220
222
|
* If already registered, returns existing state.
|
|
221
223
|
*
|
|
222
224
|
* Sets `this.agentId` on success so subsequent operations work immediately.
|
|
225
|
+
*
|
|
226
|
+
* @param options.name Agent display name (stored in on-chain metadata URI)
|
|
227
|
+
* @param options.description Agent description (defaults to 'AI agent registered via @agether/sdk')
|
|
228
|
+
*/
|
|
229
|
+
register(options?: {
|
|
230
|
+
name?: string;
|
|
231
|
+
description?: string;
|
|
232
|
+
}): Promise<RegisterResult>;
|
|
233
|
+
/** Mint a new ERC-8004 identity and return the agentId.
|
|
234
|
+
* Builds a JSON metadata document per ERC-8004 spec and encodes it as a data: URI.
|
|
223
235
|
*/
|
|
224
|
-
register(): Promise<RegisterResult>;
|
|
225
|
-
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
226
236
|
private _mintNewIdentity;
|
|
227
237
|
/**
|
|
228
238
|
* Deploy a Safe account smart wallet for the agent.
|
package/dist/index.js
CHANGED
|
@@ -128,6 +128,7 @@ var IDENTITY_REGISTRY_ABI = [
|
|
|
128
128
|
"function totalSupply() view returns (uint256)",
|
|
129
129
|
"function exists(uint256 agentId) view returns (bool)",
|
|
130
130
|
"function register() returns (uint256 agentId)",
|
|
131
|
+
"function register(string agentURI) returns (uint256 agentId)",
|
|
131
132
|
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
|
|
132
133
|
];
|
|
133
134
|
var AGETHER_4337_FACTORY_ABI = [
|
|
@@ -418,7 +419,7 @@ var AgetherClient = class _AgetherClient {
|
|
|
418
419
|
const signer = new import_ethers.ethers.Wallet(privateKey, provider);
|
|
419
420
|
return new _AgetherClient({ config, signer, agentId, _privateKey: privateKey });
|
|
420
421
|
}
|
|
421
|
-
static fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
|
|
422
|
+
static async fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
|
|
422
423
|
if (!signer.provider) {
|
|
423
424
|
throw new AgetherError("Signer must be connected to a provider", "NO_PROVIDER");
|
|
424
425
|
}
|
|
@@ -430,6 +431,14 @@ var AgetherClient = class _AgetherClient {
|
|
|
430
431
|
} else {
|
|
431
432
|
config = typeof agentIdOrChain === "number" ? getDefaultConfig(agentIdOrChain) : agentIdOrChain;
|
|
432
433
|
}
|
|
434
|
+
const network = await signer.provider.getNetwork();
|
|
435
|
+
const actualChainId = Number(network.chainId);
|
|
436
|
+
if (actualChainId !== config.chainId) {
|
|
437
|
+
throw new AgetherError(
|
|
438
|
+
`Chain mismatch: signer is on chain ${actualChainId} but config expects chain ${config.chainId}`,
|
|
439
|
+
"CHAIN_MISMATCH"
|
|
440
|
+
);
|
|
441
|
+
}
|
|
433
442
|
return new _AgetherClient({ config, signer, agentId });
|
|
434
443
|
}
|
|
435
444
|
// ════════════════════════════════════════════════════════
|
|
@@ -440,8 +449,11 @@ var AgetherClient = class _AgetherClient {
|
|
|
440
449
|
* If already registered, returns existing state.
|
|
441
450
|
*
|
|
442
451
|
* Sets `this.agentId` on success so subsequent operations work immediately.
|
|
452
|
+
*
|
|
453
|
+
* @param options.name Agent display name (stored in on-chain metadata URI)
|
|
454
|
+
* @param options.description Agent description (defaults to 'AI agent registered via @agether/sdk')
|
|
443
455
|
*/
|
|
444
|
-
async register() {
|
|
456
|
+
async register(options) {
|
|
445
457
|
const eoaAddr = await this._getSignerAddress();
|
|
446
458
|
if (this.agentId !== void 0) {
|
|
447
459
|
const exists = await this.agether4337Factory.accountExists(this.agentId);
|
|
@@ -464,10 +476,10 @@ var AgetherClient = class _AgetherClient {
|
|
|
464
476
|
if (balance > 0n) {
|
|
465
477
|
agentId = this.agentId;
|
|
466
478
|
} else {
|
|
467
|
-
agentId = await this._mintNewIdentity();
|
|
479
|
+
agentId = await this._mintNewIdentity(options?.name, options?.description);
|
|
468
480
|
}
|
|
469
481
|
} else {
|
|
470
|
-
agentId = await this._mintNewIdentity();
|
|
482
|
+
agentId = await this._mintNewIdentity(options?.name, options?.description);
|
|
471
483
|
}
|
|
472
484
|
this.agentId = agentId;
|
|
473
485
|
const acctExists = await this.agether4337Factory.accountExists(agentId);
|
|
@@ -490,9 +502,22 @@ var AgetherClient = class _AgetherClient {
|
|
|
490
502
|
tx: txHash
|
|
491
503
|
};
|
|
492
504
|
}
|
|
493
|
-
/** Mint a new ERC-8004 identity and return the agentId.
|
|
494
|
-
|
|
495
|
-
|
|
505
|
+
/** Mint a new ERC-8004 identity and return the agentId.
|
|
506
|
+
* Builds a JSON metadata document per ERC-8004 spec and encodes it as a data: URI.
|
|
507
|
+
*/
|
|
508
|
+
async _mintNewIdentity(name, description) {
|
|
509
|
+
const registrationFile = JSON.stringify({
|
|
510
|
+
type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
|
|
511
|
+
name: name || "Unnamed Agent",
|
|
512
|
+
description: description || "AI agent registered via @agether/sdk",
|
|
513
|
+
active: true,
|
|
514
|
+
registrations: [{
|
|
515
|
+
agentId: 0,
|
|
516
|
+
agentRegistry: `eip155:${this.config.chainId}:${this.config.contracts.identityRegistry}`
|
|
517
|
+
}]
|
|
518
|
+
});
|
|
519
|
+
const agentURI = `data:application/json;base64,${Buffer.from(registrationFile).toString("base64")}`;
|
|
520
|
+
const regTx = await this.identityRegistry["register(string)"](agentURI);
|
|
496
521
|
const regReceipt = await regTx.wait();
|
|
497
522
|
this._refreshSigner();
|
|
498
523
|
let agentId = 0n;
|
package/dist/index.mjs
CHANGED
|
@@ -53,6 +53,7 @@ var IDENTITY_REGISTRY_ABI = [
|
|
|
53
53
|
"function totalSupply() view returns (uint256)",
|
|
54
54
|
"function exists(uint256 agentId) view returns (bool)",
|
|
55
55
|
"function register() returns (uint256 agentId)",
|
|
56
|
+
"function register(string agentURI) returns (uint256 agentId)",
|
|
56
57
|
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
|
|
57
58
|
];
|
|
58
59
|
var AGETHER_4337_FACTORY_ABI = [
|
|
@@ -343,7 +344,7 @@ var AgetherClient = class _AgetherClient {
|
|
|
343
344
|
const signer = new ethers.Wallet(privateKey, provider);
|
|
344
345
|
return new _AgetherClient({ config, signer, agentId, _privateKey: privateKey });
|
|
345
346
|
}
|
|
346
|
-
static fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
|
|
347
|
+
static async fromSigner(signer, agentIdOrChain, chainIdOrConfig) {
|
|
347
348
|
if (!signer.provider) {
|
|
348
349
|
throw new AgetherError("Signer must be connected to a provider", "NO_PROVIDER");
|
|
349
350
|
}
|
|
@@ -355,6 +356,14 @@ var AgetherClient = class _AgetherClient {
|
|
|
355
356
|
} else {
|
|
356
357
|
config = typeof agentIdOrChain === "number" ? getDefaultConfig(agentIdOrChain) : agentIdOrChain;
|
|
357
358
|
}
|
|
359
|
+
const network = await signer.provider.getNetwork();
|
|
360
|
+
const actualChainId = Number(network.chainId);
|
|
361
|
+
if (actualChainId !== config.chainId) {
|
|
362
|
+
throw new AgetherError(
|
|
363
|
+
`Chain mismatch: signer is on chain ${actualChainId} but config expects chain ${config.chainId}`,
|
|
364
|
+
"CHAIN_MISMATCH"
|
|
365
|
+
);
|
|
366
|
+
}
|
|
358
367
|
return new _AgetherClient({ config, signer, agentId });
|
|
359
368
|
}
|
|
360
369
|
// ════════════════════════════════════════════════════════
|
|
@@ -365,8 +374,11 @@ var AgetherClient = class _AgetherClient {
|
|
|
365
374
|
* If already registered, returns existing state.
|
|
366
375
|
*
|
|
367
376
|
* Sets `this.agentId` on success so subsequent operations work immediately.
|
|
377
|
+
*
|
|
378
|
+
* @param options.name Agent display name (stored in on-chain metadata URI)
|
|
379
|
+
* @param options.description Agent description (defaults to 'AI agent registered via @agether/sdk')
|
|
368
380
|
*/
|
|
369
|
-
async register() {
|
|
381
|
+
async register(options) {
|
|
370
382
|
const eoaAddr = await this._getSignerAddress();
|
|
371
383
|
if (this.agentId !== void 0) {
|
|
372
384
|
const exists = await this.agether4337Factory.accountExists(this.agentId);
|
|
@@ -389,10 +401,10 @@ var AgetherClient = class _AgetherClient {
|
|
|
389
401
|
if (balance > 0n) {
|
|
390
402
|
agentId = this.agentId;
|
|
391
403
|
} else {
|
|
392
|
-
agentId = await this._mintNewIdentity();
|
|
404
|
+
agentId = await this._mintNewIdentity(options?.name, options?.description);
|
|
393
405
|
}
|
|
394
406
|
} else {
|
|
395
|
-
agentId = await this._mintNewIdentity();
|
|
407
|
+
agentId = await this._mintNewIdentity(options?.name, options?.description);
|
|
396
408
|
}
|
|
397
409
|
this.agentId = agentId;
|
|
398
410
|
const acctExists = await this.agether4337Factory.accountExists(agentId);
|
|
@@ -415,9 +427,22 @@ var AgetherClient = class _AgetherClient {
|
|
|
415
427
|
tx: txHash
|
|
416
428
|
};
|
|
417
429
|
}
|
|
418
|
-
/** Mint a new ERC-8004 identity and return the agentId.
|
|
419
|
-
|
|
420
|
-
|
|
430
|
+
/** Mint a new ERC-8004 identity and return the agentId.
|
|
431
|
+
* Builds a JSON metadata document per ERC-8004 spec and encodes it as a data: URI.
|
|
432
|
+
*/
|
|
433
|
+
async _mintNewIdentity(name, description) {
|
|
434
|
+
const registrationFile = JSON.stringify({
|
|
435
|
+
type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
|
|
436
|
+
name: name || "Unnamed Agent",
|
|
437
|
+
description: description || "AI agent registered via @agether/sdk",
|
|
438
|
+
active: true,
|
|
439
|
+
registrations: [{
|
|
440
|
+
agentId: 0,
|
|
441
|
+
agentRegistry: `eip155:${this.config.chainId}:${this.config.contracts.identityRegistry}`
|
|
442
|
+
}]
|
|
443
|
+
});
|
|
444
|
+
const agentURI = `data:application/json;base64,${Buffer.from(registrationFile).toString("base64")}`;
|
|
445
|
+
const regTx = await this.identityRegistry["register(string)"](agentURI);
|
|
421
446
|
const regReceipt = await regTx.wait();
|
|
422
447
|
this._refreshSigner();
|
|
423
448
|
let agentId = 0n;
|