# lmaxroutercn/poker-agent architecture

> Architecture diagram of the GitHub repository lmaxroutercn/poker-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lmaxroutercn/poker-agent
- Repository: https://github.com/lmaxroutercn/poker-agent

## Overview

PokerAgent automates a browser-based LLM tool loop: the userscript captures formatted instructions and submits them to the local Python service; the service queues and executes them, then streams task results back for the userscript to return to the LLM. Major branches include built-in file and memory commands, shell/process execution, permission checks, and the GUI’s runtime controls. The README documents these capabilities and the queue/SSE design; sampled source confirms parts of the implementation, but omitted sections leave some detailed command-to-handler wiring uncertain.

Main entry points: [`agent_server.py`](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py) (Local HTTP Service), [`PokerAgent.js`](https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js) (Browser Automation), [`agent_gui.py`](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_gui.py) (GUI Console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Agent"]
  node_userscript["Browser Automation<br/>[PokerAgent.js]"]
  node_capture["Instruction Capture<br/>[PokerAgent.js]"]
  node_browserconfig["Site Configuration<br/>[PokerAgent.js]"]
end

subgraph group_runtime["Local Runtime"]
  node_server["Local HTTP Service<br/>[agent_server.py]"]
  node_parser["Instruction Parser<br/>[agent_server.py]"]
  node_queue["Task Queue<br/>[agent_server.py]"]
  node_worker["Serial Worker<br/>[agent_server.py]"]
  node_taskstate[("Task Registry<br/>[agent_server.py]")]
  node_sse["SSE Events<br/>[agent_server.py]"]
end

subgraph group_commands["Command Execution"]
  node_dispatcher["Command Dispatcher<br/>[agent_server.py]"]
  node_permissions["Permission Checks<br/>[agent_server.py]"]
  node_fileops["File Commands<br/>[agent_server.py]"]
  node_process["Exec And Run<br/>[agent_server.py]"]
end

subgraph group_state["Memory And State"]
  node_memory["Memory Engine<br/>[agent_server.py]"]
  node_memoryfiles[("Memory Files")]
  node_tasklogs[("Task Logs")]
end

subgraph group_controls["Local Controls"]
  node_gui["GUI Console<br/>[agent_gui.py]"]
end

node_user(("User"))
node_llm(("Web LLM"))
node_compiler["Compiler Extension"]

node_user -->|"starts"| node_gui
node_gui -->|"starts service"| node_server
node_user -->|"provides task"| node_llm
node_llm -->|"outputs instructions"| node_capture
node_capture -->|"extracts commands"| node_userscript
node_browserconfig -->|"configures selectors"| node_capture
node_userscript -->|"POSTs commands"| node_server
node_server -->|"parses request"| node_parser
node_parser -->|"enqueues tasks"| node_queue
node_queue -->|"provides tasks"| node_worker
node_worker -->|"dispatches commands"| node_dispatcher
node_dispatcher -->|"checks access"| node_permissions
node_dispatcher -->|"runs file commands"| node_fileops
node_dispatcher -->|"runs processes"| node_process
node_dispatcher -->|"runs memory commands"| node_memory
node_fileops -->|"writes task data"| node_tasklogs
node_process -->|"writes output"| node_tasklogs
node_memory -->|"reads and writes"| node_memoryfiles
node_worker -->|"updates status"| node_taskstate
node_worker -->|"emits task events"| node_sse
node_sse -->|"streams updates"| node_userscript
node_userscript -->|"returns results"| node_llm
node_userscript -->|"requests memory injection"| node_server
node_server -->|"gets injection content"| node_memory
node_memory -->|"returns memory context"| node_server
node_gui -->|"controls queue"| node_worker
node_compiler -.->|"provides extra information"| node_server

click node_userscript "https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js"
click node_capture "https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js"
click node_browserconfig "https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js"
click node_server "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_parser "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_queue "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_worker "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_taskstate "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_sse "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_dispatcher "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_permissions "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_fileops "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_process "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_memory "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py"
click node_gui "https://github.com/lmaxroutercn/poker-agent/blob/main/agent_gui.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_userscript,node_capture,node_browserconfig,node_user toneBlue
class node_server,node_parser,node_queue,node_worker,node_taskstate,node_sse toneAmber
class node_dispatcher,node_permissions,node_fileops,node_process toneMint
class node_memory,node_memoryfiles,node_tasklogs toneRose
class node_gui,node_llm,node_compiler toneIndigo
```

## Components

### Browser Agent

- [Browser Automation](https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js): `PokerAgent.js`
- [Instruction Capture](https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js): `PokerAgent.js`
- [Site Configuration](https://github.com/lmaxroutercn/poker-agent/blob/main/PokerAgent.js): `PokerAgent.js`

### Local Runtime

- [Local HTTP Service](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [Instruction Parser](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [Task Queue](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [Serial Worker](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [Task Registry](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [SSE Events](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`

### Command Execution

- [Command Dispatcher](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [Permission Checks](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [File Commands](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- [Exec And Run](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`

### Memory And State

- [Memory Engine](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_server.py): `agent_server.py`
- **Memory Files**
- **Task Logs**

### Local Controls

- [GUI Console](https://github.com/lmaxroutercn/poker-agent/blob/main/agent_gui.py): `agent_gui.py`

### Other components

- **User**
- **Web LLM**
- **Compiler Extension**

## Connections

- User → GUI Console: starts
- GUI Console → Local HTTP Service: starts service
- User → Web LLM: provides task
- Web LLM → Instruction Capture: outputs instructions
- Instruction Capture → Browser Automation: extracts commands
- Site Configuration → Instruction Capture: configures selectors
- Browser Automation → Local HTTP Service: POSTs commands
- Local HTTP Service → Instruction Parser: parses request
- Instruction Parser → Task Queue: enqueues tasks
- Task Queue → Serial Worker: provides tasks
- Serial Worker → Command Dispatcher: dispatches commands
- Command Dispatcher → Permission Checks: checks access
- Command Dispatcher → File Commands: runs file commands
- Command Dispatcher → Exec And Run: runs processes
- Command Dispatcher → Memory Engine: runs memory commands
- File Commands → Task Logs: writes task data
- Exec And Run → Task Logs: writes output
- Memory Engine → Memory Files: reads and writes
- Serial Worker → Task Registry: updates status
- Serial Worker → SSE Events: emits task events
- SSE Events → Browser Automation: streams updates
- Browser Automation → Web LLM: returns results
- Browser Automation → Local HTTP Service: requests memory injection
- Local HTTP Service → Memory Engine: gets injection content
- Memory Engine → Local HTTP Service: returns memory context
- GUI Console → Serial Worker: controls queue
- Compiler Extension → Local HTTP Service: provides extra information
