Skip to content

feat(cli): scaffold selected backend framework - #785

Open
vishxrad wants to merge 20 commits into
mainfrom
visharad/th-2051-route-replacement
Open

feat(cli): scaffold selected backend framework#785
vishxrad wants to merge 20 commits into
mainfrom
visharad/th-2051-route-replacement

Conversation

@vishxrad

@vishxrad vishxrad commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ask CLI users to choose the direct OpenAI SDK route, LangGraph, or Vercel AI SDK after selecting OpenUI Cloud or self-hosted
  • replace both src/app/api/chat/route.ts and src/app/page.tsx for framework-backed variants so each route uses its matching frontend adapter and message format
  • use native LangGraph named-event SSE and native Vercel AI SDK UIMessage streaming in both Cloud and self-hosted scaffolds
  • preserve OpenUI Cloud as the model provider and conversation/artifact store while executing only app-owned function tools in the selected framework
  • keep Cloud-owned artifact, web-search, image-search, and configured MCP calls on OpenUI Cloud
  • include get_weather as the diagnostic app-owned tool in every framework-backed scaffold
  • preserve LangGraph model-step ordering and ToolMessage results in the frontend adapter so multi-step history remains valid
  • prevent immediate dev-server startup when the required API key is missing and report the remediation in the CLI
  • remove staged route/page variants and stale tool-loop files from generated framework projects
  • document the framework matrix and Cloud/provider boundary

Framework behavior

Self-hosted

  • none: OpenAI SDK Chat Completions route + OpenAI frontend adapter/message format
  • langgraph: inline StateGraph returns graph.stream(..., { encoding: "text/event-stream" }); the frontend uses langGraphAdapter() and langGraphMessageFormat
  • vercel-ai-sdk: streamText() returns toUIMessageStreamResponse(); the frontend uses vercelAIAdapter() and vercelAIMessageFormat

OpenUI Cloud

OpenUI Cloud remains the Responses provider and the sole conversation/artifact store for every Cloud variant. Choosing a framework changes the app-owned tool runtime and browser wire protocol; it does not move Cloud-owned tools onto the app server or configure a second model provider.

  • none: OpenAI SDK Responses stream + openAIResponsesAdapter()
  • langgraph: ChatOpenAI({ useResponsesApi: true }) points at OpenUI Cloud, an inline StateGraph runs app tools through ToolNode, and LangGraph encodes the named-event SSE consumed by langGraphAdapter()
  • vercel-ai-sdk: the AI SDK OpenAI Responses provider points at OpenUI Cloud, streamText() executes app tools, and toUIMessageStreamResponse() produces the UIMessage SSE consumed by vercelAIAdapter()

Both Cloud framework routes send only the latest new user/tool message into the stored Cloud conversation. Cloud-owned calls are excluded from the local framework executor, while app-owned calls such as get_weather are executed locally and submitted back to that same Cloud conversation.

Choose the self-hosted template when using a user-owned model provider.

Dependency notes

  • The Vercel scaffolds pin ai@6.0.244 and @ai-sdk/openai@3.0.90. The newer 6.0.246/3.0.91 registry entries currently depend on unpublished @ai-sdk/provider-utils@4.0.42 (and @ai-sdk/gateway@3.0.166), so caret ranges make a fresh install fail.
  • The LangGraph ToolMessage ordering fix in this PR uses React Headless 0.9.7; that package must be published before the CLI release so generated LangGraph apps can install it from the registry.
  • @openuidev/react-ui re-exports the adapters, so generated React UI code imports them only from React UI.

LangChain package note

@openuidev/langchain targets a separate LangGraph protocol-v2 server and requires an API URL, assistant ID, agent-side stream transformer, and a second process/deployment. The CLI LangGraph option remains an inline StateGraph in the Next.js route, so adopting that package would require a separate scaffold topology rather than a route/page replacement.

Issue

TH-2051 — Ask for backend framework in CLI

Validation

  • merged current main (8c6ffd88; zero commits behind at push time)
  • pnpm --filter @openuidev/cli build
  • pnpm --filter @openuidev/cli run ci
  • pnpm --filter @openuidev/react-headless test (16 files, 155 tests; previous adapter validation)
  • fresh install + production build: Cloud + Vercel AI SDK
  • fresh install + production build: Cloud + LangGraph (using a locally packed pending React Headless 0.9.7)
  • fresh install + production build: self-hosted + Vercel AI SDK
  • fresh install + production build: self-hosted + LangGraph (using the same local package)
  • confirmed all generated framework routes use their framework-native encoder and matching frontend adapter
  • confirmed generated framework option directories and the obsolete Cloud manual tool-loop file are removed
  • previously ran both generated self-hosted routes against a real provider and verified the weather tool call, result, continuation step, and final OpenUI response through their frontend adapters
  • verified missing-key immediate starts exit before spawning Next

@vishxrad
vishxrad marked this pull request as ready for review July 16, 2026 14:56
@vishxrad
vishxrad force-pushed the visharad/th-2051-route-replacement branch from 92faf00 to dcbc7d3 Compare August 4, 2026 10:04
…e-replacement

# Conflicts:
#	packages/openui-cli/src/templates/openui-cloud/package-lock.json
#	packages/openui-cli/src/templates/openui-self-hosted/package-lock.json
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
openui-docs Ready Ready Preview Aug 7, 2026 5:25am

Request Review

@abhithesys abhithesys 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.

use adapters on frontend for message transformation and framework native streaming

…e-replacement

# Conflicts:
#	docs/content/docs/agent/reference/adapters-and-formats.mdx
#	packages/openui-cli/src/commands/create-app.ts
#	packages/openui-cli/src/lib/utils.ts
#	packages/react-headless/src/stream/adapters/__tests__/vercel-ai-sdk.test.ts
#	packages/react-headless/src/stream/adapters/vercel-ai-sdk.ts
#	pnpm-lock.yaml
"@openuidev/react-lang": "^0.2.10",
"@openuidev/lang-core": "0.2.11",
"@openuidev/react-lang": "^0.2.11",
"@openuidev/react-ui": "^0.13.4",

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.

Can you also update this to ^0.13.5 and similarly in the other template

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