@agether/openclaw-plugin 1.5.0 → 1.5.1
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 +7 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -62,11 +62,15 @@ async function getBackendStatus(cfg: PluginConfig) {
|
|
|
62
62
|
return data;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// Module-level cache: survives across tool calls within the same process
|
|
66
|
+
let cachedAgentId: string | undefined;
|
|
67
|
+
|
|
65
68
|
function createClient(cfg: PluginConfig, status: any): MorphoCreditClient {
|
|
69
|
+
const agentId = cachedAgentId || cfg.agentId;
|
|
66
70
|
return new MorphoCreditClient({
|
|
67
71
|
privateKey: cfg.privateKey,
|
|
68
72
|
rpcUrl: cfg.rpcUrl,
|
|
69
|
-
agentId
|
|
73
|
+
agentId,
|
|
70
74
|
contracts: {
|
|
71
75
|
morphoCredit: status.contracts.morphoCredit,
|
|
72
76
|
accountFactory: status.contracts.accountFactory,
|
|
@@ -118,6 +122,8 @@ export default function register(api: any) {
|
|
|
118
122
|
const status = await getBackendStatus(cfg);
|
|
119
123
|
const client = createClient(cfg, status);
|
|
120
124
|
const result = await client.register(params.name);
|
|
125
|
+
// Cache agentId for subsequent tool calls
|
|
126
|
+
cachedAgentId = result.agentId;
|
|
121
127
|
return ok(JSON.stringify({
|
|
122
128
|
status: result.alreadyRegistered ? "already_registered" : "registered",
|
|
123
129
|
agentId: result.agentId,
|