From 4dbaa500d42bac91ade4a6c7852c7e87c2c800af Mon Sep 17 00:00:00 2001 From: Zheng Chen Date: Mon, 30 Oct 2023 23:26:04 +0800 Subject: [PATCH] fix(agent): crush on real mode account publishing (#202) --- common/changes/@yuants/agent/2023-10-30-15-20.json | 10 ++++++++++ libraries/agent/src/AgentScene.ts | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 common/changes/@yuants/agent/2023-10-30-15-20.json diff --git a/common/changes/@yuants/agent/2023-10-30-15-20.json b/common/changes/@yuants/agent/2023-10-30-15-20.json new file mode 100644 index 00000000..3a7ba803 --- /dev/null +++ b/common/changes/@yuants/agent/2023-10-30-15-20.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/agent", + "comment": "crush on real mode account publishing", + "type": "patch" + } + ], + "packageName": "@yuants/agent" +} \ No newline at end of file diff --git a/libraries/agent/src/AgentScene.ts b/libraries/agent/src/AgentScene.ts index 9434f0d4..8365f626 100644 --- a/libraries/agent/src/AgentScene.ts +++ b/libraries/agent/src/AgentScene.ts @@ -194,12 +194,12 @@ export const AgentScene = async (terminal: Terminal, agentConf: IAgentConf) => { if (agentConf.publish_account) { const unit = new BasicUnit(kernel); const mapAccountIdToAccountInfo$: Record> = {}; - accountInfoUnit.mapAccountIdToAccountInfo.forEach((accountInfo) => { - const accountInfo$ = (mapAccountIdToAccountInfo$[accountInfo.account_id] = new Subject()); - terminal.provideAccountInfo(accountInfo$); - }); unit.onIdle = () => { for (const accountInfo of accountInfoUnit.mapAccountIdToAccountInfo.values()) { + if (!mapAccountIdToAccountInfo$[accountInfo.account_id]) { + mapAccountIdToAccountInfo$[accountInfo.account_id] = new Subject(); + terminal.provideAccountInfo(mapAccountIdToAccountInfo$[accountInfo.account_id]); + } const accountInfo$ = mapAccountIdToAccountInfo$[accountInfo.account_id]; accountInfo$.next(accountInfo); }