Skip to content

feat(ai-sdk): AI SDK integration#1707

Merged
dinwwwh merged 7 commits into
middleapi:mainfrom
dinwwwh:claude/ai-sdk-integration-orpc-v2-edfe67
Jul 22, 2026
Merged

feat(ai-sdk): AI SDK integration#1707
dinwwwh merged 7 commits into
middleapi:mainfrom
dinwwwh:claude/ai-sdk-integration-orpc-v2-edfe67

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Brings the AI SDK integration (@orpc/ai-sdk) to v2, targeting AI SDK v7+. You can now turn procedures and contracts into AI SDK Tools:

const createTool = createToolFactory({ context: {} })
const implementTool = implementToolFactory()

const tools = {
  getWeather: createTool(getWeatherProcedure),
  createTask: implementTool(createTaskContract, { execute: ... }), // or omit execute for client-side / human-in-the-loop tools
}
  • createToolFactory converts procedures into tools; implementToolFactory implements procedure contracts as tools
  • aiSdkTool metadata plugin attaches base AI SDK tool options to procedures/contracts, with input/output types inferred from the contract
  • Procedures with asyncIteratorObject outputs stream each event as a preliminary tool result
  • Multiple input/output schemas are combined into a single schema ($defs/$ref-aware allOf composition)
  • New AI SDK Integration docs page
  • 100% test coverage

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
orpc Ready Ready Preview, Comment Jul 22, 2026 7:15am

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes — adds the new @orpc/ai-sdk package that turns oRPC procedures and contracts into AI SDK v7+ tools, alongside an aiSdkTool metadata plugin, streaming async-iterator support, multi-schema composition, docs, and tests.

  • Adds @orpc/ai-sdk package scaffold (package.json, tsconfig.json, .gitignore, README.md) following existing integration conventions.
  • Adds implementToolFactory and createToolFactory for building AI SDK tools from oRPC contracts/procedures.
  • Adds aiSdkTool metadata plugin so contracts/procedures can carry default AI SDK tool options.
  • Adds preliminary streaming support when a procedure returns an AsyncIteratorObject.
  • Adds AI SDK integration docs and updates the VitePress sidebar.
  • Updates vitest.config.ts coverage excludes and refreshes pnpm-lock.yaml for AI SDK v7.

ℹ️ Nitpicks

  • pnpm-lock.yaml now pulls the AI SDK v7 transitive dependency tree; no action needed beyond confirming the updated lockfile installs cleanly in CI.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/ai-sdk/src/tool.ts
@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/middleapi/orpc/@orpc/ai-sdk@1707

@orpc/arktype

npm i https://pkg.pr.new/middleapi/orpc/@orpc/arktype@1707

@orpc/bun

npm i https://pkg.pr.new/middleapi/orpc/@orpc/bun@1707

@orpc/client

npm i https://pkg.pr.new/middleapi/orpc/@orpc/client@1707

@orpc/cloudflare

npm i https://pkg.pr.new/middleapi/orpc/@orpc/cloudflare@1707

@orpc/contract

npm i https://pkg.pr.new/middleapi/orpc/@orpc/contract@1707

@orpc/experimental-effect

npm i https://pkg.pr.new/middleapi/orpc/@orpc/experimental-effect@1707

@orpc/evlog

npm i https://pkg.pr.new/middleapi/orpc/@orpc/evlog@1707

@orpc/json-schema

npm i https://pkg.pr.new/middleapi/orpc/@orpc/json-schema@1707

@orpc/nest

npm i https://pkg.pr.new/middleapi/orpc/@orpc/nest@1707

@orpc/next

npm i https://pkg.pr.new/middleapi/orpc/@orpc/next@1707

@orpc/openapi

npm i https://pkg.pr.new/middleapi/orpc/@orpc/openapi@1707

@orpc/opentelemetry

npm i https://pkg.pr.new/middleapi/orpc/@orpc/opentelemetry@1707

@orpc/pinia-colada

npm i https://pkg.pr.new/middleapi/orpc/@orpc/pinia-colada@1707

@orpc/pino

npm i https://pkg.pr.new/middleapi/orpc/@orpc/pino@1707

@orpc/publisher

npm i https://pkg.pr.new/middleapi/orpc/@orpc/publisher@1707

@orpc/ratelimit

npm i https://pkg.pr.new/middleapi/orpc/@orpc/ratelimit@1707

@orpc/server

npm i https://pkg.pr.new/middleapi/orpc/@orpc/server@1707

@orpc/shared

npm i https://pkg.pr.new/middleapi/orpc/@orpc/shared@1707

@orpc/tanstack-query

npm i https://pkg.pr.new/middleapi/orpc/@orpc/tanstack-query@1707

@orpc/trpc

npm i https://pkg.pr.new/middleapi/orpc/@orpc/trpc@1707

@orpc/valibot

npm i https://pkg.pr.new/middleapi/orpc/@orpc/valibot@1707

@orpc/zod

npm i https://pkg.pr.new/middleapi/orpc/@orpc/zod@1707

commit: f23821f

@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing dinwwwh:claude/ai-sdk-integration-orpc-v2-edfe67 (f23821f) with main (b57f86c)

Open in CodSpeed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes — dependency cleanup for the new @orpc/ai-sdk package since the prior review.

  • Bumped the ai peer dependency from >=7.0.0 to >=7.0.31.
  • Removed the unused @orpc/openapi devDependency and its test usage.
  • Refreshed pnpm-lock.yaml to match the updated dependency declarations.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/ai-sdk/package.json
@dinwwwh
dinwwwh merged commit 428ad93 into middleapi:main Jul 22, 2026
10 checks passed
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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