@exagent/sdk 0.1.1 → 0.1.2
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/index.d.mts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +17 -11
- package/dist/index.mjs +14 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import { Address, Hash, Chain, Account, WalletClient } from 'viem';
|
|
2
|
+
import { Address, Hash, Chain, Account, Hex, WalletClient } from 'viem';
|
|
3
3
|
import * as viem_chains from 'viem/chains';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -357,13 +357,15 @@ declare class ExagentRegistry {
|
|
|
357
357
|
*/
|
|
358
358
|
getNextAgentId(): Promise<bigint>;
|
|
359
359
|
/**
|
|
360
|
-
* Generate the message
|
|
360
|
+
* Generate the raw packed message bytes for wallet linking.
|
|
361
|
+
* Must match the contract's abi.encodePacked format exactly:
|
|
362
|
+
* keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
|
|
361
363
|
* @param wallet The wallet to link
|
|
362
364
|
* @param agentId The agent ID to link to
|
|
363
365
|
* @param nonce The current nonce for the wallet
|
|
364
|
-
* @returns
|
|
366
|
+
* @returns Raw packed bytes as hex string
|
|
365
367
|
*/
|
|
366
|
-
static generateLinkMessage(wallet: Address, agentId: bigint, nonce: bigint):
|
|
368
|
+
static generateLinkMessage(wallet: Address, agentId: bigint, nonce: bigint): Hex;
|
|
367
369
|
/**
|
|
368
370
|
* Get the agent owned by a wallet (not linked, owned)
|
|
369
371
|
* @param wallet The wallet to look up
|
|
@@ -2166,10 +2168,12 @@ declare class ExagentClient {
|
|
|
2166
2168
|
get address(): Address;
|
|
2167
2169
|
/**
|
|
2168
2170
|
* Sign a message with the wallet's private key (EIP-191 personal sign)
|
|
2169
|
-
* @param message The message to sign
|
|
2171
|
+
* @param message The message to sign — string for UTF-8, or { raw: Hex } for raw bytes
|
|
2170
2172
|
* @returns The signature
|
|
2171
2173
|
*/
|
|
2172
|
-
signMessage(message: string
|
|
2174
|
+
signMessage(message: string | {
|
|
2175
|
+
raw: `0x${string}`;
|
|
2176
|
+
}): Promise<`0x${string}`>;
|
|
2173
2177
|
private uploadMetadata;
|
|
2174
2178
|
private signIntent;
|
|
2175
2179
|
private parseAgentIdFromReceipt;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
|
-
import { Address, Hash, Chain, Account, WalletClient } from 'viem';
|
|
2
|
+
import { Address, Hash, Chain, Account, Hex, WalletClient } from 'viem';
|
|
3
3
|
import * as viem_chains from 'viem/chains';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -357,13 +357,15 @@ declare class ExagentRegistry {
|
|
|
357
357
|
*/
|
|
358
358
|
getNextAgentId(): Promise<bigint>;
|
|
359
359
|
/**
|
|
360
|
-
* Generate the message
|
|
360
|
+
* Generate the raw packed message bytes for wallet linking.
|
|
361
|
+
* Must match the contract's abi.encodePacked format exactly:
|
|
362
|
+
* keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
|
|
361
363
|
* @param wallet The wallet to link
|
|
362
364
|
* @param agentId The agent ID to link to
|
|
363
365
|
* @param nonce The current nonce for the wallet
|
|
364
|
-
* @returns
|
|
366
|
+
* @returns Raw packed bytes as hex string
|
|
365
367
|
*/
|
|
366
|
-
static generateLinkMessage(wallet: Address, agentId: bigint, nonce: bigint):
|
|
368
|
+
static generateLinkMessage(wallet: Address, agentId: bigint, nonce: bigint): Hex;
|
|
367
369
|
/**
|
|
368
370
|
* Get the agent owned by a wallet (not linked, owned)
|
|
369
371
|
* @param wallet The wallet to look up
|
|
@@ -2166,10 +2168,12 @@ declare class ExagentClient {
|
|
|
2166
2168
|
get address(): Address;
|
|
2167
2169
|
/**
|
|
2168
2170
|
* Sign a message with the wallet's private key (EIP-191 personal sign)
|
|
2169
|
-
* @param message The message to sign
|
|
2171
|
+
* @param message The message to sign — string for UTF-8, or { raw: Hex } for raw bytes
|
|
2170
2172
|
* @returns The signature
|
|
2171
2173
|
*/
|
|
2172
|
-
signMessage(message: string
|
|
2174
|
+
signMessage(message: string | {
|
|
2175
|
+
raw: `0x${string}`;
|
|
2176
|
+
}): Promise<`0x${string}`>;
|
|
2173
2177
|
private uploadMetadata;
|
|
2174
2178
|
private signIntent;
|
|
2175
2179
|
private parseAgentIdFromReceipt;
|
package/dist/index.js
CHANGED
|
@@ -38,10 +38,11 @@ __export(index_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
39
|
|
|
40
40
|
// src/client.ts
|
|
41
|
-
var
|
|
41
|
+
var import_viem2 = require("viem");
|
|
42
42
|
var import_accounts = require("viem/accounts");
|
|
43
43
|
|
|
44
44
|
// src/contracts/registry.ts
|
|
45
|
+
var import_viem = require("viem");
|
|
45
46
|
var EXAGENT_REGISTRY_ABI = [
|
|
46
47
|
{
|
|
47
48
|
type: "function",
|
|
@@ -510,14 +511,19 @@ var ExagentRegistry = class {
|
|
|
510
511
|
return nextId;
|
|
511
512
|
}
|
|
512
513
|
/**
|
|
513
|
-
* Generate the message
|
|
514
|
+
* Generate the raw packed message bytes for wallet linking.
|
|
515
|
+
* Must match the contract's abi.encodePacked format exactly:
|
|
516
|
+
* keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
|
|
514
517
|
* @param wallet The wallet to link
|
|
515
518
|
* @param agentId The agent ID to link to
|
|
516
519
|
* @param nonce The current nonce for the wallet
|
|
517
|
-
* @returns
|
|
520
|
+
* @returns Raw packed bytes as hex string
|
|
518
521
|
*/
|
|
519
522
|
static generateLinkMessage(wallet, agentId, nonce) {
|
|
520
|
-
return
|
|
523
|
+
return (0, import_viem.encodePacked)(
|
|
524
|
+
["string", "address", "string", "uint256", "string", "uint256"],
|
|
525
|
+
["Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce]
|
|
526
|
+
);
|
|
521
527
|
}
|
|
522
528
|
// ============ V4: One Agent Per Wallet ============
|
|
523
529
|
/**
|
|
@@ -649,8 +655,8 @@ var ExagentRegistry = class {
|
|
|
649
655
|
* @returns keccak256 hash of the config
|
|
650
656
|
*/
|
|
651
657
|
static calculateConfigHash(provider, model) {
|
|
652
|
-
const { keccak256, encodePacked } = require("viem");
|
|
653
|
-
return keccak256(
|
|
658
|
+
const { keccak256, encodePacked: encodePacked2 } = require("viem");
|
|
659
|
+
return keccak256(encodePacked2(["string", "string"], [provider, model]));
|
|
654
660
|
}
|
|
655
661
|
};
|
|
656
662
|
|
|
@@ -1876,19 +1882,19 @@ var ExagentClient = class {
|
|
|
1876
1882
|
this.apiKey = config.apiKey;
|
|
1877
1883
|
validateContractAddresses(this.network);
|
|
1878
1884
|
const chain = CHAIN_CONFIG[this.network];
|
|
1879
|
-
this.publicClient = (0,
|
|
1885
|
+
this.publicClient = (0, import_viem2.createPublicClient)({
|
|
1880
1886
|
chain,
|
|
1881
|
-
transport: (0,
|
|
1887
|
+
transport: (0, import_viem2.http)(config.rpcUrl)
|
|
1882
1888
|
});
|
|
1883
1889
|
if (config.walletClient) {
|
|
1884
1890
|
this.walletClient = config.walletClient;
|
|
1885
1891
|
this.account = config.walletClient.account;
|
|
1886
1892
|
} else if (config.privateKey) {
|
|
1887
1893
|
this.account = (0, import_accounts.privateKeyToAccount)(config.privateKey);
|
|
1888
|
-
this.walletClient = (0,
|
|
1894
|
+
this.walletClient = (0, import_viem2.createWalletClient)({
|
|
1889
1895
|
account: this.account,
|
|
1890
1896
|
chain,
|
|
1891
|
-
transport: (0,
|
|
1897
|
+
transport: (0, import_viem2.http)(config.rpcUrl)
|
|
1892
1898
|
});
|
|
1893
1899
|
} else {
|
|
1894
1900
|
throw new Error("Either privateKey or walletClient must be provided");
|
|
@@ -2439,7 +2445,7 @@ var ExagentClient = class {
|
|
|
2439
2445
|
}
|
|
2440
2446
|
/**
|
|
2441
2447
|
* Sign a message with the wallet's private key (EIP-191 personal sign)
|
|
2442
|
-
* @param message The message to sign
|
|
2448
|
+
* @param message The message to sign — string for UTF-8, or { raw: Hex } for raw bytes
|
|
2443
2449
|
* @returns The signature
|
|
2444
2450
|
*/
|
|
2445
2451
|
async signMessage(message) {
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
import { privateKeyToAccount } from "viem/accounts";
|
|
15
15
|
|
|
16
16
|
// src/contracts/registry.ts
|
|
17
|
+
import {
|
|
18
|
+
encodePacked
|
|
19
|
+
} from "viem";
|
|
17
20
|
var EXAGENT_REGISTRY_ABI = [
|
|
18
21
|
{
|
|
19
22
|
type: "function",
|
|
@@ -482,14 +485,19 @@ var ExagentRegistry = class {
|
|
|
482
485
|
return nextId;
|
|
483
486
|
}
|
|
484
487
|
/**
|
|
485
|
-
* Generate the message
|
|
488
|
+
* Generate the raw packed message bytes for wallet linking.
|
|
489
|
+
* Must match the contract's abi.encodePacked format exactly:
|
|
490
|
+
* keccak256(abi.encodePacked("Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce))
|
|
486
491
|
* @param wallet The wallet to link
|
|
487
492
|
* @param agentId The agent ID to link to
|
|
488
493
|
* @param nonce The current nonce for the wallet
|
|
489
|
-
* @returns
|
|
494
|
+
* @returns Raw packed bytes as hex string
|
|
490
495
|
*/
|
|
491
496
|
static generateLinkMessage(wallet, agentId, nonce) {
|
|
492
|
-
return
|
|
497
|
+
return encodePacked(
|
|
498
|
+
["string", "address", "string", "uint256", "string", "uint256"],
|
|
499
|
+
["Link wallet ", wallet, " to Exagent ", agentId, " nonce ", nonce]
|
|
500
|
+
);
|
|
493
501
|
}
|
|
494
502
|
// ============ V4: One Agent Per Wallet ============
|
|
495
503
|
/**
|
|
@@ -621,8 +629,8 @@ var ExagentRegistry = class {
|
|
|
621
629
|
* @returns keccak256 hash of the config
|
|
622
630
|
*/
|
|
623
631
|
static calculateConfigHash(provider, model) {
|
|
624
|
-
const { keccak256, encodePacked } = __require("viem");
|
|
625
|
-
return keccak256(
|
|
632
|
+
const { keccak256, encodePacked: encodePacked2 } = __require("viem");
|
|
633
|
+
return keccak256(encodePacked2(["string", "string"], [provider, model]));
|
|
626
634
|
}
|
|
627
635
|
};
|
|
628
636
|
|
|
@@ -2411,7 +2419,7 @@ var ExagentClient = class {
|
|
|
2411
2419
|
}
|
|
2412
2420
|
/**
|
|
2413
2421
|
* Sign a message with the wallet's private key (EIP-191 personal sign)
|
|
2414
|
-
* @param message The message to sign
|
|
2422
|
+
* @param message The message to sign — string for UTF-8, or { raw: Hex } for raw bytes
|
|
2415
2423
|
* @returns The signature
|
|
2416
2424
|
*/
|
|
2417
2425
|
async signMessage(message) {
|