( blocks: ContentBlock[], targetAgentId: string, parentAgentId: string, )
| 410 | * Checks if a block with the given agentId is already nested under the specified parent. |
| 411 | */ |
| 412 | const checkBlockIsUnderParent = ( |
| 413 | blocks: ContentBlock[], |
| 414 | targetAgentId: string, |
| 415 | parentAgentId: string, |
| 416 | ): boolean => { |
| 417 | for (const block of blocks) { |
| 418 | if (block.type === 'agent' && block.agentId === parentAgentId) { |
| 419 | // Found the parent, check if target is anywhere in its children |
| 420 | return findBlockInChildren(block.blocks || [], targetAgentId) |
| 421 | } else if (block.type === 'agent' && block.blocks) { |
| 422 | // Recurse into other agent blocks to find the parent |
| 423 | if (checkBlockIsUnderParent(block.blocks, targetAgentId, parentAgentId)) { |
| 424 | return true |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | return false |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Extracts a block with given agentId from nested blocks structure. |
no test coverage detected