Skip to content

feat: run chat fully offline with CopilotKit Intelligence optional - #94

Open
matthewhand wants to merge 1 commit into
CopilotKit:mainfrom
matthewhand:pr/offline-chat
Open

matthewhand wants to merge 1 commit into
CopilotKit:mainfrom
matthewhand:pr/offline-chat

Conversation

@matthewhand

Copy link
Copy Markdown

Summary

CopilotKit Intelligence is no longer a hard requirement. Three runtime modes now exist:

Mode Trigger Threads/history Realtime
Cloud CPK_INTELLIGENCE_API_KEY set Intelligence cloud managed realtime WS (unchanged)
Self-hosted INTELLIGENCE_API_URL + INTELLIGENCE_WS_URL (must be set together) your Intelligence endpoint your WS
Local no key, no URLs local thread endpoints, persisted by DurableAgentRunner in-process SSE

Without any Intelligence configuration the runtime falls back to its official SSE mode: local /threads list/messages/state endpoints, with a new DurableAgentRunner persisting threads, messages, events and state to the store the app already uses — snapshotting before and after each run, merging by runId and message id — so conversations survive restarts.

The client needs no changes: chat.tsx already branches on richThreads, and /api/main-thread serves a stable local id when Intelligence is absent.

Notes

  • assertApiDeploymentConfig now validates the shim contract (URLs paired) instead of requiring the cloud key; intelligenceConfigured() is the single switch. The intelligenceKeyRequiredMessage export is kept for the demo entry, which still requires a key by design.
  • Cherry-picked with the runtime identity kept as upstream's auth.owner pattern (a deployment-specific intelligenceUserId refactor was deliberately excluded from this PR).

Testing

  • Full suite green (277/277) at current main; tsc --noEmit clean.
  • Live-verified both directions on a real deployment: local mode boots with no cloud key, streams a real browser round-trip with zero cloud calls, and rehydrates the conversation from the local store after an API restart; cloud mode still reports mode=intelligence and streams as before.

Adapted from sunshaoan0808/openmuse (MIT), planB + planA commits, with attribution.

🤖 Generated with Codebuff

CopilotKit Intelligence is no longer required. With a cloud key (or a
self-hosted Intelligence shim via INTELLIGENCE_API_URL/WS_URL, which must
be set together) the runtime behaves as before: cloud threads and the
managed realtime WS. Without any key it falls back to the official SSE
runtime mode with local thread endpoints, and a new DurableAgentRunner
persists threads, messages, events and state to the existing PGlite
store — snapshotting before and after each run and merging by runId and
message id — so conversations survive restarts.

Verified live in both directions: local mode boots with no cloud key,
round-trips a real browser chat with zero cloud calls and rehydrates the
conversation from PGlite after an API restart; cloud mode still reports
mode=intelligence, hydrates the main thread and streams round-trips.

Adapted from sunshaoan0808/openmuse (MIT) planB + planA commits.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

This branch has not been deployed

No deployments
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.

1 participant