chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
PORT=4000
|
||||
@@ -0,0 +1,311 @@
|
||||
# @copilotkit/node-express
|
||||
|
||||
## 1.55.0-next.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8aafcbe]
|
||||
- @copilotkit/runtime@1.55.0-next.8
|
||||
|
||||
## 1.55.0-next.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1ceb963]
|
||||
- @copilotkit/runtime@1.55.0-next.7
|
||||
|
||||
## 1.54.1-next.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.1-next.6
|
||||
- @copilotkitnext/runtime@1.54.1-next.6
|
||||
|
||||
## 1.54.1-next.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.1-next.5
|
||||
- @copilotkitnext/runtime@1.54.1-next.5
|
||||
|
||||
## 1.54.1-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.1-next.4
|
||||
- @copilotkitnext/runtime@1.54.1-next.4
|
||||
|
||||
## 1.54.1-next.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.1-next.3
|
||||
- @copilotkitnext/runtime@1.54.1-next.3
|
||||
|
||||
## 1.54.1-next.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.1-next.2
|
||||
- @copilotkitnext/runtime@1.54.1-next.2
|
||||
|
||||
## 1.54.1-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.1-next.1
|
||||
- @copilotkitnext/runtime@1.54.1-next.1
|
||||
|
||||
## 1.54.1-next.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [da558d3]
|
||||
- @copilotkitnext/agent@1.54.1-next.0
|
||||
- @copilotkitnext/runtime@1.54.1-next.0
|
||||
|
||||
## 1.54.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3780c6a]
|
||||
- Updated dependencies [fa0d1cd]
|
||||
- @copilotkitnext/agent@1.54.0
|
||||
- @copilotkitnext/runtime@1.54.0
|
||||
|
||||
## 1.54.0-next.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [3780c6a]
|
||||
- @copilotkitnext/agent@1.54.0-next.9
|
||||
- @copilotkitnext/runtime@1.54.0-next.9
|
||||
|
||||
## 1.54.0-next.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.0-next.8
|
||||
- @copilotkitnext/runtime@1.54.0-next.8
|
||||
|
||||
## 1.54.0-next.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.0-next.7
|
||||
- @copilotkitnext/runtime@1.54.0-next.7
|
||||
|
||||
## 1.54.0-next.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.0-next.6
|
||||
- @copilotkitnext/runtime@1.54.0-next.6
|
||||
|
||||
## 1.54.0-next.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.0-next.5
|
||||
- @copilotkitnext/runtime@1.54.0-next.5
|
||||
|
||||
## 1.54.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkitnext/agent@1.54.0-next.4
|
||||
- @copilotkitnext/runtime@1.54.0-next.4
|
||||
|
||||
## 1.54.0-next.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fa0d1cd]
|
||||
- @copilotkitnext/agent@1.54.0-next.3
|
||||
- @copilotkitnext/runtime@1.54.0-next.3
|
||||
|
||||
## 1.53.1-next.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.53.1-next.2
|
||||
- @copilotkit/runtime@1.53.1-next.2
|
||||
|
||||
## 1.53.1-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.53.1-next.1
|
||||
- @copilotkit/runtime@1.53.1-next.1
|
||||
|
||||
## 1.53.1-next.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.53.1-next.0
|
||||
- @copilotkit/runtime@1.53.1-next.0
|
||||
|
||||
## 1.53.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1510f64]
|
||||
- @copilotkit/agent@1.53.0
|
||||
- @copilotkit/runtime@1.53.0
|
||||
|
||||
## 1.53.0-next.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.53.0-next.6
|
||||
- @copilotkit/runtime@1.53.0-next.6
|
||||
|
||||
## 1.53.0-next.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.53.0-next.5
|
||||
- @copilotkit/runtime@1.53.0-next.5
|
||||
|
||||
## 1.52.2-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.2-next.4
|
||||
- @copilotkit/runtime@1.52.2-next.4
|
||||
|
||||
## 1.52.2-next.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1510f64]
|
||||
- @copilotkit/agent@1.52.2-next.3
|
||||
- @copilotkit/runtime@1.52.2-next.3
|
||||
|
||||
## 1.52.2-next.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.2-next.2
|
||||
- @copilotkit/runtime@1.52.2-next.2
|
||||
|
||||
## 1.52.2-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.2-next.1
|
||||
- @copilotkit/runtime@1.52.2-next.1
|
||||
|
||||
## 1.52.2-next.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.2-next.0
|
||||
- @copilotkit/runtime@1.52.2-next.0
|
||||
|
||||
## 1.52.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.1
|
||||
- @copilotkit/runtime@1.52.1
|
||||
|
||||
## 1.52.1-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.1-next.1
|
||||
- @copilotkit/runtime@1.52.1-next.1
|
||||
|
||||
## 1.52.1-next.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.1-next.0
|
||||
- @copilotkit/runtime@1.52.1-next.0
|
||||
|
||||
## 1.52.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ef0f539]
|
||||
- @copilotkit/runtime@1.52.0
|
||||
- @copilotkit/agent@1.52.0
|
||||
|
||||
## 1.52.0-next.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.0-next.8
|
||||
- @copilotkit/runtime@1.52.0-next.8
|
||||
|
||||
## 1.52.0-next.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.0-next.7
|
||||
- @copilotkit/runtime@1.52.0-next.7
|
||||
|
||||
## 1.52.0-next.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.0-next.6
|
||||
- @copilotkit/runtime@1.52.0-next.6
|
||||
|
||||
## 1.52.0-next.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.52.0-next.5
|
||||
- @copilotkit/runtime@1.52.0-next.5
|
||||
|
||||
## 1.51.5-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.51.5-next.4
|
||||
- @copilotkit/runtime@1.51.5-next.4
|
||||
|
||||
## 1.51.5-next.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.51.5-next.3
|
||||
- @copilotkit/runtime@1.51.5-next.3
|
||||
|
||||
## 1.51.5-next.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.51.5-next.2
|
||||
- @copilotkit/runtime@1.51.5-next.2
|
||||
|
||||
## 1.51.5-next.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.51.5-next.1
|
||||
- @copilotkit/runtime@1.51.5-next.1
|
||||
|
||||
## 1.51.5-next.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ef0f539]
|
||||
- @copilotkit/runtime@1.51.5-next.0
|
||||
- @copilotkit/agent@1.51.5-next.0
|
||||
|
||||
## 1.51.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.51.4
|
||||
- @copilotkit/runtime@1.51.4
|
||||
|
||||
## 1.51.4-next.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @copilotkit/agent@1.51.4-next.8
|
||||
- @copilotkit/runtime@1.51.4-next.8
|
||||
@@ -0,0 +1,40 @@
|
||||
# CopilotKit v2 Express Example (Single Route)
|
||||
|
||||
This example hosts a CopilotKit v2 runtime using Express and the single-route helper.
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
pnpm -C ../../ install
|
||||
```
|
||||
|
||||
Create a local env file:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Set `OPENAI_API_KEY` in `.env`.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
pnpm -C ../../ --filter node-express example-dev
|
||||
```
|
||||
|
||||
The runtime will be available at:
|
||||
|
||||
```
|
||||
http://localhost:4000/api/copilotkit
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
pnpm -C ../../ --filter node-express example-build
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- This example uses `createCopilotEndpointSingleRouteExpress`.
|
||||
- TypeScript uses `moduleResolution: node16` to resolve the `@copilotkit/runtime/express` export correctly.
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@copilotkit/node-express",
|
||||
"version": "1.55.0-next.8",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-dev": "tsx watch src/index.ts",
|
||||
"example-build": "tsc",
|
||||
"example-start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:*",
|
||||
"dotenv": "^16.4.7",
|
||||
"express": "^4.21.2",
|
||||
"zod": "^3.25.75"
|
||||
},
|
||||
"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,51 @@
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
CopilotRuntime,
|
||||
createCopilotEndpointSingleRouteExpress,
|
||||
BuiltInAgent,
|
||||
defineTool,
|
||||
ToolDefinition,
|
||||
} from "@copilotkit/runtime/v2";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const roastTool = defineTool({
|
||||
name: "sayHello",
|
||||
description: "Say hello while roasting the user's name",
|
||||
parameters: z.object({
|
||||
roast: z.string().describe("A playful roast about the user's name"),
|
||||
}),
|
||||
execute: async ({ roast }) => {
|
||||
console.log(roast);
|
||||
return "The person has been roasted.";
|
||||
},
|
||||
}) as unknown as ToolDefinition;
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
agents: {
|
||||
default: new BuiltInAgent({
|
||||
model: "openai/gpt-4o-mini",
|
||||
tools: [roastTool],
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(
|
||||
"/api/copilotkit",
|
||||
createCopilotEndpointSingleRouteExpress({
|
||||
runtime,
|
||||
basePath: "/",
|
||||
}),
|
||||
);
|
||||
|
||||
const port = Number(process.env.PORT ?? 4000);
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(
|
||||
`CopilotKit v2 runtime listening at 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"]
|
||||
}
|
||||
Reference in New Issue
Block a user