> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Recording

本页面介绍 Lynx DevTool 支持的 `Recording` CDP domain。



:::warning 实验性参考
此生成的参考文档仍在完善中。

- CDP events 尚未包含。
- 部分 Lynx 扩展已列出，但尚未提供详细文档。
- 方法说明尚未根据实现自动校验，可能不完整或不准确。

在依赖本参考前，请根据实现及所链接的 upstream CDP reference 验证实际行为。
:::

## 概览

- 作用域：`global-and-instance`
- CDP domain：Lynx 专有

## Lynx 扩展

### `Recording.end`

Stops TestBench recording and emits stream handles for generated recording files.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_testbench_recorder_agent.cc`

###### 参数

无参数。

###### 返回字段

无返回字段。

###### 事件

- Recording.recordingComplete

###### 备注

- Recorder support must be enabled in the current runtime. If RecorderController::Enable() is false, the agent returns method not implemented.
- Dispatches through LynxGlobalDevToolMediator and calls RecorderController::EndRecord() on the UI task runner.
- Returns an empty result object after the end-record request is accepted.
- Sends Recording.recordingComplete asynchronously after the recorder writes the output files.
- Recording.recordingComplete.params.stream is an array of FileStream handles. Read each handle with IO.read and close it with IO.close.
- Recording.recordingComplete.params.filenames contains the generated file paths. Recording.recordingComplete.params.sessionIDs contains matching session ids or -1 when the recorder has no mapped session id.
- Recording.recordingComplete.params.recordFormat is json.
- The TestBench recorder writes compressed and base64-encoded JSON content to each generated file.

###### 示例

**Stop recording**

Request:

```json
{
  "id": 2,
  "method": "Recording.end"
}
```

Response:

```json
{
  "id": 2,
  "result": {}
}
```

**Recording complete notification**

Response:

```json
{
  "method": "Recording.recordingComplete",
  "params": {
    "stream": [1],
    "filenames": ["/tmp/1001.json"],
    "sessionIDs": [1001],
    "recordFormat": "json"
  }
}
```

### `Recording.start`

Starts TestBench recording for Lynx page interactions.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_testbench_recorder_agent.cc`

###### 参数

无参数。

###### 返回字段

无返回字段。

###### 备注

- Recorder support must be enabled in the current runtime. If RecorderController::Enable() is false, the agent returns method not implemented.
- Dispatches through LynxGlobalDevToolMediator and starts RecorderController::StartRecord() on the UI task runner.
- Returns an empty result object on success.
- Returns a CDP error with message Cannot find ui task runner when no UI task runner is available.

###### 示例

**Start recording**

Request:

```json
{
  "id": 1,
  "method": "Recording.start"
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

