Skip to content

feat(learning): connect Trajectories through Runtime and Gateway - #7566

Merged
AlemTuzlak merged 15 commits into
alem/pe-471-pair-on-browser-interaction-capture-experimentsfrom
codex/trajectory-contract-smoke
Oct 2, 2026
Merged

AlemTuzlak merged 15 commits into
alem/pe-471-pair-on-browser-interaction-capture-experimentsfrom
codex/trajectory-contract-smoke

Conversation

@marthakelly

@marthakelly marthakelly commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

The SDK now sends raw Trajectory activity through Runtime authentication and the Phoenix Realtime Gateway. This connects the collector in #7556 to Intelligence while retaining the public methods startTrajectory, stopTrajectory, and emitTrajectoryEvent.

This PR follows Ben’s feedback on the contract Notion doc and the backend API in Intelligence #1569, checked at a8242078. Capture scope follows Tyler’s self-hosted update.

Behavior

  • Runtime resolves identity on the server and requests a single-use join token. The project key stays on the server. Invalid server credentials return generic 502 CONNECTION_FAILED; missing user identity returns 401 IDENTITY_REQUIRED.
  • Capture starts only after authentication and channel join. Default capture includes full page URLs/query strings/fragments, title/referrer, clicked-element text and attributes, form values, and browser-visible request/response headers and bodies. It adds no Thread context. Existing explicit app opt-outs remain, and Runtime/SDK traffic is excluded.
  • Core sends events batches with sequence numbers and dropped counts. Ben’s limits remain 16 KiB/event, 50 events/batch, and 64 KiB/batch. Each body snapshot has a 4 KiB serialized budget and a one-second read timeout; truncation or unavailable content is marked. Oversized events report loss instead of bypassing Gateway limits.
  • Receipts confirm acceptance into Redis; the backend projects accepted events into Postgres asynchronously. trajectory_over_share and trajectory_outbox_full are known rejections. storage_unavailable can mean a Redis timeout after a write, so it reports PERSISTENCE_UNKNOWN without replaying events or drop counts.
  • Capture pauses offline and gets a fresh token on reconnect. Developer events emitted during recovery count as dropped. Failed batches are not resent. Stop cancels observers, pending starts, and reconnects; it attempts a final batch without waiting for persistence. Native environments without DOM observers can still emit developer events.
  • Switching from a custom sink to authenticated capture releases legacy agent subscriptions and attribution. React supports automatic/manual start and cleanup on disable/unmount.

Scope and limits

Thread linking, container assignment, and Inspector work remain deferred. October 9 targets self-hosted ingestion and the saved Trajectories view behind a feature flag. Live updates in the Intelligence web app move to October 16; the SDK’s ingestion socket remains required. Web UI, backend flag rollout, and managed-service privacy/security work are separate from this SDK PR.

Each new Core instance needs a new Trajectory UUID. Sequence numbers persist across reconnects and stop/start on that instance, but there is no cross-tab or reload resume cursor. Initial offline start returns CONNECTION_LOST; callers retry when online.

Validation

Production SDK code is exercised with synthetic browser data and mocked external services; no deployed Gateway, Redis, or Postgres is claimed.

  • Learning: 73 tests, build/types, publint, and attw pass. The expanded package is about 5.5 KiB gzipped; its bundle budget is now 6 KiB.
  • Core: all 1,102 tests pass, including 48 transport tests, 23 bridge tests, and 3 real-Phoenix boundary tests. The full-capture test verifies raw fields through capture → Core batch → Phoenix frames, self-capture exclusions, cleanup, and late-response isolation.
  • React 18 and 19: 17 focused lifecycle tests each pass. Core build/types and React types pass. Changed files pass scoped lint and diff checks.
  • Runtime code is unchanged in this update; its 71 focused authentication tests passed in the preceding review fixes.

The broad package commit hook was excluded because unrelated native prerequisites are unavailable locally. Scoped Nx checks ran separately; CI covers the complete PR.

Review/merge order: #7556, then #7566. This is a dependent branch stack; GitHub’s native stack feature is not enabled.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: CopilotKit/CopilotKit/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: da3ffb25-9396-4ae4-ae63-2734e7ad48e2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/a2ui-renderer@7566

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/agentcore-runner@7566

@copilotkit/angular

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/angular@7566

@copilotkit/channels

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels@7566

@copilotkit/channels-core

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-core@7566

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-discord@7566

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-intelligence@7566

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-slack@7566

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-teams@7566

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-telegram@7566

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-ui@7566

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/channels-whatsapp@7566

@copilotkit/core

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/core@7566

@copilotkit/intelligence-langgraph

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/intelligence-langgraph@7566

@copilotkit/intelligence-mastra

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/intelligence-mastra@7566

@copilotkit/learning

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/learning@7566

@copilotkit/mcp-apps-renderer

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/mcp-apps-renderer@7566

@copilotkit/react-core

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-core@7566

@copilotkit/react-native

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-native@7566

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-textarea@7566

@copilotkit/react-ui

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/react-ui@7566

@copilotkit/runtime

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/runtime@7566

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/runtime-client-gql@7566

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/sdk-js@7566

@copilotkit/shared

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/shared@7566

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/sqlite-runner@7566

@copilotkit/voice

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/voice@7566

@copilotkit/vue

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/vue@7566

@copilotkit/web-components

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/web-components@7566

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/CopilotKit/CopilotKit/@copilotkit/web-inspector@7566

commit: d9a04f7

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Size Change: +12.9 kB (+0.74%)

Total Size: 1.75 MB

📦 View Changed
Filename Size Change
packages/core/dist/index.cjs 78.6 kB +3.93 kB (+5.26%) 🔍
packages/core/dist/index.mjs 78.1 kB +3.94 kB (+5.31%) 🔍
packages/core/dist/index.umd.js 84.2 kB +4.37 kB (+5.47%) 🔍
packages/react-core/dist/copilotkit-8zh0nUyb.mjs 0 B -122 kB (removed) 🏆
packages/react-core/dist/copilotkit-B_vlszdV.cjs 0 B -120 kB (removed) 🏆
packages/react-core/dist/copilotkit-B8f6xWvU.cjs 120 kB +120 kB (new file) 🆕
packages/react-core/dist/copilotkit-BiEaBqgK.mjs 123 kB +123 kB (new file) 🆕
packages/react-core/dist/index.cjs 17.6 kB +3 B (+0.02%)
packages/react-core/dist/index.umd.js 68.3 kB +164 B (+0.24%)
packages/react-core/dist/v2/index.cjs 4.04 kB +2 B (+0.05%)
packages/react-core/dist/v2/index.umd.js 123 kB +158 B (+0.13%)
ℹ️ View Unchanged
Filename Size
packages/a2ui-renderer/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/a2ui-renderer/dist/a2ui-types.cjs 472 B
packages/a2ui-renderer/dist/a2ui-types.mjs 469 B
packages/a2ui-renderer/dist/index.cjs 959 B
packages/a2ui-renderer/dist/index.mjs 637 B
packages/a2ui-renderer/dist/index.umd.js 12.9 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.cjs 1.52 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.mjs 1.46 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.cjs 904 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.mjs 492 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.cjs 1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.mjs 596 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.cjs 829 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.mjs 419 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.cjs 799 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.mjs 737 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.cjs 1.63 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.mjs 1.57 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.cjs 856 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.cjs 1.12 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.mjs 1.05 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.cjs 842 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.mjs 432 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.cjs 877 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.mjs 469 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.cjs 995 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.mjs 587 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.cjs 920 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.mjs 508 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.cjs 1.19 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.mjs 1.13 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.cjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.mjs 801 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.cjs 1.06 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.mjs 984 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.mjs 1.04 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.cjs 903 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.mjs 489 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.mjs 1.14 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.cjs 788 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.mjs 378 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.cjs 928 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.mjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.cjs 579 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.mjs 556 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.cjs 982 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.mjs 580 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.cjs 800 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.mjs 735 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.cjs 1.08 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.cjs 894 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.mjs 839 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.cjs 849 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.mjs 804 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.cjs 310 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.mjs 325 B
packages/a2ui-renderer/dist/react-renderer/catalog-utils.cjs 1.59 kB
packages/a2ui-renderer/dist/react-renderer/catalog-utils.mjs 1.52 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.cjs 1.5 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.mjs 1.42 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.cjs 728 B
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.mjs 671 B
packages/a2ui-renderer/dist/react-renderer/create-catalog.cjs 1.35 kB
packages/a2ui-renderer/dist/react-renderer/create-catalog.mjs 1.28 kB
packages/a2ui-renderer/dist/react-renderer/filter-catalog.cjs 622 B
packages/a2ui-renderer/dist/react-renderer/filter-catalog.mjs 569 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.cjs 316 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.mjs 309 B
packages/a2ui-renderer/dist/react-renderer/index.cjs 409 B
packages/a2ui-renderer/dist/react-renderer/index.mjs 568 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.cjs 236 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.mjs 188 B
packages/a2ui-renderer/dist/react-renderer/styles/index.cjs 239 B
packages/a2ui-renderer/dist/react-renderer/styles/index.mjs 231 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.cjs 436 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.mjs 381 B
packages/mcp-apps-renderer/dist/activity.cjs 259 B
packages/mcp-apps-renderer/dist/activity.mjs 170 B
packages/mcp-apps-renderer/dist/activity.umd.js 1.84 kB
packages/mcp-apps-renderer/dist/constants.cjs 714 B
packages/mcp-apps-renderer/dist/constants.mjs 712 B
packages/mcp-apps-renderer/dist/content-schema.cjs 392 B
packages/mcp-apps-renderer/dist/content-schema.mjs 386 B
packages/mcp-apps-renderer/dist/follow-up.cjs 796 B
packages/mcp-apps-renderer/dist/follow-up.mjs 794 B
packages/mcp-apps-renderer/dist/index.mjs 268 B
packages/mcp-apps-renderer/dist/request-queue.mjs 1.05 kB
packages/mcp-apps-renderer/dist/sandbox.mjs 1.14 kB
packages/mcp-apps-renderer/dist/session.mjs 3.05 kB
packages/react-core/dist/index.mjs 17.5 kB
packages/react-core/dist/v2/context.cjs 1.58 kB
packages/react-core/dist/v2/context.mjs 1.5 kB
packages/react-core/dist/v2/headless.cjs 16.3 kB
packages/react-core/dist/v2/headless.mjs 15.8 kB
packages/react-core/dist/v2/index.mjs 4.03 kB
packages/react-native/dist/chunk-C0xms8kb.cjs 546 B
packages/react-native/dist/components/index.cjs 8.65 kB
packages/react-native/dist/components/index.mjs 8.45 kB
packages/react-native/dist/CopilotKitProvider-CjoPnabW.cjs 1.55 kB
packages/react-native/dist/CopilotKitProvider-D8sn7G_C.mjs 1.43 kB
packages/react-native/dist/headless.cjs 632 B
packages/react-native/dist/headless.mjs 373 B
packages/react-native/dist/index.cjs 6.52 kB
packages/react-native/dist/index.mjs 6.14 kB
packages/react-native/dist/polyfills.cjs 195 B
packages/react-native/dist/polyfills.mjs 195 B
packages/react-native/dist/polyfills/crypto.cjs 373 B
packages/react-native/dist/polyfills/crypto.mjs 381 B
packages/react-native/dist/polyfills/dom.cjs 540 B
packages/react-native/dist/polyfills/dom.mjs 550 B
packages/react-native/dist/polyfills/encoding.cjs 332 B
packages/react-native/dist/polyfills/encoding.mjs 307 B
packages/react-native/dist/polyfills/location.cjs 236 B
packages/react-native/dist/polyfills/location.mjs 244 B
packages/react-native/dist/polyfills/streams.cjs 371 B
packages/react-native/dist/polyfills/streams.mjs 339 B
packages/react-native/dist/streaming-fetch-BnQh3vBz.mjs 2.22 kB
packages/react-native/dist/streaming-fetch-BTESzLKX.cjs 2.27 kB
packages/react-textarea/dist/index.cjs 17.7 kB
packages/react-textarea/dist/index.mjs 17 kB
packages/react-textarea/dist/index.umd.js 18.5 kB
packages/react-ui/dist/index.cjs 25.2 kB
packages/react-ui/dist/index.mjs 24.5 kB
packages/react-ui/dist/index.umd.js 26.4 kB
packages/runtime-client-gql/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/runtime-client-gql/dist/client/conversion.cjs 1.52 kB
packages/runtime-client-gql/dist/client/conversion.mjs 1.45 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.cjs 1.58 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.mjs 1.54 kB
packages/runtime-client-gql/dist/client/types.cjs 701 B
packages/runtime-client-gql/dist/client/types.mjs 642 B
packages/runtime-client-gql/dist/graphql/@generated/gql.cjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/gql.mjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/graphql.cjs 2.4 kB
packages/runtime-client-gql/dist/graphql/@generated/graphql.mjs 2.36 kB
packages/runtime-client-gql/dist/graphql/definitions/mutations.cjs 740 B
packages/runtime-client-gql/dist/graphql/definitions/mutations.mjs 732 B
packages/runtime-client-gql/dist/graphql/definitions/queries.cjs 316 B
packages/runtime-client-gql/dist/graphql/definitions/queries.mjs 304 B
packages/runtime-client-gql/dist/index.cjs 679 B
packages/runtime-client-gql/dist/index.mjs 495 B
packages/runtime-client-gql/dist/index.umd.js 9.58 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.cjs 1.72 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.mjs 1.7 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.cjs 1.56 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.mjs 1.53 kB
packages/runtime-client-gql/dist/package.cjs 181 B
packages/runtime-client-gql/dist/package.mjs 116 B
packages/shared/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/shared/dist/a2ui-prompts.cjs 2.85 kB
packages/shared/dist/a2ui-prompts.mjs 2.85 kB
packages/shared/dist/attachments/content.cjs 255 B
packages/shared/dist/attachments/content.mjs 253 B
packages/shared/dist/attachments/utils.cjs 1.83 kB
packages/shared/dist/attachments/utils.mjs 1.79 kB
packages/shared/dist/constants/index.cjs 362 B
packages/shared/dist/constants/index.mjs 345 B
packages/shared/dist/debug.cjs 454 B
packages/shared/dist/debug.mjs 452 B
packages/shared/dist/event-transforms/index.cjs 335 B
packages/shared/dist/event-transforms/index.mjs 165 B
packages/shared/dist/event-transforms/open-generative-ui-middleware.cjs 2.42 kB
packages/shared/dist/event-transforms/open-generative-ui-middleware.mjs 2.35 kB
packages/shared/dist/event-transforms/recorded-events.cjs 988 B
packages/shared/dist/event-transforms/recorded-events.mjs 925 B
packages/shared/dist/finalize-events.cjs 1.94 kB
packages/shared/dist/finalize-events.mjs 1.88 kB
packages/shared/dist/index.cjs 2.89 kB
packages/shared/dist/index.mjs 2.47 kB
packages/shared/dist/index.umd.js 30.7 kB
packages/shared/dist/intelligence-routing-fields.cjs 778 B
packages/shared/dist/intelligence-routing-fields.mjs 775 B
packages/shared/dist/logger.cjs 112 B
packages/shared/dist/logger.mjs 112 B
packages/shared/dist/package.cjs 181 B
packages/shared/dist/package.mjs 116 B
packages/shared/dist/standard-schema.cjs 740 B
packages/shared/dist/standard-schema.mjs 737 B
packages/shared/dist/telemetry/index.cjs 358 B
packages/shared/dist/telemetry/index.mjs 250 B
packages/shared/dist/telemetry/lambda-client.cjs 1.59 kB
packages/shared/dist/telemetry/lambda-client.mjs 1.58 kB
packages/shared/dist/telemetry/model-host.cjs 1.63 kB
packages/shared/dist/telemetry/model-host.mjs 1.62 kB
packages/shared/dist/telemetry/sampling.cjs 956 B
packages/shared/dist/telemetry/sampling.mjs 935 B
packages/shared/dist/telemetry/telemetry-client.cjs 1.88 kB
packages/shared/dist/telemetry/telemetry-client.mjs 1.83 kB
packages/shared/dist/telemetry/telemetry-disabled.cjs 454 B
packages/shared/dist/telemetry/telemetry-disabled.mjs 451 B
packages/shared/dist/telemetry/utils.cjs 321 B
packages/shared/dist/telemetry/utils.mjs 277 B
packages/shared/dist/transcription-errors.cjs 951 B
packages/shared/dist/transcription-errors.mjs 944 B
packages/shared/dist/utils/clipboard.cjs 407 B
packages/shared/dist/utils/clipboard.mjs 405 B
packages/shared/dist/utils/conditions.cjs 540 B
packages/shared/dist/utils/conditions.mjs 536 B
packages/shared/dist/utils/console-styling.cjs 1.23 kB
packages/shared/dist/utils/console-styling.mjs 1.21 kB
packages/shared/dist/utils/errors.cjs 4.51 kB
packages/shared/dist/utils/errors.mjs 4.41 kB
packages/shared/dist/utils/index.cjs 1.45 kB
packages/shared/dist/utils/index.mjs 1.77 kB
packages/shared/dist/utils/inspector-learning.cjs 2.38 kB
packages/shared/dist/utils/inspector-learning.mjs 2.38 kB
packages/shared/dist/utils/inspector-metadata.cjs 1.46 kB
packages/shared/dist/utils/inspector-metadata.mjs 1.45 kB
packages/shared/dist/utils/inspector-visibility.cjs 285 B
packages/shared/dist/utils/inspector-visibility.mjs 282 B
packages/shared/dist/utils/json-schema.cjs 1.97 kB
packages/shared/dist/utils/json-schema.mjs 1.91 kB
packages/shared/dist/utils/random-id.cjs 618 B
packages/shared/dist/utils/random-id.mjs 559 B
packages/shared/dist/utils/requests.cjs 706 B
packages/shared/dist/utils/requests.mjs 704 B
packages/shared/dist/utils/row-render-keys.cjs 3.38 kB
packages/shared/dist/utils/row-render-keys.mjs 3.36 kB
packages/shared/dist/utils/types.cjs 161 B
packages/shared/dist/utils/types.mjs 160 B
packages/voice/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/voice/dist/index.cjs 175 B
packages/voice/dist/index.mjs 95 B
packages/voice/dist/index.umd.js 1.5 kB
packages/voice/dist/transcription/transcription-service-openai.cjs 495 B
packages/voice/dist/transcription/transcription-service-openai.mjs 434 B
packages/web-inspector/dist/assets/inspector-logo-kite.cjs 2.36 kB
packages/web-inspector/dist/assets/inspector-logo-kite.mjs 2.3 kB
packages/web-inspector/dist/assets/inspector-logo.cjs 4.32 kB
packages/web-inspector/dist/assets/inspector-logo.mjs 4.23 kB
packages/web-inspector/dist/components/learning-view.cjs 9.47 kB
packages/web-inspector/dist/components/learning-view.mjs 9.47 kB
packages/web-inspector/dist/index.cjs 130 kB
packages/web-inspector/dist/index.mjs 130 kB
packages/web-inspector/dist/index.umd.js 194 kB
packages/web-inspector/dist/lib/context-helpers.cjs 866 B
packages/web-inspector/dist/lib/context-helpers.mjs 835 B
packages/web-inspector/dist/lib/home-briefing.cjs 2.8 kB
packages/web-inspector/dist/lib/home-briefing.mjs 2.79 kB
packages/web-inspector/dist/lib/inspector-learning.cjs 754 B
packages/web-inspector/dist/lib/inspector-learning.mjs 732 B
packages/web-inspector/dist/lib/inspector-metadata.cjs 760 B
packages/web-inspector/dist/lib/inspector-metadata.mjs 750 B
packages/web-inspector/dist/lib/inspector-nav.cjs 668 B
packages/web-inspector/dist/lib/inspector-nav.mjs 649 B
packages/web-inspector/dist/lib/learning-setup.cjs 1.12 kB
packages/web-inspector/dist/lib/learning-setup.mjs 1.09 kB
packages/web-inspector/dist/lib/notification-loader.cjs 792 B
packages/web-inspector/dist/lib/notification-loader.mjs 786 B
packages/web-inspector/dist/lib/notifications.cjs 2.39 kB
packages/web-inspector/dist/lib/notifications.mjs 2.37 kB
packages/web-inspector/dist/lib/onboarding-prompt.cjs 2.38 kB
packages/web-inspector/dist/lib/onboarding-prompt.mjs 2.37 kB
packages/web-inspector/dist/lib/persistence.cjs 3.45 kB
packages/web-inspector/dist/lib/persistence.mjs 3.36 kB
packages/web-inspector/dist/lib/pop-out.cjs 1.07 kB
packages/web-inspector/dist/lib/pop-out.mjs 1.05 kB
packages/web-inspector/dist/lib/telemetry.cjs 5.59 kB
packages/web-inspector/dist/lib/telemetry.mjs 5.38 kB
packages/web-inspector/dist/lib/thread-selection.cjs 566 B
packages/web-inspector/dist/lib/thread-selection.mjs 563 B
packages/web-inspector/dist/package.cjs 181 B
packages/web-inspector/dist/package.mjs 116 B
packages/web-inspector/dist/styles/generated.cjs 20.1 kB
packages/web-inspector/dist/styles/generated.mjs 20 kB
packages/web-inspector/dist/styles/notification-article.cjs 1.44 kB
packages/web-inspector/dist/styles/notification-article.mjs 1.44 kB

compressed-size-action

@marthakelly marthakelly changed the title test(learning): add synthetic Trajectory contract smoke test feat(learning): connect Trajectories through Runtime and Gateway Oct 1, 2026
@marthakelly
marthakelly marked this pull request as ready for review October 1, 2026 20:09
@BenTaylorDev

Copy link
Copy Markdown
Contributor

Thread links: the fields the backend reads, for when linking moves out of deferred

The authenticated path in this PR sends no Thread context, and one test checks that no threadId reaches the wire. That matches "Thread linking deferred". So the backend in CopilotKit/Intelligence#1569 makes no Trajectory–Thread links for this client today.

When you add linking, the gateway reads these fields. They match what #7556's open-Thread registry and click enrichment already produce:

  • thread.linked event, value { threadId, reason }. reason is start, open, or switch, and any other value is stored as linked. It makes a strong link.
  • click with threadId and a non-empty messageId: a click inside a chat message. It makes a strong link with reason message.
  • click with threadId only: exactly one Thread was open. It makes a weak link with reason open-thread.
  • click with threadId: null, with or without threadAmbiguity: no link.
  • threadSource is ignored.

A link is made only to a live Thread in the same project whose owner is the same app user as the join token. Any other threadId is stored with the event and makes no link. A failed link never rejects an event. A later strong link upgrades a weak one.

The contract is in docs/thread-realtime-contract.md, section "Trajectory capture → Thread links", on the #1569 branch.

(Ben, drafted with Claude.)

@AlemTuzlak
AlemTuzlak merged commit 9cb62a9 into alem/pe-471-pair-on-browser-interaction-capture-experiments Oct 2, 2026
45 checks passed
@AlemTuzlak
AlemTuzlak deleted the codex/trajectory-contract-smoke branch October 2, 2026 09:11
tylerslaton added a commit that referenced this pull request Oct 2, 2026
Try it: `pnpm --filter demo exec next dev --turbopack -p 3471`, then
open `http://localhost:3471/learning` and click through a deal.

This PR adds Trajectory capture to CopilotKit. `@copilotkit/learning`
records browser activity (clicks, form edits, page changes, and network
requests) as AG-UI `CUSTOM` events. With CopilotKit, Core authenticates
through Runtime and sends the events to the Intelligence Realtime
Gateway. Apps that do not pass `learning` behave exactly as before. This
PR now also contains #7566 (Runtime authentication and Gateway
delivery), which was stacked on it.

## What does this PR do?

- **`@copilotkit/learning`** (new, about 5.8 KB gzip): the collector.
Capture follows the approved October 9 self-hosted scope: maximum
resolution, with no filtering or categorization. Two kinds of values
never leave the browser: password values and credential headers become
`[redacted]`.
- **Runtime:** a `trajectory/connect` route (REST and single endpoint).
It resolves the user with `identifyUser` and requests a single-use join
token from Intelligence. The project key stays on the server.
- **Core:**
- A `learning` config, plus `startTrajectory()`, `stopTrajectory()`,
`emitTrajectoryEvent()`, and `registerOpenThread()`.
- Batches go over Phoenix with sequence numbers, receipts, the Gateway
limits, and `dropped` counts. A failed batch is never resent.
- A custom `sink` keeps the standalone mode, which also adds Thread,
message, and tool context.
- **React:** a `learning` prop on `CopilotKitProvider`, with automatic
or manual start and cleanup on unmount. The `data-tool-call-id` wrapper
renders only while capture is active.
- **Demo and docs:** the `/learning` pages in `examples/v2/react/demo`,
and three Intelligence docs pages.

## Related PRs and Issues

- Linear: [PE-471](https://linear.app/copilotkit/issue/PE-471),
[PE-506](https://linear.app/copilotkit/issue/PE-506)
- Includes #7566. Backend: CopilotKit/Intelligence#1569 (ingestion) and
#1580 (read APIs).

## Checklist

- [ ] 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
- [ ] "Allow edits by maintainers" is checked (lets us help iterate on
your PR directly — faster turnaround for everyone)

## Changes in the latest push

- Merged #7566 and `main`.
- **Fix:** with `"auto"` transport (the default), capture started before
`/info` finished and sent a single-endpoint request to REST runtimes,
which failed. Core now waits for transport detection.
- **CodeRabbit:**
  - Password values and credential headers are redacted.
  - `data-copilotkit-ignore` now works through shadow roots.
- Click text is capped at 1,000 characters, so a large container cannot
exceed the 16 KiB event limit.
  - Reopening an in-flight XHR no longer reports the old request.

## Existing users (PE-506)

With no `learning` prop or config:

- No listeners, patches, timers, sockets, or Core or agent subscriptions
are installed. The tests `installs nothing without the learning prop`
and `warns and captures nothing without the learning option` cover this.
- The tool-call DOM is unchanged, because the wrapper renders only
during capture.
- Runtime routes are unchanged. `trajectory/connect` is new and returns
clear errors outside Intelligence.
- `fetch`, XHR, and streaming responses are untouched.

## Testing

Commands run (Windows, local):

- `pnpm nx run-many --targets=test,check-types
--projects=@copilotkit/learning,@copilotkit/core,@copilotkit/react-core,@copilotkit/runtime`:
all pass. learning 77 tests, core 1,140, react-core 1,786 (plus 54 node
checks), runtime 2,803. Types pass in all four.
- `node packages/learning/scripts/check-size.mjs`: 5,783 bytes gzip
(budget 6,144).
- `oxfmt` and `oxlint` on the changed files: 0 errors.
- Skipped: the local lefthook hooks (heavy, and flaky on this machine).
CI runs the full checks.

Manual test:

1. Run the demo, then open `/learning`.
2. Click **Open** on a deal, send a chat message, and click **Approve**
in the approval prompt.
3. Open **Captured events**. Check the click, page, network, and agent
events.

How this PR makes testing easy: unit tests in all four packages, a
real-Phoenix boundary test in Core, and the demo pages.

## Risk / rollback

Low for existing users, because nothing runs without `learning`. Core
now bundles the collector, so `@copilotkit/core` grows. Rollback: revert
this PR.

Open items, not in this PR:

- In the authenticated mode, events carry no Thread context yet. The
backend already supports Thread links. This was deferred on purpose, and
the decision is tracked in PE-504.
- No real round trip against Intelligence Dev yet. That is PE-507.

## Public API change

**Before**

```tsx
<CopilotKitProvider runtimeUrl="/api/copilotkit">{children}</CopilotKitProvider>
```

**After**

```tsx
<CopilotKitProvider runtimeUrl="/api/copilotkit" learning={{ trajectoryId }}>
  {children}
</CopilotKitProvider>;

// Or start capture yourself:
const result = await copilotkit.startTrajectory(); // { status: "started", trajectoryId }
copilotkit.emitTrajectoryEvent("deal.approved", { dealId: "deal-1" });
copilotkit.stopTrajectory();
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added learning and interaction capture for page navigation, clicks,
form input, network activity, agent messages, and tool interactions,
with credential redaction.
* Added controls to start and stop trajectories, send custom events,
filter captured data, and deliver event batches to custom endpoints.
* Added authenticated trajectory capture through the CopilotKit
provider.
* Added a demo for reviewing captured events and trying deal approval
flows.
* **Documentation**
* Added guides for interaction capture, standalone collection, captured
data, and setup.
* **Bug Fixes**
* Preserved message and tool-call identifiers in custom chat layouts for
interaction attribution.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Naz-Ovh pushed a commit to 0x-fork/CopilotKit that referenced this pull request Oct 12, 2026
…opilotKit#7601)

Application servers can assign browser Trajectories to existing Learning
Spaces without a Thread. `getTrajectoryLearningContainerIds` selects
Spaces from the verified application user and Trajectory ID;
browser-supplied assignments remain ignored.

The Runtime validates and deduplicates IDs, logs selector errors, and
returns a sanitized `LEARNING_CONTAINER_SELECTION_FAILED` HTTP 500. Core
treats that code as terminal. Selectors have a five-second deadline and
an optional second `AbortSignal` argument. Tests cover invalid results,
cancellation, timeout, and both Runtime route modes.

Each connect adds memberships. `[]` adds none; `null` or `undefined`
omits the assignment field. None removes existing memberships. A missing
Space stops capture with `LEARNING_CONTAINER_NOT_FOUND`. Usage docs
state these rules and describe only the user context the callback
receives.

**Companion:** [Intelligence
CopilotKit#1621](https://github.com/CopilotKit/Intelligence/pull/1621) adds native
Trajectory analysis and evidence viewing. Both PRs target `main`; CopilotKit#7556
and CopilotKit#7566 are already merged. Thread linking and chat events remain
deferred on this connection path.

Validation on this revision:
- `pnpm nx test @copilotkit/runtime --excludeTaskDependencies -- <four
Trajectory/selector test files>`: 96 passed. Focused Core connection
suite: 52 passed.
- `pnpm nx run-many -t check-types -p @copilotkit/runtime
@copilotkit/core --excludeTaskDependencies` passed; matching `build`
passed.
- Uncached `publint`, `attw`, and `check-dts` passed for both packages.
Public API manifest is current.
- Normal pre-commit ran `test,publint,attw` for 25 affected projects and
passed, including all 2,827 Runtime tests.
- Previously verified local flow: real browser activity → server
assignment → stored events → automatic model run → one saved insight
with 19 event references. Expense records were demo data.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Authenticated browser Trajectories can now be assigned to existing
Learning Spaces using a server-side selector, without requiring a Thread
or agent conversation.
* Assignments are validated and deduplicated, with a five-second limit.
Reconnecting adds memberships without removing existing ones.
* **Bug Fixes**
* Assignment failures no longer prevent Trajectory capture from
connecting; missing Spaces trigger a warning, while selector errors are
logged.
* **Documentation**
* Clarified server-side assignment setup and the limits of
browser-provided Learning Space IDs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants