chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@copilotkit/example-runtime-cf-workers",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "wrangler dev",
|
||||
"example-deploy": "wrangler deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20250214.0",
|
||||
"typescript": "^5.8.2",
|
||||
"wrangler": "^4.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
CopilotRuntime,
|
||||
createCopilotRuntimeHandler,
|
||||
BuiltInAgent,
|
||||
} from "@copilotkit/runtime/v2";
|
||||
|
||||
export interface Env {
|
||||
OPENAI_API_KEY: string;
|
||||
}
|
||||
|
||||
export default {
|
||||
async fetch(request: Request, env: Env): Promise<Response> {
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
||||
},
|
||||
});
|
||||
|
||||
const handler = createCopilotRuntimeHandler({
|
||||
runtime,
|
||||
basePath: "/api/copilotkit",
|
||||
cors: true,
|
||||
});
|
||||
|
||||
return handler(request);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"types": ["@cloudflare/workers-types"],
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
name = "copilotkit-runtime"
|
||||
main = "src/index.ts"
|
||||
compatibility_date = "2025-02-01"
|
||||
|
||||
[vars]
|
||||
PORT = "4006"
|
||||
@@ -0,0 +1,2 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
PORT=4005
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"nodeModulesDir": "manual",
|
||||
"tasks": {
|
||||
"dev": "deno run --allow-net --allow-env --allow-read --watch src/index.ts",
|
||||
"start": "deno run --allow-net --allow-env --allow-read src/index.ts"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "@copilotkit/example-runtime-deno",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "deno run --allow-net --allow-env --allow-read src/index.ts",
|
||||
"example-start": "deno run --allow-net --allow-env --allow-read src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
CopilotRuntime,
|
||||
createCopilotRuntimeHandler,
|
||||
BuiltInAgent,
|
||||
} from "@copilotkit/runtime/v2";
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
||||
},
|
||||
});
|
||||
|
||||
const handler = createCopilotRuntimeHandler({
|
||||
runtime,
|
||||
basePath: "/api/copilotkit",
|
||||
cors: true,
|
||||
});
|
||||
|
||||
const port = Number(Deno.env.get("PORT") ?? "4005");
|
||||
Deno.serve({ port }, handler);
|
||||
console.log(
|
||||
`Deno runtime listening on http://localhost:${port}/api/copilotkit`,
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
PORT=4004
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@copilotkit/example-runtime-elysia",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "bun run --watch src/index.ts",
|
||||
"example-build": "bun build src/index.ts --outdir dist",
|
||||
"example-start": "bun dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:^",
|
||||
"elysia": "^1.2.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.2.10",
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Elysia } from "elysia";
|
||||
import {
|
||||
CopilotRuntime,
|
||||
createCopilotRuntimeHandler,
|
||||
BuiltInAgent,
|
||||
} from "@copilotkit/runtime/v2";
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
||||
},
|
||||
});
|
||||
|
||||
const handler = createCopilotRuntimeHandler({ runtime, cors: true });
|
||||
|
||||
const port = Number(process.env.PORT ?? 4004);
|
||||
new Elysia()
|
||||
.all("/api/copilotkit/*", ({ request }) => handler(request))
|
||||
.listen(port);
|
||||
|
||||
console.log(
|
||||
`Elysia runtime listening on http://localhost:${port}/api/copilotkit`,
|
||||
);
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"types": ["bun-types"],
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
PORT=4002
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@copilotkit/example-runtime-express",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "tsx watch src/index.ts",
|
||||
"example-build": "tsc",
|
||||
"example-start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:^",
|
||||
"express": "^4.21.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@copilotkit/typescript-config": "workspace:^",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/node": "^22.10.7",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import express from "express";
|
||||
import { CopilotRuntime, BuiltInAgent } from "@copilotkit/runtime/v2";
|
||||
import { createCopilotExpressHandler } from "@copilotkit/runtime/v2/express";
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
||||
},
|
||||
});
|
||||
|
||||
const app = express();
|
||||
app.use(
|
||||
createCopilotExpressHandler({
|
||||
runtime,
|
||||
basePath: "/api/copilotkit",
|
||||
}),
|
||||
);
|
||||
|
||||
const port = Number(process.env.PORT ?? 4002);
|
||||
app.listen(port, () => {
|
||||
console.log(
|
||||
`Express runtime listening on http://localhost:${port}/api/copilotkit`,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": "@copilotkit/typescript-config/base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"module": "Node16",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node16",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
PORT=4003
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@copilotkit/example-runtime-hono",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "tsx watch src/index.ts",
|
||||
"example-build": "tsc",
|
||||
"example-start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:^",
|
||||
"@hono/node-server": "^1.13.6",
|
||||
"hono": "^4.7.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@copilotkit/typescript-config": "workspace:^",
|
||||
"@types/node": "^22.10.7",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Hono } from "hono";
|
||||
import { serve } from "@hono/node-server";
|
||||
import { CopilotRuntime, BuiltInAgent } from "@copilotkit/runtime/v2";
|
||||
import { createCopilotHonoHandler } from "@copilotkit/runtime/v2/hono";
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
||||
},
|
||||
});
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
// Root
|
||||
app.get("/", (c) =>
|
||||
c.json({ status: "ok", message: "CopilotKit Hono runtime" }),
|
||||
);
|
||||
|
||||
// Health check
|
||||
app.get("/health", (c) => c.json({ status: "healthy" }));
|
||||
|
||||
// CopilotKit endpoints
|
||||
app.route(
|
||||
"/",
|
||||
createCopilotHonoHandler({ runtime, basePath: "/api/copilotkit" }),
|
||||
);
|
||||
|
||||
const port = Number(process.env.PORT ?? 4003);
|
||||
serve({ fetch: app.fetch, port }, () => {
|
||||
console.log(`Hono runtime listening on http://localhost:${port}`);
|
||||
console.log(` CopilotKit: http://localhost:${port}/api/copilotkit`);
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": "@copilotkit/typescript-config/base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"module": "Node16",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node16",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
PORT=4001
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@copilotkit/example-runtime-node",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "tsx watch src/index.ts",
|
||||
"example-build": "tsc",
|
||||
"example-start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@copilotkit/typescript-config": "workspace:^",
|
||||
"@types/node": "^22.10.7",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { createServer } from "node:http";
|
||||
import {
|
||||
CopilotRuntime,
|
||||
createCopilotRuntimeHandler,
|
||||
BuiltInAgent,
|
||||
} from "@copilotkit/runtime/v2";
|
||||
import { createCopilotNodeHandler } from "@copilotkit/runtime/v2/node";
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
||||
},
|
||||
});
|
||||
|
||||
const copilotHandler = createCopilotRuntimeHandler({
|
||||
runtime,
|
||||
basePath: "/api/copilotkit",
|
||||
cors: true,
|
||||
});
|
||||
|
||||
const copilotNodeHandler = createCopilotNodeHandler(copilotHandler);
|
||||
|
||||
const server = createServer(async (req, res) => {
|
||||
const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
||||
|
||||
// CopilotKit endpoints
|
||||
if (url.pathname.startsWith("/api/copilotkit")) {
|
||||
return copilotNodeHandler(req, res);
|
||||
}
|
||||
|
||||
// Root
|
||||
if (url.pathname === "/") {
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(
|
||||
JSON.stringify({ status: "ok", message: "CopilotKit Node runtime" }),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Health check
|
||||
if (url.pathname === "/health") {
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ status: "healthy" }));
|
||||
return;
|
||||
}
|
||||
|
||||
// 404
|
||||
res.writeHead(404, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ error: "Not found" }));
|
||||
});
|
||||
|
||||
const port = Number(process.env.PORT ?? 4001);
|
||||
server.listen(port, () => {
|
||||
console.log(`Node runtime listening on http://localhost:${port}`);
|
||||
console.log(` CopilotKit: http://localhost:${port}/api/copilotkit`);
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": "@copilotkit/typescript-config/base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"module": "es2022",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Reference in New Issue
Block a user