Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/batch-set-field-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@simplepdf/embed": minor
"@simplepdf/react-embed-pdf": minor
"@simplepdf/web-embed-pdf": minor
---

**Fill several fields in one call: `batchSetFieldValues` sets every value at once, or none of them.**
- `batchSetFieldValues({ updates: [{ fieldId, value }] })` applies every update in one step, reverted by a single undo in the editor, and resolves with no data.
- If any update is rejected (an unknown field, an invalid option, a read-only field, an unreadable signature URL, the same field twice), nothing changes: the result fails with `bad_request:batch_validation_failed` and `error.details.failures` lists every rejected update with its `fieldId`, `code` and `message` (typed as `BatchValidationFailedDetails`).
- Values follow the `setFieldValue` rules and are never typed out.
- Available everywhere the editor operations are: `embed.actions.batchSetFieldValues`, `useEmbed().actions.batchSetFieldValues`, the `batchSetFieldValues` agentic tool on every tool subpath, and the `simplepdf_embed_batch_set_field_values` WebMCP tool, including on pages using `@simplepdf/web-embed-pdf`.
12 changes: 12 additions & 0 deletions .changeset/leaner-agent-requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@simplepdf/embed": minor
"@simplepdf/react-embed-pdf": patch
"@simplepdf/web-embed-pdf": patch
---

**Smaller installs, leaner agent requests, readable stack traces.**
- The agentic tools no longer repeat each tool's description inside its input schema: with the shorter descriptions below, a model request carrying all the AI SDK or TanStack AI tools sends about 3 KB less (24%) even with the new `batchSetFieldValues` tool, and the agentic entry points are 28 to 29% smaller.
- Tool descriptions are about 24% shorter (900 fewer characters across the 16 tools of the previous release): they state behavior and leave the details to each parameter, permission notes are gone (a refused call answers with its error code), and they name no tool or key whose spelling differs between surfaces, so they read true whether your agent sees camelCase (AI SDK, TanStack AI) or snake_case (WebMCP). The signature `value` documents that plain text is drawn as a typed signature. `getAnnotatedPage` states that the WebMCP tool returns the render as an image block and the rest of the result as a text block.
- Smaller installs: no source maps, so `@simplepdf/embed` unpacks to 248 KB instead of 596 KB and `@simplepdf/react-embed-pdf` to 74 KB instead of 110 KB. `@simplepdf/react-embed-pdf` is no longer minified, so an error inside it shows readable code in your devtools and error tracker; your bundler still minifies your app.
- `@simplepdf/web-embed-pdf` drops its `browser` field, so bundlers resolve the readable `dist/index.js`; the script-tag build on unpkg stays minified.
- The `/schemas` input schemas no longer carry the operation description at their root; read it from `SIMPLEPDF_TOOLS[name].description`, or from `OPERATIONS` in `@simplepdf/embed/protocol` for every operation including `loadDocument`.
2 changes: 1 addition & 1 deletion embed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ await embed.actions.rotatePage({ page: 1 })
await embed.actions.download()
```

Full set: `createField`, `deleteFields`, `deletePages`, `detectFields`, `download`, `focusField`, `getAnnotatedPage`, `getDocumentContent`, `getFields`, `goTo`, `loadDocument`, `movePage`, `rotatePage`, `selectTool`, `setFieldValue`, `submit`.
Full set: `batchSetFieldValues`, `createField`, `deleteFields`, `deletePages`, `detectFields`, `download`, `focusField`, `getAnnotatedPage`, `getDocumentContent`, `getFields`, `goTo`, `loadDocument`, `movePage`, `rotatePage`, `selectTool`, `setFieldValue`, `submit`.

**"Fill and read this document for me"** is just these operations in sequence, exactly what the agentic tools expose to a model:

Expand Down
324 changes: 262 additions & 62 deletions embed/embed-api.json

Large diffs are not rendered by default.

29 changes: 23 additions & 6 deletions embed/etc/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@
```ts

// @public (undocumented)
export type BridgeError = {
code: 'bad_request:missing_required_fields';
message: string;
details: MissingRequiredFieldsDetails;
} | {
code: Exclude<BridgeErrorCode, 'bad_request:missing_required_fields'>;
export type BatchSetFieldValuesInput = {
updates: Array<{
fieldId: string;
value: string | null;
}>;
};

// @public (undocumented)
export type BatchValidationFailedDetails = {
failures: Array<{
fieldId: string;
code: "bad_request:field_not_found" | "bad_request:invalid_signature_url" | "bad_request:invalid_value" | "bad_request:read_only";
message: string;
}>;
};

// Warning: (ae-forgotten-export) The symbol "DetailedBridgeError" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "EditorErrorDetailsByCode" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type BridgeError = DetailedBridgeError<keyof EditorErrorDetailsByCode> | {
code: Exclude<BridgeErrorCode, keyof EditorErrorDetailsByCode>;
message: string;
};

Expand Down Expand Up @@ -264,6 +280,7 @@ export type GoToInput = {

// @public (undocumented)
export type IframeActions = {
batchSetFieldValues: (input: BatchSetFieldValuesInput) => Promise<BridgeResult>;
createField: (input: CreateFieldInput) => Promise<BridgeResult<CreateFieldOutput>>;
deleteFields: (input?: DeleteFieldsInput) => Promise<BridgeResult<DeleteFieldsOutput>>;
deletePages: (input: DeletePagesInput) => Promise<BridgeResult>;
Expand Down
Loading
Loading