Line data Source code
1 1 : let liveAgentTurn = false
2 :
3 : /** Runs `fn` with the live-Agent-turn flag set for every write it raises. */
4 0 : export function withLiveAgentTurnWrites<T>(
5 : { isLiveAgentTurn }: { isLiveAgentTurn: boolean },
6 : fn: () => T
7 : ): T {
8 0 : const previous = liveAgentTurn
9 0 : liveAgentTurn = isLiveAgentTurn
10 0 : try {
11 0 : return fn()
12 : } finally {
13 0 : liveAgentTurn = previous
14 : }
15 : }
16 :
17 : /** True while a live Agent turn's frame is being applied to the graph. */
18 0 : export function isLiveAgentTurnWrite(): boolean {
19 0 : return liveAgentTurn
20 : }
|