feat: expose bot task progress
This commit is contained in:
@@ -95,3 +95,28 @@ test("cancel reaches hanging prompt, reset unbinds, and fingerprint changes sess
|
||||
assert.notEqual(second.text.split(":")[1], firstSession);
|
||||
await changed.manager.shutdown(); await changed.store.close();
|
||||
});
|
||||
|
||||
test("status reports initializing, processing, running time, and update activity", async () => {
|
||||
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "gori-acp-status-")); const state = path.join(dir, "state.json"); const log = path.join(dir, "fake.log");
|
||||
const current = await runtime(state, log, "test", { FAKE_ACP_BOOTSTRAP_DELAY_MS: "200" });
|
||||
const first = current.manager.prompt({ platform: "qq", chatId: "chat", userId: "user", text: "ready" });
|
||||
for (let count = 0; count < 50 && current.manager.status("qq", "chat").phase !== "initializing"; count++) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
}
|
||||
assert.deepEqual(current.manager.status("qq", "chat"), {
|
||||
bot: "test-bot", agent: "fake", workspace: path.resolve("."), persisted: false, running: true,
|
||||
phase: "initializing", runningSeconds: 0, idleSeconds: 0
|
||||
});
|
||||
await first;
|
||||
|
||||
const activity = current.manager.prompt({ platform: "qq", chatId: "chat", userId: "user", text: "activity" });
|
||||
await new Promise((resolve) => setTimeout(resolve, 1_100));
|
||||
const processing = current.manager.status("qq", "chat");
|
||||
assert.equal(processing.phase, "processing");
|
||||
assert.equal(processing.running, true);
|
||||
assert.equal(processing.runningSeconds, 1);
|
||||
assert.equal(processing.idleSeconds, 0);
|
||||
await activity;
|
||||
assert.equal(current.manager.status("qq", "chat").phase, "idle");
|
||||
await current.manager.shutdown(); await current.store.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user