Skip to content

Commit 900f3e1

Browse files
authored
Move examples to openuiLibrary and lang-core cloud prompts (#1119)
* fix: move examples to use library from react-ui * Migrate Cloud examples and templates to lang-core generateSystemPrompt Fold the #1118 consumer switch into the library-spec work so Cloud callers use `{ cloud: true }` from lang-core while keeping the generated openuiLibrary spec. * Use LibrarySpec in Cloud example prompts Match lang-core — no ChatLibrary type, components is dropped on the wire. * Point example and Cloud template lockfiles at published lang-core 0.2.17 Package manifests already pin that version; the locks still resolved 0.2.15/0.2.16. * feat: add generate:apiKey * fix: update templates
1 parent 83c9ddb commit 900f3e1

146 files changed

Lines changed: 42368 additions & 9165 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/content/docs/openui-lang/examples/harnesses/pi.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: pi Agent Harness
33
description: Chat with the pi coding agent (a real read/bash/edit/write agent) and get its answers as live generative UI, bridged through the pi SDK over an OpenAI-compatible stream.
44
---
55

6-
Anything that can stream text can drive OpenUI's renderer, including a full **coding agent**. This example connects [pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) (`@earendil-works/pi-coding-agent`), running its default `read` / `bash` / `edit` / `write` tools, to `<AgentInterface>`. Pi calls **OpenUI Cloud** Completions; `generateSystemPrompt()` is appended so it emits [OpenUI Lang](/docs/openui-lang/overview) for Cloud `chatLibrary` instead of markdown.
6+
Anything that can stream text can drive OpenUI's renderer, including a full **coding agent**. This example connects [pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) (`@earendil-works/pi-coding-agent`), running its default `read` / `bash` / `edit` / `write` tools, to `<AgentInterface>`. Pi calls **OpenUI Cloud** Completions; `generateSystemPrompt({ cloud: true })` is appended so it emits [OpenUI Lang](/docs/openui-lang/overview) for `openuiLibrary` instead of markdown.
77

88
Its mid-turn activity (reasoning and tool runs) surfaces as cards too.
99

@@ -26,9 +26,9 @@ Its mid-turn activity (reasoning and tool runs) surfaces as cards too.
2626

2727
| Piece | File | Role |
2828
| --- | --- | --- |
29-
| Frontend | `src/app/page.tsx` | A single `<AgentInterface>` wired with `fetchLLM({ streamAdapter: openAIReadableStreamAdapter(), messageFormat: openAIMessageFormat })` and Cloud `chatLibrary`. |
29+
| Frontend | `src/app/page.tsx` | A single `<AgentInterface>` wired with `fetchLLM({ streamAdapter: openAIReadableStreamAdapter(), messageFormat: openAIMessageFormat })` and `openuiLibrary`. |
3030
| Bridge route | `src/app/api/chat/route.ts` | Drives a pi `AgentSession` against OpenUI Cloud Completions and re-emits its events as NDJSON OpenAI chunks (`delta.content` is OpenUI Lang). |
31-
| Session registry | `src/lib/pi-session.ts` | One persistent `AgentSession` per chat thread, keyed by `threadId`. Injects `generateSystemPrompt()` and the Cloud model. |
31+
| Session registry | `src/lib/pi-session.ts` | One persistent `AgentSession` per chat thread, keyed by `threadId`. Injects `generateSystemPrompt({ cloud: true })` and the Cloud model. |
3232
| Agent | `@earendil-works/pi-coding-agent` | The pi coding agent: `read` / `bash` / `edit` / `write` on the workspace you choose at launch. |
3333

3434
Everything runs in **one Next.js process**: the App-Router route _is_ the backend. The pi SDK is embedded directly (no separate server), so there is no second service and no CORS. Each chat thread maps to one persistent pi `AgentSession`, so multi-turn context is preserved.
@@ -44,7 +44,7 @@ import {
4444
openAIMessageFormat,
4545
openAIReadableStreamAdapter,
4646
} from "@openuidev/react-ui";
47-
import { chatLibrary } from "@openuidev/thesys";
47+
import { openuiLibrary } from "@openuidev/react-ui/genui-lib";
4848

4949
const llm = fetchLLM({
5050
url: "/api/chat",
@@ -54,12 +54,12 @@ const llm = fetchLLM({
5454

5555
<AgentInterface
5656
llm={llm}
57-
componentLibrary={chatLibrary}
57+
componentLibrary={openuiLibrary}
5858
agentName="OpenUI Agent Harness"
5959
/>;
6060
```
6161

62-
`generateSystemPrompt()` from `@openuidev/thesys-server` is the **same** Cloud chat-library sentinel Pi sends on Completions, so the model's markup matches `chatLibrary`.
62+
`generateSystemPrompt({ cloud: true })` from `@openuidev/lang-core` is the **same** Cloud library sentinel Pi sends on Completions, so the model's markup matches `openuiLibrary`.
6363

6464
## The bridge route
6565

examples/agent-frameworks/google-adk/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ An [OpenUI](https://openui.com) example showing how to wire a
1313
supplies a `BaseLlm`
1414
- Bridging ADK's `runAsync` event stream into AG-UI SSE (`TEXT_MESSAGE_*`,
1515
`TOOL_CALL_START`/`ARGS`/`END`/`RESULT`) so OpenUI's `agUIAdapter()` can parse them
16-
- Rendering streamed OpenUI Lang with `<AgentInterface />` and Cloud's
17-
`chatLibrary`
16+
- Rendering streamed OpenUI Lang with `<AgentInterface />` and `openuiLibrary`
1817

1918
## Getting started
2019

21-
1. Create a `.env.local` file with your OpenUI Cloud key
22-
(https://console.thesys.dev/keys):
20+
1. Mint an OpenUI Cloud key into `.env.local`:
2321

2422
```bash
25-
echo "THESYS_API_KEY=sk-th-your-key-here" > .env.local
23+
pnpm generate:apiKey
2624
```
2725

2826
2. Install dependencies from this example directory:
@@ -43,7 +41,8 @@ Open [http://localhost:3000](http://localhost:3000) and try a starter such as
4341
## How it works
4442

4543
- `src/agent.ts` defines the `get_weather` tool and a `createAgent()` builder.
46-
The instruction is Cloud's `generateSystemPrompt()`. The model is Cloud's
44+
The instruction is `cloudInstructions()`, which reads the generated
45+
`openuiLibrary` spec. The model is Cloud's
4746
Gemini (`google/gemini-3.6-flash-free`).
4847
- `src/app/api/chat/route.ts` runs the agent with a `Runner` and keys ADK
4948
sessions by chat `threadId` (so multi-turn history is preserved).

0 commit comments

Comments
 (0)