<!--
 ⚠️  AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 This file is automatically generated by scripts/docs-generator.js
 To make changes, edit the source TypeScript files or update the generator script
-->

[playground](../../) / [Exports](../modules) / PlaygroundBlockCollector

# Class: PlaygroundBlockCollector

Playground-specific block collector implementation
Manages block collection with React state integration

## Implements

- [`IBlockDataCollector`](../interfaces/IBlockDataCollector)

## Table of contents

### Constructors

- [constructor](PlaygroundBlockCollector#constructor)

### Methods

- [addListener](PlaygroundBlockCollector#addlistener)
- [removeListener](PlaygroundBlockCollector#removelistener)
- [collectBlock](PlaygroundBlockCollector#collectblock)
- [updateBlock](PlaygroundBlockCollector#updateblock)
- [updateRealTimeBlock](PlaygroundBlockCollector#updaterealtimeblock)
- [getBlocks](PlaygroundBlockCollector#getblocks)
- [getBlocksByParent](PlaygroundBlockCollector#getblocksbyparent)
- [getBlockTree](PlaygroundBlockCollector#getblocktree)
- [clearBlocks](PlaygroundBlockCollector#clearblocks)
- [generateBlockId](PlaygroundBlockCollector#generateblockid)
- [getBlock](PlaygroundBlockCollector#getblock)
- [removeBlock](PlaygroundBlockCollector#removeblock)
- [createGroupBlock](PlaygroundBlockCollector#creategroupblock)
- [getStats](PlaygroundBlockCollector#getstats)

## Constructors

### constructor

• **new PlaygroundBlockCollector**(): [`PlaygroundBlockCollector`](PlaygroundBlockCollector)

#### Returns

[`PlaygroundBlockCollector`](PlaygroundBlockCollector)

## Methods

### addListener

▸ **addListener**(`listener`): `void`

Add a listener for block collection events

#### Parameters

| Name       | Type                                                              |
| :--------- | :---------------------------------------------------------------- |
| `listener` | [`TBlockCollectionListener`](../modules#tblockcollectionlistener) |

#### Returns

`void`

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[addListener](../interfaces/IBlockDataCollector#addlistener)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:25](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L25)

---

### removeListener

▸ **removeListener**(`listener`): `void`

Remove a listener

#### Parameters

| Name       | Type                                                              |
| :--------- | :---------------------------------------------------------------- |
| `listener` | [`TBlockCollectionListener`](../modules#tblockcollectionlistener) |

#### Returns

`void`

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[removeListener](../interfaces/IBlockDataCollector#removelistener)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:32](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L32)

---

### collectBlock

▸ **collectBlock**(`message`): `void`

Collect a new block message

#### Parameters

| Name      | Type                                           |
| :-------- | :--------------------------------------------- |
| `message` | [`IBlockMessage`](../interfaces/IBlockMessage) |

#### Returns

`void`

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[collectBlock](../interfaces/IBlockDataCollector#collectblock)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:52](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L52)

---

### updateBlock

▸ **updateBlock**(`blockId`, `updates`): `void`

Update an existing block

#### Parameters

| Name      | Type                                                          |
| :-------- | :------------------------------------------------------------ |
| `blockId` | `string`                                                      |
| `updates` | `Partial`\<[`IBlockMetadata`](../interfaces/IBlockMetadata)\> |

#### Returns

`void`

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[updateBlock](../interfaces/IBlockDataCollector#updateblock)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:77](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L77)

---

### updateRealTimeBlock

▸ **updateRealTimeBlock**(`blockId`, `updates`): `void`

Update a block's metadata in real-time

#### Parameters

| Name      | Type                                  |
| :-------- | :------------------------------------ |
| `blockId` | `string`                              |
| `updates` | `Partial`\<`IRealTimeBlockMetadata`\> |

#### Returns

`void`

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:93](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L93)

---

### getBlocks

▸ **getBlocks**(): [`IBlockMessage`](../interfaces/IBlockMessage)[]

Get all collected blocks

#### Returns

[`IBlockMessage`](../interfaces/IBlockMessage)[]

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[getBlocks](../interfaces/IBlockDataCollector#getblocks)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:109](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L109)

---

### getBlocksByParent

▸ **getBlocksByParent**(`parentId?`): [`IBlockMessage`](../interfaces/IBlockMessage)[]

Get blocks by parent ID for hierarchical rendering

#### Parameters

| Name        | Type     |
| :---------- | :------- |
| `parentId?` | `string` |

#### Returns

[`IBlockMessage`](../interfaces/IBlockMessage)[]

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[getBlocksByParent](../interfaces/IBlockDataCollector#getblocksbyparent)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:116](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L116)

---

### getBlockTree

▸ **getBlockTree**(): [`IBlockTreeNode`](../interfaces/IBlockTreeNode)[]

Build block tree for hierarchical visualization

#### Returns

[`IBlockTreeNode`](../interfaces/IBlockTreeNode)[]

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:137](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L137)

---

### clearBlocks

▸ **clearBlocks**(): `void`

Clear all blocks

#### Returns

`void`

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[clearBlocks](../interfaces/IBlockDataCollector#clearblocks)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:164](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L164)

---

### generateBlockId

▸ **generateBlockId**(): `string`

Generate unique block ID

#### Returns

`string`

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[generateBlockId](../interfaces/IBlockDataCollector#generateblockid)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:173](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L173)

---

### getBlock

▸ **getBlock**(`blockId`): `undefined` \| [`IBlockMessage`](../interfaces/IBlockMessage)

Get block by ID

#### Parameters

| Name      | Type     |
| :-------- | :------- |
| `blockId` | `string` |

#### Returns

`undefined` \| [`IBlockMessage`](../interfaces/IBlockMessage)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:180](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L180)

---

### removeBlock

▸ **removeBlock**(`blockId`): `void`

Remove a block and its children

#### Parameters

| Name      | Type     |
| :-------- | :------- |
| `blockId` | `string` |

#### Returns

`void`

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:187](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L187)

---

### createGroupBlock

▸ **createGroupBlock**(`type`, `content`, `parentId?`, `level?`): [`IBlockMessage`](../interfaces/IBlockMessage)

Create a group block that can contain other blocks

#### Parameters

| Name        | Type                                                    | Default value |
| :---------- | :------------------------------------------------------ | :------------ |
| `type`      | `"user"` \| `"assistant"` \| `"tool_call"` \| `"group"` | `undefined`   |
| `content`   | `string`                                                | `undefined`   |
| `parentId?` | `string`                                                | `undefined`   |
| `level`     | `number`                                                | `0`           |

#### Returns

[`IBlockMessage`](../interfaces/IBlockMessage)

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[createGroupBlock](../interfaces/IBlockDataCollector#creategroupblock)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:224](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L224)

---

### getStats

▸ **getStats**(): `Object`

Get statistics about collected blocks

#### Returns

`Object`

| Name         | Type                           |
| :----------- | :----------------------------- |
| `total`      | `number`                       |
| `byType`     | `Record`\<`string`, `number`\> |
| `byState`    | `Record`\<`string`, `number`\> |
| `rootBlocks` | `number`                       |

#### Implementation of

[IBlockDataCollector](../interfaces/IBlockDataCollector).[getStats](../interfaces/IBlockDataCollector#getstats)

#### Defined in

[playground/src/lib/playground/block-tracking/block-collector.ts:256](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/playground/src/lib/playground/block-tracking/block-collector.ts#L256)
