chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:58:18 +08:00
commit 6d5d58c1a9
18293 changed files with 3502153 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
"use client";
import {
CopilotKit,
useCopilotAction,
useCopilotReadable,
} from "@copilotkit/react-core";
import { CopilotTextarea } from "@copilotkit/react-textarea";
import { CopilotSidebar } from "@copilotkit/react-ui";
import "@copilotkit/react-ui/styles.css";
import { useState } from "react";
import "@copilotkit/react-textarea/styles.css";
import "@copilotkit/react-ui/styles.css";
function InsideHome() {
const [message, setMessage] = useState("Hello World!");
const [text, setText] = useState("");
useCopilotReadable({
description: "This is the current message",
value: message,
});
useCopilotAction(
{
name: "displayMessage",
description: "Display a message.",
parameters: [
{
name: "message",
type: "string",
description: "The message to display.",
required: true,
},
],
handler: async ({ message }) => {
setMessage(message);
},
},
[],
);
return (
<>
<div>{message}</div>
</>
);
}
export default function Home() {
return (
<CopilotKit url="http://localhost:4000" properties={{ userId: "xyz" }}>
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+33
View File
@@ -0,0 +1,33 @@
import * as http from "http";
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNodeHttpEndpoint,
} from "@copilotkit/runtime";
const port = 4000;
var HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "X-Requested-With,content-type",
};
const handler = copilotRuntimeNodeHttpEndpoint({
endpoint: "/",
runtime: new CopilotRuntime(),
serviceAdapter: new OpenAIAdapter(),
});
var server = http.createServer(function (req, res) {
// Respond to OPTIONS (preflight) request
if (req.method === "OPTIONS") {
res.writeHead(200, HEADERS);
res.end();
return;
}
return handler(req, res);
});
server.listen(port, function () {
console.log(`Server running at http://localhost:${port}`);
});
+58
View File
@@ -0,0 +1,58 @@
"use client";
import {
CopilotKit,
useCopilotAction,
useCopilotReadable,
} from "@copilotkit/react-core";
import { CopilotTextarea } from "@copilotkit/react-textarea";
import { CopilotSidebar } from "@copilotkit/react-ui";
import "@copilotkit/react-ui/styles.css";
import { useState } from "react";
import "@copilotkit/react-textarea/styles.css";
import "@copilotkit/react-ui/styles.css";
function InsideHome() {
const [message, setMessage] = useState("Hello World!");
const [text, setText] = useState("");
useCopilotReadable({
description: "This is the current message",
value: message,
});
useCopilotAction(
{
name: "displayMessage",
description: "Display a message.",
parameters: [
{
name: "message",
type: "string",
description: "The message to display.",
required: true,
},
],
handler: async ({ message }) => {
setMessage(message);
},
},
[],
);
return (
<>
<div>{message}</div>
</>
);
}
export default function Home() {
return (
<CopilotKit url="http://localhost:4000">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+22
View File
@@ -0,0 +1,22 @@
import * as http from "http";
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend";
const port = 4000;
var HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "X-Requested-With,content-type",
};
var server = http.createServer(function (req, res) {
// Respond to OPTIONS (preflight) request
if (req.method === "OPTIONS") {
res.writeHead(200, HEADERS);
res.end();
return;
}
var copilotKit = new CopilotRuntime();
copilotKit.streamHttpServerResponse(req, res, new OpenAIAdapter(), HEADERS);
});
server.listen(port, function () {
console.log(`Server running at http://localhost:${port}`);
});