Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A9T9 RPA runCommandInPlayTab

From Leeroopedia
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)
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment