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

Function createTestContext

cli/src/utils/__tests__/sdk-event-handlers.test.ts:104–168  ·  view source on GitHub ↗
(agentMode: AgentMode = 'DEFAULT')

Source from the content-addressed store, hash-verified

102}
103
104const createTestContext = (agentMode: AgentMode = 'DEFAULT') => {
105 let messages: ChatMessage[] = [
106 {
107 id: 'ai-1',
108 variant: 'ai',
109 content: '',
110 blocks: [],
111 timestamp: 'now',
112 },
113 ]
114 let streamingAgents = new Set<string>()
115 let streamStatus: StreamStatus | null = null
116 let hasPlanResponse = false
117 const streamRefs = createStreamRefs()
118
119 const updater = createMessageUpdater(
120 'ai-1',
121 (fn: (msgs: ChatMessage[]) => ChatMessage[]) => {
122 messages = fn(messages)
123 },
124 )
125
126 const ctx: EventHandlerState = {
127 streaming: {
128 streamRefs: streamRefs.controller,
129 setStreamingAgents: (fn: (prev: Set<string>) => Set<string>) => {
130 streamingAgents = fn(streamingAgents)
131 },
132 setStreamStatus: (status: StreamStatus) => {
133 streamStatus = status
134 },
135 },
136 message: {
137 aiMessageId: 'ai-1',
138 updater,
139 hasReceivedContentRef: { current: false },
140 },
141 subagents: {
142 addActiveSubagent: () => {},
143 removeActiveSubagent: () => {},
144 },
145 mode: {
146 agentMode,
147 setHasReceivedPlanResponse: (value: boolean) => {
148 hasPlanResponse = value
149 },
150 },
151 logger: {
152 info: () => {},
153 warn: () => {},
154 error: () => {},
155 debug: () => {},
156 } as Logger,
157 setIsRetrying: () => {},
158 }
159
160 return {
161 ctx,

Callers 1

Calls 2

createMessageUpdaterFunction · 0.90
createStreamRefsFunction · 0.85

Tested by

no test coverage detected