@ingcreators/annot-mcp 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @ingcreators/annot-mcp
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b3e8e53: Both packages now accept an optional `encode` option that flows through to `@ingcreators/annot-annotator@0.3.0`'s `toEncoded()` / `decodeAndEncodeImage()` pipeline. Achieves feature parity with the Chrome extension's "Save size" + "Format smart" capture settings for AI-agent (`annot-mcp`) and Playwright-test (`annot-playwright`) flows.
8
+
9
+ ## `annot-playwright`
10
+
11
+ ```ts
12
+ await annotator.annotateScreenshot(page, {
13
+ annotations: [...],
14
+ encode: { format: "smart", saveSizePreset: "standard" },
15
+ });
16
+ ```
17
+
18
+ Returned bytes shrink to PNG-8 / JPEG / resized PNG-32 per the smart heuristic; default behaviour when `encode` is omitted matches v0.2.x (raw PNG-32 from the annotator).
19
+
20
+ ## `annot-mcp`
21
+
22
+ All five tools (`annot_annotate_screenshot`, `annot_annotate_url`, `annot_redact_screenshot`, `annot_redact_url`, `annot_compare_screenshots`) accept the same `encode` shape on their MCP `inputSchema`. Agents can specify any subset:
23
+
24
+ ```jsonc
25
+ {
26
+ "url": "https://...",
27
+ "annotations": [...],
28
+ "encode": {
29
+ "format": "smart",
30
+ "saveSizePreset": "light",
31
+ "smartFallback": "jpeg"
32
+ }
33
+ }
34
+ ```
35
+
36
+ `format`: `"smart"` (default — PNG-8 for UI / PNG / JPEG for photos) / `"png"` / `"jpeg"`.
37
+ `saveSizePreset`: `"light"` 1280px / `"standard"` 1920px / `"highQuality"` 2560px / `"original"` no resize.
38
+ `smartFallback`, `smartColorThreshold`, `jpegPercent` all configurable.
39
+
40
+ Output `mimeType` flips to `image/jpeg` when the chosen path emits JPEG, so MCP clients render inline correctly. The text confirmation when `output` is set now includes the chosen format and any `reason` (`png-8` / `photo-fallback-jpeg` / `imagequant-missing` / …) for observability.
41
+
42
+ Backwards-compatible: when `encode` is omitted, all tools emit PNG-32 bytes verbatim (no decode/encode round-trip, same as v0.1.x / v0.2.x).
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [86d0853]
47
+ - @ingcreators/annot-annotator@0.3.0
48
+
49
+ ## 0.1.1
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [92378f9]
54
+ - @ingcreators/annot-annotator@0.2.0
55
+
3
56
  ## 0.1.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -17,18 +17,14 @@ browser-driven workflows:
17
17
  single MCP call; the server handles capture + locator
18
18
  resolution + render.
19
19
 
20
- > **Status:** under construction. Phases 1–5 + 7 of
21
- > [`docs/plans/agent-mcp-integration.md`](../../docs/plans/agent-mcp-integration.md)
22
- > have landed; the package is `private: true` in the workspace
23
- > until Phase 8 (gated on
24
- > [`docs/plans/headless-annotator-publish.md`](../../docs/plans/headless-annotator-publish.md))
25
- > flips it for the first npm publish. Phase 6 (PPTX export) is
26
- > deferred indefinitely per the plan.
20
+ > Phase 6 (PPTX export) is deferred indefinitely per the
21
+ > design plan in
22
+ > [`docs/plans/_done/agent-mcp-integration.md`](../../docs/plans/_done/agent-mcp-integration.md),
23
+ > pending the `pptx-export` `ImageRecord[]`-driven refactor noted
24
+ > in [`CLAUDE.md`](../../CLAUDE.md) §2.
27
25
 
28
26
  ## Installation
29
27
 
30
- After Phase 8 publish:
31
-
32
28
  ```sh
33
29
  # Once globally (or via npx per-call)
34
30
  npm install -g @ingcreators/annot-mcp
@@ -329,7 +325,7 @@ The agent sees these as MCP tool errors and can correct + retry.
329
325
  - [`docs/ai-agents.md`](../../docs/ai-agents.md) — short intro
330
326
  guide + "which doc do I want?" map; start here if you're new
331
327
  to the MCP integration.
332
- - [`docs/plans/agent-mcp-integration.md`](../../docs/plans/agent-mcp-integration.md)
328
+ - [`docs/plans/_done/agent-mcp-integration.md`](../../docs/plans/_done/agent-mcp-integration.md)
333
329
  — full design + phase ledger.
334
330
  - [`@ingcreators/annot-annotator`](../annotator/README.md) — the
335
331
  underlying Tier A headless renderer.
@@ -1,7 +1,15 @@
1
- /** Common shared subschemas referenced from `$defs` in each tool's
2
- * inputSchema. Spread these into the tool's `$defs` object at
3
- * registration time. */
1
+ export { BBOX_ANNOTATION_SCHEMA, BBOX_REDACT_REGION_SCHEMA, } from '@ingcreators/annot-annotator';
2
+ /**
3
+ * `$defs` to spread into every MCP tool inputSchema. Combines the
4
+ * annotator's bbox-flavour `SHARED_DEFS` (`BBox`, `Point`,
5
+ * `Intent`, `AnnotationStyle`) with the mcp-only `Locator` shape
6
+ * referenced by every `LOCATOR_*` schema in this file.
7
+ */
4
8
  export declare const SHARED_DEFS: {
9
+ Locator: {
10
+ type: string;
11
+ minLength: number;
12
+ };
5
13
  BBox: {
6
14
  type: string;
7
15
  required: string[];
@@ -62,184 +70,9 @@ export declare const SHARED_DEFS: {
62
70
  };
63
71
  };
64
72
  };
65
- Locator: {
66
- type: string;
67
- minLength: number;
68
- };
69
- };
70
- export declare const BBOX_ANNOTATION_SCHEMA: {
71
- oneOf: ({
72
- type: string;
73
- required: string[];
74
- additionalProperties: boolean;
75
- properties: {
76
- type: {
77
- const: string;
78
- };
79
- bbox: {
80
- $ref: string;
81
- };
82
- intent: {
83
- $ref: string;
84
- };
85
- stroke: {
86
- type: string;
87
- };
88
- strokeWidth: {
89
- type: string;
90
- minimum: number;
91
- };
92
- fill: {
93
- type: string;
94
- };
95
- color: {
96
- type: string;
97
- };
98
- };
99
- } | {
100
- type: string;
101
- required: string[];
102
- additionalProperties: boolean;
103
- properties: {
104
- type: {
105
- const: string;
106
- };
107
- center: {
108
- $ref: string;
109
- };
110
- radius: {
111
- type: string;
112
- minimum: number;
113
- };
114
- intent: {
115
- $ref: string;
116
- };
117
- stroke: {
118
- type: string;
119
- };
120
- strokeWidth: {
121
- type: string;
122
- minimum: number;
123
- };
124
- fill: {
125
- type: string;
126
- };
127
- color: {
128
- type: string;
129
- };
130
- };
131
- } | {
132
- type: string;
133
- required: string[];
134
- additionalProperties: boolean;
135
- properties: {
136
- type: {
137
- const: string;
138
- };
139
- from: {
140
- $ref: string;
141
- };
142
- to: {
143
- $ref: string;
144
- };
145
- intent: {
146
- $ref: string;
147
- };
148
- stroke: {
149
- type: string;
150
- };
151
- strokeWidth: {
152
- type: string;
153
- minimum: number;
154
- };
155
- color: {
156
- type: string;
157
- };
158
- };
159
- } | {
160
- type: string;
161
- required: string[];
162
- additionalProperties: boolean;
163
- properties: {
164
- type: {
165
- const: string;
166
- };
167
- at: {
168
- $ref: string;
169
- };
170
- content: {
171
- type: string;
172
- };
173
- fontSize: {
174
- type: string;
175
- minimum: number;
176
- };
177
- anchor: {
178
- type: string;
179
- enum: string[];
180
- };
181
- intent: {
182
- $ref: string;
183
- };
184
- color: {
185
- type: string;
186
- };
187
- };
188
- } | {
189
- type: string;
190
- required: string[];
191
- additionalProperties: boolean;
192
- properties: {
193
- type: {
194
- const: string;
195
- };
196
- at: {
197
- $ref: string;
198
- };
199
- targetBbox: {
200
- $ref: string;
201
- };
202
- content: {
203
- type: string;
204
- };
205
- intent: {
206
- $ref: string;
207
- };
208
- stroke: {
209
- type: string;
210
- };
211
- color: {
212
- type: string;
213
- };
214
- };
215
- } | {
216
- type: string;
217
- required: string[];
218
- additionalProperties: boolean;
219
- properties: {
220
- type: {
221
- const: string;
222
- };
223
- svgFragment: {
224
- type: string;
225
- };
226
- };
227
- })[];
228
73
  };
229
74
  export declare const LOCATOR_ANNOTATION_SCHEMA: {
230
75
  oneOf: ({
231
- type: string;
232
- required: string[];
233
- additionalProperties: boolean;
234
- properties: {
235
- type: {
236
- const: string;
237
- };
238
- svgFragment: {
239
- type: string;
240
- };
241
- };
242
- } | {
243
76
  type: string;
244
77
  required: string[];
245
78
  additionalProperties: boolean;
@@ -423,22 +256,49 @@ export declare const LOCATOR_ANNOTATION_SCHEMA: {
423
256
  required: string[];
424
257
  }[];
425
258
  }[];
259
+ } | {
260
+ type: string;
261
+ required: string[];
262
+ additionalProperties: boolean;
263
+ properties: {
264
+ type: {
265
+ const: string;
266
+ };
267
+ svgFragment: {
268
+ type: string;
269
+ };
270
+ };
426
271
  })[];
427
272
  };
428
- export declare const BBOX_REDACT_REGION_SCHEMA: {
273
+ export declare const ENCODE_OPTIONS_SCHEMA: {
429
274
  type: string;
430
- required: string[];
431
275
  additionalProperties: boolean;
432
276
  properties: {
433
- bbox: {
434
- $ref: string;
277
+ format: {
278
+ type: string;
279
+ enum: string[];
280
+ description: string;
435
281
  };
436
- style: {
282
+ saveSizePreset: {
437
283
  type: string;
438
284
  enum: string[];
285
+ description: string;
439
286
  };
440
- color: {
287
+ smartFallback: {
288
+ type: string;
289
+ enum: string[];
290
+ description: string;
291
+ };
292
+ smartColorThreshold: {
293
+ type: string;
294
+ minimum: number;
295
+ description: string;
296
+ };
297
+ jpegPercent: {
441
298
  type: string;
299
+ minimum: number;
300
+ maximum: number;
301
+ description: string;
442
302
  };
443
303
  };
444
304
  };
@@ -1,62 +1,5 @@
1
- /** Axis-aligned bounding box. Coordinates are page pixels. */
2
- export interface BBox {
3
- x: number;
4
- y: number;
5
- width: number;
6
- height: number;
7
- }
8
- /** Point in page pixels. */
9
- export interface Point {
10
- x: number;
11
- y: number;
12
- }
13
- /**
14
- * Semantic colour shorthand. Resolves to the Annot design system's
15
- * matching token (e.g. `intent: "error"` → `--annot-color-error`).
16
- * Explicit `stroke` / `color` / `fill` on an annotation override
17
- * the intent-derived defaults.
18
- */
19
- export type Intent = "info" | "warning" | "error" | "success" | "neutral";
20
- /** Style overrides shared across most annotation shapes. */
21
- export interface AnnotationStyle {
22
- intent?: Intent;
23
- stroke?: string;
24
- strokeWidth?: number;
25
- fill?: string;
26
- color?: string;
27
- }
28
- export type BboxRectAnnotation = AnnotationStyle & {
29
- type: "rect";
30
- bbox: BBox;
31
- };
32
- export type BboxCircleAnnotation = AnnotationStyle & {
33
- type: "circle";
34
- center: Point;
35
- radius: number;
36
- };
37
- export type BboxArrowAnnotation = AnnotationStyle & {
38
- type: "arrow";
39
- from: Point;
40
- to: Point;
41
- };
42
- export type BboxTextAnnotation = AnnotationStyle & {
43
- type: "text";
44
- at: Point;
45
- content: string;
46
- fontSize?: number;
47
- anchor?: "start" | "middle" | "end";
48
- };
49
- export type BboxCalloutAnnotation = AnnotationStyle & {
50
- type: "callout";
51
- at: Point;
52
- targetBbox: BBox;
53
- content: string;
54
- };
55
- export interface RawAnnotation {
56
- type: "raw";
57
- svgFragment: string;
58
- }
59
- export type BboxAnnotation = BboxRectAnnotation | BboxCircleAnnotation | BboxArrowAnnotation | BboxTextAnnotation | BboxCalloutAnnotation | RawAnnotation;
1
+ import { AnnotationStyle, BBox, Point } from '@ingcreators/annot-annotator';
2
+ export type { AnnotationStyle, BBox, BboxAnnotation, BboxArrowAnnotation, BboxCalloutAnnotation, BboxCircleAnnotation, BboxRectAnnotation, BboxRedactRegion, BboxTextAnnotation, Intent, Point, RawAnnotation, RedactStyle, } from '@ingcreators/annot-annotator';
60
3
  /**
61
4
  * Playwright locator string. Follows the standard locator grammar:
62
5
  * CSS selectors (`button.primary`), text engines (`text=Submit`,
@@ -110,17 +53,13 @@ export type LocatorCalloutAnnotation = AnnotationStyle & {
110
53
  targetLocator?: Locator;
111
54
  content: string;
112
55
  };
113
- export type LocatorAnnotation = LocatorRectAnnotation | LocatorCircleAnnotation | LocatorArrowAnnotation | LocatorTextAnnotation | LocatorCalloutAnnotation | RawAnnotation;
114
- export type RedactStyle = "solid" | "mosaic" | "blur";
115
- export interface BboxRedactRegion {
116
- bbox: BBox;
117
- style?: RedactStyle;
118
- /** CSS colour, applied only when `style` is `"solid"`. */
119
- color?: string;
120
- }
56
+ export type LocatorAnnotation = LocatorRectAnnotation | LocatorCircleAnnotation | LocatorArrowAnnotation | LocatorTextAnnotation | LocatorCalloutAnnotation | {
57
+ type: "raw";
58
+ svgFragment: string;
59
+ };
121
60
  export type LocatorRedactRegion = {
122
61
  bbox?: BBox;
123
62
  locator?: Locator;
124
- style?: RedactStyle;
63
+ style?: import('@ingcreators/annot-annotator').RedactStyle;
125
64
  color?: string;
126
65
  };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
+ export { arrowBetween, bboxAnnotationsToSvg, rectForBoundingBox, textAt, } from '@ingcreators/annot-annotator';
1
2
  export { type CapturePageOptions, type CapturePageResult, capturePage, type PageHandle, type ViewportOptions, } from './browser/capture.js';
2
3
  export { type BrowserLauncher, type BrowserLike, BrowserPool, type BrowserPoolOptions, ChromiumUnavailableError, createChromiumPool, } from './browser/pool.js';
3
4
  export { type LocatorLike, LocatorResolutionError, type PageLike, resolveLocator, resolveLocatorAnnotation, resolveLocatorAnnotations, } from './browser/resolve-locator.js';
4
5
  export { aggregateDiffRegions } from './compare/aggregate.js';
5
6
  export { type DiffOptions, type DiffResult, DimensionMismatchError, diffScreenshots, } from './compare/diff.js';
6
7
  export { BBOX_ANNOTATION_SCHEMA, BBOX_REDACT_REGION_SCHEMA, LOCATOR_ANNOTATION_SCHEMA, LOCATOR_REDACT_REGION_SCHEMA, SHARED_DEFS, } from './dsl/schema.js';
7
- export { bboxAnnotationsToSvg } from './dsl/to-svg.js';
8
8
  export type { AnnotationStyle, BBox, BboxAnnotation, BboxArrowAnnotation, BboxCalloutAnnotation, BboxCircleAnnotation, BboxRectAnnotation, BboxRedactRegion, BboxTextAnnotation, Intent, Locator, LocatorAnnotation, LocatorArrowAnnotation, LocatorCalloutAnnotation, LocatorCircleAnnotation, LocatorRectAnnotation, LocatorRedactRegion, LocatorTextAnnotation, Point, RawAnnotation, RedactStyle, } from './dsl/types.js';
9
9
  export { InvalidPngError, type PngDimensions, readPngDimensions, } from './io/png-dimensions.js';
10
10
  export { InvalidImageInputError, type ResolvedImage, resolveImageInput, } from './io/read-image.js';