@moltium/core 0.1.28 → 0.1.30
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/AgentWallet-WSXDC5NX.mjs +7 -0
- package/dist/AgentWallet-WSXDC5NX.mjs.map +1 -0
- package/dist/chunk-K2UFQ7YF.mjs +197 -0
- package/dist/chunk-K2UFQ7YF.mjs.map +1 -0
- package/dist/index.d.cts +67 -3
- package/dist/index.d.ts +67 -3
- package/dist/index.js +415 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -128
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/logger.ts
|
|
9
|
+
import winston from "winston";
|
|
10
|
+
var logLevel = process.env.LOG_LEVEL || "info";
|
|
11
|
+
var colors = {
|
|
12
|
+
reset: "\x1B[0m",
|
|
13
|
+
dim: "\x1B[2m",
|
|
14
|
+
bold: "\x1B[1m",
|
|
15
|
+
cyan: "\x1B[36m",
|
|
16
|
+
yellow: "\x1B[33m",
|
|
17
|
+
green: "\x1B[32m",
|
|
18
|
+
red: "\x1B[31m",
|
|
19
|
+
magenta: "\x1B[35m",
|
|
20
|
+
blue: "\x1B[34m",
|
|
21
|
+
white: "\x1B[37m",
|
|
22
|
+
gray: "\x1B[90m"
|
|
23
|
+
};
|
|
24
|
+
var levelColors = {
|
|
25
|
+
error: colors.red,
|
|
26
|
+
warn: colors.yellow,
|
|
27
|
+
info: colors.green,
|
|
28
|
+
debug: colors.gray
|
|
29
|
+
};
|
|
30
|
+
function createLogger(label) {
|
|
31
|
+
return winston.createLogger({
|
|
32
|
+
level: logLevel,
|
|
33
|
+
format: winston.format.combine(
|
|
34
|
+
winston.format.timestamp({ format: "HH:mm:ss" }),
|
|
35
|
+
winston.format.label({ label }),
|
|
36
|
+
winston.format.printf(({ timestamp, level, label: label2, message, ...meta }) => {
|
|
37
|
+
const lvlColor = levelColors[level] || colors.white;
|
|
38
|
+
const lvl = `${lvlColor}${level.toUpperCase().padEnd(5)}${colors.reset}`;
|
|
39
|
+
const mod = `${colors.magenta}[${label2}]${colors.reset}`;
|
|
40
|
+
const ts = `${colors.dim}${timestamp}${colors.reset}`;
|
|
41
|
+
const metaStr = Object.keys(meta).length > 0 ? ` ${colors.dim}${JSON.stringify(meta)}${colors.reset}` : "";
|
|
42
|
+
return `${ts} ${lvl} ${mod} ${message}${metaStr}`;
|
|
43
|
+
})
|
|
44
|
+
),
|
|
45
|
+
transports: [new winston.transports.Console()]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/wallet/AgentWallet.ts
|
|
50
|
+
var logger = createLogger("AgentWallet");
|
|
51
|
+
var AgentWallet = class {
|
|
52
|
+
constructor(privateKey, rpcUrl) {
|
|
53
|
+
this.privateKey = privateKey;
|
|
54
|
+
if (!privateKey.startsWith("0x")) {
|
|
55
|
+
this.privateKey = `0x${privateKey}`;
|
|
56
|
+
}
|
|
57
|
+
if (rpcUrl) {
|
|
58
|
+
this.connect(rpcUrl);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ethers;
|
|
62
|
+
wallet;
|
|
63
|
+
// ethers.Wallet
|
|
64
|
+
provider;
|
|
65
|
+
// ethers.JsonRpcProvider
|
|
66
|
+
_address = null;
|
|
67
|
+
/**
|
|
68
|
+
* Lazy-load ethers.js (optional peer dependency)
|
|
69
|
+
*/
|
|
70
|
+
async loadEthers() {
|
|
71
|
+
if (this.ethers) return this.ethers;
|
|
72
|
+
try {
|
|
73
|
+
this.ethers = await import("ethers");
|
|
74
|
+
return this.ethers;
|
|
75
|
+
} catch {
|
|
76
|
+
throw new Error(
|
|
77
|
+
"ethers.js is required for wallet operations. Install it: npm install ethers"
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Ensure wallet is initialized
|
|
83
|
+
*/
|
|
84
|
+
async ensureWallet() {
|
|
85
|
+
if (this.wallet) return;
|
|
86
|
+
const ethers = await this.loadEthers();
|
|
87
|
+
if (this.provider) {
|
|
88
|
+
this.wallet = new ethers.Wallet(this.privateKey, this.provider);
|
|
89
|
+
} else {
|
|
90
|
+
this.wallet = new ethers.Wallet(this.privateKey);
|
|
91
|
+
}
|
|
92
|
+
this._address = this.wallet.address;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Connect to a blockchain RPC endpoint
|
|
96
|
+
*/
|
|
97
|
+
connect(rpcUrl) {
|
|
98
|
+
this._rpcUrl = rpcUrl;
|
|
99
|
+
this.wallet = null;
|
|
100
|
+
this.provider = null;
|
|
101
|
+
}
|
|
102
|
+
_rpcUrl;
|
|
103
|
+
/**
|
|
104
|
+
* Ensure provider is connected
|
|
105
|
+
*/
|
|
106
|
+
async ensureProvider() {
|
|
107
|
+
if (this.provider) return;
|
|
108
|
+
if (!this._rpcUrl) {
|
|
109
|
+
throw new Error("No RPC URL configured. Call connect(rpcUrl) first.");
|
|
110
|
+
}
|
|
111
|
+
const ethers = await this.loadEthers();
|
|
112
|
+
this.provider = new ethers.JsonRpcProvider(this._rpcUrl);
|
|
113
|
+
this.wallet = new ethers.Wallet(this.privateKey, this.provider);
|
|
114
|
+
this._address = this.wallet.address;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get the wallet address derived from the private key.
|
|
118
|
+
* This is synchronous if ethers is already loaded, otherwise async.
|
|
119
|
+
*/
|
|
120
|
+
getAddress() {
|
|
121
|
+
if (this._address) return this._address;
|
|
122
|
+
try {
|
|
123
|
+
const ethers = __require("ethers");
|
|
124
|
+
const addr = ethers.computeAddress(this.privateKey);
|
|
125
|
+
this._address = addr;
|
|
126
|
+
return addr;
|
|
127
|
+
} catch {
|
|
128
|
+
throw new Error(
|
|
129
|
+
"ethers.js is required for wallet operations. Install it: npm install ethers"
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get wallet address (async version — always works)
|
|
135
|
+
*/
|
|
136
|
+
async getAddressAsync() {
|
|
137
|
+
if (this._address) return this._address;
|
|
138
|
+
const ethers = await this.loadEthers();
|
|
139
|
+
const addr = ethers.computeAddress(this.privateKey);
|
|
140
|
+
this._address = addr;
|
|
141
|
+
return addr;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Send native tokens (MON/ETH) to an address
|
|
145
|
+
* @param to Recipient address
|
|
146
|
+
* @param amountWei Amount in wei (string)
|
|
147
|
+
* @returns Transaction hash
|
|
148
|
+
*/
|
|
149
|
+
async sendPayment(to, amountWei) {
|
|
150
|
+
await this.ensureProvider();
|
|
151
|
+
logger.info(`Sending payment: ${amountWei} wei to ${to}`);
|
|
152
|
+
const tx = await this.wallet.sendTransaction({
|
|
153
|
+
to,
|
|
154
|
+
value: BigInt(amountWei)
|
|
155
|
+
});
|
|
156
|
+
logger.info(`Payment sent, waiting for confirmation...`, { txHash: tx.hash });
|
|
157
|
+
const receipt = await tx.wait();
|
|
158
|
+
if (receipt.status !== 1) {
|
|
159
|
+
throw new Error(`Payment transaction failed: ${tx.hash}`);
|
|
160
|
+
}
|
|
161
|
+
logger.info(`Payment confirmed`, { txHash: tx.hash });
|
|
162
|
+
return tx.hash;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Sign a message with the wallet's private key
|
|
166
|
+
* @param message Message to sign
|
|
167
|
+
* @returns Signature hex string
|
|
168
|
+
*/
|
|
169
|
+
async signMessage(message) {
|
|
170
|
+
await this.ensureWallet();
|
|
171
|
+
return this.wallet.signMessage(message);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get wallet balance in wei
|
|
175
|
+
* @returns Balance as string (wei)
|
|
176
|
+
*/
|
|
177
|
+
async getBalance() {
|
|
178
|
+
await this.ensureProvider();
|
|
179
|
+
const balance = await this.provider.getBalance(this.wallet.address);
|
|
180
|
+
return balance.toString();
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get formatted balance (in ETH/MON)
|
|
184
|
+
*/
|
|
185
|
+
async getFormattedBalance() {
|
|
186
|
+
await this.ensureProvider();
|
|
187
|
+
const ethers = await this.loadEthers();
|
|
188
|
+
const balance = await this.provider.getBalance(this.wallet.address);
|
|
189
|
+
return ethers.formatEther(balance);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export {
|
|
194
|
+
createLogger,
|
|
195
|
+
AgentWallet
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=chunk-K2UFQ7YF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/logger.ts","../src/wallet/AgentWallet.ts"],"sourcesContent":["import winston from 'winston';\n\nconst logLevel = process.env.LOG_LEVEL || 'info';\n\n// ANSI color codes\nconst colors = {\n reset: '\\x1b[0m',\n dim: '\\x1b[2m',\n bold: '\\x1b[1m',\n cyan: '\\x1b[36m',\n yellow: '\\x1b[33m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n magenta: '\\x1b[35m',\n blue: '\\x1b[34m',\n white: '\\x1b[37m',\n gray: '\\x1b[90m',\n};\n\nconst levelColors: Record<string, string> = {\n error: colors.red,\n warn: colors.yellow,\n info: colors.green,\n debug: colors.gray,\n};\n\nexport function createLogger(label: string): winston.Logger {\n return winston.createLogger({\n level: logLevel,\n format: winston.format.combine(\n winston.format.timestamp({ format: 'HH:mm:ss' }),\n winston.format.label({ label }),\n winston.format.printf(({ timestamp, level, label, message, ...meta }) => {\n const lvlColor = levelColors[level] || colors.white;\n const lvl = `${lvlColor}${level.toUpperCase().padEnd(5)}${colors.reset}`;\n const mod = `${colors.magenta}[${label}]${colors.reset}`;\n const ts = `${colors.dim}${timestamp}${colors.reset}`;\n const metaStr = Object.keys(meta).length > 0\n ? ` ${colors.dim}${JSON.stringify(meta)}${colors.reset}`\n : '';\n return `${ts} ${lvl} ${mod} ${message}${metaStr}`;\n }),\n ),\n transports: [new winston.transports.Console()],\n });\n}\n","import { createLogger } from '../logger.js';\n\nconst logger = createLogger('AgentWallet');\n\n/**\n * Lightweight wallet for agents to sign transactions and pay entry fees.\n * Uses ethers.js as an optional peer dependency — lazy-imported only when needed.\n */\nexport class AgentWallet {\n private ethers: any;\n private wallet: any; // ethers.Wallet\n private provider: any; // ethers.JsonRpcProvider\n private _address: string | null = null;\n\n constructor(private privateKey: string, rpcUrl?: string) {\n if (!privateKey.startsWith('0x')) {\n this.privateKey = `0x${privateKey}`;\n }\n\n if (rpcUrl) {\n this.connect(rpcUrl);\n }\n }\n\n /**\n * Lazy-load ethers.js (optional peer dependency)\n */\n private async loadEthers(): Promise<any> {\n if (this.ethers) return this.ethers;\n\n try {\n this.ethers = await import('ethers');\n return this.ethers;\n } catch {\n throw new Error(\n 'ethers.js is required for wallet operations. Install it: npm install ethers'\n );\n }\n }\n\n /**\n * Ensure wallet is initialized\n */\n private async ensureWallet(): Promise<void> {\n if (this.wallet) return;\n\n const ethers = await this.loadEthers();\n\n if (this.provider) {\n this.wallet = new ethers.Wallet(this.privateKey, this.provider);\n } else {\n this.wallet = new ethers.Wallet(this.privateKey);\n }\n\n this._address = this.wallet.address;\n }\n\n /**\n * Connect to a blockchain RPC endpoint\n */\n connect(rpcUrl: string): void {\n // Synchronous setup — provider and wallet created lazily\n this._rpcUrl = rpcUrl;\n // Reset so next ensureWallet recreates with provider\n this.wallet = null;\n this.provider = null;\n }\n\n private _rpcUrl?: string;\n\n /**\n * Ensure provider is connected\n */\n private async ensureProvider(): Promise<void> {\n if (this.provider) return;\n\n if (!this._rpcUrl) {\n throw new Error('No RPC URL configured. Call connect(rpcUrl) first.');\n }\n\n const ethers = await this.loadEthers();\n this.provider = new ethers.JsonRpcProvider(this._rpcUrl);\n // Recreate wallet with provider\n this.wallet = new ethers.Wallet(this.privateKey, this.provider);\n this._address = this.wallet.address;\n }\n\n /**\n * Get the wallet address derived from the private key.\n * This is synchronous if ethers is already loaded, otherwise async.\n */\n getAddress(): string {\n if (this._address) return this._address;\n\n // Synchronous derivation using ethers.computeAddress\n // We need to load ethers first\n try {\n // Try synchronous require for address derivation\n const ethers = require('ethers');\n const addr: string = ethers.computeAddress(this.privateKey);\n this._address = addr;\n return addr;\n } catch {\n throw new Error(\n 'ethers.js is required for wallet operations. Install it: npm install ethers'\n );\n }\n }\n\n /**\n * Get wallet address (async version — always works)\n */\n async getAddressAsync(): Promise<string> {\n if (this._address) return this._address;\n\n const ethers = await this.loadEthers();\n const addr: string = ethers.computeAddress(this.privateKey);\n this._address = addr;\n return addr;\n }\n\n /**\n * Send native tokens (MON/ETH) to an address\n * @param to Recipient address\n * @param amountWei Amount in wei (string)\n * @returns Transaction hash\n */\n async sendPayment(to: string, amountWei: string): Promise<string> {\n await this.ensureProvider();\n\n logger.info(`Sending payment: ${amountWei} wei to ${to}`);\n\n const tx = await this.wallet.sendTransaction({\n to,\n value: BigInt(amountWei),\n });\n\n logger.info(`Payment sent, waiting for confirmation...`, { txHash: tx.hash });\n\n const receipt = await tx.wait();\n\n if (receipt.status !== 1) {\n throw new Error(`Payment transaction failed: ${tx.hash}`);\n }\n\n logger.info(`Payment confirmed`, { txHash: tx.hash });\n return tx.hash;\n }\n\n /**\n * Sign a message with the wallet's private key\n * @param message Message to sign\n * @returns Signature hex string\n */\n async signMessage(message: string): Promise<string> {\n await this.ensureWallet();\n return this.wallet.signMessage(message);\n }\n\n /**\n * Get wallet balance in wei\n * @returns Balance as string (wei)\n */\n async getBalance(): Promise<string> {\n await this.ensureProvider();\n const balance = await this.provider.getBalance(this.wallet.address);\n return balance.toString();\n }\n\n /**\n * Get formatted balance (in ETH/MON)\n */\n async getFormattedBalance(): Promise<string> {\n await this.ensureProvider();\n const ethers = await this.loadEthers();\n const balance = await this.provider.getBalance(this.wallet.address);\n return ethers.formatEther(balance);\n }\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,aAAa;AAEpB,IAAM,WAAW,QAAQ,IAAI,aAAa;AAG1C,IAAM,SAAS;AAAA,EACb,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AAAA,EACL,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;AAEA,IAAM,cAAsC;AAAA,EAC1C,OAAO,OAAO;AAAA,EACd,MAAM,OAAO;AAAA,EACb,MAAM,OAAO;AAAA,EACb,OAAO,OAAO;AAChB;AAEO,SAAS,aAAa,OAA+B;AAC1D,SAAO,QAAQ,aAAa;AAAA,IAC1B,OAAO;AAAA,IACP,QAAQ,QAAQ,OAAO;AAAA,MACrB,QAAQ,OAAO,UAAU,EAAE,QAAQ,WAAW,CAAC;AAAA,MAC/C,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC;AAAA,MAC9B,QAAQ,OAAO,OAAO,CAAC,EAAE,WAAW,OAAO,OAAAA,QAAO,SAAS,GAAG,KAAK,MAAM;AACvE,cAAM,WAAW,YAAY,KAAK,KAAK,OAAO;AAC9C,cAAM,MAAM,GAAG,QAAQ,GAAG,MAAM,YAAY,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,KAAK;AACtE,cAAM,MAAM,GAAG,OAAO,OAAO,IAAIA,MAAK,IAAI,OAAO,KAAK;AACtD,cAAM,KAAK,GAAG,OAAO,GAAG,GAAG,SAAS,GAAG,OAAO,KAAK;AACnD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AQ,WAAW,GAAG;AACxB,YAAM,IAAI,MAAM,+BAA+B,GAAG,IAAI,EAAE;AAAA,IAC1D;AAEA,WAAO,KAAK,qBAAqB,EAAE,QAAQ,GAAG,KAAK,CAAC;AACpD,WAAO,GAAG;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,YAAY,SAAkC;AAClD,UAAM,KAAK,aAAa;AACxB,WAAO,KAAK,OAAO,YAAY,OAAO;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,aAA8B;AAClC,UAAM,KAAK,eAAe;AAC1B,UAAM,UAAU,MAAM,KAAK,SAAS,WAAW,KAAK,OAAO,OAAO;AAClE,WAAO,QAAQ,SAAS;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,sBAAuC;AAC3C,UAAM,KAAK,eAAe;AAC1B,UAAM,SAAS,MAAM,KAAK,WAAW;AACrC,UAAM,UAAU,MAAM,KAAK,SAAS,WAAW,KAAK,OAAO,OAAO;AAClE,WAAO,OAAO,YAAY,OAAO;AAAA,EACnC;AACF;","names":["label"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -137,8 +137,10 @@ interface AgentConfig {
|
|
|
137
137
|
world?: {
|
|
138
138
|
/** URL of the world to join */
|
|
139
139
|
url: string;
|
|
140
|
-
/** Wallet address for blockchain-enabled worlds */
|
|
140
|
+
/** Wallet address for blockchain-enabled worlds (derived from privateKey if not set) */
|
|
141
141
|
walletAddress?: string;
|
|
142
|
+
/** Private key for signing transactions and paying entry fees (hex with 0x prefix) */
|
|
143
|
+
privateKey?: string;
|
|
142
144
|
/** Auto-join the world when agent starts (default: true) */
|
|
143
145
|
autoJoin?: boolean;
|
|
144
146
|
};
|
|
@@ -788,7 +790,8 @@ declare const moltbookActions: Action[];
|
|
|
788
790
|
* @moltium/world-core. These use plain HTTP to call the world's REST endpoints.
|
|
789
791
|
*/
|
|
790
792
|
/**
|
|
791
|
-
* Creates a join_world action that
|
|
793
|
+
* Creates a join_world action that queries join requirements, pays entry fee
|
|
794
|
+
* if needed, and POSTs to a world's /world/join endpoint.
|
|
792
795
|
*/
|
|
793
796
|
declare function createJoinWorldAction(config?: {
|
|
794
797
|
defaultWorldUrl?: string;
|
|
@@ -1075,6 +1078,67 @@ declare function startServer(agent: Agent, options?: ServerOptions): Promise<voi
|
|
|
1075
1078
|
|
|
1076
1079
|
declare function createRoutes(agent: Agent): Router;
|
|
1077
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Lightweight wallet for agents to sign transactions and pay entry fees.
|
|
1083
|
+
* Uses ethers.js as an optional peer dependency — lazy-imported only when needed.
|
|
1084
|
+
*/
|
|
1085
|
+
declare class AgentWallet {
|
|
1086
|
+
private privateKey;
|
|
1087
|
+
private ethers;
|
|
1088
|
+
private wallet;
|
|
1089
|
+
private provider;
|
|
1090
|
+
private _address;
|
|
1091
|
+
constructor(privateKey: string, rpcUrl?: string);
|
|
1092
|
+
/**
|
|
1093
|
+
* Lazy-load ethers.js (optional peer dependency)
|
|
1094
|
+
*/
|
|
1095
|
+
private loadEthers;
|
|
1096
|
+
/**
|
|
1097
|
+
* Ensure wallet is initialized
|
|
1098
|
+
*/
|
|
1099
|
+
private ensureWallet;
|
|
1100
|
+
/**
|
|
1101
|
+
* Connect to a blockchain RPC endpoint
|
|
1102
|
+
*/
|
|
1103
|
+
connect(rpcUrl: string): void;
|
|
1104
|
+
private _rpcUrl?;
|
|
1105
|
+
/**
|
|
1106
|
+
* Ensure provider is connected
|
|
1107
|
+
*/
|
|
1108
|
+
private ensureProvider;
|
|
1109
|
+
/**
|
|
1110
|
+
* Get the wallet address derived from the private key.
|
|
1111
|
+
* This is synchronous if ethers is already loaded, otherwise async.
|
|
1112
|
+
*/
|
|
1113
|
+
getAddress(): string;
|
|
1114
|
+
/**
|
|
1115
|
+
* Get wallet address (async version — always works)
|
|
1116
|
+
*/
|
|
1117
|
+
getAddressAsync(): Promise<string>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Send native tokens (MON/ETH) to an address
|
|
1120
|
+
* @param to Recipient address
|
|
1121
|
+
* @param amountWei Amount in wei (string)
|
|
1122
|
+
* @returns Transaction hash
|
|
1123
|
+
*/
|
|
1124
|
+
sendPayment(to: string, amountWei: string): Promise<string>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Sign a message with the wallet's private key
|
|
1127
|
+
* @param message Message to sign
|
|
1128
|
+
* @returns Signature hex string
|
|
1129
|
+
*/
|
|
1130
|
+
signMessage(message: string): Promise<string>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Get wallet balance in wei
|
|
1133
|
+
* @returns Balance as string (wei)
|
|
1134
|
+
*/
|
|
1135
|
+
getBalance(): Promise<string>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Get formatted balance (in ETH/MON)
|
|
1138
|
+
*/
|
|
1139
|
+
getFormattedBalance(): Promise<string>;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1078
1142
|
declare function createLogger(label: string): winston.Logger;
|
|
1079
1143
|
|
|
1080
|
-
export { A2AClient, type A2AClientConfig, type A2AConfig, A2AIntegration, type A2AMessageOptions, type A2AMessageResponse, type A2AServerOptions, type Action, type ActionContext, ActionHandler, ActionRegistry, type ActionResult, Agent, AgentCardBuilder, type AgentConfig, type AgentState, AnthropicProvider, type BehaviorTrigger, type Comment, ConfigLoader, type ConfigType, type Conversation, type ConversationDetail, type CustomAPIConfig, type CustomCLIConfig, type CustomDeploymentConfig, type CustomDockerConfig, type CustomSSHConfig, type DMCheckResult, type DMRequest, type Decision, type DeploymentConfig, type DeploymentResult, type DeploymentStatus, type DirectMessage, type Experience, type FeedOptions, type GenerateOptions, LLMProvider, type LifecycleEvent, type LifecycleHooks, LongTermMemory, MarkdownParser, Memory, type Mention, type Message, MoltbookAdapter, type MoltbookConfig, type MoltbookRegistration, type MoltbookStatus, MoltiumExecutor, OpenAIProvider, type Plugin, type Post, type PostResult, type PostgresConfig, type Profile, type RedisConfig, type ReplyResult, type ScheduledJob, type ScheduledTask, Scheduler, type SearchOptions, type SearchResult, type ServerOptions, ShortTermMemory, SocialAdapter, type SocialConfig, type SocialPlatformConfig, type StructuredSchema, type Submolt, type SubmoltSettings, type TimelineOptions, TwitterAdapter, type TwitterConfig, buildDecisionPrompt, buildSkillPrompt, buildSystemPrompt, builtInActions, createA2AClient, createA2AIntegration, createApp, createJoinWorldAction, createLeaveWorldAction, createLogger, createMarkdownAction, createQueryWorldAction, createRoutes, createSendWorldMessageAction, moltbookActions, startServer, validateConfig, worldActions };
|
|
1144
|
+
export { A2AClient, type A2AClientConfig, type A2AConfig, A2AIntegration, type A2AMessageOptions, type A2AMessageResponse, type A2AServerOptions, type Action, type ActionContext, ActionHandler, ActionRegistry, type ActionResult, Agent, AgentCardBuilder, type AgentConfig, type AgentState, AgentWallet, AnthropicProvider, type BehaviorTrigger, type Comment, ConfigLoader, type ConfigType, type Conversation, type ConversationDetail, type CustomAPIConfig, type CustomCLIConfig, type CustomDeploymentConfig, type CustomDockerConfig, type CustomSSHConfig, type DMCheckResult, type DMRequest, type Decision, type DeploymentConfig, type DeploymentResult, type DeploymentStatus, type DirectMessage, type Experience, type FeedOptions, type GenerateOptions, LLMProvider, type LifecycleEvent, type LifecycleHooks, LongTermMemory, MarkdownParser, Memory, type Mention, type Message, MoltbookAdapter, type MoltbookConfig, type MoltbookRegistration, type MoltbookStatus, MoltiumExecutor, OpenAIProvider, type Plugin, type Post, type PostResult, type PostgresConfig, type Profile, type RedisConfig, type ReplyResult, type ScheduledJob, type ScheduledTask, Scheduler, type SearchOptions, type SearchResult, type ServerOptions, ShortTermMemory, SocialAdapter, type SocialConfig, type SocialPlatformConfig, type StructuredSchema, type Submolt, type SubmoltSettings, type TimelineOptions, TwitterAdapter, type TwitterConfig, buildDecisionPrompt, buildSkillPrompt, buildSystemPrompt, builtInActions, createA2AClient, createA2AIntegration, createApp, createJoinWorldAction, createLeaveWorldAction, createLogger, createMarkdownAction, createQueryWorldAction, createRoutes, createSendWorldMessageAction, moltbookActions, startServer, validateConfig, worldActions };
|
package/dist/index.d.ts
CHANGED
|
@@ -137,8 +137,10 @@ interface AgentConfig {
|
|
|
137
137
|
world?: {
|
|
138
138
|
/** URL of the world to join */
|
|
139
139
|
url: string;
|
|
140
|
-
/** Wallet address for blockchain-enabled worlds */
|
|
140
|
+
/** Wallet address for blockchain-enabled worlds (derived from privateKey if not set) */
|
|
141
141
|
walletAddress?: string;
|
|
142
|
+
/** Private key for signing transactions and paying entry fees (hex with 0x prefix) */
|
|
143
|
+
privateKey?: string;
|
|
142
144
|
/** Auto-join the world when agent starts (default: true) */
|
|
143
145
|
autoJoin?: boolean;
|
|
144
146
|
};
|
|
@@ -788,7 +790,8 @@ declare const moltbookActions: Action[];
|
|
|
788
790
|
* @moltium/world-core. These use plain HTTP to call the world's REST endpoints.
|
|
789
791
|
*/
|
|
790
792
|
/**
|
|
791
|
-
* Creates a join_world action that
|
|
793
|
+
* Creates a join_world action that queries join requirements, pays entry fee
|
|
794
|
+
* if needed, and POSTs to a world's /world/join endpoint.
|
|
792
795
|
*/
|
|
793
796
|
declare function createJoinWorldAction(config?: {
|
|
794
797
|
defaultWorldUrl?: string;
|
|
@@ -1075,6 +1078,67 @@ declare function startServer(agent: Agent, options?: ServerOptions): Promise<voi
|
|
|
1075
1078
|
|
|
1076
1079
|
declare function createRoutes(agent: Agent): Router;
|
|
1077
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Lightweight wallet for agents to sign transactions and pay entry fees.
|
|
1083
|
+
* Uses ethers.js as an optional peer dependency — lazy-imported only when needed.
|
|
1084
|
+
*/
|
|
1085
|
+
declare class AgentWallet {
|
|
1086
|
+
private privateKey;
|
|
1087
|
+
private ethers;
|
|
1088
|
+
private wallet;
|
|
1089
|
+
private provider;
|
|
1090
|
+
private _address;
|
|
1091
|
+
constructor(privateKey: string, rpcUrl?: string);
|
|
1092
|
+
/**
|
|
1093
|
+
* Lazy-load ethers.js (optional peer dependency)
|
|
1094
|
+
*/
|
|
1095
|
+
private loadEthers;
|
|
1096
|
+
/**
|
|
1097
|
+
* Ensure wallet is initialized
|
|
1098
|
+
*/
|
|
1099
|
+
private ensureWallet;
|
|
1100
|
+
/**
|
|
1101
|
+
* Connect to a blockchain RPC endpoint
|
|
1102
|
+
*/
|
|
1103
|
+
connect(rpcUrl: string): void;
|
|
1104
|
+
private _rpcUrl?;
|
|
1105
|
+
/**
|
|
1106
|
+
* Ensure provider is connected
|
|
1107
|
+
*/
|
|
1108
|
+
private ensureProvider;
|
|
1109
|
+
/**
|
|
1110
|
+
* Get the wallet address derived from the private key.
|
|
1111
|
+
* This is synchronous if ethers is already loaded, otherwise async.
|
|
1112
|
+
*/
|
|
1113
|
+
getAddress(): string;
|
|
1114
|
+
/**
|
|
1115
|
+
* Get wallet address (async version — always works)
|
|
1116
|
+
*/
|
|
1117
|
+
getAddressAsync(): Promise<string>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Send native tokens (MON/ETH) to an address
|
|
1120
|
+
* @param to Recipient address
|
|
1121
|
+
* @param amountWei Amount in wei (string)
|
|
1122
|
+
* @returns Transaction hash
|
|
1123
|
+
*/
|
|
1124
|
+
sendPayment(to: string, amountWei: string): Promise<string>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Sign a message with the wallet's private key
|
|
1127
|
+
* @param message Message to sign
|
|
1128
|
+
* @returns Signature hex string
|
|
1129
|
+
*/
|
|
1130
|
+
signMessage(message: string): Promise<string>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Get wallet balance in wei
|
|
1133
|
+
* @returns Balance as string (wei)
|
|
1134
|
+
*/
|
|
1135
|
+
getBalance(): Promise<string>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Get formatted balance (in ETH/MON)
|
|
1138
|
+
*/
|
|
1139
|
+
getFormattedBalance(): Promise<string>;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1078
1142
|
declare function createLogger(label: string): winston.Logger;
|
|
1079
1143
|
|
|
1080
|
-
export { A2AClient, type A2AClientConfig, type A2AConfig, A2AIntegration, type A2AMessageOptions, type A2AMessageResponse, type A2AServerOptions, type Action, type ActionContext, ActionHandler, ActionRegistry, type ActionResult, Agent, AgentCardBuilder, type AgentConfig, type AgentState, AnthropicProvider, type BehaviorTrigger, type Comment, ConfigLoader, type ConfigType, type Conversation, type ConversationDetail, type CustomAPIConfig, type CustomCLIConfig, type CustomDeploymentConfig, type CustomDockerConfig, type CustomSSHConfig, type DMCheckResult, type DMRequest, type Decision, type DeploymentConfig, type DeploymentResult, type DeploymentStatus, type DirectMessage, type Experience, type FeedOptions, type GenerateOptions, LLMProvider, type LifecycleEvent, type LifecycleHooks, LongTermMemory, MarkdownParser, Memory, type Mention, type Message, MoltbookAdapter, type MoltbookConfig, type MoltbookRegistration, type MoltbookStatus, MoltiumExecutor, OpenAIProvider, type Plugin, type Post, type PostResult, type PostgresConfig, type Profile, type RedisConfig, type ReplyResult, type ScheduledJob, type ScheduledTask, Scheduler, type SearchOptions, type SearchResult, type ServerOptions, ShortTermMemory, SocialAdapter, type SocialConfig, type SocialPlatformConfig, type StructuredSchema, type Submolt, type SubmoltSettings, type TimelineOptions, TwitterAdapter, type TwitterConfig, buildDecisionPrompt, buildSkillPrompt, buildSystemPrompt, builtInActions, createA2AClient, createA2AIntegration, createApp, createJoinWorldAction, createLeaveWorldAction, createLogger, createMarkdownAction, createQueryWorldAction, createRoutes, createSendWorldMessageAction, moltbookActions, startServer, validateConfig, worldActions };
|
|
1144
|
+
export { A2AClient, type A2AClientConfig, type A2AConfig, A2AIntegration, type A2AMessageOptions, type A2AMessageResponse, type A2AServerOptions, type Action, type ActionContext, ActionHandler, ActionRegistry, type ActionResult, Agent, AgentCardBuilder, type AgentConfig, type AgentState, AgentWallet, AnthropicProvider, type BehaviorTrigger, type Comment, ConfigLoader, type ConfigType, type Conversation, type ConversationDetail, type CustomAPIConfig, type CustomCLIConfig, type CustomDeploymentConfig, type CustomDockerConfig, type CustomSSHConfig, type DMCheckResult, type DMRequest, type Decision, type DeploymentConfig, type DeploymentResult, type DeploymentStatus, type DirectMessage, type Experience, type FeedOptions, type GenerateOptions, LLMProvider, type LifecycleEvent, type LifecycleHooks, LongTermMemory, MarkdownParser, Memory, type Mention, type Message, MoltbookAdapter, type MoltbookConfig, type MoltbookRegistration, type MoltbookStatus, MoltiumExecutor, OpenAIProvider, type Plugin, type Post, type PostResult, type PostgresConfig, type Profile, type RedisConfig, type ReplyResult, type ScheduledJob, type ScheduledTask, Scheduler, type SearchOptions, type SearchResult, type ServerOptions, ShortTermMemory, SocialAdapter, type SocialConfig, type SocialPlatformConfig, type StructuredSchema, type Submolt, type SubmoltSettings, type TimelineOptions, TwitterAdapter, type TwitterConfig, buildDecisionPrompt, buildSkillPrompt, buildSystemPrompt, builtInActions, createA2AClient, createA2AIntegration, createApp, createJoinWorldAction, createLeaveWorldAction, createLogger, createMarkdownAction, createQueryWorldAction, createRoutes, createSendWorldMessageAction, moltbookActions, startServer, validateConfig, worldActions };
|