@proveanything/smartlinks 2.0.28 → 2.0.29

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.
@@ -29,6 +29,8 @@ export declare const AI_TOOL_NAMES: {
29
29
  readonly PDF_INSPECT: "pdf.inspect";
30
30
  readonly PDF_RENDER: "pdf.render";
31
31
  readonly PDF_EXTRACT: "pdf.extract";
32
+ readonly PDF_DECODE_BARCODES: "pdf.decodeBarcodes";
33
+ readonly PDF_INSPECT_GRAPHICS: "pdf.inspectGraphics";
32
34
  readonly HTTP_REQUEST: "http.request";
33
35
  readonly TRANSLATE: "translate";
34
36
  };
package/dist/ai-tools.js CHANGED
@@ -26,6 +26,8 @@ export const AI_TOOL_NAMES = {
26
26
  PDF_INSPECT: 'pdf.inspect',
27
27
  PDF_RENDER: 'pdf.render',
28
28
  PDF_EXTRACT: 'pdf.extract',
29
+ PDF_DECODE_BARCODES: 'pdf.decodeBarcodes',
30
+ PDF_INSPECT_GRAPHICS: 'pdf.inspectGraphics',
29
31
  HTTP_REQUEST: 'http.request',
30
32
  TRANSLATE: 'translate',
31
33
  };
@@ -66,7 +68,11 @@ export const BUILTIN_AI_TOOLS = [
66
68
  { name: 'pdf.render', group: 'media', capabilities: ['web:read'],
67
69
  description: 'Rasterize a single PDF page to a PNG at a controllable DPI (e.g. 300 for small print) and return a hosted image URL — feed to a vision call or screenshot a page.' },
68
70
  { name: 'pdf.extract', group: 'media', capabilities: ['web:read', 'ai:vision'],
69
- description: 'Extract typed JSON from a PDF in one call given a schema and/or prompt. Auto-routes: text-layer pages use cheap text extraction; curve-only/raster pages are rendered and read with vision.' },
71
+ description: 'Extract typed JSON from a PDF in one call given a schema and/or prompt. Auto-routes: text-layer pages use cheap text extraction; curve-only/raster pages are rendered and read with vision. Optional per-field confidence/source (includeConfidence) and bounding boxes (includeBoxes).' },
72
+ { name: 'pdf.decodeBarcodes', group: 'media', capabilities: ['web:read'],
73
+ description: 'Deterministically decode 1D/2D barcodes (EAN/UPC/QR/Code128/DataMatrix/…) on a PDF page by rasterizing and running a WASM decoder — reliable barcode/QR values where vision hallucinates. Returns value, symbology, page, bbox, confidence. No AI.' },
74
+ { name: 'pdf.inspectGraphics', group: 'media', capabilities: ['web:read'],
75
+ description: 'Prepress structural inspection: per-page vector-path/image/outlined-text counts + colour spaces used, plus document-level named SPOT colours (e.g. "PANTONE 871 C"). Answers whether spot/foil plates survived. Deterministic, no AI.' },
70
76
  { name: 'http.request', group: 'net', capabilities: ['net:http'],
71
77
  description: 'SSRF-guarded outbound HTTP(S) request to a public URL; returns status/headers/body.' },
72
78
  { name: 'translate', group: 'text', capabilities: ['ai:text'],
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.0.28 | Generated: 2026-09-28T13:20:09.049Z
3
+ Version: 2.0.29 | Generated: 2026-09-29T10:33:46.286Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -1485,7 +1485,21 @@ interface PdfRenderArgs {
1485
1485
  **PdfExtractArgs** (interface)
1486
1486
  ```typescript
1487
1487
  interface PdfExtractArgs {
1488
- url: string; schema?: Record<string, any>; prompt?: string; maxPages?: number; dpi?: number
1488
+ url: string; schema?: Record<string, any>; prompt?: string; maxPages?: number; dpi?: number; includeConfidence?: boolean; includeBoxes?: boolean
1489
+ }
1490
+ ```
1491
+
1492
+ **PdfDecodeBarcodesArgs** (interface)
1493
+ ```typescript
1494
+ interface PdfDecodeBarcodesArgs {
1495
+ url: string; page?: number; dpi?: number
1496
+ }
1497
+ ```
1498
+
1499
+ **PdfInspectGraphicsArgs** (interface)
1500
+ ```typescript
1501
+ interface PdfInspectGraphicsArgs {
1502
+ url: string; page?: number
1489
1503
  }
1490
1504
  ```
1491
1505
 
@@ -1524,6 +1538,8 @@ interface AiToolArgsMap {
1524
1538
  'pdf.inspect': PdfInspectArgs
1525
1539
  'pdf.render': PdfRenderArgs
1526
1540
  'pdf.extract': PdfExtractArgs
1541
+ 'pdf.decodeBarcodes': PdfDecodeBarcodesArgs
1542
+ 'pdf.inspectGraphics': PdfInspectGraphicsArgs
1527
1543
  'http.request': HttpRequestArgs
1528
1544
  'translate': TranslateArgs
1529
1545
  }
@@ -1613,10 +1629,45 @@ interface PdfRenderResult {
1613
1629
  }
1614
1630
  ```
1615
1631
 
1632
+ **PdfFieldMeta** (interface)
1633
+ ```typescript
1634
+ interface PdfFieldMeta {
1635
+ confidence?: number | null; source?: 'text' | 'vision' | 'inferred'; bbox?: { x: number; y: number; w: number; h: number; page: number }
1636
+ }
1637
+ ```
1638
+
1616
1639
  **PdfExtractResult** (interface)
1617
1640
  ```typescript
1618
1641
  interface PdfExtractResult {
1619
- url: string; method: 'text' | 'vision'; pagesRead: number; fields: Record<string, any>
1642
+ url: string; method: 'text' | 'vision'; pagesRead: number; fields: Record<string, any>; fieldsMeta?: Record<string, PdfFieldMeta>
1643
+ }
1644
+ ```
1645
+
1646
+ **PdfBarcode** (interface)
1647
+ ```typescript
1648
+ interface PdfBarcode {
1649
+ type: string; format: string; value: string; page: number; bbox?: { x: number; y: number; w: number; h: number }; confidence: number
1650
+ }
1651
+ ```
1652
+
1653
+ **PdfDecodeBarcodesResult** (interface)
1654
+ ```typescript
1655
+ interface PdfDecodeBarcodesResult {
1656
+ url: string; pagesScanned: number; codes: PdfBarcode[]
1657
+ }
1658
+ ```
1659
+
1660
+ **PdfGraphicsPage** (interface)
1661
+ ```typescript
1662
+ interface PdfGraphicsPage {
1663
+ page: number; paths: number; images: number; textRuns: number; colourSpaces: string[]
1664
+ }
1665
+ ```
1666
+
1667
+ **PdfInspectGraphicsResult** (interface)
1668
+ ```typescript
1669
+ interface PdfInspectGraphicsResult {
1670
+ url: string; pages: PdfGraphicsPage[]; spotColours: string[]; note: string
1620
1671
  }
1621
1672
  ```
1622
1673
 
package/dist/docs/ai.md CHANGED
@@ -324,15 +324,40 @@ in `input`.
324
324
  | `image.searchStock` | Search real stock photos (Unsplash). |
325
325
  | `image.transform` | Resize / crop / rotate / grayscale / format-convert / compress → hosted URL. |
326
326
  | `pdf.create` | Render HTML → PDF → hosted URL. |
327
- | `pdf.fill` | Fill an AcroForm PDF's fields → hosted URL. |
328
- | `pdf.merge` | Merge several PDFs into one → hosted URL. |
327
+ | `pdf.fill` | Fill an AcroForm PDF's fields (`{ field: value }`) → hosted URL. |
328
+ | `pdf.merge` | Merge several PDFs into one, in order → hosted URL. |
329
+ | `pdf.inspect` | Cheap, no-AI introspection: page count/sizes, which pages have a real text layer, raster present, and a routing hint (`text` vs `vision`). |
330
+ | `pdf.render` | Rasterize one page to a PNG at a chosen DPI → hosted image URL (feed to vision, or screenshot a page). |
331
+ | `pdf.extract` | PDF → typed JSON in one call (schema and/or prompt). Auto-routes text vs vision. Optional per-field `confidence`/`source` (`includeConfidence`) and `bbox` (`includeBoxes`) in `fieldsMeta`. |
332
+ | `pdf.decodeBarcodes` | Deterministically decode barcodes/QR on a page (WASM, no AI) → value + symbology + page + bbox + confidence. Use this for barcode digits, never vision. |
333
+ | `pdf.inspectGraphics` | Prepress inspection: per-page path/image/outlined-text counts + colour spaces, plus named SPOT colours (e.g. "PANTONE 871 C"). No AI. |
329
334
  | `http.request` | SSRF-guarded outbound HTTP(S) to a public URL (call a REST API). |
330
335
  | `translate` | Translate text into one or more languages (generic, model-based). |
331
336
 
337
+ **Working with PDFs.** The PDF tools split into *read/analyse* and *produce*:
338
+
339
+ - **Read a whole PDF as text** → `document.read` (Firecrawl; good for prose/decks).
340
+ - **Turn a PDF into structured fields** → `pdf.extract` (give it a JSON schema and/or a prompt; it
341
+ returns typed JSON). It routes itself, but you can drive the route yourself: call `pdf.inspect`
342
+ first (deterministic, no AI) to see whether each page has a real text layer, then `pdf.extract`
343
+ (cheap text path) or `pdf.render` → `image.describe`/vision for curve-only or raster artwork.
344
+ - **Zoom in on small print** (INCI/allergen lists) → `pdf.render` at a high DPI (e.g. 300), then read
345
+ the PNG with vision.
346
+ - **Barcodes / QR** → `pdf.decodeBarcodes` (deterministic WASM decode) — never trust vision for barcode
347
+ digits; it hallucinates them.
348
+ - **Prepress / print QA** (spot colours, colour spaces, vector vs raster) → `pdf.inspectGraphics`.
349
+ - **A review UI that flags guessed fields** → `pdf.extract` with `includeConfidence` (per-field
350
+ confidence + source) and `includeBoxes` (per-field bbox on text-native pages) in `fieldsMeta`.
351
+ - **Produce a PDF** → `pdf.create` (HTML → PDF), `pdf.fill` (populate an AcroForm's fields),
352
+ `pdf.merge` (combine several). These return a hosted `hostedUrl`.
353
+
354
+ Every tool is also directly callable without the model loop via `ai.tools.run(collectionId, name,
355
+ args)` — e.g. render a page or extract fields straight from a UI, no agent round-trip.
356
+
332
357
  Discover tools two ways:
333
358
  - **Design time (typed):** import `BUILTIN_AI_TOOLS`, `AI_TOOL_NAMES`, and the per-tool arg types
334
- (`WebSearchArgs`, `DataExtractArgs`, …) from the SDK. This is the core set — stable, versioned,
335
- documented here.
359
+ (`WebSearchArgs`, `DataExtractArgs`, `PdfExtractArgs`, …) from the SDK. This is the core set —
360
+ stable, versioned, documented here.
336
361
  - **Runtime (live):** `await ai.catalog(collectionId)` returns the registry as the server sees it,
337
362
  including any future app-contributed tools. The built-in set above is always present.
338
363
 
@@ -400,6 +400,12 @@ Prefer the platform primitives above over a dependency; when you do need one, pi
400
400
  | Schema validation of inputs | no | `zod` |
401
401
  | JWT (sign/verify for a third-party API) | Web Crypto can, verbosely | `jose` |
402
402
  | Hash / HMAC / encrypt | **native** — `crypto.subtle` | — |
403
+ | PDF **text** extraction (cheap first-pass, no AI) | no | `unpdf` — a serverless/WASM pdf.js build with no Node deps; `import { extractText } from 'unpdf'`. Text only. |
404
+
405
+ > **PDFs in a server function:** for a cheap text-layer check use `unpdf` (edge-safe, WASM). For
406
+ > anything heavier — rendering pages, vision extraction, **barcode/QR decode**, or prepress/spot-colour
407
+ > inspection — call the platform tools `pdf.render` / `pdf.extract` / `pdf.decodeBarcodes` /
408
+ > `pdf.inspectGraphics` via `ai.tools.run`; those run in the full platform runtime, not the sandbox.
403
409
 
404
410
  **The common actions, and how to do each:**
405
411
 
package/dist/openapi.yaml CHANGED
@@ -17064,6 +17064,22 @@ components:
17064
17064
  additionalProperties: true
17065
17065
  required:
17066
17066
  - url
17067
+ PdfDecodeBarcodesArgs:
17068
+ type: object
17069
+ properties:
17070
+ url:
17071
+ type: object
17072
+ additionalProperties: true
17073
+ required:
17074
+ - url
17075
+ PdfInspectGraphicsArgs:
17076
+ type: object
17077
+ properties:
17078
+ url:
17079
+ type: object
17080
+ additionalProperties: true
17081
+ required:
17082
+ - url
17067
17083
  HttpRequestArgs:
17068
17084
  type: object
17069
17085
  properties:
@@ -17125,6 +17141,10 @@ components:
17125
17141
  $ref: "#/components/schemas/PdfRenderArgs"
17126
17142
  pdf.extract:
17127
17143
  $ref: "#/components/schemas/PdfExtractArgs"
17144
+ pdf.decodeBarcodes:
17145
+ $ref: "#/components/schemas/PdfDecodeBarcodesArgs"
17146
+ pdf.inspectGraphics:
17147
+ $ref: "#/components/schemas/PdfInspectGraphicsArgs"
17128
17148
  http.request:
17129
17149
  $ref: "#/components/schemas/HttpRequestArgs"
17130
17150
  translate:
@@ -17148,6 +17168,8 @@ components:
17148
17168
  - pdf.inspect
17149
17169
  - pdf.render
17150
17170
  - pdf.extract
17171
+ - pdf.decodeBarcodes
17172
+ - pdf.inspectGraphics
17151
17173
  - http.request
17152
17174
  - translate
17153
17175
  WebSearchResultItem:
@@ -17256,6 +17278,12 @@ components:
17256
17278
  additionalProperties: true
17257
17279
  required:
17258
17280
  - url
17281
+ PdfFieldMeta:
17282
+ type: object
17283
+ properties:
17284
+ confidence:
17285
+ type: object
17286
+ additionalProperties: true
17259
17287
  PdfExtractResult:
17260
17288
  type: object
17261
17289
  properties:
@@ -17266,6 +17294,42 @@ components:
17266
17294
  - vision
17267
17295
  required:
17268
17296
  - url
17297
+ PdfBarcode:
17298
+ type: object
17299
+ properties:
17300
+ type:
17301
+ type: object
17302
+ additionalProperties: true
17303
+ required:
17304
+ - type
17305
+ PdfDecodeBarcodesResult:
17306
+ type: object
17307
+ properties:
17308
+ url:
17309
+ type: array
17310
+ items:
17311
+ type: object
17312
+ additionalProperties: true
17313
+ required:
17314
+ - url
17315
+ PdfGraphicsPage:
17316
+ type: object
17317
+ properties:
17318
+ page:
17319
+ type: array
17320
+ items:
17321
+ type: object
17322
+ additionalProperties: true
17323
+ required:
17324
+ - page
17325
+ PdfInspectGraphicsResult:
17326
+ type: object
17327
+ properties:
17328
+ url:
17329
+ type: object
17330
+ additionalProperties: true
17331
+ required:
17332
+ - url
17269
17333
  ResponsesAgentTrace:
17270
17334
  type: object
17271
17335
  properties:
@@ -17347,6 +17411,8 @@ components:
17347
17411
  - pdf.inspect
17348
17412
  - pdf.render
17349
17413
  - pdf.extract
17414
+ - pdf.decodeBarcodes
17415
+ - pdf.inspectGraphics
17350
17416
  - http.request
17351
17417
  - translate
17352
17418
  AgentStreamEvent:
@@ -848,7 +848,7 @@ export interface CatalogResponse {
848
848
  /** Capability tags a tool requires; scope a run with `allowCapabilities`. */
849
849
  export type AiToolCapability = 'web:read' | 'ai:vision' | 'ai:image' | 'ai:text' | 'media:image' | 'media:pdf' | 'net:http';
850
850
  /** The names of the built-in server-side agent tools (run via `server_tools`). */
851
- export type AiToolName = 'web.fetchPage' | 'web.extractSchema' | 'web.screenshot' | 'web.search' | 'brand.assets' | 'document.read' | 'data.extract' | 'image.describe' | 'image.generate' | 'image.fromReference' | 'image.searchStock' | 'image.transform' | 'pdf.create' | 'pdf.fill' | 'pdf.merge' | 'pdf.inspect' | 'pdf.render' | 'pdf.extract' | 'http.request' | 'translate';
851
+ export type AiToolName = 'web.fetchPage' | 'web.extractSchema' | 'web.screenshot' | 'web.search' | 'brand.assets' | 'document.read' | 'data.extract' | 'image.describe' | 'image.generate' | 'image.fromReference' | 'image.searchStock' | 'image.transform' | 'pdf.create' | 'pdf.fill' | 'pdf.merge' | 'pdf.inspect' | 'pdf.render' | 'pdf.extract' | 'pdf.decodeBarcodes' | 'pdf.inspectGraphics' | 'http.request' | 'translate';
852
852
  export interface WebFetchPageArgs {
853
853
  url: string;
854
854
  type?: string;
@@ -956,6 +956,17 @@ export interface PdfExtractArgs {
956
956
  prompt?: string;
957
957
  maxPages?: number;
958
958
  dpi?: number;
959
+ includeConfidence?: boolean;
960
+ includeBoxes?: boolean;
961
+ }
962
+ export interface PdfDecodeBarcodesArgs {
963
+ url: string;
964
+ page?: number;
965
+ dpi?: number;
966
+ }
967
+ export interface PdfInspectGraphicsArgs {
968
+ url: string;
969
+ page?: number;
959
970
  }
960
971
  export interface HttpRequestArgs {
961
972
  url: string;
@@ -988,6 +999,8 @@ export interface AiToolArgsMap {
988
999
  'pdf.inspect': PdfInspectArgs;
989
1000
  'pdf.render': PdfRenderArgs;
990
1001
  'pdf.extract': PdfExtractArgs;
1002
+ 'pdf.decodeBarcodes': PdfDecodeBarcodesArgs;
1003
+ 'pdf.inspectGraphics': PdfInspectGraphicsArgs;
991
1004
  'http.request': HttpRequestArgs;
992
1005
  'translate': TranslateArgs;
993
1006
  }
@@ -1077,11 +1090,56 @@ export interface PdfRenderResult {
1077
1090
  width: number;
1078
1091
  height: number;
1079
1092
  }
1093
+ /** Per-field metadata from pdf.extract when includeConfidence / includeBoxes is set. */
1094
+ export interface PdfFieldMeta {
1095
+ confidence?: number | null;
1096
+ source?: 'text' | 'vision' | 'inferred';
1097
+ bbox?: {
1098
+ x: number;
1099
+ y: number;
1100
+ w: number;
1101
+ h: number;
1102
+ page: number;
1103
+ };
1104
+ }
1080
1105
  export interface PdfExtractResult {
1081
1106
  url: string;
1082
1107
  method: 'text' | 'vision';
1083
1108
  pagesRead: number;
1084
1109
  fields: Record<string, any>;
1110
+ fieldsMeta?: Record<string, PdfFieldMeta>;
1111
+ }
1112
+ /** One decoded barcode/QR from pdf.decodeBarcodes. bbox is in PDF points (top-left origin). */
1113
+ export interface PdfBarcode {
1114
+ type: string;
1115
+ format: string;
1116
+ value: string;
1117
+ page: number;
1118
+ bbox?: {
1119
+ x: number;
1120
+ y: number;
1121
+ w: number;
1122
+ h: number;
1123
+ };
1124
+ confidence: number;
1125
+ }
1126
+ export interface PdfDecodeBarcodesResult {
1127
+ url: string;
1128
+ pagesScanned: number;
1129
+ codes: PdfBarcode[];
1130
+ }
1131
+ export interface PdfGraphicsPage {
1132
+ page: number;
1133
+ paths: number;
1134
+ images: number;
1135
+ textRuns: number;
1136
+ colourSpaces: string[];
1137
+ }
1138
+ export interface PdfInspectGraphicsResult {
1139
+ url: string;
1140
+ pages: PdfGraphicsPage[];
1141
+ spotColours: string[];
1142
+ note: string;
1085
1143
  }
1086
1144
  /** The `_agent` trace attached to an agentic Responses result. */
1087
1145
  export interface ResponsesAgentTrace {
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.0.28 | Generated: 2026-09-28T13:20:09.049Z
3
+ Version: 2.0.29 | Generated: 2026-09-29T10:33:46.286Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -1485,7 +1485,21 @@ interface PdfRenderArgs {
1485
1485
  **PdfExtractArgs** (interface)
1486
1486
  ```typescript
1487
1487
  interface PdfExtractArgs {
1488
- url: string; schema?: Record<string, any>; prompt?: string; maxPages?: number; dpi?: number
1488
+ url: string; schema?: Record<string, any>; prompt?: string; maxPages?: number; dpi?: number; includeConfidence?: boolean; includeBoxes?: boolean
1489
+ }
1490
+ ```
1491
+
1492
+ **PdfDecodeBarcodesArgs** (interface)
1493
+ ```typescript
1494
+ interface PdfDecodeBarcodesArgs {
1495
+ url: string; page?: number; dpi?: number
1496
+ }
1497
+ ```
1498
+
1499
+ **PdfInspectGraphicsArgs** (interface)
1500
+ ```typescript
1501
+ interface PdfInspectGraphicsArgs {
1502
+ url: string; page?: number
1489
1503
  }
1490
1504
  ```
1491
1505
 
@@ -1524,6 +1538,8 @@ interface AiToolArgsMap {
1524
1538
  'pdf.inspect': PdfInspectArgs
1525
1539
  'pdf.render': PdfRenderArgs
1526
1540
  'pdf.extract': PdfExtractArgs
1541
+ 'pdf.decodeBarcodes': PdfDecodeBarcodesArgs
1542
+ 'pdf.inspectGraphics': PdfInspectGraphicsArgs
1527
1543
  'http.request': HttpRequestArgs
1528
1544
  'translate': TranslateArgs
1529
1545
  }
@@ -1613,10 +1629,45 @@ interface PdfRenderResult {
1613
1629
  }
1614
1630
  ```
1615
1631
 
1632
+ **PdfFieldMeta** (interface)
1633
+ ```typescript
1634
+ interface PdfFieldMeta {
1635
+ confidence?: number | null; source?: 'text' | 'vision' | 'inferred'; bbox?: { x: number; y: number; w: number; h: number; page: number }
1636
+ }
1637
+ ```
1638
+
1616
1639
  **PdfExtractResult** (interface)
1617
1640
  ```typescript
1618
1641
  interface PdfExtractResult {
1619
- url: string; method: 'text' | 'vision'; pagesRead: number; fields: Record<string, any>
1642
+ url: string; method: 'text' | 'vision'; pagesRead: number; fields: Record<string, any>; fieldsMeta?: Record<string, PdfFieldMeta>
1643
+ }
1644
+ ```
1645
+
1646
+ **PdfBarcode** (interface)
1647
+ ```typescript
1648
+ interface PdfBarcode {
1649
+ type: string; format: string; value: string; page: number; bbox?: { x: number; y: number; w: number; h: number }; confidence: number
1650
+ }
1651
+ ```
1652
+
1653
+ **PdfDecodeBarcodesResult** (interface)
1654
+ ```typescript
1655
+ interface PdfDecodeBarcodesResult {
1656
+ url: string; pagesScanned: number; codes: PdfBarcode[]
1657
+ }
1658
+ ```
1659
+
1660
+ **PdfGraphicsPage** (interface)
1661
+ ```typescript
1662
+ interface PdfGraphicsPage {
1663
+ page: number; paths: number; images: number; textRuns: number; colourSpaces: string[]
1664
+ }
1665
+ ```
1666
+
1667
+ **PdfInspectGraphicsResult** (interface)
1668
+ ```typescript
1669
+ interface PdfInspectGraphicsResult {
1670
+ url: string; pages: PdfGraphicsPage[]; spotColours: string[]; note: string
1620
1671
  }
1621
1672
  ```
1622
1673
 
package/docs/ai.md CHANGED
@@ -324,15 +324,40 @@ in `input`.
324
324
  | `image.searchStock` | Search real stock photos (Unsplash). |
325
325
  | `image.transform` | Resize / crop / rotate / grayscale / format-convert / compress → hosted URL. |
326
326
  | `pdf.create` | Render HTML → PDF → hosted URL. |
327
- | `pdf.fill` | Fill an AcroForm PDF's fields → hosted URL. |
328
- | `pdf.merge` | Merge several PDFs into one → hosted URL. |
327
+ | `pdf.fill` | Fill an AcroForm PDF's fields (`{ field: value }`) → hosted URL. |
328
+ | `pdf.merge` | Merge several PDFs into one, in order → hosted URL. |
329
+ | `pdf.inspect` | Cheap, no-AI introspection: page count/sizes, which pages have a real text layer, raster present, and a routing hint (`text` vs `vision`). |
330
+ | `pdf.render` | Rasterize one page to a PNG at a chosen DPI → hosted image URL (feed to vision, or screenshot a page). |
331
+ | `pdf.extract` | PDF → typed JSON in one call (schema and/or prompt). Auto-routes text vs vision. Optional per-field `confidence`/`source` (`includeConfidence`) and `bbox` (`includeBoxes`) in `fieldsMeta`. |
332
+ | `pdf.decodeBarcodes` | Deterministically decode barcodes/QR on a page (WASM, no AI) → value + symbology + page + bbox + confidence. Use this for barcode digits, never vision. |
333
+ | `pdf.inspectGraphics` | Prepress inspection: per-page path/image/outlined-text counts + colour spaces, plus named SPOT colours (e.g. "PANTONE 871 C"). No AI. |
329
334
  | `http.request` | SSRF-guarded outbound HTTP(S) to a public URL (call a REST API). |
330
335
  | `translate` | Translate text into one or more languages (generic, model-based). |
331
336
 
337
+ **Working with PDFs.** The PDF tools split into *read/analyse* and *produce*:
338
+
339
+ - **Read a whole PDF as text** → `document.read` (Firecrawl; good for prose/decks).
340
+ - **Turn a PDF into structured fields** → `pdf.extract` (give it a JSON schema and/or a prompt; it
341
+ returns typed JSON). It routes itself, but you can drive the route yourself: call `pdf.inspect`
342
+ first (deterministic, no AI) to see whether each page has a real text layer, then `pdf.extract`
343
+ (cheap text path) or `pdf.render` → `image.describe`/vision for curve-only or raster artwork.
344
+ - **Zoom in on small print** (INCI/allergen lists) → `pdf.render` at a high DPI (e.g. 300), then read
345
+ the PNG with vision.
346
+ - **Barcodes / QR** → `pdf.decodeBarcodes` (deterministic WASM decode) — never trust vision for barcode
347
+ digits; it hallucinates them.
348
+ - **Prepress / print QA** (spot colours, colour spaces, vector vs raster) → `pdf.inspectGraphics`.
349
+ - **A review UI that flags guessed fields** → `pdf.extract` with `includeConfidence` (per-field
350
+ confidence + source) and `includeBoxes` (per-field bbox on text-native pages) in `fieldsMeta`.
351
+ - **Produce a PDF** → `pdf.create` (HTML → PDF), `pdf.fill` (populate an AcroForm's fields),
352
+ `pdf.merge` (combine several). These return a hosted `hostedUrl`.
353
+
354
+ Every tool is also directly callable without the model loop via `ai.tools.run(collectionId, name,
355
+ args)` — e.g. render a page or extract fields straight from a UI, no agent round-trip.
356
+
332
357
  Discover tools two ways:
333
358
  - **Design time (typed):** import `BUILTIN_AI_TOOLS`, `AI_TOOL_NAMES`, and the per-tool arg types
334
- (`WebSearchArgs`, `DataExtractArgs`, …) from the SDK. This is the core set — stable, versioned,
335
- documented here.
359
+ (`WebSearchArgs`, `DataExtractArgs`, `PdfExtractArgs`, …) from the SDK. This is the core set —
360
+ stable, versioned, documented here.
336
361
  - **Runtime (live):** `await ai.catalog(collectionId)` returns the registry as the server sees it,
337
362
  including any future app-contributed tools. The built-in set above is always present.
338
363
 
@@ -400,6 +400,12 @@ Prefer the platform primitives above over a dependency; when you do need one, pi
400
400
  | Schema validation of inputs | no | `zod` |
401
401
  | JWT (sign/verify for a third-party API) | Web Crypto can, verbosely | `jose` |
402
402
  | Hash / HMAC / encrypt | **native** — `crypto.subtle` | — |
403
+ | PDF **text** extraction (cheap first-pass, no AI) | no | `unpdf` — a serverless/WASM pdf.js build with no Node deps; `import { extractText } from 'unpdf'`. Text only. |
404
+
405
+ > **PDFs in a server function:** for a cheap text-layer check use `unpdf` (edge-safe, WASM). For
406
+ > anything heavier — rendering pages, vision extraction, **barcode/QR decode**, or prepress/spot-colour
407
+ > inspection — call the platform tools `pdf.render` / `pdf.extract` / `pdf.decodeBarcodes` /
408
+ > `pdf.inspectGraphics` via `ai.tools.run`; those run in the full platform runtime, not the sandbox.
403
409
 
404
410
  **The common actions, and how to do each:**
405
411
 
package/openapi.yaml CHANGED
@@ -17064,6 +17064,22 @@ components:
17064
17064
  additionalProperties: true
17065
17065
  required:
17066
17066
  - url
17067
+ PdfDecodeBarcodesArgs:
17068
+ type: object
17069
+ properties:
17070
+ url:
17071
+ type: object
17072
+ additionalProperties: true
17073
+ required:
17074
+ - url
17075
+ PdfInspectGraphicsArgs:
17076
+ type: object
17077
+ properties:
17078
+ url:
17079
+ type: object
17080
+ additionalProperties: true
17081
+ required:
17082
+ - url
17067
17083
  HttpRequestArgs:
17068
17084
  type: object
17069
17085
  properties:
@@ -17125,6 +17141,10 @@ components:
17125
17141
  $ref: "#/components/schemas/PdfRenderArgs"
17126
17142
  pdf.extract:
17127
17143
  $ref: "#/components/schemas/PdfExtractArgs"
17144
+ pdf.decodeBarcodes:
17145
+ $ref: "#/components/schemas/PdfDecodeBarcodesArgs"
17146
+ pdf.inspectGraphics:
17147
+ $ref: "#/components/schemas/PdfInspectGraphicsArgs"
17128
17148
  http.request:
17129
17149
  $ref: "#/components/schemas/HttpRequestArgs"
17130
17150
  translate:
@@ -17148,6 +17168,8 @@ components:
17148
17168
  - pdf.inspect
17149
17169
  - pdf.render
17150
17170
  - pdf.extract
17171
+ - pdf.decodeBarcodes
17172
+ - pdf.inspectGraphics
17151
17173
  - http.request
17152
17174
  - translate
17153
17175
  WebSearchResultItem:
@@ -17256,6 +17278,12 @@ components:
17256
17278
  additionalProperties: true
17257
17279
  required:
17258
17280
  - url
17281
+ PdfFieldMeta:
17282
+ type: object
17283
+ properties:
17284
+ confidence:
17285
+ type: object
17286
+ additionalProperties: true
17259
17287
  PdfExtractResult:
17260
17288
  type: object
17261
17289
  properties:
@@ -17266,6 +17294,42 @@ components:
17266
17294
  - vision
17267
17295
  required:
17268
17296
  - url
17297
+ PdfBarcode:
17298
+ type: object
17299
+ properties:
17300
+ type:
17301
+ type: object
17302
+ additionalProperties: true
17303
+ required:
17304
+ - type
17305
+ PdfDecodeBarcodesResult:
17306
+ type: object
17307
+ properties:
17308
+ url:
17309
+ type: array
17310
+ items:
17311
+ type: object
17312
+ additionalProperties: true
17313
+ required:
17314
+ - url
17315
+ PdfGraphicsPage:
17316
+ type: object
17317
+ properties:
17318
+ page:
17319
+ type: array
17320
+ items:
17321
+ type: object
17322
+ additionalProperties: true
17323
+ required:
17324
+ - page
17325
+ PdfInspectGraphicsResult:
17326
+ type: object
17327
+ properties:
17328
+ url:
17329
+ type: object
17330
+ additionalProperties: true
17331
+ required:
17332
+ - url
17269
17333
  ResponsesAgentTrace:
17270
17334
  type: object
17271
17335
  properties:
@@ -17347,6 +17411,8 @@ components:
17347
17411
  - pdf.inspect
17348
17412
  - pdf.render
17349
17413
  - pdf.extract
17414
+ - pdf.decodeBarcodes
17415
+ - pdf.inspectGraphics
17350
17416
  - http.request
17351
17417
  - translate
17352
17418
  AgentStreamEvent:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",