Skip to content

Commit b8190c1

Browse files
committed
qol
1 parent d2aeeb8 commit b8190c1

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

integrations/mastra/typescript/src/copilotkit.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,34 @@ import { RequestContext } from "@mastra/core/request-context";
99
import { registerApiRoute } from "@mastra/core/server";
1010
import { MastraAgent } from "./mastra";
1111

12-
export function registerCopilotKit<T extends Record<string, any> | unknown = unknown>({
12+
/**
13+
* Registers a CopilotKit endpoint that exposes Mastra agents through the AG-UI protocol.
14+
* This function creates an API route that handles CopilotKit requests and forwards them to Mastra agents, enabling seamless integration between CopilotKit's UI components and Mastra's agent framework.
15+
*
16+
* @example
17+
* ```ts
18+
* registerCopilotKit({
19+
* path: "/api/copilotkit"
20+
* });
21+
* ```
22+
*/
23+
export function registerCopilotKit<
24+
T extends Record<string, any> | unknown = unknown,
25+
>({
1326
path,
1427
resourceId,
1528
serviceAdapter = new ExperimentalEmptyAdapter(),
1629
agents,
1730
setContext,
1831
}: {
1932
path: string;
20-
resourceId: string;
33+
resourceId?: string;
2134
serviceAdapter?: CopilotServiceAdapter;
2235
agents?: Record<string, AbstractAgent>;
23-
setContext?: (c: any, requestContext: RequestContext<T>) => void | Promise<void>;
36+
setContext?: (
37+
c: any,
38+
requestContext: RequestContext<T>,
39+
) => void | Promise<void>;
2440
}) {
2541
return registerApiRoute(path, {
2642
method: `ALL`,

0 commit comments

Comments
 (0)