@copilotkitnext/runtime 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/runtime.always.mdc +9 -0
- package/LICENSE +21 -0
- package/dist/chunk-3QLKFSXI.mjs +964 -0
- package/dist/chunk-3QLKFSXI.mjs.map +1 -0
- package/dist/express.d.mts +19 -0
- package/dist/express.d.ts +19 -0
- package/dist/express.js +1120 -0
- package/dist/express.js.map +1 -0
- package/dist/express.mjs +391 -0
- package/dist/express.mjs.map +1 -0
- package/dist/index.d.mts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +1221 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +257 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runtime-BEcxV64L.d.mts +97 -0
- package/dist/runtime-BEcxV64L.d.ts +97 -0
- package/eslint.config.mjs +3 -0
- package/package.json +63 -0
- package/vitest.config.mjs +15 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { MaybePromise, NonEmptyRecord } from '@copilotkitnext/shared';
|
|
2
|
+
import { AbstractAgent, RunAgentInput, BaseEvent } from '@ag-ui/client';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Middleware support for CopilotKit Runtime.
|
|
7
|
+
*
|
|
8
|
+
* A middleware hook can be provided as either:
|
|
9
|
+
* 1. A **callback function** executed in-process.
|
|
10
|
+
* 2. A **webhook URL** (http/https). The runtime will `POST` a JSON payload
|
|
11
|
+
* to the URL and, for *before* hooks, accept an optional modified
|
|
12
|
+
* `Request` object in the response body.
|
|
13
|
+
*
|
|
14
|
+
* Two lifecycle hooks are available:
|
|
15
|
+
* • `BEFORE_REQUEST` – runs *before* the request handler.
|
|
16
|
+
* • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface BeforeRequestMiddlewareParameters {
|
|
20
|
+
runtime: CopilotRuntime;
|
|
21
|
+
request: Request;
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
interface AfterRequestMiddlewareParameters {
|
|
25
|
+
runtime: CopilotRuntime;
|
|
26
|
+
response: Response;
|
|
27
|
+
path: string;
|
|
28
|
+
}
|
|
29
|
+
type BeforeRequestMiddlewareFn = (params: BeforeRequestMiddlewareParameters) => MaybePromise<Request | void>;
|
|
30
|
+
type AfterRequestMiddlewareFn = (params: AfterRequestMiddlewareParameters) => MaybePromise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* A middleware value can be either a callback function or a webhook URL.
|
|
33
|
+
*/
|
|
34
|
+
type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;
|
|
35
|
+
type AfterRequestMiddleware = AfterRequestMiddlewareFn;
|
|
36
|
+
|
|
37
|
+
interface TranscribeFileOptions {
|
|
38
|
+
audioFile: File;
|
|
39
|
+
/** MIME type of the audio file */
|
|
40
|
+
mimeType?: string;
|
|
41
|
+
/** Size of the audio file in bytes */
|
|
42
|
+
size?: number;
|
|
43
|
+
}
|
|
44
|
+
declare abstract class TranscriptionService {
|
|
45
|
+
abstract transcribeFile(options: TranscribeFileOptions): Promise<string>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface AgentRunnerRunRequest {
|
|
49
|
+
threadId: string;
|
|
50
|
+
agent: AbstractAgent;
|
|
51
|
+
input: RunAgentInput;
|
|
52
|
+
}
|
|
53
|
+
interface AgentRunnerConnectRequest {
|
|
54
|
+
threadId: string;
|
|
55
|
+
}
|
|
56
|
+
interface AgentRunnerIsRunningRequest {
|
|
57
|
+
threadId: string;
|
|
58
|
+
}
|
|
59
|
+
interface AgentRunnerStopRequest {
|
|
60
|
+
threadId: string;
|
|
61
|
+
}
|
|
62
|
+
declare abstract class AgentRunner {
|
|
63
|
+
abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;
|
|
64
|
+
abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;
|
|
65
|
+
abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;
|
|
66
|
+
abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare const VERSION: string;
|
|
70
|
+
/**
|
|
71
|
+
* Options used to construct a `CopilotRuntime` instance.
|
|
72
|
+
*/
|
|
73
|
+
interface CopilotRuntimeOptions {
|
|
74
|
+
/** Map of available agents (loaded lazily is fine). */
|
|
75
|
+
agents: MaybePromise<NonEmptyRecord<Record<string, AbstractAgent>>>;
|
|
76
|
+
/** The runner to use for running agents. */
|
|
77
|
+
runner?: AgentRunner;
|
|
78
|
+
/** Optional transcription service for audio processing. */
|
|
79
|
+
transcriptionService?: TranscriptionService;
|
|
80
|
+
/** Optional *before* middleware – callback function or webhook URL. */
|
|
81
|
+
beforeRequestMiddleware?: BeforeRequestMiddleware;
|
|
82
|
+
/** Optional *after* middleware – callback function or webhook URL. */
|
|
83
|
+
afterRequestMiddleware?: AfterRequestMiddleware;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Central runtime object passed to all request handlers.
|
|
87
|
+
*/
|
|
88
|
+
declare class CopilotRuntime {
|
|
89
|
+
agents: CopilotRuntimeOptions["agents"];
|
|
90
|
+
transcriptionService: CopilotRuntimeOptions["transcriptionService"];
|
|
91
|
+
beforeRequestMiddleware: CopilotRuntimeOptions["beforeRequestMiddleware"];
|
|
92
|
+
afterRequestMiddleware: CopilotRuntimeOptions["afterRequestMiddleware"];
|
|
93
|
+
runner: AgentRunner;
|
|
94
|
+
constructor({ agents, transcriptionService, beforeRequestMiddleware, afterRequestMiddleware, runner, }: CopilotRuntimeOptions);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { AgentRunner as A, CopilotRuntime as C, VERSION as V, type AgentRunnerRunRequest as a, type AgentRunnerConnectRequest as b, type AgentRunnerIsRunningRequest as c, type AgentRunnerStopRequest as d, type CopilotRuntimeOptions as e };
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@copilotkitnext/runtime",
|
|
3
|
+
"version": "0.0.0-0.0.0-max-changeset-10101010101010-20260109191632",
|
|
4
|
+
"description": "Server-side runtime package for CopilotKit2",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./express": {
|
|
14
|
+
"types": "./dist/express.d.ts",
|
|
15
|
+
"import": "./dist/express.mjs",
|
|
16
|
+
"require": "./dist/express.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/cors": "^2.8.17",
|
|
24
|
+
"@types/express": "^4.17.21",
|
|
25
|
+
"@types/node": "^22.15.3",
|
|
26
|
+
"eslint": "^9.30.0",
|
|
27
|
+
"openai": "^5.9.0",
|
|
28
|
+
"supertest": "^7.1.1",
|
|
29
|
+
"tsup": "^8.5.0",
|
|
30
|
+
"typescript": "5.8.2",
|
|
31
|
+
"vitest": "^3.0.5",
|
|
32
|
+
"@copilotkitnext/eslint-config": "0.0.0-0.0.0-max-changeset-10101010101010-20260109191632",
|
|
33
|
+
"@copilotkitnext/shared": "0.0.0-0.0.0-max-changeset-10101010101010-20260109191632",
|
|
34
|
+
"@copilotkitnext/typescript-config": "0.0.0-0.0.0-max-changeset-10101010101010-20260109191632"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"cors": "^2.8.5",
|
|
38
|
+
"express": "^4.21.2",
|
|
39
|
+
"hono": "^4.6.13",
|
|
40
|
+
"rxjs": "7.8.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@ag-ui/client": "0.0.42",
|
|
44
|
+
"@ag-ui/core": "0.0.42",
|
|
45
|
+
"@ag-ui/encoder": "0.0.42",
|
|
46
|
+
"openai": "^5.9.0",
|
|
47
|
+
"@copilotkitnext/shared": "0.0.0-0.0.0-max-changeset-10101010101010-20260109191632"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup",
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"lint": "eslint . --max-warnings 0",
|
|
57
|
+
"check-types": "tsc --noEmit",
|
|
58
|
+
"clean": "rm -rf dist",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest",
|
|
61
|
+
"test:coverage": "vitest run --coverage"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: "node",
|
|
6
|
+
globals: true,
|
|
7
|
+
include: ["src/**/__tests__/**/*.{test,spec}.ts"],
|
|
8
|
+
coverage: {
|
|
9
|
+
reporter: ["text", "lcov", "html"],
|
|
10
|
+
include: ["src/**/*.ts"],
|
|
11
|
+
exclude: ["src/**/*.d.ts", "src/**/index.ts"],
|
|
12
|
+
},
|
|
13
|
+
setupFiles: [],
|
|
14
|
+
},
|
|
15
|
+
});
|