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

Function createAgentBlock

cli/src/utils/message-block-helpers.ts:297–318  ·  view source on GitHub ↗
(
  options: CreateAgentBlockOptions,
)

Source from the content-addressed store, hash-verified

295 * Creates a new agent content block with standard defaults.
296 */
297export const createAgentBlock = (
298 options: CreateAgentBlockOptions,
299): AgentContentBlock => {
300 const { agentId, agentType, prompt, params, spawnToolCallId, spawnIndex, parentAgentType } = options
301 const shouldCollapse =
302 shouldCollapseByDefault(agentType || '') ||
303 shouldCollapseForParent(agentType || '', parentAgentType)
304 return {
305 type: 'agent',
306 agentId,
307 agentName: agentType || 'Agent',
308 agentType: agentType || 'unknown',
309 content: '',
310 status: 'running' as const,
311 blocks: [] as ContentBlock[],
312 initialPrompt: prompt || '',
313 ...(params && { params }),
314 ...(spawnToolCallId && { spawnToolCallId }),
315 ...(spawnIndex !== undefined && { spawnIndex }),
316 ...(shouldCollapse && { isCollapsed: true }),
317 }
318}
319
320/**
321 * Helper function to recursively update blocks by target agent ID.

Calls 2

shouldCollapseByDefaultFunction · 0.90
shouldCollapseForParentFunction · 0.90

Tested by

no test coverage detected