Skip to content

Commit 4d1ffc2

Browse files
author
Alem Tuzlak
committed
Merge remote-tracking branch 'origin/main' into alem/oss-360-sdk-foundations
# Conflicts: # packages/bot/src/create-bot.ts
2 parents c55aa13 + c1d5764 commit 4d1ffc2

298 files changed

Lines changed: 34488 additions & 3545 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.

.github/config-allowlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ examples/canvas/llamaindex/next.config.ts
55
examples/canvas/mastra-pm/next.config.ts
66
examples/canvas/mastra/next.config.ts
77
examples/canvas/pydantic-ai/next.config.ts
8+
examples/shadcn/next.config.ts
89
examples/integrations/a2a-a2ui/next.config.js
910
examples/integrations/a2a-middleware/next.config.ts
1011
examples/integrations/adk/next.config.ts

.github/workflows/static_quality.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ jobs:
123123
if [ -n "$py_files" ]; then
124124
echo "$py_files" | xargs ruff format || echo "::warning::ruff format exited with error"
125125
fi
126-
if [ -n "$(git diff --name-only)" ]; then
126+
# Trigger the auto-commit only when one of the SCOPED PR files
127+
# actually changed. A whole-tree `git diff` here also trips on
128+
# unrelated working-tree drift (e.g. an LFS smudge on a tracked
129+
# `*.png filter=lfs` file), which would set format_fixed=true while
130+
# the scoped `git add` below stages nothing — making `git commit`
131+
# fail with "nothing to commit". Diffing only the scoped files keeps
132+
# the trigger aligned with what the commit step can actually stage.
133+
# shellcheck disable=SC2046 # intentional split: each path is a
134+
# separate `git diff` pathspec arg; the `-s` guard rules out the
135+
# empty-arg (whole-tree) case, and PR paths never contain spaces.
136+
if [ -s .pr-format-files.existing.txt ] && \
137+
! git diff --quiet -- $(cat .pr-format-files.existing.txt); then
127138
echo "format_fixed=true" >> "$GITHUB_ENV"
128139
fi
129140
# Check mode: verify everything is formatted
@@ -161,6 +172,14 @@ jobs:
161172
# leaving formatting violations on the PR branch and (post-
162173
# merge) on main.
163174
xargs -a .pr-format-files.existing.txt git add --
175+
# Guard against an empty staged set: if the scoped `git add` staged
176+
# nothing (e.g. the whole-tree drift that set format_fixed=true lives
177+
# entirely outside the scoped files), `git commit` would exit 1 and
178+
# fail the job. Treat an empty index as a no-op instead.
179+
if git diff --cached --quiet; then
180+
echo "No scoped formatting changes to commit"
181+
exit 0
182+
fi
164183
git commit -m "style: auto-fix formatting"
165184
git push
166185

examples/shadcn/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OPENAI_API_KEY=
2+
COPILOTKIT_MODEL=openai/gpt-5.4

examples/shadcn/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
.pnpm-store/
3+
.next/
4+
out/
5+
dist/
6+
*.tsbuildinfo
7+
.env*
8+
!.env.example

examples/shadcn/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# CopilotKit x ShadCN
2+
3+
https://github.com/user-attachments/assets/f0059b04-ad68-4563-ad7a-e574c64e42d0
4+
5+
A compact Next.js example showing how to build a custom CopilotKit chat UI with
6+
ShadCN-style primitives. It uses `useAgent` with a CopilotKit Built-in Agent at
7+
`/api/copilotkit`, renders assistant messages with local chat components, and
8+
includes two frontend interactions:
9+
10+
- A generated line chart rendered through `useFrontendTool`
11+
- A human-in-the-loop taco rain picker rendered through `useHumanInTheLoop`
12+
13+
The app intentionally keeps the chat prompt fixed to make the demo repeatable.
14+
15+
## Prerequisites
16+
17+
- Node.js 20 or newer
18+
- pnpm, via Corepack or your local install. The example declares
19+
`pnpm@10.33.4` in `package.json`.
20+
- An OpenAI API key
21+
22+
## Environment Variables
23+
24+
Create a local environment file:
25+
26+
```bash
27+
cp .env.example .env.local
28+
```
29+
30+
Then set:
31+
32+
```bash
33+
OPENAI_API_KEY=sk-...
34+
COPILOTKIT_MODEL=openai/gpt-5.4
35+
```
36+
37+
`OPENAI_API_KEY` is required for the Built-in Agent. `COPILOTKIT_MODEL` is
38+
optional and defaults to `openai/gpt-5.4` in `app/api/copilotkit/route.ts`.
39+
40+
## Setup
41+
42+
From this example directory:
43+
44+
```bash
45+
cd examples/shadcn
46+
corepack enable
47+
pnpm install
48+
pnpm dev
49+
```
50+
51+
Open the local URL printed by Next.js, usually
52+
`http://localhost:3000`.
53+
54+
## Try It
55+
56+
Press the send button to run each queued example:
57+
58+
1. Ask for a brief explanation of ShadCN
59+
2. Render a simple generated line chart
60+
3. Open the taco rain picker, choose an emoji, and make it rain
61+
62+
Use the reset button in the chat header to replay the sequence.
63+
64+
## Available Checks
65+
66+
```bash
67+
pnpm typecheck
68+
pnpm lint
69+
pnpm build
70+
```
71+
72+
`pnpm check-types` is also available as an alias for `pnpm typecheck`.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
CopilotRuntime,
3+
copilotRuntimeNextJSAppRouterEndpoint,
4+
} from "@copilotkit/runtime";
5+
import { BuiltInAgent } from "@copilotkit/runtime/v2";
6+
7+
const agent = new BuiltInAgent({
8+
model: process.env.COPILOTKIT_MODEL ?? "openai/gpt-5.4",
9+
prompt: `
10+
You are a concise assistant for a CopilotKit + ShadCN demo.
11+
Answer briefly. Use renderLineChart only when the user asks for a chart, and
12+
call it exactly once. Use makeItRain only when the user asks for the taco rain
13+
picker or emoji picker. Keep surrounding text short.
14+
`,
15+
});
16+
17+
const runtime = new CopilotRuntime({
18+
agents: {
19+
default: agent,
20+
},
21+
});
22+
23+
export const POST = async (request: Request) => {
24+
if (!process.env.OPENAI_API_KEY) {
25+
return new Response(
26+
"Missing OPENAI_API_KEY. Set it in examples/shadcn/.env.local and restart the dev server.",
27+
{ status: 500 },
28+
);
29+
}
30+
31+
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
32+
runtime,
33+
endpoint: "/api/copilotkit",
34+
});
35+
36+
return handleRequest(request);
37+
};

examples/shadcn/app/globals.css

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
@import "tailwindcss";
2+
@import "tw-animate-css";
3+
@import "shadcn/tailwind.css";
4+
5+
@custom-variant dark (&:is(.dark *));
6+
7+
@theme inline {
8+
--color-background: var(--background);
9+
--color-foreground: var(--foreground);
10+
--color-card: var(--card);
11+
--color-card-foreground: var(--card-foreground);
12+
--color-popover: var(--popover);
13+
--color-popover-foreground: var(--popover-foreground);
14+
--color-primary: var(--primary);
15+
--color-primary-foreground: var(--primary-foreground);
16+
--color-secondary: var(--secondary);
17+
--color-secondary-foreground: var(--secondary-foreground);
18+
--color-muted: var(--muted);
19+
--color-muted-foreground: var(--muted-foreground);
20+
--color-accent: var(--accent);
21+
--color-accent-foreground: var(--accent-foreground);
22+
--color-destructive: var(--destructive);
23+
--color-border: var(--border);
24+
--color-input: var(--input);
25+
--color-ring: var(--ring);
26+
--radius-sm: calc(var(--radius) - 4px);
27+
--radius-md: calc(var(--radius) - 2px);
28+
--radius-lg: var(--radius);
29+
--radius-xl: calc(var(--radius) + 4px);
30+
--font-heading: var(--font-sans);
31+
--font-sans: var(--font-sans);
32+
--color-sidebar-ring: var(--sidebar-ring);
33+
--color-sidebar-border: var(--sidebar-border);
34+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
35+
--color-sidebar-accent: var(--sidebar-accent);
36+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
37+
--color-sidebar-primary: var(--sidebar-primary);
38+
--color-sidebar-foreground: var(--sidebar-foreground);
39+
--color-sidebar: var(--sidebar);
40+
--color-chart-5: var(--chart-5);
41+
--color-chart-4: var(--chart-4);
42+
--color-chart-3: var(--chart-3);
43+
--color-chart-2: var(--chart-2);
44+
--color-chart-1: var(--chart-1);
45+
--radius-2xl: calc(var(--radius) * 1.8);
46+
--radius-3xl: calc(var(--radius) * 2.2);
47+
--radius-4xl: calc(var(--radius) * 2.6);
48+
}
49+
50+
@layer base {
51+
:root {
52+
--radius: 0.625rem;
53+
--background: oklch(0.97 0 0);
54+
--foreground: oklch(0.145 0 0);
55+
--card: oklch(1 0 0);
56+
--card-foreground: oklch(0.145 0 0);
57+
--popover: oklch(1 0 0);
58+
--popover-foreground: oklch(0.145 0 0);
59+
--primary: oklch(0.55 0.22 263);
60+
--primary-foreground: oklch(0.985 0 0);
61+
--secondary: oklch(0.92 0 0);
62+
--secondary-foreground: oklch(0.205 0 0);
63+
--muted: oklch(0.94 0 0);
64+
--muted-foreground: oklch(0.48 0 0);
65+
--accent: oklch(0.94 0 0);
66+
--accent-foreground: oklch(0.205 0 0);
67+
--destructive: oklch(0.577 0.245 27.325);
68+
--border: oklch(0.89 0 0);
69+
--input: oklch(0.89 0 0);
70+
--ring: oklch(0.55 0.22 263);
71+
}
72+
73+
* {
74+
@apply border-border outline-ring/50;
75+
}
76+
77+
body {
78+
@apply bg-background text-foreground antialiased;
79+
}
80+
html {
81+
@apply font-sans;
82+
}
83+
}
84+
85+
:root {
86+
--background: oklch(1 0 0);
87+
--foreground: oklch(0.145 0 0);
88+
--card: oklch(1 0 0);
89+
--card-foreground: oklch(0.145 0 0);
90+
--popover: oklch(1 0 0);
91+
--popover-foreground: oklch(0.145 0 0);
92+
--primary: oklch(0.205 0 0);
93+
--primary-foreground: oklch(0.985 0 0);
94+
--secondary: oklch(0.97 0 0);
95+
--secondary-foreground: oklch(0.205 0 0);
96+
--muted: oklch(0.97 0 0);
97+
--muted-foreground: oklch(0.556 0 0);
98+
--accent: oklch(0.97 0 0);
99+
--accent-foreground: oklch(0.205 0 0);
100+
--destructive: oklch(0.577 0.245 27.325);
101+
--border: oklch(0.922 0 0);
102+
--input: oklch(0.922 0 0);
103+
--ring: oklch(0.708 0 0);
104+
--chart-1: oklch(0.62 0.22 255);
105+
--chart-2: oklch(0.66 0.18 155);
106+
--chart-3: oklch(0.72 0.19 80);
107+
--chart-4: oklch(0.64 0.2 330);
108+
--chart-5: oklch(0.6 0.2 25);
109+
--radius: 0.625rem;
110+
--sidebar: oklch(0.985 0 0);
111+
--sidebar-foreground: oklch(0.145 0 0);
112+
--sidebar-primary: oklch(0.205 0 0);
113+
--sidebar-primary-foreground: oklch(0.985 0 0);
114+
--sidebar-accent: oklch(0.97 0 0);
115+
--sidebar-accent-foreground: oklch(0.205 0 0);
116+
--sidebar-border: oklch(0.922 0 0);
117+
--sidebar-ring: oklch(0.708 0 0);
118+
}
119+
120+
.dark {
121+
--background: oklch(0.145 0 0);
122+
--foreground: oklch(0.985 0 0);
123+
--card: oklch(0.205 0 0);
124+
--card-foreground: oklch(0.985 0 0);
125+
--popover: oklch(0.205 0 0);
126+
--popover-foreground: oklch(0.985 0 0);
127+
--primary: oklch(0.922 0 0);
128+
--primary-foreground: oklch(0.205 0 0);
129+
--secondary: oklch(0.269 0 0);
130+
--secondary-foreground: oklch(0.985 0 0);
131+
--muted: oklch(0.269 0 0);
132+
--muted-foreground: oklch(0.708 0 0);
133+
--accent: oklch(0.269 0 0);
134+
--accent-foreground: oklch(0.985 0 0);
135+
--destructive: oklch(0.704 0.191 22.216);
136+
--border: oklch(1 0 0 / 10%);
137+
--input: oklch(1 0 0 / 15%);
138+
--ring: oklch(0.556 0 0);
139+
--chart-1: oklch(0.72 0.18 255);
140+
--chart-2: oklch(0.74 0.15 155);
141+
--chart-3: oklch(0.78 0.17 80);
142+
--chart-4: oklch(0.74 0.17 330);
143+
--chart-5: oklch(0.72 0.17 25);
144+
--sidebar: oklch(0.205 0 0);
145+
--sidebar-foreground: oklch(0.985 0 0);
146+
--sidebar-primary: oklch(0.488 0.243 264.376);
147+
--sidebar-primary-foreground: oklch(0.985 0 0);
148+
--sidebar-accent: oklch(0.269 0 0);
149+
--sidebar-accent-foreground: oklch(0.985 0 0);
150+
--sidebar-border: oklch(1 0 0 / 10%);
151+
--sidebar-ring: oklch(0.556 0 0);
152+
}

examples/shadcn/app/layout.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { Metadata } from "next";
2+
import "./globals.css";
3+
import { Inter } from "next/font/google";
4+
import { Providers } from "./providers";
5+
import { cn } from "@/lib/utils";
6+
7+
const inter = Inter({ subsets: ["latin"], variable: "--font-sans" });
8+
9+
export const metadata: Metadata = {
10+
title: "CopilotKit ShadCN Chat",
11+
description:
12+
"A minimal useAgent demo with chat, charts, and human-in-the-loop UI.",
13+
};
14+
15+
export default function RootLayout({
16+
children,
17+
}: Readonly<{
18+
children: React.ReactNode;
19+
}>) {
20+
return (
21+
<html lang="en" className={cn("font-sans", inter.variable)}>
22+
<body>
23+
<Providers>{children}</Providers>
24+
</body>
25+
</html>
26+
);
27+
}

examples/shadcn/app/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { SimpleChat } from "@/components/simple-chat";
2+
3+
export default function Home() {
4+
return <SimpleChat />;
5+
}

examples/shadcn/app/providers.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use client";
2+
3+
import type { ReactNode } from "react";
4+
5+
import { CopilotKit } from "@copilotkit/react-core/v2";
6+
import { TooltipProvider } from "@/components/ui/tooltip";
7+
8+
function Providers({ children }: { children: ReactNode }) {
9+
return (
10+
<CopilotKit runtimeUrl="/api/copilotkit" enableInspector={false}>
11+
<TooltipProvider>{children}</TooltipProvider>
12+
</CopilotKit>
13+
);
14+
}
15+
16+
export { Providers };

0 commit comments

Comments
 (0)