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(whatsapp): access levels (General / Extended); Mercury knows it's on WhatsApp

Salman Qureshi1a30972dd06e
diff --git a/plugins/whatsapp/mercury-plugin.template.json b/plugins/whatsapp/mercury-plugin.template.json
index 6ecc5be2..5cce9d3b 100644
--- a/plugins/whatsapp/mercury-plugin.template.json
+++ b/plugins/whatsapp/mercury-plugin.template.json
@@ -55,11 +55,30 @@
"description": "Your own WhatsApp number (with country code). Only this number can talk to Mercury.",
"default": ""
},
+ "access": {
+ "type": "enum",
+ "description": "What Mercury may do in your chat: general (chat only) or extended (memory, files, tools). 'ask' asks you after linking.",
+ "options": [
+ "ask",
+ "general",
+ "extended"
+ ],
+ "default": "ask"
+ },
"members": {
"type": "string",
"description": "Other numbers allowed to chat with Mercury, comma separated (they can't run admin commands).",
"default": ""
},
+ "memberAccess": {
+ "type": "enum",
+ "description": "What members may do (never more than you).",
+ "options": [
+ "general",
+ "extended"
+ ],
+ "default": "general"
+ },
"allowGroups": {
"type": "boolean",
"description": "Answer in WhatsApp groups (owner and members only).",
diff --git a/src/capabilities/registry.ts b/src/capabilities/registry.ts
index 38a23b74..b8d95953 100644
--- a/src/capabilities/registry.ts
+++ b/src/capabilities/registry.ts
@@ -146,6 +146,21 @@ export class CapabilityRegistry {
return { channelId: ctx.channelId, channelType: ctx.channelType };
}
+ private toolsDisabled = false;
+
+ /**
+ * No tools at all for the current turn (a chat channel at "general"
+ * access). Enforced here so every code path that asks for tools, including
+ * the plan and narration-guard paths, gets none.
+ */
+ setToolsDisabled(disabled: boolean): void {
+ this.toolsDisabled = disabled;
+ }
+
+ areToolsDisabled(): boolean {
+ return this.toolsDisabled;
+ }
+
getCwd(): string {
return this.currentCwd;
}
@@ -281,6 +296,7 @@ export class CapabilityRegistry {
}
getTools(): Record<string, Tool> {
+ if (this.toolsDisabled) return {};
// Members on a channel that distinguishes roles (e.g. Telegram) must not be
// able to install skills: `install_skill` is the escalation path from chat
// access to arbitrary local execution and is documented as admin-only.
@@ -312,6 +328,7 @@ export class CapabilityRegistry {
/** Return tools filtered for plan mode — read-only tools only */
getPlanTools(): Record<string, Tool> {
+ if (this.toolsDisabled) return {};
const blocked = new Set([
'write_file', 'create_file', 'delete_file', 'edit_file',
'run_command', 'cd',
diff --git a/src/core/agent.ts b/src/core/agent.ts
index 80a3d973..8f44a7dc 100644
--- a/src/core/agent.ts
+++ b/src/core/agent.ts
@@ -1611,6 +1611,9 @@ export class Agent {
(channel as CLIChannel).sendHeartbeat(heartbeatText);
} else if (channel instanceof WebChannel) {
(channel as WebChannel).sendHeartbeat(heartbeatText, msg.channelId);
+ } else if (channel && (channel as { quietProgress?: boolean }).quietProgress) {
+ // Phone chats (plugin channels like WhatsApp): keep "typing…" alive instead of messages.
+ void channel.typing(msg.channelId).catch(() => {});
} else if (channel) {
void channel.send(heartbeatText, msg.channelId).catch((e) => logger.warn({ e }, 'channel send failed'));
}
@@ -2609,7 +2612,15 @@ export class Agent {
const loopWarning = detectRepetitionLoop(recentMemory);
if (loopWarning) contextBlocks.push(loopWarning);
- contextBlocks.push(...(await this.retrieveMemoryContext(msg)));
+ // Chat channels can carry an access level and guidance (plugin API 1.1,
+ // e.g. WhatsApp): "general" means no tools, no personal memory and no
+ // learning from the turn; the guidance tells the model where it is and
+ // how to write for it.
+ const generalAccess = msg.metadata?.channelAccess === 'general';
+ this.capabilities.setToolsDisabled(generalAccess);
+ const guidance = typeof msg.metadata?.channelGuidance === 'string' ? msg.metadata.channelGuidance.slice(0, 2000) : '';
+ if (guidance) contextBlocks.unshift(guidance);
+ if (!generalAccess) contextBlocks.push(...(await this.retrieveMemoryContext(msg)));
for (const m of recentMemory) messages.push(toModelMessage(m));
@@ -3035,7 +3046,8 @@ export class Agent {
}
}
} else {
- void channel.send(` [Using: ${names}]`, msg.channelId).catch((e) => logger.warn({ e }, 'channel send failed'));
+ if ((channel as { quietProgress?: boolean }).quietProgress) void channel.typing(msg.channelId).catch(() => {});
+ else void channel.send(` [Using: ${names}]`, msg.channelId).catch((e) => logger.warn({ e }, 'channel send failed'));
}
this.markProgress();
}
@@ -3565,6 +3577,7 @@ export class Agent {
while (
!loopAbortController.signal.aborted
&& this.programmingMode.isExecute()
+ && !this.capabilities.areToolsDisabled()
&& executeGuardRounds < (narrationSecondWind ? MAX_EXECUTE_CONTINUATIONS * 2 : MAX_EXECUTE_CONTINUATIONS)
// A turn that ends by asking the user something in plain text is a
// legitimate pause — forcing rounds here looped the model forever
@@ -3822,6 +3835,7 @@ export class Agent {
!loopAbortController.signal.aborted
&& turnEnd() === 'text-stop'
&& this.programmingMode.isExecute()
+ && !this.capabilities.areToolsDisabled()
&& verificationContinuations < MAX_VERIFICATION_CONTINUATIONS
&& shouldRequireVerification({
taskText: msg.content,
@@ -3908,6 +3922,7 @@ export class Agent {
if (
!loopAbortController.signal.aborted
&& this.programmingMode.isExecute()
+ && !this.capabilities.areToolsDisabled()
&& !responseAsksUser(result.text || '')
&& shouldForceExecuteContinuation({
taskText: msg.content,
@@ -3934,6 +3949,7 @@ export class Agent {
if (
!loopAbortController.signal.aborted
&& this.programmingMode.isExecute()
+ && !this.capabilities.areToolsDisabled()
&& lastVerification != null
&& !verifiedAfterLastMutation()
&& !responseAsksUser(result.text || '')
@@ -4049,7 +4065,7 @@ export class Agent {
channelType: msg.channelType,
});
- if (msg.channelType !== 'internal') {
+ if (msg.channelType !== 'internal' && msg.metadata?.channelAccess !== 'general') {
this.extractMemory(msg.content, finalText).catch(err => {
logger.warn({ err }, 'Memory extraction failed');
});
@@ -4151,6 +4167,7 @@ export class Agent {
stallWatchdog.stop();
stopHeartbeat();
this.finalizeChannelTask(msg);
+ this.capabilities.setToolsDisabled(false);
this.currentMessage = null;
this.currentAbort = null;
this.currentAbortReason = null;
diff --git a/src/index.ts b/src/index.ts
index f2806f14..af06531e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -2614,6 +2614,16 @@ async function runAgent(isDaemon: boolean = false): Promise<void> {
return;
}
+ // Any other chat channel (plugin channels such as WhatsApp): the file goes
+ // back to the chat that asked for it.
+ if (channelType !== 'cli' && channelType !== 'web' && channelType !== 'internal') {
+ const current = channels.get(channelType as Parameters<typeof channels.get>[0]);
+ if (current) {
+ await current.sendFile(filePath, channelId);
+ return;
+ }
+ }
+
if (config.channels.telegram.enabled && telegram && getTelegramApprovedUsers(config).length > 0) {
await telegram.sendFile(filePath);
return;
diff --git a/src/plugins/channel-bridge.ts b/src/plugins/channel-bridge.ts
index 1c3d05e0..71521154 100644
--- a/src/plugins/channel-bridge.ts
+++ b/src/plugins/channel-bridge.ts
@@ -148,11 +148,19 @@ export class PluginChannel extends BaseChannel {
/** The plugin's current settings (owner, members, allowGroups). */
private readonly settings: () => Record<string, unknown>,
private readonly notifyOwner: (message: string) => void,
+ /** Persist a plugin setting without restarting it (access level, members). */
+ private readonly saveSetting: (key: string, value: unknown) => Promise<void> = async () => {},
) {
super();
this.type = manifest.contributes.channel!.type as ChannelType;
}
+ /** Phone chats: no per-step messages or "Working…" heartbeats; keep "typing…" alive instead. */
+ readonly quietProgress = true;
+
+ /** Owner chats waiting for the one-time "how much can Mercury do here?" answer. */
+ private awaitingAccessChoice = new Set<string>();
+
get pluginId(): string {
return this.manifest.id;
}
@@ -245,7 +253,7 @@ export class PluginChannel extends BaseChannel {
senderRole: 'admin',
content: `[Voice call — the owner asked this out loud. Answer in one to three short spoken sentences: no markdown, lists, links or code. Anything that needs approval can't be done during a call; say so and offer to do it by message.]\n${question}`,
timestamp: Date.now(),
- metadata: { pluginId: this.manifest.id, voiceCall: true, callId },
+ metadata: { pluginId: this.manifest.id, voiceCall: true, callId, channelAccess: this.accessFor('admin'), channelGuidance: this.guidance('admin', false, true) },
});
});
}
@@ -299,6 +307,10 @@ export class PluginChannel extends BaseChannel {
pairCode: str(p.pairCode, 32),
at: Date.now(),
});
+ if (state === 'connected' && prev !== 'connected' && this.ownerAccess() === 'ask') {
+ // Linked: ask the owner once how much Mercury may do here.
+ setTimeout(() => this.askAccessChoice(), 3000).unref?.();
+ }
if (state === 'logged-out' && prev !== 'logged-out') {
this.notifyOwner(`⚠️ ${this.manifest.name} was logged out${this.status.detail ? `: ${this.status.detail}` : ''}. Link it again with /plugins pair ${this.manifest.id}.`);
}
@@ -342,6 +354,7 @@ export class PluginChannel extends BaseChannel {
}
const text = typeof p.text === 'string' ? p.text.slice(0, 20_000) : '';
+ if (role === 'admin' && text && this.handleAccessReply(p.chatId, text)) return;
const pending = this.pending.get(p.chatId);
if (pending && text) {
const answer = normalizeReply(text);
@@ -375,11 +388,104 @@ export class PluginChannel extends BaseChannel {
senderRole: role,
content,
timestamp: typeof p.timestamp === 'number' ? p.timestamp : Date.now(),
- metadata: { pluginId: this.manifest.id, chatId: p.chatId, isGroup: p.isGroup === true, attachments: files },
+ metadata: {
+ pluginId: this.manifest.id,
+ chatId: p.chatId,
+ isGroup: p.isGroup === true,
+ attachments: files,
+ channelAccess: this.accessFor(role),
+ channelGuidance: this.guidance(role, p.isGroup === true),
+ },
};
+ if (role === 'admin' && this.ownerAccess() === 'ask' && !this.awaitingAccessChoice.has(p.chatId)) {
+ // Not chosen yet: answer at General, and ask (once) after this reply.
+ setTimeout(() => this.askAccessChoice(), 1500).unref?.();
+ }
this.emit(msg);
}
+ // ── access levels ────────────────────────────────────────────────────
+
+ /** The owner's chosen level: 'ask' until they pick one after linking. */
+ ownerAccess(): 'ask' | 'general' | 'extended' {
+ const v = String(this.settings().access ?? 'ask');
+ return v === 'general' || v === 'extended' ? v : 'ask';
+ }
+
+ /** What a sender may do here. Members never exceed the owner's level. */
+ accessFor(role: 'admin' | 'member'): 'general' | 'extended' {
+ const owner = this.ownerAccess() === 'extended' ? 'extended' : 'general';
+ if (role === 'admin') return owner;
+ return owner === 'extended' && String(this.settings().memberAccess ?? 'general') === 'extended' ? 'extended' : 'general';
+ }
+
+ /** Told to the model every turn: where it is, who it's talking to, what it may do, how to write. */
+ guidance(role: 'admin' | 'member', isGroup: boolean, voiceCall = false): string {
+ const name = this.manifest.name;
+ const who = role === 'admin' ? 'the owner (the person you work for)' : 'an approved member, not the owner';
+ const where = voiceCall ? `a ${name} voice call` : `${name}${isGroup ? ', in a group chat' : ''}, a phone chat app`;
+ const lines = [
+ `## Channel: ${name}`,
+ `You're talking with ${who} on ${where}.`,
+ voiceCall
+ ? 'Your answer is spoken aloud: one to three short sentences, no markdown, lists, links or code.'
+ : `Write like a text message: short and conversational. ${name} formatting only (*bold*, _italic_, ~strike~). No code blocks, tables, headings or long lists. If they need code, a document or long output, write it to a file and send it with send_file, then summarise it in a sentence. Never paste raw file contents, logs or stack traces.`,
+ ];
+ if (this.accessFor(role) === 'extended') {
+ lines.push(role === 'admin'
+ ? 'Access: Extended. Use your tools, files and memory as you normally would. Actions that need approval are confirmed by the owner replying 1 (yes), 2 (no) or 3 (always) in this chat: ask once, clearly, saying what will happen.'
+ : 'Access: Extended for members. You may use tools, but never share the owner\'s private details (memory, files, contacts, accounts) with this member unless the owner told you to.');
+ } else {
+ lines.push(role === 'admin'
+ ? 'Access: General. In this chat you have no tools, files or personal memory. Help with conversation and general knowledge. If something needs tools or personal context, say so in one line and that they can switch this chat to Extended by sending: /access extended'
+ : 'Access: General. You have no tools, files or memory here, and must not share anything personal about the owner. Help with general questions only. If they ask for more, say only the owner can allow it.');
+ }
+ return lines.join('\n');
+ }
+
+ private askAccessChoice(): void {
+ const chat = this.defaultTarget();
+ if (!chat || this.ownerAccess() !== 'ask' || this.awaitingAccessChoice.has(chat)) return;
+ this.awaitingAccessChoice.add(chat);
+ void this.send([
+ `☿ How much should I do for you on ${this.manifest.name}?`,
+ '',
+ '*1 · General*: chat and general knowledge only. No tools, files or personal memory.',
+ '*2 · Extended*: everything I can do elsewhere (memory, files, tools, actions). Anything risky still asks you first.',
+ '',
+ 'Reply *1* or *2*. You can change it anytime with /access general or /access extended.',
+ ].join('\n')).catch(() => this.awaitingAccessChoice.delete(chat));
+ }
+
+ /** Owner messages that set the access level. Returns true when handled (not passed to the agent). */
+ private handleAccessReply(chatId: string, text: string): boolean {
+ const t = text.trim().toLowerCase().replace(/[.!]/g, '');
+ let choice: 'general' | 'extended' | null = null;
+ const cmd = /^\/access(?:\s+(\S+))?$/.exec(t);
+ if (cmd) {
+ if (!cmd[1]) {
+ void this.send(`Access here is *${this.ownerAccess() === 'extended' ? 'Extended' : 'General'}*. Change it with /access general or /access extended.`, `${this.type}:${chatId}`).catch(() => {});
+ return true;
+ }
+ choice = cmd[1] === 'extended' || cmd[1] === 'full' || cmd[1] === '2' ? 'extended' : cmd[1] === 'general' || cmd[1] === '1' ? 'general' : null;
+ if (!choice) {
+ void this.send('Use /access general or /access extended.', `${this.type}:${chatId}`).catch(() => {});
+ return true;
+ }
+ } else if (this.awaitingAccessChoice.size && (t === '1' || t === '2' || t === 'general' || t === 'extended')) {
+ choice = t === '2' || t === 'extended' ? 'extended' : 'general';
+ } else {
+ return false;
+ }
+ this.awaitingAccessChoice.clear();
+ void this.saveSetting('access', choice)
+ .then(() => this.send(choice === 'extended'
+ ? '✅ *Extended*: I can use my memory, files and tools here. I\'ll still ask before anything risky. Switch back anytime with /access general.'
+ : '✅ *General*: chat and general knowledge only here. Switch anytime with /access extended.', `${this.type}:${chatId}`))
+ .catch((err) => this.send(`Couldn't change access: ${(err as Error).message}`, `${this.type}:${chatId}`).catch(() => {}));
+ return true;
+ }
+
// ── Channel ──────────────────────────────────────────────────────────
async start(): Promise<void> { /* the plugin runtime drives the connection */ }
diff --git a/src/plugins/channel.test.ts b/src/plugins/channel.test.ts
index 3957af07..f207e3f9 100644
--- a/src/plugins/channel.test.ts
+++ b/src/plugins/channel.test.ts
@@ -71,7 +71,13 @@ function channelPlugin(root: string, id = 'whatsapp', extra: Record<string, unkn
engines: { mercury: '>=1.0.0', pluginApi: '^1.1.0' },
server: { command: 'node', args: ['server.cjs'] },
contributes: { tools: ['inject', 'callsim', 'callend'].map((name) => ({ name, description: 'Test hook.', readOnly: true })), channel: { type: 'whatsapp' } },
- settings: { version: 1, fields: { owner: { type: 'string', default: '' }, members: { type: 'string', default: '' }, allowGroups: { type: 'boolean', default: false } } },
+ settings: { version: 1, fields: {
+ owner: { type: 'string', default: '' },
+ access: { type: 'enum', options: ['ask', 'general', 'extended'], default: 'ask' },
+ members: { type: 'string', default: '' },
+ memberAccess: { type: 'enum', options: ['general', 'extended'], default: 'general' },
+ allowGroups: { type: 'boolean', default: false },
+ } },
...extra,
}));
writeFileSync(join(dir, 'server.cjs'), CHANNEL_SERVER);
@@ -264,4 +270,66 @@ describe('plugin channels (plugin API 1.1)', () => {
expect(sent().every((m) => m.chatId === '[email protected]')).toBe(true);
});
});
+
+ describe('access levels', () => {
+ const sentTexts = () => {
+ const f = join(pluginDataDir('whatsapp'), 'out.jsonl');
+ return existsSync(f) ? readFileSync(f, 'utf8').trim().split('\n').map((l) => JSON.parse(l).text as string) : [];
+ };
+
+ it('before the owner chooses: General, told it is on WhatsApp, and asked once', async () => {
+ await installChannel();
+ await inject({ id: 'g1', senderPhone: '15550002', text: 'hello' });
+ await inject({ id: 'g2', senderPhone: '15550002', text: 'and again' });
+ expect(received[0].metadata?.channelAccess).toBe('general');
+ const g = String(received[0].metadata?.channelGuidance);
+ expect(g).toMatch(/talking with the owner \(the person you work for\) on WhatsApp, a phone chat app/);
+ expect(g).toMatch(/No code blocks/);
+ expect(g).toMatch(/Access: General[\s\S]*\/access extended/);
+ await waitFor(() => sentTexts().some((t) => /How much should I do/.test(t)), 4000);
+ await sleep(1600);
+ expect(sentTexts().filter((t) => /How much should I do/.test(t))).toHaveLength(1);
+ });
+
+ it('replying 2 switches to Extended live, without restarting the plugin', async () => {
+ await installChannel();
+ const before = (await mgr.info('whatsapp'))?.running;
+ await inject({ id: 'e1', senderPhone: '15550002', text: 'hi' });
+ await waitFor(() => sentTexts().some((t) => /How much should I do/.test(t)), 4000);
+ await inject({ id: 'e2', senderPhone: '15550002', text: '2' });
+ await waitFor(() => sentTexts().some((t) => /Extended/.test(t) && /✅/.test(t)));
+ await inject({ id: 'e3', senderPhone: '15550002', text: 'what is on my calendar' });
+ expect(received.map((m) => m.content)).toEqual(['hi', 'what is on my calendar']); // "2" never reached the agent
+ expect(received[1].metadata?.channelAccess).toBe('extended');
+ expect(String(received[1].metadata?.channelGuidance)).toMatch(/Access: Extended/);
+ expect(before).toBe(true);
+ expect(getPluginChannel('whatsapp')?.isReady() !== undefined).toBe(true);
+ expect(registered).toHaveLength(1); // same channel instance: no restart happened
+ });
+
+ it('/access general goes back; /access shows the level', async () => {
+ await installChannel();
+ await mgr.setSetting('whatsapp', 'access', 'extended');
+ await inject({ id: 'a1', senderPhone: '15550002', text: '/access' });
+ await inject({ id: 'a2', senderPhone: '15550002', text: '/access general' });
+ await waitFor(() => sentTexts().some((t) => /✅ \*General\*/.test(t)));
+ await inject({ id: 'a3', senderPhone: '15550002', text: 'hello' });
+ expect(sentTexts().some((t) => /Access here is \*Extended\*/.test(t))).toBe(true);
+ expect(received.map((m) => [m.content, m.metadata?.channelAccess])).toEqual([['hello', 'general']]);
+ });
+
+ it('members never exceed the owner, and default to General', async () => {
+ await installChannel('+15550002', '15550003');
+ await mgr.setSetting('whatsapp', 'access', 'extended');
+ await inject({ id: 'm1', senderPhone: '15550003', text: 'hi' });
+ expect(received[0].metadata?.channelAccess).toBe('general');
+ expect(String(received[0].metadata?.channelGuidance)).toMatch(/approved member, not the owner[\s\S]*only the owner can allow/);
+ await mgr.setSetting('whatsapp', 'memberAccess', 'extended');
+ await inject({ id: 'm2', senderPhone: '15550003', text: 'hi again' });
+ expect(received[1].metadata?.channelAccess).toBe('extended');
+ await mgr.setSetting('whatsapp', 'access', 'general');
+ await inject({ id: 'm3', senderPhone: '15550003', text: 'and now' });
+ expect(received[2].metadata?.channelAccess).toBe('general');
+ });
+ });
});
diff --git a/src/plugins/integration.test.ts b/src/plugins/integration.test.ts
index af50774f..13cd2be0 100644
--- a/src/plugins/integration.test.ts
+++ b/src/plugins/integration.test.ts
@@ -77,3 +77,17 @@ describe('approvePluginTool', () => {
expect(await pm.approvePluginTool('notes__write', 'x')).toBe(false);
});
});
+
+describe('general access disables every tool for the turn', () => {
+ it('getTools and getPlanTools return nothing while disabled', async () => {
+ const { CapabilityRegistry } = await import('../capabilities/registry.js');
+ const reg = new CapabilityRegistry();
+ reg.registerAll();
+ expect(Object.keys(reg.getTools()).length).toBeGreaterThan(0);
+ reg.setToolsDisabled(true);
+ expect(reg.getTools()).toEqual({});
+ expect(reg.getPlanTools()).toEqual({});
+ reg.setToolsDisabled(false);
+ expect(Object.keys(reg.getTools()).length).toBeGreaterThan(0);
+ });
+});
diff --git a/src/plugins/manager.ts b/src/plugins/manager.ts
index 51f218ff..4985046b 100644
--- a/src/plugins/manager.ts
+++ b/src/plugins/manager.ts
@@ -41,6 +41,8 @@ export const CIRCUIT_BREAKER_FAILURES = 5;
export const BOOT_HEALTHY_AFTER_MS = 60_000;
/** How long after start the missing-secret notice is sent (mutable for tests). */
export const SECRET_NOTICE_DELAY = { ms: 15_000 };
+/** Channel-plugin settings read by Mercury on every message, so changing them needs no restart. */
+const LIVE_CHANNEL_SETTINGS = new Set(['access', 'memberAccess', 'members', 'allowGroups']);
const BOOT_GUARD_WINDOW_MS = 24 * 60 * 60 * 1000;
interface Running {
@@ -269,6 +271,7 @@ export class PluginManager {
{ request: (method, params, timeoutMs) => runtimeRef ? runtimeRef.channelRequest(method, params, timeoutMs) : Promise.reject(new Error('not running')) },
() => resolvedSettings(manifest),
(m) => { void this.notifyFn(m); },
+ (key, value) => this.setSetting(id, key, value),
);
}
const deps = {
@@ -503,7 +506,9 @@ export class PluginManager {
const values = { ...resolvedSettings(manifest), [key]: coerced };
writeSettings(id, values, manifest.settings?.version ?? 1);
// Settings are read at start: restart a running plugin so it sees them.
- if (this.running.has(id)) {
+ // Channel settings Mercury itself reads (who may talk, at what level) apply
+ // live: restarting would drop the plugin's connection for nothing.
+ if (this.running.has(id) && !(manifest.contributes.channel && LIVE_CHANNEL_SETTINGS.has(key))) {
await this.stopRuntime(id);
await this.reconcile();
}