Skip to content
Merged
1 change: 1 addition & 0 deletions docs/bots.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ Every bot has `secret_request` without asking, `secret_fetch` in its chat and it

- **Pasting a key.** The desktop bot composer offers “Keep as secret” for recognized credential shapes, not for every possible secret. It recognizes provider-prefixed keys, labelled AWS secret access keys and AWS pairs across CSV, JSON, environment lines and prose, private-key blocks, credential URLs with long, varied token values (including OAuth fragments and signed S3/GCS links) and an Authorization Bearer line. Bare JWTs, arbitrary passwords, attached files (including dropped `.env` files), and text pastes of 32 KB or more that become attachments are not checked. Choose the private card's keep time (24 hours by default); the value goes to the local vault for the bot's home thread under a free, service-specific name. The composer replaces the matched span with “the secret NAME” for review; an AWS pair keeps the secret half and leaves the access key ID visible. Private drafts survive chat switches in window memory only, including text added by applets and memory quotes. A successful save says “Kept as NAME” even if it finished after an edit or while another chat was open. The notice clears on the next edit or Send; remembered copies expire with the keep time or clear on Send. A save that finishes after the window reloads cannot be announced there; the saved secret is still listed in Settings → Secrets. An AWS access key ID alone is public: paste its secret access key too. With temporary credentials (`ASIA…`), the session token stays in the message; it is useless without the secret access key. Send as text keeps unsaved text unchanged; ignoring the offer takes one extra Send. A refused save leaves the key private and explains the error. Phones are unchanged: secrets and this offer are desktop-only.

- **`/secform`.** The owner opens the form without waiting to be asked: `/secform` (one field), `/secform 3`, or `/secform for email, password and openrouterkey` (named fields, read in the composer by `parseSecform`; plain words such as email are shown as typed, the rest masked). The same command works in an agent thread. The form adds fields and sets when they expire (1 hour, 1 day, 7 days or never), who may use them (the thread, or a bot of this computer) and single use. Save securely sends the values once to the secret store of the computer that runs the thread (`secrets.share`; for a thread of another computer, over the encrypted link, routed with the values left out of the request ledger's match). The chat shows a chip, “Shared N secrets: NAMES · expires in …”, with Revoke; it reads expired or revoked once they end. The agent, or the bot, gets a quiet note with the names only, read with its next turn (`secretShareNote`). A single-use secret gets no readable file and is deleted after the first `secret_run` that names it. A bot of another computer is not offered the form yet.
- **The card.** `secret_request` opens the same private card a thread shows (`SecretRequests`), filed under the bot's chat thread whichever of its turns asked (`botHomeOf`), and the bot's chat shows it above the composer (`BotSecretRequests`). The owner types the secret there, or picks a saved one, never in the chat; the bot gets only its name. A bot's turn answers no approvals, but this ask reaches its owner (`MousseTool.botAsksOwner`), so the call waits for the answer, up to the card's hour, as a thread's does.
- **Bound to one service.** A bot may ask with `for: { service: "openai" }` (also anthropic, github, stripe, notion or huggingface), or `for: { origin: "https://api.example.com" }`. The private card names the service or host and says “read only”.
- **Where the key goes.** Mousse keeps the value for requests to that origin, in one fixed header, with known services limited to listed API paths. Notion and Anthropic also have fixed version headers (`Notion-Version` and `anthropic-version`).
Expand Down
5 changes: 5 additions & 0 deletions src/main/mms/protocolEventBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ export function bridgeProtocolEvent(
if (threadId != null) broadcast('secrets:requestsChanged', { threadId })
return true
}
case 'secrets.shares.changed': {
// Only the thread id: a window reads the thread's shared secrets (`/secform`) itself.
if (threadId != null) broadcast('secrets:sharesChanged', { threadId })
return true
}
case 'computerUse.setupRequest.changed': {
// Only the thread id: a window reads the thread's setup card itself.
if (threadId != null) broadcast('computerUse:setupRequestChanged', { threadId })
Expand Down
18 changes: 17 additions & 1 deletion src/mms/MmsProfileServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { BugReportService } from './bugReports/BugReportService'
import { WebPictures } from './webPictures/WebPictures'
import { createGhFallbackRunner, execRunner } from './git/ghRunner'
import { userAction } from './git/gitPolicy'
import { SecretShares } from './secrets/SecretShares'
import { SecretRequests } from './secrets/SecretRequests'
import { createSecretToolHost } from './secrets/secretToolHost'
import { forgetWorktreeFolders, refreshWorktreeFolders, setWorktreeFolders } from './worktree/worktreeLayout'
Expand Down Expand Up @@ -1608,9 +1609,23 @@ export class MmsProfileServices {
// A subagent's thread is masked with its parents' secrets: their agents may hand it the value.
ancestorsOf: (threadId) => threadAncestors(this.threads, threadId),
threadBusy: (threadId) => secretThreadBusy(threadId, this.orchestrator, this.runEngine),
changed: () => this.secretsChanged.emit('changed')
changed: () => {
this.secretsChanged.emit('changed')
this.secretShares?.storeChanged()
},
usedUp: (name, shareId) => this.secretShares?.usedUp(name, shareId)
})
this.secretRequests = new SecretRequests(this.secretVault)
// Secrets a person shares with /secform (asks i121, i125): kept in the same store, for the thread or bot chosen.
this.secretShares = new SecretShares({
profileRoot: homeDir,
vault: this.secretVault,
threadAlive: (threadId) => Boolean(this.threads.getThread(threadId)),
botHome: (botId) => {
if (!this.personalBots) throw new Error('Bots are not available.')
return this.personalBots.service.secretHome(botId)
}
})
const vault = this.secretVault
// Bug reports (Settings → General → Error reports): the Report button's and report_bug's filing.
const runner = createGhFallbackRunner(execRunner)
Expand Down Expand Up @@ -2505,6 +2520,7 @@ export class MmsProfileServices {
automationKeys!: { list(): string[]; set(name: string, value: string): void; has(name: string): boolean }
/** Secrets agents asked for in threads, over the profile's secret store (#595). */
secretVault!: SecretVault
secretShares?: SecretShares
secretRequests!: SecretRequests
/** Emits `changed` when a secret is added, used, removed or expires (Settings → Secrets refreshes). */
readonly secretsChanged = new EventEmitter()
Expand Down
21 changes: 21 additions & 0 deletions src/mms/MousseMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { registerComputerUseMethods } from './computerUse/registerMethods'
import { registerSourceControlMethods } from './sourceControl/registerMethods'
import { GitHubAccount } from './git/GitHubAccount'
import { registerSecretMethods } from './secrets/registerMethods'
import { secretShareNote } from './secrets/secretShareNote'
import { registerBugReportMethods } from './bugReports/registerMethods'
import { registerWorkflowDefinitionMethods } from './workflows/registerDefinitionMethods'
import { registerWorkflowRunMethods } from './workflows/registerRunMethods'
Expand Down Expand Up @@ -414,6 +415,26 @@ export class MousseMainService extends MmsProfileServices {
if (!services.personalBots) throw new Error('Bots are not available.')
return services.personalBots.service.secretHome(botId)
} },
shares: services.secretShares ? {
share: (input) => {
const { usableIn, ...share } = services.secretShares!.share(input)
const text = secretShareNote(share)
const bot = share.botId ? services.personalBots?.service : undefined
// A bot's chat keeps a quiet line the bot reads next turn, drawn as the chip there.
// The values are kept already: a line that could not be written must not read as a failed save (a retry would share twice).
if (share.botId && bot) {
try { bot.postSecretShare(share.botId, share.shareId, text) }
catch (error) { console.warn('the bot could not be told the names of shared secrets', { shareId: share.shareId, error: error instanceof Error ? error.message : String(error) }) }
}
// An agent thread shows the chip, and its agent (when it may use them) gets the names with its next turn.
if (share.threadId !== usableIn || !share.botId) {
services.orchestrator.recordSecretShare(share.threadId, share, share.botId ? undefined : { threadId: usableIn, text })
}
return share
},
list: (threadId) => services.secretShares!.list(threadId),
revoke: (threadId, shareId) => services.secretShares!.revoke(threadId, shareId)
} : undefined,
list: () => services.secretVault.list(),
delete: (name) => services.secretVault.delete(name)
}
Expand Down
9 changes: 9 additions & 0 deletions src/mms/bots/chat/BotChatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { pictureInfos, pictureThumbs, type PictureInfos } from '../../pictures/P
import type { PictureThumbs } from '../../pictures/PictureThumbs'
import { describedInOrder, localPictureFiles, withMessagePictures, type PictureFiles } from './messagePictures'
import { turnTimingBegin, turnTimingBotMark, turnTimingForget } from '../../diagnostics/turnTiming'
import { SECFORM_LINE_PREFIX } from '../../../shared/secform'

/**
* The Bot UI's daemon side (Bot Phase 1 §5.3, §5.11): create a bot from a look and a sentence,
Expand Down Expand Up @@ -499,6 +500,14 @@ export class BotChatService {
* The local vault resolves its recipient here, never from a window's thread id. Every bot may be given secrets: one
* with an approved grant may keep a pasted key.
*/
/**
* `/secform` in the bot's chat: a quiet line from Mousse that names the secrets, which the bot reads with its next turn
* and the chat shows as the chip. It wakes nothing.
*/
postSecretShare(botId: string, shareId: string, text: string): void {
this.engine.chat.post({ id: `${SECFORM_LINE_PREFIX}${shareId}`, botId, author: 'bot', kind: 'notice', text, quiet: true, lane: 'chat' })
}

secretHome(botId: string): { threadId: string; allowed: boolean } {
this.engine.definitionOf(botId)
const threadId = this.store.registry(botId)?.homeThreadId
Expand Down
5 changes: 4 additions & 1 deletion src/mms/bots/chat/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ import { takeToolImages } from './toolImages'
import { takeReplyCards } from './replyCards'
import { readSilentReply, WAKE_LINE_PREFIX, wakeEventLabel } from '../../../shared/bots/personal/wakes'
import { BOT_FOLD_LINE_PREFIX, BOT_FOLD_LINE_TITLE } from '../../../shared/bots/personal/memory'
import { SECFORM_LINE_PREFIX } from '../../../shared/secform'

function isServiceLine(id: string): boolean {
return ['bm_asks_first_', 'bm_permission_', 'bm_schedule_ended_', 'bm_schedule_done_', WAKE_LINE_PREFIX, BOT_FOLD_LINE_PREFIX].some(prefix => id.startsWith(prefix))
return ['bm_asks_first_', 'bm_permission_', 'bm_schedule_ended_', 'bm_schedule_done_', WAKE_LINE_PREFIX, BOT_FOLD_LINE_PREFIX, SECFORM_LINE_PREFIX].some(prefix => id.startsWith(prefix))
}
import type { AppletReference } from '../../../shared/applets'
import { BOT_USAGE_WINDOW_MS, botContextSummary, turnUsageSummary } from '../activation/turnUsage'
Expand Down Expand Up @@ -448,6 +449,8 @@ export class BotChatProjection {
...(row.kind === 'notice' && isServiceLine(row.id) ? { systemLine: true as const } : {}),
// A fold's line says what happened on hover (docs/plans/bot-context.md §14).
...(row.kind === 'notice' && row.id.startsWith(BOT_FOLD_LINE_PREFIX) ? { systemTitle: BOT_FOLD_LINE_TITLE } : {}),
// Secrets shared with /secform: the chat shows the form's chip instead of the words the bot reads.
...(row.kind === 'notice' && row.id.startsWith(SECFORM_LINE_PREFIX) ? { secretShare: { shareId: row.id.slice(SECFORM_LINE_PREFIX.length) } } : {}),
text: plain ? (said ? `${said}\n\n${plain}` : plain) : said,
...(plain ? { plainFrom: said.length } : {}),
...(cards.length ? { cards } : {}),
Expand Down
6 changes: 5 additions & 1 deletion src/mms/bridge/routed/OwnerRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { NodeCapability } from '../../../shared/net'
import {
ROUTED_AGENT_BOT_KEY,
ROUTED_DISPLAY_ONLY_KEYS,
ROUTED_SECRET_KEYS,
ROUTED_AGENT_CHAIN_KEY,
ROUTED_AGENT_KEY,
routedKeyForbidden,
Expand Down Expand Up @@ -724,7 +725,10 @@ export class OwnerRoutes {
}
: {}),
// A display-only key (a bot's name and face) is no part of what a retry is matched on (#2010).
...(ROUTED_DISPLAY_ONLY_KEYS[method] ? { ledgerMatch: (params: unknown) => withoutKeys(params, ROUTED_DISPLAY_ONLY_KEYS[method]!) } : {}),
// Nor is a secret value (`/secform`): the ledger keeps no hash of one.
...(ROUTED_DISPLAY_ONLY_KEYS[method] || ROUTED_SECRET_KEYS[method]
? { ledgerMatch: (params: unknown) => withoutKeys(params, [...(ROUTED_DISPLAY_ONLY_KEYS[method] ?? []), ...(ROUTED_SECRET_KEYS[method] ?? [])]) }
: {}),
handle: (params, context) =>
this.options.track(this.run(method, row, params as Record<string, unknown>, context))
}
Expand Down
21 changes: 20 additions & 1 deletion src/mms/orchestrator/OrchestratorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6312,6 +6312,24 @@ export class OrchestratorService extends EventEmitter {
}
}

/**
* `/secform`: the person shared secrets in this thread. The chat gets the chip's row (`secretShare`); the agent that
* may use them (`usableIn`: this thread, or a thread a bot works in) gets `note`, quiet, with its next turn. Both name
* the secrets only: their values never pass through here.
*/
recordSecretShare(threadId: string, share: { shareId: string; names: string[] }, note: { threadId: string; text: string } | undefined): void {
this.sessionAls.run(this.getOrCreateSession(threadId), () => this.addSystemMessage(`Shared ${share.names.join(', ')} with /secform.`, undefined, undefined, undefined, share))
if (!note) return
const payload: AgentNotePayload = {
kind: 'agent_note', senderThreadId: threadId, senderRunId: '', senderTitle: null, senderAccess: 'agent', from: 'relay', attention: 'none', text: note.text
}
try {
postNote(this.requireRunEngine(), `secform:${share.shareId}`, payload, note.threadId)
} catch (error) {
console.warn('the agent could not be told the names of shared secrets', { shareId: share.shareId, error: error instanceof Error ? error.message : String(error) })
}
}

/** Tells a held message's sender what became of it, with a quiet note from Mousse it reads with its next turn. */
private tellHoldSender(hold: ChainHoldRecord, outcome: string): void {
// A sender on another computer has no thread here to tell: it was told its message is held, and ended its turn.
Expand Down Expand Up @@ -14309,12 +14327,13 @@ export class OrchestratorService extends EventEmitter {
* `kind` `warning`: a line the thread shows, quiet, as Mousse's own (`ThreadNotice`). Others are not shown, the note
* of a launched thread (`launchedThread`) among them.
*/
private addSystemMessage(content: string, end?: { turnId?: string; turnEnd: TurnEnd }, kind?: 'warning', launchedThread?: ChatMessage['launchedThread']): void {
private addSystemMessage(content: string, end?: { turnId?: string; turnEnd: TurnEnd }, kind?: 'warning', launchedThread?: ChatMessage['launchedThread'], secretShare?: ChatMessage['secretShare']): void {
const msg: ChatMessage = {
id: uuidv4(),
role: 'system',
...(kind ? { kind } : {}),
...(launchedThread ? { launchedThread } : {}),
...(secretShare ? { secretShare: { shareId: secretShare.shareId, names: [...secretShare.names] } } : {}),
content,
timestamp: new Date().toISOString(),
...(end?.turnId ? { turnId: end.turnId } : {}),
Expand Down
7 changes: 7 additions & 0 deletions src/mms/protocol/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,13 @@ export class MmsProtocolServer {
emitToSubscribers(this.ring.push('secrets.requests.changed', { threadId: payload.threadId }, payload.threadId))
})
}
// Secrets shared with /secform: only the thread id travels; a window reads the thread's chips itself.
const secretShares = services.secretShares
if (secretShares) {
onEmitter(secretShares, 'changed', (payload: { threadId: string }) => {
emitToSubscribers(this.ring.push('secrets.shares.changed', { threadId: payload.threadId }, payload.threadId))
})
}
// Computer use setup cards: only the thread id travels; a window of this computer reads the card itself. Nothing
// waits on one, so the thread's state stays as it is.
const computerSetup = typeof services.orchestrator.computerUseSetup === 'function' ? services.orchestrator.computerUseSetup() : undefined
Expand Down
2 changes: 2 additions & 0 deletions src/mms/protocol/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ export type ProtocolEventType =
| 'questions.pending'
| 'questions.cleared'
| 'secrets.requests.changed'
| 'secrets.shares.changed'
| 'computerUse.setupRequest.changed'
| 'secrets.changed'
| 'pty.data'
Expand Down Expand Up @@ -732,6 +733,7 @@ export type ProtocolEventType =
| 'questions.pending'
| 'questions.cleared'
| 'secrets.requests.changed'
| 'secrets.shares.changed'
| 'computerUse.setupRequest.changed'
| 'secrets.changed'
| 'pty.data'
Expand Down
4 changes: 2 additions & 2 deletions src/mms/run/mcp/appTools/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const REQUEST_DEFINITION: Tool = {
const RUN_DEFINITION: Tool = {
name: 'secret_run',
description: [
'Run one shell command in the thread\'s project folder with secrets the user gave this thread (through secret_request).',
'Run one shell command in the thread\'s project folder with secrets the user gave this thread (through secret_request, or shared with /secform).',
'Each secret is the environment variable of its name (as: "env", the default), or a private file whose path is in NAME_FILE',
'(as: "file"); the file is deleted when the command ends. Refer to the variable in the command (e.g. "$HF_TOKEN"), never the value.',
'The output comes back with every secret masked, and Authorization headers hidden.',
Expand Down Expand Up @@ -247,7 +247,7 @@ export function secretTools(host: AppToolHost): MousseTool[] {
approvalPrompt: 'Allow the agent to run this command with a secret you gave this thread?',
// A personal bot's owner allowed "use secrets you give it" and "run commands": that is its answer, so nothing asks.
botGrantAnswers: true,
botDescription: 'Run a command from your files folder with secrets your owner gave you (secret_request): each as an environment variable (default) or a private file, by name. Its output is masked. It runs without asking first, as your other commands do: from your files folder, with none of your owner\'s other settings or credentials, only the secrets you name. With your command sandbox on it runs there (only your folders, and the network as your owner set it); with it off, like your owner\'s own commands. Use it only for the work your owner asked for.',
botDescription: 'Run a command from your files folder with secrets your owner gave you (secret_request, or shared with /secform): each as an environment variable (default) or a private file, by name. Its output is masked. It runs without asking first, as your other commands do: from your files folder, with none of your owner\'s other settings or credentials, only the secrets you name. With your command sandbox on it runs there (only your folders, and the network as your owner set it); with it off, like your owner\'s own commands. Use it only for the work your owner asked for.',
class: 'mutation',
listed: () => Boolean(secrets()),
available: (turn) => (secrets() ? runAvailable(turn) : 'secret_run is not available here.'),
Expand Down
Loading
Loading