Commit Graph

1601 Commits

Author SHA1 Message Date
Max Korp 66a80d99b0 feat(react-ui/react-v2): add intelligence license check to clients
feat(shared): re-export @copilotkit/license-verifier

feat(react-v2): add LicenseWarningBanner and InlineFeatureWarning components

Self-contained components with inline styles for displaying license
status warnings (no_license, expired, expiring, invalid, feature_unlicensed).

chore: add @copilotkit/shared dependency to v2 react and runtime

feat(react-v2): add licenseToken prop with verification, context, and warnings

feat(react-v2): add license check to CopilotChat

feat(react-v2): add license check to CopilotSidebar

feat(react-v2): add license check to CopilotPopup

feat(react-ui): respect remove_branding flag in PoweredByTag
2026-03-26 16:19:03 -07:00
Martha Schumann b56322e942 docs(use-agent): add comment explaining intentional thread clone cache lifetime
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 09:48:23 -07:00
Benjamin Taylor 77764d043e feat(react): Restore lost changes 2026-03-26 10:47:36 -05:00
Benjamin Taylor 81edf42e6b feat(runtime): Bubble up thread lock error so it can be handled explicitly 2026-03-26 09:45:20 -05:00
Mike Ryan e7d74b832f feat(threads): remove client userId from thread flows 2026-03-25 17:09:41 -07:00
Maxim f6b9543511 feat(useInterrupt): attach interrupt event metadata to resume command
When resolve() is called, the interrupt event value is now included
alongside the user's response in forwardedProps.command.interruptEvent.
This enables agent adapters (e.g. Mastra) to round-trip interrupt
context (toolCallId, runId, type) without storing state between runs.

Uses a ref to avoid changing the resolve callback's dependency array,
preventing double-invocation of the handler effect.

The LangGraph adapter is unaffected — it ignores the extra field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 17:07:21 -07:00
Max Korp 303bc8691c fix: fix newly added tenantIds post rebase 2026-03-25 16:30:26 -07:00
Max Korp 04f131ad6e feat: rename tenantId to organizationId in CopilotKit SDK 2026-03-25 16:19:59 -07:00
Martha Kelly Schumann 53e56699e8 fix: isolate agent instances per threadId in useAgent hook
Multiple CopilotChat components with the same agentId but different
threadIds were sharing a single agent instance, causing message state
to bleed between them. The useAgent hook now creates per-thread clones
keyed by agentId:threadId, keeping messages and state isolated.

Closes #2957

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 16:02:30 -07:00
github-actions[bot] 80da7704c4 chore(post-release): update version to 1.54.1-next.6 2026-03-25 22:04:40 +00:00
Martha Kelly Schumann dfdc234130 fix: respect defaultOpen={false} in CopilotSidebar and CopilotPopup (#3513)
## Summary

`<CopilotSidebar defaultOpen={false} />` was opening anyway because the
prop was not being forwarded through the provider chain. This PR fixes
that - and also addresses the architectural trade-off flagged in review.

### Who is affected

**User A** just uses `<CopilotSidebar />` with no outer provider
Before the fix, their sidebar opened by default. After the fix, it still
opens by default. Nothing changed for them.
                                                            
**User B** uses `<CopilotSidebar defaultOpen={false} />`
Before: broken (opened anyway). After: works.
**User C** wraps their app in a bare `CopilotChatConfigurationProvider`
and reads `isModalOpen` from it.
Before our fix `isModalOpen` was stuck at true forever. After: it
reflects the sidebar's state.

### What changed

- The `defaultOpen` prop is forwarded correctly through the provider
chain to both `CopilotSidebar` and `CopilotPopup`.
- Outer `useCopilotChatConfiguration()` hooks now reflect sidebar state.
Fixed via bidirectional state sync between nested providers.

### Files changed

- `packages/v2/react/src/components/chat/CopilotChat.tsx` - accept and
forward `isModalDefaultOpen`
- `packages/v2/react/src/components/chat/CopilotSidebar.tsx` - pass
`isModalDefaultOpen={defaultOpen}`
- `packages/v2/react/src/components/chat/CopilotPopup.tsx` - same
- `packages/v2/react/src/providers/CopilotChatConfigurationProvider.tsx`
- fix resolution logic + bidirectional sync
-
`packages/v2/react/src/providers/__tests__/CopilotChatConfigurationProvider.test.tsx`
- add tests

### Test plan

- [x] 843 tests pass (including 4 new bidirectional sync tests)
- [x] New tests cover all three reproduction scenarios from
[tkt-modal-default-open](https://github.com/CopilotKit/deep-agent-cpk-experiments/tree/main/app/client/src/tickets/tkt-modal-default-open)

**Linear:**
[CPK-7152](https://linear.app/copilotkit/issue/CPK-7152/fix-defaultopenfalse-prop-ignored-in-copilotsidebar)
**GitHub Issue:** #3475
**Related PRs:** #3477, #3496 (stalled community PRs addressing the same
issue)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-25 15:00:36 -07:00
Benjamin Taylor 72d637b052 feat(threads): Remove straggling console.log 2026-03-25 13:56:29 -07:00
Benjamin Taylor b1cc32c277 feat(threads): 'includedArchived' and pagination for threads API 2026-03-25 13:56:29 -07:00
Martha Schumann ea9b0bbd2a fix: bidirectional modal state sync between nested providers (CPK-7152)
PR #3513 fixed Behavior A (defaultOpen={false} now respected) but broke
Behavior B: users who read isModalOpen from an outer
CopilotChatConfigurationProvider no longer see state changes originating
in the inner provider (e.g. CopilotSidebarView's provider).

Root cause: with hasExplicitDefault=true, the inner provider used its own
setter exclusively, so open/close events never reached ancestor providers.

Fix: when a provider owns its state (hasExplicitDefault=true), wrap
setModalOpen to also call parentConfig.setModalOpen — propagating changes
upward through the provider chain. Add a useEffect to sync parent→child
when an ancestor's state is changed externally (e.g. via an outer hook).
The mount-skip guard (isMounted ref) ensures the child's own
isModalDefaultOpen is honoured on first render and not overwritten.

Three new tests mirror the reproduction scenarios from:
https://github.com/CopilotKit/deep-agent-cpk-experiments/tree/main/app/client/src/tickets/tkt-modal-default-open

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 12:23:06 -07:00
Maxim 838565d623 Merge branch 'main' into fix/abort-running-frontend-tool 2026-03-25 18:58:36 +01:00
Maxim 0918071f86 Merge branch 'main' into fix/react-strict-mode-hmr-agent-disconnect-fix 2026-03-25 17:52:48 +01:00
github-actions[bot] 0683758931 chore(post-release): update version to 1.54.1-next.5 2026-03-25 16:45:07 +00:00
Maxim f00dfd2359 Merge branch 'main' into fix/react-strict-mode-hmr-agent-disconnect-fix 2026-03-25 17:41:48 +01:00
Maxim e149f67507 Merge branch 'main' into fix/react-strict-mode-hmr-agent-disconnect-fix 2026-03-25 17:33:54 +01:00
Maxim 98daf5c90a Merge branch 'main' into feat/builtin-agent-persistent-mcp 2026-03-25 17:30:12 +01:00
Max Korp 0827b4cd50 fix: update @ag-ui deps to 0.0.48 to fix detachActiveRun hang
@ag-ui/client 0.0.47 had a bug where connectAgent() hung forever
  for agents that don't implement connect(), causing detachActiveRun()
  and runAgent() to deadlock. Fixed in 0.0.48.
2026-03-24 19:30:16 -07:00
github-actions[bot] ed99910e51 chore(post-release): update version to 1.54.1-next.4 2026-03-24 23:04:43 +00:00
Martha Kelly Schumann 35073c8cab fix: race condition in RunHandler.runAgent() causes dropped runs (#3514)
## Summary

Fixes a race condition where `detachActiveRun()` was called without
`await`, allowing a new run to overwrite pipeline state before cleanup
finished — silently dropping the previous run.

- **`run-handler.ts`**: `void agent.detachActiveRun()` → `await
agent.detachActiveRun()`. The original deadlock that motivated
fire-and-forget (ConnectNotImplementedError cleanup) has been resolved
in the current `@ag-ui/client`. Confirmed via git history: added as
fire-and-forget in `5b3037a` on Mar 13 by Max Korp.
- **`use-copilot-chat_internal.ts`**: Added AbortController cleanup in
the `connectAgent` useEffect, mirroring the V2 `CopilotChat.tsx`
pattern. Guards state updates against aborted signals.
- Updated test mocks to include `detachActiveRun`

**Linear:**
[CPK-7151](https://linear.app/copilotkit/issue/CPK-7151/fix-race-condition-in-runhandlerrunagent-causes-dropped-runs)
**GitHub Issue:** #3482

## Files changed

- `packages/v2/core/src/core/run-handler.ts`
- `packages/v1/react-core/src/hooks/use-copilot-chat_internal.ts`
-
`packages/v1/react-core/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx`
-
`packages/v1/react-core/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx`

## Test plan

- [x] All tests pass (pre-commit hook ran full suite)
- [x] Manual: rapid sequential message sends don't drop runs
- [x] Manual: verify no deadlock on initial connectAgent → immediate
runAgent

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-24 16:00:57 -07:00
github-actions[bot] e384ad05fa chore(post-release): update version to 1.54.1-next.3 2026-03-24 22:19:10 +00:00
Martha Kelly Schumann ae23784c60 fix: remove negative margin overlap and adjust content padding
Remove -mt-16 from input container so the scrollbar is not clipped.
Drop FEATHER_HEIGHT and inputContainerHeight from content padding
since the input is now a flex sibling, not an absolute overlay.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:15:23 -07:00
Martha Kelly Schumann cf61007202 fix: change chat layout from absolute to flex to fix scrollbar clipping
The input container was absolutely positioned on top of the scroll area,
causing the custom scrollbar to get clipped at the bottom. Changed to
flex column layout with negative margin to preserve the visual overlap
where messages fade behind the input.

Still needs tuning — bottom spacing varies by viewport. Pushing for
review to get input on the layout approach.

Resolves CPK-7153

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:15:23 -07:00
Martha Kelly Schumann b8fda39289 fix: address scroll bar styling when using mouse-wheel
Replace overflow-y-scroll with overflow-y-auto so the scrollbar only
appears when content overflows. Add minimal custom scrollbar CSS scoped
to [data-copilotkit] for a thin, rounded thumb with no gutter.

Resolves CPK-7153

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:15:23 -07:00
Maxim fef083e16f fix: prevent follow-up run restart when stop is called during frontend tool execution
When a user clicks Stop (or calls agent.abortRun()) while a frontend tool
handler is executing, processAgentResult would unconditionally start a new
runAgent() call — restarting the run the user just stopped.

Changes:
- Add AbortController to RunHandler, created per top-level runAgent() call
- stopAgent() now aborts the controller before calling agent.abortRun()
- agent.abortRun() is intercepted during a run to also abort the controller
- processAgentResult checks the abort signal before starting follow-up runs
- Tool handlers now receive an optional AbortSignal in their context for
  cooperative cancellation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:03:32 +01:00
Martha Kelly Schumann 8113dba21c fix: race condition in RunHandler.runAgent() causes dropped runs
Await detachActiveRun() in run-handler.ts instead of fire-and-forget.
The original deadlock that motivated void has been resolved in the
current @ag-ui/client — ConnectNotImplementedError cleanup now
completes reliably.

Add AbortController cleanup in use-copilot-chat_internal.ts to match
the V2 CopilotChat.tsx pattern, preventing stale state updates and
ensuring proper teardown on unmount/re-render.

Resolves CPK-7151
Closes #3482

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-24 14:56:17 -07:00
Martha Kelly Schumann 13584d0da9 fix: respect defaultOpen={false} in CopilotSidebar and CopilotPopup
Forward isModalDefaultOpen through CopilotChat into the configuration
provider. Fix nested provider resolution so explicit isModalDefaultOpen
overrides the parent's value instead of being ignored.

Resolves CPK-7152
Closes #3475

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 14:29:32 -07:00
Martha Schumann 3645c83fc0 fix: expose containerRef in CopilotChatInput children render prop
When using the children render prop pattern, containerRef was never
passed to the render function. This caused CopilotChatView's
ResizeObserver to never measure the input height, resulting in
insufficient paddingBottom and input overlapping chat messages.

Closes #3500

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 14:14:47 -07:00
Maxim ae8c75a374 feat(agent): add mcpClients for user-managed persistent MCP clients
Add MCPClientProvider interface and mcpClients config field to
BuiltInAgent, allowing users to provide pre-created MCP clients
whose tools are merged into the agent's tool set without per-request
lifecycle management. Users control persistence, auth, and caching.
2026-03-21 12:54:05 +01:00
Maxim 0d00b56801 fix: suppress AbortError in devtools when using CopilotKit with React StrictMode
React StrictMode double-mounts components in development, causing
CopilotChat's connectAgent() useEffect to abort its in-flight fetch
on the first cleanup. This produced noisy "Agent execution failed:
AbortError: signal is aborted without reason" errors in browser
devtools.

Two fixes:

1. withAbortErrorHandling() in agent.ts now catches AbortError
   (alongside the existing ZodError handling) and returns EMPTY,
   preventing the error from reaching onError() which would log
   "Agent execution failed:" to the console.

2. CopilotChat.tsx attaches .catch() to the fire-and-forget
   detachActiveRun() call in the cleanup function. The promise
   does not actually reject, but without an attached handler V8
   flags the promise chain as unhandled when the abort signal
   propagates through connected promises internally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 21:10:11 +01:00
Ben Taylor b84215f653 feat(runtime): Add a dedicated callback for identifying users in Intelligence (closes ENT-133) (#3471)
<!--
Thank you for sending the PR! We appreciate you spending the time to
work on these changes.

Help us understand your motivation by explaining why you decided to make
this change.


**Please PLEASE reach out to us first before starting any significant
work on new or existing features.**

By the time you've gotten here, you're looking at creating a pull
request so hopefully we're not too late.

We love community contributions! That said, we want to make sure we're
all on the same page before you start.
Investing a lot of time and effort just to find out it doesn't align
with the upstream project feels awful, and we don't want that to happen.
It also helps to make sure the work you're planning isn't already in
progress.

As described in our contributing guide, please file an issue first:
https://github.com/ag-ui-protocol/ag-ui/issues
Or, reach out to us on Discord: https://discord.com/invite/6dffbvGU3D


You can learn more about contributing to copilotkit here:
https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md

Happy contributing!

-->

## What does this PR do?

(Describe the changes introduced in this PR)

## Related PRs and Issues

- (Direct link to related PR or issue, if relevant)

## Checklist

- [ ] I have read the [Contribution
Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md)
- [ ] If the PR changes or adds functionality, I have updated the
relevant documentation
2026-03-19 10:51:14 -05:00
Mike Ryan dc297b182e refactor(runtime): clarify intelligence handler response guards 2026-03-19 08:36:13 -07:00
Mike Ryan 2f5da1a66f feat(runtime): Add a dedicated callback for identifying users in Intelligence (closes ENT-133) 2026-03-19 08:27:16 -07:00
github-actions[bot] a93d7f0ab8 chore(post-release): update version to 1.54.1-next.2 2026-03-19 15:25:58 +00:00
Benjamin Taylor 1fbf0fc7fc fix(runtime): Port Scarf event telemetry instrumentation from v1 to v2 2026-03-19 08:23:03 -07:00
Ran Shem Tov 31a721cdae feat: re-export state streaming langgraph middleware 2026-03-19 12:58:55 +01:00
github-actions[bot] 8238f0e912 chore(post-release): update version to 1.54.1-next.1 2026-03-18 22:17:23 +00:00
Jordan Ritter 3a50dc952c fix: handle empty tool arguments without crashing (#3439)
## Problem

When a HITL (Human-in-the-Loop) tool has no parameters, some providers
(e.g., Google ADK) send `arguments` as an empty string `""`.
`JSON.parse("")` throws `"Unexpected end of JSON input"`, crashing the
tool execution pipeline with an opaque error instead of executing the
tool with empty args.

Fixes #3263

## Root Cause

In `run-handler.ts`, both the specific-tool and wildcard-tool execution
paths call `JSON.parse(toolCall.function.arguments)` without checking
for empty/falsy values:

```ts
// Line 309 — specific tool path
parsedArgs = JSON.parse(toolCall.function.arguments); // crashes on ""

// Line 448 — wildcard tool path  
parsedArgs = JSON.parse(toolCall.function.arguments); // crashes on ""
```

## Fix

Treat empty/falsy argument strings as `{}` (empty object) before
parsing:

```ts
const rawArgs = toolCall.function.arguments;
parsedArgs = rawArgs ? JSON.parse(rawArgs) : {};
```

This matches the existing defensive patterns:
- **v1 `agui-to-gql.ts`**: already catches parse errors and falls back
to `{}`
- **v2 `web-inspector`**: already checks `args === "" ` before parsing
(line 818)

## Changes

| File | Change |
|------|--------|
| `packages/v2/core/src/core/run-handler.ts` | Safe empty-args fallback
at both parse sites |
| `packages/v2/core/src/__tests__/core-edge-cases.test.ts` | Updated
test: empty args → handler called with `{}` |
| `packages/v2/core/src/__tests__/core-full.test.ts` | Updated test:
empty args → handler called with `{}` |

## Testing

- All 230 passing tests still pass (61 pre-existing failures in
unrelated packages unchanged)
- Updated 2 tests that previously expected a crash on empty args to
verify the handler is called with `{}`
2026-03-18 15:13:34 -07:00
Jordan Ritter 08f10eb784 style: fix prettier formatting in edge cases test 2026-03-18 15:03:55 -07:00
github-actions[bot] 7865731108 chore(post-release): update version to 1.54.1-next.0 2026-03-18 19:40:35 +00:00
GregoireW da558d3e8b feat(vertex): Add vertex 2026-03-18 15:36:46 -04:00
giulio-leone d8457b7b10 refactor: extract parseToolArguments helper, type toolCall, add debug logging
Address review feedback:
- Extract parseToolArguments() to deduplicate empty/null/undefined handling
- Add debug-level warning when arguments fallback to {} (no longer silent)
- Type toolCall parameter as ToolCall instead of any in executeSpecificTool
  and executeWildcardTool
- Both specific-tool and wildcard paths share the same parsing logic
2026-03-15 18:28:51 +01:00
giulio-leone d423001771 fix: handle empty tool arguments without crashing
Treat empty, null, or undefined tool arguments as {} instead of throwing
a JSON parse error. Uses explicit checks (=== '' || === null || === undefined)
rather than a broad falsy check, as recommended in review.

Addresses all review feedback from jpr5:
- Added tests for wildcard tool path with empty args
- Added tests for null and undefined arguments
- Used explicit empty/null/undefined check instead of broad falsy
- Added inline comments explaining the fallback rationale
- Removed duplicate tests (TEST 7/8) from core-full.test.ts
- Removed console.log debugging statements from tests
2026-03-14 21:43:24 +01:00
Max Korp 5b3037a241 feat: Add support for intelligence platform
Co-authored-by: Benjamin Taylor <ben@liveloveapp.com>
Co-authored-by: Mike Ryan <mike.ryan52@gmail.com>
2026-03-13 14:02:59 -07:00
github-actions[bot] 8ce7d4a55c chore(post-release): update version to 1.54.0 2026-03-13 18:50:45 +00:00
Tyler Slaton a6de73aa96 chore(cli): release 1.0.0
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-03-13 14:49:17 -04:00
Tyler Slaton 3e60b48c1f chore(cli): release 1.54.0
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-03-13 14:38:42 -04:00