Implementation:A9T9 RPA runCommandInPlayTab
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Command_Dispatch |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Concrete tool for dispatching individual RPA commands from the popup/side panel to the content script for in-page execution, provided by the Ui.Vision command dispatch module.
Description
The runCommandInPlayTab function (`src/ext/popup/run_command.ts`) takes a single Command object from the player's iteration loop and sends it to the content script running in the target tab for execution. It uses `callPlayTab` to send an IPC message via the background↔content script IPC hub (`src/common/ipc/ipc_bg_cs.js`). The content script's command runner (`src/ext/content_script/command_runner.js`) receives the command and executes the actual RPA action (click, type, select, verify, etc.) using trusted CDP input (`src/services/cdp_input/index.ts`) where needed.
The function returns a `RunCommandResult` with status (ok/error), screenshots, and logs, which the player loop uses for result reporting.
Usage
Call this function from the player run loop to execute one command in the target tab. It is the dispatch bridge between the player engine and the in-page command executor.
Code Reference
Source Location
- Repository: A9T9/RPA
- File: src/ext/popup/run_command.ts
- Lines: L34-L120 (runCommandInPlayTab), L121-L160 (callPlayTab)
Signature
export function runCommandInPlayTab(command: Command): Promise<RunCommandResult>
export function callPlayTab<T>(
params: PlayTabIPCParams
): Promise<T>
Import
import { runCommandInPlayTab, callPlayTab } from '@/ext/popup/run_command'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| command | Command | Yes | Command object with cmd, target, value fields |
| params.tabIpcTimeout | number | No | IPC timeout in milliseconds |
Outputs
| Name | Type | Description |
|---|---|---|
| result | RunCommandResult | Status (ok/error), screenshots, logs from command execution |
Usage Examples
Dispatch a Single Command
import { runCommandInPlayTab } from '@/ext/popup/run_command'
const result = await runCommandInPlayTab({
cmd: 'click',
target: 'xpath=//button[@id="login"]',
value: ''
})
if (result.status === 'ok') {
console.log('Command succeeded')
} else {
console.error('Command failed:', result.message)
}