Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

feat(bots): Tab autocomplete for bot ids/names + name resolution everywhere

Salman Qureshia91960bc6e04
diff --git a/src/channels/cli.ts b/src/channels/cli.ts
index be0bd335..c4eff44e 100644
--- a/src/channels/cli.ts
+++ b/src/channels/cli.ts
@@ -326,6 +326,8 @@ export interface TuiState {
updateAvailable: string | null;
/** Active Mercury Bot chat — transcript is swapped to the bot's thread. */
botChat: { botId: string; botName: string } | null;
+ /** Live bot roster (drives `/bots` argument autocomplete and badges). */
+ botRoster: Array<{ id: string; name: string; state: string; needsYou: boolean }>;
}
const defaultState: TuiState = {
@@ -361,6 +363,7 @@ const defaultState: TuiState = {
tuiFrozen: false,
updateAvailable: null,
botChat: null,
+ botRoster: [],
};
function shallowEqualSubAgents(a: SubAgentInfo[], b: SubAgentInfo[]): boolean {
@@ -432,6 +435,7 @@ export class CLIChannel extends BaseChannel {
saver?: () => { state: import('../core/saver-mode.js').SaverModeState; savedToday: number; savedLifetime: number };
subAgents?: () => SubAgentInfo[];
bgTasks?: () => BackgroundTaskInfo[];
+ botRoster?: () => Array<{ id: string; name: string; state: string; needsYou: boolean }>;
} = {};
constructor(agentName: string = 'Mercury') {
@@ -2033,6 +2037,16 @@ export class CLIChannel extends BaseChannel {
}
}
+ // 4b. Bot roster — drives /bots argument autocomplete (§3.2)
+ if (this.statusProviders.botRoster) {
+ const roster = this.statusProviders.botRoster();
+ const current = this.state.botRoster;
+ if (current.length !== roster.length || current.some((b, i) =>
+ b.id !== roster[i].id || b.name !== roster[i].name || b.state !== roster[i].state || b.needsYou !== roster[i].needsYou)) {
+ patch.botRoster = roster;
+ }
+ }
+
// 5. Workspace git state (async — branch/files/ahead/behind can
// change from outside Mercury, so we re-read every tick)
if (this.state.workspace?.active) {
diff --git a/src/core/agent.ts b/src/core/agent.ts
index 9071df70..88cc866e 100644
--- a/src/core/agent.ts
+++ b/src/core/agent.ts
@@ -659,8 +659,9 @@ export class Agent {
if (!this.botManager) return; // bots not wired — fall through as a normal message
const rest = trimmed.slice('/bot '.length).trim();
const spaceIndex = rest.indexOf(' ');
- const botId = (spaceIndex === -1 ? rest : rest.slice(0, spaceIndex)).toLowerCase();
+ const rawTarget = (spaceIndex === -1 ? rest : rest.slice(0, spaceIndex)).toLowerCase();
const message = spaceIndex === -1 ? '' : rest.slice(spaceIndex + 1).trim();
+ const botId = this.botManager.resolveBotId(rawTarget) ?? rawTarget;
if (botId && message) {
void this.dispatchToBot(botId, message, msg);
}
@@ -1258,6 +1259,12 @@ export class Agent {
const parts = rawArgs.length > 0 ? rawArgs.split(/\s+/) : [];
const action = (parts[0] ?? '').toLowerCase();
+ // All bot-targeting actions accept id OR name — resolve to the id here.
+ if (['open', 'send', 'journal', 'inbox', 'budget', 'edit', 'delete', 'enable', 'disable', 'stop', 'pause'].includes(action) && parts[1]) {
+ const resolved = bm.resolveBotId(parts[1]);
+ if (resolved) parts[1] = resolved;
+ }
+
const stateIcons: Record<string, string> = { idle: '⚪', queued: '🔵', running: '🟢', paused: '🟡', disabled: '⛔' };
const runIcons: Record<string, string> = { completed: '✅', failed: '❌', halted: '⛔', paused: '⏸', denied: '🚫' };
diff --git a/src/index.ts b/src/index.ts
index 0dea2ce5..25ca3182 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -2561,6 +2561,12 @@ async function runAgent(isDaemon: boolean = false): Promise<void> {
startedAt: 0,
})) : [],
bgTasks: () => agent.backgroundTasks.getAllSummaries(),
+ botRoster: () => agent.getBotManager()?.getStatusSummaries().map((b) => ({
+ id: b.id,
+ name: b.name,
+ state: b.state,
+ needsYou: b.needsYou,
+ })) ?? [],
});
bootCli.startStatusPoller(2000);
bootCli.mountTUI((inputText: string) => {
diff --git a/src/ui/App.tsx b/src/ui/App.tsx
index f742e50f..a09f47c5 100644
--- a/src/ui/App.tsx
+++ b/src/ui/App.tsx
@@ -218,8 +218,22 @@ export function TuiApp({ channel, onInput, onPermissionResolve, onExit, spotifyC
const slashSuggestions = React.useMemo(() => {
if (!input.startsWith('/')) return [];
const q = input.toLowerCase();
+ // Bot-id argument completion: `/bots <action> <partial>` or `/bot <partial>`
+ // suggests existing bots (id or name) — the roster arrives via the 2s poller.
+ const botsArg = /^(\/bots\s+(?:open|send|journal|inbox|budget|edit|delete|enable|disable|stop|persona)\s+)(\S*)$/.exec(input);
+ const botArg = /^(\/bot\s+)(\S*)$/.exec(input);
+ if ((botsArg || botArg) && state.botRoster.length > 0) {
+ const [_, cmdPrefix, typed] = botsArg ?? botArg!;
+ const p = typed.toLowerCase();
+ const botCmds = state.botRoster
+ .filter((b) => b.id.startsWith(p) || b.name.toLowerCase().startsWith(p))
+ .slice(0, 5)
+ .map((b) => `${cmdPrefix}${b.id}`);
+ const base = slashCommands.filter((cmd) => cmd.startsWith(q)).slice(0, 2);
+ return [...botCmds, ...base].slice(0, 5);
+ }
return slashCommands.filter((cmd) => cmd.startsWith(q)).slice(0, 5);
- }, [input, slashCommands]);
+ }, [input, slashCommands, state.botRoster]);
const [slashSelIdx, setSlashSelIdx] = React.useState(0);