MCPcopy
hub / github.com/CodebuffAI/codebuff / processStream

Function processStream

packages/agent-runtime/src/tools/stream-parser.ts:34–383  ·  view source on GitHub ↗
(
  params: {
    agentContext: Record<string, Subgoal>
    agentTemplate: AgentTemplate
    ancestorRunIds: string[]
    fileContext: ProjectFileContext
    fingerprintId: string
    fullResponse: string
    logger: Logger
    messages: Message[]
    repoId: string | undefined
    runId: string
    signal: AbortSignal
    userId: string | undefined

    onCostCalculated: (credits: number) => Promise<void>
    onResponseChunk: (chunk: string | PrintModeEvent) => void
  } & Omit<
    ExecuteToolCallParams<any>,
    | 'fileProcessingState'
    | 'fromHandleSteps'
    | 'fullResponse'
    | 'input'
    | 'previousToolCallFinished'
    | 'state'
    | 'toolCallId'
    | 'toolCalls'
    | 'toolCallsToAddToMessageHistory'
    | 'toolName'
    | 'toolResults'
    | 'toolResultsToAddToMessageHistory'
  > &
    ParamsExcluding<
      typeof processStreamWithTools,
      | 'processors'
      | 'defaultProcessor'
      | 'loggerOptions'
      | 'executeXmlToolCall'
    >,
)

Source from the content-addressed store, hash-verified

32import type { ProjectFileContext } from '@codebuff/common/util/file'
33
34export async function processStream(
35 params: {
36 agentContext: Record<string, Subgoal>
37 agentTemplate: AgentTemplate
38 ancestorRunIds: string[]
39 fileContext: ProjectFileContext
40 fingerprintId: string
41 fullResponse: string
42 logger: Logger
43 messages: Message[]
44 repoId: string | undefined
45 runId: string
46 signal: AbortSignal
47 userId: string | undefined
48
49 onCostCalculated: (credits: number) => Promise<void>
50 onResponseChunk: (chunk: string | PrintModeEvent) => void
51 } & Omit<
52 ExecuteToolCallParams<any>,
53 | 'fileProcessingState'
54 | 'fromHandleSteps'
55 | 'fullResponse'
56 | 'input'
57 | 'previousToolCallFinished'
58 | 'state'
59 | 'toolCallId'
60 | 'toolCalls'
61 | 'toolCallsToAddToMessageHistory'
62 | 'toolName'
63 | 'toolResults'
64 | 'toolResultsToAddToMessageHistory'
65 > &
66 ParamsExcluding<
67 typeof processStreamWithTools,
68 | 'processors'
69 | 'defaultProcessor'
70 | 'loggerOptions'
71 | 'executeXmlToolCall'
72 >,
73) {
74 const {
75 agentState,
76 agentTemplate,
77 ancestorRunIds,
78 fileContext,
79 fullResponse,
80 onCostCalculated,
81 onResponseChunk,
82 runId,
83 signal,
84 userId,
85 } = params
86 const fullResponseChunks: string[] = [fullResponse]
87
88 // === MUTABLE STATE ===
89 const toolResults: ToolMessage[] = []
90 const toolResultsToAddToMessageHistory: ToolMessage[] = []
91 const toolCalls: (CodebuffToolCall | CustomToolCall)[] = []

Callers 4

runAgentStepFunction · 0.90
runStreamFunction · 0.90

Calls 7

processStreamWithToolsFunction · 0.90
assistantMessageFunction · 0.90
userMessageFunction · 0.90
withSystemTagsFunction · 0.90
buildArrayFunction · 0.90
onResponseChunkFunction · 0.50

Tested by 1

runStreamFunction · 0.72