@copilotkit/runtime 1.71.0 → 1.71.1

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.
Files changed (37) hide show
  1. package/dist/agent/index.cjs +1 -1
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts.map +1 -1
  4. package/dist/agent/index.d.mts.map +1 -1
  5. package/dist/agent/index.mjs +1 -1
  6. package/dist/agent/index.mjs.map +1 -1
  7. package/dist/package.cjs +3 -3
  8. package/dist/package.mjs +3 -3
  9. package/package.json +4 -5
  10. package/skills/runtime/SKILL.md +0 -98
  11. package/skills/runtime/references/agent-runners-custom.md +0 -161
  12. package/skills/runtime/references/agent-runners-in-memory.md +0 -79
  13. package/skills/runtime/references/agent-runners-sqlite.md +0 -90
  14. package/skills/runtime/references/agent-runners.md +0 -336
  15. package/skills/runtime/references/built-in-agent-factory-modes.md +0 -232
  16. package/skills/runtime/references/built-in-agent-helper-utilities.md +0 -123
  17. package/skills/runtime/references/built-in-agent-model-identifiers.md +0 -58
  18. package/skills/runtime/references/built-in-agent.md +0 -523
  19. package/skills/runtime/references/intelligence-mode.md +0 -364
  20. package/skills/runtime/references/middleware.md +0 -376
  21. package/skills/runtime/references/server-side-tools.md +0 -414
  22. package/skills/runtime/references/setup-endpoint.md +0 -503
  23. package/skills/runtime/references/transcription.md +0 -287
  24. package/skills/runtime/references/wiring-a2a.md +0 -40
  25. package/skills/runtime/references/wiring-adk.md +0 -45
  26. package/skills/runtime/references/wiring-ag2.md +0 -41
  27. package/skills/runtime/references/wiring-agno.md +0 -40
  28. package/skills/runtime/references/wiring-aws-strands.md +0 -59
  29. package/skills/runtime/references/wiring-crewai-crews.md +0 -51
  30. package/skills/runtime/references/wiring-crewai-flows.md +0 -45
  31. package/skills/runtime/references/wiring-external-agents.md +0 -348
  32. package/skills/runtime/references/wiring-langgraph.md +0 -49
  33. package/skills/runtime/references/wiring-llamaindex.md +0 -39
  34. package/skills/runtime/references/wiring-mastra.md +0 -70
  35. package/skills/runtime/references/wiring-mcp-apps-middleware.md +0 -73
  36. package/skills/runtime/references/wiring-ms-agent-framework.md +0 -41
  37. package/skills/runtime/references/wiring-pydantic-ai.md +0 -45
@@ -1,287 +0,0 @@
1
- # CopilotKit Transcription
2
-
3
- Subclass `TranscriptionService`, pass an instance to `CopilotRuntime({ transcriptionService })`,
4
- and the `POST /transcribe` endpoint lights up. The service has a single method,
5
- `transcribeFile`, that returns the transcript as a plain string.
6
-
7
- ## Setup
8
-
9
- ```typescript
10
- import {
11
- CopilotRuntime,
12
- createCopilotRuntimeHandler,
13
- TranscriptionService,
14
- type TranscribeFileOptions,
15
- } from "@copilotkit/runtime/v2";
16
- import OpenAI from "openai";
17
-
18
- class OpenAIWhisperTranscription extends TranscriptionService {
19
- private client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
20
-
21
- async transcribeFile({ audioFile }: TranscribeFileOptions): Promise<string> {
22
- const result = await this.client.audio.transcriptions.create({
23
- file: audioFile,
24
- model: "whisper-1",
25
- });
26
- return result.text;
27
- }
28
- }
29
-
30
- const runtime = new CopilotRuntime({
31
- agents: {
32
- /* ... */
33
- } as any,
34
- transcriptionService: new OpenAIWhisperTranscription(),
35
- });
36
-
37
- const handler = createCopilotRuntimeHandler({
38
- runtime,
39
- basePath: "/api/copilotkit",
40
- });
41
-
42
- export default { fetch: handler };
43
- ```
44
-
45
- ## Core Patterns
46
-
47
- ### Abstract contract
48
-
49
- ```typescript
50
- // packages/runtime/src/v2/runtime/transcription-service/transcription-service.ts
51
- export interface TranscribeFileOptions {
52
- audioFile: File;
53
- mimeType?: string;
54
- size?: number;
55
- }
56
-
57
- export abstract class TranscriptionService {
58
- abstract transcribeFile(options: TranscribeFileOptions): Promise<string>;
59
- }
60
- ```
61
-
62
- ### Supported request shapes
63
-
64
- Multipart (REST mode):
65
-
66
- ```typescript
67
- const form = new FormData();
68
- form.append("audio", blob, "recording.webm");
69
- await fetch("/api/copilotkit/transcribe", { method: "POST", body: form });
70
- ```
71
-
72
- JSON (works in both multi-route and single-endpoint modes — dispatch is by
73
- `Content-Type: application/json`; `mimeType` is required in the payload):
74
-
75
- ```typescript
76
- await fetch("/api/copilotkit/transcribe", {
77
- method: "POST",
78
- headers: { "Content-Type": "application/json" },
79
- body: JSON.stringify({
80
- audio: base64String,
81
- mimeType: "audio/webm",
82
- filename: "recording.webm", // optional
83
- }),
84
- });
85
- ```
86
-
87
- ### Reject oversize audio with a graceful 400
88
-
89
- ```typescript
90
- class OpenAIWhisperTranscription extends TranscriptionService {
91
- private client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
92
-
93
- async transcribeFile({
94
- audioFile,
95
- size,
96
- }: TranscribeFileOptions): Promise<string> {
97
- const max = 25 * 1024 * 1024; // 25 MB
98
- if ((size ?? audioFile.size) > max) {
99
- // "too long" keyword → audio_too_long response
100
- throw new Error("Audio duration too long — max 25MB per upload");
101
- }
102
- const result = await this.client.audio.transcriptions.create({
103
- file: audioFile,
104
- model: "whisper-1",
105
- });
106
- return result.text;
107
- }
108
- }
109
- ```
110
-
111
- ### Error auto-categorization
112
-
113
- The runtime inspects `String(error).toLowerCase()` thrown by your service and maps keywords
114
- to error codes. Let the provider error bubble up — do not re-categorize inside the service.
115
-
116
- | Keyword substrings | Maps to |
117
- | ---------------------------------------- | -------------------------------- |
118
- | `rate`, `429`, `too many` | `rate_limited` (retryable) |
119
- | `auth`, `401`, `api key`, `unauthorized` | `auth_failed` (not retryable) |
120
- | `too long`, `duration`, `length` | `audio_too_long` (not retryable) |
121
- | (anything else) | `provider_error` (retryable) |
122
-
123
- Full error-code enum:
124
-
125
- ```typescript
126
- // packages/shared/src/transcription-errors.ts
127
- export enum TranscriptionErrorCode {
128
- SERVICE_NOT_CONFIGURED = "service_not_configured",
129
- INVALID_AUDIO_FORMAT = "invalid_audio_format",
130
- AUDIO_TOO_LONG = "audio_too_long",
131
- AUDIO_TOO_SHORT = "audio_too_short",
132
- RATE_LIMITED = "rate_limited",
133
- AUTH_FAILED = "auth_failed",
134
- PROVIDER_ERROR = "provider_error",
135
- NETWORK_ERROR = "network_error",
136
- INVALID_REQUEST = "invalid_request",
137
- }
138
- ```
139
-
140
- ## Common Mistakes
141
-
142
- ### HIGH Calling /transcribe without configuring transcriptionService
143
-
144
- Wrong:
145
-
146
- ```typescript
147
- new CopilotRuntime({ agents });
148
- // client calls /api/copilotkit/transcribe → 503
149
- ```
150
-
151
- Correct:
152
-
153
- ```typescript
154
- new CopilotRuntime({
155
- agents,
156
- transcriptionService: new MyWhisperService(),
157
- });
158
- ```
159
-
160
- Unconfigured runtime returns HTTP 503 with
161
- `{ error: "service_not_configured" }`. The frontend gets no transcript with no obvious
162
- server-side failure.
163
-
164
- Source: `packages/runtime/src/v2/runtime/handlers/handle-transcribe.ts:203-207`.
165
-
166
- ### MEDIUM Form field named "file" instead of "audio"
167
-
168
- Wrong:
169
-
170
- ```typescript
171
- const form = new FormData();
172
- form.append("file", blob, "recording.webm");
173
- await fetch("/api/copilotkit/transcribe", { method: "POST", body: form });
174
- ```
175
-
176
- Correct:
177
-
178
- ```typescript
179
- const form = new FormData();
180
- form.append("audio", blob, "recording.webm");
181
- await fetch("/api/copilotkit/transcribe", { method: "POST", body: form });
182
- ```
183
-
184
- The handler reads `formData.get("audio")` — any other field name yields `null` and returns
185
- `invalid_request`.
186
-
187
- Source: `packages/runtime/src/v2/runtime/handlers/handle-transcribe.ts:91-97`.
188
-
189
- ### MEDIUM Base64 payload missing mimeType
190
-
191
- Wrong:
192
-
193
- ```typescript
194
- await fetch("/api/copilotkit/transcribe", {
195
- method: "POST",
196
- headers: { "Content-Type": "application/json" },
197
- body: JSON.stringify({ audio: b64 }),
198
- });
199
- ```
200
-
201
- Correct:
202
-
203
- ```typescript
204
- await fetch("/api/copilotkit/transcribe", {
205
- method: "POST",
206
- headers: { "Content-Type": "application/json" },
207
- body: JSON.stringify({ audio: b64, mimeType: "audio/webm" }),
208
- });
209
- ```
210
-
211
- JSON mode requires `mimeType` — the handler explicitly rejects payloads missing it with
212
- `invalid_request`.
213
-
214
- Source: `packages/runtime/src/v2/runtime/handlers/handle-transcribe.ts:131-136`.
215
-
216
- ### LOW Re-categorizing errors inside the service
217
-
218
- Wrong:
219
-
220
- ```typescript
221
- class MyService extends TranscriptionService {
222
- async transcribeFile(opts: TranscribeFileOptions): Promise<string> {
223
- try {
224
- return await doTranscribe(opts);
225
- } catch (e) {
226
- // trying to hand-pick error codes
227
- throw new Error("RATE_LIMITED");
228
- }
229
- }
230
- }
231
- ```
232
-
233
- Correct:
234
-
235
- ```typescript
236
- class MyService extends TranscriptionService {
237
- async transcribeFile(opts: TranscribeFileOptions): Promise<string> {
238
- return doTranscribe(opts); // let provider errors bubble up verbatim
239
- }
240
- }
241
- ```
242
-
243
- The runtime scans `String(error).toLowerCase()` for `"rate"`, `"429"`, `"auth"`, `"too long"`
244
- etc. Provider-native messages (`"OpenAI returned 429 rate limited"`) auto-map to the right
245
- code. Hand-crafted codes bypass the keyword matcher and end up as `provider_error`.
246
-
247
- Source: `packages/runtime/src/v2/runtime/handlers/handle-transcribe.ts:160-196`.
248
-
249
- ### MEDIUM Returning a rich object instead of a string
250
-
251
- Wrong:
252
-
253
- ```typescript
254
- class MyService extends TranscriptionService {
255
- async transcribeFile(opts: TranscribeFileOptions): Promise<string> {
256
- // @ts-expect-error returning the wrong shape
257
- return {
258
- text: "hi",
259
- segments: [
260
- /* ... */
261
- ],
262
- };
263
- }
264
- }
265
- ```
266
-
267
- Correct:
268
-
269
- ```typescript
270
- class MyService extends TranscriptionService {
271
- async transcribeFile(opts: TranscribeFileOptions): Promise<string> {
272
- const result = await provider.transcribe(opts.audioFile);
273
- return result.text;
274
- }
275
- }
276
- ```
277
-
278
- `transcribeFile` returns `Promise<string>`. The handler sends
279
- `{ transcription: string }` back to the client — any other shape is a TypeScript error and
280
- would be JSON-stringified wrongly at runtime.
281
-
282
- Source: `packages/runtime/src/v2/runtime/transcription-service/transcription-service.ts:9-11`.
283
-
284
- ## See also
285
-
286
- - `copilotkit/setup-endpoint` — `/transcribe` is one of the routes the handler mounts
287
- - `copilotkit/debug-and-troubleshoot` — `TranscriptionErrorCode` catalog
@@ -1,40 +0,0 @@
1
- A2A (Agent2Agent) — wired via `@ag-ui/a2a`. Requires a pre-built `A2AClient` (not a URL).
2
-
3
- ## Install
4
-
5
- ```bash
6
- pnpm add @ag-ui/a2a @a2a-js/sdk
7
- ```
8
-
9
- ## Minimal wire-up
10
-
11
- ```typescript
12
- import {
13
- CopilotRuntime,
14
- createCopilotRuntimeHandler,
15
- } from "@copilotkit/runtime/v2";
16
- import { A2AAgent } from "@ag-ui/a2a";
17
- import { A2AClient } from "@a2a-js/sdk/client";
18
-
19
- const a2aClient = new A2AClient(process.env.A2A_URL!);
20
-
21
- const runtime = new CopilotRuntime({
22
- agents: {
23
- default: new A2AAgent({ a2aClient }),
24
- },
25
- });
26
-
27
- const handler = createCopilotRuntimeHandler({
28
- runtime,
29
- basePath: "/api/copilotkit",
30
- });
31
-
32
- export default { fetch: handler };
33
- ```
34
-
35
- ## Gotcha — do NOT pass `{ url }`
36
-
37
- `A2AAgent` takes `{ a2aClient }`. The A2A protocol has its own handshake; the client
38
- object handles it. Passing `{ url: "..." }` is a type error and will fail at runtime.
39
-
40
- Source: `examples/integrations/a2a-a2ui/app/api/copilotkit/[[...slug]]/route.tsx:12`.
@@ -1,45 +0,0 @@
1
- Google ADK (Agent Development Kit) — wired via the bare `HttpAgent` from `@ag-ui/client`.
2
-
3
- ## Install
4
-
5
- ```bash
6
- pnpm add @ag-ui/client
7
- ```
8
-
9
- ## Minimal wire-up
10
-
11
- ```typescript
12
- import {
13
- CopilotRuntime,
14
- createCopilotRuntimeHandler,
15
- } from "@copilotkit/runtime/v2";
16
- import { HttpAgent } from "@ag-ui/client";
17
-
18
- const runtime = new CopilotRuntime({
19
- agents: {
20
- default: new HttpAgent({
21
- url: process.env.ADK_URL ?? "http://localhost:8000/",
22
- }),
23
- },
24
- });
25
-
26
- const handler = createCopilotRuntimeHandler({
27
- runtime,
28
- basePath: "/api/copilotkit",
29
- });
30
-
31
- export default { fetch: handler };
32
- ```
33
-
34
- ## Server side
35
-
36
- Your ADK Python agent must speak AG-UI. ADK ships an AG-UI FastAPI adapter — use it
37
- and point `HttpAgent({ url })` at the FastAPI route.
38
-
39
- ## Gotcha — env-sourced credentials
40
-
41
- ADK typically authenticates to Google Cloud via service-account credentials
42
- (`GOOGLE_APPLICATION_CREDENTIALS`). Those live on the ADK Python server, not in the
43
- CopilotKit runtime. The runtime just forwards AG-UI events.
44
-
45
- Source: `docs/content/docs/integrations/adk/quickstart.mdx`.
@@ -1,41 +0,0 @@
1
- AG2 — wired via the bare `HttpAgent` from `@ag-ui/client`. No dedicated `@ag-ui/ag2`
2
- package exists; AG2 is a standard HTTP AG-UI framework.
3
-
4
- ## Install
5
-
6
- ```bash
7
- pnpm add @ag-ui/client
8
- ```
9
-
10
- ## Minimal wire-up
11
-
12
- ```typescript
13
- import {
14
- CopilotRuntime,
15
- createCopilotRuntimeHandler,
16
- } from "@copilotkit/runtime/v2";
17
- import { HttpAgent } from "@ag-ui/client";
18
-
19
- const runtime = new CopilotRuntime({
20
- agents: {
21
- default: new HttpAgent({
22
- url: process.env.AG2_URL ?? "http://localhost:8000/",
23
- }),
24
- },
25
- });
26
-
27
- const handler = createCopilotRuntimeHandler({
28
- runtime,
29
- basePath: "/api/copilotkit",
30
- });
31
-
32
- export default { fetch: handler };
33
- ```
34
-
35
- ## Gotcha — no dedicated package
36
-
37
- Unlike Mastra / LangGraph / CrewAI / LlamaIndex / Agno, AG2 has no `@ag-ui/ag2` package.
38
- Always use the generic `HttpAgent`. If an older doc references a dedicated AG2 package,
39
- treat it as stale.
40
-
41
- Source: `docs/content/docs/integrations/ag2/quickstart.mdx`; maintainer Phase 4 resolution.
@@ -1,40 +0,0 @@
1
- Agno — wired via the generic `HttpAgent` from `@ag-ui/client`. Requires an `/agui` URL
2
- suffix.
3
-
4
- ## Install
5
-
6
- ```bash
7
- pnpm add @ag-ui/client
8
- ```
9
-
10
- ## Minimal wire-up
11
-
12
- ```typescript
13
- import {
14
- CopilotRuntime,
15
- createCopilotRuntimeHandler,
16
- } from "@copilotkit/runtime/v2";
17
- import { HttpAgent } from "@ag-ui/client";
18
-
19
- const runtime = new CopilotRuntime({
20
- agents: {
21
- default: new HttpAgent({
22
- url: process.env.AGNO_URL ?? "http://localhost:8000/agui",
23
- }),
24
- },
25
- });
26
-
27
- const handler = createCopilotRuntimeHandler({
28
- runtime,
29
- basePath: "/api/copilotkit",
30
- });
31
-
32
- export default { fetch: handler };
33
- ```
34
-
35
- ## Gotcha — the `/agui` suffix is mandatory
36
-
37
- Agno's AG-UI FastAPI app mounts at `/agui`. Pointing `url` at the server root
38
- (`http://localhost:8000`) returns 404. Always include `/agui`.
39
-
40
- Source: `docs/content/docs/integrations/agno/quickstart.mdx:215`.
@@ -1,59 +0,0 @@
1
- AWS Strands — wired via the bare `HttpAgent` from `@ag-ui/client`.
2
-
3
- ## Install
4
-
5
- ```bash
6
- pnpm add @ag-ui/client
7
- ```
8
-
9
- ## Minimal wire-up
10
-
11
- ```typescript
12
- import {
13
- CopilotRuntime,
14
- createCopilotRuntimeHandler,
15
- } from "@copilotkit/runtime/v2";
16
- import { HttpAgent } from "@ag-ui/client";
17
-
18
- const runtime = new CopilotRuntime({
19
- agents: {
20
- default: new HttpAgent({
21
- url: process.env.STRANDS_URL ?? "http://localhost:8000",
22
- }),
23
- },
24
- });
25
-
26
- const handler = createCopilotRuntimeHandler({
27
- runtime,
28
- basePath: "/api/copilotkit",
29
- });
30
-
31
- export default { fetch: handler };
32
- ```
33
-
34
- ## Server side
35
-
36
- Strands agents run on AWS and typically expose an AG-UI-speaking endpoint (API Gateway or
37
- Lambda Function URL). Point `HttpAgent({ url })` at that endpoint.
38
-
39
- ## Gotcha — AWS auth
40
-
41
- Strands deployments often require IAM SigV4 or a custom header. `HttpAgent` accepts a
42
- `headers: Record<string, string>` option that is attached to every outbound runtime →
43
- Strands call:
44
-
45
- ```typescript
46
- new HttpAgent({
47
- url: process.env.STRANDS_URL!,
48
- headers: { Authorization: `Bearer ${process.env.STRANDS_TOKEN!}` },
49
- });
50
- ```
51
-
52
- `hooks.onBeforeHandler` will NOT work for this — those hooks run on the inbound frontend
53
- → runtime request, not on the outbound runtime → Strands call that `HttpAgent` issues.
54
- For SigV4 (which needs a per-request signature over the body), front Strands with a
55
- lightweight Lambda / API Gateway authorizer that strips client credentials and adds the
56
- IAM signing, then point `HttpAgent({ url })` at that shim.
57
-
58
- Source: `node_modules/@ag-ui/client/dist/index.d.ts` (`HttpAgentConfig.headers`);
59
- `docs/content/docs/integrations/aws-strands/quickstart.mdx`.
@@ -1,51 +0,0 @@
1
- CrewAI Crews — multi-agent crews wired via `@ag-ui/crewai`.
2
-
3
- ## Install
4
-
5
- ```bash
6
- pnpm add @ag-ui/crewai
7
- ```
8
-
9
- ## Minimal wire-up
10
-
11
- ```typescript
12
- import {
13
- CopilotRuntime,
14
- createCopilotRuntimeHandler,
15
- } from "@copilotkit/runtime/v2";
16
- import { CrewAIAgent } from "@ag-ui/crewai";
17
-
18
- const runtime = new CopilotRuntime({
19
- agents: {
20
- default: new CrewAIAgent({
21
- url: process.env.CREWAI_URL ?? "http://localhost:8000/",
22
- }),
23
- },
24
- });
25
-
26
- const handler = createCopilotRuntimeHandler({
27
- runtime,
28
- basePath: "/api/copilotkit",
29
- });
30
-
31
- export default { fetch: handler };
32
- ```
33
-
34
- ## Crews vs Flows
35
-
36
- CrewAI ships two products:
37
-
38
- - **Crews** — multi-agent orchestration. Use `CrewAIAgent` from `@ag-ui/crewai`.
39
- - **Flows** — event-driven pipelines. Use the generic `HttpAgent` from `@ag-ui/client`
40
- (there's no framework-specific wrapper). See [crewai-flows.md](crewai-flows.md).
41
-
42
- ## Gotcha — trailing slash
43
-
44
- The `url` for `CrewAIAgent` traditionally ends with a trailing slash
45
- (`http://localhost:8000/`). Follow whatever your CrewAI server exposes — don't strip it.
46
-
47
- Source: `@ag-ui/crewai` package types (`CrewAIAgent` constructor);
48
- `docs/content/docs/reference/v1/sdk/python/CrewAIAgent.mdx` for v1 Python-side
49
- reference. The v2 integrations docs currently ship only a Flows quickstart at
50
- `docs/content/docs/integrations/crewai-flows/quickstart.mdx` — there is no dedicated
51
- Crews quickstart yet.
@@ -1,45 +0,0 @@
1
- CrewAI Flows — wired via the bare `HttpAgent` from `@ag-ui/client`. No dedicated wrapper.
2
-
3
- ## Install
4
-
5
- ```bash
6
- pnpm add @ag-ui/client
7
- ```
8
-
9
- ## Minimal wire-up
10
-
11
- ```typescript
12
- import {
13
- CopilotRuntime,
14
- createCopilotRuntimeHandler,
15
- } from "@copilotkit/runtime/v2";
16
- import { HttpAgent } from "@ag-ui/client";
17
-
18
- const runtime = new CopilotRuntime({
19
- agents: {
20
- default: new HttpAgent({
21
- url: process.env.CREWAI_FLOWS_URL ?? "http://localhost:8000/",
22
- }),
23
- },
24
- });
25
-
26
- const handler = createCopilotRuntimeHandler({
27
- runtime,
28
- basePath: "/api/copilotkit",
29
- });
30
-
31
- export default { fetch: handler };
32
- ```
33
-
34
- ## Flows vs Crews
35
-
36
- Flows is the event-driven pipeline product. For multi-agent Crews orchestration, use
37
- `CrewAIAgent` from `@ag-ui/crewai` instead — see [crewai-crews.md](crewai-crews.md).
38
-
39
- ## Gotcha — AG-UI compatibility
40
-
41
- Your CrewAI Flows server must speak AG-UI over HTTP. If you control the server, use the
42
- official CrewAI Python AG-UI adapter. `HttpAgent` is a thin bridge — any server that
43
- emits AG-UI events at the URL works.
44
-
45
- Source: `docs/content/docs/integrations/crewai-flows/quickstart.mdx`.