captchakraken 5.0.0-beta.42 → 5.0.0-beta.43

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.
@@ -54,6 +54,13 @@ export interface VendorSelectors {
54
54
  readonly board?: readonly string[];
55
55
  /** Inside the widget: the piece, measured to steer the slide and dragged directly when there is no track. */
56
56
  readonly piece?: readonly string[];
57
+ /**
58
+ * Inside the widget: picture strips a slide rolls by their background (DingXiang's restore bands). Which strip rolls,
59
+ * and how far per handle pixel, are dealt per board and cannot be seen in the picture, so each strip's background
60
+ * offset is read while the handle moves and the slide stops when the one that rolls has rolled as far as the
61
+ * answer's two points are apart.
62
+ */
63
+ readonly band?: readonly string[];
57
64
  /** Inside the widget: the control that deals a new puzzle, pressed when the model answers `refresh`. */
58
65
  readonly refresh?: readonly string[];
59
66
  /**
package/dist/selectors.js CHANGED
@@ -26,7 +26,7 @@ const GENERIC = ['submit_text', 'text_input', 'slider_handle', 'piece', 'feedbac
26
26
  // The file is spelled as the Python port's fields; these three are camelCase here.
27
27
  const CAMEL = { text_input: 'textInput', slider_handle: 'sliderHandle', hold_completes: 'holdCompletes' };
28
28
  const FIELDS = ['hosts', 'challenge', 'checkbox', 'enclave', 'widget', 'response', 'checked', 'box', 'accepted', 'fresh',
29
- 'images', 'tiles', 'submit', 'banners', 'blocked', 'passive', 'text_input', 'slider_handle', 'bar', 'board', 'piece', 'refresh', 'hold_completes'];
29
+ 'images', 'tiles', 'submit', 'banners', 'blocked', 'passive', 'text_input', 'slider_handle', 'bar', 'board', 'piece', 'band', 'refresh', 'hold_completes'];
30
30
  const ONE = new Set(['response', 'checked', 'accepted', 'fresh']);
31
31
  const BANNERS = new Set(Object.values(kinds_1.RecaptchaBanner));
32
32
  const VENDOR_VALUES = new Set(Object.values(kinds_1.Vendor));
package/dist/solver.d.ts CHANGED
@@ -26,6 +26,23 @@ export interface Widget {
26
26
  * `boundingBox` is the union everywhere the round reads it; everything else is the element's own.
27
27
  */
28
28
  export declare function withAnswerBox(el: ElementHandle, box: ElementHandle, maxGrowth?: number): ElementHandle;
29
+ /** One read of a `band` strip: how far its picture sits right of where it started (background offset plus box), its rows, and the width its picture repeats at. */
30
+ export interface BandRead {
31
+ x: number;
32
+ top: number;
33
+ bottom: number;
34
+ period: number;
35
+ }
36
+ /**
37
+ * How far the band that rolled must roll in all, in CSS px, for the answer's two points to meet; null when no band
38
+ * rolled. The answer names a point on one band and where it belongs on the other. When the point's own band rolls it
39
+ * travels to the target; when the target's band rolls the target travels to the point. A band repeats, so the roll
40
+ * is taken the way the probe showed it going, within one turn of its picture.
41
+ */
42
+ export declare function bandRoll(rest: readonly BandRead[], now: readonly BandRead[], seed: readonly [number, number], goal: readonly [number, number]): {
43
+ band: number;
44
+ roll: number;
45
+ } | null;
29
46
  /** An allow-list of what needs nothing: the other direction raises instead of clicking at the origin. */
30
47
  export declare function answerNeedsElementBox(actions: ReadonlyArray<{
31
48
  action?: string;
@@ -456,12 +473,28 @@ export declare class CaptchaKrakenSolver {
456
473
  private executeType;
457
474
  /** One look of the slide loop (`slide_tracker.py` behind the CV worker); null when the part cannot be followed. */
458
475
  private slideStep;
476
+ /** The vendor's `band` strips inside the widget, in table order; none for a vendor that names none. */
477
+ private bandsOf;
478
+ /** Where each band's picture sits now (`BandRead`), in page CSS px. */
479
+ private readBands;
480
+ /** Which band the probe rolled and how far it must roll in all (`bandRoll`); a zero is read again before it is believed. */
481
+ private bandRolling;
482
+ /**
483
+ * One look of the slide loop for a band, in the tracker's terms (shot pixels): how far the rolling band has gone
484
+ * against how far it must, and the travel that closes the gap at the roll per handle pixel seen so far.
485
+ */
486
+ private bandStep;
459
487
  private shotScale;
460
488
  /**
461
489
  * Press the handle, nudge it to see what it moves, then steer that part's point onto its target. Release is the submit.
462
490
  * A generation-3 answer names all three points, so nothing is read from the page but pixels. A generation-2 answer
463
491
  * names only the target: its handle comes from the selector table and the part it moves is whatever moved most.
464
492
  * That path goes when the last generation-2 model does.
493
+ *
494
+ * A vendor that names `band`s (DingXiang's restore) is steered by the DOM instead: the handle rolls one of two
495
+ * picture strips, which one and how far per handle pixel are dealt per board, and the answer's point sits on one
496
+ * strip and its target on the other, so there is no single moving part for pixels to follow. The strips'
497
+ * background offsets say exactly how far the one that rolls has gone.
465
498
  */
466
499
  private executeSlide;
467
500
  }
package/dist/solver.js CHANGED
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CaptchaKrakenSolver = exports.SOLVE_DEFAULTS = exports.HOLD_MAX_MS = exports.HOLD_SETTLE_MS = exports.GRID_LOAD_CAP_FACTOR = exports.IDLE_DRIFT_PX = exports.IDLE_DRIFT_EVERY_MS = exports.INPUT_SETTLE_MS = void 0;
37
37
  exports.withAnswerBox = withAnswerBox;
38
+ exports.bandRoll = bandRoll;
38
39
  exports.answerNeedsElementBox = answerNeedsElementBox;
39
40
  exports.isStaleHandleError = isStaleHandleError;
40
41
  exports.isClosedTargetError = isClosedTargetError;
@@ -191,6 +192,37 @@ const SLIDE_PROBE_PX = 8;
191
192
  // pushing on only carries the pointer away from the handle. Mirrors page_solver.py SLIDE_STALL_PX.
192
193
  const SLIDE_STALL_PX = 1;
193
194
  const slideOffset = (s) => (Array.isArray(s) ? [s[0], s[1]] : [s, 0]);
195
+ // A band whose background moved less than this (CSS px) did not roll. The first drag after a reload can leave every
196
+ // band where it was, so a zero is read twice before it is believed.
197
+ const BAND_STILL_PX = 0.5;
198
+ /**
199
+ * How far the band that rolled must roll in all, in CSS px, for the answer's two points to meet; null when no band
200
+ * rolled. The answer names a point on one band and where it belongs on the other. When the point's own band rolls it
201
+ * travels to the target; when the target's band rolls the target travels to the point. A band repeats, so the roll
202
+ * is taken the way the probe showed it going, within one turn of its picture.
203
+ */
204
+ function bandRoll(rest, now, seed, goal) {
205
+ let band = -1;
206
+ let moved = 0;
207
+ now.forEach((b, i) => {
208
+ const d = b.x - (rest[i]?.x ?? b.x);
209
+ if (Math.abs(d) > Math.abs(moved)) {
210
+ band = i;
211
+ moved = d;
212
+ }
213
+ });
214
+ if (band < 0 || Math.abs(moved) < BAND_STILL_PX)
215
+ return null;
216
+ const b = now[band];
217
+ const on = (y) => y >= b.top && y < b.bottom;
218
+ let roll = on(goal[1]) && !on(seed[1]) ? seed[0] - goal[0] : goal[0] - seed[0];
219
+ if (b.period > 0) {
220
+ roll = ((roll % b.period) + b.period) % b.period;
221
+ if (moved < 0 && roll > 0)
222
+ roll -= b.period;
223
+ }
224
+ return { band, roll };
225
+ }
194
226
  /** Did the handle travel while the part stayed put? Each side is the travel and the part's point of one look. */
195
227
  const slideStalled = (before, now, k) => {
196
228
  const [ax, ay] = slideOffset(before[0]);
@@ -1089,7 +1121,7 @@ class CaptchaKrakenSolver {
1089
1121
  await this.emitStep(captchaElement, kinds_1.SolveStage.CLICK, `clicked ${bboxes.length || 1} target(s)`, puzzleSource, frameRole, attempt, { bboxes });
1090
1122
  }
1091
1123
  else if (action.action === kinds_1.ActionKind.SLIDE || (action.action === kinds_1.ActionKind.DRAG && !action.source_bounding_box)) {
1092
- if (await this.executeSlide(page, captchaElement, scope, action, requireBox())) {
1124
+ if (await this.executeSlide(page, captchaElement, scope, action, requireBox(), puzzleSource)) {
1093
1125
  performedAction = slid = true;
1094
1126
  await this.emitStep(captchaElement, kinds_1.SolveStage.DRAG, 'slid the piece into the slot', puzzleSource, frameRole, attempt, { action });
1095
1127
  }
@@ -3124,6 +3156,52 @@ class CaptchaKrakenSolver {
3124
3156
  }
3125
3157
  return res;
3126
3158
  }
3159
+ /** The vendor's `band` strips inside the widget, in table order; none for a vendor that names none. */
3160
+ async bandsOf(scope, vendor) {
3161
+ const own = this.sel.selectors[vendor]?.band;
3162
+ return own?.length ? handles(await visible(scope, own)).catch(() => []) : [];
3163
+ }
3164
+ /** Where each band's picture sits now (`BandRead`), in page CSS px. */
3165
+ async readBands(bands) {
3166
+ return Promise.all(bands.map(async (band) => {
3167
+ const box = await band.boundingBox().catch(() => null);
3168
+ const [x, period] = await band.evaluate((el) => {
3169
+ const cs = getComputedStyle(el);
3170
+ const px = (v) => (/^-?[\d.]+px/.test(v.trim()) ? parseFloat(v) : 0);
3171
+ return [px(cs.backgroundPositionX), px(cs.backgroundSize.split(/[\s,]/)[0] ?? '')];
3172
+ }).catch(() => [0, 0]);
3173
+ return { x: x + (box?.x ?? 0), top: box?.y ?? 0, bottom: (box?.y ?? 0) + (box?.height ?? 0), period: period || (box?.width ?? 0) };
3174
+ }));
3175
+ }
3176
+ /** Which band the probe rolled and how far it must roll in all (`bandRoll`); a zero is read again before it is believed. */
3177
+ async bandRolling(bands, rest, seed, goal) {
3178
+ let rolling = bandRoll(rest, await this.readBands(bands), seed, goal);
3179
+ if (!rolling) {
3180
+ await this.human.pause(kinds_1.PauseKind.PROBE);
3181
+ rolling = bandRoll(rest, await this.readBands(bands), seed, goal);
3182
+ }
3183
+ if (rolling)
3184
+ console.log(`[slide] band ${rolling.band + 1} of ${bands.length} rolls; it must roll ${rolling.roll.toFixed(1)}px`);
3185
+ else
3186
+ console.warn('[slide] no band rolled with the handle; steering by pixels');
3187
+ return rolling;
3188
+ }
3189
+ /**
3190
+ * One look of the slide loop for a band, in the tracker's terms (shot pixels): how far the rolling band has gone
3191
+ * against how far it must, and the travel that closes the gap at the roll per handle pixel seen so far.
3192
+ */
3193
+ async bandStep(bands, rest, rolling, s, rolled, k, ask) {
3194
+ const d = ((await this.readBands(bands))[rolling.band].x - rest[rolling.band].x) * k;
3195
+ rolled.push([s, d]);
3196
+ const ss = rolled.reduce((a, [t]) => a + t * t, 0);
3197
+ const slope = ss > 0 ? rolled.reduce((a, [t, m]) => a + t * m, 0) / ss : 0;
3198
+ const gap = rolling.roll * k - d;
3199
+ const next = slope ? Math.min(Math.max(s + gap / slope, ask.bounds[0]), ask.bounds[1]) : s;
3200
+ return {
3201
+ pos: [ask.seed[0] + d, ask.seed[1]], params: [0, d, 0], error: Math.abs(gap), grabbed: false, kind: 'slide', next,
3202
+ done: Math.abs(gap) <= ask.tol, correlation: 1, observation: { s, params: [0, d, 0] },
3203
+ };
3204
+ }
3127
3205
  shotScale(shot, cssWidth) {
3128
3206
  const dims = readPngDimensions(shot);
3129
3207
  return dims && cssWidth > 0 ? dims.width / cssWidth : 1;
@@ -3133,8 +3211,13 @@ class CaptchaKrakenSolver {
3133
3211
  * A generation-3 answer names all three points, so nothing is read from the page but pixels. A generation-2 answer
3134
3212
  * names only the target: its handle comes from the selector table and the part it moves is whatever moved most.
3135
3213
  * That path goes when the last generation-2 model does.
3214
+ *
3215
+ * A vendor that names `band`s (DingXiang's restore) is steered by the DOM instead: the handle rolls one of two
3216
+ * picture strips, which one and how far per handle pixel are dealt per board, and the answer's point sits on one
3217
+ * strip and its target on the other, so there is no single moving part for pixels to follow. The strips'
3218
+ * background offsets say exactly how far the one that rolls has gone.
3136
3219
  */
3137
- async executeSlide(page, element, scope, action, elementBox) {
3220
+ async executeSlide(page, element, scope, action, elementBox, vendor) {
3138
3221
  this.actedOnBoard = true;
3139
3222
  const { width: w, height: h } = elementBox;
3140
3223
  const at = (b) => [((b[0] + b[2]) / 2) * w, ((b[1] + b[3]) / 2) * h];
@@ -3161,10 +3244,12 @@ class CaptchaKrakenSolver {
3161
3244
  const probe = goal[0] >= (seed ?? handle)[0] ? SLIDE_PROBE_PX : -SLIDE_PROBE_PX;
3162
3245
  const timeout = this.config.elementScreenshotTimeoutMs ?? 8000;
3163
3246
  const [first, probed, current] = [tmp('slide_0'), tmp('slide_1'), tmp('slide_2')];
3247
+ const bands = seed && vendor ? await this.bandsOf(scope, vendor) : [];
3164
3248
  try {
3165
3249
  await this.performSmoothMove(page, ...press);
3166
3250
  await this.human.press(page);
3167
3251
  await this.human.pause(kinds_1.PauseKind.GRAB);
3252
+ const rest = bands.length ? await this.readBands(bands) : null;
3168
3253
  await this.shot(element, first, timeout);
3169
3254
  const k = this.shotScale(first, w);
3170
3255
  await this.performSmoothMove(page, press[0] + probe, press[1]);
@@ -3174,12 +3259,17 @@ class CaptchaKrakenSolver {
3174
3259
  first, probe: probed, probe_s: probe * k, goal: [goal[0] * k, goal[1] * k], seed: seed && [seed[0] * k, seed[1] * k],
3175
3260
  handle: [handle[0] * k, handle[1] * k], bounds: [-handle[0] * k, (w - handle[0]) * k], tol: SLIDE_TOLERANCE_PX * k,
3176
3261
  };
3262
+ const page_ = (p) => [elementBox.x + p[0], elementBox.y + p[1]];
3263
+ const rolling = rest && seed ? await this.bandRolling(bands, rest, page_(seed), page_(goal)) : null;
3177
3264
  let look = probed;
3178
3265
  let s = probe * k;
3179
3266
  const history = [];
3267
+ const rolled = [];
3180
3268
  let last = null;
3181
3269
  for (let moves = 0;; moves++) {
3182
- const reply = await this.slideStep({ ...ask, current: look, s, history });
3270
+ const reply = rolling
3271
+ ? await this.bandStep(bands, rest, rolling, s, rolled, k, { ...ask, seed: ask.seed })
3272
+ : await this.slideStep({ ...ask, current: look, s, history });
3183
3273
  if (!reply)
3184
3274
  break;
3185
3275
  if (look !== probed)
@@ -3201,6 +3291,8 @@ class CaptchaKrakenSolver {
3201
3291
  const [dx, dy] = slideOffset(s);
3202
3292
  await this.performSmoothMove(page, press[0] + dx / k, press[1] + dy / k);
3203
3293
  await this.human.pause(kinds_1.PauseKind.PROBE);
3294
+ if (rolling)
3295
+ continue;
3204
3296
  await this.shot(element, current, timeout);
3205
3297
  look = current;
3206
3298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captchakraken",
3
- "version": "5.0.0-beta.42",
3
+ "version": "5.0.0-beta.43",
4
4
  "description": "Captcha solver for Playwright and Puppeteer. Finds the captcha, reads it with the v2 pointer model, and clicks, drags, slides or types through to a token — reCAPTCHA, GeeTest, NetEase Yidun, Tencent, Lemin, Prosopo, Turnstile and distorted text. Hosted API or self-hosted.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "captchakraken"
7
- version = "5.0.0b42"
7
+ version = "5.0.0b43"
8
8
  description = "Captcha-solving engine and CLI: a v2 pointer model for image grids, click and drag puzzles, sliders, distorted text and animated challenges. Hosted API or self-hosted on vLLM."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -100,4 +100,4 @@ __all__ = [
100
100
  "PauseKind",
101
101
  ]
102
102
 
103
- __version__ = "5.0.0b42"
103
+ __version__ = "5.0.0b43"
@@ -50,6 +50,7 @@
50
50
  "board": "Inside the widget's frame or a frame nested in it: the element that is the board itself, when the widget frame pads it. The shot is this element, so the model sees the crop it was trained on.",
51
51
  "bar": "Beside the widget (a sibling of it, or of its parent): a strip the vendor draws outside the widget element that every board carries, such as Yidun's prompt and slider bar. The shot takes it in, so the model sees what it was trained on.",
52
52
  "piece": "Inside the widget: the piece, measured to steer the slide and dragged directly when there is no track.",
53
+ "band": "Inside the widget: picture strips a slide rolls by their background, such as DingXiang's restore bands. Which strip rolls, and how far per handle pixel, are dealt per board and cannot be seen in the picture (see TRIBAL_KNOWLEDGE.md), so each strip's background offset is read while the handle moves, and the slide stops when the strip that rolls has rolled as far as the answer's two points are apart.",
53
54
  "refresh": "Inside the widget: the control that deals a new puzzle, pressed when the model answers `refresh`.",
54
55
  "hold_completes": "A press-and-hold that completes on its own once full, and resets when let go before it has: the fill reaching the answer's `to` is not a release, and the hold lasts until the widget says it is done."
55
56
  },
@@ -363,6 +364,10 @@
363
364
  "slider_handle": [
364
365
  ".dx_captcha_basic_slider",
365
366
  ".dx_captcha_rotate_slider"
367
+ ],
368
+ "band": [
369
+ ".dx_captcha_basic_pic .upper",
370
+ ".dx_captcha_basic_pic .lower"
366
371
  ]
367
372
  },
368
373
  "funcaptcha": {
@@ -515,6 +515,46 @@ def _offset(s: Any) -> Tuple[float, float]:
515
515
  return (float(s[0]), float(s[1])) if isinstance(s, (list, tuple)) else (float(s), 0.0)
516
516
 
517
517
 
518
+ # A band whose background moved less than this (CSS px) did not roll. The first drag after a reload can leave every
519
+ # band where it was, so a zero is read twice before it is believed.
520
+ BAND_STILL_PX = 0.5
521
+
522
+ _BAND_READ_JS = """(el) => {
523
+ const cs = getComputedStyle(el);
524
+ const px = (v) => (/^-?[\\d.]+px/.test((v || '').trim()) ? parseFloat(v) : 0);
525
+ return [px(cs.backgroundPositionX), px((cs.backgroundSize || '').split(/[\\s,]/)[0])];
526
+ }"""
527
+
528
+
529
+ def band_roll(rest: Sequence[Dict[str, float]], now: Sequence[Dict[str, float]], seed: Sequence[float],
530
+ goal: Sequence[float]) -> Optional[Tuple[int, float]]:
531
+ """(which band rolled, how far it must roll in all) in CSS px for the answer's two points to meet; None when none did.
532
+
533
+ Each read is a band's `x` (how far its picture sits right of where it started), its rows `top`..`bottom` and the
534
+ `period` its picture repeats at. The answer names a point on one band and where it belongs on the other. When the
535
+ point's own band rolls it travels to the target; when the target's band rolls the target travels to the point. A
536
+ band repeats, so the roll is taken the way the probe showed it going, within one turn of its picture.
537
+ """
538
+ band, moved = -1, 0.0
539
+ for i, b in enumerate(now):
540
+ d = b["x"] - (rest[i]["x"] if i < len(rest) else b["x"])
541
+ if abs(d) > abs(moved):
542
+ band, moved = i, d
543
+ if band < 0 or abs(moved) < BAND_STILL_PX:
544
+ return None
545
+ b = now[band]
546
+
547
+ def on(y: float) -> bool:
548
+ return b["top"] <= y < b["bottom"]
549
+
550
+ roll = seed[0] - goal[0] if on(goal[1]) and not on(seed[1]) else goal[0] - seed[0]
551
+ if b["period"] > 0:
552
+ roll %= b["period"]
553
+ if moved < 0 and roll > 0:
554
+ roll -= b["period"]
555
+ return band, roll
556
+
557
+
518
558
  def _stalled(before: Tuple[Any, Sequence[float]], now: Tuple[Any, Sequence[float]], k: float) -> bool:
519
559
  """Did the handle travel while the part stayed put? Each side is (travel, the part's point) of one look."""
520
560
  (ax, ay), (bx, by) = _offset(before[0]), _offset(now[0])
@@ -1240,13 +1280,71 @@ class PageSolver:
1240
1280
  dims = _read_png_dimensions(shot)
1241
1281
  return dims[0] / css_width if dims and css_width > 0 else 1.0
1242
1282
 
1283
+ def _bands_of(self, scope: Any, vendor: Optional[Vendor]) -> List[Any]:
1284
+ """The vendor's `band` strips inside the widget, in table order; none for a vendor that names none."""
1285
+ own = getattr(self._sel.selectors.get(vendor), "band", ()) if vendor is not None else ()
1286
+ return _handles(_visible(scope, own)) if own else []
1287
+
1288
+ @staticmethod
1289
+ def _read_bands(bands: Sequence[Any]) -> List[Dict[str, float]]:
1290
+ """Where each band's picture sits now (see `band_roll`), in page CSS px."""
1291
+ out = []
1292
+ for band in bands:
1293
+ try:
1294
+ box = band.bounding_box() or {}
1295
+ except Exception:
1296
+ box = {}
1297
+ try:
1298
+ x, period = band.evaluate(_BAND_READ_JS)
1299
+ except Exception:
1300
+ x, period = 0.0, 0.0
1301
+ top = float(box.get("y", 0.0))
1302
+ out.append({"x": float(x) + float(box.get("x", 0.0)), "top": top,
1303
+ "bottom": top + float(box.get("height", 0.0)),
1304
+ "period": float(period) or float(box.get("width", 0.0))})
1305
+ return out
1306
+
1307
+ def _band_rolling(self, bands: Sequence[Any], rest: Sequence[Dict[str, float]], seed: Sequence[float],
1308
+ goal: Sequence[float]) -> Optional[Tuple[int, float]]:
1309
+ """Which band the probe rolled and how far it must roll in all (`band_roll`); a zero is read again first."""
1310
+ rolling = band_roll(rest, self._read_bands(bands), seed, goal)
1311
+ if rolling is None:
1312
+ self._human.pause(PauseKind.PROBE)
1313
+ rolling = band_roll(rest, self._read_bands(bands), seed, goal)
1314
+ if rolling is not None:
1315
+ _log(f"slider: band {rolling[0] + 1} of {len(bands)} rolls; it must roll {rolling[1]:.1f}px")
1316
+ else:
1317
+ _log("slider: no band rolled with the handle; steering by pixels")
1318
+ return rolling
1319
+
1320
+ def _band_step(self, bands: Sequence[Any], rest: Sequence[Dict[str, float]], rolling: Tuple[int, float],
1321
+ s: float, rolled: List[Tuple[float, float]], k: float, seed: Sequence[float],
1322
+ bounds: Sequence[float], tol: float) -> Dict[str, Any]:
1323
+ """One look of the slide loop for a band, in the tracker's terms (shot pixels): how far the rolling band has
1324
+ gone against how far it must, and the travel that closes the gap at the roll per handle pixel seen so far."""
1325
+ i, roll = rolling
1326
+ d = (self._read_bands(bands)[i]["x"] - rest[i]["x"]) * k
1327
+ rolled.append((s, d))
1328
+ ss = sum(t * t for t, _ in rolled)
1329
+ slope = sum(t * m for t, m in rolled) / ss if ss > 0 else 0.0
1330
+ gap = roll * k - d
1331
+ nxt = min(max(s + gap / slope, bounds[0]), bounds[1]) if slope else s
1332
+ return {"pos": (seed[0] + d, seed[1]), "params": (0.0, d, 0.0), "error": abs(gap), "grabbed": False,
1333
+ "kind": "slide", "next": nxt, "done": abs(gap) <= tol, "correlation": 1.0,
1334
+ "observation": {"s": s, "params": [0.0, d, 0.0]}}
1335
+
1243
1336
  def _execute_slide(self, page: Any, element: Any, scope: Any, action: Dict[str, Any],
1244
- element_box: Dict[str, float]) -> bool:
1337
+ element_box: Dict[str, float], vendor: Optional[Vendor] = None) -> bool:
1245
1338
  """Press the handle, nudge it to see what it moves, then steer that part's point onto its target.
1246
1339
 
1247
1340
  A generation-3 answer names all three points, so nothing is read from the page but pixels. A generation-2
1248
1341
  answer names only the target: its handle comes from the selector table and the part it moves is whatever
1249
1342
  moved most. That path goes when the last generation-2 model does.
1343
+
1344
+ A vendor that names `band`s (DingXiang's restore) is steered by the DOM instead: the handle rolls one of two
1345
+ picture strips, which one and how far per handle pixel are dealt per board, and the answer's point sits on one
1346
+ strip and its target on the other, so there is no single moving part for pixels to follow. The strips'
1347
+ background offsets say exactly how far the one that rolls has gone.
1250
1348
  """
1251
1349
  from .tool_calls.slide_tracker import TrackingError, slide_step
1252
1350
 
@@ -1274,10 +1372,12 @@ class PageSolver:
1274
1372
  probe = SLIDE_PROBE_PX if goal[0] >= (seed or handle)[0] else -SLIDE_PROBE_PX
1275
1373
  timeout = self.config.element_screenshot_timeout_ms
1276
1374
  first, probed, current = (_tmp_png("slide") for _ in range(3))
1375
+ bands = self._bands_of(scope, vendor) if seed is not None else []
1277
1376
  try:
1278
1377
  self._smooth_move(page, *press)
1279
1378
  self._human.press(page)
1280
1379
  self._human.pause(PauseKind.GRAB)
1380
+ rest = self._read_bands(bands) if bands else None
1281
1381
  self._screenshot(element, first, timeout_ms=timeout)
1282
1382
  k = self._shot_scale(first, w)
1283
1383
  self._smooth_move(page, press[0] + probe, press[1])
@@ -1286,11 +1386,18 @@ class PageSolver:
1286
1386
  ask = dict(probe_s=probe * k, goal=(goal[0] * k, goal[1] * k), seed=seed and (seed[0] * k, seed[1] * k),
1287
1387
  handle=(handle[0] * k, handle[1] * k), bounds=(-handle[0] * k, (w - handle[0]) * k),
1288
1388
  tol=self.config.slide_tolerance_px * k)
1389
+ rolling = None
1390
+ if rest is not None:
1391
+ origin = (element_box["x"], element_box["y"])
1392
+ rolling = self._band_rolling(bands, rest, (origin[0] + seed[0], origin[1] + seed[1]),
1393
+ (origin[0] + goal[0], origin[1] + goal[1]))
1289
1394
  look, s, history, moves = probed, probe * k, [], 0
1395
+ rolled: List[Tuple[float, float]] = []
1290
1396
  last: Optional[Tuple[Any, Sequence[float]]] = None
1291
1397
  while True:
1292
1398
  try:
1293
- reply = slide_step(first, probed, look, s=s, history=history, **ask)
1399
+ reply = (self._band_step(bands, rest, rolling, s, rolled, k, ask["seed"], ask["bounds"], ask["tol"])
1400
+ if rolling is not None else slide_step(first, probed, look, s=s, history=history, **ask))
1294
1401
  except TrackingError as exc:
1295
1402
  _log(f"slider: {exc}; released where the handle is")
1296
1403
  break
@@ -1312,8 +1419,10 @@ class PageSolver:
1312
1419
  dx, dy = _offset(s)
1313
1420
  self._smooth_move(page, press[0] + dx / k, press[1] + dy / k)
1314
1421
  self._human.pause(PauseKind.PROBE)
1315
- self._screenshot(element, current, timeout_ms=timeout)
1316
- look, moves = current, moves + 1
1422
+ moves += 1
1423
+ if rolling is None:
1424
+ self._screenshot(element, current, timeout_ms=timeout)
1425
+ look = current
1317
1426
  self._human.pause(PauseKind.SETTLE)
1318
1427
  finally:
1319
1428
  try:
@@ -2508,7 +2617,7 @@ class PageSolver:
2508
2617
  self._human.pause(PauseKind.BETWEEN)
2509
2618
  performed = answered = True
2510
2619
  elif kind == ActionKind.SLIDE or (kind == ActionKind.DRAG and not action.get("source_bounding_box")):
2511
- if self._execute_slide(page, element, scope, action, element_box):
2620
+ if self._execute_slide(page, element, scope, action, element_box, puzzle_source):
2512
2621
  performed = slid = True
2513
2622
  elif kind == ActionKind.DRAG:
2514
2623
  if await_kf:
@@ -66,6 +66,11 @@ class VendorSelectors:
66
66
  board: Sequence[str] = ()
67
67
  # Inside the widget: the piece, measured to steer the slide and dragged directly when there is no track.
68
68
  piece: Sequence[str] = ()
69
+ # Inside the widget: picture strips a slide rolls by their background (DingXiang's restore bands). Which strip
70
+ # rolls, and how far per handle pixel, are dealt per board and cannot be seen in the picture, so each strip's
71
+ # background offset is read while the handle moves and the slide stops when the one that rolls has rolled as far
72
+ # as the answer's two points are apart.
73
+ band: Sequence[str] = ()
69
74
  # Inside the widget: the control that deals a new puzzle, pressed when the model answers `refresh`.
70
75
  refresh: Sequence[str] = ()
71
76
  # A press-and-hold that completes on its own once full, and resets when let go before it has: the fill reaching