Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Use these terms in issues, PRs, comments, and docs. If you need a term that is n
- **Bot journal:** Mousse's complete record of what a bot did and was told: every message, run report, ask, answer and tool call, kept in `bots.db`. A bot's memory, chat summary and search are built from it. See `docs/bot-memory.md`.
- **Bot memory:** the short, dated facts about its owner and notes a bot keeps and sees in every turn, within a fixed size. The owner manages it by asking the bot ("remember …", "forget …", "export your memory").
- **Bot tool catalogue:** how a bot reaches the tools beyond its core set (memory, replies, asks, work, reminders, thread basics). Its instructions name each group in one line; the bot reads a group with `tool_catalogue` when it first needs it, which also gives that group's guidance. On Claude Code every tool is listed and loaded on demand by its tool search; on Codex and Pi only the core set is listed, and the rest are called through one fixed `use_tool` entry. Every permission and refusal is the same either way. See `docs/plans/bot-context.md` §15.
- **Offered message:** a message a bot on one of the owner's computers wants to send to a bot on another computer it can't reach. It waits in the first bot's chat; on the computer it is for, a person sees the exact words, picks a bot and presses Send. The receiving bot gets it as a message in its chat and does nothing until its owner writes to it. Make private, or a switch in the bot's About, stops a bot from taking them. See `docs/bots.md`.
- **Chat summary:** a short summary of a bot's older chat, kept in `bots.db` and given to every turn with the recent messages. Mousse folds the oldest messages into it without a model call.
- **Files folder:** the folder where a bot keeps the documents it makes and copies of the files its owner attaches (`<profile>/bots/files/<botId>/`). The bot may always write there; it is not memory, and none of its contents are read back into prompts: only its files' names and dates are. Its file tools reach no other folder but its scratch folder: "use files on this computer" was removed, and a grant an older build wrote with it keeps working without it.
- **Bot browser:** a bot's own browser, which it uses once its owner allowed "use the browser": a browser without a window, on a Chromium profile of that bot alone, apart from the owner's tabs and every thread's. Sites the owner signs in to there stay signed in for that bot. Its reply shows a live preview of it; Expand opens the split view, the browser beside the bot chat, where the owner uses it just by using its page; it goes back to the bot when they message it, close the view or press Give back. Both get pictures only while they are on screen, pushed as the page paints. See `docs/bots.md`.
Expand Down
16 changes: 15 additions & 1 deletion docs/bots.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,19 @@ A bot can tell another of its owner's bots something: `bot_list()` names the own
- **Stored.** The row is an ordinary chat message, the turn an ordinary chat activation; an older build reads both and ignores `fromBot`. What is held is a `bot_chain_holds` row (`bots.db` v16), and the latest Continue is `bot_memory_state`'s `chain-renewed`. Threads never read either.
- **The risk that remains.** A bot's message can carry what its sender read on the web or in a file. The receiving bot is told it is information, and its turn can't act on the owner's threads, but what it does with its own permissions (its files, commands if it has them) rests on the model's judgement.

### Offered messages

When the owner writes from one computer (here "the PC") to a bot of another (here "the Mac") that the PC uses one way, the Mac has no grant at the PC, so `bot_send` can't reach the PC's bots. The bot can offer the message instead (issue #2490): the PC shows the exact words, and a person there sends them, or doesn't. Nothing crosses from the Mac to the PC; the PC reads the offer on the chat stream it opened.

- **The tool.** `bot_offer({ message, to? })` (`src/shared/bots/personal/offers.ts`, `BotEngine.offerBotMessage`), compiled only for the chat front desk (`compileBotThread`'s `bots` with `frontDesk`) and listed only for a chat turn. It works only in a chat turn the owner started from another device whose message said it takes offers: that device's router adds `offers: 1` to `bots.chat.send` (a version 3 row; added only when the bot's computer lists that version in `net.info`, and never taken from a window), and the turn keeps it on its owner (`BotOwnerTurn.offers`) with the device's node. Any other turn (this computer's own window, a phone, an older PC, a wake, work, another bot's message) is refused with `offer_unsupported` and words to tell the owner to write from the device it is for; there is no other way to send it, ever. Up to 3 offers in a turn (`MAX_OFFERS_PER_TURN`), each up to 2,000 characters and 6 KiB (`MAX_OFFER_CHARS`, `MAX_OFFER_BYTES`). `to` is a name the bot was told, shown as the first pick; it chooses nothing. A retry under the same tool call is the same offer (`replayed`).
- **Where it waits.** In the offering bot's chat, as a notice (`bm_offer_<offerId>`: "I'd like to send a message to a bot on ANIMATRIX. It waits for you there.") with an `offer` card: the offer id, the words, `to`, the computer's name and the node it is for. The node never leaves the Mac: each reader gets the card through `offerCardFor` (in `remoteBotMessage`, so chat streams, `bots.chat.list` and every other bot method), which drops it and marks `forYou` for the device the offer is for alone. On the Mac, and on every other device, the card shows the words and where it waits, with no Send.
- **Send.** On the PC the card shows the words as plain text (no Markdown, no HTML), a pick of the PC's bots that take offered messages (the one `to` names first, else the only one) and Send. `bots.remote.offerSend` (`BotRouter.offerSend`, a local method) takes only a person at a Mousse window of the PC (`clientType: 'gui'`, not through Bridge; the command line, agents and bots are `forbidden`; #2052 applies). It finds the offer in the PC's own copy of the chat (`RemoteBotChats`), or reads that one row from the Mac (`bots.chat.list` by `seq`), never from what the window says, and checks that it is the PC's (`offer_not_here`), that the words are the window's (`offer_changed`), and, with nothing awaited after it, that the PC still lists the bot and has not blocked the Mac (`sender_blocked`). Then `BotChatService.keepOffered` keeps it in one transaction: one row per offer (`bm_offered_<hash of node, bot and offer>`) and its receipt, kept apart from every chat (`bot_memory_state` under `mousse:offered`). So a second Send, after a reconnect, a restart, with the Mac away, or after that chat was cleared or that bot deleted, answers `replayed` from the PC alone, and one to another bot is `offer_sent`; the bot is here (`recipient_gone`) and takes offered messages (`recipient_closed`); at most 30 a hour on this computer (`too_many`). A second Send while one runs is `offer_busy`.
- **What the receiving bot gets.** A notice in its chat ("**Message from your bot Loki on Mac mini**, sent by you" and the words as a quote), marked as outside text (`external`: its journal gives it as text from outside, not the owner's) and quiet. It starts no turn and answers nothing: the bot reads it with the owner's next message to it. Working on it is the owner's own message.
- **States on the PC's card** (`BotOfferRow`): Send; Sent to Alpha; a refusal in its words (`BOT_OFFER_REFUSALS`; `offer_offline` when the offer is in no copy here and the Mac can't be reached); "No bot here takes these." when none does. A Send whose answer was lost is looked up (`bots.remote.offerState`, which reads the PC alone) before Send comes back. The Mac's row is not told the outcome.
- **Which bots take them.** Every bot of a computer, until the owner says otherwise: Make private closes it first, then makes the bot private, and stops if closing fails (`bots.devices.offers`, this computer's alone: no other device has a row for it, at any bot access), and About → Devices has the switch "Messages from other computers' bots". Kept in `<profile>/bots/offers.json` (`BotOfferAccessStore`); a file that can't be read closes every bot, and the next change keeps the others closed. Make private on a bot of another computer leaves that computer's switch alone.
- **A bot that moves** to another computer takes its offers without the device each was for (`offerCardFor` in the bundle), so there they wait for no Send.
- **Not yet.** Offers don't expire. A picture's path in the words shows that picture in the receiving bot's chat on the PC, as in any message between bots; nothing leaves the PC.

## Asks

An ask is a request for one permission, shown as a card with Allow and Not now (`bot_escalations`, `mode` `wall` or `ask`).
Expand Down Expand Up @@ -840,7 +853,7 @@ A bot is held on two sides, both set on the computer that holds it (its home com

### Which devices reach a bot

- **Per bot.** About → Devices: This computer, always on, then a switch for each other device of the owner's (phones too), each off until the owner turns it on. With no other device it says Only this computer. A device linked later reaches no bot until it is turned on in that bot's About. Kept in `<profile>/bots/device-access.json` (`BotDeviceAccessStore`), not in `bots.db`, so no database version moves: `this_computer`, or `chosen` with the devices turned on; none turned on is `this_computer`. The bot's menu has Make private (this computer alone, in one click).
- **Per bot.** About → Devices: This computer, always on, then a switch for each other device of the owner's (phones too), each off until the owner turns it on. With no other device it says Only this computer. A device linked later reaches no bot until it is turned on in that bot's About. Kept in `<profile>/bots/device-access.json` (`BotDeviceAccessStore`), not in `bots.db`, so no database version moves: `this_computer`, or `chosen` with the devices turned on; none turned on is `this_computer`. The bot's menu has Make private (this computer alone, in one click; it also closes the bot to offered messages, see Messages between bots).
- **New bot.** When the owner has another device (`devices` in `bots.model.choices`, the other devices linked now), New bot has a Devices step after Runs on, with the same switches, all off. With this computer the only device there is no step, and the bot is this computer's alone. Either way About changes it later. `access` is sent only to a service that says `reachOnCreate`; an older service gets none.
- **Saved before the bot exists.** `bots.create`'s choice is written before the bot is published, so no list or call ever shows a new bot to a device it leaves out. A create that fails before publishing takes its choice off again; a crash between the two leaves a choice for a bot that was never made, which the next start removes (`BotDeviceAccessStore.dropBots`) before any create can run. A retry of the same request returns the bot it made and changes nothing. This computer alone writes nothing once no stored choice already means it. `access: { mode: 'all' }` from an older window is taken as this computer alone.
- **Per device.** Settings → Devices → Bots on this computer, beside each device's other switches: an Off / Use / Full picker (`net_node_policy.bots`, `bridge.policy`'s `bots`, `mousse-cli bridge limits <node> --bots off|use|full`). A new device starts at Use. **Off:** the device reaches no bot here, whatever each bot says. **Use:** it lists and opens the bots it reaches, reads their chat, images, cards and memory, sends messages, answers questions and held actions (within the bot's existing permissions), stops work, snoozes reminders, marks read, and watches the browser and opens applets. **Full:** every other remote action as well: rename and look, pause and resume, permissions (answering an ask is a grant), memory edits, cancelling reminders, schedules, taking over the browser, the bot's Devices, delete, and making bots here. The presets set it with their other switches (View and chat and Work on threads give Use, Full control gives Full); changed on its own, the preset shows Custom, and Full control for remote updates and the engine grant role does not move. Full bot access never widens thread access: turning on Allow everything, or allowing "Use your threads", also needs the device's highest permission mode here to be Full access, and a turn a device starts stays under that mode. It is the only device-level setting for bots: the computer-wide "Share bots with other devices" of earlier builds is gone. On update, a computer that had it off sets every device it knows to Off (its account's devices, every device with a record here and every engine pairing), once, so no device gains access; one that had it on changes nothing. The update to levels (Net schema 2) keeps Off as Off and makes an on device Full if it was at Full control and Use otherwise. Dictation and read-aloud (`speech.*`) are not bot calls and do not follow the level.
Expand Down Expand Up @@ -976,6 +989,7 @@ NULL `owner_set` means set before v10 (or by an older writer) and preserves toda
| Work and reminders | `BotEngine` (`startWork`, `listWork`, `noteWork`, `addReminder`, `deliverDueReminders`), `src/mms/bots/grants/compile.ts` (`frontDeskManifest`) |
| Subagents of work | `BotEngine` (`startSubagent`, `compileSubagent`, `holdOf`, `prepareSubagent`, `settleSubagent`, `acknowledgeReportStops`), `src/shared/bots/personal/subagentHold.ts` (the hold rule), `HarnessDriver.botHold`, `src/mms/bots/grants/compile.ts` (`subagentManifest`), `subagent_*` in `src/mms/run/mcp/appTools/bots.ts` |
| Messages between bots (`bot_list`, `bot_send`) | `src/shared/bots/personal/botMessages.ts`, `BotEngine.sendBotMessage`, `receiveBotMessage`, `otherBots` and `unownedChainOf`, `BotStore.botMessageRowAfter`, `botMessageRowSince`, `botMessagesReceivedAfter`; other computers' bots: `src/mms/bridge/routed/otherComputersBots.ts`, `src/mms/protocol/otherComputersBotsPort.ts`, `RemoteBotRegistry`'s `FeedState` |
| Offered messages (`bot_offer`) | `src/shared/bots/personal/offers.ts`, `BotEngine.offerBotMessage`, `offerCardFor` in `RemoteBots.ts`, `BotRouter.offerSend` and `offerState`, `BotChatService.keepOffered`, `src/mms/bots/definitions/BotOfferAccessStore.ts`, the card's `BotOfferCard.tsx` |
| Questions (`question_ask`, taps, moving on, work that waits on one) | `src/shared/bots/personal/questions.ts`, `BotEngine.askOwner`, `askFromWork`, `postReply`, `parkForQuestion`, `answerWorkInTx` and `relayAnswer`, `BotChatService.answerQuestion`, `answerWork` and `send`, `src/renderer/components/bots/BotQuestionReplies.tsx` |
| Cards (`show_card`, a question's card) | `src/shared/bots/personal/cards.ts` (`cardOf`, `plainCard`), `src/mms/bots/chat/replyCards.ts` (`galleryPicture`), `BotEngine.showCard`, `BotChatProjection.shown` and `toMessage`, `src/renderer/components/bots/BotCards.tsx` |
| Question follow-ups (nudges, defaults, late answers) | `questionFollowOf` (`questions.ts`), `src/mms/bots/activation/questionFollowUps.ts` (`nudgeSlot`), `BotEngine.armDue`, `followUpQuestion`, `nudge`, `goWithDefault` and `lateWorkAnswerInTx`, `BotChatService.workAnswerMode` |
Expand Down
5 changes: 4 additions & 1 deletion src/main/ipc/registerGuiIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import { BRIDGE_LISTS_METHODS } from '../../shared/bridge/computerProjects'
import { SPACES_LOCAL_METHODS } from '../../shared/spaces/local'
import { BOTS_LOCAL_METHODS } from '../../shared/bots/space/local'
import { BOTS_ELSEWHERE_METHODS, BOTS_PERSONAL_V2_METHODS, BOTS_WORK_METHODS } from '../../shared/bots/personal/methods'
import { BOT_DEVICE_METHODS } from '../../shared/bots/personal/deviceAccess'
import { BOT_DEVICE_METHODS, BOT_OFFERS_SWITCH_METHOD } from '../../shared/bots/personal/deviceAccess'
import { BOT_OFFER_METHODS } from '../../shared/bots/personal/offers'
import { BOT_MARK_METHODS } from '../../shared/bots/personal/marks'
import { BOTS_BROWSER_METHODS } from '../../shared/bots/personal/browser'
import type { BotChatMessage } from '../../shared/bots/personal/chat'
Expand Down Expand Up @@ -312,6 +313,8 @@ export const PLATFORM_REQUEST_METHODS: ReadonlySet<PlatformRequestMethod> = new
...BOT_MARK_METHODS,
...BOTS_WORK_METHODS,
...BOT_DEVICE_METHODS,
BOT_OFFERS_SWITCH_METHOD,
...BOT_OFFER_METHODS,
...BOTS_BROWSER_METHODS,
...AUTOMATIONS_METHODS,
...SECRET_METHODS,
Expand Down
17 changes: 17 additions & 0 deletions src/mms/MmsProfileServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ import type { EditorAsksPort } from './protocol/editorAsksPort'
import type { BotReachPort } from './protocol/botReachPort'
import type { OtherComputersBotsPort } from './protocol/otherComputersBotsPort'
import { BotDeviceAccessStore } from './bots/definitions/BotDeviceAccessStore'
import { BotOfferAccessStore } from './bots/definitions/BotOfferAccessStore'
import { ensureBuiltInBots, renameOldDefaultBot } from './bots/builtIn'
import { BotMarksStore } from './bots/marks/BotMarksStore'
import type { RemoteListsPort } from './protocol/remoteListsPort'
Expand Down Expand Up @@ -377,6 +378,11 @@ export class MmsProfileServices {
* keeps of their feeds, and a message sent to their computer. Set by the Bridge service with `botRouter`.
*/
otherComputersBots?: OtherComputersBotsPort
/**
* Another device's name as Settings, Devices names it, for words a bot says about it (an offer names the computer it
* is for). Set by the Bridge service; absent while it is off.
*/
deviceName?: (node: string) => string | undefined
/**
* The threads, projects and statuses of the user's other computers, merged into this computer's lists
* for windows. Set and cleared with `threadRouter`; empty while routing is off.
Expand Down Expand Up @@ -489,6 +495,8 @@ export class MmsProfileServices {
readonly botBrowsers: BotBrowsers
/** Which devices reach each bot (About → Devices), in `<profile>/bots/device-access.json`. */
readonly botDeviceAccess: BotDeviceAccessStore
/** Which bots here take offered messages (issue #2490); Make private closes a bot. */
readonly botOfferAccess: BotOfferAccessStore
/** Pin, hide, mute and marked unread on every bot this computer lists, in `<profile>/bots/bot-marks.json`. */
readonly botMarks: BotMarksStore
/** Bots' schedules: automations whose Who is the bot, in the shared scheduled-job store. */
Expand Down Expand Up @@ -882,6 +890,7 @@ export class MmsProfileServices {
})
this.botBrowsers = botBrowsers
this.botDeviceAccess = new BotDeviceAccessStore(join(homeDir, 'bots'))
this.botOfferAccess = new BotOfferAccessStore(join(homeDir, 'bots'))
// Read on first use (the Bots list asks once it shows), never here.
this.botMarks = new BotMarksStore(join(homeDir, 'bots'))
this.platform.onDispose(() => botBrowsers.dispose())
Expand Down Expand Up @@ -973,6 +982,7 @@ export class MmsProfileServices {
// A device's limit now, for a turn held to it; while Bridge is off it can't be read, and the saved limit holds.
deviceLimit: (botId, node) => this.botReach?.turnLimit?.(botId, node),
otherComputersBots: () => this.otherComputersBots,
deviceName: (node) => this.deviceName?.(node),
// The shared store, through the book made once the scheduler exists below (nothing reads it before that).
schedules: {
list: (botId) => this.botSchedules?.list(botId) ?? [],
Expand Down Expand Up @@ -1049,6 +1059,8 @@ export class MmsProfileServices {
},
// Which devices reach each bot: a new bot's choice is saved before the bot is published.
deviceAccess: this.botDeviceAccess,
// Which bots take offered messages from bots of the owner's other computers.
offerAccess: this.botOfferAccess,
// New bot's Devices step lists the owner's other devices, as About's Devices does.
devices: async () => this.botReach?.devices(),
// The secrets a bot's home thread may use, for its profile: names and labels only, read when it asks.
Expand Down Expand Up @@ -1138,6 +1150,11 @@ export class MmsProfileServices {
} catch (error) {
console.warn('bot device choices could not be tidied', error instanceof Error ? error.message : String(error))
}
try {
this.botOfferAccess.dropBots((botId) => opened.store.registry(botId) !== undefined)
} catch (error) {
console.warn('bot offer choices could not be tidied', error instanceof Error ? error.message : String(error))
}
try {
renameOldDefaultBot(opened.engine)
} catch (error) {
Expand Down
Loading
Loading