MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / createStreamController

Function createStreamController

cli/src/hooks/stream-state.ts:33–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 * so it can be consumed by non-React helpers (event handlers, SDK callbacks).
32 */
33export const createStreamController = (): StreamController => {
34 const state: StreamState = {
35 rootStreamBuffer: '',
36 agentStreamAccumulators: new Map(),
37 rootStreamSeen: false,
38 planExtracted: false,
39 wasAbortedByUser: false,
40 spawnAgentsMap: new Map(),
41 }
42
43 const reset = () => {
44 state.rootStreamBuffer = ''
45 state.agentStreamAccumulators = new Map()
46 state.rootStreamSeen = false
47 state.planExtracted = false
48 state.wasAbortedByUser = false
49 state.spawnAgentsMap = new Map()
50 }
51
52 const setters = {
53 setRootStreamBuffer: (value: string) => {
54 state.rootStreamBuffer = value
55 },
56 appendRootStreamBuffer: (value: string) => {
57 state.rootStreamBuffer += value
58 },
59 setAgentAccumulator: (agentId: string, value: string) => {
60 state.agentStreamAccumulators.set(agentId, value)
61 },
62 removeAgentAccumulator: (agentId: string) => {
63 state.agentStreamAccumulators.delete(agentId)
64 },
65 setRootStreamSeen: (value: boolean) => {
66 state.rootStreamSeen = value
67 },
68 setPlanExtracted: (value: boolean) => {
69 state.planExtracted = value
70 },
71 setWasAbortedByUser: (value: boolean) => {
72 state.wasAbortedByUser = value
73 },
74 setSpawnAgentInfo: (agentId: string, info: SpawnAgentInfo) => {
75 state.spawnAgentsMap.set(agentId, info)
76 },
77 removeSpawnAgentInfo: (agentId: string) => {
78 state.spawnAgentsMap.delete(agentId)
79 },
80 }
81
82 return { reset, state, setters }
83}

Callers 2

useSendMessageFunction · 0.90

Calls 2

setMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected