Commit Graph

396 Commits

Author SHA1 Message Date
Benjamin Taylor 47b7476702 feat(react-core): add CopilotDrawer wrapper and chat drawer-awareness
Add <CopilotDrawer> (interops with the shadow-DOM element, two-pronged license
gate, scoped chat-input focus return, registration-gated header launcher) and
extend CopilotChatConfigurationProvider with drawerOpen + mobile mutual
exclusion + a non-explicit active-thread setter so a bare drawer connects to the
picked thread and resets on New with no host wiring. useThreads gains an
{enabled} gate and a list-only error channel.
2026-06-25 10:42:46 -05:00
ranst91 bb69f55c98 chore: release monorepo v1.61.2 2026-06-25 07:54:33 +00:00
Tyler Slaton 947fe2142a fix(core): preserve agent-level headers instead of overwriting them (#5635) (#5637)
Fixes #5635.

## What

Headers set directly on an `HttpAgent` registered via
`agents__unsafe_dev_only` were silently replaced by the provider
headers. Per-agent auth headers (like an `Authorization` for a
self-hosted backend) got dropped, causing 401s.

## Why

`AgentRegistry.applyHeadersToAgent` did `agent.headers = {
...core.headers }`, a full overwrite. The run handler and the react-core
`useAgent` hook did the same. So an agent built with its own headers
lost them on registration, on every `setHeaders`, and before each
request.

## Fix

Merge instead of replace. The registry captures each agent's own headers
once (in a WeakMap, before the first apply) and rebuilds `{
...ownHeaders, ...coreHeaders }`. Core wins on key conflicts, which
keeps the existing "provider headers are authoritative" and logout/clear
behavior. All header application now routes through one method,
`CopilotKitCore.applyHeadersToAgent`, so runs never clobber per-agent
headers.

Vue and Angular benefit too: they dispatch runs through `core.runAgent`
/ `connectAgent`, so the merge is re-applied before every request.

## Tests

- core: 3 new cases in `core-headers.test.ts` (preserve, merge,
retain-across-setHeaders); existing overwrite and clear tests still
pass.
- react-core: new `use-agent-provider-headers.e2e.test.tsx` with a real
provider and an HttpAgent that has its own headers.

Verified locally: format, lint, full core + react-core suites, and both
builds.
2026-06-24 07:45:37 -07:00
Ben Taylor fbf154cb0d feat(core,react-core): add unarchiveThread to v2 thread store + useThreads (#5624)
## Summary

Adds `unarchiveThread(id)` to the v2 thread store (`@copilotkit/core`)
and the `useThreads` hook (`@copilotkit/react-core/v2`), restoring an
archived thread via the existing generic `PATCH /threads/:id { archived:
false }` update path — no new runtime endpoint. Mirrors `archiveThread`
across the store and hook.

This is the durable, architecture-independent piece extracted from the
threads-drawer effort. The drawer UI itself is being restarted as a
framework-agnostic **CopilotDrawer** (Lit web component + React/Angular
wrappers) under a separate spec; this hook method stands on its own and
is needed regardless.

## Testing

TDD. New core store test (`PATCH … { archived: false }`) and
`useThreads` hook test; full suites green (core, react-core).
2026-06-24 08:56:08 -05:00
Benjamin Taylor f90231f4fd feat(core,react-core): add unarchiveThread to thread store and useThreads
Restores an archived thread via the existing generic PATCH /threads/:id
update path with { archived: false } — the same mechanism example apps
already use for restore — so no new runtime route is required. Mirrors
archiveThread across the core thread store and the v2 useThreads hook.
2026-06-24 08:44:40 -05:00
Ran Shemtov 5d31ebbfb2 Merge branch 'main' into claude/stupefied-northcutt-12d382 2026-06-24 15:29:16 +02:00
Tyler Slaton 2291fc545f fix(react-core): resolve interrupt typecheck failures 2026-06-23 21:08:37 -07:00
Tyler Slaton a13c3ee663 chore: merge main into PR 5480 2026-06-23 20:50:16 -07:00
github-actions[bot] 3284bc863f style: auto-fix formatting 2026-06-23 22:34:58 +00:00
Tyler Slaton 75611b272c chore: merge main into PR 5480 2026-06-23 15:32:09 -07:00
Austin Merrick 4ba201b5c4 fix: repair check-types across all packages and gate it in CI
Repairs TypeScript check-types across the monorepo and adds a CI gate so
regressions are caught going forward:

- core: bundler module resolution and strict-mode fixes
- sdk-js: bundler module resolution; keep codegen, formatter, packaging working
- react-core: fixes across components, hooks, and tests
- react-native: restore catch binding referenced by TypeError cause
- runtime: repair check-types and bound AI SDK schema inference
- web-inspector: nodenext import extensions, export Anchor
- remaining packages and node example: assorted check-types repairs
- deps: add missing type-only devDependencies
- license context driven from /info licenseStatus
- ci: run check-types in the static quality workflow

Squashed from 12 commits for a single, easily-revertable change.
2026-06-23 15:26:47 -07:00
Austin Merrick 30bd6d8f0e test(core): pin remove/re-add baseline; doc + assertion polish
CR round 2 follow-ups (no behavior change):
- Add a core-headers regression test proving the agentOwnHeaders baseline
  stays pristine across remove + re-add (the WeakMap is intentionally not
  cleared on removal; clearing would re-capture polluted headers).
- Correct the stale `headers` config doc ("appended" -> merged on top of each
  HttpAgent's own headers, core wins).
- Tighten the e2e no-provider-headers assertion to toEqual.
2026-06-23 15:22:11 -07:00
tylerslaton 410d34001d chore: release monorepo v1.61.1 2026-06-23 21:00:28 +00:00
Tyler Slaton 56615da485 ci: reduce release delay, fix flakey test, use devops bot token (#5644)
## Summary
- Mint a GitHub App token for the stable release workflow and reuse it
for PR creation and follow-up API calls
- Disable lefthook during automation commits so release PR generation
does not depend on local developer hooks
- Relax the CopilotChat perf regression test to assert correctness
without a hard 5s wall-clock check

## Testing
- Unit/UI test updated to allow longer async rendering while still
verifying 100 messages render successfully
- Not run (not requested)
2026-06-23 13:56:33 -07:00
Tyler Slaton 83b21df925 Stabilize release PR token and chat perf test 2026-06-23 13:51:35 -07:00
Mike Ryan 3e4c515252 fix: preserve legacy thread endpoint behavior 2026-06-23 12:10:01 -07:00
Austin Merrick 6bfb12267f docs(core): document header merge/clear contract; pin clear-baseline test
CR round 1 follow-ups (no behavior change):
- Document on setHeaders + applyHeadersToAgent that the merge baseline is the
  agent's construction-time headers, so setHeaders can override but cannot
  remove a per-agent header (the agent's own value re-surfaces on clear), and
  that dynamic updates go through setHeaders, not direct agent.headers mutation.
- Tighten the agentOwnHeaders field comment (captured on first apply, never
  re-captured) and the applyHeadersToAgent method doc.
- Add a core-headers test pinning the clear-reveals-baseline contract.
- Soften the two useAgent test-mock comments: they are an additive stand-in,
  not a faithful model of core's frozen baseline.
2026-06-23 11:43:21 -07:00
Mike Ryan 3452657416 fix: update thread capability test fixtures 2026-06-23 11:36:58 -07:00
Mike Ryan 0187ec250a fix: address thread capability review feedback 2026-06-23 11:33:48 -07:00
Mike Ryan d906171c26 fix: honor thread endpoint capabilities 2026-06-23 11:33:10 -07:00
Mike Ryan db09796809 fix: gate thread endpoints by runtime capability 2026-06-23 11:32:30 -07:00
Alem Tuzlak 43fdba74aa feat: AG-UI standard interrupt support in useInterrupt + BuiltInAgent
Adds the AG-UI standard interrupt flow (RUN_FINISHED outcome:interrupt + resume array) alongside the legacy on_interrupt path.

- core: forward the standard resume array through runAgent.
- react-core / vue / react-native: useInterrupt handles standard interrupts with resolve()/cancel(), surfaces the primary + full interrupt set, and persists each resolved tool-backed interrupt as a tool-result message so multi-turn conversations stay well-formed (no dangling tool call -> no tool-call loop).
- runtime BuiltInAgent: native interrupts for the aisdk + tanstack factory paths via each SDK's needsApproval primitive (tool-approval-request / CUSTOM approval-requested -> outcome:interrupt); classic interrupt-tool emission + ctx.interrupt() factory primitive; idempotent resume injection mapped to each SDK's native tool-result; getCapabilities advertises humanInTheLoop.interrupts.
- docs: document standard interrupt support.

Verified across core/react-core/runtime unit suites and a real-model multi-turn run on both aisdk and tanstack.
2026-06-23 20:14:17 +02:00
Austin Merrick 59f96620bb fix(core): preserve agent-level headers instead of overwriting them (#5635)
HttpAgent headers configured directly on an agent registered via
agents__unsafe_dev_only were silently replaced by core headers, dropping
per-agent auth headers and causing 401s against self-hosted backends.

Core headers are now merged ON TOP of each agent's construction-time
headers (captured once in a WeakMap before the first apply), with the
core-level value winning on a key conflict. Header application is
centralized in CopilotKitCore.applyHeadersToAgent so the run handler and
the react-core useAgent hook share one merge path and never clobber
per-agent headers.
2026-06-23 10:33:32 -07:00
Nathan 🔶 Tarbert 7d644f22fa fix: reject pending human-in-the-loop promise on run abort (#5554) 2026-06-22 18:04:50 -04:00
Ran Shem Tov 15005794a5 feat(a2ui): passing a catalog to the provider auto-enables A2UI and tool injection
A catalog on <CopilotKit a2ui={{ catalog }}> is now enough to use A2UI
end to end. Previously developers also had to set a2ui.injectA2UITool: true
on the runtime.

The provider forwards an a2uiCatalogAvailable signal per run whenever it has
a catalog (and renders surfaces locally). handle-run reads that signal and
hands it to configureAgentForRequest, which enables A2UIMiddleware and defaults
injectA2UITool to true. An explicit injectA2UITool value (including false) and
an explicit a2ui.enabled: false are always respected via ?? / short-circuit, so
this only fills the default and never overrides a deeper opt-out.
2026-06-22 14:04:36 +02:00
Austin Merrick 4c71ea1138 fix(core): allow clearing headers via setHeaders with null/undefined
setHeaders typed headers as Record<string, string>, so there was no
type-safe way to clear a header (e.g. Authorization on logout) — passing
an empty string left the header present with a blank value.

Widen the signature to Record<string, string | null | undefined> and drop
any entry whose value is null/undefined. setHeaders remains a full overwrite,
so clearing one header while keeping the rest is the spread pattern:
setHeaders({ ...copilotkit.headers, Authorization: null }). A shared
normalizeHeaders helper enforces the same string-only invariant at both
write paths (constructor and setHeaders).

Update the react-core AuthTokenSync skill example to show the logout/clear
path and warn that a header must not be managed via both the headers prop and
imperative setHeaders (the provider re-applies prop-derived headers as a full
overwrite when its inputs change). Also update the setHeaders reference
signature docs. Tests cover null/undefined stripping, empty-string
preservation, overwrite-not-merge semantics, single-header clear via spread,
subscriber notification, and propagation to local and remote
(ProxiedCopilotRuntimeAgent) agents.

Fixes #5535
2026-06-19 14:13:02 -07:00
Mike Ryan b094156537 chore: release monorepo v1.61.0 2026-06-18 15:00:19 -07:00
Maxim 8bba3e5535 test(react-core): assert missing-config warning is silent for self-managed agents
Strengthen the license-signal test so it pins that selfManagedAgents
satisfies hasLocalAgents — the Enterprise warning fires while the
separate "Missing required prop" missing-runtime warning does not.

Refs #5417
2026-06-18 22:54:19 +02:00
Maxim 7ece925f12 feat(react-core): warn when selfManagedAgents is used without a license key
selfManagedAgents is part of CopilotKit's Enterprise Intelligence
offering. Emit an advisory console.warn (in both development and
production) when it is supplied without a publicLicenseKey/publicApiKey,
so production usage is surfaced. The signal is client-side and not
enforced — rendering still proceeds — and agents__unsafe_dev_only
remains a free local-dev escape hatch.

Refs #5417
2026-06-18 22:45:22 +02:00
Maxim 0b690a0290 test(react-core): fix inaccurate console spy comment
The spy comment claimed console.error was "not blanket-silenced", but
the mock implementation does silence it. Correct the wording.

Refs #5417
2026-06-18 22:08:48 +02:00
Maxim 9abaefa7be test(react-core): make self-managed agents render assertions self-contained
Clear the console.error spy inside the render helper so each assertion
is independent, and split the combined runtimeUrl/publicApiKey case into
two tests so each renders a single provider tree.

Refs #5417
2026-06-18 21:59:10 +02:00
Maxim 186bb719df test(react-core): strengthen self-managed agents validation coverage
Add empty-map (selfManagedAgents={}) throw case and the pre-existing
runtimeUrl/publicApiKey happy paths so a future gate inversion is
caught, and assert valid configs surface no unexpected console errors
instead of blanket-silencing console.error.

Refs #5417
2026-06-18 21:52:56 +02:00
Maxim 9907519989 fix(react-core): honor selfManagedAgents in CopilotKit wrapper validation
The v1 <CopilotKit> wrapper's validateProps threw ConfigurationError
whenever neither runtimeUrl nor a public key was supplied, ignoring
self-managed agents. This rejected the documented self-managed-agent
setup even though the underlying v2 CopilotKitProvider accepts it.
Mirror the provider's hasLocalAgents gate so selfManagedAgents and
agents__unsafe_dev_only satisfy the check.

Closes #5417
2026-06-18 21:11:04 +02:00
David McKay 0098840d42 test(react-core): assert HITL attribution survives the status transition
Extend the unscoped-tool attribution test to verify toolCallId persists and
agentId stays undefined after the tool moves InProgress -> Executing, not just
at InProgress.
2026-06-18 10:58:47 -05:00
David McKay ca07dcad63 refactor(react-core): exhaustiveness check for HITL render fallback
Code-review follow-up. Replace the unreachable `as any` fallback branch with
a compile-time exhaustiveness check (const _: never = props): a newly-added
ToolCallStatus now becomes a type error that must get its own branch, rather
than silently rendering with respond=undefined. Also correct the prop-build
comment (name/description are overwritten with the registration values, not
'normalized'). No behavior change for the three live statuses.
2026-06-18 10:58:42 -05:00
David McKay b8f6856b48 fix(react-core): accurate HITL attribution docs + defensive render fallback
Addresses code-review findings on the HITL attribution change:
- Correct the render-prop JSDoc: agentId is the tool's STATIC registration
  scope (undefined for unscoped tools), not the runtime sub-agent; toolCallId
  is the key to correlate with runtime attribution (onToolExecutionStart /
  event stream). Removes the over-claim that agentId resumes 'the correct
  sub-agent'.
- Compare props.status against the ToolCallStatus enum instead of string
  literals (removes silent drift risk).
- Inject name/description/agentId in the otherwise-unreachable fallback branch
  so attribution is never silently dropped if a status is ever added; cast
  the narrowed-never props to a record so the spread typechecks.

Behavior-preserving for the three live statuses; e2e suite green (13/13).
2026-06-18 10:51:52 -05:00
David McKay 93d3d80d80 feat(react-core): expose toolCallId and agentId on human-in-the-loop render props
The HITL render callback received args/status/result but no attribution, so
a UI could not tell which run raised an interrupt — the blocker for rendering
and resuming human-in-the-loop stops that originate from a subagent.

- Add toolCallId (already delivered at runtime via the renderer props spread;
  this only surfaces it in the type) and agentId (sourced from the tool's own
  registration) to all three ReactHumanInTheLoop render-prop variants.
- Thread agentId through useHumanInTheLoop's enhanced props.
- e2e tests assert both reach the render props through the real CopilotChat
  pipeline, and that agentId is undefined for an unscoped tool.

No shared renderer-contract or dispatch changes; no runtime behavior change.
2026-06-18 10:42:30 -05:00
Mike Ryan 237a176fbf chore: release monorepo v1.60.2 (#5517)
## Release monorepo v1.60.2

**Scope:** `monorepo` | **Bump:** `patch`

---

### How this release process works

1. **This PR was created automatically** by the "release / create-pr"
workflow.
   It bumped the `monorepo` packages to `1.60.2`
   and generated AI-enhanced release notes.

2. **CI runs on this PR** — the full test suite (unit tests, lint, type
checks, build)
   must pass before merging. This is the review gate.

3. **Review the release notes** in `release-notes.md` in this PR.
If a Notion draft was created, you can edit the release notes there
before merging.

4. **When this PR is merged**, the `release / publish` workflow
automatically:
   - Builds all packages
   - Publishes the `monorepo` packages to npm at version `1.60.2`
   - Creates git tag `monorepo/v1.60.2`
   - Creates a GitHub Release with the final release notes

### Before merging

- [ ] CI is green (tests, lint, types, build)
- [ ] Version bumps look correct
- [ ] Release notes are accurate (edit in Notion if a draft was created)

---

> **Do not merge until CI is fully green.** The full test suite runs
automatically on this PR.
2026-06-17 10:46:56 -07:00
davidmckayv 692e52244c chore: release monorepo v1.60.2 2026-06-17 16:59:44 +00:00
Tyler Slaton 8ec7d0d4e5 docs(shell-docs): restore enterprise intelligence product name 2026-06-17 09:16:29 -07:00
Tyler Slaton 449237af0c fix: rename premium docs to intelligence platform 2026-06-16 22:09:48 -07:00
Tyler Slaton 88588223af fix(react-core): add dark mode styling for default tool rendering (#5455)
## Summary
- Update the default tool-call renderer to use dark-theme-aware classes
for the card, header, status badge, and detail panels
- Add coverage for the dark theme styling path in unit tests
- Add a Storybook example that demonstrates the default tool renderer on
a dark CopilotKit surface

## Testing
- Added unit tests for the renderer’s dark-theme class output and
expanded details state
- Not run (not requested)
2026-06-16 10:04:54 -07:00
Jordan Ritter 7b80590f67 fix(react-core): await runAgent in useInterrupt::resolve
resolve() previously called copilotkit.runAgent(...) without await and
without return, so callers had no handle to sequence against the resume
run's settle. The harness DOM-settle check timed out for any consumer
awaiting the assistant confirmation bubble.

Changes:
- Make resolve async, return await copilotkit.runAgent(...) so callers
  receive a Promise that settles when the resume run settles.
- Update InterruptHandlerProps / InterruptRenderProps resolve return
  type from () => void to () => Promise<RunAgentResult>.
- Wrap runAgent in try/catch + setPendingEvent(null) + rethrow, so
  rejection clears the popup AND propagates to awaiting callers
  (mirrors onRunFailed handler symmetry; closes the case where
  runAgent rejects before any run-failed event fires, e.g. network
  error pre-RUN_STARTED).
- onRunFailed now also setPendingEvent(null) symmetric with
  onRunStartedEvent.
- Regression tests: RESUME-PATH asserts resolve() returns a Promise
  that settles 1:1 with runAgent; RESUME-PATH-REJECT asserts rejection
  propagates, popup clears, console.error logs.
2026-06-15 17:11:39 -07:00
Tyler Slaton bd2db6009a Add dark theme support to default tool renderer 2026-06-15 11:09:12 -07:00
jinhyuk9714 9639b8d4d6 fix(react-core): refresh thread headers on provider updates 2026-06-12 12:47:32 -05:00
Tyler Slaton 930e182d41 fix(react-core): stabilize pin-to-send scrolling (#5386)
## What does this PR do?

Fixes `pin-to-send` scrolling in the v2 chat view.

- Re-attaches the non-autoscroll scroll listener after the real scroll
element mounts by depending on `nonAutoScrollEl`, not the stable
`scrollRef` object.
- Lets the `usePinToSend` spacer adjust in both directions as content
below the pinned user message changes, so the user message stays
anchored after streaming finishes and layout height changes.
- Adds regression coverage for the scroll-to-bottom button and spacer
adjustment behavior.

## Related PRs and Issues

Fixes #5355

## Tests

- `corepack pnpm -C packages/react-core exec vitest run
src/v2/hooks/__tests__/use-pin-to-send.test.tsx
src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.tsx`
- `corepack pnpm exec oxfmt --check
packages/react-core/src/v2/components/chat/CopilotChatView.tsx
packages/react-core/src/v2/hooks/use-pin-to-send.ts
packages/react-core/src/v2/hooks/__tests__/use-pin-to-send.test.tsx
packages/react-core/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.tsx`
- `git diff --check`

Attempted:

- `corepack pnpm -C packages/react-core run check-types`
- This failed in the local workspace on existing/type-resolution issues
outside this diff, including `react-markdown` JSX namespace errors,
missing `@copilotkit/runtime-client-gql` declarations, and existing e2e
mock `AbstractAgent` private member mismatches.

## Checklist

- [x] I have read the [Contribution
Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md)
- [x] If the PR changes or adds functionality, I have updated the
relevant documentation (N/A: bug fix only, no API/docs change)
- [x] "Allow edits by maintainers" is checked (lets us help iterate on
your PR directly — faster turnaround for everyone)
2026-06-12 10:34:38 -07:00
Austin Merrick 9275ec2ce0 fix(react-core): cover mermaid-block + sub/superscript streamdown styles 2026-06-12 09:49:45 -07:00
Tushar-Khandelwal-2004 f90c3dcfd7 fix(react-core): scope streamdown markdown styles 2026-06-12 09:49:44 -07:00
ranst91 02c3a8aef0 chore: release monorepo v1.60.1 2026-06-12 13:03:45 +00:00
Ran Shem Tov 7805a9a57b fix: update cpk to use latest agui core packages 2026-06-12 11:16:19 +02:00