Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Apply a bot's own skill on/off/delete directly, with a receipt and Undo
milind-soni3e9357377959
diff --cc scripts/ci-scope.mjsindex 3a7361fd27,173228779a..862a064b29--- a/scripts/ci-scope.mjs+++ b/scripts/ci-scope.mjs@@@ -50,7 -50,8 +50,8 @@@ export const VITEST_SUBSETS ="server/server-lines.test.ts", "server/host/devs-reports.test.ts", "server/automation-reports.test.ts", "server/incidents.test.ts","server/routine-run-card.test.ts", "server/host/chief-notices-retry.test.ts", "server/connector-card-text.test.ts", "server/host/secret-cards.test.ts","server/notify.test.ts", "server/room-lines.test.ts", "server/post-to-room.test.ts",- "server/teammate-lines.test.ts", "server/cloud-send-arrived.test.ts", "server/skill-switch.test.ts"],+ "server/teammate-lines.test.ts", "server/cloud-send-arrived.test.ts", "scripts/ci-workflow.test.ts", "scripts/pre-push-check.test.ts",- "server/host/wait-words.test.ts"],++ "server/host/wait-words.test.ts", "server/skill-switch.test.ts"],shards: 2,nodeTests: true,},diff --cc server/drivers/agents-call.tsindex 3f53b354ae,3532e67523..1e4b4471ca--- a/server/drivers/agents-call.ts+++ b/server/drivers/agents-call.ts@@@ -2,7 -2,7 +2,8 @@@// per-turn limits are the harness's, since one proxy can serve many turns of a warm engine.import { agentsCallMember, resolveAgentsCall } from "../../shared/agents-tool-names.ts";import { CREDENTIAL_TARGETS, isCredentialTargetId } from "../../shared/credential-request.ts";+import { isSkillSwitchAction, skillSwitchVerb } from "../../shared/skill-request.ts";+ import { EMAIL_CREDENTIAL } from "../../shared/email.ts";import { peerName } from "../peer-roster.ts";import { callCardTool, CARD_TOOL_NAMES } from "./agents-call-cards.ts";diff --cc server/drivers/agents-catalog-goldens/full.tools-list.jsonindex 6a8ce05cd5,e86e2107f7..46a5fba9b5--- a/server/drivers/agents-catalog-goldens/full.tools-list.json+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json@@@ -1806,7 -1811,7 +1811,7 @@@},{"name": "skill_manage",- "description": "Submit a new or updated reusable SKILL.md, or turn one of your own skills on, off, or delete it (always after the person approves). Never change a skill unless the user explicitly asked for that named skill. If the result is pending, a create stays inactive and an update leaves the current version unchanged. Read the result: it applies immediately at every access level, and the person sees it with an Undo where possible. If applied, continue the work without another confirmation. Only a pending result (a Cloud conversation its owner did not drive) means ending the turn to wait for the owner. Never claim success without an applied result; report failures honestly. This does not elevate another bot's execution permissions.",- "description": "Submit a new or updated reusable SKILL.md. Never update unless the user explicitly asked to revise that named skill. If the result is pending, a create stays inactive and an update leaves the current version unchanged. Read the result: it applies immediately at every access level, and the person sees it with an Undo where possible. If applied, continue the work without another confirmation. Only a pending result (a Cloud conversation its owner did not drive) means ending the turn to wait for the owner. Never claim success without an applied result; report failures honestly. This does not elevate another bot's execution permissions.",++ "description": "Submit a new or updated reusable SKILL.md, or turn one of your own skills on or off, or delete it. Never change a skill unless the user explicitly asked for that named skill. If the result is pending, a create stays inactive and an update leaves the current version unchanged. Read the result: it applies immediately at every access level, and the person sees it with an Undo where possible. If applied, continue the work without another confirmation. Only a pending result (a Cloud conversation its owner did not drive) means ending the turn to wait for the owner. Never claim success without an applied result; report failures honestly. This does not elevate another bot's execution permissions.","inputSchema": {"type": "object","additionalProperties": false,diff --cc server/drivers/agents-catalog-goldens/profiles.jsonindex 2027424509,7307cbdc3a..b10a28b4bd--- a/server/drivers/agents-catalog-goldens/profiles.json+++ b/server/drivers/agents-catalog-goldens/profiles.json@@@ -206,8 -210,8 +210,8 @@@]},"skills": {- "bytes": 61581,- "sha256": "6e8f4195f095ac2fe50a4880cc6b64cdc0180d367c7e5826436607a03fdc2c91",- "bytes": 62159,- "sha256": "270d5c39f7be91a964e76dbce68473aa8adbb49e45d6f332aad207662d84a54d",++ "bytes": 62267,++ "sha256": "6135fd2608e4d49a9e231f5e636ffd86e3a8720088a7ca7aba23a13e5b3662db","tools": ["tool_result_read","list_room_targets",@@@ -258,8 -263,8 +263,8 @@@]},"skills+voice": {- "bytes": 62362,- "sha256": "e990781cc6e9a45f9e3b4d4aa32e70de1114bbe079c01e82c771ea06993d0193",- "bytes": 62940,- "sha256": "6f92153b9b83d31386c091986af75bb9517b2e67dd3d2b2e875f3fb13fda9b6a",++ "bytes": 63048,++ "sha256": "66252617bb7029d34ef24820f18f48b8691236c0c74ac34911beb06765493210","tools": ["tool_result_read","list_room_targets",@@@ -311,8 -317,8 +317,8 @@@]},"skills+shared": {- "bytes": 63846,- "sha256": "7c5df56504db13dfe4e368012a9d6b4d991698f060ebbdc752cf321853e723a1",- "bytes": 64424,- "sha256": "c76f84ae4ae9353ae80c9a0c62b1352bbda7f1f3d7f993ea42471e97757bc3f0",++ "bytes": 64532,++ "sha256": "60145540ec7ff1c02e64d87bae1c93dcdf5bca1446fc90c5c18d7f90f1271c3d","tools": ["tool_result_read","list_shared_computers",@@@ -365,8 -372,8 +372,8 @@@]},"skills+shared+voice": {- "bytes": 64627,- "sha256": "612f5e87f39894ace3040f43b39b3be7390c97277a0239db258ce4f20e5e32fb",- "bytes": 65205,- "sha256": "aabd8e61de605d04fbe8a177baa0b1f62d288a9de812df22cbbe70be7fa2382a",++ "bytes": 65313,++ "sha256": "ac0555dbd0032ef3c12614a36d087d63950c955d306a030b3cacd1e8b3e83ec1","tools": ["tool_result_read","list_shared_computers",@@@ -598,8 -610,8 +610,8 @@@]},"skills+non-chief": {- "bytes": 52365,- "sha256": "61db2ce824324616b821d2ff2af98030d91f52d2a088cbb91a98fdcc5ad72ea5",- "bytes": 52943,- "sha256": "f339e5f741cbe2dac09450f9a957933f69baa4f9fad7dbd263631355a3a739af",++ "bytes": 53051,++ "sha256": "24f66bc798e102712896fb3b86461901d5b8738cec45113ef7e599b16f9058d1","tools": ["tool_result_read","list_room_targets",@@@ -643,8 -656,8 +656,8 @@@]},"skills+voice+non-chief": {- "bytes": 53146,- "sha256": "31998337cc3c3bcf83353ed2094c3140ed9ca305708f0153d67816a62d099b52",- "bytes": 53724,- "sha256": "6bf7fd3d6e404b1e236f8b9f22b9f702cdc8034367dc799e2249187d8cb866b2",++ "bytes": 53832,++ "sha256": "20c008bdb7ade399b3e391e1d474e969ede68cf5cb3bb8ee698cddc2ae57f4d6","tools": ["tool_result_read","list_room_targets",@@@ -689,8 -703,8 +703,8 @@@]},"skills+shared+non-chief": {- "bytes": 54630,- "sha256": "253289864d07fcf05087793ed2d0c346b0aa661b58538ef693d4e97fe43d3175",- "bytes": 55208,- "sha256": "b48a369ca7b5c68d239dd31c26a7decea0444c8d08b17e629716a992144708e8",++ "bytes": 55316,++ "sha256": "db965becc32ce7aa75339f0cb93ead0e911e8a3d8a4b5570271cf1708b4e340e","tools": ["tool_result_read","list_shared_computers",@@@ -736,8 -751,8 +751,8 @@@]},"skills+shared+voice+non-chief": {- "bytes": 55411,- "sha256": "615aca75654b7836766f4d0a645a0b52a45970ca45aba3e2d6b24a129463258a",- "bytes": 55989,- "sha256": "41afa570703583a40a432a11655d7aa427d645c54b1f32773aaaf881e156525a",++ "bytes": 56097,++ "sha256": "03d6a0d9a39b0b0cf5e18550c52810548f39809e9b622b6ba0fca4911f3b4d92","tools": ["tool_result_read","list_shared_computers",@@@ -784,8 -800,8 +800,8 @@@]},"skills+shared+voice+cloud-home": {- "bytes": 64393,- "sha256": "f753c543275ef60e48940a930e892decdf869f139b4dfd1a2465d086bb75ff71",- "bytes": 64971,- "sha256": "6f01080bc3024adf9a80984d06e024d3b5b4fd8d8beca51de5292c1085a92b2f",++ "bytes": 65079,++ "sha256": "a5a0d5849e250c33b63bb04b914fe8c14bfbfe41ca1c163128202399e24f7975","tools": ["tool_result_read","list_shared_computers",@@@ -839,8 -856,8 +856,8 @@@]},"skills+shared+voice+non-chief+cloud-home": {- "bytes": 55177,- "sha256": "af346fb96aa07cfc3357ff67a242b7fcb6c8763b480b2bfff32705189bb2dd5d",- "bytes": 55755,- "sha256": "37d4ee1217b3be5ba60b7e65fd42520cef62c286f37d92193a4c5f7435ddc515",++ "bytes": 55863,++ "sha256": "1a659071281088ad5aa9d7e5116c2c62f0cbf4ba7068e0f61edcaf70c15d9a7c","tools": ["tool_result_read","list_shared_computers",@@@ -887,8 -905,8 +905,8 @@@]},"skills+shared+voice+escalations": {- "bytes": 65457,- "sha256": "516885fcb1aa705fd6c1e06b44093a5f00928976ea63e0e2694d1a9b63429530",- "bytes": 66035,- "sha256": "2c2d6a44230d5d854ca689d2d5540cd57b7be5797fba72ac295143a51c97d894",++ "bytes": 66143,++ "sha256": "bb56189a11306e2b4636f108135aee82b52fcc3be1cb4b6b616fc680aaaa3287","tools": ["tool_result_read","list_shared_computers",@@@ -943,8 -962,8 +962,8 @@@]},"skills+shared+voice+escalations+x": {- "bytes": 69296,- "sha256": "a805f3035208d757dd568eefe4b9ee663558ed54a7846ebf5d6447c1400ad73c",- "bytes": 69874,- "sha256": "5d819191ba0f0b10a8c8e8257bba37c7cb2b5c846b27a87814edc1422dbffb09",++ "bytes": 69982,++ "sha256": "018968d7f08733f6d23945eff608f5c41937d078de5d9e95f96ab59f06267a95","tools": ["tool_result_read","list_shared_computers",@@@ -1003,8 -1023,8 +1023,8 @@@]},"skills+shared+voice+escalations+x+team": {- "bytes": 69928,- "sha256": "178f2b6280272459e445524223168a218b1ad1dfdeba3a8cbc9b31e416e47114",- "bytes": 69874,- "sha256": "5d819191ba0f0b10a8c8e8257bba37c7cb2b5c846b27a87814edc1422dbffb09",++ "bytes": 69982,++ "sha256": "018968d7f08733f6d23945eff608f5c41937d078de5d9e95f96ab59f06267a95","tools": ["tool_result_read","list_shared_computers",@@@ -1166,8 -1188,8 +1188,8 @@@]},"skills+shared+voice+mausbot": {- "bytes": 65278,- "sha256": "5798b8fc0d4fb9267dd94376de171e1e126d8673cec52a0b1cadd621216b0a49",- "bytes": 65856,- "sha256": "dfa20b6735c189a0d056ecd54d8fdb8957b8f0db263454f039d90dc636a9c0c9",++ "bytes": 65964,++ "sha256": "eac49bb7dd495ff29c5ea3ea1d63d8c0c580b7686ea7a2f13408647ce7612b0a","tools": ["tool_result_read","list_shared_computers",diff --cc server/drivers/agents-catalog.tsindex 903bca9313,c9f505737f..51da9c2bd8--- a/server/drivers/agents-catalog.ts+++ b/server/drivers/agents-catalog.ts@@@ -746,7 -747,7 +747,7 @@@ const TOOL_DEFINITIONS ={name: "skill_manage",description:- "Submit a new or updated reusable SKILL.md, or turn one of your own skills on, off, or delete it (always after the person approves). Never change a skill unless the user explicitly asked for that named skill. If the result is pending, a create stays inactive and an update leaves the current version unchanged." + APPLIES_OUTCOME,- "Submit a new or updated reusable SKILL.md. Never update unless the user explicitly asked to revise that named skill. If the result is pending, a create stays inactive and an update leaves the current version unchanged." + APPLIES_OUTCOME,++ "Submit a new or updated reusable SKILL.md, or turn one of your own skills on or off, or delete it. Never change a skill unless the user explicitly asked for that named skill. If the result is pending, a create stays inactive and an update leaves the current version unchanged." + APPLIES_OUTCOME,inputSchema: {type: "object",additionalProperties: false,diff --cc server/drivers/agents-proxy.test.tsindex 7621b7cf07,4eb7481270..a239aeb38e--- a/server/drivers/agents-proxy.test.ts+++ b/server/drivers/agents-proxy.test.ts@@@ -2075,28 -2076,6 +2076,28 @@@ describe("agents-proxy MCP surface", (expect(missingTarget.result.isError).toBe(true);expect(missingTarget.result.content[0].text).toContain("needs skill_name");expect(lastSkillStageBody).toBeNull();++ const missingSkillMd = await callTool("skill_manage", { action: "create", source: "conversation" });+ expect(missingSkillMd.result.isError).toBe(true);+ expect(missingSkillMd.result.content[0].text).toContain("needs skill_md");+ expect(lastSkillStageBody).toBeNull();+ });+- it("asks the person before a skill is turned on, turned off or deleted", async () => {++ it("sends turning a skill on, off or deleting it to the skill stage route", async () => {+ for (const [action, verb] of [["enable", "turn on"], ["disable", "turn off"], ["delete", "delete"]] as const) {+ lastSkillStageBody = null;+ const switched = await callTool("skill_manage", { action, skill_name: " learned-expense " });+ expect(lastSkillStageBody).toEqual({ fromBotId: "bot-asker", fromThreadId: "thread-asker-routine", action, skill_name: "learned-expense" });+ expect(switched.result.isError).toBeFalsy();+ expect(switched.result.content[0].text).toContain(`to ${verb} skill “learned-expense”`);+ expect(switched.result.content[0].text).toContain("wait for the decision");+ }++ lastSkillStageBody = null;+ const unnamed = await callTool("skill_manage", { action: "delete" });+ expect(unnamed.result.isError).toBe(true);+ expect(unnamed.result.content[0].text).toContain("needs skill_name to delete a skill");+ expect(lastSkillStageBody).toBeNull();});});diff --cc server/host/skill-switch-host.test.tsindex a1f33b183b,0000000000..25c7177df2mode 100644,000000..100644--- a/server/host/skill-switch-host.test.ts+++ b/server/host/skill-switch-host.test.ts@@@ -1,97 -1,0 +1,134 @@@+import { mkdtempSync, readdirSync, rmSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";++import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import type { SkillRequestCardData, SkillSwitchAction } from "../../shared/skill-request.ts";+import type { OptionCardData } from "../../shared/wire.ts";+import { flushDecisionLog } from "../decision-log.ts";+import type { BotRecord } from "../store.ts";++const mocks = vi.hoisted(() => ({ setImportedSkillEnabled: vi.fn() }));+vi.mock("../imported-skills.ts", () => ({ setImportedSkillEnabled: mocks.setImportedSkillEnabled }));+vi.mock("../skills.ts", async (importOriginal) => ({+ ...(await importOriginal<typeof import("../skills.ts")>()),+ listSkills: () => [],+ readSkillFile: () => null,+}));++import { createSkillSwitchHost } from "./skill-switch-host.ts";++const skillMd = (key: string) => `---\nname: lookup\ndescription: Looks things up\n---\nkey: sk-ant-api03-${key.repeat(40)}\n`;+const dirs: string[] = [];++function setup() {+ const dataDir = mkdtempSync(join(tmpdir(), "skill-switch-host-"));+ dirs.push(dataDir);+ const bot = { id: "b1", name: "Bot", color: "blue" } as BotRecord;+ const messages: Array<{ id: string; card: OptionCardData }> = [];+ let file = skillMd("A");++ let enabled = true;+ let appendFails = false;+ const host = createSkillSwitchHost({+ store: {+ bot: () => bot,+ appendMessage: ((_threadId: string, message: { card: OptionCardData }) => { if (appendFails) throw new Error("disk full"); messages.push({ id: `m${messages.length}`, card: message.card }); }) as never,+ patchMessage: ((_threadId: string, id: string, patch: { card: OptionCardData }) => { messages.find((message) => message.id === id)!.card = patch.card; }) as never,+ },+ dataDir,+ persistence: () => ({ ok: true }),- listBotSkills: () => [{ name: "lookup", enabled: true, source: "imported", description: "Looks things up", origin: "imported" } as never],++ listBotSkills: () => [{ name: "lookup", enabled, source: "imported", description: "Looks things up", origin: "imported" } as never],+ readBotSkillFile: () => file,+ noteSkillChange: vi.fn(),+ });+ const card = () => messages.at(-1)!.card;+ const approve = () => {+ const { id, card: shown } = messages.at(-1)!;+ const request = shown.skillRequest as SkillRequestCardData & { action: SkillSwitchAction };+ return host.resolve({ botId: bot.id, threadId: "t1", requestId: request.requestId, behavior: "allow", reviewedSha256: request.sha256 }, id, shown, request);+ };- const pins = () => readdirSync(join(dataDir, "skill-switch"));- return { bot, host, card, approve, pins, edit: (next: string) => { file = next; }, failAppend: () => { appendFails = true; } };++ const pins = () => { try { return readdirSync(join(dataDir, "skill-switch")); } catch { return []; } };++ const undo = () => {++ const { id, card: shown } = messages.at(-1)!;++ const request = shown.skillRequest as SkillRequestCardData & { action: SkillSwitchAction };++ return host.undo(bot.id, "t1", { id, card: shown } as never, request);++ };++ return { bot, host, card, approve, undo, pins, edit: (next: string) => { file = next; }, failAppend: () => { appendFails = true; }, setEnabled: (next: boolean) => { enabled = next; } };+}++beforeEach(() => {+ mocks.setImportedSkillEnabled.mockReset().mockReturnValue({ name: "lookup", enabled: false });+});+afterEach(async () => {+ for (const dir of dirs.splice(0)) {+ await flushDecisionLog(dir);+ rmSync(dir, { recursive: true, force: true });+ }+});++describe("skill switch cards", () => {- it("turns off an imported skill only after the person approves", () => {++ it("turns off an imported skill only after the person approves when changes wait for the owner", () => {+ const { bot, host, card, approve, pins } = setup();- expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" })).toMatchObject({ status: 201, body: { state: "pending" } });++ expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" }, null)).toMatchObject({ status: 201, body: { state: "pending" } });+ expect(card()).toMatchObject({ title: "Turn off skill \"lookup\"?", options: ["Turn off", "Deny"] });+ expect(card().skillRequest?.preview).not.toContain("AAAA");+ expect(mocks.setImportedSkillEnabled).not.toHaveBeenCalled();+ expect(pins()).toHaveLength(1);++ expect(approve()).toEqual({ claimed: true, outcome: "allowed-once" });+ expect(mocks.setImportedSkillEnabled).toHaveBeenCalledWith("b1", "lookup", false);+ expect(card()).toMatchObject({ answered: "allow", title: "Skill \"lookup\" turned off" });+ expect(pins()).toHaveLength(0);+ });++ it("refuses approval when a hidden secret changed after the card opened", () => {+ const { bot, host, card, approve, edit } = setup();- expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" }).status).toBe(201);++ expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" }, null).status).toBe(201);+ const shown = card().skillRequest?.sha256;+ // Same length, so the redacted preview and the card's sha256 stay the same.+ edit(skillMd("B"));+ expect(approve()).toEqual({ claimed: true, status: 422, error: expect.stringContaining("changed after this card was shown") });+ expect(card().skillRequest?.sha256).toBe(shown);+ expect(card().held).toContain("changed after this card was shown");+ expect(mocks.setImportedSkillEnabled).not.toHaveBeenCalled();+ });++ it("leaves no digest pin behind when the card can't be added", () => {+ const { bot, host, pins, failAppend } = setup();+ failAppend();- expect(() => host.stage(bot, "t1", "disable", { skill_name: "lookup" })).toThrow("disk full");++ expect(() => host.stage(bot, "t1", "disable", { skill_name: "lookup" }, null)).toThrow("disk full");++ expect(pins()).toHaveLength(0);++ });++++ it("turns off an imported skill at once where the bot's own changes apply directly, and undoes it from the receipt", () => {++ const { bot, host, card, undo, pins, setEnabled } = setup();++ expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" }, "full-access")).toMatchObject({++ status: 201, body: { state: "applied", name: "lookup", action: "disable", summary: "Skill \"lookup\" turned off." },++ });++ expect(mocks.setImportedSkillEnabled).toHaveBeenCalledWith("b1", "lookup", false);++ expect(card()).toMatchObject({ answered: "allow", autoApplied: true, options: [], title: "Skill \"lookup\" turned off" });++ expect(card().skillRequest?.preview).not.toContain("AAAA");+ expect(pins()).toHaveLength(0);++++ setEnabled(false);++ expect(undo()).toEqual({ claimed: true, state: "undone" });++ expect(mocks.setImportedSkillEnabled).toHaveBeenLastCalledWith("b1", "lookup", true);++ expect(card().undone).toBe(true);++ });++++ it("refuses Undo, changing nothing, once the skill was switched back since", () => {++ const { bot, host, undo } = setup();++ expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" }, "level").body.state).toBe("applied");++ mocks.setImportedSkillEnabled.mockClear();++ expect(undo()).toMatchObject({ claimed: true, state: "invalid", status: 409, stale: true });++ expect(mocks.setImportedSkillEnabled).not.toHaveBeenCalled();++ });++++ it("reports a switch that fails to apply directly, with no receipt", () => {++ const { bot, host, card } = setup();++ mocks.setImportedSkillEnabled.mockReturnValue({ error: "the skill folder is gone" });++ expect(host.stage(bot, "t1", "disable", { skill_name: "lookup" }, "self")).toEqual({ status: 422, body: { state: "failed", error: "the skill folder is gone" } });++ expect(() => card()).toThrow();+ });+});diff --cc server/host/skill-switch-host.tsindex 0916322ef2,0000000000..2b0129ce2emode 100644,000000..100644--- a/server/host/skill-switch-host.ts+++ b/server/host/skill-switch-host.ts@@@ -1,157 -1,0 +1,242 @@@- // A bot asks to turn one of its skills on or off, or to delete it. That always waits for the person on a card, even with- // Full Access, and approval applies only if the skill is still the one the card showed: the digest of its full SKILL.md,- // secrets included, is pinned on the server when the card opens, since the card's own sha256 covers only the redacted preview.++// A bot turns one of its own skills on or off, or deletes it. Where the bot's own skill writes apply directly, this does too,++// with a receipt and Undo. Otherwise the person decides on a card, and approval applies only if the skill is still the one the++// card showed: the digest of its full SKILL.md, secrets included, is pinned on the server when the card opens, since the card's++// own sha256 covers only the redacted preview.+import { randomUUID } from "node:crypto";+import { mkdirSync, readFileSync, rmSync } from "node:fs";+import { dirname, join } from "node:path";+import type { SkillRequestCardData, SkillSwitchAction } from "../../shared/skill-request.ts";+import type { OptionCardData } from "../../shared/wire.ts";+import { writeFileAtomic } from "../atomic.ts";+import { appendDecision } from "../decision-log.ts";++import { UNDO_STALE, type DirectApply } from "../direct-apply.ts";+import { setImportedSkillEnabled } from "../imported-skills.ts";- import { listSkills, readSkillFile, removeSkill, setSkillEnabled } from "../skills.ts";++import { applySkillWriteWithReceipt, listSkills, readSkillFile, readSkillReferences, rejectStagedSkillWrite, removeSkill, setSkillEnabled, stageSkillWrite } from "../skills.ts";+import { skillSwitchCardCopy, skillSwitchStillMatches, skillSwitchTarget, type SkillSwitchTarget, type SwitchableSkill } from "../skill-switch.ts";+import { conversationLanguage } from "../server-lines.ts";- import type { BotRecord, Store } from "../store.ts";++import type { BotRecord, Message, Store } from "../store.ts";++export interface SkillSwitchHostDeps {+ store: Pick<Store, "bot" | "appendMessage" | "patchMessage">;+ dataDir: string;- /** The open-card checks every skill card passes; a switch card opens even with Full Access. */- persistence(botId: string, threadId: string): { ok: true } | { ok: false; status: number; error: string };++ /** The checks every skill change passes; opensCard adds the open-card limit. */++ persistence(botId: string, threadId: string, opensCard: boolean): { ok: true } | { ok: false; status: number; error: string };+ listBotSkills(bot: BotRecord): Array<{ name: string; enabled: boolean; source: string; description: string }>;+ readBotSkillFile(bot: BotRecord, name: string): string | null;+ noteSkillChange(botId: string, threadId: string): void;+}++export interface SkillSwitchResolveArgs {+ botId: string;+ botName?: string;+ threadId: string;+ requestId: string;+ behavior: "allow" | "deny" | "answer";+ reviewedSha256?: string;+}++export type SkillSwitchResolution =+ | { claimed: true; status: number; error: string }+ | { claimed: true; outcome: "allowed-once" | "rejected"; alreadySettled?: true };+++export type SkillSwitchUndo =++ | { claimed: true; state: "already_undone" | "undone" }++ | { claimed: true; state: "invalid"; error: string; status: number; stale?: true };++++const UNDO_ACTION: Record<"enable" | "disable", "enable" | "disable"> = { enable: "disable", disable: "enable" };+++export function createSkillSwitchHost(deps: SkillSwitchHostDeps) {+ const { store } = deps;+ const pinPath = (requestId: string) => join(deps.dataDir, "skill-switch", `${requestId}.sha256`);+ const readPin = (requestId: string) => {+ try { return readFileSync(pinPath(requestId), "utf8"); } catch { return ""; }+ };+ const dropPin = (requestId: string) => rmSync(pinPath(requestId), { force: true });++ /** The skill a bot asked to turn on, turn off or delete, as it is now. */+ function switchableSkill(bot: BotRecord, name: string): SwitchableSkill | undefined {+ const own = listSkills(bot.id).find((skill) => skill.name === name);+ // Org skills an Admin pushed stay the person's to change, like library skills.+ if (own) return { kind: own.source.startsWith("org:") ? "fixed" : "own", enabled: own.enabled, text: readSkillFile(bot.id, name), source: own.source, description: own.description };+ const seen = deps.listBotSkills(bot).find((skill) => skill.name === name);+ if (!seen) return undefined;+ const imported = (seen as { origin?: string }).origin === "imported";+ return { kind: imported ? "imported" : "fixed", enabled: seen.enabled, text: imported ? deps.readBotSkillFile(bot, name) : null, source: seen.source, description: seen.description };+ }+- function appendCard(args: { requestId: string; botId: string; threadId: string; action: SkillSwitchAction; name: string; target: SkillSwitchTarget }): string {- const { requestId } = args;++ /** What Undo needs to bring a deleted skill back: its files as they are now, and whether it was on. */++ function deletedSkillFiles(botId: string, name: string, skill: SwitchableSkill): SkillRequestCardData["previous"] {++ if (skill.kind !== "own" || skill.text === null || !skill.source) return undefined;++ const references = readSkillReferences(botId, name);++ if (references === null) return undefined;++ return { preview: skill.text, source: skill.source, ...(references.length ? { references } : {}), ...(skill.enabled ? {} : { enabled: false }) };++ }++++ function appendCard(args: {++ requestId: string; botId: string; threadId: string; action: SkillSwitchAction; name: string; target: SkillSwitchTarget;++ applied?: { previous?: SkillRequestCardData["previous"] };++ }): { title: string; done: string } {++ const { requestId, applied } = args;+ const copy = skillSwitchCardCopy(args.action, args.name, args.target.gist, conversationLanguage(args.threadId));+ const payload: SkillRequestCardData = {+ version: 1,+ requestId,+ botId: args.botId,+ threadId: args.threadId,+ // Nothing is staged: approval binds to the SKILL.md digest pinned on the server.+ stagedId: `switch-${requestId}`,+ action: args.action,+ name: args.name,+ gist: args.target.gist,+ ...(args.target.source ? { source: args.target.source } : {}),+ preview: args.target.preview,+ sha256: args.target.sha256,+ warnings: [],+ createdAt: Date.now(),++ ...(applied?.previous ? { previous: applied.previous } : {}),+ };+ const from = store.bot(args.botId);+ store.appendMessage(args.threadId, {+ role: "bot",+ kind: "options",+ from: from ? { botId: from.id, name: from.name, color: from.color } : undefined,- card: { title: copy.title, subtitle: copy.subtitle, options: [copy.option, "Deny"], requestId, tool: "stage_skill", skillRequest: payload },++ card: {++ title: copy.title,++ subtitle: copy.subtitle,++ options: applied ? [] : [copy.option, "Deny"],++ ...(applied ? { answered: "allow" as const, autoApplied: true, title: copy.done } : {}),++ requestId,++ tool: "stage_skill",++ skillRequest: payload,++ },+ });- return copy.title;++ return { title: copy.title, done: copy.done };+ }++ function apply(botId: string, name: string, action: SkillSwitchAction, kind: SwitchableSkill["kind"] | undefined) {+ if (action === "delete") return removeSkill(botId, name);+ return (kind === "imported" ? setImportedSkillEnabled : setSkillEnabled)(botId, name, action === "enable");+ }+- /** Turning a skill on or off, or deleting it, always waits for the person, even with Full Access. */- function stage(from: BotRecord, threadId: string, action: SkillSwitchAction, body: Record<string, unknown>): { status: number; body: Record<string, unknown> } {++ /** Where the bot's own skill writes apply directly, so does this, with a receipt; otherwise the person decides on a card. */++ function stage(from: BotRecord, threadId: string, action: SkillSwitchAction, body: Record<string, unknown>, direct: DirectApply | null): { status: number; body: Record<string, unknown> } {+ const name = typeof body.skill_name === "string" ? body.skill_name.trim() : "";+ if (!name) return { status: 400, body: { error: `skill_name is required when action is ${action}` } };- const persistence = deps.persistence(from.id, threadId);++ const persistence = deps.persistence(from.id, threadId, !direct);+ if (!persistence.ok) return { status: persistence.status, body: { error: persistence.error } };- const target = skillSwitchTarget(name, action, switchableSkill(from, name));++ const current = switchableSkill(from, name);++ const target = skillSwitchTarget(name, action, current);+ if ("error" in target) return { status: 422, body: { error: target.error } };+ const requestId = randomUUID();++ if (direct) {++ const previous = action === "delete" && current ? deletedSkillFiles(from.id, name, current) : undefined;++ const applied = apply(from.id, name, action, current?.kind);++ if ("error" in applied) return { status: 422, body: { state: "failed", error: applied.error } };++ const { done } = appendCard({ requestId, botId: from.id, threadId, action, name, target, applied: { previous } });++ appendDecision(deps.dataDir, { threadId, requestId, botId: from.id, botName: from.name,++ tool: "stage_skill", summary: done, decision: "auto-approved", source: direct });++ deps.noteSkillChange(from.id, threadId);++ return { status: 201, body: { state: "applied", name, action, gist: target.gist, warnings: [], summary: `${done}.` } };++ }+ mkdirSync(dirname(pinPath(requestId)), { recursive: true, mode: 0o700 });+ writeFileAtomic(pinPath(requestId), target.contentSha256, { mode: 0o600 });+ let summary: string;+ try {- summary = appendCard({ requestId, botId: from.id, threadId, action, name, target });++ summary = appendCard({ requestId, botId: from.id, threadId, action, name, target }).title;+ } catch (error) {+ dropPin(requestId);+ throw error;+ }+ appendDecision(deps.dataDir, { threadId, requestId, botId: from.id, botName: from.name,+ tool: "stage_skill", summary, decision: "card-shown", source: "skill" });+ return { status: 201, body: { state: "pending", name, action, gist: target.gist, warnings: [], summary } };+ }++ function resolve(+ args: SkillSwitchResolveArgs,+ messageId: string,+ card: OptionCardData,+ request: SkillRequestCardData & { action: SkillSwitchAction },+ ): SkillSwitchResolution {+ if (card.answered || card.dismissed) {+ return { claimed: true, outcome: card.answered === "allow" ? "allowed-once" : "rejected", alreadySettled: true };+ }+ const decided = (decision: "user-approved" | "user-denied") => appendDecision(deps.dataDir, { threadId: args.threadId,+ requestId: args.requestId, botId: args.botId, botName: args.botName, tool: card.tool, summary: card.subtitle, decision, source: "user" });+ if (args.behavior !== "allow") {+ store.patchMessage(args.threadId, messageId, { card: { ...card, answered: "deny", dismissed: true, held: undefined } });+ dropPin(request.requestId);+ decided("user-denied");+ return { claimed: true, outcome: "rejected" };+ }+ if (!request.sha256 || args.reviewedSha256 !== request.sha256) {+ return { claimed: true, status: 409, error: "reviewedSha256 must match the skill shown on the approval card" };+ }+ if (request.requestId !== args.requestId || request.threadId !== args.threadId) {+ return { claimed: true, status: 422, error: "this approval card no longer matches its skill" };+ }+ const bot = store.bot(args.botId);+ const current = bot ? switchableSkill(bot, request.name) : undefined;+ const still = skillSwitchStillMatches(request.name, request.action, current, readPin(request.requestId));+ const applied = "error" in still ? still : apply(args.botId, request.name, request.action, current?.kind);+ if ("error" in applied) {+ store.patchMessage(args.threadId, messageId, { card: { ...card, held: applied.error } });+ return { claimed: true, status: 422, error: applied.error };+ }+ store.patchMessage(args.threadId, messageId, {+ card: { ...card, answered: "allow", held: undefined, title: skillSwitchCardCopy(request.action, request.name, "", conversationLanguage(args.threadId)).done },+ });+ deps.noteSkillChange(args.botId, args.threadId);+ decided("user-approved");+ dropPin(request.requestId);+ return { claimed: true, outcome: "allowed-once" };+ }+- return { stage, resolve };++ /** Brings a deleted skill back as the bot's own learned skill. */++ function recreate(botId: string, previous: NonNullable<SkillRequestCardData["previous"]>, gist: string): { ok: true } | { error: string } {++ const staged = stageSkillWrite(botId, {++ action: "create",++ files: [{ path: "SKILL.md", content: previous.preview }, ...(previous.references ?? [])],++ gist,++ source: previous.source,++ });++ if ("error" in staged) return staged;++ const applied = applySkillWriteWithReceipt(botId, staged, () => {});++ if ("error" in applied) {++ rejectStagedSkillWrite(botId, staged.id);++ return applied;++ }++ if (previous.enabled === false) {++ const off = setSkillEnabled(botId, staged.name, false);++ if ("error" in off) return off;++ }++ return { ok: true };++ }++++ /** Undo from the receipt of a change that applied on its own; refuses, changing nothing, once the skill moved on since. */++ function undo(botId: string, threadId: string, message: Message, request: SkillRequestCardData & { action: SkillSwitchAction }): SkillSwitchUndo {++ const card = message.card!;++ const bot = store.bot(botId);++ if (!bot) return { claimed: true, state: "invalid", error: "this change has no valid owner", status: 400 };++ const current = switchableSkill(bot, request.name);++ let undone: { ok: true } | { error: string } | { stale: true };++ if (request.action === "delete") {++ if (!request.previous) return { claimed: true, state: "invalid", error: "This change can't be undone here.", status: 409 };++ undone = current ? { stale: true } : recreate(botId, request.previous, request.gist);++ } else {++ const back = UNDO_ACTION[request.action];++ if (!current || current.kind === "fixed" || current.enabled !== (request.action === "enable")) undone = { stale: true };++ else {++ const flipped = apply(botId, request.name, back, current.kind);++ undone = "error" in flipped ? flipped : { ok: true };++ }++ }++ if ("stale" in undone) return { claimed: true, state: "invalid", error: UNDO_STALE, status: 409, stale: true };++ if ("error" in undone) return { claimed: true, state: "invalid", error: undone.error, status: 409 };++ store.patchMessage(threadId, message.id, { card: { ...card, undone: true } });++ deps.noteSkillChange(botId, threadId);++ return { claimed: true, state: "undone" };++ }++++ return { stage, resolve, undo };+}diff --cc server/host/skills-library.tsindex 53cf2ac373,d1f052cab2..3d8cb51774--- a/server/host/skills-library.ts+++ b/server/host/skills-library.ts@@@ -1,8 -1,8 +1,8 @@@import { randomUUID } from "node:crypto";import { join } from "node:path";- import { skillCommandTurnText, skillMentions } from "../../shared/skill-command.ts";- import type { SkillRequestCardData, SkillShareRecord } from "../../shared/skill-request.ts";+ import { skillCalls, skillCommandTurnText } from "../../shared/skill-command.ts";-import type { SkillRequestCardData, SkillShareRecord } from "../../shared/skill-request.ts";++import { isSkillSwitchAction, type SkillRequestCardData, type SkillShareRecord } from "../../shared/skill-request.ts";import { narrowestAudience, intersectAudience } from "../bot-visibility.ts";import { DATA_DIR, type AppConfig } from "../config.ts";import { appendDecision } from "../decision-log.ts";@@@ -348,8 -351,8 +351,8 @@@ export function createSkillsLibraryHostconst card = message?.card;const request = card?.skillRequest;if (!message || !card || !request) return { ok: false, status: 404, error: "this skill is no longer in the conversation" };-- if (!card.autoApplied || card.answered !== "allow" || card.undone) {-- return { ok: false, status: 409, error: "only a skill change that applied and was not undone can be shared" };++ if (!card.autoApplied || card.answered !== "allow" || card.undone || isSkillSwitchAction(request.action)) {++ return { ok: false, status: 409, error: "only a new or updated skill that applied and was not undone can be shared" };}if (request.shared) return { ok: true, shared: request.shared };const botId = message.from?.botId ?? store.botByThread(threadId)?.id;diff --cc server/index.test.tsindex d59cf47939,c76e7374c2..84097c6502--- a/server/index.test.ts+++ b/server/index.test.ts@@@ -11824,76 -11826,6 +11826,75 @@@ describe("harness HTTP API", () =>}});- it("turns a bot's own skill on, off or deletes it only after the person approves its card", async () => {++ it("turns a bot's own skill on, off or deletes it at once, with a receipt the person can undo", async () => {+ const bot = (await api("POST", "/api/bots", {})).body.bot;+ try {+ expect((await api("PATCH", `/api/bots/${bot.id}`, {+ modelSelection: { instanceId: "claude", model: "claude-sonnet-5" },+ })).status).toBe(200);+ const token = await mintTestCapability(BASE, bot.id, bot.threadId, { skillAuthoring: true });+ const post = (body: Record<string, unknown>) => fetch(`${BASE}/api/internal/skills/stage`, {+ method: "POST",+ headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },+ body: JSON.stringify({ fromBotId: bot.id, fromThreadId: bot.threadId, ...body }),+ });+ const latestCard = async (action: string) => {+ const messages = (await api("GET", "/api/bots")).body.bots.find((candidate: { id: string }) => candidate.id === bot.id).messages;+ return messages.filter((message: any) => message.card?.skillRequest?.name === "switch-me" && message.card.skillRequest.action === action).at(-1).card;+ };+ const skill = async () => (await api("GET", `/api/bots/${bot.id}/skills`)).body.skills.find((entry: { name: string }) => entry.name === "switch-me");- const respond = (body: Record<string, unknown>) => api("POST", `/api/threads/${bot.threadId}/respond`, body);- const stage = async (action: string) => {++ const skillText = async () => (await api("GET", `/api/bots/${bot.id}/skills/switch-me`)).body.text;++ const undo = (requestId: string) => api("POST", `/api/threads/${bot.threadId}/undo`, { requestId });++ const skillMd = "---\nname: switch-me\ndescription: Keeps notes.\n---\n\n# Switch me\n";++ const create = async () => expect((await post({ action: "create", source: "conversation", skill_md: skillMd })).status).toBe(201);++ const change = async (action: string, title: string) => {+ const response = await post({ action, skill_name: "switch-me" });+ expect(response.status).toBe(201);- expect(await response.json()).toMatchObject({ state: "pending", name: "switch-me", action });- return latestCard(action);++ expect(await response.json()).toMatchObject({ state: "applied", name: "switch-me", action });++ const receipt = await latestCard(action);++ expect(receipt).toMatchObject({ answered: "allow", autoApplied: true, options: [], title });++ return receipt;+ };+- expect((await post({- action: "create",- source: "conversation",- skill_md: "---\nname: switch-me\ndescription: Keeps notes.\n---\n\n# Switch me\n",- })).status).toBe(201);++ await create();+ expect(await skill()).toMatchObject({ enabled: true });+- // Even with Full Access, turning a skill off waits for the card.- const off = await stage("disable");- expect(off).toMatchObject({ title: "Turn off skill \"switch-me\"?", options: ["Turn off", "Deny"] });- expect(off.answered).toBeUndefined();- expect(off.skillRequest.preview).toContain("# Switch me");- expect(await skill()).toMatchObject({ enabled: true });- expect((await respond({ requestId: off.requestId, behavior: "allow", reviewedSha256: "0".repeat(64) })).status).toBe(409);- expect(await skill()).toMatchObject({ enabled: true });- expect((await respond({ requestId: off.requestId, behavior: "allow", reviewedSha256: off.skillRequest.sha256 })).status).toBe(200);++ const off = await change("disable", "Skill \"switch-me\" turned off");+ expect(await skill()).toMatchObject({ enabled: false });- expect(await latestCard("disable")).toMatchObject({ answered: "allow", title: "Skill \"switch-me\" turned off" });+ expect((await post({ action: "disable", skill_name: "switch-me" })).status).toBe(422);++ expect((await undo(off.requestId)).status).toBe(200);++ expect(await skill()).toMatchObject({ enabled: true });++ expect(await latestCard("disable")).toMatchObject({ undone: true });+- // Saying no changes nothing.- const on = await stage("enable");- expect((await respond({ requestId: on.requestId, behavior: "deny" })).status).toBe(200);- expect(await skill()).toMatchObject({ enabled: false });- expect(await latestCard("enable")).toMatchObject({ answered: "deny" });- const onAgain = await stage("enable");- expect((await respond({ requestId: onAgain.requestId, behavior: "allow", reviewedSha256: onAgain.skillRequest.sha256 })).status).toBe(200);++ const offAgain = await change("disable", "Skill \"switch-me\" turned off");++ const on = await change("enable", "Skill \"switch-me\" turned on");+ expect(await skill()).toMatchObject({ enabled: true });++ expect((await undo(offAgain.requestId)).status, "the skill is on again since, so turning it back on is stale").toBe(409);++ expect((await undo(on.requestId)).status).toBe(200);++ expect(await skill()).toMatchObject({ enabled: false });+- const gone = await stage("delete");- expect(gone).toMatchObject({ title: "Delete skill \"switch-me\"?", options: ["Delete", "Deny"] });- expect(await skill()).toBeDefined();- expect((await respond({ requestId: gone.requestId, behavior: "allow", reviewedSha256: gone.skillRequest.sha256 })).status).toBe(200);++ const gone = await change("delete", "Skill \"switch-me\" deleted");+ expect(await skill()).toBeUndefined();++ expect(gone.skillRequest.previous).toMatchObject({ preview: skillMd, enabled: false });++ expect((await undo(gone.requestId)).status).toBe(200);++ expect(await skill(), "a skill that was off comes back off").toMatchObject({ enabled: false });++ expect(await skillText()).toBe(skillMd);++++ expect((await post({ action: "enable", skill_name: "switch-me" })).status).toBe(201);++ const goneAgain = await change("delete", "Skill \"switch-me\" deleted");++ await create();++ expect((await undo(goneAgain.requestId)).status, "a skill of that name exists again").toBe(409);+- const missing = await post({ action: "enable", skill_name: "switch-me" });++ const missing = await post({ action: "enable", skill_name: "not-there" });+ expect(missing.status).toBe(422);+ expect(((await missing.json()) as { error: string }).error).toContain("no skill named");+ expect((await post({ action: "delete" })).status).toBe(400);+ } finally {+ await api("POST", `/api/bots/${bot.id}/interrupt`);+ await api("DELETE", `/api/bots/${bot.id}`);+ }+ }, 60_000);+it("applies a bot's own learned skill at once and undoes it from its receipt", async () => {const bot = (await api("POST", "/api/bots", {})).body.bot;try {diff --cc server/index.tsindex e81131bba7,e8729ef9c1..d5c5e6a5c1--- a/server/index.ts+++ b/server/index.ts@@@ -9566,10 -9466,14 +9466,10 @@@ function undoSkillCard(botId: string, tif (!card.autoApplied || card.answered !== "allow") {return { claimed: true, state: "invalid", error: "Only a change that applied on its own can be undone here.", status: 409 };}- if (request.botId !== botId || request.threadId !== threadId) {- return { claimed: true, state: "invalid", error: "this skill request belongs to a different bot", status: 403 };- }- if (request.shared) return skillsHost.undoReceipt(botId, threadId, message, { ...request, shared: request.shared });- const undone = undoSkillWrite(botId, {- stagedId: request.stagedId,- name: request.name,- action: request.action,+ if (request.botId !== botId || request.threadId !== threadId) return { claimed: true, state: "invalid", error: "this skill request belongs to a different bot", status: 403 };- const action = request.action; if (isSkillSwitchAction(action)) return { claimed: true, state: "invalid", error: "This change was approved on its card and can't be undone here.", status: 409 };++ const action = request.action; if (isSkillSwitchAction(action)) return skillSwitch.undo(botId, threadId, message, { ...request, action });+ if (request.shared) return skillsHost.undoReceipt(botId, threadId, message, { ...request, action, shared: request.shared });+ const undone = undoSkillWrite(botId, { stagedId: request.stagedId, name: request.name, action,...(request.previous ? { previous: { skillMd: request.previous.preview, source: request.previous.source, references: request.previous.references ?? [] } } : {}),});if ("stale" in undone) return { claimed: true, state: "invalid", error: UNDO_STALE, status: 409, stale: true };@@@ -11446,7 -11348,6 +11344,7 @@@ function appendSkillRequestCard(args:};}- const skillSwitch = createSkillSwitchHost({ store, dataDir: DATA_DIR, persistence: (botId, threadId) => skillProposalPersistence(botId, threadId, true, true), listBotSkills, readBotSkillFile, noteSkillChange: (botId, threadId) => skillReview.noteSkillChange(botId, threadId) });++const skillSwitch = createSkillSwitchHost({ store, dataDir: DATA_DIR, persistence: skillProposalPersistence, listBotSkills, readBotSkillFile, noteSkillChange: (botId, threadId) => skillReview.noteSkillChange(botId, threadId) });function resolveSkillRequest(args: {botId: string;botName?: string;@@@ -13820,8 -13721,7 +13719,8 @@@ const handleRequest = async (req: Incomif (!connectorThread(from.id, fromThreadId)) {return json(res, 403, { error: "source conversation does not belong to sender" });}- if (isSkillSwitchAction(body.action)) { const staged = skillSwitch.stage(from, fromThreadId, body.action, body); return json(res, staged.status, staged.body); }const direct = appliesDirectly(from.id, fromThreadId);++ if (isSkillSwitchAction(body.action)) { const staged = skillSwitch.stage(from, fromThreadId, body.action, body, direct); return json(res, staged.status, staged.body); }const persistence = skillProposalPersistence(from.id, fromThreadId, !direct);if (!persistence.ok) return json(res, persistence.status, { error: persistence.error });const action = body.action === "create" || body.action === "update" ? body.action : "";diff --cc shared/skill-request.tsindex b0f753415f,fb28578bdb..0a70e54026--- a/shared/skill-request.ts+++ b/shared/skill-request.ts@@@ -48,9 -36,9 +48,9 @@@ export interface SkillRequestCardDatareferencesSha256?: string;warnings: string[];createdAt: number;-- /** An update that applied without a person: the SKILL.md it replaced, so-- * Undo can put it back while the skill is unchanged since. */-- previous?: { preview: string; source: string; references?: Array<{ path: string; content: string }> };++ /** An update or delete that applied without a person: the SKILL.md it replaced or removed, so++ * Undo can put it back while the skill is unchanged since. enabled is false for a deleted skill that was off. */++ previous?: { preview: string; source: string; references?: Array<{ path: string; content: string }>; enabled?: boolean };shared?: SkillShareRecord;shareError?: string;}diff --cc src/components/ApprovalCard.tsxindex 50d29f1529,f1c1192944..e77a1b8d8c--- a/src/components/ApprovalCard.tsx+++ b/src/components/ApprovalCard.tsx@@@ -77,9 -71,8 +77,9 @@@ const PROFILE_FIELD_LABEL: Record<Profi/** A routine card no one answered is from before Triggers v2 applied changes on their own: nothing can confirm it now. */const staleRoutineCard = (card: OptionCardData) => Boolean(card.routineRequest && !card.answered);-/** The card brings its own question and answer words (its title and first option): team setup and MCP server changes. */-export const titledCard = (card: OptionCardData | undefined) => Boolean(card?.teamSetupRequest || card?.mcpRequest || card?.lendingLift);+/** Cards whose server-written title and first option say what approving does. */+export const titledCard = (card: OptionCardData | undefined) =>- Boolean(card?.teamSetupRequest || card?.mcpRequest || isSkillSwitchAction(card?.skillRequest?.action));++ Boolean(card?.teamSetupRequest || card?.mcpRequest || card?.lendingLift || isSkillSwitchAction(card?.skillRequest?.action));export function approvalCardOutcome(card: OptionCardData): string | undefined {const isProposal = Boolean(card.routineRequest || card.skillRequest || card.profileRequest || card.modelRequest || titledCard(card));@@@ -175,7 -168,7 +175,7 @@@ export function appliedChange(card: Optif (skill) {return {line: t(SKILL_APPLIED_LINE[skill.action], { name, title: skill.name }),-- canUndo: skill.action === "create" || Boolean(skill.previous),++ canUndo: skill.action === "create" || skill.action === "enable" || skill.action === "disable" || Boolean(skill.previous),};}const profile = card.profileRequest;@@@ -233,7 -226,7 +233,7 @@@ function AppliedChangeLine(const cancels = summary.cancels === true;const skill = card.skillRequest;const shared = skill?.shared ?? (sharedNow && sharedNow.requestId === card.requestId ? sharedNow.shared : undefined);-- const canShare = Boolean(skill && !shared && !undone && threadId && card.requestId)++ const canShare = Boolean(skill && !isSkillSwitchAction(skill.action) && !shared && !undone && threadId && card.requestId)&& shareLearnedSkillsMode(config) === "ask";const share = () => {const requestId = card.requestId;diff --cc src/components/GroupCallView.tsxindex aa456c4320,ac032042ee..cf17a99639--- a/src/components/GroupCallView.tsx+++ b/src/components/GroupCallView.tsx@@@ -15,9 -15,9 +15,10 @@@ import { cn } from "@/lib/cn"import { BotAvatar } from "./Avatar";import { CallTargetButton, type CallButtonPlacement } from "./CallView";import { useAdvancedMode } from "@/lib/interface-mode";+ import { speechBridge } from "@/lib/speech";import { useDesktopCapabilities } from "./DesktopCapabilities";import { isRoutineApproval, isSkillApproval, pendingApprovals, spokenApprovalPrompt } from "./PendingApproval";+import { titledCard } from "./ApprovalCard";const YES = /^(yes|yeah|yep|yup|sure|ok|okay|go ahead|do it|allow|approve|approved|fine|please do)\b/i;const NO = /^(no|nope|don'?t|do not|stop|deny|denied|cancel|never|skip it)\b/i;