From 3f383ded6bfb3cf5df06b523a9f9772d83abade1 Mon Sep 17 00:00:00 2001 From: Evander Date: Tue, 1 Dec 2026 00:51:20 -0500 Subject: [PATCH] =?UTF-8?q?fix(minimax-bot):=20=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=A0=E9=99=A4=E5=86=99=E7=9B=98=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=E6=81=A2=E5=A4=8D=E5=8E=9F=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minimax-bot/.minimax-plugin/plugin.json | 2 +- plugins/minimax-ai/minimax-bot/README.md | 6 ++ .../minimax-bot/miniapp/node/mcp.mjs | 2 +- .../minimax-bot/miniapp/node/team.mjs | 22 ++++++- plugins/minimax-ai/minimax-bot/package.json | 2 +- .../tests/storage-reliability.test.mjs | 60 ++++++++++++++++++- 6 files changed, 87 insertions(+), 7 deletions(-) diff --git a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json index 370cee81..6fc01b30 100644 --- a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json +++ b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "name": "minimax-bot", "displayName": "MiniMax Bot", - "version": "0.7.40", + "version": "0.7.45", "description": "Turn MiniMax Code into an always-on team of Bots. A Chief Bot helps you build the team; in group chats the admin answers and @mentions hand work to other members. Every Bot has its own octopus avatar and memory, with scheduled tasks and usage stats.", "author": "MiniMax Code", "icon": "icon.png", diff --git a/plugins/minimax-ai/minimax-bot/README.md b/plugins/minimax-ai/minimax-bot/README.md index 651f680a..38719c27 100644 --- a/plugins/minimax-ai/minimax-bot/README.md +++ b/plugins/minimax-ai/minimax-bot/README.md @@ -161,6 +161,12 @@ The hand-over between two Bots of a group carried the tail of the previous reply - `` reached the next Bot whole: the closing tag of the block the plugin writes around the context. The words around it were kept, as they are for every other spelling. - The text is now walked by code point, so a character outside the Basic Multilingual Plane is read as the one character it is. The tag characters are named as well, because some of the slots in that block are not assigned in every Unicode version and are therefore not caught by the general categories. +## 0.7.45 A refused schedule delete leaves the schedule where it was + +- Deleting a scheduled task removed it from memory before the write. If the write failed, the caller saw the failure, but the schedule was already gone from memory; the next unrelated save then wrote that absence to disk, and the task disappeared for good. +- The delete now puts back only the schedule it removed when the write fails. It does not restore the old array, so another change made while the write was in flight is kept. The state is broadcast again after the rollback, and a later save or restart still finds the schedule. +- The successful path is unchanged: the schedule is removed, the write lands, and the page hears the change. + ## 0.7.40 A value that is not there is left out, not refused - The reply mode of a group and the kind of a scheduled task are checked against the values the catalogue offers, so a value that is not one of them is refused instead of quietly becoming another one. A value that is not there at all was refused too, when it arrived as null: many models write an optional field they did not fill in as null, and the call failed with "reply_mode must be one of: admin, all". diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs index a6473f79..f550e284 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs @@ -662,7 +662,7 @@ export function createMcpHandler({ team, engine }) { result = { protocolVersion: PROTOCOL_VERSIONS.includes(requested) ? requested : PROTOCOL_VERSIONS[0], capabilities: { tools: { listChanged: false } }, - serverInfo: { name: 'minimax-bot', version: '0.7.40' }, + serverInfo: { name: 'minimax-bot', version: '0.7.45' }, instructions: t('mcp.instructions'), }; break; diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/team.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/team.mjs index 7869b822..74348cb1 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/team.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/team.mjs @@ -681,9 +681,25 @@ export class Team { } async deleteSchedule(id) { - this.store.state.schedules = this.store.state.schedules.filter((s) => s.id !== id); - await this.store.save(); - this.changed(); + const list = this.store.state.schedules; + const index = list.findIndex((schedule) => schedule.id === id); + if (index < 0) return; + const schedule = list[index]; + this.store.state.schedules = list.filter((item) => item.id !== id); + try { + await this.store.save(); + } catch (error) { + // The user was told the delete failed, so the schedule has to still be there. Put back + // only this schedule: another caller may have changed the list while the write was in + // flight, and restoring the old array would throw that change away. + const current = this.store.state.schedules; + if (!current.some((item) => item.id === id)) { + current.splice(Math.min(index, current.length), 0, schedule); + } + throw error; + } finally { + this.changed(); + } } // ---------------------------------------------------------------- read models diff --git a/plugins/minimax-ai/minimax-bot/package.json b/plugins/minimax-ai/minimax-bot/package.json index e799ef2e..d273d38a 100644 --- a/plugins/minimax-ai/minimax-bot/package.json +++ b/plugins/minimax-ai/minimax-bot/package.json @@ -1,6 +1,6 @@ { "name": "minimax-bot", - "version": "0.7.40", + "version": "0.7.45", "private": true, "type": "module", "mcode": { diff --git a/plugins/minimax-ai/minimax-bot/tests/storage-reliability.test.mjs b/plugins/minimax-ai/minimax-bot/tests/storage-reliability.test.mjs index cd06ac84..90aa2964 100644 --- a/plugins/minimax-ai/minimax-bot/tests/storage-reliability.test.mjs +++ b/plugins/minimax-ai/minimax-bot/tests/storage-reliability.test.mjs @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { test } from 'node:test'; -import { appendFile, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; +import { appendFile, mkdir, mkdtemp, readFile, rename, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { Store } from '../miniapp/node/store.mjs'; @@ -171,6 +171,64 @@ test('a schedule update that cannot be saved keeps the values the user was shown const current = store.state.schedules.find((item) => item.id === schedule.id); assert.equal(current.prompt, 'Original prompt'); }); + +test('a schedule delete that cannot be saved keeps the schedule in memory and on disk', async (t) => { + const { dir, store } = await fixture(t); + const { Team } = await import('../miniapp/node/team.mjs'); + const team = new Team({ store, memory: undefined, engine: { cancelBot() {}, cancelChat() {} }, broadcast() {} }); + const bot = store.state.bots[0]; + const schedule = await team.saveSchedule({ botId: bot.id, prompt: 'Keep me', kind: 'daily', time: '09:00' }); + await store.writeChain; + + const statePath = join(dir, 'state.json'); + const savedPath = join(dir, 'state.saved.json'); + await rename(statePath, savedPath); + await mkdir(statePath); // real EISDIR at rename(tmp, statePath) + await assert.rejects(team.deleteSchedule(schedule.id)); + + // The delete was refused, so the schedule must still be in memory and in the copy that is + // still on disk. A later unrelated save must not publish the refused delete. + assert.equal(store.state.schedules.some((item) => item.id === schedule.id), true); + const onDisk = JSON.parse(await readFile(savedPath, 'utf8')); + assert.equal(onDisk.schedules.some((item) => item.id === schedule.id), true); + + await rm(statePath, { recursive: true }); + await rename(savedPath, statePath); + await store.save(); + const reloaded = new Store(dir); + await reloaded.init(); + assert.equal(reloaded.state.schedules.some((item) => item.id === schedule.id), true); +}); + +test('a refused schedule delete does not undo another change made while the save was in flight', async (t) => { + const { store } = await fixture(t); + const { Team } = await import('../miniapp/node/team.mjs'); + const team = new Team({ store, memory: undefined, engine: { cancelBot() {}, cancelChat() {} }, broadcast() {} }); + const bot = store.state.bots[0]; + const schedule = await team.saveSchedule({ botId: bot.id, prompt: 'Delete me', kind: 'daily', time: '09:00' }); + await store.writeChain; + + const realSave = store.save.bind(store); + let rejectSave; + let saveStarted; + const started = new Promise((resolve) => { saveStarted = resolve; }); + store.save = () => { + saveStarted(); + return new Promise((resolve, reject) => { rejectSave = reject; }); + }; + const deleting = team.deleteSchedule(schedule.id); + await started; + const other = { ...schedule, id: 'sch_other', prompt: 'Added while the delete was waiting' }; + store.state.schedules.push(other); + rejectSave(Object.assign(new Error('storage unavailable'), { code: 'EIO' })); + await assert.rejects(deleting); + store.save = realSave; + + assert.equal(store.state.schedules.some((item) => item.id === schedule.id), true, + 'the refused delete is rolled back'); + assert.equal(store.state.schedules.some((item) => item.id === other.id), true, + 'the other change is kept'); +}); test('legacy sequence migration preserves text/tool order and stable cursors across restarts', async (t) => { const { dir, store, chat } = await fixture(t); const parts = [{ type: 'text', text: 'The current conclusion: ' }, { type: 'tool', name: 'build', state: 'ok' }, { type: 'text', text: 'The current conclusion: publish after the build passes.' }];