@agether/agether 2.6.2 → 2.6.3
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/package.json +1 -1
- package/src/index.ts +6 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -158,13 +158,15 @@ function resolvePrivateKey(): string {
|
|
|
158
158
|
|
|
159
159
|
function getConfig(api: any): PluginConfig {
|
|
160
160
|
const cfg = api.config?.plugins?.entries?.["agether"]?.config ?? {};
|
|
161
|
-
|
|
161
|
+
// chainOverride (set by agether_set_chain at runtime) takes priority over
|
|
162
|
+
// api.config which is a stale in-memory snapshot that never refreshes.
|
|
163
|
+
const rawChain = chainOverride ?? cfg.chain;
|
|
162
164
|
const chainConfigured = rawChain !== undefined && rawChain !== null && rawChain !== "";
|
|
163
165
|
const chainId = (rawChain as ChainId) || ChainId.Ethereum;
|
|
164
166
|
activeChainId = chainId; // Update module-level for txLink
|
|
165
167
|
return {
|
|
166
168
|
privateKey: resolvePrivateKey(),
|
|
167
|
-
agentId: cfg.agentId,
|
|
169
|
+
agentId: cachedAgentId || cfg.agentId,
|
|
168
170
|
rpcUrl: resolveRpcUrl(chainId),
|
|
169
171
|
chainId,
|
|
170
172
|
chainConfigured,
|
|
@@ -174,6 +176,7 @@ function getConfig(api: any): PluginConfig {
|
|
|
174
176
|
// Module-level cache
|
|
175
177
|
let cachedAgentId: string | undefined;
|
|
176
178
|
let activeChainId: ChainId = ChainId.Ethereum;
|
|
179
|
+
let chainOverride: ChainId | undefined; // set by agether_set_chain, survives stale api.config
|
|
177
180
|
|
|
178
181
|
/**
|
|
179
182
|
* Hard guardrail: refuse to proceed if chain was never explicitly configured.
|
|
@@ -225,6 +228,7 @@ function persistAgentId(agentId: string): string {
|
|
|
225
228
|
/** Persist chain to openclaw.json so it survives restarts. */
|
|
226
229
|
function persistChainId(chainId: ChainId): string {
|
|
227
230
|
activeChainId = chainId;
|
|
231
|
+
chainOverride = chainId; // In-memory override so getConfig() picks it up immediately
|
|
228
232
|
try {
|
|
229
233
|
const home = process.env.HOME || process.env.USERPROFILE || "/root";
|
|
230
234
|
const cfgPath = path.join(home, ".openclaw", "openclaw.json");
|