()
| 45 | } |
| 46 | |
| 47 | const createStreamRefs = (): { |
| 48 | controller: EventHandlerState['streaming']['streamRefs'] |
| 49 | state: { |
| 50 | rootStreamBuffer: string |
| 51 | agentStreamAccumulators: Map<string, string> |
| 52 | rootStreamSeen: boolean |
| 53 | planExtracted: boolean |
| 54 | wasAbortedByUser: boolean |
| 55 | spawnAgentsMap: Map<string, SpawnAgentInfo> |
| 56 | } |
| 57 | } => { |
| 58 | const state = { |
| 59 | rootStreamBuffer: '', |
| 60 | agentStreamAccumulators: new Map<string, string>(), |
| 61 | rootStreamSeen: false, |
| 62 | planExtracted: false, |
| 63 | wasAbortedByUser: false, |
| 64 | spawnAgentsMap: new Map<string, SpawnAgentInfo>(), |
| 65 | } |
| 66 | |
| 67 | const controller = { |
| 68 | state, |
| 69 | reset: () => {}, |
| 70 | setters: { |
| 71 | setRootStreamBuffer: (value: string) => { |
| 72 | state.rootStreamBuffer = value |
| 73 | }, |
| 74 | appendRootStreamBuffer: (value: string) => { |
| 75 | state.rootStreamBuffer += value |
| 76 | }, |
| 77 | setAgentAccumulator: (agentId: string, value: string) => { |
| 78 | state.agentStreamAccumulators.set(agentId, value) |
| 79 | }, |
| 80 | removeAgentAccumulator: (agentId: string) => { |
| 81 | state.agentStreamAccumulators.delete(agentId) |
| 82 | }, |
| 83 | setRootStreamSeen: (value: boolean) => { |
| 84 | state.rootStreamSeen = value |
| 85 | }, |
| 86 | setPlanExtracted: (value: boolean) => { |
| 87 | state.planExtracted = value |
| 88 | }, |
| 89 | setWasAbortedByUser: (value: boolean) => { |
| 90 | state.wasAbortedByUser = value |
| 91 | }, |
| 92 | setSpawnAgentInfo: (agentId: string, info: SpawnAgentInfo) => { |
| 93 | state.spawnAgentsMap.set(agentId, info) |
| 94 | }, |
| 95 | removeSpawnAgentInfo: (agentId: string) => { |
| 96 | state.spawnAgentsMap.delete(agentId) |
| 97 | }, |
| 98 | }, |
| 99 | } |
| 100 | |
| 101 | return { controller, state } |
| 102 | } |
| 103 | |
| 104 | const createTestContext = (agentMode: AgentMode = 'DEFAULT') => { |
no test coverage detected