Commit Graph

1227 Commits

Author SHA1 Message Date
Jordan Ritter 2dc5910a8a fix: deduplicate messages to prevent duplicate React keys in CopilotChatMessageView (#3258) 2026-03-02 19:44:56 -08:00
Maxim 6cfdd3464c fix: formatting 2026-03-02 23:51:19 +04:00
Maxim 30c2ae95ba test: add enum preservation tests for convertJsonSchemaToZodSchema
Move V1 test file to __tests__/ directory and add test verifying that
string enum constraints round-trip through convertJsonSchemaToZodSchema.
Add equivalent test for V2's copy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 23:47:54 +04:00
Maxim 662007f264 fix: preserve enum constraints in convertJsonSchemaToZodSchema
The string case in convertJsonSchemaToZodSchema produced z.string() and
silently discarded the enum field. When useCopilotAction defines a
parameter with enum: ["todo", "done"], the constraint was lost during
the V1→V2 bridge and never reached the runtime payload.

Add an enum check before falling through to z.string() in both V1
(shared/json-schema.ts) and V2 (agent/index.ts) copies of the function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 23:47:54 +04:00
Alem Tuzlak 933914df0f Merge branch 'main' into tyler/fix-thing 2026-03-02 18:06:19 +01:00
Alem Tuzlak 3a161ac6af Merge branch 'main' into worktree-validated-greeting-quokka 2026-03-02 18:05:13 +01:00
Maxim c2ce3f19ae fix(runtime): use expect.any(Response) in middleware tests for Node 20/22 compat
The afterRequestMiddleware receives a cloned Response (via c.res.clone()),
whose internal stream controller functions have different names across
Node versions. Using expect.any(Response) avoids brittle deep equality
on Response internals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 20:43:34 +04:00
Maxim c56386e9db docs: update afterRequestMiddleware reference
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 20:43:34 +04:00
Maxim 3057c7c9ec feat(runtime): expose messages in afterRequestMiddleware
Clone Response before body is consumed, parse SSE stream to reconstruct
messages. Adds messages, threadId, runId to AfterRequestMiddlewareParameters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 20:43:34 +04:00
Alem Tuzlak 93edc65f23 fix: update build process and add outputs for snapshot caching 2026-03-02 11:42:22 -05:00
Alem Tuzlak 45652201a9 Merge branch 'main' into worktree-validated-greeting-quokka 2026-03-02 15:23:37 +01:00
g97iulio1609 8cf1bb8b4a fix(react): replace static KaTeX CSS import with dynamic runtime injection
Next.js rejects global CSS imports from within node_modules, causing
build failures when consumers use @copilotkitnext/react:

  Global CSS cannot be imported from within node_modules.
  Location: node_modules/@copilotkitnext/react/dist/index.mjs

The static `import 'katex/dist/katex.min.css'` in
CopilotChatAssistantMessage.tsx gets preserved in the dist bundle
(tsdown unbundle mode), triggering the Next.js css-npm restriction.

Replace with a useKatexStyles() hook that dynamically imports the CSS
at runtime via useEffect. Dynamic imports bypass Next.js static
analysis and load the stylesheet lazily when the component mounts.

Fixes #2851
2026-02-28 02:59:17 +01:00
Tyler Slaton 7e792a8ec5 fix(react): address issue with isModelOpen test
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-02-27 18:24:44 -05:00
Tyler Slaton 12fb5ea6bf fix(react): add backwards compat for disclaimer prop on chat components
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-02-27 18:16:49 -05:00
Tyler Slaton 089e4f3370 fix(react): [data-copilotkit] scoping to avoid leaking base styles
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-02-27 18:09:51 -05:00
Tyler Slaton f1eaa4c214 fix: ensure setModalOpen is always defined in useCopilotChatConfiguration
The shouldCreateModalState guard introduced in #3101 made setModalOpen
and isModalOpen conditionally undefined when isModalDefaultOpen wasn't
explicitly passed. This broke programmatic modal control for anyone
using useCopilotChatConfiguration outside of CopilotPopup/CopilotSidebar.

Reverts to the simpler ?? fallback pattern: each provider always has
modal state, preferring parent state when available, falling back to
its own internal state otherwise. Initial state still respects the
local isModalDefaultOpen prop (fix from 76e381f78).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 17:55:00 -05:00
github-actions[bot] aeac645881 chore(post-release): update version to 1.52.1 2026-02-27 20:04:51 +00:00
Alem Tuzlak cc0b6b0a91 Merge branch 'main' into 3169-multiple-requests 2026-02-27 15:32:17 +01:00
Alem Tuzlak fc5fbc7fe3 Merge branch 'main' into 3169-multiple-requests 2026-02-27 15:21:13 +01:00
Markus Ecker 39722ecbe4 Merge branch 'main' into mme/ag-ui-0.0.46 2026-02-27 15:13:22 +01:00
github-actions[bot] d523d6cc68 chore(post-release): update version to 1.52.1-next.1 2026-02-27 14:12:29 +00:00
Markus Ecker 979511a900 chore: upgrade AG-UI to 0.0.46 2026-02-27 14:47:50 +01:00
Alem Tuzlak b555ac4b69 fix(react-core): allow overriding useSingleEndpoint in CopilotKit provider
The V1 CopilotKit provider hardcoded useSingleEndpoint={true}, preventing
users from opting into REST transport mode. Now passes through the user's
prop value, defaulting to true for backward compatibility.
2026-02-27 13:36:06 +01:00
github-actions[bot] 0cf39911a0 chore(post-release): update version to 1.52.1-next.0 2026-02-27 03:53:52 +00:00
Tyler Slaton 6fb4f6518c fix(css): address imcompat with CJS
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-02-26 19:50:26 -08:00
Jordan Ritter a3fbf467aa feat: add selfManagedAgents prop to React and Angular providers (#3285)
## What does this PR do?

Add `selfManagedAgents` prop.

## Related PRs and Issues

- https://copilotkit.slack.com/archives/C075NF9SN01/p1771967940173989
2026-02-26 18:55:49 -04:00
Jordan Ritter 3f1259d060 fix: propagate custom provider config from service adapters to BuiltInAgent (#3283)
Fixes #2903

## The Bug

Azure OpenAI users get `AI_LoadAPIKeyError: OpenAI API key is missing`
despite passing a properly configured `OpenAI` instance to
`OpenAIAdapter`, exactly as shown in the docs.

**Root cause**: `CopilotRuntime.handleServiceAdapter()` discards the
adapter's configured OpenAI instance and constructs a plain string
`"openai/gpt-4o"` to pass to `BuiltInAgent`. The agent's
`resolveModel()` then creates a *brand new* OpenAI provider using only
`OPENAI_API_KEY`, losing all Azure configuration (baseURL, api-key
header, api-version query param).

The V1 adapter's `process()` method — which correctly uses the custom
OpenAI instance — is dead code. It's never called. Only `.provider` and
`.model` strings are extracted.

```
User configures Azure OpenAI instance →
  OpenAIAdapter stores it →
    CopilotRuntime extracts only "openai"/"gpt-4o" strings →
      BuiltInAgent.resolveModel("openai/gpt-4o") →
        createOpenAI({ apiKey: OPENAI_API_KEY }) →
          💥 API key missing / wrong endpoint
```

## Workaround

Until this is merged, users can bypass the broken adapter entirely by
using `BuiltInAgent` directly with the Vercel AI SDK Azure provider:

```typescript
import { createAzure } from "@ai-sdk/azure";
import { CopilotRuntime, copilotRuntimeNodeHttpEndpoint } from "@copilotkit/runtime";
import { BuiltInAgent } from "@copilotkitnext/agent";

const azure = createAzure({
  resourceName: process.env.AZURE_RESOURCE_NAME,
  apiKey: process.env.AZURE_API_KEY,
});

const runtime = new CopilotRuntime({
  agents: {
    default: new BuiltInAgent({
      model: azure("your-deployment-name"),
    }),
  },
});

// Then use copilotRuntimeNodeHttpEndpoint as usual — no serviceAdapter needed
```

This works because `BuiltInAgent` already accepts `LanguageModel`
instances and `resolveModel()` passes them straight through.

## The Fix

Add an optional `getLanguageModel()` method to `CopilotServiceAdapter`.
Adapters that accept custom SDK instances (OpenAI, Anthropic, Groq) now
implement this to produce a pre-configured Vercel AI SDK `LanguageModel`
that carries the full provider configuration. `CopilotRuntime` prefers
this over the string format when creating `BuiltInAgent`.

**Backward compatible**: `getLanguageModel()` is optional on the
interface, so existing custom adapters continue to work unchanged.

| File | Change |
|------|--------|
| `service-adapter.ts` | Add optional `getLanguageModel()` to
`CopilotServiceAdapter` interface |
| `openai-adapter.ts` | Implement `getLanguageModel()` using
`createOpenAI` with the configured instance's `baseURL`/`apiKey` |
| `anthropic-adapter.ts` | Implement `getLanguageModel()` using
`createAnthropic` |
| `groq-adapter.ts` | Implement `getLanguageModel()` using
`createOpenAI` (Groq is OpenAI-compatible) |
| `copilot-runtime.ts` | Prefer `serviceAdapter.getLanguageModel()` over
string model when creating `BuiltInAgent` |
| `package.json` | Add `ai`, `@ai-sdk/openai`, `@ai-sdk/anthropic`
dependencies |

## Test plan

- [x] V2 agent tests pass (101/101)
- [x] V1 runtime build succeeds with no type errors
- [x] V1 runtime tests: same pass/fail as `main` (pre-existing failures
unrelated to this change)
- [ ] Manual: configure Azure OpenAI via `OpenAIAdapter` without
`OPENAI_API_KEY` — should work without `AI_LoadAPIKeyError`
- [ ] Manual: standard OpenAI via `OpenAIAdapter` with `OPENAI_API_KEY`
— should continue working

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-02-26 18:36:11 -04:00
Maxim 0897192cc6 feat: add selfManagedAgents prop to React and Angular providers
Merges selfManagedAgents into agents__unsafe_dev_only at the component level.
No core changes, no validation, no license key checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 01:22:09 +04:00
Jordan Ritter ecfafc989c test: add unit tests for getSdkClientOptions utility 2026-02-26 12:47:19 -08:00
Jordan Ritter b8bf8085e0 refactor: replace as-any _options access with typed shared utility
SDK clients store defaultHeaders and fetch in a private _options field.
Extract the access pattern into getSdkClientOptions() with runtime
validation and a narrow return type, eliminating as-any from all three
adapter getLanguageModel() implementations.
2026-02-26 12:43:13 -08:00
Jordan Ritter 777231aaea refactor: use static imports and remove as-any casts in adapter tests
Address PR review feedback: replace dynamic await import() with static
top-level imports using vi.hoisted() for mock declarations, and remove
all `as any` type casts since the SDK constructor types already accept
the options we pass.
2026-02-26 12:25:44 -08:00
Jordan Ritter e520a66ed6 test: add exhaustive option-forwarding tests for adapter getLanguageModel()
Each test mocks the AI SDK provider factory and asserts that all options
from the SDK client instance are forwarded. Compile-time exhaustiveness
guards ensure the tests break if the AI SDK provider types add new
options that need to be handled.
2026-02-26 12:03:39 -08:00
Jordan Ritter 311d758570 fix: forward custom fetch from SDK clients to AI SDK providers 2026-02-26 12:03:32 -08:00
Jordan Ritter 7d2c69fef2 fix: forward custom headers, organization, and project to AI SDK providers
Pass defaultHeaders from SDK client instances through to the AI SDK
providers. This is critical for Azure OpenAI (api-key header) and any
custom proxy setups. Also forward organization and project for OpenAI.
2026-02-26 11:52:39 -08:00
github-actions[bot] f924ecb4aa chore(post-release): update version to 1.52.0 2026-02-26 19:37:25 +00:00
Jordan Ritter 3f8b5e2360 fix: propagate custom provider config from service adapters to BuiltInAgent
Service adapters (OpenAIAdapter, AnthropicAdapter, GroqAdapter) accept
custom SDK instances with provider-specific configuration (e.g. Azure
OpenAI with custom baseURL/apiKey/headers), but CopilotRuntime discards
those instances and reconstructs a plain "provider/model" string for
BuiltInAgent. The agent's resolveModel() then creates a fresh provider
using only environment variables, losing all custom configuration.

Add getLanguageModel() to CopilotServiceAdapter so adapters can produce
a pre-configured Vercel AI SDK LanguageModel. CopilotRuntime now prefers
this over the string format when creating BuiltInAgent.

Fixes CopilotKit/CopilotKit#2903
2026-02-26 11:13:08 -08:00
Mike Ryan 609c3e9936 feat(angular): add public license key config 2026-02-26 09:22:48 -08:00
Alem Tuzlak b60707563f feat: accept agentId parameter in useLangGraphInterrupt (#3272) 2026-02-26 17:24:32 +01:00
Mike Ryan 9920ad34b2 fix(angular): restore frontend tool handler context wiring 2026-02-26 08:18:52 -08:00
Mike Ryan dca52ed355 docs(angular): Add Angular documentation 2026-02-26 08:18:52 -08:00
Mike Ryan 744e392230 feat(angular): mirror React agent proxying and runtime signals 2026-02-26 08:18:52 -08:00
Mike Ryan 6be0696d11 chore(angular): Update the license of the Angular SDK 2026-02-26 07:25:47 -08:00
Júlio Cesar Guimarães cdb8a456b0 fix(runtime): clean up stale messagesInProcess when copilotkit:emit-messages suppresses events 2026-02-24 22:22:16 -03:00
Brian Love 6833f0f7e3 chore(angular): version 19 2026-02-24 14:23:27 -08:00
github-actions[bot] a0cd2ed364 chore(post-release): update version to 1.52.0-next.8 2026-02-24 15:21:43 +00:00
Alem Tuzlak 942d397352 feat: e2e selectors for components (#3264) 2026-02-24 16:18:11 +01:00
github-actions[bot] 17d42682ef chore(post-release): update version to 1.52.0-next.7 2026-02-24 14:54:00 +00:00
Ran Shemtov d77f3475a6 feat: create use-interrupt hook (#3184)
Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 15:50:21 +01:00
Alem Tuzlak f25f182ff1 chore: migrate from husky to lefthook and fix angular tests
- Replace husky with lefthook for git hooks management
- Pre-commit runs lint --fix, format, test, and check:packages in parallel
  with auto-staging of fixes via stage_fixed
- Commit-msg runs commitlint
- Add dependsOn ^build to test target in nx.json so dependencies are
  built before tests run
- Upgrade @analogjs/vite-plugin-angular and @analogjs/vitest-angular
  from ^1.20.2 to ^2.2.3 for vite 7 compatibility
- Add pnpm packageExtensions to declare missing vite peer dependency
  on @analogjs/vite-plugin-angular
- Fix lint issues: let -> const in agent and react packages
- Disable nx TUI in pre-commit hooks via NX_TUI env var
2026-02-24 15:17:21 +01:00
Ian VS 1c77272197 chore: format 2026-02-23 08:33:13 -05:00