3119 Commits

Author SHA1 Message Date
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
Tyler Slaton bb96398854 fix(cli): remove prepare script on install
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-03-12 20:44:56 -04:00
github-actions[bot] ea746d4629 chore(post-release): update version to 1.54.0 2026-03-12 22:32:04 +00:00
Jordan Ritter 13da6bde76 feat: consolidate 73 standalone demo repos into monorepo (#3418)
## Summary

Migrates 47 standalone demo repositories from the CopilotKit GitHub org
into the monorepo under `examples/`, organized by category
(integrations, showcases, canvas). History is intentionally dropped —
shallow clone + file copy only.

Also migrates the `copilotkit` CLI package from CopilotCloud into
`packages/v1/cli` (previously stacked as PR #3419, now merged into this
branch).

### Demo consolidation

- **47 demos** imported across 4 groups (A=22, B=21, C=2, D=2)
- **26 repos excluded** — all 13 experiments (old/irrelevant
prototypes), 6 showcases (autotale, agui, campaign-manager, chat-sso,
crewai-enterprise, crm), and 7 starters (textarea, todos-app,
coagents-langgraph, coagents-crewai-flows, llamaindex-hitl,
enterprise-runner, react-vite-agent) dropped to reduce consolidation
footprint
- **Git LFS** tracks binary assets (png, jpg, jpeg, gif, mp4, webm, pdf)
— svg removed from LFS (text-based, breaks `GIT_LFS_SKIP_SMUDGE=1` clone
instructions)
- **Image deduplication** via `examples/images/` with symlinks from
individual examples
- **Tutorial branches** imported as `start/` and `final/` subdirectories
- **Cross-link rewriting** — all standalone repo URLs in READMEs and
docs updated to monorepo paths
- **Doc updates** — 18 tutorial/doc files updated with new clone
instructions and paths
- **Renovate config** — `examples/**` dependencies grouped into weekly
Monday PRs, v1/v2 legacy dirs excluded
- **`examples/README.md`** — full index of all 47 demos by category
- **Archive script** — `scripts/archive-demo-repos.sh` ready to
deprecate+archive original repos post-merge
- **Prettier** — all example files formatted to match monorepo standards
- **Example bug fixes** — Gemini agents (unguarded variables, sync
blocking, dead OpenAI route), langgraph-python (debug print, docstring
placement), StackBlitz URLs

### CLI migration (from CopilotCloud)

- `TEMPLATE_REPOS` updated to use monorepo subdirectory sparse checkout
for all CopilotKit-owned templates
- Tarball download fallback preserved for external repos
(ag2ai/ag2-copilotkit-starter)
- Package metadata (bugs, homepage, repository) updated to point to
monorepo
- Removed stale tsconfig paths/references to non-existent
`@repo/trpc-cli`
- **Pre-existing bug fixes:**
  - `base-command.ts`: unguarded `fetch()` crashed CLI when offline
  - `init.ts`: dropped all user flags when delegating to `create`
- `detect-endpoint-type.utils.ts`: Promise.all destructuring mismatch (5
promises, 4 variables)
- `auth.service.ts`: OAuth state validated after analytics, Promise
never settled on mismatch

### Category breakdown

| Category | Count | Path |
|----------|-------|------|
| Integrations | 17 | `examples/integrations/` |
| Canvas | 7 | `examples/canvas/` |
| Showcases | 23 | `examples/showcases/` |

### What happens after merge
- Run `scripts/archive-demo-repos.sh` to deprecate+archive the 47
consolidated repos
- 26 excluded repos (experiments + 6 showcases + 7 starters) left as-is
on GitHub
- Community announcement (Slack draft prepared)
- Post-merge verification (README rendering, LFS quotas, CLI test)

## Test plan

- [ ] `examples/README.md` renders correctly on GitHub with all links
working
- [ ] LFS-tracked images render in GitHub READMEs
- [ ] Spot-check 3-5 examples can `npm install && npm run dev`
successfully
- [ ] Symlinks in `examples/images/` resolve correctly
- [ ] No `.git/`, `.github/`, `node_modules/`, or `.env` files in any
example
- [ ] Doc tutorial paths point to existing `start/`/`final/` directories
- [ ] No remaining standalone repo URLs in docs
- [ ] `nx run copilotkit:test` passes (46/46)
- [ ] `copilotkit create` scaffolds from monorepo subdirectory
- [ ] CLI works offline (version check doesn't crash)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-12 16:29:54 -04:00
Jordan Ritter fd34bbfbf6 style: format all example files with prettier
Run prettier on ~1,865 files across examples/ to match the monorepo's
formatting standards. These files were imported as-is from standalone
repos that used different prettier configs.
2026-03-12 13:06:04 -07:00
Jordan Ritter f36dcc708f fix: resolve pre-existing bugs in CLI package
- base-command: wrap checkCLIVersion() fetch in try-catch so CLI
  doesn't crash when offline (version check is non-critical)
- init: forward argv to Create instead of dropping all flags, remove
  misleading flag definitions (init is just a deprecated redirect)
- detect-endpoint-type: fix Promise.all destructuring (5 promises but
  only 4 variables caused isCopilot to receive the LangGraph FastAPI
  result), add missing isMCP branch, use isLangGraphFastAPI result
- auth.service: validate OAuth state parameter before tracking analytics
  with user data, add reject()+server.close() on state mismatch so the
  Promise settles instead of hanging the CLI forever
- create.test: fix quote-style assertion to match prettier output
2026-03-12 13:06:03 -07:00
Jordan Ritter ad81aaa524 fix: address review findings in migrated CLI package
- Remove copy-paste triplication in scaffoldAgent (LangSmith block
  duplicated twice, causing duplicate .env entries and redundant writes)
- Update AgentTemplates URLs to point to monorepo paths instead of
  archived standalone repos
- Fix flags.projectName → args.projectName in banner logic (projectName
  is an Args field, not Flags)
- Remove stale trpc-cli path mapping and project reference from
  tsconfig.json (package doesn't exist in this monorepo)
2026-03-12 13:06:03 -07:00
Jordan Ritter bee70690bb feat: move CLI package from CopilotCloud into monorepo
Migrate the copilotkit CLI (npx copilotkit create/init/dev) from
CopilotCloud into packages/v1/cli. TEMPLATE_REPOS updated to use
monorepo subdirectory sparse checkout for all CopilotKit-owned
templates, with tarball fallback for external repos (ag2).
2026-03-12 13:06:03 -07:00
github-actions[bot] 98890426e5 chore(post-release): update version to 1.54.0-next.9 2026-03-12 19:08:50 +00:00
Alem Tuzlak 3780c6ae74 chore: deprecate all @copilotkitnext/* packages
Mark all publishable @copilotkitnext/* packages as deprecated in
package.json, pointing users to the @copilotkit/* equivalents.
V2 features will be available under the /v2 subpath.

Affected packages: shared, core, agent, angular, react, runtime,
sqlite-runner, web-inspector.
2026-03-12 15:05:29 -04:00
github-actions[bot] b443706792 chore(post-release): update version to 1.54.0-next.8 2026-03-12 16:52:13 +00:00
Ran Shem Tov ad85914b8c fix: inject useCopilotReadable context into connectAgent 2026-03-12 16:16:20 +01:00
github-actions[bot] ecd76256ed chore(post-release): update version to 1.54.0-next.7 2026-03-12 14:26:14 +00:00
Ran Shem Tov aa2f2c1af9 fix(react): use flushSync 2026-03-12 13:38:02 +01:00
Ran Shem Tov cad191176a fix(react): yield to React scheduler before follow-up agent run to prevent stale useAgentContext 2026-03-12 10:54:39 +01:00
github-actions[bot] ed34d9daef chore(post-release): update version to 1.54.0-next.6 2026-03-11 16:22:53 +00:00
Maxim a042d74a77 Merge branch 'main' into claude/condescending-turing 2026-03-11 20:09:15 +04:00
github-actions[bot] e9cb7dfe26 chore(post-release): update version to 1.54.0-next.5 2026-03-11 15:20:13 +00:00
Ran Shemtov 4c0f92ac58 Merge branch 'main' into feat/a2ui-cpk-theme 2026-03-11 16:16:36 +01:00
Ran Shem Tov 5433fc33da fix: refine default theme 2026-03-11 15:54:59 +01:00
Maxim 8554ca674b fix: preserve graceful arg-parse error handling in executeSpecificTool
Remove throw on isArgumentError — matches main's behavior where parse
errors are emitted via subscribers and the run continues, rather than
crashing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 17:36:38 +04:00
Tyler Slaton 8224d761a3 style: fix prettier formatting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 17:25:19 +04:00
Tyler Slaton 3efbf86314 feat(core): add copilotkit.runTool() for programmatic tool execution
Adds a new `runTool()` method to `CopilotKitCore` that allows programmatic
execution of registered frontend tools without requiring an LLM turn. This
enables UI-driven tool invocations (e.g., button clicks triggering tool
handlers) while maintaining proper message history and subscriber notifications.

Key changes:
- Extract `executeToolHandler` helper from duplicated logic in
  `executeSpecificTool` to share with `runTool`
- Add `runTool()` on `RunHandler` with tool/agent lookup, message creation,
  handler execution, and optional follow-up support
- Add `TOOL_NOT_FOUND` and `AGENT_NOT_FOUND` error codes
- Add `CopilotKitCoreRunToolParams` and `CopilotKitCoreRunToolResult` types
- Add delegation method on `CopilotKitCore`
- Add 16 comprehensive tests covering all runTool behaviors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 17:24:22 +04:00
github-actions[bot] 190eb07f09 chore(post-release): update version to 1.54.0-next.4 2026-03-11 12:50:08 +00:00
Maxim c233c260d1 fix(react): update standard-schema test mock for hook-based render tool calls
Same fix as zod-regression — the mock was missing addHookRenderToolCall
and removeHookRenderToolCall methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:52:06 +04:00
Maxim e5cbcb670a fix(react): update zod-regression test mock for hook-based render tool calls
The mock was missing addHookRenderToolCall/removeHookRenderToolCall methods
introduced by the separate hook vs prop render tool call storage refactor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:39:27 +04:00
Maxim a57dc40fca fix(react): remove as casts and clean up unused imports
Address review feedback: remove `as ReactToolCallRenderer` cast in
useFrontendTool by guarding with `tool.parameters` check (matching
CopilotKitProvider's pattern). Remove unused ReactToolCallRenderer
imports from use-frontend-tool.tsx and use-render-tool.tsx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:28:26 +04:00
Maxim fd44b5ba5f test(react): add StrictMode render tool call preservation tests
Add tests verifying:
- useFrontendTool render registrations survive StrictMode remount
- Hook and prop render entries coexist through StrictMode remount
- Hook render entries survive provider prop changes
- Update useRenderTool test mock to match new addHookRenderToolCall API

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:28:26 +04:00
Maxim 829589a625 fix(react): separate hook vs prop render tool call storage to fix StrictMode race
CopilotKitProvider's didMountRef guard breaks under React Strict Mode:
refs persist across the simulated unmount/remount cycle, causing the
provider's setRenderToolCalls effect to overwrite registrations from
useFrontendTool and useRenderTool hooks.

Split render tool call storage in CopilotKitCoreReact into two layers:
- _renderToolCalls: prop-based entries (set by provider)
- _hookRenderToolCalls: hook-based entries (set by useFrontendTool/useRenderTool)

The renderToolCalls getter merges both with a cached result for
useSyncExternalStore referential stability. Provider and hooks can
never overwrite each other, eliminating the race by design.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:28:26 +04:00
github-actions[bot] 60de47cda2 chore(post-release): update version to 1.54.0-next.3 2026-03-11 11:14:53 +00:00
Tyler Slaton 1550e5d541 fix(angular): address issue with the angular build failing due to typing
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-03-10 15:50:14 -07:00
Tyler Slaton 26541a9268 chore(lint): run formatter on changes
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-03-10 15:49:34 -07:00
Alem Tuzlak ea98c8649c test: add Zod regression tests for Standard Schema migration
Adds 77 regression tests across shared, core, react, and agent packages
proving that existing Zod usage produces identical results after the
Standard Schema V1 migration. Covers JSON Schema output identity,
additionalProperties stripping, schema pass-through to AI SDK, React
hook compatibility, and complex Zod patterns (unions, discriminated
unions, nested objects, arrays, constraints, defaults, etc.).
2026-03-10 15:36:27 -07:00