Repository navigation
feat(bots): choose which of my devices can reach each bot - #1118
Conversation
|
About: a new Devices row under Runs on, All my devices (every existing bot keeps this): Its three choices: Chosen devices with Tablet unticked: Tablet now gets the same answer as for a bot that does not exist: Tablet ticked: it reaches the bot again: Settings, Devices: Bots on this computer under each device, on by default (the Older than this device row is the scripted test device reporting 0.0.0): Switched off: Tablet reaches no bot here: |
|
What the second device (Tablet, a development home joined over Net) saw while the owner changed the controls, asking every 3 seconds: In order: every device; Chosen devices without Tablet; Tablet ticked again; Bots on this computer off for Tablet. |
…ces reach a bot A saved result asked for by request id is checked against the bot it named, and a device that left the account or is blocked here has its queued messages withdrawn.
|
One review pass found two gaps, fixed in the last commits before merge. A saved result of an earlier bot call, asked for by request id, is now checked against the bot it named, and is refused when that is no longer known and the device is held from any bot. A device that left the account or is blocked on this computer has its queued messages withdrawn. A new case in |






Problem
Any device linked to the owner's account that has read or chat access could list every personal bot on a computer, read its chat and memory, message it, stop its work and answer its cards; with write access it could create and change bots. A shared laptop with the account signed in reached every bot, including one that can shut down the owner's servers. What bots may do on a computer was already limited (What bots may do here); which devices may reach a bot was not.
Change
Two controls, both kept and enforced on the bot's own computer:
<profile>/bots/device-access.json(BotDeviceAccessStore), not inbots.db, so no database version moves.botscolumn onnet_node_policy, added the way the editor switch was (default on, no version bump); alsomousse-cli bridge limits <node> --bots on|off.To a device that is left out, the bot does not exist. Every bot method a device can call goes through one wrapper in
RemoteBots.ts(remoteBotMethods'smethod), which checks the device's switch and the bot's choice before the call is admitted and again as it runs. A method added to the table later is held to it without any extra code. A hidden bot gets word for word the same answer as a missing one (stream_unknown). A device whose switch is off gets the same refusal as when Share bots is off (forbidden,setting_off), the same for every bot id. The one check iscreateBotReachinsrc/mms/bridge/remote/botReach.ts.Every other path by which a bot shows on another device, and how it is closed:
bots.get,bots.chat.list,bots.chat.attachment,bots.memory.list,bots.chat.send,bots.chat.stop,bots.work.stop,bots.chat.markRead,bots.asks.answer,bots.personal.pause,bots.personal.resume,bots.create,bots.update,bots.reminders.cancel,bots.schedules.remove,bots.permissions.revoke,bots.memory.forget)bridge.lists.open): bot list, unread counts, last message, live chip, and the notifications the phone makes from themmousse:lists:<node>), with only the bots it reaches. Only that device may read the stream (ThreadStreamAdapter.boundReader, checked inNodeStreamAuthority.canRead), so a guessed or leaked stream id reads nothing. They push again as soon as a choice or switch changes.botOwned); unchanged.startedByBot: { botId: "", name: "a bot" }and no launcher (withHiddenBots), and the app shows "Started by a bot". A stream any device may read names the bot only when every device reaches it.storage.usagefrom a phone)jobSharedWithComputers); unchanged.bots.*,bridge.*andsettings.*never route; unchanged.Who can change it. Only this computer's own window and its command line.
bots.devices.getandbots.devices.setare local methods that refuse a call through Bridge or from any client but the app window and the CLI. They are not in a device's table and never route.bridge.policywas already local. A device'sbots.updatetakes only a name and a look. A device'sbots.createkeeps the new bot within that device's reach and changes no other bot. A request id that names a bot made earlier is answered only if the device reaches that bot. No bot tool, agent tool or MCP tool changes either control.Already under way. A device taken off a bot, or switched off, gets nothing at its next call, and its lists drop the bot at once. A message it sent that is still queued is not delivered: its chat turn is cancelled and the chat says "Not delivered: the device it came from can no longer reach me." Its cards are no longer answerable from it. Work the bot is doing, and a turn already running, carry on, because they are the owner's.
Fails closed. A bot with no stored choice reaches every device. A choice or file that can't be read means only this computer; About says so in the row's tooltip, and the next change puts the unreadable file aside. A device removed from the account leaves every bot's list. A device switch reads as off for any stored value but 1.
Versions. An update keeps every bot on every device and every device's switch on. A newer device talking to an older home computer sees what it always did: the choice lives and is enforced only on the home computer, so nothing asks an older one to enforce it. An older phone talking to a newer home computer is held like any other device; it opens its lists as before and gets its own stream back. An older build on the home computer itself (a downgrade) ignores the file and the column, so every device reaches every bot again while it runs.
docs/bots.mdhas a new section, "Two layers", that puts this beside What bots may do here and says what it does not do.docs/GLOSSARY.mdhas the two terms.Teammate work. #869 rewrites the Devices page. The switch here is its own component (
DeviceBotsRow), so #869 only needs one added line where it renders a device's detail. #868 (Teams access decision) and #871 (message authors) touch routed calls between people, not a person's own devices; there is no overlap. Lines touched outside the bridge, the stored choice, the two settings surfaces and the docs:BotOwnerTurngainsnode(definition.ts); two lines inBotEngine.tskeep it on a queued chat turn;BotChatService.tspasses it on and gainswithdrawQueued;MmsProfileServices.tsholds the store;MousseMainService.tsregisters the two local methods;registerGuiIpc.tsandplatform.tsallow them for the window;ThreadStartedByBar.tsxshows "Started by a bot". Nothing insrc/mms/run/mcp/appTools/,botAuthority.tsorsrc/mms/harness/(#1101, #1097). Nobots.dbmigration (#1108 takes v7). No bot chat view files (#1104).How to review
src/shared/bots/personal/deviceAccess.tsandsrc/mms/bots/definitions/BotDeviceAccessStore.ts: the choice and how it is stored and read.src/mms/bridge/remote/botReach.ts: the one test, and the "Started by" scrub.src/mms/bridge/remote/RemoteBots.ts: the wrapper. This is where the risk is.src/mms/bridge/BridgeProfileService.ts,MmsListsSource.ts,ThreadStreamAdapter.ts,nodeAuthority.ts: per-device lists and their reader binding.MmsBackend.ts,MmsThreadSource.ts,OwnerRoutes.ts,privateSources.ts: thread results and disk usage.src/mms/bots/deviceMethods.ts,nodePolicy.ts,database.ts,NetService.ts: who may change what.BotDevices.tsx,DeviceBotsRow.tsx,ThreadStartedByBar.tsx.Verification
Tier 5 (permissions and networking). Teammate review is needed before merge.
Named tests, run from PowerShell on Windows at
5bb72bbfd:tests/net/bridge/remote/botDeviceAccess.test.ts(15). It runs every device method against a bot the device reaches, a bot it may not reach and a bot that does not exist, and checks that the last two answer the same, before admission and as the call runs. It also covers: the device switch for every method and for the lists; a device on one bot's list reaching another bot through the first bot's ids; lists per device and the shared lists; a queued message withdrawn while running work carries on; cards; every way to change the choice from a device refused (table, routing,bots.updateandbots.createkeys, the local methods called through Bridge or from other clients); a device'sbots.create; storage after an update, unreadable files and entries, and removed devices; "Started by"; disk usage. Removing the reach check in the wrapper makes the method table and the create test fail.tests/net/bridge/remote/botDeviceSessions.test.ts(1). Over real Net sessions, a full owner profile with its Bridge and two joined phones: the left-out phone gets the missing-bot answer and no call reaches the bot; the switched-off phone is refused; each phone's lists stream is its own, and the other phone's subscription to it is refused withforbidden.tests/renderer/botDeviceControls.test.ts(5), mounting About and the real Devices page;tests/net/store/nodePolicyMigration.test.ts(+2, the column on an older database and an older build's writes).tests/net/bridge/nodePolicy.test.ts(the defaults list now hasbots: true),tests/renderer/botAboutPanel.test.ts(Runs on lists Devices),tests/renderer/botThreadsUi.test.ts(+1, "Started by a bot").bots,lists,privateLists,remoteQuestionsAndDeltas,composer,boundedStreams(bridge/remote);privateAccess,owner,streams,release,privateThreads,deviceActivity,editorAsk,table,ids(bridge/routed);net(cli),privateThreads,threadListPushes,botThreads,botThreadsDaemon,botChat,botsProtocolV2,browserViewAccess,botLanes,botNoModelNames,deviceAccessRows,netDevicesRefresh,newBotDialog,botsSection,netDevices. 304 + 182 tests passed in all.masterat71f2792alike (Windows folder locks and no SIGKILL exit signal), not from this change: three cases oftests/net/bridge/remote/remote.test.ts("keeps an accepted actual MMS turn running…", "records an actual child SIGKILL…", "installs a display snapshot larger…").npm run typecheckpasses.stream_unknown, the same as for a bot that does not exist. Ticked again: it saw the bot. Bots on this computer off for Tablet:forbiddenfor both. Screenshots below.Not checked: the phone app itself (it is not in this repository). That an older phone simply uses the new lists stream that
bridge.lists.openreturns is inferred from the protocol and was not seen on a phone. Not checked on macOS. A bot thread already in the trash may still be named in disk usage.Security review, as the left-out device. What I tried, and the result:
forbidden(session test). An attachment, reminder, ask or work id is looked up inside the bot named, which must be reached.bots.updateandbots.createrefuse extra keys.settings.set,bridge.policyandbots.devices.*are not in a device's table and never route. Another computer's command line talks to its own service. The local methods refuse a routed call or any client but the window and the CLI (tests).Notes
Decisions the owner may want to change: New bot is left as it was (a new bot starts on every device; narrow it in About); a device switched off gets the "doesn't share its bots" refusal rather than the missing-bot answer; a thread a bot started keeps the bot's name in its own transcript lines, because changing a thread's text per device would change what ordinary threads show.
Closes #1114