mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 05:03:26 +00:00
refactor(coding-agent): simplify AgentSession
This commit is contained in:
parent
254c00b788
commit
f9eb190ef9
5 changed files with 33 additions and 51 deletions
18
packages/coding-agent/src/utils/sleep.ts
Normal file
18
packages/coding-agent/src/utils/sleep.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Sleep helper that respects abort signal.
|
||||
*/
|
||||
export function sleep(ms: number, signal?: AbortSignal): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (signal?.aborted) {
|
||||
reject(new Error("Aborted"));
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = setTimeout(resolve, ms);
|
||||
|
||||
signal?.addEventListener("abort", () => {
|
||||
clearTimeout(timeout);
|
||||
reject(new Error("Aborted"));
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue