Skip to content

feat(chat-gateway): private simplemsg send + history gateway routes (BotOS M4) - #16

Open
WuFenG-Hub wants to merge 2 commits into
metaid-developers:mainfrom
WuFenG-Hub:feat/botos-a2a-gateway
Open

feat(chat-gateway): private simplemsg send + history gateway routes (BotOS M4)#16
WuFenG-Hub wants to merge 2 commits into
metaid-developers:mainfrom
WuFenG-Hub:feat/botos-a2a-gateway

Conversation

@WuFenG-Hub

Copy link
Copy Markdown

Summary

BotOS Mega-Phase M4: two local RPC gateway routes that let an external harness
(botos-runner / DSH) act as a MetaBot in private A2A conversations
— the
missing link between the harness and on-chain encrypted messaging.

  1. POST /api/idbots/chat/private-send{ metabot_id, to_global_meta_id, content, reply_pin? }:
    • resolves the bot's wallet mnemonic internally (never appears in any response),
    • resolves the peer's ECDH chat pubkey (local private_chat_messages history → MetaID chain API fallback),
    • encrypts via sendEncryptedSimplemsg and broadcasts a /protocols/simplemsg pin through the existing create-pin path,
    • returns { success, pinId, txids, to }; validation + typed 400s; 64 KB content cap.
  2. POST /api/idbots/chat/private-history — read-only recent messages with a peer (newest last).

Route logic lives in a new Electron-free module (chatGatewayRoutes.ts) with injected deps (same pattern as memoryGatewayRoutes.ts), so it is unit-testable under plain node.

Verification

  • npm run compile:electron — 0 errors.
  • New tests tests/chatGatewayRoutes.test.mjs6/6 pass, including a REAL ECDH encrypt round (mnemonic → shared-secret → encrypted payload) with create-pin capture proving the simplemsg payload shape (to, encrypt: 'ecdh', replyPin, content encrypted — never plaintext, mnemonic never exposed).
  • Related existing suite tests/metaidRpcWalletRoutes.test.mjs16/16 pass (server boot unaffected).
  • npx eslint on changed files — clean; git diff --check clean.

Notes

WuFenG added 2 commits August 15, 2026 01:10
…BotOS M4)

Add POST /api/idbots/chat/private-send and /api/idbots/chat/private-history
to the local RPC gateway, backed by a pure chatGatewayRoutes module:

- private-send: resolves the bot's wallet (mnemonic never exposed), resolves
  the peer's ECDH chat pubkey (local history then MetaID chain API), encrypts
  via sendEncryptedSimplemsg and broadcasts a /protocols/simplemsg pin through
  create-pin. Validation + typed errors; 64KB content cap.
- private-history: read-only recent messages with a peer from
  private_chat_messages (newest last).

Enables an external harness (botos-runner / DSH) to act as the MetaBot in
private A2A conversations. 6/6 new tests (incl. a real ECDH encrypt round with
create-pin capture), compile 0 errors, lint clean.
… chat)

Exposes the group-chat transcript over the gateway so a DSH-side consumer
can observe group conversations (Mega-Phase M4 R-M4.1). New deps hook
listGroupChatMessagesForGateway (groupTaskService wrapper over
GroupTaskStore.listGroupChatMessages — the same reader the UI uses; no
wallet, no chain write). Route validates group_id + limits (default 50,
cap 200) with optional before_id paging. 4 new tests; compile 0 errors,
lint clean, chat-gateway suite 10/10.
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