Planned Python move
Several PowerShell mistakes parsed fine and failed only at run time. A \b in a path became a control character. An argument list built with @(...) + @(...) passed a bare + as an argument and silently broke every acceptance check for hours. A variable name that differed only in case overwrote a parameter. A wait loop matched the start of a line but every log line started with a time, so a failed session start waited for the full timeout. A callback’s printed output became part of a function’s return value. A typed language with a compiler or a type checker would catch most of these before a run. The repository already guards against some of them with Pester tests, such as a syntax tree test that forbids a bare + argument.
What exists today
Section titled “What exists today”About 3,200 lines of PowerShell plus the Python report script scripts/runs.py. The orchestrator is factory.ps1 and its modules. The agent runner is Invoke-Agent.ps1. The VM layer is vm-e2e.ps1, vm-session.ps1, vm-do.ps1, vm-proof.ps1, accept.ps1 and the guest scripts. Tests are Pester under factory2/tests and tests/factory.
The options that were considered
Section titled “The options that were considered”- Keep PowerShell, guarded by Pester and syntax tree checks.
- A Python orchestrator with a thin PowerShell layer for Hyper-V. This is the leaning choice. Python is already needed for Graphify, DuckDB and
runs.py, and the Claude Agent SDK could replaceInvoke-Agent.ps1. - C#. It matches the plugin and checks types at compile time, but the Agent SDK is for Python and TypeScript, so it would still shell out to
claude. - Remove PowerShell from the VM layer too, with a small guest agent in the logged in desktop session that exposes click, type, screenshot, read-UI-tree and install-build over a socket.
What the Agent SDK might add
Section titled “What the Agent SDK might add”- Typed tools for the acceptance agent (
click,screenshot,read_ui) that call the guest directly. Today it writes step files and runs them through a command allow list, and the permission matcher has cost hours. - Permission callbacks and hooks in code instead of regular expression rules and stream parsing, with telemetry coming from hooks.
- Structured output and per message cost built in.
Two things to verify first
Section titled “Two things to verify first”- Whether the Agent SDK can use the owner’s local
claudelogin. The factory never uses an API key or a token, and this is believed but not verified. - The guest agent protocol, and how Flare’s UI automation behaves under it.
Suggested order
Section titled “Suggested order”Each stage keeps factory.ps1 working and is proved on a real issue.
- Verify the login question and write down the requirements in
Invoke-Agent.ps1. - Port the agent runner to Python behind the same command line, with parity tests.
- Port the gate, the build module and telemetry, keeping the event names so
runs.pykeeps working. - Port the loop, the VM queue and the claims.
- Acceptance with typed VM tools and the guest agent.
- Delete the PowerShell that is left, apart from anything Hyper-V still needs.
Nothing is rewritten while a factory run is going, because a running process keeps the modules it started with.