(agentId: string, durationMs: number)
| 45 | * Pause agent execution for a specified duration |
| 46 | */ |
| 47 | export function pauseAgentLoop(agentId: string, durationMs: number): void { |
| 48 | if (activeLoops[agentId]?.isRunning) { |
| 49 | activeLoops[agentId].sleepUntil = Date.now() + durationMs; |
| 50 | |
| 51 | // Dispatch sleep start event |
| 52 | Logger.info(agentId, `Agent sleeping for ${Math.round(durationMs/1000)}s`, { |
| 53 | logType: 'agent-sleep-start', |
| 54 | content: { |
| 55 | agentId, |
| 56 | durationMs |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Wake agent from sleep early |