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

Function findBlockInChildren

cli/src/utils/message-block-helpers.ts:392–407  ·  view source on GitHub ↗
(
  blocks: ContentBlock[],
  targetId: string,
)

Source from the content-addressed store, hash-verified

390 * Checks if a block with the given targetId exists anywhere in the children of the blocks.
391 */
392const findBlockInChildren = (
393 blocks: ContentBlock[],
394 targetId: string,
395): boolean => {
396 for (const block of blocks) {
397 if (block.type === 'agent' && block.agentId === targetId) {
398 return true
399 }
400 if (block.type === 'agent' && block.blocks) {
401 if (findBlockInChildren(block.blocks, targetId)) {
402 return true
403 }
404 }
405 }
406 return false
407}
408
409/**
410 * Checks if a block with the given agentId is already nested under the specified parent.

Callers 1

checkBlockIsUnderParentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected