Skip to content

feat: integrate MiMo Claw agent provider - #865

Open
feihu1991 wants to merge 1 commit into
Chevey339:masterfrom
feihu1991:feat/mimo-claw-integration
Open

feat: integrate MiMo Claw agent provider#865
feihu1991 wants to merge 1 commit into
Chevey339:masterfrom
feihu1991:feat/mimo-claw-integration

Conversation

@feihu1991

Copy link
Copy Markdown

MiMo Claw 集成

将小米 MiMo Claw 的完整 Agent 能力接入 Kelivo。

新增文件

  • lib/core/services/mimo_claw/gateway.dart - WebSocket JSON-RPC 客户端
  • lib/core/services/mimo_claw/auth.dart - 小米 SSO 登录服务
  • lib/core/services/mimo_claw/provider.dart - ChangeNotifier Provider
  • lib/ui/screens/mimo_claw_login_page.dart - WebView 登录页
  • lib/ui/screens/mimo_claw_settings_page.dart - 设置页面

功能

  • 小米账号 SSO 登录
  • WebSocket 实时连接
  • 完整 Agent 能力(工具调用、文件操作)
  • 会话管理
  • 流式响应

使用方式

设置 → MiMo Claw → 登录 → 即可使用

- Add WebSocket JSON-RPC gateway client (gateway.dart)
- Add Xiaomi SSO auth service (auth.dart)
- Add ChangeNotifier provider (provider.dart)
- Add WebView login page (mimo_claw_login_page.dart)
- Add settings page (mimo_claw_settings_page.dart)
- Register MiMoClawProvider in main.dart
- Add MiMo Claw entry to settings page
- Add web_socket_channel dependency

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f330e4448e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

_wsSubscription?.cancel();
_ws?.sink.close(1000, '用户断开');
_ws = null;
_connectionReady?.completeError(Exception('连接已断开'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid completing the ready completer twice

After a successful handshake, _connectionReady has already been completed in _doConnect, but it remains non-null. Any later normal disconnect path, such as pressing logout, reconnecting, or disposing the provider after login, calls completeError on the same completed completer and throws Bad state: Future already completed, so the disconnect action can crash instead of cleaning up.

Useful? React with 👍 / 👎.

Comment on lines +74 to +76
_cookies = cookies;
_isLoggedIn = true;
notifyListeners();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Roll back login state when gateway connection fails

When cookie validation succeeds but _gateway.connect fails because the WS ticket/handshake/network is unavailable, completeLogin returns false from the catch while leaving _cookies and _isLoggedIn set and listeners already notified. In that failure scenario the settings UI will think the account is logged in even though the gateway never connected, hiding the login flow until the user manually logs out.

Useful? React with 👍 / 👎.

Comment on lines +121 to +124
onTap: () async {
await widget.provider.completeLogin(
widget.provider.isLoggedIn ? '' : '',
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reuse the saved cookies for reconnect

On the logged-in settings screen, tapping “重新连接” always calls completeLogin with an empty cookie string because both sides of the ternary are ''. Since completeLogin validates that cookie before reconnecting, this action cannot restore a dropped MiMo Claw connection; it should use the stored provider cookies instead.

Useful? React with 👍 / 👎.

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