test: cover complete fake agent flow

This commit is contained in:
Wenxin Duan
2026-09-08 10:35:11 +08:00
parent c4a88e4aae
commit 89ce7973c3
8 changed files with 406 additions and 2 deletions
@@ -82,8 +82,17 @@ export class HarnessSession {
eventStore: this.#eventStore,
...(skillInference === undefined ? {} : { skillInference }),
});
let eventQueue = Promise.resolve();
let eventError: unknown;
const unsubscribe = port.subscribe((event) => {
void adapter.observe(event);
eventQueue = eventQueue.then(async () => {
if (eventError !== undefined) return;
try {
await adapter.observe(event);
} catch (error) {
eventError = error;
}
});
});
const active: ActiveRun = {
runId,
@@ -108,7 +117,11 @@ export class HarnessSession {
void Promise.resolve()
.then(() => port.prompt(message.text, { images }))
.then(() => this.#complete(active))
.then(async () => {
await eventQueue;
if (eventError !== undefined) throw eventError;
this.#complete(active);
})
.catch((error: unknown) => this.#fail(active, error));
return { runId };
}