MCPcopy Create free account
hub / github.com/anus-dev/ANUS / createMockStream

Function createMockStream

packages/core/src/core/subagent.test.ts:68–86  ·  view source on GitHub ↗
(
  functionCallsList: Array<FunctionCall[] | 'stop'>,
)

Source from the content-addressed store, hash-verified

66
67// Helper to simulate LLM responses (sequence of tool calls over multiple turns)
68const createMockStream = (
69 functionCallsList: Array<FunctionCall[] | 'stop'>,
70) => {
71 let index = 0;
72 return vi.fn().mockImplementation(() => {
73 const response = functionCallsList[index] || 'stop';
74 index++;
75 return (async function* () {
76 if (response === 'stop') {
77 // When stopping, the model might return text, but the subagent logic primarily cares about the absence of functionCalls.
78 yield { text: 'Done.' };
79 } else if (response.length > 0) {
80 yield { functionCalls: response };
81 } else {
82 yield { text: 'Done.' }; // Handle empty array also as stop
83 }
84 })();
85 });
86};
87
88describe('subagent.ts', () => {
89 describe('ContextState', () => {

Callers 1

subagent.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected