Skip to content

feat(sdk/js): add vision support, list(), and missing types to Responses API client#671

Open
MaanavD wants to merge 3 commits intomainfrom
agents/update-responses-api-sdk-vision-support
Open

feat(sdk/js): add vision support, list(), and missing types to Responses API client#671
MaanavD wants to merge 3 commits intomainfrom
agents/update-responses-api-sdk-vision-support

Conversation

@MaanavD
Copy link
Copy Markdown
Collaborator

@MaanavD MaanavD commented Apr 23, 2026

Summary

Updates the existing Responses API client in the Foundry Local JavaScript/TypeScript SDK with vision support, a list() method, missing streaming event types, and corrected defaults.

Changes

New types (src/types.ts)

  • InputImageContent — base64-encoded or URL-based image input part
  • InputFileContent — file input part
  • Updated ContentPart union to include both new types
  • 7 new reasoning/annotation streaming event interfaces: ReasoningSummaryPartAddedEvent, ReasoningSummaryPartDoneEvent, ReasoningDeltaEvent, ReasoningDoneEvent, ReasoningSummaryTextDeltaEvent, ReasoningSummaryTextDoneEvent, OutputTextAnnotationAddedEvent
  • Updated StreamingEvent union to include all new event types
  • ListResponsesResult — return type for GET /v1/responses

Client updates (src/openai/responsesClient.ts)

  • Added list() method — GET /v1/responses
  • store now defaults to true in _serialize() when not explicitly set

New vision helpers (src/openai/vision.ts)

  • createImageContentFromFile(filePath, detail?) — reads a local image file, base64-encodes it, infers media type from extension (png/jpg/jpeg/gif/webp)
  • createImageContentFromUrl(url, detail?) — creates a URL-based image content part
  • Both exported from src/index.ts

Tests (test/openai/responsesClient.test.ts, test/testUtils.ts)

  • Unit tests for vision helpers (URL, base64, file read, unsupported extension)
  • Unit test for list() network error handling
  • Unit tests for all 7 new reasoning event types
  • Updated store default serialization test
  • Integration tests for list() and vision (skipped when native addon unavailable)
  • Added IS_NATIVE_ADDON_AVAILABLE guard to testUtils.ts so integration tests skip gracefully instead of erroring when foundry_local_napi.node is not compiled

Example (examples/responses.ts)

  • Added Example 6: list stored responses
  • Added Example 7: vision with createImageContentFromFile

Test results

43 passing
9 pending (integration tests skipped — native addon not compiled in this environment)
0 failing

…ses API client

- Add InputImageContent and InputFileContent content part types
- Expand ContentPart union to include new types
- Add 7 new reasoning/annotation streaming event interfaces and expand StreamingEvent union
- Add ListResponsesResult type
- Add list() method to ResponsesClient (GET /v1/responses)
- Default store to true in ResponsesClientSettings._serialize()
- Add vision.ts with createImageContentFromFile and createImageContentFromUrl helpers
- Export vision helpers from index.ts
- Add unit tests: vision helpers, list(), reasoning event types, store default
- Add integration tests for list() and vision (skipped when addon unavailable)
- Add IS_NATIVE_ADDON_AVAILABLE guard to testUtils to skip integration tests gracefully
- Update responses.ts example with list() and vision examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 16:54
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Apr 24, 2026 2:03am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the JS/TS SDK’s Responses API support by adding multimodal (vision) input helpers, a list() endpoint wrapper, and additional missing streaming event/type definitions to better align with the service contract.

Changes:

  • Added new content-part and streaming event types (image/file inputs + reasoning/annotation events) and a ListResponsesResult type.
  • Added ResponsesClient.list() (GET /v1/responses) and changed ResponsesClientSettings._serialize() so store defaults to true.
  • Introduced createImageContentFromFile() / createImageContentFromUrl() helpers, exported via src/index.ts, and expanded tests + examples accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/js/test/testUtils.ts Adds IS_NATIVE_ADDON_AVAILABLE detection to help skip integration tests when the native addon isn’t present.
sdk/js/test/openai/responsesClient.test.ts Adds unit/integration tests for vision helpers, list(), new streaming event types, and updates store-default expectations.
sdk/js/src/types.ts Adds image/file content parts, reasoning/annotation streaming event interfaces, extends unions, and defines ListResponsesResult.
sdk/js/src/openai/vision.ts New helper module to build InputImageContent parts from files or URLs.
sdk/js/src/openai/responsesClient.ts Adds list() and changes serialization default for store.
sdk/js/src/index.ts Exports the new vision helper functions from the public SDK surface.
sdk/js/examples/responses.ts Adds examples demonstrating listing stored responses and sending vision input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/js/test/testUtils.ts Outdated
Comment thread sdk/js/test/openai/responsesClient.test.ts Outdated
Comment thread sdk/js/test/openai/responsesClient.test.ts Outdated
Comment thread sdk/js/src/openai/responsesClient.ts
Comment thread sdk/js/src/openai/vision.ts Outdated
Comment thread sdk/js/src/openai/vision.ts
Comment thread sdk/js/src/openai/vision.ts Outdated
Comment thread sdk/js/src/types.ts Outdated
Comment thread sdk/js/src/openai/vision.ts Outdated
- Make media_type optional in InputImageContent (server can infer)
- Add file existence check in createImageContentFromFile
- Add bmp support to MEDIA_TYPE_MAP
- Add optional maxDimension resize via soft-peer sharp dependency
- Omit media_type in createImageContentFromUrl (server infers from URL)
- Add JSDoc on ResponsesClientSettings.store documenting default=true
- Replace FoundryLocalManager.create() in checkNativeAddonAvailable with
  file-existence checks (avoids side effects)
- Replace unreachable-server list() test with globalThis.fetch mock
- Use fs.mkdtempSync for unique temp dirs in file-based tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/js/test/testUtils.ts Outdated
Comment thread sdk/js/src/openai/vision.ts Outdated
Comment thread sdk/js/src/openai/vision.ts
Comment thread sdk/js/src/openai/vision.ts
Comment thread sdk/js/src/openai/vision.ts Outdated
- vision.ts: use fs.promises.readFile (async) instead of sync existsSync/readFileSync
- vision.ts: validate maxDimension is a finite positive integer before use
- vision.ts: update JSDoc to reflect overloaded options param (object or detail string)
- vision.ts: resizeImage returns { buffer, mediaType } so media_type is explicit post-resize
- vision.ts: pass fallbackMediaType into resizeImage to avoid hardcoded 'image/png'
- testUtils.ts: check all 4 candidate addon paths (sdk/js/prebuilds, sdk/js/native,
  sdk/js/dist/prebuilds, sdk/js/dist/native) matching CoreInterop.loadAddon() logic

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants