Commit Graph

699 Commits

Author SHA1 Message Date
ranst91 cfb5921108 chore: release monorepo v1.56.0 2026-04-15 17:22:27 +00:00
Ran Shem Tov 6986a1c120 fix: use latest agui langgraph packages 2026-04-15 18:11:17 +02:00
Alem Tuzlak b7e009c56b fix: correct verbose default in docs and remove stray vscode-extension README
The docs table and prose claimed `debug: true` sets `verbose: true`,
but the implementation intentionally defaults verbose to false (PII
safety). Fixed the table and explanatory text to match.

Also removed packages/vscode-extension/README.md which was committed
on this branch by mistake — it describes an unrelated VS Code extension
and has nothing to do with debug mode.
2026-04-15 17:18:09 +02:00
Alem Tuzlak 9953b8a264 Merge branch 'main' into worktree-lucky-popping-wren 2026-04-15 17:12:55 +02:00
Markus Ecker d51140ebbc chore: bump @ag-ui/a2ui-middleware to 0.0.5 2026-04-15 14:56:51 +02:00
github-actions[bot] 4abb9af1b2 style: auto-fix formatting 2026-04-15 11:12:37 +00:00
Jordan Ritter fb6b518362 fix: mock navigator in clipboard test for Node 20 compatibility 2026-04-15 13:10:48 +02:00
Jordan Ritter f4887a763e test: add userToggledRef behavior tests for reasoning message
Two new test cases covering the core behavioral fix:
- User collapses during streaming → panel stays collapsed after stream ends
- User collapses then re-expands during streaming → panel stays open after stream ends
2026-04-15 13:10:45 +02:00
Jordan Ritter 921b02ab57 test: wrap fireEvent.click in act() for deterministic reasoning toggle test
Without act(), React 18 defers the state update through its scheduler,
which can race with waitFor polling on slow CI runners (Node 20.x/22.x).
Wrapping in act() forces synchronous flush.
2026-04-15 13:10:45 +02:00
Jordan Ritter adbd38b5e5 fix: respect user expand/collapse intent in reasoning message
The auto-collapse useEffect unconditionally called setIsOpen(false) when
streaming ended, overriding any manual expand/collapse the user had
performed.  Add a userToggledRef that tracks explicit clicks so the
effect only auto-collapses when the user hasn't interacted.
2026-04-15 13:10:44 +02:00
Jordan Ritter d45620c1e7 fix: propagate copyToClipboard success result to CopyButton UI state
The CopyButton in react-core was showing the "copied" checkmark based on
an independent clipboard availability check rather than the actual copy
result. This meant a failed copy (e.g. permission denied) would still
show the success indicator. Now the onClick handler returns the boolean
from copyToClipboard, and handleClick uses that to drive the UI state.
Also removes unsafe type casts of onClick to Promise<void>.
2026-04-15 13:10:43 +02:00
Jordan Ritter 2f4152c8ec fix: extract shared copyToClipboard utility to eliminate clipboard duplication
Address review feedback: extract the repeated clipboard availability check +
writeText + error handling pattern into a shared copyToClipboard() utility in
@copilotkit/shared. All 9 call sites across angular, react-core, and react-ui
now use the shared utility instead of duplicating the same code block.
2026-04-15 13:10:42 +02:00
Jordan Ritter 04739dd6ba fix: guard clipboard calls and only show copied state on success (#2114)
Add null checks for navigator.clipboard across all copy-to-clipboard
calls to prevent TypeError in non-localhost environments where the
Clipboard API is unavailable. The copied indicator now only appears
after a confirmed successful write, preventing false positive UX
feedback when the clipboard API is missing or the write fails.
2026-04-15 13:10:41 +02:00
Jordan Ritter d4c75ce15e fix: replace tautological test with real unit tests for error visibility
Extract getErrorSuppression as a pure testable function from the
routeError closure. Replace the mock-only test that only proved mock
wiring with 12 real assertions covering all visibility x isDev
combinations against the actual logic.
2026-04-15 13:10:41 +02:00
Jordan Ritter 2c3c6a973d fix: surface TOAST/BANNER errors even when showDevConsole=false (#2431)
The routeError function returned early for ALL errors when
showDevConsole was false, suppressing user-visible errors
(TOAST and BANNER visibility) in production.

Now only DEV_ONLY and SILENT errors are suppressed in production.
TOAST and BANNER errors are always surfaced to the chat UI.
2026-04-15 13:10:40 +02:00
Jordan Ritter 9a0c7eb18f fix: remove unstable key on CodeBlock to prevent flickering during streaming
The original Math.random() key caused React to remount the CodeBlock on
every render. The PR's content-based key (language + content prefix) still
changed every streaming token, causing the same flickering. Removing the
key entirely lets React use positional identity, which is stable across
re-renders while content streams in.

Closes #2669
2026-04-15 13:10:38 +02:00
Jordan Ritter 7c9ac787f0 fix: clone visited-refs set to prevent false circular-ref detection across sibling branches
The shared visitedRefs Set was mutated in place, so when two sibling
properties referenced the same $def (e.g. billing and shipping both
referencing Address), the second resolution was incorrectly flagged as
circular. Clone the set before recursing so each branch has its own
ancestry path. Added regression test that fails without this fix.
2026-04-15 13:10:37 +02:00
Jordan Ritter 6b391c6538 fix: add circular $ref cycle detection in JSON schema to Zod conversion
Recursive JSON schemas that reference themselves via $ref would cause
infinite recursion and stack overflow. This adds a visited set that
tracks which $ref paths have been seen during resolution. When a cycle
is detected, it breaks with z.any() and logs a console.warn so users
get feedback. Also adds console.warn for the generic z.any() fallback
on unsupported schema types.

Adds tests for circular refs, non-circular $ref resolution, anyOf with
$ref variants, integer type, null type, and unsupported type warning.
2026-04-15 13:10:36 +02:00
github-actions[bot] 3c32e469d8 style: auto-fix formatting 2026-04-15 13:10:36 +02:00
Jordan Ritter 8ebbba20df fix: handle anyOf/oneOf/ in JSON schema to Zod conversion (#2220) 2026-04-15 13:10:35 +02:00
Jordan Ritter 92730856b5 fix: widen openai peer dep range to include v6.x
The compatibility layer correctly handles v6 (same API surface as v5),
but the version range ^5.0.0 excluded v6.x. Changed to >=5.0.0 so
users on the latest openai SDK don't get peer dependency warnings.
2026-04-15 13:10:34 +02:00
Jordan Ritter 614e4cf815 fix: replace unsafe type casts with proper type guards for OpenAI v4/v5 compat
- Remove all `as any`, `as Function`, and `as Record<string, unknown>` casts
  from production code in the OpenAI compatibility layer
- Introduce typed `OpenAIV4Beta` interface and `hasV4BetaChat` type guard
  for safe runtime detection of v4 vs v5 clients
- Extract `retrieveThreadRun` and `submitToolOutputsStream` helper functions
  into utils.ts with properly typed generic signatures, moving the v4/v5
  dispatch logic out of the assistant adapter
- Give `getChatCompletionsForStreaming` an explicit return type so callers
  no longer need secondary casts
- Update tests to exercise the new helpers directly instead of
  duplicating dispatch logic inline
2026-04-15 13:10:34 +02:00
Jordan Ritter 1a458d1dcf test: add OpenAI SDK v4/v5 compatibility tests (#1979)
Cover isOpenAIV5 detection, getChatCompletionsForStreaming dispatch,
and named-path-param calling conventions for runs.retrieve and
submitToolOutputsStream.
2026-04-15 13:10:32 +02:00
Jordan Ritter 020588e357 fix: support OpenAI SDK v5 in adapter and assistant adapter (#1979)
OpenAI SDK v5 removed beta.chat (promoted to chat.completions) and
changed multi-path-param methods to use named params (e.g.
runs.retrieve(runId, { thread_id }) instead of positional args).

- Add isOpenAIV5() detection and getChatCompletionsForStreaming() helper
- Migrate OpenAIAdapter to use helper for streaming completions
- Migrate OpenAIAssistantAdapter runs.retrieve() and
  submitToolOutputsStream() to branch on SDK version
- Add openai ^4.85.1 || ^5.0.0 to peerDependencies
2026-04-15 13:10:32 +02:00
Jordan Ritter 856ec88b22 fix: update blockquote nested paragraph selector after p-to-div change
The blockquote.copilotKitMarkdownElement p selector targeted literal <p>
elements inside blockquotes, but paragraphs now render as <div> after
the hydration fix. Updated to target .copilotKitParagraph class instead.

Also removes unused import and adds a regression test for this selector.
2026-04-15 13:10:31 +02:00
Jordan Ritter 3bb12d12ec fix: update CSS selectors to match div-based paragraph component
The p tag was changed to div to fix hydration errors, but CSS selectors
still targeted p.copilotKitMarkdownElement. Updated to use the
.copilotKitParagraph class selector so paragraph styling (line-height,
font-size, margin) applies correctly to the new div element.
2026-04-15 13:10:30 +02:00
Jordan Ritter 7403aba8a3 fix: use div instead of p tag in Markdown to prevent hydration errors (#2234) 2026-04-15 13:10:30 +02:00
Jordan Ritter 7b5275e8db fix: scope dark theme CSS variables in colors.css
Same bug pattern as console.css and input.css: bare `.dark,` was a
standalone selector leaking all --copilot-kit-* CSS custom properties
onto any element with a .dark class. Also removed broken `:root`
pseudo-element from `body[style*="color-scheme: dark"] :root` — :root
cannot be a descendant of body, so this selector never matched.

Fix: drop standalone `.dark,` (redundant with `html.dark` and
`body.dark`) and remove the non-functional `:root` descendant.
2026-04-15 13:10:29 +02:00
github-actions[bot] 13c2ccae78 style: auto-fix formatting 2026-04-15 13:10:27 +02:00
Jordan Ritter db2ed5e19a fix: scope .dark CSS selectors to CopilotKit elements (#2920) 2026-04-15 13:10:27 +02:00
Jordan Ritter 362a04e1cc fix: resolve agent factory functions in V1 CopilotRuntime constructor
The V1 CopilotRuntime constructor did `{...endpointAgents, ...agents}`
which silently spread a factory function to `{}`, losing all agents.
Anyone using the V1 API with a factory function got zero agents and no
error. This wraps factory functions so endpoint agents are merged at
resolution time instead of construction time.
2026-04-15 13:10:24 +02:00
Alem Tuzlak b875258b22 docs(vscode-extension): add README with setup, usage, and CI/CD instructions 2026-04-15 13:10:07 +02:00
Markus Ecker 0f02aae198 fix: align A2UI schema format with v0.9 spec and improve path binding prompts
- Replace custom { name, props } schema format with spec-aligned inline
  catalog format (allOf + properties) so the LLM sees the same flat
  structure it must produce — eliminates "props" nesting confusion.
- Restructure generation prompts: inline literal values are the default,
  path binding is a narrow schema-driven exception for form inputs.
- Export InlineCatalogSchema type from a2ui-renderer.
2026-04-15 12:28:13 +02:00
Markus Ecker abd0d5c11c fix: add path binding schema rule to A2UI generation prompts
LLMs sometimes use path bindings (e.g. {"path": "/chartData"}) on
component properties that only accept literal values, causing silent
render failures. The new guideline tells the LLM to check the schema's
anyOf type before using path bindings.
2026-04-15 11:51:05 +02:00
Jordan Ritter afc36a3da9 fix: mock navigator in clipboard test for Node 20 compatibility 2026-04-14 15:11:35 -07:00
Jordan Ritter 39b4ea6ecc docs: clarify client-side debug prop behavior
Updated JSDoc and troubleshooting docs to accurately describe that
the client-side debug prop forwards config to the AG-UI transport
layer, not CopilotKit's own logging. Removed fabricated console.debug
output examples that don't exist.
2026-04-14 14:58:44 -07:00
Jordan Ritter 295a1e609e fix: sync debug prop changes at runtime in CopilotKitProvider
debug was only read at construction time. Added setDebug() to
CopilotKitCore and added it to the provider's prop-sync useEffect
so runtime changes to the debug prop take effect.
2026-04-14 14:58:33 -07:00
Jordan Ritter fde4e0b424 fix: cache pino debug logger on runtime instead of creating per-request
createLogger() was called on every request when debug was enabled,
instantiating a new pino + pino-pretty stream each time. Now creates
a single logger in the runtime constructor and passes it to handlers.
Added test verifying pre-created logger is reused.
2026-04-14 14:58:22 -07:00
Jordan Ritter 6689de4522 fix: thread debug config through to ProxiedCopilotRuntimeAgent
Debug config was silently dropped because ProxiedCopilotRuntimeAgentConfig
had no debug field. Now stores it in the constructor, resolves it in
AgentRegistry before passing, and clone() preserves it. Added 6 tests
verifying the full threading chain.
2026-04-14 14:58:09 -07:00
Jordan Ritter 971a8165aa fix: default verbose to false when debug: true to prevent PII exposure
When users pass the boolean shorthand `debug: true`, verbose previously
defaulted to true, logging full event payloads including user messages,
tool args, and state snapshots. Now defaults to false — users must
explicitly opt in with `debug: { verbose: true }`.
2026-04-14 14:57:22 -07:00
Jordan Ritter 2438896409 fix: respect user expand/collapse intent in reasoning message (#3897)
## Summary

- **Component bug fix:** `CopilotChatReasoningMessage` auto-collapse
`useEffect` unconditionally called `setIsOpen(false)` when streaming
ended, overriding any manual expand/collapse the user had performed.
Added a `userToggledRef` that tracks explicit clicks so the effect only
auto-collapses when the user hasn't interacted.
- **Flaky test fix:** `CopilotChat.e2e.test.tsx` reasoning toggle test
used `fireEvent.click` without `act()`, causing React 18 to defer the
state update through its scheduler. This raced with `waitFor` polling on
slow CI runners (Node 20.x/22.x), producing nondeterministic failures
across multiple PRs.

## Test plan

- [x] Existing reasoning message tests pass with both fixes applied
- [x] Pre-commit hooks (lint, format, test, build) pass
- [ ] Verify intermittent CI failures on unit (20.x/22.x) no longer
reproduce

Note: This fixes the intermittent unit test failures that have been
appearing across multiple unrelated PRs.
2026-04-14 14:35:38 -07:00
Jordan Ritter 1e0de53a25 fix: add null check for navigator.clipboard across all copy-to-clipboard calls (#2114) (#3813)
Fixes #2114

Red-green tested locally.
2026-04-14 14:31:13 -07:00
Jordan Ritter 5aa158da03 fix: surface TOAST/BANNER errors when showDevConsole=false (#3789)
## Summary
- Fixes #2431
- The `routeError` function in `copilot-messages.tsx` returned early
when `showDevConsole=false`, suppressing ALL errors including
user-visible ones (TOAST and BANNER visibility)
- Now only `DEV_ONLY` and `SILENT` errors are suppressed in production;
`TOAST` and `BANNER` errors are always surfaced to the chat UI
- Also fixes the non-GraphQL error handler which had the same
early-return bug

## Test plan
- [x] Added `error-visibility-prod.test.tsx` covering TOAST, DEV_ONLY,
and SILENT visibility behavior
- [x] All 1073 existing react-core tests pass
- [x] Build passes
2026-04-14 14:26:17 -07:00
Jordan Ritter 0106b1bf19 fix: remove unstable key on CodeBlock to prevent flickering during streaming (#3826)
## Summary

- Removes the `key` prop from `CodeBlock` in `Markdown.tsx` entirely
- The original `Math.random()` key caused React to remount the component
on every render, producing visible flickering
- A content-based key (language + content prefix) still changes every
streaming token, causing the same problem
- Without an explicit key, React uses positional identity — stable
across re-renders while content streams in

Closes #2669

## Test plan

- [x] `@copilotkit/react-ui` tests pass
- [x] `@copilotkit/react-ui` build succeeds
- [ ] Manual: verify code blocks no longer flicker during streaming in
chat UI
2026-04-14 14:26:13 -07:00
Jordan Ritter 2c45e24e90 fix: handle anyOf/oneOf/$ref/null in JSON schema to Zod conversion (#3849)
## Summary
- Handle `anyOf`, `oneOf`, `$ref`, and null type entries when converting
JSON schema to Zod schemas
- Prevents runtime errors when LLM tool parameters use union types or
nullable fields

Closes #2220

---
*Split from #3847*
2026-04-14 14:26:09 -07:00
Jordan Ritter 1e5c0ba9ec fix: support OpenAI SDK v5 by falling back from openai.beta to openai.chat.completions (#1979) (#3810)
Fixes #1979

## Summary

- Add `isOpenAIV5()` detection helper that checks whether `beta.chat`
was removed (v5 promoted it to `chat.completions`)
- Add `getChatCompletionsForStreaming()` helper that routes to the
correct completions namespace per SDK version
- Migrate `OpenAIAdapter` to use the new helper instead of direct
`beta.chat.completions` access
- Migrate `OpenAIAssistantAdapter` `runs.retrieve()` and
`submitToolOutputsStream()` to use v5 named path params (e.g.
`retrieve(runId, { thread_id })` instead of positional
`retrieve(threadId, runId)`)
- Add `openai` to peerDependencies with `^4.85.1 || ^5.0.0` range
- Add 11 unit tests covering v4/v5 detection, streaming dispatch, and
named path param calling conventions

## Notes

The remaining `openai.beta.threads.*` calls (`threads.create`,
`messages.create`, `runs.stream`) do NOT need migration because:
1. `beta.threads` still exists in v5 (only `beta.chat` was removed)
2. These methods have single path params, so their signatures are
unchanged

## Test plan

- [x] All 11 v5 compat tests pass (`nx run @copilotkit/runtime:test`)
- [x] Runtime package builds successfully (`nx run
@copilotkit/runtime:build`)
- [x] Pre-commit hooks pass (lint, format, publint, attw)
2026-04-14 14:26:05 -07:00
Jordan Ritter 9e5b458612 fix: use div instead of p tag in Markdown to prevent hydration errors (#2234) (#3821)
## Summary

Fixes #2234

React's hydration fails when block-level elements (like `<div>`) are
nested inside `<p>` tags in the Markdown component. Replaces the `<p>`
wrapper with `<div>` (adding `copilotKitParagraph` class for styling) to
prevent SSR hydration mismatches.

## Test plan

- [ ] Verify Markdown rendering in SSR context has no hydration errors
- [ ] Verify paragraph styling is preserved via `copilotKitParagraph`
class
2026-04-14 14:26:02 -07:00
Jordan Ritter 14eef93d20 fix: scope .dark CSS selectors to CopilotKit elements (#3850)
## Summary

- **console.css + input.css:** Scope `.dark` CSS selectors to CopilotKit
container elements (`.copilotKitDevConsole
.copilotKitDebugMenuTriggerButton` and `.poweredBy` respectively). The
original selectors had bare `.dark,` as standalone entries in
comma-separated selector lists, which applied styles to *any* element
with class `.dark` instead of scoping to CopilotKit elements.
- **colors.css:** Remove broken `:root` pseudo-element from
`body[style*="color-scheme: dark"] :root` — `:root` is `<html>`, which
cannot be a descendant of `<body>`, so this selector never matched
anything.
- **E2E tests:** 4 Playwright regression tests verifying dark mode
styles don't leak into host application elements.

Prevents CopilotKit dark-mode styles from leaking into the host
application.

Closes #2920

---
*Split from #3847*
2026-04-14 14:25:57 -07:00
Jordan Ritter e1ef523a3e fix: resolve agent factory functions in V1 CopilotRuntime constructor (#3865)
## Summary

- The V1 `CopilotRuntime` constructor did `{...endpointAgents,
...agents}` which silently spread a factory function to `{}`, destroying
all agents with no error or warning
- Anyone using the V1 API with a factory function (introduced in #3854)
got zero agents — complete silent data loss
- This wraps factory functions so endpoint agents are merged at
resolution time instead of construction time, matching how V2 already
handles it via `resolveAgents()`

Fixes the V1 path regression from #3854 (per-request agent factory,
issue #2941).

## Test plan

- [x] New test: factory function is preserved through constructor (not
spread to `{}`)
- [x] New test: factory resolves different agents per-request based on
headers
- [x] New test: endpoint agents are correctly merged with
factory-resolved agents
- [x] New test: static agent records still work (backward compat)
- [x] New test: promised agent records still work (backward compat)
- [x] Red-green verified: 4/5 tests fail without the fix, all 5 pass
with it
- [x] Full runtime test suite passes (1234 tests)
- [x] Full build passes
2026-04-14 14:06:14 -07:00
Jordan Ritter b9748a6e0e fix: widen openai peer dep range to include v6.x
The compatibility layer correctly handles v6 (same API surface as v5),
but the version range ^5.0.0 excluded v6.x. Changed to >=5.0.0 so
users on the latest openai SDK don't get peer dependency warnings.
2026-04-14 13:57:49 -07:00