diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index f01ca3e992..8392919ecb 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -79,7 +79,8 @@ User-facing preferences that are not provider/agent scheduling. `SettingsStore.g | Key | Type | Default | Description | |-----|------|---------|-------------| -| `profile.username` | `string` | Random generated name | Display name in the app | +| `profile.ownerAddress` | `object` | Absent until the profile's first start, then `{ "name": null, "invitation": null }` | What bots call you (Settings → General → You): `name` is the name you gave, or `null` when none is set. Written only by Mousse's `OwnerAddress` (Settings, Set up Mousse, New bot, or a bot saving what you told it in chat); `mousse config set` and `settings.set` can't change it. Also holds whether Set up Mousse and New bot showed their field (`setupShown`, `newBotShown`) and the one chat ask (`invitation`, with `spentAt` once a bot asked). See [`plans/what-bots-call-you.md`](plans/what-bots-call-you.md). | +| `profile.username` | `string` | none | The random name older versions made. Read once, to make `profile.ownerAddress` (a name the generator could not have made is kept; a generated or blank one is unset), and kept for older versions. Nothing reads it after that. | ### `settings.appearance` diff --git a/docs/bot-memory.md b/docs/bot-memory.md index d41835e65a..992ab0694b 100644 --- a/docs/bot-memory.md +++ b/docs/bot-memory.md @@ -40,7 +40,7 @@ Every bot has an append-only **journal** in `bots.db` (`bot_journal`). It holds | chat summary (≤1k tokens; about 3k once it holds digests) | its first 600 tokens, the newest digest first | | verbatim window: owner messages, bot replies, run reports, and how a chat turn ended without its reply (≤8k) | last 3 reports of this schedule id (any trigger for a manual run) | | open items (≤1.5k tokens, see "Open items") | owner messages since this schedule last ran (≤8); a schedule's first run gets the message from when it was made | -| situation: time and zone, the owner's last message, open asks, schedules, the last run | one line saying how many items are open, then the situation | +| situation: time and zone, what to call the owner (the name, or that none is set) and their language, the owner's last message, open asks, schedules, the last run | one line saying how many items are open, then the situation | - **A schedule keeps its place.** After its last reports, a scheduled run gets its own latest `leftOff` with collapsed whitespace and fixed, escaped data markers, never instructions. It gets no other schedule's note; chat, work and runs by hand do not get it. `run_report` accepts up to 600 characters, and a quiet run is told to report quiet with this note. The engine holds it under `progress_pending:` until the run ends done; a failed or stopped run cannot replace a good note. Marking a paused run done drops its pending note and keeps the previous successful one. Successful completion saves it under `progress:` in `bot_memory_state`, replacing the last value, and journals it as written in the run lane. It never enters the automation runs' database. A `[SILENT]` end with no report call leaves the old value. The chat's schedule-list tool screens notes and labels them as unattended data; other runs receive no notes from that tool. Removing the schedule clears the value; a deleted bot's memory is purged with it. - **What can be looked up.** The situation lists up to twelve most recently changed files by relative name and date, never contents, plus the remaining count. Each name is JSON-quoted on its own line, escaping quotes and line breaks without rewriting the name. Names pass through the outside-text guard and are cut to at most 60 characters. Dot entries are skipped. The bot's files are scanned first, stopping after 512 entries (directories included); Mousse's root pictures, attachments and temporary folders are scanned afterward under a separate 128-entry bound, for counts only. An incomplete scan says “and many more”; managed counts from an incomplete scan are lower bounds. Ordinary files called `scratch-pad.md` or `temp_readings.csv` are listed. The history line gives the number of searchable messages and their earliest date, with a reminder that `memory_search` reaches them. File dates and the history date show the year when it is not the current year in the owner's zone. Together the indexes fit 300 tokens in chat and 200 in a run brief; long names are shortened further to fit. Empty indexes are omitted. Both indexes freeze with the activation, and earlier pack blocks stay unchanged. diff --git a/docs/bots.md b/docs/bots.md index 9f2f737e4b..729b7ec3a5 100644 --- a/docs/bots.md +++ b/docs/bots.md @@ -31,6 +31,16 @@ The owner can rename the bot, change its look, prompt and models, and pause it. - **Its look through `set_profile`.** `set_profile` takes an optional `look` with any of `kind`, `colour`, `accessory`, `eyes` and `eyeColour`, each one of the values in `src/shared/bots/personal/look.ts`. Only the fields given change; the rest of the published look stays (`tools.setProfile` merges, then `setProfile` publishes like a rename). Only in the chat, when the owner asks. The app's face changes at once (`bots.changed`), and a card asking for `set_profile` reads "change its name, description or look". - **Its face picture.** `face.png` in its files folder: its face as the app draws it, 512 px square, the whole character, front on, still (`src/renderer/components/bots/face/facePictureSync.ts`). Only the renderer has the face shader, so the app draws it and the service writes it (`bots.facePicture.save`, `BotFacePictures` in `src/mms/bots/facePicture.ts`): whole, through a temporary file and a rename. The bot can write in its files folder and the service is not sandboxed, so no link it plants is followed: the temporary file has a random name and is created only where nothing is (`O_EXCL`, with `O_NOFOLLOW` where the platform has it), the rename replaces a link at `face.png` itself, and a `face.png` that is a link counts as no picture (`lstat`); a failed write or rename removes the temporary file. The PNG carries the key it was drawn from (look, view, size, `faceArtVersion`) in a `tEXt` chunk; each bot's summary carries that key (`facePicture.key`), and the window draws again only a bot whose key differs, so a new look, new face art, or a picture someone replaced or deleted is drawn again. The service compares the key's look part (`faceLookKey`) with the bot's look, from the same cached stat, to tell a picture of an older look. The window draws in idle time, once the faces draw live, one bot at a time; a key is marked tried once its picture is drawn, so a refused save is not tried again in that window, while a picture the renderer could not draw (a lost context) is drawn once the faces draw again. With no face on screen, the drawing buffer the picture grew shrinks again after `IDLE_SHRINK_MS`. No window open: it is drawn the next time one opens. `bots.facePicture.save` is refused to a bridged call and to any client but the app window, and is not offered to other devices (`remoteBotSummary` drops the key, so another computer's app never draws it). +## What bots call the owner + +One name for every bot of a profile, or none (`settings.profile.ownerAddress`, written only by `OwnerAddress` in `src/mms/settings/OwnerAddress.ts`; design in [`plans/what-bots-call-you.md`](plans/what-bots-call-you.md)). + +- **What a bot is told.** Every pack's situation has the `owner` line: `What to call the owner: "Sam".`, the name JSON-quoted as data, or `What to call the owner: no name is set, so use none.` The base instructions say to use only that name, never guess one or take one from memory, files or old chats, and not to ask unless the situation says to. A running chat epoch hears a change on its next turn, set or cleared, as any keyed fact. The owner's language, when known, is its own line (`ownerLanguage`). +- **Where the owner sets it.** Set up Mousse's Welcome page ("What should bots call you?", saved when they leave Welcome), New bot's What it does step (while no name is set; not while another computer can be picked under Lives on, and the bot is made even if the name is not saved, the failure said in its new chat), and Settings → General → You → What bots call you. Each setup field shows once per profile (`setupShown`, `newBotShown`), only in the one window that claims it (`ownerAddress.shown` answers `claimed`), and never after the chat ask was spent. Welcome and New bot save with `setup: true`, only while no name is set, so an older draft never overwrites a newer name; Welcome may correct the name it saved itself (`replaces`), and says so when its save is refused. A window keeps its claims per profile. Emptying the Settings field clears the name and opens the chat ask once more. `ownerAddress.set` and `ownerAddress.shown` answer only a Mousse window on this computer; `settings.set`, `mousse config set` and a whole settings object sent back by an older window never change the record. +- **The one chat ask.** While no name is set, the first greeting or reply to the owner (`owner_message`, `owner_tap` or `first_message` turns, `ownerInvitationTurn`) of any bot on the profile holds the ask: the profile service records its activation as the delivery id (`claimInvitation`), and that turn's chat pack says `In this reply only, unless your owner already told you, ask in your own words what they'd like you to call them. Keep it brief and easy to skip. Put that question alone on the last line of your reply, starting with [[ask-name]]. Mousse removes the marker and shows that line as its own message, so don't ask it anywhere else.` Work, schedules, wake-ups, threads and other bots' messages never hold it, and two bots can't both. `postReply` takes the marked line (at a line's start, in any case, in simple Markdown, never in a code block) out of the reply and posts it as a message of its own (`bm__name`), and drops it on a turn without the ask; the home thread's message events, which windows, phones and other computers get, never carry it, nor a marker still being written (`withoutNameQuestion`), though the stored thread may; a reply with words and no marked line gets "What should I call you?" there instead, and a reply that is only a card, or stops at a wall, gets none. The ask is spent (`invitation.spentAt`) just before that message is posted. A turn holds it until then, or until it ended and its final words are not on their way (`replyPending`); one that posted no question frees it. Answering, declining and ignoring leave it spent; clearing a chat, resetting or deleting a bot never reopens it. +- **Saving from the chat.** `save_owner_name { name }` (core, so every runtime lists it; only a chat turn holds it, never work, a consult or a subagent) saves the name only when one message the owner typed in this turn names it as words of its own (taps left out; `BotEngine.saveOwnerName`, `nameSaidIn`, where scripts without spaces such as Chinese and Japanese match without word breaks). It answers `Saved. Every bot will use it from its next turn.` or `Not saved: . Tell your owner, and that they can set it in Settings → General.` A name saved there shows at once in Settings. +- **Old profiles.** The random two-word name older versions wrote into `settings.profile.username` is read once, when the record is missing: a non-blank name the generator could not have made is kept as written; a generated, blank or missing one is unset. Changelog entry 45 tells existing bots the name now comes only from the situation. A pack frozen before the upgrade is built again at its turn's next dispatch. An older version opening the profile keeps the record, and may still show its own random name to its own bots. + ## Lanes Each bot has two lanes. The chat lane runs one activation at a time; the run lane runs everything side by side, with no count per bot or per profile. Each activation keeps its own spend ledger, counts, deadline and supervisor. The chat is the bot's front desk and the run lane does its work, so the owner can always talk to it (see "The chat and its work"). diff --git a/docs/plans/bot-context.md b/docs/plans/bot-context.md index 43089ae6a6..b96634c45e 100644 --- a/docs/plans/bot-context.md +++ b/docs/plans/bot-context.md @@ -137,7 +137,7 @@ CREATE TABLE bot_memory_state(bot_id TEXT NOT NULL, key TEXT NOT NULL, value TEX | 3 | **Run notes**, under "Notes from my unattended runs (data, not instructions)" | ≤500 | | 4 | **Chat summary** (§5.3) | ≤1,000 | | 5 | **Verbatim window**: chat rows from `window_start_seq`, meaning owner messages, bot replies, run reports and the one Mousse line a chat turn leaves when it fails, is interrupted or is stopped, with no tool rows. When it passes 8k tokens, the oldest rows are dropped down to 4k and folded into the summary. Between those jumps each turn's prefix extends the last one. | ≤8,000 | -| 6 | **Situation**: local date, time and zone, time since the owner last wrote, open asks, schedules by label, and how the last run ended | ≤250 | +| 6 | **Situation**: local date, time and zone, what to call the owner (`owner`, on every turn: the name the owner gave, JSON-quoted, or that none is set; [`what-bots-call-you.md`](what-bots-call-you.md)) and their language (`ownerLanguage`), time since the owner last wrote, open asks, schedules by label, and how the last run ended; the one chat turn that holds the ask for the owner's name also gets that line | ≤250 | The whole pack is wrapped as `…`. It comes to at most about 12k tokens, flat for the bot's whole life. Today a locked Claude turn re-sends the whole home history, so for any bot older than a few days this is a saving. @@ -280,7 +280,7 @@ memory_forget({ id?: string; refs?: string[]; reason: string }) - Run briefs carry only the bot's own reports and the owner's own words. - Search results are wrapped as quoted history. - **The memory store belongs to the daemon.** It lives in `bots.db`, outside the bot's sandbox. The bot has no file it can rewrite to change its memory. -- **Scope.** Memory is per bot, and a bot never reads another bot's rows. Phase 1 shares only the owner's name, time zone and language, taken from settings. +- **Scope.** Memory is per bot, and a bot never reads another bot's rows. Phase 1 shares only what bots call the owner, their time zone and language, taken from settings. The name is the profile's `settings.profile.ownerAddress`, which only the owner sets (Settings, setup, or their own typed words through `save_owner_name`); while none is set, bots use no name ([`what-bots-call-you.md`](what-bots-call-you.md)). ## 10. Changes to the Bot Architecture plan @@ -511,7 +511,7 @@ does not hold, one no bot may be offered, and `use_tool` itself are refused. A s | Owner's permissions, run | 88,000 | 25,000 | 46,100 | 18,400 | | Starter, chat | 55,900 | 26,300 | 33,300 | 20,000 | -Since these numbers, `show_card` is in the core set (see Reliability): about 2,900 characters more on Codex and Pi in each lane. The test holds a bot with every permission to 53,000 characters on Codex and Pi and 22,000 on Claude Code, on both lanes. +Since these numbers, `show_card` is in the core set (see Reliability): about 2,900 characters more on Codex and Pi in each lane. The test holds a bot with every permission to 53,000 characters on Codex and Pi and 22,000 on Claude Code, on both lanes. `save_owner_name` is core too, held only by the chat, since the base instructions name it ([`what-bots-call-you.md`](what-bots-call-you.md)): about 480 characters more on the chat lane on Codex and Pi. **Reliability.** Real Claude Code (Opus) and Codex (GPT 6.1 Sol), headless with the owner's sign-ins, each given a bot's system text and tool list through a stub MCP server that records the calls. Eight owner messages to the chat (remind, a standing rule, find a thread, a weekly schedule, think harder, forget a memory, hide a thread, a checklist card), three rounds each, plus five more rounds of the two weakest: diff --git a/docs/plans/what-bots-call-you.md b/docs/plans/what-bots-call-you.md new file mode 100644 index 0000000000..2e57c6354f --- /dev/null +++ b/docs/plans/what-bots-call-you.md @@ -0,0 +1,79 @@ +# What bots call you + +Status: built. + +## The problem + +Every profile got a random two-word name ("Wobbly Pickle") the first time its settings loaded. Nothing in the app showed it, and every bot was told "The owner is Wobbly Pickle." The person couldn't say what bots should call them. At the root, the name bots read was a placeholder that the settings loader filled in, so "no name" looked the same as "a name the person chose". + +## The record + +There is one record on the profile: `settings.profile.ownerAddress`. + +| Field | Meaning | +|---|---| +| `name: string \| null` | `null` means unset. A string is a name the person gave. Nothing else ever supplies a name. | +| `setupShown`, `newBotShown` | The Welcome field and the New bot field were each given to a window once. | +| `invitation: { deliveryId, botId, at, spentAt? } \| null` | The one chat ask. A chat turn holds it (`deliveryId` is its activation); `spentAt` is when its name question was posted. Clearing the name in Settings resets it. | + +- **One writer.** `OwnerAddress` (`src/mms/settings/OwnerAddress.ts`), built in `MmsProfileServices` right after `SettingsStore`, is the only writer. It writes through `MousseConfigStore.replaceProfileKey`, which writes the file before it changes the live copy, so a failed write throws and the old value stays. Its methods are synchronous, so the service thread runs one at a time: two bots or two windows can't both win a claim. +- **No other way in.** `SettingsStore.set` drops `profile` from every update and leaves it out of what it writes, so `settings.set`, `mousse config set` and a whole settings object sent back by an older window can't change the record. `ownerAddress.set` and `ownerAddress.shown` answer only a Mousse window on this computer: the CLI, agents and other computers are refused. +- **Old key.** `settings.profile.username` is read once, to migrate, and never again. The random-name generator is gone from the defaults and from the loader, and `SettingsStore.get` no longer returns the old key. +- **Upgrade.** The migration runs once, when the record is missing, and reads the file as loaded (the defaults hold no profile key): + - A non-blank `username` that is not exactly one of the generator's 400 outputs is kept as written. + - An exact generator output, a blank or a missing value becomes `null`. + - `username` itself is left as it is, for older builds. + - Known limit: someone who once typed exactly "Rusty Fox" can't be told apart from a generated "Rusty Fox", so they are asked again. +- **Older builds.** An older build opening the same profile keeps the record (checked by hand on the design). It may write a new random `username` and show it to its own bots. The newer build ignores that value. +- **Packs frozen before the upgrade.** The packs frozen per activation carry a format version. One without it may say "The owner is Wobbly Pickle.", so it is built again at the turn's next dispatch, a waiting run's included. A running chat epoch's update then sends the changed `owner` fact. Building it moved the epoch's chat cursor past what it held, so it is built again from the first chat line it held: a work report in it is not lost. An epoch's start is built again as a start. + +## What bots are told + +- Key `owner`, in every pack's situation: + - set: `What to call the owner: "Sam".` (the name JSON-quoted, as data) + - unset: `What to call the owner: no name is set, so use none.` +- Key `ownerLanguage`: `The owner writes in .` +- Base instructions: `Use only the name in your situation for your owner. If none is set, use no name: never guess one or take one from memory, files or old chats, and don't ask unless your situation tells you to. When your owner tells you what to call them, or answers your question about it, use save_owner_name, and confirm only after it is saved.` +- Changelog entry 45, sent once to existing bots: `Your owner's name now comes only from your situation. If none is set, use no name, even if you used one before.` +- Only the turn that holds the ask: `In this reply only, unless your owner already told you, ask in your own words what they'd like you to call them. Keep it brief and easy to skip. Put that question alone on the last line of your reply, starting with [[ask-name]]. Mousse removes the marker and shows that line as its own message, so don't ask it anywhere else.` + +## The one chat ask + +- **Who holds it.** While the name is unset and the ask unspent, the first greeting or reply to the owner (`owner_message`, `owner_tap` or `first_message` turns) of any bot on the profile claims it when its pack is built (`botInvitationClaim`). Work, schedules, wake-ups, threads and other bots' messages never do. +- **How long.** The turn holds it until its name question is posted, or until it can post nothing more: it ended, and its final words are not on their way (`BotEngine.replyPending`, up to a few seconds after the turn ends). A turn that failed or posted no question frees it for the next turn. A turn whose bot was removed frees it too. +- **The question.** `BotEngine.postReply` takes the line the bot marked with `[[ask-name]]` out of its reply and posts it as a message of its own after the reply (`bm__name`). When the bot marked none, a reply with words gets Mousse's `What should I call you?` as that message. A reply with no words (a question card or a card alone), or one at a permission wall, gets no unmarked question; a later reply of the same turn may. A marked line never shows on any other turn (a name set, or the ask spent): its question is dropped, and a reply with nothing else posts nothing. +- **The marker.** It counts only at the start of a line: in any case, with spaces inside (`[[ Ask-Name ]]`), more than once, and inside simple Markdown (bold, italics, a code span, a list bullet or a quote), whose leftover marks are dropped with it. A marker alone on its line takes the next line as its question. Windows line endings read the same. A reply that ends in the middle of a marker (`[[ask-`) loses it. One in the middle of a sentence, or in a fenced code block, is the bot's words and stays. +- **Not on screen in the chat.** The question shows only as its own message. While a chat reply is written, the message events of the bot's home thread, which windows, phones and other computers get, carry it without the marked line and anything after it, or a marker it is still writing at the end (`withoutNameQuestion`, in `OrchestratorService.shownMessage`); the home thread's stored row drops it once the turn ends. The chat's live reply drops the same, for a service that still sends it, and so do a stopped reply and the voice reading it aloud. Work threads are never filtered. Not filtered: reading the stored thread itself (loading or paging it), which still holds the line for a turn that was stopped or published applets, and the activation's result, which the chat reads the question from. +- **Spent.** The ask is spent (`spentAt`) just before the question is posted, so a crash can never let a second turn ask. Answering, declining and ignoring leave it spent. Clearing a chat, resetting or deleting a bot never reopens it; only clearing the name in Settings does, once. A reply that asks something else ("Which inbox should I check?") never spends it. +- **The owner already said it.** If the owner's message already says "call me Sam", the bot saves it with `save_owner_name`, and no question is posted. + +## Saving from chat + +`save_owner_name { name }` is a core tool of the main chat only (listed directly on every runtime), never work, a consult or a subagent. + +- **Checks** (`BotEngine.saveOwnerName`): the turn is a chat turn of that bot, and one message the owner typed in this turn names the name as words of its own (`nameSaidIn`: case and spacing aside, never inside a longer word, so "Sam" is not in "Samantha"; in scripts without spaces, such as Chinese, Japanese and Korean, the letters around it don't count). Tapped answers are the bot's words and don't count. +- **Whose name.** The tool can't tell the owner's own name from one they mention about someone else ("My colleague Samantha"). Its description says never to use it for such a name; the bot's confirmation shows the save, and Settings corrects it. +- **Results.** `Saved. Every bot will use it from its next turn.` or `Not saved: . Tell your owner, and that they can set it in Settings → General.` +- The bot's message saying it saved the name has the chip "saving your name", and the name shows at once in every window's Settings. + +## Setup and Settings + +One optional field each, never blocking: + +- **Set up Mousse → Welcome:** "What should bots call you?", note "Optional. Change it later in Settings.", placeholder "Your name". Leaving Welcome (Get started or Skip setup) saves a name typed there; a failed save shows a toast with Retry. +- **New bot → What it does:** under "What should it do?", label "What should bots call you?", placeholder "Optional. Every bot will use this name." Not shown, and not used up, while another computer can be picked under Lives on (that step comes later, and a bot there reads that computer's name). The bot is made even if the name is not saved; the failure is said in its new chat. +- **Settings → General → You → What bots call you:** "Every bot uses only this name.", placeholder "Not set". Saves on Enter or when the field loses focus; emptying it clears the name and opens the chat ask once more. +- **Once, in one window.** A setup field shows while no name is set, it was never shown there, and the chat ask is unspent. The window claims it first (`ownerAddress.shown` answers `claimed`), and only the window that got it shows it, each time that page or dialog opens. A claim tells the other windows. A window keeps its claims per profile: after it moves to another profile, that profile's own claim decides. +- **Setup saves keep a newer name.** Welcome and New bot save with `setup: true`: only while no name is set, so a draft typed earlier never overwrites a name saved since in Settings or from a chat. Welcome may correct the name it saved itself: it sends that name as `replaces`, and the save goes through while the name is still that. A save refused because another name was saved first is said in a toast. New bot sends the name only while its field shows; a name typed there stays in the draft when New bot is closed on a later step, and Create bot saves it after it opens again. + +## Not checked + +- A bot living on another computer. +- A reply from the phone. +- How real models word the question and use the marker. + +## Revisit if + +- names need to sync across computers (Mousse ID); +- per-bot nicknames are wanted (they would be resolved at the per-bot situation read); +- bots keep using old names from memory. diff --git a/src/main/ipc/registerGuiIpc.ts b/src/main/ipc/registerGuiIpc.ts index 3c4e32acee..4fef34cf27 100644 --- a/src/main/ipc/registerGuiIpc.ts +++ b/src/main/ipc/registerGuiIpc.ts @@ -347,7 +347,8 @@ export const PLATFORM_REQUEST_METHODS: ReadonlySet = new 'mcp.create', 'mcp.update', 'mcp.read', 'mcp.enable', 'mcp.delete', 'mcp.testConnection', 'mcp.beginAuth', 'mcp.cancelAuth', 'mcp.revokeAuth', 'orchestrator.sendAccepted', 'runs.resumeNow', 'runs.cancelPause', 'threads.goal', 'threads.setHidden', 'threads.chainHold', - 'threads.dismissArchiveKept' + 'threads.dismissArchiveKept', + 'ownerAddress.set', 'ownerAddress.shown' ]) class PlatformRequestError extends AppError { diff --git a/src/mms/MmsProfileServices.ts b/src/mms/MmsProfileServices.ts index 170ed26869..545e725896 100644 --- a/src/mms/MmsProfileServices.ts +++ b/src/mms/MmsProfileServices.ts @@ -1,4 +1,5 @@ import { workWaits } from './bots/store/BotStore' +import { botInvitationClaim, botInvitationLedger } from './bots/ownerInvitation' import { readSelfUpdateReport } from './updates/selfUpdateReport' import { remoteUpdatesFor } from './updates/remoteUpdates' import { UpdateRollouts } from './updates/rollout' @@ -23,6 +24,7 @@ import { homedir, hostname } from 'os' import { MousseConfigStore } from './config/MousseConfigStore' import { MmsEventBus } from './events' import { SettingsStore } from './settings/SettingsStore' +import { OwnerAddress } from './settings/OwnerAddress' import { normalizeExperimentalSettings, type MousseSettingsUpdate } from '../shared/settings' import { normalizeErrorReportSettings } from '../shared/bugReports' import { rewriteMovedDefaults } from './settings/movedDefaults' @@ -312,6 +314,8 @@ export class MmsProfileServices { readonly domains: DomainHandlerRegistry readonly config: MousseConfigStore readonly settings: SettingsStore + /** What bots call the owner (docs/plans/what-bots-call-you.md): the only writer of `settings.profile.ownerAddress`. */ + readonly ownerAddress: OwnerAddress private forgetBranchNamer?: () => void readonly providerAuth: ProviderAuthService readonly antigravity: AntigravityProviderService @@ -590,6 +594,10 @@ export class MmsProfileServices { }) this.events = new MmsEventBus() this.settings = new SettingsStore(config) + // Before any bot reads it: a profile without the record gets it once, from its old username as the file holds it. + // A bot's turn taking or spending the chat ask shows in every window at once (their setup fields hide). + this.ownerAddress = new OwnerAddress(config, undefined, () => this.ownerAddressChanged()) + this.ownerAddress.migrate() // Before anything reads or moves a worktree: the folders this profile chose for them are Mousse's (`worktreeLayout`). setWorktreeFolders(homeDir, this.settings.get().storage) this.providerAuth = shared.providerAuth @@ -978,6 +986,16 @@ export class MmsProfileServices { // A resumed bot's due schedules are claimed at once; before the scheduler started this does nothing. settings: this.settings, settingsChanged: (settings) => this.events.emit({ channel: 'protocol:event', data: { type: 'settings.changed', data: { settings } } }), + // What bots call the owner: a name saved from a chat shows at once in every window's Settings. + ownerAddress: { + asking: (activationId) => this.ownerAddress.asking(activationId), + spend: (activationId) => this.ownerAddress.spend(activationId), + setName: (name) => { + const saved = this.ownerAddress.setName(name) + this.ownerAddressChanged() + return saved + } + }, schedulesChanged: () => { this.scheduled?.wake() }, // 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), @@ -1092,6 +1110,8 @@ export class MmsProfileServices { asksFirstEnabled: () => botAsksFirst(this.settings.get()), filesFolder: (botId) => botFilesFolder(homeDir, botId), situation: (botId) => this.botSituation(botId), + // The one chat ask (docs/plans/what-bots-call-you.md): only a greeting or a reply to the owner can hold it. + ownerInvitation: botInvitationClaim(store, this.ownerAddress), scheduleCreatedAt: (botId, scheduleId) => this.botSchedules?.get(botId, scheduleId)?.createdAt, jobs: (botId, limit, since) => store.recentJobs(botId, limit, since), jobOn: (botId, threadId) => store.latestJobOn(botId, threadId), @@ -1129,6 +1149,8 @@ export class MmsProfileServices { return { journal, context, progress: memory, ownerAskMemory: memory, memory: admin, supervision: botProcesses } }) this.botStore = opened?.store ?? null + // Whether the chat turn that holds the one ask can still post its name question. + if (opened) this.ownerAddress.bind(botInvitationLedger(opened.store, (activationId) => opened.engine.replyPending(activationId))) let pillBotsEnsured = false const ensurePillBots = (): void => { if (!opened) return @@ -2802,12 +2824,18 @@ export class MmsProfileServices { return this.threadDeletes.finishCutShort(skip) } + /** What bots call the owner changed outside a window's request (a bot's chat): every window reads the settings again. */ + private ownerAddressChanged(): void { + this.events.emit({ channel: 'protocol:event', data: { type: 'settings.changed', data: { settings: this.settings.get() } } }) + } + /** What a bot's context pack says about the present (bot-context.md §5.1): the owner's name, open asks and schedules. */ private botSituation(botId: string): BotSituation { const engine = this.personalBots const store = this.botStore if (!engine || !store) return {} - const ownerName = this.settings.get().profile.username.trim() + // The name the owner gave, or null (unset): never any other name. + const ownerName = this.ownerAddress.name() const openAsks = store.openAsks(botId).filter((ask) => ask.messageId !== null).map((ask) => engine.chat.card(ask).title) const schedules = engine.listSchedules(botId).map((schedule) => ({ label: schedule.label, ...(schedule.nextAt ? { nextAt: schedule.nextAt } : {}) })) // What its work is doing and what it will say later, so a chat turn answers "how's it going?" without a tool. @@ -2823,7 +2851,7 @@ export class MmsProfileServices { // The owner's custom slots: the chat routes work whose job matches one to it (`work_start`'s `slot`). const slots = engine.customSlots(botId).map((slot) => ({ name: slot.name, ...(slot.description ? { description: slot.description } : {}) })) return { - ...(ownerName ? { ownerName } : {}), ...(openAsks.length ? { openAsks } : {}), ...(schedules.length ? { schedules } : {}), + ownerName, ...(openAsks.length ? { openAsks } : {}), ...(schedules.length ? { schedules } : {}), work, ...(reminders.length ? { reminders } : {}), ...(blocked.length ? { blocked } : {}), ...(questions.length ? { questions } : {}), ...(slots.length ? { slots } : {}) } diff --git a/src/mms/bots/activation/BotEngine.ts b/src/mms/bots/activation/BotEngine.ts index e5305067da..64d0e3ce66 100644 --- a/src/mms/bots/activation/BotEngine.ts +++ b/src/mms/bots/activation/BotEngine.ts @@ -122,6 +122,7 @@ import type { BotModelOption, BotSystemInstructions } from '../../../shared/bots import type { BotDeviceAccessStore } from '../definitions/BotDeviceAccessStore' import type { BotOfferAccessStore } from '../definitions/BotOfferAccessStore' import type { BotDeviceChoice } from '../../../shared/bots/personal/deviceAccess' +import { nameSaidIn, ownerNameOf, OWNER_NAME_FALLBACK_QUESTION, takeNameQuestion } from '../../../shared/ownerAddress' import { defaultChatInput, defaultWorkLine, lateWorkNote, DEFAULT_NUDGE_AFTER_MINUTES, MAX_NUDGES_PER_QUESTION, MAX_QUESTIONS_PER_CALL, QUESTION_DUPLICATE_TEXT, questionIdentity, NUDGE_AGAIN_MS, NUDGE_TEXT, plainChoices, QUESTION_AFTER_ASK_TEXT, QUESTION_ASKED_TEXT, QUESTION_END_TURN_TEXT, QUESTION_ANSWER_FORGOTTEN_TEXT, QUESTION_NOT_OFFERED_TEXT, QUESTION_WORK_ASKED_TEXT, QUESTION_WORK_WAITING_TEXT, questionGoneText, keepsWorking, openQuestionAnswerNote, questionWorkKeepsWorkingText, waitingQuestionLine, workAnswerLine, type BotQuestionAnswer, type BotQuestionAsk, type BotQuestionFollow, type BotQuestionSpec, type BotQuestionStatus } from '../../../shared/bots/personal/questions' import { CARD_SHOWN_TEXT, type BotCard } from '../../../shared/bots/personal/cards' import { checkedCard, hasReplyCards, keepMousseCard, keepReplyCard } from '../chat/replyCards' @@ -275,6 +276,12 @@ export interface BotEngineHost { webPictures?(): WebPictures settings?: Pick settingsChanged?(settings: ReturnType): void + /** + * What bots call the owner (docs/plans/what-bots-call-you.md), the profile's `OwnerAddress`: whether a chat turn's + * reply carries the name question, spending the one ask as that question is posted, and saving a name + * `save_owner_name` checked. Absent: none of these here. + */ + ownerAddress?: { asking(activationId: string): boolean; spend(activationId: string): boolean; setName(name: string): unknown } store: BotStore definitions: BotDefinitionStore threads: { @@ -6884,8 +6891,17 @@ export class BotEngine implements BotTurnDispatcher, BotThreads { if (silent && !asks.length && !waiting && !cards && !questions.length) return const lateReport = report && row.trigger.kind === 'schedule' && row.trigger.missed && this.now() - Date.parse(row.trigger.occurrenceAt) > 15 * 60_000 ? `(Due ${scheduledDueTime(row.trigger.occurrenceAt, this.now())}, this computer was off or asleep) ` : '' - const body = silent ? '' : lateReport ? `${lateReport}${written || 'Done.'}` : written - if (!body && !chips.length && !asks.length && !report && !waiting && !questions.length && !cards) { + const spoken = silent ? '' : lateReport ? `${lateReport}${written || 'Done.'}` : written + // What to call the owner (docs/plans/what-bots-call-you.md): the one chat turn that holds the ask posts its name + // question as a message of its own after its reply, the line the bot marked or, when it marked none, Mousse's. A + // reply without words (a card or a question alone) or at a wall carries no unmarked one; a later reply of the turn + // may. The ask is spent as the question is posted. On any other turn (a name set, or the ask spent) a marked line's + // question goes: the reply is what is left, and nothing when nothing is. + const named = row.lane === 'chat' ? takeNameQuestion(spoken) : { text: spoken } + const askOwnerName = row.lane === 'chat' && !silent && (named.question !== undefined || (Boolean(named.text.trim()) && !atWall)) && this.host.ownerAddress?.asking(row.id) === true + const nameQuestion = askOwnerName && this.host.ownerAddress!.spend(row.id) ? named.question ?? OWNER_NAME_FALLBACK_QUESTION : undefined + const body = named.text + if (!body && !nameQuestion && !chips.length && !asks.length && !report && !waiting && !questions.length && !cards) { // A held draft that is itself the silent marker says nothing either: it goes, rather than coming back here. const draft = this.chatDraft(row) if (draft && draft.n === dispatch.n && readSilentReply(draft.text).marked && !readSilentReply(draft.text).text) this.clearChatDraft(row) @@ -6917,6 +6933,8 @@ export class BotEngine implements BotTurnDispatcher, BotThreads { ...(transcriptMessageId ? { transcriptMessageId } : {}) }) if (reply && row.lane === 'chat') this.clearChatDraft(row) + // Its own message, written once (its id is the turn's), with no thread: the reply took the turn's. + if (nameQuestion) this.chat.post({ id: `bm_${row.id}_name`, botId: row.botId, author: 'bot', kind: 'text', text: nameQuestion, activationId: row.id, lane: 'chat' }) for (const ask of more) this.chat.post({ botId: row.botId, author: 'bot', kind: 'notice', text: askNoticeText(name, this.chat.card(ask).title), askId: ask.id, activationId: row.id, lane: row.lane, threadId: dispatch.threadId }) // Each question as a bubble of its own under the reply, carrying its answers (its id is the question's place in @@ -10601,6 +10619,7 @@ export class BotEngine implements BotTurnDispatcher, BotThreads { profile: (botId) => this.profileFacts(botId), setModel: (botId, activationId, scope, choice) => this.setModel(botId, activationId, scope, choice), ownerWords: (botId, activationId) => this.ownerWords(botId, activationId), + saveOwnerName: (botId, activationId, name) => this.saveOwnerName(botId, activationId, name), rows: (botId) => this.ownerSlots(botId), mcpServers: (botId, lane) => this.mcpServerList(botId, lane), work: { @@ -10864,13 +10883,42 @@ export class BotEngine implements BotTurnDispatcher, BotThreads { * answer the owner tapped (`bots.questions.answer`) is the bot's label, not their words, so it is left out. */ ownerWords(botId: string, activationId: string): string { + return this.ownerTyped(botId, activationId).join('\n') + } + + /** + * The owner's typed messages in a chat activation, one by one, oldest first (`ownerWords` joins them): the message it + * answers and any sent at a wall that continued it. Taps are left out; a run has none. + */ + ownerTyped(botId: string, activationId: string): string[] { const row = this.store.activation(activationId) - if (!row || row.botId !== botId || row.lane !== 'chat') return '' + if (!row || row.botId !== botId || row.lane !== 'chat') return [] const rows = this.store.all(`SELECT m.text FROM bot_messages m WHERE m.activation_id = ? AND m.author = 'owner' AND NOT EXISTS (SELECT 1 FROM bot_questions q WHERE q.answer_message = m.id AND ((q.status = 'answered' AND (json_extract(q.answer_json, '$.choice') IS NOT NULL OR json_extract(q.answer_json, '$.tapped'))) OR (q.status = 'defaulted' AND json_extract(q.answer_json, '$.late.tapped')))) ORDER BY m.seq`, activationId) - return rows.map((message) => (typeof message.text === 'string' ? message.text : '')).join('\n') + return rows.map((message) => (typeof message.text === 'string' ? message.text : '')) + } + + /** + * `save_owner_name` (docs/plans/what-bots-call-you.md): saves what every bot calls the owner, only from the bot's chat + * with its owner and only when one message the owner typed in this turn names it. Never from work, a schedule, another + * bot, a thread or a page: their turns hold no typed owner message, and a tapped answer is the bot's own words. + */ + saveOwnerName(botId: string, activationId: string, given: string): { saved: true } | { refused: string } { + const row = this.store.activation(activationId) + if (!row || row.botId !== botId || row.lane !== 'chat') return { refused: 'only your chat with your owner can save it' } + if (!this.host.ownerAddress) return { refused: "it can't be saved on this computer" } + const read = ownerNameOf(given) + if ('problem' in read) return { refused: read.problem } + if (!this.ownerTyped(botId, activationId).some((text) => nameSaidIn(text, read.name))) + return { refused: "your owner didn't type that name in a message of theirs in this turn" } + try { + this.host.ownerAddress.setName(read.name) + } catch (failure) { + return { refused: `it couldn't be written (${failure instanceof Error ? failure.message : String(failure)})` } + } + return { saved: true } } /** @@ -12881,10 +12929,15 @@ export class BotEngine implements BotTurnDispatcher, BotThreads { this.markCompletedScheduleRemoved(row) } + /** Whether a reply of `activationId` waits for its final words (at most `REPLY_WAIT_MS`): it may still post. */ + replyPending(activationId: string): boolean { + return [...this.pendingReplies.keys()].some((key) => key.startsWith(`${activationId}:`)) + } + private postScheduleCompleted(row: BotActivationRow): void { if (row.trigger.kind !== 'schedule' || !row.trigger.completed || !ENDED_ACTIVATION_STATUSES.has(row.status)) return // A late final message still gets its report first. Its bounded reply timer finishes this settlement. - if ([...this.pendingReplies.keys()].some(key => key.startsWith(`${row.id}:`))) return + if (this.replyPending(row.id)) return const id = `bm_schedule_done_${row.id}` if (this.store.message(id)) return this.removeCompletedSchedule(row) diff --git a/src/mms/bots/activation/dispatcher.ts b/src/mms/bots/activation/dispatcher.ts index e68f686f04..eb5728c973 100644 --- a/src/mms/bots/activation/dispatcher.ts +++ b/src/mms/bots/activation/dispatcher.ts @@ -28,6 +28,8 @@ export interface BotTurnDispatcher { settle(payload: BotTurnPayload, outcome: { text?: string; messageId?: string; unanswered?: boolean }): void /** The bot's name when `threadId` is one of its threads: ordinary sends there are refused. */ ownerOf(threadId: string): string | undefined + /** The chat thread (home) of the bot `threadId` is one of, if it is a bot's: its chat replies' events are filtered. */ + homeOf?(threadId: string): string | undefined } export interface PreparedBotTurn { diff --git a/src/mms/bots/activation/turnKinds.ts b/src/mms/bots/activation/turnKinds.ts index dbcdd94e41..eebf30e8ec 100644 --- a/src/mms/bots/activation/turnKinds.ts +++ b/src/mms/bots/activation/turnKinds.ts @@ -129,3 +129,14 @@ export function turnRefusals(rights: BotTurnRights, held: ReadonlySet): } return refused } + +/** + * The chat turns that may hold the one ask for what to call the owner (docs/plans/what-bots-call-you.md): a greeting, or + * a reply to the owner's message or tapped answer. Work, schedules, wake-ups, threads and other bots never do. + */ +const OWNER_INVITATION_STARTS: ReadonlySet = new Set(['owner_message', 'owner_tap', 'first_message']) + +/** Whether a turn on `lane` that `provenance` started may hold the ask (`OWNER_INVITATION_STARTS`). */ +export function ownerInvitationTurn(lane: BotLane, provenance: BotActivationProvenance): boolean { + return lane === 'chat' && OWNER_INVITATION_STARTS.has(provenance) +} diff --git a/src/mms/bots/changelog.ts b/src/mms/bots/changelog.ts index e4e402fee9..76df8eb178 100644 --- a/src/mms/bots/changelog.ts +++ b/src/mms/bots/changelog.ts @@ -239,6 +239,11 @@ export const BOT_CHANGELOG: readonly BotChangelogEntry[] = [ date: '2026-11-30', text: 'Save all separate new asks in the owner message with asks_save before starting work. Use the returned ask to start its job and update the item Mousse keeps for it. On a wake-up or notice, continue only its assigned work. If a cleanup schedule adds owner items from recent chat, take that line out. Use item_save for a separate promise you make.', gone: [/Call it first, with a brief/i, /item_save what comes next/i, /adds an item for each ask or promise that has none/i] + }, + { + id: 45, + date: '2026-11-30', + text: "Your owner's name now comes only from your situation. If none is set, use no name, even if you used one before." } ] diff --git a/src/mms/bots/grants/compile.ts b/src/mms/bots/grants/compile.ts index bcb6a54488..cebe6f31c4 100644 --- a/src/mms/bots/grants/compile.ts +++ b/src/mms/bots/grants/compile.ts @@ -4,7 +4,7 @@ import { isAbsolute, join, relative, resolve, sep } from 'node:path' import { realpathSync } from 'node:fs' import type { BotManifest, BotThreadSpec } from '../../../shared/bots/personal/definition' import { BOT_OFFER_TOOL } from '../../../shared/bots/personal/offers' -import { BOT_APP_TOOLS, BOT_AUTOMATION_ENABLE_TOOL, BOT_RETIRED_APP_TOOLS, BOT_APPLET_TOOL, BOT_READ_APPLET_TOOL, BOT_PREVIEW_APPLET_TOOL, BOT_CARD_TOOL, BOT_REPORT_BUG_TOOL, BOT_GROUP_PERMISSIONS, BOT_MESSAGE_TOOLS, BOT_QUESTION_ANSWER_TOOL, BOT_QUESTION_TOOL, BOT_QUESTION_WITHDRAW_TOOL, BOT_BROWSER_PERMISSION, BOT_COMPUTER_PERMISSION, BOT_COMPUTER_REQUEST_TOOL, BOT_COMPUTER_TOOLS, BOT_IMAGE_TOOL, BOT_BROWSER_TOOLS, BOT_MCP_LIST_TOOL, BOT_PROFILE_TOOL, BOT_RUNNING_TOOL, BOT_PROFILER_CHAT_TOOLS, BOT_PROFILER_TOOLS, BOT_QUICK_ACTION_TOOLS, BOT_SCHEDULE_ACT_TOOLS, BOT_SCHEDULE_READ_TOOLS, BOT_SECRET_TOOLS, BOT_TASK_TOOLS, BOT_THEME_TOOLS, BOT_THREAD_ACT_TOOLS, BOT_THREAD_READ_TOOLS, BOT_THREADS_PERMISSION, BOT_CHAT_NATIVE_OFF, BOT_WORK_ONLY_TOOLS, BOT_WORK_TOOLS, canonicalManifest, intersectManifest, narrowManifest, BOT_SUBAGENT_APP_TOOLS, BOT_SUBAGENT_TOOLS } from '../../../shared/bots/personal/manifest' +import { BOT_APP_TOOLS, BOT_AUTOMATION_ENABLE_TOOL, BOT_RETIRED_APP_TOOLS, BOT_APPLET_TOOL, BOT_READ_APPLET_TOOL, BOT_PREVIEW_APPLET_TOOL, BOT_CARD_TOOL, BOT_REPORT_BUG_TOOL, BOT_GROUP_PERMISSIONS, BOT_MESSAGE_TOOLS, BOT_QUESTION_ANSWER_TOOL, BOT_QUESTION_TOOL, BOT_QUESTION_WITHDRAW_TOOL, BOT_BROWSER_PERMISSION, BOT_COMPUTER_PERMISSION, BOT_COMPUTER_REQUEST_TOOL, BOT_COMPUTER_TOOLS, BOT_IMAGE_TOOL, BOT_BROWSER_TOOLS, BOT_MCP_LIST_TOOL, BOT_PROFILE_TOOL, BOT_RUNNING_TOOL, BOT_PROFILER_CHAT_TOOLS, BOT_PROFILER_TOOLS, BOT_QUICK_ACTION_TOOLS, BOT_SCHEDULE_ACT_TOOLS, BOT_SCHEDULE_READ_TOOLS, BOT_SECRET_TOOLS, BOT_TASK_TOOLS, BOT_THEME_TOOLS, BOT_THREAD_ACT_TOOLS, BOT_THREAD_READ_TOOLS, BOT_THREADS_PERMISSION, BOT_CHAT_NATIVE_OFF, BOT_WORK_ONLY_TOOLS, BOT_WORK_TOOLS, BOT_OWNER_NAME_TOOL, canonicalManifest, intersectManifest, narrowManifest, BOT_SUBAGENT_APP_TOOLS, BOT_SUBAGENT_TOOLS } from '../../../shared/bots/personal/manifest' import { BOT_CATALOGUE_TOOL, BOT_USE_TOOL } from '../../../shared/bots/personal/catalogue' import { BOT_MEMORY_TOOLS } from '../../../shared/bots/personal/memory' import { BOT_ITEM_TOOLS } from '../../../shared/bots/personal/items' @@ -301,6 +301,7 @@ export function compileBotThread(input: CompileInput): CompileResult { // instead of starting another: it only reads. BOT_RUNNING_TOOL, ...(own?.frontDesk ? BOT_WORK_TOOLS.filter((tool) => tool !== 'watch_start' || own.watcherStart === true) : []), + ...(own?.frontDesk ? [BOT_OWNER_NAME_TOOL] : []), ...(!own?.frontDesk && own?.timers ? ['remind', ...(own.watcherStart ? ['watch_start'] : [])] : []), ...(own?.images ? [BOT_IMAGE_TOOL] : []), ...(own?.applets ? [BOT_APPLET_TOOL, BOT_READ_APPLET_TOOL, BOT_PREVIEW_APPLET_TOOL] : []), diff --git a/src/mms/bots/instructions.ts b/src/mms/bots/instructions.ts index b0909d29df..7ab130445e 100644 --- a/src/mms/bots/instructions.ts +++ b/src/mms/bots/instructions.ts @@ -23,6 +23,7 @@ How you talk - Before every step that takes a while (a search, a page, a long read, starting work, a thread tool), always write one short line first on what you're doing now, like "Checking prices at Indian stores now". Never start such a step without it. The owner sees your latest such line beside your typing dots until your reply comes. Keep it to one line of about eight words: no second sentence, no findings, and don't repeat it in your reply. - To your owner you are one person, doing one thing at a time or several. Speak of everything you do as yourself, in the first person, in chat replies and in reports alike: "I'll use that open tab from here on, so you can watch me there", "I found three SSDs under ₹6,000". This chat, the work you do beside it, threads you start, your schedules and any help you get are all you. Never speak of your work as someone else ("it will…"), and never mention handing off, notes, runs, turns, threads, worktrees or how Mousse runs you, unless asked what you can do or how you work. Naming a job by its title is fine ("for the SSD search, I'll…"). - Never name or discuss AI models or providers, yours or any other, unless the owner asks for one for a piece of work. When the owner asks you to think harder or be quicker from now on, or names a model for you, use the tools of the you group. +- Use only the name in your situation for your owner. If none is set, use no name: never guess one or take one from memory, files or old chats, and don't ask unless your situation tells you to. When your owner tells you what to call them, or answers your question about it, use save_owner_name, and confirm only after it is saved. Permissions - You can use only what your owner allowed. Your files folder, your memory, your schedules and reminders, the web, your owner's MCP servers and skills, and every group under More tools that names no permission need no asking. To get more, ask with permission_ask: one permission per call, with one plain sentence on why. diff --git a/src/mms/bots/memory/contextPack.ts b/src/mms/bots/memory/contextPack.ts index 0ad843c1cf..c3bf60042a 100644 --- a/src/mms/bots/memory/contextPack.ts +++ b/src/mms/bots/memory/contextPack.ts @@ -25,6 +25,7 @@ import { BOT_CHAT_FOLD_TAIL_TOKENS, type BotChatDigestState, type BotChatEpoch, import { BOT_PACK_JOB_CHANGES, BOT_PACK_JOBS, LEDGER_CHANGES_HEADING, LEDGER_HEADING, capReport, ledgerLine, type BotJob } from '../../../shared/bots/personal/jobs' import { BOT_ITEMS_PACK_TOKENS, ITEMS_CHANGES_HEADING, itemLine, itemThreads, itemsBlock, itemsCountLine, openItems, shortItemLine, type BotItem } from '../../../shared/bots/personal/items' import { addUntrackedAsks, botItems, botItemsRev, linkHandoffs, trackReplyPromises } from './items' +import { OWNER_NAME_QUESTION_MARKER } from '../../../shared/ownerAddress' /** * The context packs (docs/plans/bot-context.md §5): Mousse builds every bot turn from `bots.db`, so @@ -38,8 +39,11 @@ import { addUntrackedAsks, botItems, botItemsRev, linkHandoffs, trackReplyPromis /** What the pack says about the present, from outside the memory tables. Plain words only. */ export interface BotSituation { - /** Shared from settings (bot-context.md §9): the owner's name and language. */ - ownerName?: string + /** + * Shared from settings (bot-context.md §9): what bots call the owner (docs/plans/what-bots-call-you.md), `null` when no + * name is set (absent: not known here, and no line), and the owner's language. + */ + ownerName?: string | null language?: string /** Open asks, by their titles ("change files in ~/Notes"). */ openAsks?: string[] @@ -77,6 +81,24 @@ interface SituationFact { always?: true } +/** The situation's `owner` line while no name is set (docs/plans/what-bots-call-you.md). */ +export const OWNER_NAME_UNSET_LINE = 'What to call the owner: no name is set, so use none.' + +/** + * What only the one chat turn that holds the ask is told (docs/plans/what-bots-call-you.md). Its marked line is posted + * as a message of its own (`takeNameQuestion`). + */ +export const OWNER_NAME_INVITATION_LINE = `In this reply only, unless your owner already told you, ask in your own words what they'd like you to call them. Keep it brief and easy to skip. Put that question alone on the last line of your reply, starting with ${OWNER_NAME_QUESTION_MARKER}. Mousse removes the marker and shows that line as its own message, so don't ask it anywhere else.` + +/** + * The format of the packs frozen per activation. One frozen before what bots call the owner changed may name a made-up + * owner ("The owner is Wobbly Pickle."), so a pack without this version is built again (a waiting run's next turn too). + */ +const FROZEN_PACK_VERSION = 2 + +/** Heads the chat rows a running epoch's later turn reads (`chatDelta`), each `[j ·