Skip to content

feat(chat): add chat runtime and MCP integration - #412

Open
SonyLeo wants to merge 4 commits into
opentiny:developfrom
SonyLeo:feat/chat-pr2-runtime
Open

feat(chat): add chat runtime and MCP integration#412
SonyLeo wants to merge 4 commits into
opentiny:developfrom
SonyLeo:feat/chat-pr2-runtime

Conversation

@SonyLeo

@SonyLeo SonyLeo commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

背景

本 PR 在 Chat UI 包的基础上补充 Chat Runtime,实现模型请求、响应处理、MCP 工具调用以及 Kit Runtime 适配能力。

本 PR 基于 #411 合入

关联关系

robot/develop
└── PR1: feat/chat-pr1-ui-runtime-boundary
    └── PR2: feat/chat-pr2-runtime

PR1 负责 Chat 包、UI 组件和构建边界;本 PR 仅补充 Runtime 实现。

变更内容

Runtime 入口与公共导出

新增并导出:

  • useLocalChatRuntime
  • useKitChatRuntime
  • Chat Runtime 相关类型
  • Provider 配置与模型类型
  • MCP Server 配置类型
  • Provider Model Runtime、Request Plugin、Response Provider
  • Provider 模型预设解析能力

Local Runtime

新增本地 Chat Runtime,支持:

  • 本地模型请求生命周期管理
  • 请求状态与响应状态同步
  • 会话运行配置处理
  • 请求取消与错误处理
  • MCP Adapter 注入
  • Runtime Action 执行

Kit Runtime

新增基于 @opentiny/tiny-robot-kit 的 Chat Runtime 适配:

  • 将 Kit 的请求能力适配为 Chat Runtime 协议
  • 同步 Kit 的消息、请求和处理状态
  • 支持暂停、继续、终止等运行时操作
  • 将 Kit 的响应事件转换为 Chat 可消费的数据结构

Provider Runtime

新增 Provider 请求处理链:

  • Provider 模型配置解析
  • 模型能力和预设配置解析
  • 请求参数组装
  • 请求插件
  • 响应 Provider
  • 流式响应处理
  • 请求错误和完成状态处理

MCP Runtime

新增 MCP 能力:

  • 默认 MCP Adapter
  • MCP Server 配置类型
  • MCP Server 连接与工具获取
  • MCP 工具调用
  • 工具调用结果处理
  • MCP 工具状态同步

运行配置

新增 Chat Runtime 默认配置和运行配置解析:

  • 默认请求配置
  • Provider 配置
  • MCP 配置
  • Reasoning 配置
  • Runtime Context 注入
  • Chat Run Config 管理

用于同步 Kit Runtime 的暂停状态。

文件范围

本 PR 相对 PR1 变更:

  • 16 个源码文件
  • 新增约 1,350 行代码
  • 主要集中在 packages/chat/src/runtime
  • 修改 packages/chat/src/index.ts
  • 修改 packages/chat/src/types/base.ts

构建与验证

已验证:

pnpm --filter @opentiny/tiny-robot-chat type-check
pnpm --filter @opentiny/tiny-robot-chat build
pnpm build

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2cebc85c-5b72-41c3-9a9d-0bf34f9638a2

📥 Commits

Reviewing files that changed from the base of the PR and between ed873bb and 2350a55.

⛔ Files ignored due to path filters (1)
  • packages/chat/src/assets/modelcontextprotocol.png is excluded by !**/*.png
📒 Files selected for processing (50)
  • package.json
  • packages/chat/package.json
  • packages/chat/src/Chat.vue
  • packages/chat/src/ChatUI.vue
  • packages/chat/src/composables/useChatAsideState.ts
  • packages/chat/src/composables/useChatDraft.ts
  • packages/chat/src/composables/useChatHistoryItems.ts
  • packages/chat/src/composables/useChatRuntimeAdapter.ts
  • packages/chat/src/index.ts
  • packages/chat/src/runtime/defaults.ts
  • packages/chat/src/runtime/mcp/createDefaultMcpAdapter.ts
  • packages/chat/src/runtime/mcp/types.ts
  • packages/chat/src/runtime/plugins/mcpToolPlugin.ts
  • packages/chat/src/runtime/plugins/runConfigContextPlugin.ts
  • packages/chat/src/runtime/provider/index.ts
  • packages/chat/src/runtime/provider/modelRuntime.ts
  • packages/chat/src/runtime/provider/presets.ts
  • packages/chat/src/runtime/provider/requestPlugin.ts
  • packages/chat/src/runtime/provider/responseProvider.ts
  • packages/chat/src/runtime/provider/types.ts
  • packages/chat/src/runtime/runConfig.ts
  • packages/chat/src/runtime/useKitChatRuntime.ts
  • packages/chat/src/runtime/useLocalChatRuntime.ts
  • packages/chat/src/types/base.ts
  • packages/chat/src/types/commands.ts
  • packages/chat/src/types/index.ts
  • packages/chat/src/types/runtime.ts
  • packages/chat/src/types/ui/data.ts
  • packages/chat/src/types/ui/events.ts
  • packages/chat/src/types/ui/index.ts
  • packages/chat/src/types/ui/options.ts
  • packages/chat/src/types/ui/slots.ts
  • packages/chat/src/ui/composer/ChatComposer.vue
  • packages/chat/src/ui/composer/ChatComposerHost.vue
  • packages/chat/src/ui/composer/MCPSelector.vue
  • packages/chat/src/ui/composer/ModelFeatures.vue
  • packages/chat/src/ui/composer/ModelSelector.vue
  • packages/chat/src/ui/defaults.ts
  • packages/chat/src/ui/formatRequestError.ts
  • packages/chat/src/ui/layout/ChatHeader.vue
  • packages/chat/src/ui/layout/ChatLeftAside.vue
  • packages/chat/src/ui/layout/ChatMcpPanel.vue
  • packages/chat/src/ui/layout/ChatRightAside.vue
  • packages/chat/src/ui/messages/ChatMessages.vue
  • packages/chat/src/ui/messages/ScrollToBottom.vue
  • packages/chat/src/ui/resolveData.ts
  • packages/chat/src/ui/resolveOptions.ts
  • packages/chat/src/vite-env.d.ts
  • packages/chat/tsconfig.json
  • packages/chat/vite.config.ts

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.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

✅ Preview build completed successfully!

Click the image above to preview.
Preview will be automatically removed when this PR is closed.

@github-actions

Copy link
Copy Markdown
Contributor

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