autokap 1.5.4 → 1.5.5

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.
@@ -382,16 +382,23 @@ Capture a screenshot of the viewport or a specific element.
382
382
  | `captureId` | string | no | Stable identifier for Studio/dev links. Should match preset page/element id |
383
383
  | `captureName` | string | no | Human-readable label shown in Studio |
384
384
  | `elementSelector` | string | no | CSS selector for element-level capture (crops to element bounds) |
385
+ | `outscale` | OutscaleConfig | no | Padding around the captured element (only applied with `elementSelector`). Typically set by the user post-generation. Omit by default. |
385
386
 
386
387
  **Can:** Full-page viewport capture, element-level capture (cropped), LLM verification (detects blank/error/loading/overlay states), alt text generation, favicon extraction.
387
388
  **Cannot:** Capture content below the fold in a single shot (use SCROLL first). Capture cross-origin iframe content.
388
389
 
389
390
  **Tip:** Without `elementSelector`, captures the full viewport. With `elementSelector`, captures only that element's bounding box — useful for component-level screenshots.
390
391
 
392
+ **`outscale` shape:** all fields optional. `padding` is uniform (pixels). `paddingTop/Right/Bottom/Left` override per side. `paddingPercent` (0–100) scales with the element. `clampToViewport` (default `true`) prevents the crop from exceeding the document. `backgroundColor` fills any uncovered area.
393
+
391
394
  ```json
392
395
  { "kind": "CAPTURE_SCREENSHOT", "captureId": "dashboard-main", "captureName": "Dashboard", "elementSelector": "[data-ak=\"main-content\"]", "postcondition": { "type": "always" } }
393
396
  ```
394
397
 
398
+ ```json
399
+ { "kind": "CAPTURE_SCREENSHOT", "captureName": "Pricing card", "elementSelector": "[data-ak=\"pricing\"]", "outscale": { "padding": 24 }, "postcondition": { "type": "always" } }
400
+ ```
401
+
395
402
  ## BEGIN_CLIP
396
403
 
397
404
  Start recording a clip. All interactions between BEGIN_CLIP and END_CLIP are recorded.
@@ -163,7 +163,7 @@ interface VariantSpec {
163
163
  | `SET_THEME` | no | `theme`, `method`, `storageHints?` | `always` | Use `"$variant"`. Prefer `method: "storage"` |
164
164
  | `ASSERT_ROUTE` | no | `urlPattern` | `route_matches` | Validation checkpoint |
165
165
  | `ASSERT_SURFACE` | no | `selectors[]`, `matchAll` | `always` | Validation checkpoint |
166
- | `CAPTURE_SCREENSHOT` | no | `captureId`, `captureName`, `elementSelector?` | `always` | `elementSelector` for element-level crop |
166
+ | `CAPTURE_SCREENSHOT` | no | `captureId`, `captureName`, `elementSelector?`, `outscale?` | `always` | `elementSelector` for element-level crop. `outscale` adds padding around the element (user-edited post-generation; omit by default) |
167
167
  | `BEGIN_CLIP` | no | `clipId`, `clipName` | `always` | Start recording |
168
168
  | `END_CLIP` | no | `clipId`, `clipName` | `always` | Stop recording. Same `clipId` as BEGIN_CLIP |
169
169
  | `CLONE_ELEMENT` | yes | `sourceSelector`, `containerSelector`, `count` | `always` | **Non-blocking.** Duplicate a template element N times |
@@ -29,6 +29,16 @@ export declare const RecoveryPolicySchema: z.ZodObject<{
29
29
  allowReload: z.ZodBoolean;
30
30
  allowHealer: z.ZodBoolean;
31
31
  }, z.core.$strict>;
32
+ export declare const OutscaleConfigSchema: z.ZodObject<{
33
+ padding: z.ZodOptional<z.ZodNumber>;
34
+ paddingTop: z.ZodOptional<z.ZodNumber>;
35
+ paddingRight: z.ZodOptional<z.ZodNumber>;
36
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
37
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
38
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
39
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
40
+ backgroundColor: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strict>;
32
42
  export declare const ExecutionOpcodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
33
43
  url: z.ZodString;
34
44
  description: z.ZodString;
@@ -495,6 +505,16 @@ export declare const ExecutionOpcodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject
495
505
  captureId: z.ZodOptional<z.ZodString>;
496
506
  captureName: z.ZodOptional<z.ZodString>;
497
507
  elementSelector: z.ZodOptional<z.ZodString>;
508
+ outscale: z.ZodOptional<z.ZodObject<{
509
+ padding: z.ZodOptional<z.ZodNumber>;
510
+ paddingTop: z.ZodOptional<z.ZodNumber>;
511
+ paddingRight: z.ZodOptional<z.ZodNumber>;
512
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
513
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
514
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
515
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
516
+ backgroundColor: z.ZodOptional<z.ZodString>;
517
+ }, z.core.$strict>>;
498
518
  description: z.ZodString;
499
519
  postcondition: z.ZodObject<{
500
520
  type: z.ZodEnum<{
@@ -1688,6 +1708,16 @@ export declare const ExecutionProgramSchema: z.ZodObject<{
1688
1708
  captureId: z.ZodOptional<z.ZodString>;
1689
1709
  captureName: z.ZodOptional<z.ZodString>;
1690
1710
  elementSelector: z.ZodOptional<z.ZodString>;
1711
+ outscale: z.ZodOptional<z.ZodObject<{
1712
+ padding: z.ZodOptional<z.ZodNumber>;
1713
+ paddingTop: z.ZodOptional<z.ZodNumber>;
1714
+ paddingRight: z.ZodOptional<z.ZodNumber>;
1715
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
1716
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
1717
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
1718
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
1719
+ backgroundColor: z.ZodOptional<z.ZodString>;
1720
+ }, z.core.$strict>>;
1691
1721
  description: z.ZodString;
1692
1722
  postcondition: z.ZodObject<{
1693
1723
  type: z.ZodEnum<{
@@ -2665,6 +2695,16 @@ export declare const HealerPatchSchema: z.ZodObject<{
2665
2695
  captureId: z.ZodOptional<z.ZodString>;
2666
2696
  captureName: z.ZodOptional<z.ZodString>;
2667
2697
  elementSelector: z.ZodOptional<z.ZodString>;
2698
+ outscale: z.ZodOptional<z.ZodObject<{
2699
+ padding: z.ZodOptional<z.ZodNumber>;
2700
+ paddingTop: z.ZodOptional<z.ZodNumber>;
2701
+ paddingRight: z.ZodOptional<z.ZodNumber>;
2702
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
2703
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
2704
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
2705
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
2706
+ backgroundColor: z.ZodOptional<z.ZodString>;
2707
+ }, z.core.$strict>>;
2668
2708
  description: z.ZodString;
2669
2709
  postcondition: z.ZodObject<{
2670
2710
  type: z.ZodEnum<{
@@ -3588,6 +3628,16 @@ export declare const HealerPatchSchema: z.ZodObject<{
3588
3628
  captureId: z.ZodOptional<z.ZodString>;
3589
3629
  captureName: z.ZodOptional<z.ZodString>;
3590
3630
  elementSelector: z.ZodOptional<z.ZodString>;
3631
+ outscale: z.ZodOptional<z.ZodObject<{
3632
+ padding: z.ZodOptional<z.ZodNumber>;
3633
+ paddingTop: z.ZodOptional<z.ZodNumber>;
3634
+ paddingRight: z.ZodOptional<z.ZodNumber>;
3635
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
3636
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
3637
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
3638
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
3639
+ backgroundColor: z.ZodOptional<z.ZodString>;
3640
+ }, z.core.$strict>>;
3591
3641
  description: z.ZodString;
3592
3642
  postcondition: z.ZodObject<{
3593
3643
  type: z.ZodEnum<{
@@ -4610,6 +4660,16 @@ export declare function safeParseProgramResult(data: unknown): z.ZodSafeParseRes
4610
4660
  captureId?: string | undefined;
4611
4661
  captureName?: string | undefined;
4612
4662
  elementSelector?: string | undefined;
4663
+ outscale?: {
4664
+ padding?: number | undefined;
4665
+ paddingTop?: number | undefined;
4666
+ paddingRight?: number | undefined;
4667
+ paddingBottom?: number | undefined;
4668
+ paddingLeft?: number | undefined;
4669
+ paddingPercent?: number | undefined;
4670
+ clampToViewport?: boolean | undefined;
4671
+ backgroundColor?: string | undefined;
4672
+ } | undefined;
4613
4673
  stepId?: string | undefined;
4614
4674
  } | {
4615
4675
  description: string;
@@ -242,12 +242,23 @@ const ScrollOpcodeSchema = z.object({
242
242
  targetSelector: z.string().optional(),
243
243
  target: SemanticTargetSchema.optional(),
244
244
  }).strict();
245
+ export const OutscaleConfigSchema = z.object({
246
+ padding: z.number().min(0).optional(),
247
+ paddingTop: z.number().min(0).optional(),
248
+ paddingRight: z.number().min(0).optional(),
249
+ paddingBottom: z.number().min(0).optional(),
250
+ paddingLeft: z.number().min(0).optional(),
251
+ paddingPercent: z.number().min(0).max(100).optional(),
252
+ clampToViewport: z.boolean().optional(),
253
+ backgroundColor: z.string().optional(),
254
+ }).strict();
245
255
  const CaptureScreenshotOpcodeSchema = z.object({
246
256
  kind: z.literal('CAPTURE_SCREENSHOT'),
247
257
  ...opcodeBase,
248
258
  captureId: z.string().optional(),
249
259
  captureName: z.string().optional(),
250
260
  elementSelector: z.string().optional(),
261
+ outscale: OutscaleConfigSchema.optional(),
251
262
  }).strict();
252
263
  const BeginClipOpcodeSchema = z.object({
253
264
  kind: z.literal('BEGIN_CLIP'),
@@ -4,7 +4,7 @@
4
4
  * All types for the compiled execution model:
5
5
  * preset (natural language) -> ExecutionProgram (typed IR) -> deterministic runtime
6
6
  */
7
- import type { AKTree, BrowserStorageState, BrowserSessionStorageState, VideoCursorTheme, VideoPageSignals } from './types.js';
7
+ import type { AKTree, BrowserStorageState, BrowserSessionStorageState, OutscaleConfig, VideoCursorTheme, VideoPageSignals } from './types.js';
8
8
  import type { MockupOptions } from './mockup.js';
9
9
  /** Sentinel value that resolves to the current variant's locale or theme at runtime */
10
10
  export declare const VARIANT_PLACEHOLDER: "$variant";
@@ -247,6 +247,8 @@ export interface CaptureScreenshotOpcode extends OpcodeBase {
247
247
  captureName?: string;
248
248
  /** Optional element selector for element-level capture */
249
249
  elementSelector?: string;
250
+ /** Optional padding around the captured element. Only applied when `elementSelector` is set. */
251
+ outscale?: OutscaleConfig;
250
252
  }
251
253
  export interface BeginClipOpcode extends OpcodeBase {
252
254
  kind: 'BEGIN_CLIP';
@@ -809,7 +811,7 @@ export interface RuntimeAdapter {
809
811
  method: string | null;
810
812
  }>;
811
813
  takeScreenshot(): Promise<Buffer>;
812
- takeElementScreenshot?(selector: string): Promise<Buffer>;
814
+ takeElementScreenshot?(selector: string, outscale?: OutscaleConfig): Promise<Buffer>;
813
815
  takeCleanScreenshot(): Promise<Buffer>;
814
816
  beginRecording(options: RecordingOptions): Promise<void>;
815
817
  endRecording(): Promise<RecordingResult>;
@@ -545,7 +545,7 @@ async function executeOpcodeAction(opcode, opcodeIndex, adapter, artifacts, tele
545
545
  const captureUrl = await adapter.getCurrentUrl();
546
546
  const takeBuffer = async () => {
547
547
  if (opcode.elementSelector && adapter.takeElementScreenshot) {
548
- return adapter.takeElementScreenshot(opcode.elementSelector);
548
+ return adapter.takeElementScreenshot(opcode.elementSelector, opcode.outscale);
549
549
  }
550
550
  if (opcode.elementSelector) {
551
551
  throw new Error(`element capture requires adapter support for selector "${opcode.elementSelector}"`);
@@ -608,6 +608,16 @@ export declare const SignedExecutionProgramEnvelopeSchema: z.ZodObject<{
608
608
  captureId: z.ZodOptional<z.ZodString>;
609
609
  captureName: z.ZodOptional<z.ZodString>;
610
610
  elementSelector: z.ZodOptional<z.ZodString>;
611
+ outscale: z.ZodOptional<z.ZodObject<{
612
+ padding: z.ZodOptional<z.ZodNumber>;
613
+ paddingTop: z.ZodOptional<z.ZodNumber>;
614
+ paddingRight: z.ZodOptional<z.ZodNumber>;
615
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
616
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
617
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
618
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
619
+ backgroundColor: z.ZodOptional<z.ZodString>;
620
+ }, z.core.$strict>>;
611
621
  description: z.ZodString;
612
622
  postcondition: z.ZodObject<{
613
623
  type: z.ZodEnum<{
@@ -634,6 +634,16 @@ export declare const VideoIngestPayloadSchema: z.ZodObject<{
634
634
  captureId: z.ZodOptional<z.ZodString>;
635
635
  captureName: z.ZodOptional<z.ZodString>;
636
636
  elementSelector: z.ZodOptional<z.ZodString>;
637
+ outscale: z.ZodOptional<z.ZodObject<{
638
+ padding: z.ZodOptional<z.ZodNumber>;
639
+ paddingTop: z.ZodOptional<z.ZodNumber>;
640
+ paddingRight: z.ZodOptional<z.ZodNumber>;
641
+ paddingBottom: z.ZodOptional<z.ZodNumber>;
642
+ paddingLeft: z.ZodOptional<z.ZodNumber>;
643
+ paddingPercent: z.ZodOptional<z.ZodNumber>;
644
+ clampToViewport: z.ZodOptional<z.ZodBoolean>;
645
+ backgroundColor: z.ZodOptional<z.ZodString>;
646
+ }, z.core.$strict>>;
637
647
  description: z.ZodString;
638
648
  postcondition: z.ZodObject<{
639
649
  type: z.ZodEnum<{
@@ -5,7 +5,7 @@
5
5
  * This is the first (and for now only) RuntimeAdapter implementation.
6
6
  */
7
7
  import type { Browser } from './browser.js';
8
- import type { AKTree, VideoPageSignals } from './types.js';
8
+ import type { AKTree, OutscaleConfig, VideoPageSignals } from './types.js';
9
9
  import type { RuntimeAdapter, ClickOptions, WaitCondition, RecordingOptions, RecordingResult, SemanticTarget } from './execution-types.js';
10
10
  import { type ResolveOptions } from './semantic-resolver.js';
11
11
  export declare class WebPlaywrightLocal implements RuntimeAdapter {
@@ -63,7 +63,7 @@ export declare class WebPlaywrightLocal implements RuntimeAdapter {
63
63
  method: string | null;
64
64
  }>;
65
65
  takeScreenshot(): Promise<Buffer>;
66
- takeElementScreenshot(selector: string): Promise<Buffer>;
66
+ takeElementScreenshot(selector: string, outscale?: OutscaleConfig): Promise<Buffer>;
67
67
  takeCleanScreenshot(): Promise<Buffer>;
68
68
  beginRecording(options: RecordingOptions): Promise<void>;
69
69
  getElementBoundingBox(selector: string): Promise<{
@@ -316,8 +316,8 @@ export class WebPlaywrightLocal {
316
316
  async takeScreenshot() {
317
317
  return this.browser.takeScreenshot();
318
318
  }
319
- async takeElementScreenshot(selector) {
320
- const { buffer } = await this.browser.screenshotBySelector(selector);
319
+ async takeElementScreenshot(selector, outscale) {
320
+ const { buffer } = await this.browser.screenshotBySelector(selector, outscale);
321
321
  return buffer;
322
322
  }
323
323
  async takeCleanScreenshot() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autokap",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "AI-powered CLI tool for capturing clean screenshots of websites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",