Commit Graph

121 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 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
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 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
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 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 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
Jordan Ritter a8b224e935 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-14 13:50:23 -07:00
github-actions[bot] 8933ee82b5 style: auto-fix formatting 2026-04-14 16:39:04 +00:00
Alem Tuzlak 488c7d00e0 fix: address PR review feedback for debug mode
- Count all emitted events unconditionally (eventCount), track separately
  how many were logged (loggedEventCount) — completion log shows both
- Remove dead `?? undefined` on runtime.debug (non-optional type)
- Update test to verify eventCount reflects actual events; add test with
  events: true to verify loggedEventCount
2026-04-14 18:34:49 +02:00
Alem Tuzlak 7e0a632e64 test: add debug mode tests for shared, runtime, and core packages 2026-04-14 18:34:47 +02:00
Alem Tuzlak 99c3a39a29 style: fix prettier formatting 2026-04-14 18:34:47 +02:00
Alem Tuzlak 4ec0230cf8 fix(runtime): guard debug property access for backward compat with mock runtimes 2026-04-14 18:34:46 +02:00
Alem Tuzlak 0b2731e8da feat(runtime): add debug logging to SSE event pipeline 2026-04-14 18:34:08 +02:00
Alem Tuzlak b9127c18c1 feat(runtime): accept debug config on CopilotRuntime constructor 2026-04-14 18:34:07 +02:00
Alem Tuzlak 983274f7c3 Merge branch 'main' into worktree-nested-tinkering-quail 2026-04-14 14:11:42 +02:00
Alem Tuzlak 19b99dd2ae fix(runtime): widen TanStack message content type for adapter compat (#3747)
## Summary

- Widen `TanStackChatMessage.content` from `TanStackContentPart[]`
  to `any[]` so messages from `convertInputToTanStackAI` are directly
  passable to any TanStack AI adapter without `as any` casts
- Split `TanStackContentPart` into a proper discriminated union with
  separate variants per modality
- Add `env.d.ts` with `vite/client` reference for CSS import types
- Fix `onError` callback shape in the example

## Test plan

- [x] All 17 multimodal TanStack tests pass
- [x] All 294 agent tests pass
- [ ] Verify no TS errors in react-router example IDE

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-04-14 14:11:18 +02:00
Jordan Ritter b53844c8c3 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-13 09:11:28 -07:00
Jordan Ritter 6bf84f3cec 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-13 09:07:38 -07:00
Jordan Ritter 4e10f1344a 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-13 08:27:19 -07:00
Alem Tuzlak f55cd5f7e2 Merge remote-tracking branch 'origin/main' into worktree-nested-tinkering-quail
# Conflicts:
#	packages/runtime/src/v2/runtime/handlers/get-runtime-info.ts
2026-04-13 15:03:54 +02:00
Alem Tuzlak 4b279cee64 fix: address code review findings on capabilities
- Restore getCapabilities() return type to Promise<AgentCapabilities>
  with ?? {} fallback, honoring AbstractAgent base class contract
- Simplify type annotation in get-runtime-info.ts to explicit
  AgentCapabilities | undefined instead of complex Awaited<ReturnType<...>>
- Add console.warn logging to per-agent capabilities error catch block
- Fix useCapabilities JSDoc to accurately describe behavior during
  runtime handshake
- Add test for empty capabilities object {} (truthy, included in response)
- Update error isolation test to verify warning is logged
2026-04-13 14:49:50 +02:00
Alem Tuzlak ee926b8628 fix: address capabilities review feedback
- Add per-agent error isolation in /info handler so a single
  getCapabilities() failure doesn't 500 the whole endpoint
- Normalize getCapabilities() to return undefined (not {}) when no
  capabilities are set, matching the sync getter
- Replace instanceof ProxiedCopilotRuntimeAgent with duck-type check
  in useCapabilities hook for extensibility
- Add JSDoc warning about shallow-merge behavior on capabilities config
- Add useCapabilities hook tests (5 cases covering both branches)
- Add per-agent error isolation test for get-runtime-info
2026-04-13 11:22:22 +02:00
Alem Tuzlak 327d134ecd Merge remote-tracking branch 'origin/main' into worktree-nested-tinkering-quail
# Conflicts:
#	packages/angular/package.json
#	packages/core/package.json
#	packages/demo-agents/package.json
#	packages/react-core/package.json
#	packages/runtime/package.json
#	packages/shared/package.json
#	packages/sqlite-runner/package.json
#	packages/web-inspector/package.json
#	pnpm-lock.yaml
2026-04-13 11:12:25 +02:00
Jordan Ritter 6c4162c2d0 fix: support per-request agent factory function (#2941)
Add AgentsFactory type that accepts a function receiving request context,
enabling multi-tenant and request-scoped agent configuration. The agents
option now accepts a static record, a Promise, or a factory function.
2026-04-12 16:09:41 -07:00
tylerslaton ccdd276a6d chore: release monorepo v1.55.3 2026-04-11 06:24:17 +00:00
github-actions[bot] 087cbae689 chore: version packages 2026-04-10 23:38:59 +00:00
github-actions[bot] 4fcfe35fc5 style: auto-fix formatting 2026-04-10 14:02:10 -05:00
Max Korp 215bfd9385 test(runtime): add thread route coverage to fetch-router tests 2026-04-10 14:02:10 -05:00
Max Korp 395e10059c fix(runtime): restore thread routes dropped during fetch-handler rewrite 2026-04-10 14:02:10 -05:00
github-actions[bot] 3e43f35131 chore: version packages (next) 2026-04-10 18:29:58 +00:00
Alem Tuzlak ff2093102c chore(lint): add new oxlint rules and auto-fix violations
Enable stricter oxlint rules for better code health:
- typescript/consistent-type-imports: enforce `import type` for type-only imports
- typescript/no-import-type-side-effects: prefer top-level type imports
- import/consistent-type-specifier-style: consistent type specifier placement
- typescript/no-unnecessary-type-assertion: bump to error
- react/self-closing-comp: enforce self-closing JSX components
- unicorn/prefer-optional-catch-binding: drop unused catch params
- eslint/no-useless-computed-key: simplify object keys
- unicorn/prefer-string-slice: prefer .slice() over .substring()
- unicorn/prefer-array-flat-map: prefer .flatMap() over .map().flat()

All existing violations auto-fixed via oxlint --fix.
2026-04-10 19:29:32 +02:00
Alem Tuzlak c3fc0091a0 fix(runtime): widen TanStack message content type for adapter compat
TanStackChatMessage.content uses any[] for multimodal so
messages are directly passable to any adapter without casts.
Add env.d.ts with vite/client types for CSS imports.
2026-04-10 17:53:43 +02:00
Alem Tuzlak 672d3cf2e1 fix(runtime): preserve empty text parts in TanStack converter
Fix falsy check dropping valid empty-string text parts.
Add tests for unknown part types, null content, and
binary parts with neither data nor url.
2026-04-10 17:29:24 +02:00
Alem Tuzlak 4a69d7a8e3 feat(runtime): add multimodal support to TanStack converter
- Fix convertInputToTanStackAI silently dropping multimodal
  content (images, audio, video, documents) by converting
  AG-UI content parts to TanStack AI ContentPart format
- Switch react-router example from Hono server to a React
  Router resource route using createCopilotRuntimeHandler
- Both agents now use BuiltInAgent factory pattern
- Remove hono/react-router-hono-server deps from example
2026-04-10 17:15:57 +02:00
Tyler Slaton 214924c7f9 Merge branch 'main' into worktree-fancy-mapping-valley 2026-04-09 20:47:51 -07:00
Jordan Ritter 1b01725d40 test: add 18 MCP integration tests with aimock MCPMock
Phase 1 — BasicAgent mcpServers (8 tests):
- HTTP transport tool fetch, SSE error handling
- Tool call round-trip, client cleanup, unreachable server error
- Multiple servers merge tools, error-path cleanup, tool descriptions

Phase 2 — MCPAppsActivityRenderer proxy (5 tests):
- tools/call proxy round-trip, error handling
- ui/open-link handler + missing URL error
- Multiple independent activities

Phase 3 — MCPAppsMiddleware edge cases (5 tests):
- Middleware creation, tools/call proxy, resources/read proxy
- Non-proxied request delegation, wrong serverHash error

All tests use real HTTP connections to aimock MCPMock.
2026-04-09 14:58:32 -07:00
Jordan Ritter 55663ee69f chore(runtime): add @copilotkit/aimock devDependency for MCP integration tests 2026-04-09 14:54:07 -07:00
Alem Tuzlak 3dd17c1c5b Merge branch 'main' into worktree-fancy-mapping-valley 2026-04-09 20:40:27 +02:00
github-actions[bot] 1bc4786759 chore: version packages (next) 2026-04-09 18:09:30 +00:00
Tyler Slaton 62c604213c chore(a2ui-renderer): bump version for a2ui-middleware to 0.0.4
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-04-09 11:05:10 -07:00
github-actions[bot] 0093bdbaa4 chore: version packages 2026-04-09 02:26:42 +00:00
github-actions[bot] c2837a3001 chore: version packages (next) 2026-04-09 01:53:20 +00:00
Tyler Slaton 422f5f55e1 fix(open-gen-ui): correctly import clairinet
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-04-08 18:09:03 -07:00