feat: session sharing — cross-user conversation transfer via /share-session#327
Open
HuaweiREN wants to merge 16 commits into
Open
feat: session sharing — cross-user conversation transfer via /share-session#327HuaweiREN wants to merge 16 commits into
HuaweiREN wants to merge 16 commits into
Conversation
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * feat(cluster): add federated identity foundation --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * feat(memory): add namespace scoped instance token --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * feat(skills): track owner metadata and hashes --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * feat(cluster): bootstrap peers from cluster url --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * docs: document federated memory and skill hub --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * fix(cli): use instance memory token --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* feat(installer): allow custom install directory via --dir / -Dir flag install.sh and install.ps1 previously hardcoded the install path to $HOME/metabot. Add a CLI flag (and matching PowerShell parameter) plus an interactive prompt so users can install MetaBot anywhere. - Priority: --dir / -Dir > METABOT_HOME env var > prompt > default. - Tilde expansion + absolute-path validation; refuses to clobber $HOME / system roots. - Persists METABOT_HOME to ~/.bashrc / ~/.zshrc (Linux/macOS) or user-level env (Windows) when non-default, so the mm/mb/metabot CLIs can locate the install in new shells. * fix(codex): show model metadata in cards * fix(codex): mirror skills and avoid bwrap sandbox * fix(codex): tolerate agents deployment failures * fix(codex): install bundled skills when user cache is empty * docs: explain Codex skill migration * Cache peer Skill Hub artifacts --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* Mirror peer MetaMemory documents * Add stable bot memory namespaces --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
* Mirror peer MetaMemory documents * Add stable bot memory namespaces * Update lark CLI via metabot update --------- Co-authored-by: Flood Sung <floodsung@xvirobotics.ai>
When a bot opts in via `perUserContext: true`, conversation state (session, persistent executor, message queue, running task) is keyed by `chatId:userId` instead of `chatId`. This gives each Feishu member in a group chat their own Claude thread. Changes: - composeScopeKey / chatIdFromScopeKey / userIdFromScopeKey helpers - SessionManager, ExecutorRegistry: opaque scopeKey parameter - MessageBridge: thread scopeKey through all conversation-state Maps - CommandHandler: /reset, /stop, /status, /model scoped by caller - ExecutorRoutes: adjusted for scopeKey - Config: perUserContext bot flag wired through JSON loader - Tests: compose-key (8 tests) + per-user-context (12 tests) - Bump default executor pool cap 20 -> 50 for per-user multiplier Back-compat: default false/undefined preserves byte-for-byte identical behavior. Existing session JSON files load unchanged.
- Add perUserContext to CLAUDE.md Configuration section - Add perUserContext example to bots.example.json - Enable perUserContext: true for Baymax in bots.json
Thread msg.userId through ApiContext so the Claude executor (and the persistent variant) can mention "The current user's ID is <open_id>" in the system prompt appendix. Groundwork for per-user context keying — the userId is now reliably available on the wire end-to-end.
Implements plan C for cross-user session transfer: - /share-session @user — creates a pending 30-min transfer, generates a share code. Target user can auto-claim by sending any message to the bot, or use /claim <code> explicitly. - /claim <code> — explicitly claim a shared session by code. - mentions now flow through IncomingMessage so @mention resolution works in command handlers. - SessionSharing (new): in-memory store for pending transfers, keyed by userId and shareCode, with TTL cleanup. - Bridge auto-checks pending transfers on every incoming non-command message — if found, links the target scopeKey to the source Claude sessionId before processing. - Also supports /share-session <open_id> for private chats where @mentions are unavailable.
When the user types '@bot /share-session @targetUser', the mentions array includes both the bot and the target. Previously mentions[0] was used which picked up the bot itself. Now the event handler filters out botOpenId before passing mentions through to IncomingMessage.
Previously only mentions[0] was used. Now iterates over all mentions (after bot filtering) and creates a transfer for each. Also added 'i' parameter to map that's unused — removed. Success message now lists all recipients with their codes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
/share-session @userand/claim <code>commands that allow users to transfer their Claude conversation session to other Feishu users, even underperUserContextisolation mode.Depends on PR #324 (perUserContext).
Motivation
When
perUserContext: trueis enabled, each user has an isolated Claude session — great for privacy, but breaks collaborative workflows where context handoff is needed (e.g., developer shift change).Design
/share-session @userB @userC— creates pending transfers with 6-char share codes, 30-min TTL/share-session ou_xxxxxxxxxxxx— private chat fallback via raw open_id/claim <shareCode>— explicit manual claimNew Module:
SessionSharing(src/bridge/session-sharing.ts)In-memory dual-indexed store (by userId + shareCode) with periodic TTL cleanup.
Type Change:
IncomingMessage.mentionsNew optional field carrying raw @mention data. Event handler filters bot own @ before passing upstream.
Behavioral Semantics
/reset/resetBackward Compatibility
mentionsfield optional — Telegram/Web unaffectedFiles Changed
src/bridge/session-sharing.ts(new)src/bridge/command-handler.tssrc/bridge/message-bridge.tssrc/feishu/event-handler.tssrc/types.ts5 files, +462 −2