@weavetab/plugin-gamer 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +67 -2
- package/dist/gate.d.ts +36 -0
- package/dist/gate.js +108 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +318 -0
- package/dist/input.d.ts +66 -0
- package/dist/input.js +244 -0
- package/dist/loop.d.ts +62 -0
- package/dist/loop.js +224 -0
- package/package.json +63 -4
- package/weavetab.json +292 -0
package/dist/loop.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { captureFrame, getGate, getViewport, readSelectorText, } from "./gate.js";
|
|
4
|
+
import { describeAction, focusTarget, InputController } from "./input.js";
|
|
5
|
+
const VALID_ACTIONS = new Set(["hold", "tap", "click", "mouse_hold", "drag", "look", "idle", "yield"]);
|
|
6
|
+
const MAX_SPANS = 60;
|
|
7
|
+
const HEARTBEAT_MS = 2000;
|
|
8
|
+
export function parseRules(raw) {
|
|
9
|
+
let list = raw;
|
|
10
|
+
if (typeof raw === "string") {
|
|
11
|
+
try {
|
|
12
|
+
list = JSON.parse(raw);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
throw new Error(`invalid rules JSON: ${e?.message || e}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (!Array.isArray(list) || list.length < 1 || list.length > 32) {
|
|
19
|
+
throw new Error("rules must contain between 1 and 32 entries");
|
|
20
|
+
}
|
|
21
|
+
return list.map((r, idx) => {
|
|
22
|
+
if (!r || typeof r.when !== "string" || !r.when.trim()) {
|
|
23
|
+
throw new Error(`rules[${idx}].when must be a non-empty string`);
|
|
24
|
+
}
|
|
25
|
+
if (!r.do || typeof r.do !== "object" || !VALID_ACTIONS.has(r.do.type)) {
|
|
26
|
+
throw new Error(`rules[${idx}].do.type is invalid`);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
when: r.when.trim(),
|
|
30
|
+
do: r.do,
|
|
31
|
+
min_conf: r.min_conf,
|
|
32
|
+
yield: Boolean(r.yield),
|
|
33
|
+
cooldown_ms: r.cooldown_ms,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function clamp(n, lo, hi) {
|
|
38
|
+
return Math.min(hi, Math.max(lo, n));
|
|
39
|
+
}
|
|
40
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
41
|
+
export async function runPlaybook(sess, args, opts = {}) {
|
|
42
|
+
const rules = parseRules(args.rules);
|
|
43
|
+
const gate = opts.gate ?? (await getGate());
|
|
44
|
+
const cfg = opts.defaultConfig ?? {};
|
|
45
|
+
const maxSteps = Math.round(clamp(args.steps ?? cfg.defaultSteps ?? 30, 1, 200));
|
|
46
|
+
const maxMs = Math.round(clamp(args.max_ms ?? 6000, 200, 30000));
|
|
47
|
+
const intervalMs = Math.round(clamp(args.interval_ms ?? cfg.defaultIntervalMs ?? 100, 50, 2000));
|
|
48
|
+
const baseMinConf = clamp(args.min_conf ?? cfg.minConfidence ?? 0.45, 0, 1);
|
|
49
|
+
const stopConf = clamp(args.stop_conf ?? 0.65, 0, 1);
|
|
50
|
+
const stopCheckEvery = Math.round(clamp(args.stop_check_every ?? 1, 1, 20));
|
|
51
|
+
const quality = Math.round(clamp(args.quality ?? cfg.jpegQuality ?? 65, 25, 95));
|
|
52
|
+
const vp = await getViewport(sess);
|
|
53
|
+
await focusTarget(sess, args.focus);
|
|
54
|
+
const input = new InputController();
|
|
55
|
+
const transitions = [];
|
|
56
|
+
let truncated = false;
|
|
57
|
+
const lastFired = new Map();
|
|
58
|
+
const choices = rules.map((r) => r.when);
|
|
59
|
+
let ticks = 0;
|
|
60
|
+
let lowConfStreak = 0;
|
|
61
|
+
let stoppedReason = "steps";
|
|
62
|
+
let lastDecision = null;
|
|
63
|
+
let aborted = false;
|
|
64
|
+
let prevEmittedKey = "";
|
|
65
|
+
let prevEmitMs = -HEARTBEAT_MS;
|
|
66
|
+
let repeatCount = 0;
|
|
67
|
+
const sigintHandler = () => {
|
|
68
|
+
aborted = true;
|
|
69
|
+
};
|
|
70
|
+
if (opts.attachSigint)
|
|
71
|
+
process.once("SIGINT", sigintHandler);
|
|
72
|
+
const t0 = Date.now();
|
|
73
|
+
const recordSpan = (nowMs, when, action, conf) => {
|
|
74
|
+
const last = transitions[transitions.length - 1];
|
|
75
|
+
if (last && last.when === when && last.action === action) {
|
|
76
|
+
const nextTicks = last.ticks + 1;
|
|
77
|
+
last.avg_conf = Math.round(((last.avg_conf * last.ticks + conf) / nextTicks) * 1000) / 1000;
|
|
78
|
+
last.ticks = nextTicks;
|
|
79
|
+
last.to_ms = nowMs;
|
|
80
|
+
repeatCount++;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
repeatCount = 1;
|
|
84
|
+
if (transitions.length < MAX_SPANS) {
|
|
85
|
+
transitions.push({
|
|
86
|
+
from_ms: nowMs,
|
|
87
|
+
to_ms: nowMs,
|
|
88
|
+
ticks: 1,
|
|
89
|
+
when,
|
|
90
|
+
action,
|
|
91
|
+
avg_conf: Math.round(conf * 1000) / 1000,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
truncated = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
lastDecision = { when, action, confidence: Math.round(conf * 1000) / 1000 };
|
|
99
|
+
if (opts.onLine) {
|
|
100
|
+
const key = `${when}\0${action}`;
|
|
101
|
+
const sec = (nowMs / 1000).toFixed(1);
|
|
102
|
+
if (key !== prevEmittedKey) {
|
|
103
|
+
opts.onLine(`[+${sec}s] "${when}" (${conf.toFixed(2)}) -> ${action}`);
|
|
104
|
+
prevEmittedKey = key;
|
|
105
|
+
prevEmitMs = nowMs;
|
|
106
|
+
}
|
|
107
|
+
else if (nowMs - prevEmitMs >= HEARTBEAT_MS) {
|
|
108
|
+
opts.onLine(`[+${sec}s] (still x${repeatCount}) "${when}" (${conf.toFixed(2)}) -> ${action}`);
|
|
109
|
+
prevEmitMs = nowMs;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
try {
|
|
114
|
+
while (ticks < maxSteps) {
|
|
115
|
+
if (aborted || opts.signal?.aborted) {
|
|
116
|
+
stoppedReason = "aborted";
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
const tickStart = Date.now();
|
|
120
|
+
const elapsed = tickStart - t0;
|
|
121
|
+
if (ticks > 0 && elapsed >= maxMs) {
|
|
122
|
+
stoppedReason = "max_ms";
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
const payload = args.text_selector
|
|
126
|
+
? await readSelectorText(sess, args.text_selector)
|
|
127
|
+
: (await captureFrame(sess, { quality, clip: args.clip, viewport: vp })).buffer;
|
|
128
|
+
ticks++;
|
|
129
|
+
const nowRel = Date.now() - t0;
|
|
130
|
+
if (args.stop_if && ticks % stopCheckEvery === 0) {
|
|
131
|
+
const guard = gate.yesNo(payload, args.stop_if);
|
|
132
|
+
if (guard.answer && guard.confidence >= stopConf) {
|
|
133
|
+
recordSpan(nowRel, `stop_if: ${args.stop_if}`, "yield", guard.confidence);
|
|
134
|
+
stoppedReason = "stop_if";
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let matchedIdx = -1;
|
|
139
|
+
let conf = 0;
|
|
140
|
+
if (rules.length === 1) {
|
|
141
|
+
const yn = gate.yesNo(payload, rules[0].when);
|
|
142
|
+
conf = yn.probability;
|
|
143
|
+
if (yn.answer)
|
|
144
|
+
matchedIdx = 0;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const dec = gate.decide(payload, choices);
|
|
148
|
+
conf = dec.confidence;
|
|
149
|
+
matchedIdx = rules.findIndex((r) => r.when === dec.choice);
|
|
150
|
+
}
|
|
151
|
+
const rule = matchedIdx >= 0 ? rules[matchedIdx] : undefined;
|
|
152
|
+
const neededConf = rule?.min_conf ?? baseMinConf;
|
|
153
|
+
if (!rule || conf < neededConf) {
|
|
154
|
+
lowConfStreak++;
|
|
155
|
+
await input.releaseAll(sess);
|
|
156
|
+
recordSpan(nowRel, "(low_conf)", "idle", conf);
|
|
157
|
+
if (args.yield_on_low_conf && lowConfStreak >= args.yield_on_low_conf) {
|
|
158
|
+
stoppedReason = "low_confidence";
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
lowConfStreak = 0;
|
|
164
|
+
const prevFire = lastFired.get(matchedIdx) ?? -1e9;
|
|
165
|
+
if (rule.cooldown_ms && Date.now() - prevFire < rule.cooldown_ms) {
|
|
166
|
+
recordSpan(nowRel, rule.when, "cooldown", conf);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
lastFired.set(matchedIdx, Date.now());
|
|
170
|
+
const actLabel = describeAction(rule.do);
|
|
171
|
+
if (rule.yield || rule.do.type === "yield") {
|
|
172
|
+
if (rule.do.type !== "yield") {
|
|
173
|
+
await input.exec(sess, rule.do, vp);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
await input.releaseAll(sess);
|
|
177
|
+
}
|
|
178
|
+
recordSpan(nowRel, rule.when, actLabel, conf);
|
|
179
|
+
stoppedReason = "rule_yield";
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
await input.exec(sess, rule.do, vp);
|
|
183
|
+
recordSpan(nowRel, rule.when, actLabel, conf);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const spent = Date.now() - tickStart;
|
|
187
|
+
if (ticks < maxSteps && spent < intervalMs) {
|
|
188
|
+
await sleep(intervalMs - spent);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
await input.releaseAll(sess).catch(() => { });
|
|
194
|
+
if (opts.attachSigint)
|
|
195
|
+
process.removeListener("SIGINT", sigintHandler);
|
|
196
|
+
}
|
|
197
|
+
let savedFramePath;
|
|
198
|
+
let lastFrameBase64;
|
|
199
|
+
if (args.return_frame || args.save_frame) {
|
|
200
|
+
const snap = await captureFrame(sess, { quality, clip: args.clip, viewport: vp }).catch(() => null);
|
|
201
|
+
if (snap) {
|
|
202
|
+
if (args.return_frame)
|
|
203
|
+
lastFrameBase64 = snap.base64;
|
|
204
|
+
if (args.save_frame) {
|
|
205
|
+
const abs = path.resolve(args.save_frame);
|
|
206
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
207
|
+
fs.writeFileSync(abs, snap.buffer);
|
|
208
|
+
savedFramePath = abs;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const totalMs = Math.max(1, Date.now() - t0);
|
|
213
|
+
return {
|
|
214
|
+
stopped_reason: stoppedReason,
|
|
215
|
+
ticks,
|
|
216
|
+
elapsed_ms: totalMs,
|
|
217
|
+
hz: Math.round((ticks * 1000 * 10) / totalMs) / 10,
|
|
218
|
+
transitions,
|
|
219
|
+
...(truncated ? { truncated_transitions: true } : {}),
|
|
220
|
+
last_decision: lastDecision,
|
|
221
|
+
...(savedFramePath ? { saved_frame: savedFramePath } : {}),
|
|
222
|
+
...(lastFrameBase64 ? { last_frame_base64: lastFrameBase64 } : {}),
|
|
223
|
+
};
|
|
224
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weavetab/plugin-gamer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Weavetab local-vision real-time controller plugin powered by Weavetab Gate v2.0 — CLI-first bounded burst playbooks, MCP parity, and universal CDP input for browser and Electron apps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"weavetab.json",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"preflight": "weavetab-sdk preflight",
|
|
24
|
+
"test": "node --test test/*.test.mjs",
|
|
25
|
+
"prepublishOnly": "npm run build && npm run preflight"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@weavetab/gate": "^2.0.0",
|
|
29
|
+
"@weavetab/sdk": "^2.6.4"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.10.0",
|
|
33
|
+
"typescript": "^5.5.0"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"weavetab",
|
|
37
|
+
"weavetab-plugin",
|
|
38
|
+
"weavetab-official",
|
|
39
|
+
"gate",
|
|
40
|
+
"vision",
|
|
41
|
+
"realtime",
|
|
42
|
+
"cdp",
|
|
43
|
+
"electron",
|
|
44
|
+
"automation"
|
|
45
|
+
],
|
|
46
|
+
"author": {
|
|
47
|
+
"name": "Weavetab",
|
|
48
|
+
"url": "https://weavetab.dev"
|
|
49
|
+
},
|
|
50
|
+
"license": "Apache-2.0",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/Weavetab/Gamer.git"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/Weavetab/Gamer/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/Weavetab/Gamer#readme",
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=20.19.0"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/weavetab.json
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://weavetab.dev/schema/plugin.json",
|
|
3
|
+
"name": "@weavetab/plugin-gamer",
|
|
4
|
+
"displayName": "Gamer",
|
|
5
|
+
"description": "Local-vision real-time controller powered by Weavetab Gate v2.0 — CLI-first bounded burst playbooks, MCP parity, and universal CDP inputs for 2D/3D/turn-based browser and Electron sessions.",
|
|
6
|
+
"entry": "dist/index.js",
|
|
7
|
+
"instructions": "Two-tier Planner-Actor control using Weavetab Gate v2.0 local ONNX vision/NLI (~8-12 Hz CPU, zero tokens):\n1. You are the strategic planner; Gate is the fast local actor. Write concise visual/text rules ('when' -> 'do') for each bounded burst.\n2. Prefer CLI `weavetab plugin use gamer run --rules '[...]'` for live transition-only stdout streaming without context bloat. Use MCP `gamer_play` when you want the final JPEG frame attached inline to re-plan.\n3. Calibrate labels before bursting with `gamer_decide` (or `weavetab plugin use gamer decide --choices ...`). Use `gamer_act` / `act` for single holds, clicks, drags, or camera turns.\n4. Supports browser tabs and Electron apps, pixel or 0..1 normalized coordinates, selector `clip` (e.g. 'canvas' or '#board'), optional `text_selector` for HUD/DOM NLI, `stop_if` interrupts, and `yield` rules.",
|
|
8
|
+
"tags": [
|
|
9
|
+
"Gamer",
|
|
10
|
+
"Vision",
|
|
11
|
+
"Gate",
|
|
12
|
+
"Realtime",
|
|
13
|
+
"Electron",
|
|
14
|
+
"CDP",
|
|
15
|
+
"Official"
|
|
16
|
+
],
|
|
17
|
+
"links": {
|
|
18
|
+
"github": "https://github.com/Weavetab/Gamer",
|
|
19
|
+
"npm": "https://www.npmjs.com/package/@weavetab/plugin-gamer"
|
|
20
|
+
},
|
|
21
|
+
"defaultConfig": {
|
|
22
|
+
"defaultIntervalMs": 100,
|
|
23
|
+
"defaultSteps": 30,
|
|
24
|
+
"minConfidence": 0.45,
|
|
25
|
+
"jpegQuality": 65
|
|
26
|
+
},
|
|
27
|
+
"permissions": {
|
|
28
|
+
"cdp": {
|
|
29
|
+
"evaluate": true,
|
|
30
|
+
"screenshot": true,
|
|
31
|
+
"input": true,
|
|
32
|
+
"reason": "Captures fast viewport/selector screenshots, reads optional HUD text or canvas focus/pointer-lock state, and dispatches keyboard/mouse/drag/camera inputs."
|
|
33
|
+
},
|
|
34
|
+
"tools": {
|
|
35
|
+
"add": true,
|
|
36
|
+
"reason": "Registers gamer_play, gamer_decide, and gamer_act MCP tools."
|
|
37
|
+
},
|
|
38
|
+
"commands": {
|
|
39
|
+
"add": true,
|
|
40
|
+
"reason": "Registers run, decide, and act CLI commands with live transition streaming."
|
|
41
|
+
},
|
|
42
|
+
"prompts": {
|
|
43
|
+
"add": true,
|
|
44
|
+
"reason": "Registers the /gamer_playbook prompt utility."
|
|
45
|
+
},
|
|
46
|
+
"config": {
|
|
47
|
+
"read": true,
|
|
48
|
+
"write": true,
|
|
49
|
+
"reason": "Reads default burst interval, step budget, confidence threshold, and JPEG quality."
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"commands": [
|
|
53
|
+
{
|
|
54
|
+
"name": "run",
|
|
55
|
+
"description": "Run a bounded real-time Gate v2.0 vision/NLI playbook loop and stream transition-only progress lines to stdout.",
|
|
56
|
+
"usage": "weavetab plugin use gamer run --rules '[{\"when\":\"...\",\"do\":{\"type\":\"hold\",\"keys\":[\"w\"]}}]' [--steps 30] [--interval_ms 100] [--clip canvas] [--stop_if \"...\"] [--save_frame out.jpg]",
|
|
57
|
+
"requiresSession": true,
|
|
58
|
+
"parameters": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"required": ["rules"],
|
|
61
|
+
"properties": {
|
|
62
|
+
"rules": {
|
|
63
|
+
"description": "Playbook rules array (or JSON string) mapping 'when' conditions to 'do' actions."
|
|
64
|
+
},
|
|
65
|
+
"steps": {
|
|
66
|
+
"type": "number",
|
|
67
|
+
"description": "Maximum decision ticks (1-200, default 30)."
|
|
68
|
+
},
|
|
69
|
+
"max_ms": {
|
|
70
|
+
"type": "number",
|
|
71
|
+
"description": "Maximum wall-clock burst duration in ms (200-30000, default 6000)."
|
|
72
|
+
},
|
|
73
|
+
"interval_ms": {
|
|
74
|
+
"type": "number",
|
|
75
|
+
"description": "Target loop interval in ms (50-2000, default 100)."
|
|
76
|
+
},
|
|
77
|
+
"min_conf": {
|
|
78
|
+
"type": "number",
|
|
79
|
+
"description": "Minimum Gate confidence threshold (0-1, default 0.45)."
|
|
80
|
+
},
|
|
81
|
+
"yield_on_low_conf": {
|
|
82
|
+
"type": "number",
|
|
83
|
+
"description": "Pause burst after N consecutive low-confidence ticks."
|
|
84
|
+
},
|
|
85
|
+
"stop_if": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"description": "Optional Gate yes/no interrupt condition evaluated during the burst."
|
|
88
|
+
},
|
|
89
|
+
"stop_conf": {
|
|
90
|
+
"type": "number",
|
|
91
|
+
"description": "Confidence required for stop_if (0-1, default 0.65)."
|
|
92
|
+
},
|
|
93
|
+
"stop_check_every": {
|
|
94
|
+
"type": "number",
|
|
95
|
+
"description": "Evaluate stop_if every N ticks (1-20, default 1)."
|
|
96
|
+
},
|
|
97
|
+
"clip": {
|
|
98
|
+
"description": "CSS selector string (e.g. 'canvas') or {x, y, w, h} crop rect (pixels or 0..1 normalized)."
|
|
99
|
+
},
|
|
100
|
+
"text_selector": {
|
|
101
|
+
"type": "string",
|
|
102
|
+
"description": "Optional DOM selector to evaluate via Gate text NLI instead of vision."
|
|
103
|
+
},
|
|
104
|
+
"focus": {
|
|
105
|
+
"description": "CSS selector to focus before running, or false to skip auto-focusing the largest canvas."
|
|
106
|
+
},
|
|
107
|
+
"quality": {
|
|
108
|
+
"type": "number",
|
|
109
|
+
"description": "JPEG screenshot quality (25-95, default 65)."
|
|
110
|
+
},
|
|
111
|
+
"save_frame": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "Optional file path to save the final JPEG screenshot after the burst."
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "decide",
|
|
120
|
+
"description": "Capture a single frame (or selector text) and evaluate Gate v2.0 decide, yes/no, or ordered score.",
|
|
121
|
+
"usage": "weavetab plugin use gamer decide --choices '[\"a\",\"b\"]' | --ask \"...\" | --levels '[\"low\",\"high\"]' [--clip canvas]",
|
|
122
|
+
"requiresSession": true,
|
|
123
|
+
"parameters": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"properties": {
|
|
126
|
+
"choices": {
|
|
127
|
+
"description": "2-64 candidate labels (array or JSON string) for Gate decide."
|
|
128
|
+
},
|
|
129
|
+
"ask": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"description": "Declarative statement for Gate yesNo."
|
|
132
|
+
},
|
|
133
|
+
"levels": {
|
|
134
|
+
"description": "2-64 ordered rubric levels (array or JSON string) for Gate score."
|
|
135
|
+
},
|
|
136
|
+
"clip": {
|
|
137
|
+
"description": "Optional CSS selector or {x, y, w, h} crop rect."
|
|
138
|
+
},
|
|
139
|
+
"text_selector": {
|
|
140
|
+
"type": "string",
|
|
141
|
+
"description": "Optional DOM selector to score via text NLI instead of screenshot vision."
|
|
142
|
+
},
|
|
143
|
+
"quality": {
|
|
144
|
+
"type": "number",
|
|
145
|
+
"description": "JPEG quality (25-95, default 65)."
|
|
146
|
+
},
|
|
147
|
+
"save_frame": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"description": "Optional path to write the captured JPEG frame."
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "act",
|
|
156
|
+
"description": "Dispatch an immediate CDP keyboard, mouse, drag, or camera-look action on the active tab or Electron window.",
|
|
157
|
+
"usage": "weavetab plugin use gamer act --type tap|hold|click|mouse_hold|drag|look --keys '[\"w\"]' [--x 0.5] [--y 0.5]",
|
|
158
|
+
"requiresSession": true,
|
|
159
|
+
"parameters": {
|
|
160
|
+
"type": "object",
|
|
161
|
+
"required": ["type"],
|
|
162
|
+
"properties": {
|
|
163
|
+
"type": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"enum": ["hold", "tap", "click", "mouse_hold", "drag", "look", "idle", "yield"],
|
|
166
|
+
"description": "Input action kind."
|
|
167
|
+
},
|
|
168
|
+
"keys": {
|
|
169
|
+
"description": "Keys array or JSON/comma list for tap/hold (e.g. ['w','Space'])."
|
|
170
|
+
},
|
|
171
|
+
"button": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"enum": ["left", "right", "middle"],
|
|
174
|
+
"description": "Mouse button."
|
|
175
|
+
},
|
|
176
|
+
"x": { "type": "number", "description": "Pixel or 0..1 normalized X coordinate." },
|
|
177
|
+
"y": { "type": "number", "description": "Pixel or 0..1 normalized Y coordinate." },
|
|
178
|
+
"x1": { "type": "number", "description": "Drag start X (pixel or 0..1)." },
|
|
179
|
+
"y1": { "type": "number", "description": "Drag start Y (pixel or 0..1)." },
|
|
180
|
+
"x2": { "type": "number", "description": "Drag end X (pixel or 0..1)." },
|
|
181
|
+
"y2": { "type": "number", "description": "Drag end Y (pixel or 0..1)." },
|
|
182
|
+
"dx": { "type": "number", "description": "Relative pointer delta X for look." },
|
|
183
|
+
"dy": { "type": "number", "description": "Relative pointer delta Y for look." },
|
|
184
|
+
"steps": { "type": "number", "description": "Interpolation steps for drag/look." },
|
|
185
|
+
"hold_ms": { "type": "number", "description": "Hold duration in ms." },
|
|
186
|
+
"focus": { "description": "Optional selector to focus before input, or false to skip." }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"prompts": [
|
|
192
|
+
{
|
|
193
|
+
"name": "gamer_playbook",
|
|
194
|
+
"description": "Inspect viewport dimensions and active canvas/focus state, then guide writing a Playbook rule set for CLI `run` or MCP `gamer_play`.",
|
|
195
|
+
"arguments": {
|
|
196
|
+
"type": "object",
|
|
197
|
+
"properties": {
|
|
198
|
+
"goal": {
|
|
199
|
+
"type": "string",
|
|
200
|
+
"description": "Short description of the mission or interactive task."
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"tools": [
|
|
207
|
+
{
|
|
208
|
+
"name": "gamer_play",
|
|
209
|
+
"description": "Runs a bounded ~8-12 Hz local Gate v2.0 vision/NLI playbook loop and returns compacted Run-Length Encoded transitions plus an optional final JPEG frame for LLM re-planning.",
|
|
210
|
+
"requiresSession": true,
|
|
211
|
+
"inputSchema": {
|
|
212
|
+
"type": "object",
|
|
213
|
+
"required": ["rules"],
|
|
214
|
+
"properties": {
|
|
215
|
+
"rules": {
|
|
216
|
+
"type": "array",
|
|
217
|
+
"description": "Playbook rules mapping 'when' conditions to 'do' actions.",
|
|
218
|
+
"items": {
|
|
219
|
+
"type": "object",
|
|
220
|
+
"required": ["when", "do"],
|
|
221
|
+
"properties": {
|
|
222
|
+
"when": { "type": "string" },
|
|
223
|
+
"do": { "type": "object" },
|
|
224
|
+
"min_conf": { "type": "number" },
|
|
225
|
+
"yield": { "type": "boolean" },
|
|
226
|
+
"cooldown_ms": { "type": "number" }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"steps": { "type": "number", "description": "Max decision ticks (1-200, default 30)." },
|
|
231
|
+
"max_ms": { "type": "number", "description": "Max burst duration in ms (200-30000, default 6000)." },
|
|
232
|
+
"interval_ms": { "type": "number", "description": "Loop interval in ms (50-2000, default 100)." },
|
|
233
|
+
"min_conf": { "type": "number", "description": "Minimum confidence (0-1, default 0.45)." },
|
|
234
|
+
"yield_on_low_conf": { "type": "number", "description": "Stop after N consecutive low-confidence ticks." },
|
|
235
|
+
"stop_if": { "type": "string", "description": "Optional Gate yesNo stop condition." },
|
|
236
|
+
"stop_conf": { "type": "number", "description": "Confidence threshold for stop_if (default 0.65)." },
|
|
237
|
+
"stop_check_every": { "type": "number", "description": "Check stop_if every N ticks (default 1)." },
|
|
238
|
+
"clip": { "description": "CSS selector string or {x, y, w, h} crop rect." },
|
|
239
|
+
"text_selector": { "type": "string", "description": "Optional DOM selector for Gate text NLI mode." },
|
|
240
|
+
"focus": { "description": "Selector to focus before starting, or false to skip." },
|
|
241
|
+
"quality": { "type": "number", "description": "JPEG screenshot quality (25-95, default 65)." },
|
|
242
|
+
"return_frame": { "type": "boolean", "description": "Attach final JPEG frame inline (default true)." }
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "gamer_decide",
|
|
248
|
+
"description": "Evaluates a single live frame (or selector text) using Gate v2.0 decide, yesNo, or score to calibrate labels or check state without burning LLM vision tokens.",
|
|
249
|
+
"requiresSession": true,
|
|
250
|
+
"inputSchema": {
|
|
251
|
+
"type": "object",
|
|
252
|
+
"properties": {
|
|
253
|
+
"choices": { "type": "array", "items": { "type": "string" }, "description": "2-64 choice labels." },
|
|
254
|
+
"ask": { "type": "string", "description": "Statement for Gate yesNo." },
|
|
255
|
+
"levels": { "type": "array", "items": { "type": "string" }, "description": "2-64 ordered rubric levels." },
|
|
256
|
+
"clip": { "description": "Optional CSS selector or {x, y, w, h} crop rect." },
|
|
257
|
+
"text_selector": { "type": "string", "description": "Optional DOM selector for Gate text NLI." },
|
|
258
|
+
"quality": { "type": "number", "description": "JPEG quality (25-95, default 65)." },
|
|
259
|
+
"return_frame": { "type": "boolean", "description": "Attach captured JPEG frame inline (default false)." }
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "gamer_act",
|
|
265
|
+
"description": "Dispatches an immediate keyboard, mouse click/hold, drag, or pointer-lock look input via CDP.",
|
|
266
|
+
"requiresSession": true,
|
|
267
|
+
"inputSchema": {
|
|
268
|
+
"type": "object",
|
|
269
|
+
"required": ["type"],
|
|
270
|
+
"properties": {
|
|
271
|
+
"type": {
|
|
272
|
+
"type": "string",
|
|
273
|
+
"enum": ["hold", "tap", "click", "mouse_hold", "drag", "look", "idle", "yield"]
|
|
274
|
+
},
|
|
275
|
+
"keys": { "type": "array", "items": { "type": "string" } },
|
|
276
|
+
"button": { "type": "string", "enum": ["left", "right", "middle"] },
|
|
277
|
+
"x": { "type": "number" },
|
|
278
|
+
"y": { "type": "number" },
|
|
279
|
+
"x1": { "type": "number" },
|
|
280
|
+
"y1": { "type": "number" },
|
|
281
|
+
"x2": { "type": "number" },
|
|
282
|
+
"y2": { "type": "number" },
|
|
283
|
+
"dx": { "type": "number" },
|
|
284
|
+
"dy": { "type": "number" },
|
|
285
|
+
"steps": { "type": "number" },
|
|
286
|
+
"hold_ms": { "type": "number" },
|
|
287
|
+
"focus": { "description": "Optional selector to focus before input, or false to skip." }
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
}
|