DocsIntegrate
Plan format
Reference for the software-layer SDK's plan JSON: top-level fields, the eight step types, guard, frame, style, results, verification output, and error codes.
Overview#
A plan is a JSON document you hand to the software-layer SDK. The stick-sdk run command, the run_plan MCP tool, and Python's Plan.from_json all use the same format.
{
"plan": 1,
"style": {"kind": "robot"},
"guard": {"foreground": {"class": "MSPaintApp"}},
"frame": {"window": {"class": "MSPaintApp"}, "area": "client", "units": [400, 300], "fit": "contain"},
"steps": [
{"do": "move_to", "at": [95, 225]},
{"do": "drag", "path": [[95, 225], [185, 225], [160, 150]], "speed": 750},
{"do": "click", "at": [200, 120], "button": "left", "count": 2},
{"do": "type", "text": "hello", "style": {"kind": "human", "wpm": 60, "seed": 1}},
{"do": "key", "keys": "ctrl+s"},
{"do": "scroll", "dy": -3, "at": [300, 200]},
{"do": "wait", "ms": 200}
]
}The JSON Schema is in the repository at sdk/docs/plan-schema.json. Editors can use it for completion and validation.
Top-level fields#
| Field | Required | Default | Description |
|---|---|---|---|
plan |
Yes | Format version, currently 1 |
|
steps |
Yes | Array of steps, run in order | |
style |
No | {"kind": "robot"} |
Style for the whole plan; each step can override it |
guard |
No | None | Guards, see below |
frame |
No | None | Coordinate system, see below. Without it, coordinates are physical screen pixels |
checkpoint_ms |
No | 200 |
Interval in milliseconds for checking guard during the run; 0 means check only before the run |
keyset |
No | "87" |
Which keys key steps accept: "87" is the standard 87-key set; "full" also allows F13–F24 and NumLock |
verify |
No | false |
Verify the input the device actually sent after the run |
dry_run |
No | false |
Compile without running |
Coordinates#
- Without
frame:[x, y]is in physical screen pixels, with[0, 0]at the top-left of the primary display. Secondary displays follow their position on the virtual desktop, so coordinates can be negative. - With
frame:[x, y]is in units within that area. - All points are checked at compile time. A point outside every display reports
unreachable_point, along with which step it is in.
Steps#
Each step is an object whose do says what it does. Every step except wait and timeline can carry a style that changes the style for that step only.
do |
Fields | Description |
|---|---|---|
move_to |
at |
Move to the point without pressing anything |
click |
at, button, count |
Click. Without at, clicks at the current position; count is 1 or 2 |
drag |
path, button, speed |
Move to the start point, press, follow the path, release. path needs at least 2 points |
type |
text |
Type text. Limited to printable ASCII on the US layout, newline \n, and tab \t |
key |
keys |
Press a key combination: one combination, or an array pressed in order |
scroll |
dy, dx, at |
Scroll the wheel, in notches; up and right are positive. dy and dx can't both be 0 |
wait |
ms |
Wait 0–600000 milliseconds |
timeline |
file or records |
Insert a hardware-layer timeline as-is; not restricted by keyset |
Field values:
| Field | Values | Default |
|---|---|---|
button |
left, right, middle, back, forward |
left |
count |
1, 2 |
1 |
speed |
Pixels per second, greater than 0. Applies only to the robot style; the human style sets duration by distance | 750 |
keys |
Written like "ctrl+shift+s": the last part is the key name, preceded by the modifiers ctrl, shift, alt, gui |
If type contains any non-ASCII character, the whole plan reports bad_text; nothing runs halfway.
{"do": "key", "keys": ["ctrl+a", "ctrl+c", "alt+tab"]}guard: guards#
guard states the conditions for running. It is checked once before the run and again every checkpoint_ms milliseconds during it; if a check fails, the SDK triggers an emergency stop immediately and returns guard_failed. You can use both items together.
| Item | Meaning |
|---|---|
foreground |
The foreground window must match this window query |
within |
Every point in the plan must fall inside this window, and the window must not be covered by another. area is client (default, the client area) or window (the whole window) |
{"guard": {
"foreground": {"process": "notepad.exe"},
"within": {"window": {"class": "Notepad"}, "area": "client"}
}}Window queries#
guard and frame find windows with the same query format. Specify at least one key:
| Key | Description |
|---|---|
class |
Window class name, such as Notepad or MSPaintApp |
process |
Process name, such as notepad.exe |
title |
Window title |
match |
How the title is matched: exact (default, identical) or contains |
Look up class and process names with stick-sdk windows or the windows MCP tool. Titles change with the open document, so prefer the class or process name.
frame: coordinate system#
frame maps an area to unit coordinates, and every point in the plan is converted through it. Specify the area with either window or rect, not both.
| Key | Required | Default | Description |
|---|---|---|---|
window |
One of the two | Window query; the area is this window | |
rect |
One of the two | [left, top, right, bottom], in screen pixels |
|
area |
No | client |
Used with window: client for the client area, window for the whole window |
units |
Yes | [width, height], the range of unit coordinates; both greater than 0 |
|
fit |
No | contain |
contain: scale uniformly and center; stretch: fill the area, scaling each axis independently |
margin |
No | 0 |
Padding in pixels around the edges of the area |
{"frame": {"window": {"class": "Notepad"}, "area": "client", "units": [100, 100], "fit": "stretch"}}With this frame, [50, 50] is always the center of Notepad's client area, and the plan needs no changes when the window moves or is resized. Use contain where proportions matter, such as in Paint.
style: style#
{"kind": "robot"}
{"kind": "human", "wpm": 55, "typos": 0, "think": [150, 600], "seed": 7}| Key | Range | Default | Description |
|---|---|---|---|
kind |
robot, human |
robot |
Fast and precise, or human |
wpm |
5–250 | 55 |
Typing speed in words per minute |
typos |
0–0.2 | 0 |
Probability of a typo that is then corrected with Backspace. The final text is unchanged |
think |
[min, max] milliseconds |
[150, 600] |
Pause between steps |
seed |
Integer | Random | The same seed compiles to the same timeline. If omitted, one is generated at random and written to seed in the result |
wpm, typos, think, and seed only matter for the human style. For how the two styles differ, see the Style section of Software-layer SDK.
Results#
On success:
{
"ok": true,
"run": "r_20261130_1530_ab12",
"planned_ms": 8949,
"elapsed_ms": 9063,
"segments": [{"seq": 6, "tag": "r_20261130_1530_ab12.0", "records": 1950, "planned_ms": 8949, "checkpoint": null}],
"cursor": [1500, 600],
"stopped": null
}| Field | Description |
|---|---|
run |
ID of this run. Each segment's tag is <run>.<segment>, which matches the batch in the device log |
planned_ms, elapsed_ms |
Planned and actual duration, in milliseconds |
segments |
The segments sent: record count and planned duration |
cursor |
Cursor position at the end, in screen pixels. null if it couldn't be read |
seed |
The seed used by the human style |
syncs, pointing |
Number of syncs and details for feedback-loop pointing on secondary displays |
stopped |
The reason if the run was stopped, otherwise null |
verify |
Verification results when the plan has verify, see below |
With "dry_run": true, nothing runs. The result contains "dry_run": true, per-segment statistics in stats (distributions of hold times, gaps between keys, and peak speed), and the expected end position.
On failure, ok is false, error is the error code, message is a description, and step is the number of the failing step, starting from 1.
Verification results#
"verify": {
"ok": true,
"keys": {"ok": true, "planned": 42, "seen": 42, "first_diff": null},
"buttons": {"ok": true, "planned": 4, "seen": 4, "first_diff": null},
"pointer": {"ok": true, "abs_points": 120, "abs_max_err": 0, "rel_planned": [310, -12], "rel_seen": [310, -12]},
"timing": {"frames": 166, "median_ms": 0.4, "p95_ms": 1.8, "max_ms": 4.0},
"note": null
}| Section | What it compares |
|---|---|
keys |
The sequence of key presses and releases. OS auto-repeat is merged first |
buttons |
The sequence of mouse button presses and releases |
pointer |
Maximum error of absolute coordinates, and the sum of relative moves |
timing |
Difference between actual and planned intervals between adjacent frames. Reported only; not part of the pass/fail decision |
verify.ok is true when keys, mouse buttons, and pointer all match. When verification is unavailable, it is {"ok": null, "skipped": "<reason>"}: the system is not Windows, or input from this device can't be read. This does not affect the run result.
Error codes#
| Code | Meaning |
|---|---|
bad_plan |
The plan format is invalid |
bad_text |
The type text contains characters that can't be typed |
guard_failed |
A guard was not met. Includes which item and on which check |
unreachable_point |
A coordinate is outside every display |
no_pointing |
Pointing by coordinates is not possible: the target is not on the primary display and the device is not plugged in locally |
not_reached |
Feedback-loop pointing on a secondary display didn't arrive within the step limit |
| Hardware-layer codes | hid_locked, not_mounted, queue_full, hid_stopped, hid_lease_expired, unreachable, and others are passed through as-is |
not_mounted means the computer hasn't recognized the device as a keyboard and mouse: the USB cable isn't seated properly, the computer is asleep, or the device has switched to serial mode.
Tips for writing plans#
- Use
windowsto find the target window's class name first, and point bothguardandframeat it. - Put multi-step operations into one plan instead of splitting them across several calls.
- Before the first real run, call it once with
dry_run, or run it on the simulator withstick-sdk run --sim. - Before typing, make sure the input method on the computer is set to English; otherwise the input method will intercept the characters.
- Use the human style only for steps that need to look human, and the default robot style for the rest. It runs faster.