Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
feat(plugins): flatter, clearer plugin menus (WhatsApp 0.1.1, Optimus 0.4.5)
Salman Qureshi3ce26acf06e2
diff --git a/plugins/optimus/companion/Cargo.toml b/plugins/optimus/companion/Cargo.tomlindex fdce6f09..886e1548 100644--- a/plugins/optimus/companion/Cargo.toml+++ b/plugins/optimus/companion/Cargo.toml@@ -1,6 +1,6 @@[package]name = "mercury-optimus"-version = "0.4.4"+version = "0.4.5"edition = "2024"rust-version = "1.94"description = "Optimus: full computer control for Mercury (screen, mouse, keyboard, apps, voice)"diff --git a/plugins/optimus/mercury-plugin.template.json b/plugins/optimus/mercury-plugin.template.jsonindex 9e4911bf..554aed1d 100644--- a/plugins/optimus/mercury-plugin.template.json+++ b/plugins/optimus/mercury-plugin.template.json@@ -2,7 +2,7 @@"manifestVersion": 1,"id": "optimus","name": "Optimus",- "version": "0.4.4",+ "version": "0.4.5","description": "Mercury uses your computer like a person: sees the screen, moves the mouse, types and opens apps, by chat or out loud with a talk key. macOS, Windows and Linux. Asks before anything that submits, sends, pays or deletes.","kind": "out-of-process","author": "Cosmic Stack",@@ -127,11 +127,15 @@"fields": {"allowControl": {"type": "boolean",- "label": "Let Optimus control this computer?",+ "label": "Control this computer","description": "Optimus sees your screen and uses the mouse and keyboard in any app. It asks before anything that submits, sends, pays, deletes or installs, and stops the moment you move the mouse.","default": false,"setup": true,- "required": true+ "required": true,+ "optionLabels": {+ "true": "On: Optimus can see your screen and use the mouse and keyboard",+ "false": "Off: Optimus does nothing until you turn it on"+ }},"mode": {"type": "enum",@@ -143,7 +147,7 @@"default": "both","setup": true,"required": true,- "label": "How do you want to talk to Optimus?",+ "label": "How you talk to Optimus","description": "Chat: type to Mercury as usual. Listening: press a key, talk, and hear Mercury answer while it works on your screen.","optionLabels": {"both": "⭐ Both: chat, plus a key to talk out loud (recommended)",@@ -168,38 +172,53 @@"showOverlay": {"type": "boolean","default": true,- "label": "Show \"Mercury is driving\" by the pointer",- "description": "A ring around the pointer and a small label while Optimus moves the mouse, so it's clear the agent is in control. Never appears in Optimus's own screenshots."+ "label": "\"Mercury is driving\" ring by the pointer",+ "description": "A ring around the pointer and a small label while Optimus moves the mouse, so it's clear the agent is in control. Never appears in Optimus's own screenshots.",+ "optionLabels": {+ "true": "On: a ring and label follow the pointer while Mercury drives",+ "false": "Off: no ring or label"+ }},"hotkey": {"type": "string","default": "ctrl+alt+m","setup": true,- "label": "Key to start and stop talking",+ "label": "Talk key","description": "Press it to start listening, press again to stop (or say goodbye). While Mercury is speaking, pressing it interrupts. Examples: ctrl+alt+m, ctrl+shift+space, f9. On a Mac, alt is Option and cmd is Command.","when": {"mode": ["voice","both"]- }+ },+ "examples": [+ "ctrl+alt+m",+ "ctrl+shift+space",+ "ctrl+alt+space",+ "f9"+ ]},"muteHotkey": {"type": "string","default": "ctrl+alt+shift+m",- "label": "Key to mute and unmute",+ "label": "Mute key","description": "While talking: Optimus stops listening (nothing you say is sent anywhere) but keeps working and still speaks. Press again, or press the talk key, to unmute. Saying \"mute\" also mutes.","when": {"mode": ["voice","both"]- }+ },+ "examples": [+ "ctrl+alt+shift+m",+ "ctrl+alt+n",+ "f10"+ ]},"bargeIn": {"type": "boolean","default": false,- "label": "I use headphones (let me interrupt by talking)",+ "label": "Headphones","description": "With speakers, Optimus mutes the mic while Mercury talks so it doesn't hear itself; press the key to interrupt. With headphones, turn this on to interrupt just by talking.","group": "voice","when": {@@ -207,12 +226,16 @@"voice","both"]+ },+ "optionLabels": {+ "true": "On: I use headphones, so I can interrupt just by talking",+ "false": "Off: speakers, so the mic waits while Mercury talks (press the talk key to interrupt)"}},"thinkingSound": {"type": "boolean","default": true,- "label": "Soft \"tick… tock\" while Mercury works",+ "label": "Tick-tock while working","description": "A quiet wooden tick-tock while Mercury searches or works on your screen and nobody is talking, so you know it's still going. It's well below speech level and never mutes your mic.","group": "voice","when": {@@ -220,12 +243,16 @@"voice","both"]+ },+ "optionLabels": {+ "true": "On: a soft tick… tock while Mercury searches or works",+ "false": "Off: silence while it works"}},"idleStopSeconds": {"type": "number","default": 60,- "label": "Stop listening after this much silence (seconds)",+ "label": "Stop listening after silence (seconds)","description": "The mic closes by itself when you haven't spoken for this long and Mercury isn't working on something, so it never streams (and costs) for nothing. 0 keeps listening until you press the key or say bye.","group": "voice","when": {@@ -233,7 +260,13 @@"voice","both"]- }+ },+ "examples": [+ "30",+ "60",+ "120",+ "0"+ ]},"voiceEngine": {"type": "enum",@@ -799,7 +832,12 @@"voice","both"]- }+ },+ "examples": [+ "15",+ "30",+ "60"+ ]}},"groups": {diff --git a/plugins/whatsapp/mercury-plugin.template.json b/plugins/whatsapp/mercury-plugin.template.jsonindex a9ae065e..4164dc73 100644--- a/plugins/whatsapp/mercury-plugin.template.json+++ b/plugins/whatsapp/mercury-plugin.template.json@@ -2,7 +2,7 @@"manifestVersion": 1,"id": "whatsapp","name": "WhatsApp",- "version": "0.1.0",+ "version": "0.1.1","description": "Chat with Mercury on WhatsApp and talk to it by voice call: OpenAI by default, or Gemini, Grok, ElevenLabs, Azure, Qwen, or your own Mercury model with Deepgram/Cartesia/MiniMax/Sarvam voices. Runs on a spare number as a linked device (unofficial protocol).","kind": "out-of-process","author": "Cosmic Stack",@@ -75,14 +75,14 @@"when": {"voiceEngine": "openai"},- "alternative": "Or pick another voice in /plugins whatsapp \u2192 \ud83c\udf99 Voice calls."+ "alternative": "Or pick another voice in /plugins whatsapp → 🎙 Voice calls."},"grok": {"unlocks": "Voice calls with Grok","when": {"voiceEngine": "grok"},- "alternative": "Or pick another voice in /plugins whatsapp \u2192 \ud83c\udf99 Voice calls."+ "alternative": "Or pick another voice in /plugins whatsapp → 🎙 Voice calls."}}},@@ -138,7 +138,11 @@"type": "boolean","description": "Answer in WhatsApp groups (owner and members only).","default": false,- "label": "Answer in WhatsApp groups"+ "label": "Answer in WhatsApp groups",+ "optionLabels": {+ "true": "On: Mercury answers in groups when someone mentions it",+ "false": "Off: Mercury only answers in one-to-one chats"+ }},"answerCalls": {"type": "boolean",@@ -146,7 +150,11 @@"default": true,"label": "Answer your voice calls","setup": false,- "group": "voice"+ "group": "voice",+ "optionLabels": {+ "true": "On: Mercury picks up when you call it",+ "false": "Off: your calls to Mercury ring out"+ }},"voiceEngine": {"type": "enum",@@ -164,7 +172,7 @@"mercury"],"optionLabels": {- "openai": "\u2b50 OpenAI Realtime: recommended for the best calls (uses your OpenAI key)",+ "openai": "⭐ OpenAI Realtime: recommended for the best calls (uses your OpenAI key)","gemini": "Google Gemini Live: cheapest, free tier, Hindi and Urdu","grok": "xAI Grok Voice: uses your Grok provider","elevenlabs": "ElevenLabs Realtime (experimental)",@@ -580,19 +588,29 @@"description": "Most times Mercury may call you in an hour.","default": 4,"label": "Most calls from Mercury per hour",- "group": "voice"+ "group": "voice",+ "examples": [+ "2",+ "4",+ "8"+ ]},"maxCallMinutes": {"type": "number","description": "Longest a call can last, in minutes.","default": 15,"label": "Longest call, in minutes",- "group": "voice"+ "group": "voice",+ "examples": [+ "10",+ "15",+ "30"+ ]}},"groups": {"voice": {- "label": "\ud83c\udf99 Voice calls",+ "label": "🎙 Voice calls","description": "Who listens and speaks when you call Mercury (or it calls you). OpenAI is recommended for the best results; every other option works too.","readyUnless": ["provider:openai",diff --git a/src/plugins/commands.test.ts b/src/plugins/commands.test.tsindex e3b174ed..3759c656 100644--- a/src/plugins/commands.test.ts+++ b/src/plugins/commands.test.ts@@ -58,7 +58,8 @@ describe('guided setup from chat', () => {expect(readSettings('greeter')).toMatchObject({ greeting: 'Salaam', tone: 'formal' });await handlePluginsCommand('/plugins greeter', msg, channel);- expect(sent.at(-1)).toMatch(/How should I greet people\?: Salaam[\s\S]*Tone: Formal[\s\S]*Change a setting/);+ // Every setting is on the menu itself, with its value: one tap to change.+ expect(sent.at(-1)).toMatch(/\*1\* · How should I greet people\?: Salaam[\s\S]*\*2\* · Tone: Formal/);await answerPluginDialog('cancel', msg, channel);expect(hasPluginDialog('cli:test')).toBe(false);} finally {diff --git a/src/plugins/dialog.test.ts b/src/plugins/dialog.test.tsindex 9a40d151..6526546e 100644--- a/src/plugins/dialog.test.ts+++ b/src/plugins/dialog.test.ts@@ -87,24 +87,94 @@ describe('setup dialog', () => {});describe('/plugins <id> menu', () => {- it('shows status and settings, and its actions work', async () => {+ it('shows status, every setting with its value, and its actions work', async () => {const { svc, calls, values, link } = fakeService();link();const d = (await PluginDialog.menu(svc, 'whatsapp', true))!;const menu = renderPrompt((await d.current())!, false);- expect(menu).toMatch(/WhatsApp[\s\S]*Account: linked as \+639759021037[\s\S]*What can Mercury do in your chat\?: General/);- expect(menu).toMatch(/Change a setting[\s\S]*Send me a test message[\s\S]*Unlink the account[\s\S]*Turn off[\s\S]*Uninstall[\s\S]*Close/);+ expect(menu).toMatch(/WhatsApp[\s\S]*Account: linked as \+639759021037/);+ expect(menu).toMatch(/What can Mercury do in your chat\?: General[\s\S]*Answer your voice calls: On[\s\S]*Send me a test message[\s\S]*Unlink the account[\s\S]*Turn off[\s\S]*Uninstall[\s\S]*Close/);+ expect(menu).not.toMatch(/Change a setting/);await say(d, 'Send me a test message');expect(calls).toContain('test');- await say(d, '1', '2', '2'); // Change a setting → access → Extended+ // One tap opens the setting; the current choice is marked; a way back is always there.+ const opened = await say(d, '2');+ expect(opened.at(-1)).toMatch(/General: chat only ✓ now[\s\S]*Extended: memory, files, tools[\s\S]*← Back \(no change\)/);+ const saved = await say(d, '2');expect(values.access).toBe('extended');+ expect(saved[0]).toBe('✅ What can Mercury do in your chat?: Extended: memory, files, tools');await say(d, 'unlink', 'yes');expect(calls).toContain('unlink');const r = await d.answer('close');expect(r.finished).toBe(true);});+ it('yes/no settings say what each choice does, and Back leaves them unchanged', async () => {+ const { svc, values } = fakeService();+ const base = (await svc.info('whatsapp'))!.settings!;+ const settings = base.map((s) => s.key === 'answerCalls' ? { ...s, optionLabels: { true: 'On: Mercury picks up when you call', false: 'Off: calls ring out' } } : s);+ const d = (await PluginDialog.menu({ ...svc, info: async () => ({ ...(await svc.info('whatsapp'))!, settings: settings.map((s) => ({ ...s, value: values[s.key] })) }) } as typeof svc, 'whatsapp', true))!;+ expect(renderPrompt((await d.current())!, false)).toMatch(/Answer your voice calls: On/);+ const opened = await say(d, '3');+ expect(opened.at(-1)).toMatch(/On: Mercury picks up when you call ✓ now[\s\S]*Off: calls ring out[\s\S]*← Back/);+ await say(d, '3'); // Back+ expect(values.answerCalls).toBe(true);+ const saved = await say(d, '3', '2');+ expect(values.answerCalls).toBe(false);+ expect(saved).toContain('✅ Answer your voice calls: Off: calls ring out');+ });++ it('a typed setting offers suggestions, and typing your own still works', async () => {+ const values: Record<string, unknown> = { hotkey: 'ctrl+alt+m' };+ const svc = {+ info: async () => ({+ id: 'optimus', name: 'Optimus', description: 'x', kind: 'out-of-process', tier: 'official', status: 'enabled', installedVersion: '0.4.4', enabled: true, running: true, verified: true, tools: [], commands: [],+ settings: [{ key: 'hotkey', type: 'string', description: '', value: values.hotkey, label: 'Key to start and stop talking', setup: true, examples: ['ctrl+alt+m', 'ctrl+shift+space', 'f9'] }],+ }),+ setSetting: async (_id: string, k: string, v: unknown) => { values[k] = v; },+ } as unknown as PluginService;+ const d = (await PluginDialog.menu(svc, 'optimus', true))!;+ expect(renderPrompt((await d.current())!, false)).toMatch(/Key to start and stop talking: ctrl\+alt\+m/);+ const opened = await say(d, '1');+ expect(opened.at(-1)).toMatch(/Pick one, or reply with your own[\s\S]*ctrl\+alt\+m ✓ now[\s\S]*ctrl\+shift\+space[\s\S]*f9/);+ await say(d, '3');+ expect(values.hotkey).toBe('f9');+ await say(d, '1', 'ctrl+alt+k');+ expect(values.hotkey).toBe('ctrl+alt+k');+ });++ it('a section lists its settings; choosing an engine asks for what it needs next', async () => {+ const values: Record<string, unknown> = { voiceEngine: 'openai', voiceModel: 'gpt-realtime', geminiModel: 'gemini-3.8-live' };+ let geminiKey = false;+ const settings = () => [+ { key: 'voiceEngine', type: 'enum', description: '', options: ['openai', 'gemini'], value: values.voiceEngine, label: 'Who listens and speaks?', setup: true, group: 'voice', optionLabels: { openai: '⭐ OpenAI Realtime: recommended', gemini: 'Google Gemini Live: free tier' } },+ { key: 'voiceModel', type: 'string', description: '', value: values.voiceModel, label: 'OpenAI voice model', group: 'voice', when: { voiceEngine: ['openai'] } },+ { key: 'geminiKey', type: 'secret', description: '', value: undefined, isSet: geminiKey, label: 'Gemini API key', setup: true, required: true, group: 'voice', when: { voiceEngine: ['gemini'] } },+ { key: 'geminiModel', type: 'string', description: '', value: values.geminiModel, label: 'Gemini Live model', group: 'voice', when: { voiceEngine: ['gemini'] } },+ ];+ const svc = {+ info: async () => ({+ id: 'optimus', name: 'Optimus', description: 'x', kind: 'out-of-process', tier: 'official', status: 'enabled', installedVersion: '0.4.4', enabled: true, running: true, verified: true, tools: [], commands: [],+ settingGroups: [{ id: 'voice', label: '🎙 Voice', ready: values.voiceEngine === 'openai' || geminiKey }],+ settings: settings(),+ }),+ setSetting: async (_id: string, k: string, v: unknown) => { if (k === 'geminiKey') geminiKey = true; else values[k] = v; },+ } as unknown as PluginService;+ const d = (await PluginDialog.menu(svc, 'optimus', true))!;+ expect(renderPrompt((await d.current())!, false)).toMatch(/🎙 Voice: OpenAI Realtime ✓/);+ const section = await say(d, '1');+ expect(section.at(-1)).toMatch(/Who listens and speaks\?: OpenAI Realtime[\s\S]*OpenAI voice model: gpt-realtime[\s\S]*Set up step by step[\s\S]*← Back/);+ expect(section.at(-1)).not.toMatch(/Gemini API key/); // doesn't apply to OpenAI+ const picked = await say(d, '1', '2'); // engine → Gemini+ expect(values.voiceEngine).toBe('gemini');+ // The key is required for Gemini, so it's asked right away; the model has a working default.+ expect(picked.join('\n')).toMatch(/✅ Who listens and speaks\?: Google Gemini Live: free tier\nNext, one more thing it needs:[\s\S]*Gemini API key/);+ const after = await say(d, 'AIzaSyTESTKEY123456');+ expect(geminiKey).toBe(true);+ expect(after.at(-1)).toMatch(/🎙 Voice[\s\S]*Who listens and speaks\?: Google Gemini Live[\s\S]*Gemini API key: set ✓/);+ });+it('members see status only, with no actions', async () => {const { svc } = fakeService();const d = (await PluginDialog.menu(svc, 'whatsapp', false))!;diff --git a/src/plugins/dialog.ts b/src/plugins/dialog.tsindex 67a52abe..ea563101 100644--- a/src/plugins/dialog.ts+++ b/src/plugins/dialog.ts@@ -132,52 +132,86 @@ export class PluginDialog {private settingStep(s: Setting, ctx: { index?: number; total?: number; setup?: boolean } = {}): Step {const title = s.label ?? s.key;const counter = ctx.index ? ` (${ctx.index}/${ctx.total})` : '';- const current = s.type === 'secret' ? (s.isSet ? 'set ✓' : 'not set') : s.value === undefined || s.value === '' ? 'not set' : String(s.optionLabels?.[String(s.value)] ?? s.value);+ const current = shownValue(s);const hasValue = s.type === 'secret' ? !!s.isSet : s.value !== undefined && s.value !== '';- const keep = ctx.setup && hasValue ? [{ label: `Keep: ${current}`, value: '__keep' }] : [];+ // Setup offers "Keep"; the menu always offers a way back, so no question is a dead end.+ const keep = ctx.setup+ ? (hasValue ? [{ label: `Keep: ${current}`, value: '__keep' }] : [])+ : [{ label: '← Back (no change)', value: '__keep' }];+ const head = `${ctx.setup ? `⚙️ ${this.title}${counter}\n` : ''}*${title}*${s.description ? `\n${s.description}` : ''}`;+ const mark = (label: string, isCurrent: boolean) => (isCurrent ? `${label} ✓ now` : label);return {applies: async () => settingApplies(s, (await this.svc.info(this.pluginId))?.settings ?? []),prompt: async () => {if (s.type === 'secret') {- const head = `${ctx.setup ? `⚙️ ${this.title}${counter}\n` : ''}*${title}*${s.description ? `\n${s.description}` : ''}`;return {text: `${head}\nNow: ${current}`,- freeText: 'Paste the key here. It\'s stored with Mercury\'s keys (never shown again), and only this plugin can use it. You can delete your message afterwards.',+ freeText: 'Paste the key here. It\'s stored with Mercury\'s keys (never shown again), and only plugins that declare it can use it. You can delete your message afterwards.',options: keep.length ? keep : (s.required ? undefined : [{ label: 'Skip', value: '__keep' }]),};}- const head = `${ctx.setup ? `⚙️ ${this.title}${counter}\n` : ''}*${title}*${s.description ? `\n${s.description}` : ''}`;if (s.type === 'enum') {- return { text: `${head}\nNow: ${current}`, options: (s.options ?? []).map((o) => ({ label: s.optionLabels?.[o] ?? o, value: o })) };+ const options = (s.options ?? []).map((o) => ({ label: mark(s.optionLabels?.[o] ?? o, String(s.value) === o), value: o }));+ return { text: `${head}\nNow: ${current}`, options: ctx.setup ? options : [...options, ...keep] };}if (s.type === 'boolean') {- return { text: `${head}\nNow: ${s.value === true ? 'yes' : 'no'}`, options: [{ label: 'Yes', value: 'true' }, { label: 'No', value: 'false' }] };+ const options = [+ { label: mark(s.optionLabels?.true ?? 'Yes', s.value === true), value: 'true' },+ { label: mark(s.optionLabels?.false ?? 'No', s.value !== true), value: 'false' },+ ];+ return { text: `${head}\nNow: ${current}`, options: ctx.setup ? options : [...options, ...keep] };}- const hint = s.format === 'phone' ? 'Reply with the number, including the country code (e.g. +15551234567).' : `Reply with the new value${s.type === 'number' ? ' (a number)' : ''}.`;- return { text: `${head}\nNow: ${current}`, freeText: hint, options: keep.length ? keep : (ctx.setup && !s.required ? [{ label: 'Skip', value: '__keep' }] : undefined) };+ const hint = s.format === 'phone'+ ? 'Reply with the number, including the country code (e.g. +15551234567).'+ : `Pick one, or reply with your own${s.type === 'number' ? ' number' : ' value'}.`;+ const examples = (s.examples ?? []).map((e) => ({ label: mark(e, String(s.value) === e), value: `__ex:${e}` }));+ const skip = ctx.setup && !hasValue && !s.required ? [{ label: 'Skip', value: '__keep' }] : [];+ const options = [...examples, ...keep, ...skip];+ return { text: `${head}\nNow: ${current}`, freeText: examples.length || s.format === 'phone' ? hint : `Reply with the new value${s.type === 'number' ? ' (a number)' : ''}.`, options: options.length ? options : undefined };},answer: async (input, option) => {if (option?.value === '__keep') return { kind: 'next' };if (s.type === 'secret') {if (!input || input.length < 8) return { kind: 'retry', message: 'Paste the whole key, or reply "skip".' };await this.svc.setSetting(this.pluginId, s.key, input.trim());- return { kind: 'next', message: `✅ ${title} saved.` };+ return this.afterSave(s, `✅ ${title} saved.`, ctx.setup);}let value: string;if (s.type === 'enum' || s.type === 'boolean') {if (!option) return { kind: 'retry', message: 'Reply with one of the numbers.' };value = option.value;+ } else if (option?.value.startsWith('__ex:')) {+ value = option.value.slice('__ex:'.length);} else {if (!input) return { kind: 'retry', message: 'Reply with a value.' };value = input;}await this.svc.setSetting(this.pluginId, s.key, s.type === 'boolean' ? value === 'true' : s.type === 'number' ? Number(value) : value);- const shown = s.type === 'enum' ? (s.optionLabels?.[value] ?? value).split(':')[0] : s.type === 'boolean' ? (value === 'true' ? 'yes' : 'no') : value;- return { kind: 'next', message: `✅ ${title}: ${shown}` };+ const fresh = (await this.svc.info(this.pluginId))?.settings?.find((x) => x.key === s.key) ?? { ...s, value: s.type === 'boolean' ? value === 'true' : value };+ // Say what the choice does, not just "yes".+ const effect = s.type === 'boolean' || s.type === 'enum' ? (s.optionLabels?.[value] ?? shownValue(fresh)) : shownValue(fresh);+ return this.afterSave(s, `✅ ${title}: ${effect}`, ctx.setup);},};}+ /**+ * After a change in the menu, ask straight away what the choice now needs+ * (pick Gemini → the Gemini key and model), instead of leaving the owner to+ * find those settings. Setup already walks every applicable setting.+ */+ private async afterSave(s: Setting, message: string, setup?: boolean): Promise<StepOutcome> {+ if (setup) return { kind: 'next', message };+ const all = (await this.svc.info(this.pluginId))?.settings ?? [];+ const follow = all.filter((x) => x.key !== s.key && whenMentions(x.when, s.key) && settingApplies(x, all) && (x.type === 'secret' ? !x.isSet : x.setup || x.required || x.type === 'enum'));+ if (!follow.length) return { kind: 'next', message };+ return {+ kind: 'push',+ steps: follow.map((f, n) => this.liveSettingStep(f.key, { index: n + 1, total: follow.length })),+ message: `${message}\nNext, ${follow.length === 1 ? 'one more thing it needs' : `${follow.length} things it needs`}:`,+ };+ }+private linkStep(info: PluginListItem, setup: boolean): Step {return {prompt: async () => {@@ -240,23 +274,23 @@ export class PluginDialog {const status = i.installedVersion ? (i.enabled ? (i.status === 'enabled' ? 'on' : i.status) : 'off') : 'not installed';lines.push('', `Status: ${status}`);if (i.channel) lines.push(`Account: ${i.channel.state === 'connected' ? `linked${i.channel.account ? ` as +${i.channel.account}` : ''}` : (i.channel.state ?? 'not linked')}`);- for (const g of i.settingGroups ?? []) {- const first = (i.settings ?? []).find((x) => x.group === g.id && x.type === 'enum');- const choice = first ? String(first.optionLabels?.[String(first.value)] ?? first.value ?? '').split(':')[0] : '';- lines.push(`${g.label}: ${g.ready ? 'ready ✓' : 'not set up ⚠'}${choice ? ` (${choice})` : ''}`);- }- for (const s of (i.settings ?? []).filter((x) => !x.group && (x.setup || x.label) && settingApplies(x, i.settings ?? []))) {- const v = s.type === 'secret' ? (s.isSet ? 'set ✓' : 'not set') : s.value === undefined || s.value === '' ? 'not set' : s.type === 'boolean' ? (s.value ? 'yes' : 'no') : String(s.optionLabels?.[String(s.value)]?.split(':')[0] ?? s.value);- lines.push(`${s.label ?? s.key}: ${v}`);- }for (const m of i.missing ?? []) lines.push(`⚠️ ${m.unlocks} is off: needs ${m.needs}.`);const options: DialogOption[] = [];if (!this.admin) return { text: lines.join('\n') };if (!i.installedVersion) {options.push({ label: 'Install', value: 'install' });} else {- for (const g of i.settingGroups ?? []) options.push({ label: `${g.label}${g.ready ? '' : ' ⚠ set up'}`, value: `group:${g.id}` });- if (i.settings?.some((x) => !x.group)) options.push({ label: 'Change a setting', value: 'settings' });+ // Every setting is one tap away, with what it's set to now.+ for (const g of i.settingGroups ?? []) {+ const first = (i.settings ?? []).find((x) => x.group === g.id && x.type === 'enum' && settingApplies(x, i.settings ?? []));+ const choice = first ? shownValue(first) : '';+ options.push({ label: `${g.label}${choice ? `: ${choice}` : ''}${g.ready ? ' ✓' : ' ⚠ needs setup'}`, value: `group:${g.id}` });+ }+ const loose = (i.settings ?? []).filter((x) => !x.group && (x.setup || x.label) && settingApplies(x, i.settings ?? []));+ for (const x of loose.slice(0, MENU_SETTINGS)) options.push({ label: `${x.label ?? x.key}: ${shownValue(x)}`, value: `set:${x.key}` });+ if (loose.length > MENU_SETTINGS || (i.settings ?? []).some((x) => !x.group && !x.setup && !x.label && settingApplies(x, i.settings ?? []))) {+ options.push({ label: 'More settings', value: 'settings' });+ }if (i.channel && i.enabled) {if (i.channel.state === 'connected') {options.push({ label: 'Send me a test message', value: 'test' });@@ -279,7 +313,11 @@ export class PluginDialog {const i = (await this.svc.info(this.pluginId))!;if (option.value.startsWith('group:')) {const gid = option.value.slice('group:'.length);- return { kind: 'push', steps: [...this.groupSteps(i, gid), this.menuStep()] };+ return { kind: 'push', steps: [this.groupMenuStep(gid), this.menuStep()] };+ }+ if (option.value.startsWith('set:')) {+ const fresh = i.settings?.find((x) => x.key === option.value.slice('set:'.length));+ return fresh ? { kind: 'push', steps: [this.settingStep(fresh), this.menuStep()] } : { kind: 'retry', message: 'That setting is gone.' };}switch (option.value) {case 'close':@@ -320,23 +358,34 @@ export class PluginDialog {};}- /** A menu section: its intro, then each of its settings that applies (keys asked only when needed). */- private groupSteps(i: PluginListItem, gid: string): Step[] {- const g = (i.settingGroups ?? []).find((x) => x.id === gid);- const fields = (i.settings ?? []).filter((x) => x.group === gid);- const intro: Step = {- prompt: async () => ({- text: `*${g?.label ?? gid}*${g?.description ? `\n${g.description}` : ''}\nNow: ${g?.ready ? 'ready ✓' : 'not set up yet ⚠'}`,- options: [{ label: 'Change it', value: 'go' }, { label: 'Back', value: 'back' }],- }),+ /** A menu section: its settings with current values (one tap each), or a guided walk through them. */+ private groupMenuStep(gid: string): Step {+ return {+ prompt: async () => {+ const i = (await this.svc.info(this.pluginId))!;+ const g = (i.settingGroups ?? []).find((x) => x.id === gid);+ const fields = (i.settings ?? []).filter((x) => x.group === gid && settingApplies(x, i.settings ?? []));+ return {+ text: `*${g?.label ?? gid}*${g?.description ? `\n${g.description}` : ''}\nNow: ${g?.ready ? 'ready ✓' : 'not set up yet ⚠'}`,+ options: [+ ...fields.map((f) => ({ label: `${f.label ?? f.key}: ${shownValue(f)}`, value: `set:${f.key}` })),+ { label: 'Set up step by step', value: 'walk' },+ { label: '← Back', value: 'back' },+ ],+ };+ },answer: async (_input, option) => {- if (!option) return { kind: 'retry', message: 'Reply 1 or 2.' };- return option.value === 'back' ? { kind: 'done' } : { kind: 'next' };+ if (!option) return { kind: 'retry', message: 'Reply with one of the numbers.' };+ if (option.value === 'back') return { kind: 'next' };+ const i = (await this.svc.info(this.pluginId))!;+ if (option.value === 'walk') {+ const keys = (i.settings ?? []).filter((x) => x.group === gid).map((x) => x.key);+ return { kind: 'push', steps: [...keys.map((k, n) => this.liveSettingStep(k, { index: n + 1, total: keys.length })), this.groupMenuStep(gid)] };+ }+ const fresh = i.settings?.find((x) => x.key === option.value.slice('set:'.length));+ return fresh ? { kind: 'push', steps: [this.settingStep(fresh), this.groupMenuStep(gid)] } : { kind: 'retry', message: 'That setting is gone.' };},};- // Re-read each setting fresh, so a key question follows the engine just chosen.- const steps = fields.map((f, n) => this.liveSettingStep(f.key, { index: n + 1, total: fields.length }));- return [intro, ...steps];}/** A setting step that looks the setting up when it's reached (values may have changed since). */@@ -359,7 +408,7 @@ export class PluginDialog {return {prompt: async () => ({text: '*Which setting?*',- options: [...settings.map((s) => ({ label: s.label ?? s.key, value: s.key })), { label: 'Back', value: '__back' }],+ options: [...settings.map((s) => ({ label: `${s.label ?? s.key}: ${shownValue(s)}`, value: s.key })), { label: '← Back', value: '__back' }],}),answer: async (_input, option) => {if (!option) return { kind: 'retry', message: 'Reply with one of the numbers.' };@@ -400,6 +449,28 @@ export class PluginDialog {}}+/** Settings listed directly on a plugin's menu; the rest go under "More settings". */+const MENU_SETTINGS = 10;++/** A setting's current value in a few words: "Control+Option+M", "On", "Gemini Live", "set ✓". */+export function shownValue(s: Setting): string {+ if (s.type === 'secret') return s.isSet ? 'set ✓' : 'not set';+ if (s.value === undefined || s.value === '') return 'not set';+ const short = (label: string) => label.split(':')[0].replace(/⭐\s*/g, '').trim();+ if (s.type === 'boolean') {+ const label = s.optionLabels?.[s.value === true ? 'true' : 'false'];+ return label ? short(label) : s.value === true ? 'On' : 'Off';+ }+ const label = s.optionLabels?.[String(s.value)];+ return label ? short(label) : String(s.value);+}++/** Does `when` depend on `key`? */+function whenMentions(when: Setting['when'], key: string): boolean {+ if (!when) return false;+ return (Array.isArray(when) ? when : [when]).some((c) => Object.prototype.hasOwnProperty.call(c, key));+}+/** Does a setting apply, given the current values of the settings it depends on (`when`)? */export function settingApplies(s: Setting, all: Setting[]): boolean {return whenMatches(s.when, Object.fromEntries(all.map((x) => [x.key, x.value])));diff --git a/src/plugins/manager.ts b/src/plugins/manager.tsindex a2f28d5c..6fd35ffa 100644--- a/src/plugins/manager.ts+++ b/src/plugins/manager.ts@@ -623,7 +623,7 @@ export class PluginManager {key, type: f.type, description: f.description, options: f.options,value: f.type === 'secret' ? undefined : values[key],isSet: f.type === 'secret' ? !!secretValue(f.secret!) : undefined,- label: f.label, setup: f.setup, required: f.required, optionLabels: f.optionLabels, format: f.format, when: f.when,+ label: f.label, setup: f.setup, required: f.required, optionLabels: f.optionLabels, examples: f.examples, format: f.format, when: f.when,group: f.group, setupWhenMissing: f.setupWhenMissing,}));const missingKeys = new Set((item.missing ?? []).map((m) => m.key));diff --git a/src/plugins/types.ts b/src/plugins/types.tsindex ff3b8b3f..33416135 100644--- a/src/plugins/types.ts+++ b/src/plugins/types.ts@@ -104,8 +104,13 @@ const settingField = z.object({setup: z.boolean().default(false),/** Setup can't finish without a value. */required: z.boolean().default(false),- /** Plain-language labels for enum options, e.g. { "general": "General: chat only" }. */+ /**+ * Plain-language labels for enum options, e.g. { "general": "General: chat only" },+ * and for booleans under "true" / "false", saying what each choice does.+ */optionLabels: z.record(z.string(), z.string().max(160)).optional(),+ /** Suggested values for a string setting, offered as one-tap choices (typing your own still works). */+ examples: z.array(z.string().min(1).max(60)).max(8).optional(),/** Input format for string settings, validated and normalised on save. */format: z.enum(['text', 'phone']).default('text'),/** For type 'secret': the env var name the plugin receives it as (must be in permissions.secrets). */@@ -364,6 +369,7 @@ export interface PluginListItem {setup?: boolean;required?: boolean;optionLabels?: Record<string, string>;+ examples?: string[];format?: 'text' | 'phone';/** Only relevant when these other settings match (the menu and setup hide it otherwise). */when?: WhenCondition | WhenCondition[];