Skip to content

feat: batchSetFieldValues fills several fields in one call, all or none - #65

Merged
bendersej merged 10 commits into
mainfrom
P123-batch-set-field-value
Oct 14, 2026
Merged

bendersej merged 10 commits into
mainfrom
P123-batch-set-field-value

Conversation

@bendersej

@bendersej bendersej commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Background

The SimplePDF editor gains BATCH_SET_FIELD_VALUES: it sets several existing fields in one call, all or none, as a single undo step, and reports every rejected update at once in bad_request:batch_validation_failed details.failures. This re-syncs the SDK's contract pin so every SDK surface exposes it.

Release order: the editor change is live (SimplePDF/simple-pdf#496, editor_version 7845f7c3-20261014T100758Z); the pin is synced from the live manifest, and check:contract passes.

Changes

  • embed-api.json re-pinned and src/generated/* regenerated: batchSetFieldValues({ updates: [{ fieldId, value }] }) on embed.actions, the agentic tools (/tools, /ai-sdk, /tanstack-ai) and the simplepdf_embed_batch_set_field_values WebMCP tool
  • useEmbed().actions.batchSetFieldValues in @simplepdf/react-embed-pdf
  • Typed error details generalised: the generator emits one <Code>Details type per error code that carries details and the map BridgeError derives from, so bad_request:batch_validation_failed exposes typed details.failures (BatchValidationFailedDetails) next to MissingRequiredFieldsDetails (name unchanged)
  • API reports re-blessed; tool-count tests (15 → 16 agentic operations) and the exclude known-names message updated; READMEs list the new action
  • Each tool description ships once: the generator no longer repeats it at the root of the operation's input schema, which also sent it to the model a second time in every tool's JSON schema (3,484 B per request with every tool in 0.8.0); a test pins it. With the shorter descriptions, a request carrying every AI SDK tool is 12,699 → 9,603 B against 0.8.0 despite the new tool, and the agentic bundles shrink 28 to 29% (tools.js 5056 → 3592 B gzip, ai-sdk.js 5269 → 3808 B, tanstack-ai.js 5247 → 3786 B); their caps are lowered (4.5 / 5 / 5 KB, schemas.js 3 → 2 KB)
  • Tool descriptions 24% shorter on the 16 tools 0.8.0 shipped (3,694 → 2,794 characters): behavior only, parameters keep their details, no permission notes (the model cannot check them; a refused call answers with its error code), tools and keys named in words so the text reads true in camelCase (AI SDK, TanStack AI) and snake_case (WebMCP), getAnnotatedPage states the WebMCP image block plus text block, and signature values document plain text as a typed signature (SimplePDF/simple-pdf#496)
  • No source maps in any package (the surface is small): @simplepdf/embed 596 → 248 KB unpacked; @simplepdf/react-embed-pdf is no longer minified, so it stays readable without maps (110 → 74 KB); @simplepdf/web-embed-pdf drops its browser field, which sent webpack users the minified build (unpkg keeps index.min.js)
  • Changesets: the batch (minor for all three packages: @simplepdf/web-embed-pdf bundles @simplepdf/embed, so it ships the WebMCP tool) and leaner agent requests (minor for @simplepdf/embed, whose /schemas lose the root description; patch for @simplepdf/react-embed-pdf and @simplepdf/web-embed-pdf)

Verified locally: @simplepdf/embed test:types, test (119), check:size, check:exports, check:api; React test:types, test (15), check:api, check:exports after rebuilding embed then react. @simplepdf/web-embed-pdf test:types, test:unit (11). The Changelog Check (npm run version, then React and web test:format) passes in a scratch copy. check:contract passes against the live manifest.

Review outcomes

Change Before After
O1 ❓✅
React build readable without maps
react/rollup.config.js
Minified with terser, maps shipped (110 KB unpacked) Not minified (the integrator's bundler minifies the app), no maps: 74 KB
O2 ❓✅
Named batchSetFieldValues, with a short description
embed/src/bridge.ts
(new) Follows the editor's BATCH_SET_FIELD_VALUES (Google AIP-233/234 pattern); the description drops implementation detail; your call
O3 ✅
Each tool description shipped and sent once
embed/scripts/generate.mjs
On the tool and again at the root of its input schema: 3,484 B repeated in every model request carrying all the tools (0.8.0) On the tool only, pinned by a test
O4 ✅
Agentic bundle caps lowered
embed/scripts/check-bundle-size.mjs
schemas.js 3 KB, tools.js 5 KB, ai-sdk.js / tanstack-ai.js 5.5 KB 2 / 4.5 / 5 / 5 KB, each 0.5 to 1.3 KB above the measured size
O5 ❓✅
No source maps anywhere; web drops its browser field
web/package.json
Maps in @simplepdf/embed and React (58% and 63% of their installs); web's browser field pointed bundlers at index.min.js No maps: the code is small and readable unminified. Bundlers resolve web's readable index.js; unpkg keeps index.min.js
O6 ✅
Typed details for every error code that carries them
embed/scripts/generate.mjs
Only missing_required_fields, picked by name One <Code>Details type per code and the map BridgeError derives from
O7 ❓✅
Tool descriptions carry behavior, in words
embed/embed-api.json
Value rules restated on the tool and its value parameter; "It renders document content, so it is gated exactly like get_document_content: the embedding origin must be whitelisted for the tenant." and "requires editing to be enabled"; snake_case names (get_fields, field_id, image_data_url) that are wrong on the camelCase tools; getAnnotatedPage promised image_data_url, which WebMCP returns as an image block Value rules on the parameter only; no permission notes; tools and keys named in words (pinned by an editor contract test); both result shapes stated; "Destructive" kept (annotations never reach the model on the AI SDK / TanStack definitions)
O8 ❓✅
Web ships the batch tool as a minor
.changeset/batch-set-field-value.md
Batch changeset listed @simplepdf/embed and React only, though web bundles embed (web/rollup.config.js external: []) Minor for web too, with a line naming the WebMCP tool on pages using it

@bendersej
bendersej marked this pull request as draft October 13, 2026 18:17
@bendersej bendersej changed the title feat: batchSetFieldValue fills several fields in one call, all or none feat: batchSetFieldValues fills several fields in one call, all or none Oct 13, 2026
@bendersej
bendersej marked this pull request as ready for review October 14, 2026 10:17
@bendersej
bendersej merged commit c225115 into main Oct 14, 2026
5 checks passed
@bendersej
bendersej deleted the P123-batch-set-field-value branch October 14, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant