Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Skills on all bots: each bot keeps a managed copy of its own

milind-soni8b2194805fd5
diff --git a/scripts/ci-scope.mjs b/scripts/ci-scope.mjs
index 1d1b2af5d5..a89676f895 100644
--- a/scripts/ci-scope.mjs
+++ b/scripts/ci-scope.mjs
@@ -80,6 +80,7 @@ export const VITEST_SUBSETS = {
"server/cloud-lending.e2e.test.ts",
"server/cloud-lent-mcp.e2e.test.ts",
"server/cloud-personal-slack.e2e.test.ts",
+ "server/cloud-send-all-bots.e2e.test.ts",
"server/cloud-send-kinds.e2e.test.ts",
"server/cloud-send-move.e2e.test.ts",
"server/cloud-send-rooms.e2e.test.ts",
diff --git a/scripts/ci-scope.test.ts b/scripts/ci-scope.test.ts
index 362daf23f8..3c2647f779 100644
--- a/scripts/ci-scope.test.ts
+++ b/scripts/ci-scope.test.ts
@@ -220,6 +220,7 @@ describe("CI outputs", () => {
"server/cloud-lending.e2e.test.ts",
"server/cloud-lent-mcp.e2e.test.ts",
"server/cloud-personal-slack.e2e.test.ts",
+ "server/cloud-send-all-bots.e2e.test.ts",
"server/cloud-send-kinds.e2e.test.ts",
"server/cloud-send-move.e2e.test.ts",
"server/cloud-send-rooms.e2e.test.ts",
diff --git a/server/cloud-send-all-bots.e2e.test.ts b/server/cloud-send-all-bots.e2e.test.ts
new file mode 100644
index 0000000000..bd26df8b77
--- /dev/null
+++ b/server/cloud-send-all-bots.e2e.test.ts
@@ -0,0 +1,34 @@
+// A skill on all of the person's bots, moved to their own Cloud: each bot's copy is one of its own skills, so the move
+// carries it with that bot's switch, and My Cloud, which has no record of the person's all-bots skills yet, keeps it as
+// the bot's own. Two real servers with main's own wiring between them (scripts/testing/cloud-send-fixture.ts); no network.
+import { randomBytes } from "node:crypto";
+import { afterAll, beforeAll, expect, it } from "vitest";
+import { launchCloudSendFixture, type CloudSendFixture } from "../scripts/testing/cloud-send-fixture.ts";
+import { hostTimeout } from "./testing/host-timeout.ts";
+
+const SKILL = "---\nname: client-onboarding\ndescription: Sets up a new client the way this person does.\n---\n\n# Client onboarding\n\nMake the folder, then the intake sheet.\n";
+let fx: CloudSendFixture;
+
+beforeAll(async () => { fx = await launchCloudSendFixture({ onePasswordToken: `ops_fake-allbots-${randomBytes(8).toString("hex")}` }); }, hostTimeout(60_000));
+afterAll(async () => { await fx?.close(); });
+
+type Skill = { name: string; enabled: boolean; allBots?: boolean };
+const skillsOn = async (side: CloudSendFixture["local"], botId: string) =>
+ ((await side("GET", `/api/bots/${botId}/skills`)).body.skills as Skill[]).filter((skill) => skill.name === "client-onboarding");
+
+it("carries each bot's copy of a skill on all bots, with its switch, and My Cloud keeps it as the bot's own", async () => {
+ const { local, onCloud } = fx;
+ const newBot = async (name: string) => (await local("POST", "/api/bots", { name, modelSelection: { instanceId: "claude", model: "claude-sonnet-5" } })).body.bot as { id: string };
+ const writer = await newBot("Writer"), researcher = await newBot("Researcher");
+ // Both bots have a conversation of their own, so the move does not pass them by as unused.
+ for (const bot of [writer, researcher]) await local("PATCH", `/api/bots/${bot.id}`, { soul: `You are ${bot.id}.` });
+ expect((await local("POST", `/api/bots/${writer.id}/skill-template`, { name: "client-onboarding", description: "", source: "test", text: SKILL, enabled: true })).status).toBe(201);
+ expect((await local("POST", `/api/bots/${writer.id}/skills/client-onboarding/all-bots`)).status).toBe(200);
+ expect((await local("PATCH", `/api/bots/${researcher.id}/skills/client-onboarding`, { enabled: false })).status).toBe(200);
+ expect(await skillsOn(local, researcher.id)).toEqual([expect.objectContaining({ enabled: false, allBots: true })]);
+
+ await fx.move();
+ expect(await skillsOn(onCloud, writer.id)).toEqual([expect.objectContaining({ enabled: true })]);
+ expect(await skillsOn(onCloud, researcher.id)).toEqual([expect.objectContaining({ enabled: false })]);
+ expect((await onCloud("GET", `/api/bots/${writer.id}/skills/client-onboarding`)).body.text).toBe(SKILL);
+}, hostTimeout(180_000));
diff --git a/server/cloud-team-skills-all-bots.e2e.test.ts b/server/cloud-team-skills-all-bots.e2e.test.ts
index 9b1fa38c80..6ddcc04399 100644
--- a/server/cloud-team-skills-all-bots.e2e.test.ts
+++ b/server/cloud-team-skills-all-bots.e2e.test.ts
@@ -44,6 +44,9 @@ it("reaches only the person's own bots, and only that person can put it on or ta
const adasWriter = await create(ada, "Ada's Writer");
const adasResearcher = await create(ada, "Ada's Researcher");
const olivesBot = await create(olive, "Olive's Helper");
+ const adasKeeper = await create(ada, "Ada's Keeper");
+ const different = SKILL.replace("Make the folder", "Ask first, then make the folder");
+ expect((await team.as(ada, "POST", `/api/bots/${adasKeeper.id}/skill-template`, { name: "client-onboarding", description: "", source: "test", text: different, enabled: true })).status).toBe(201);
const added = await team.as(ada, "POST", `/api/bots/${adasWriter.id}/skill-template`, { name: "client-onboarding", description: "", source: "test", text: SKILL, enabled: true });
expect(added.status, JSON.stringify(added.body)).toBe(201);
@@ -59,12 +62,10 @@ it("reaches only the person's own bots, and only that person can put it on or ta
expect(await skillsOf(olivesBot)).toEqual([]);
// A bot with a different copy of its own keeps it, and cannot silently replace the one on all of Ada's bots.
- const different = SKILL.replace("Make the folder", "Ask first, then make the folder");
- expect((await team.as(ada, "POST", `/api/bots/${later.id}/skill-template`, { name: "client-onboarding", description: "", source: "test", text: different, enabled: true })).status).toBe(201);
- expect(await skillsOf(later)).toEqual([expect.not.objectContaining({ allBots: true })]);
- expect((await allBots(ada, later)).status).toBe(409);
- expect((await team.as(ada, "DELETE", `/api/bots/${later.id}/skills/client-onboarding`)).status).toBe(200);
- expect(await skillsOf(later)).toEqual([expect.objectContaining({ allBots: true })]);
+ expect(await skillsOf(adasKeeper)).toEqual([expect.not.objectContaining({ allBots: true })]);
+ expect((await allBots(ada, adasKeeper)).status).toBe(409);
+ expect((await team.as(ada, "DELETE", `/api/bots/${adasKeeper.id}/skills/client-onboarding`)).status).toBe(200);
+ expect(await skillsOf(adasKeeper)).toEqual([expect.objectContaining({ allBots: true })]);
expect((await team.as(olive, "DELETE", `/api/bots/${adasResearcher.id}/skills/client-onboarding`)).status).toBe(403);
expect(await skillsOf(adasResearcher)).toHaveLength(1);
@@ -74,5 +75,7 @@ it("reaches only the person's own bots, and only that person can put it on or ta
expect(await skillsOf(adasWriter)).toEqual([expect.objectContaining({ enabled: true })]);
expect((await team.as(ada, "DELETE", `/api/bots/${adasWriter.id}/skills/client-onboarding`)).status).toBe(200);
- for (const bot of [adasWriter, adasResearcher, later]) expect(await skillsOf(bot)).toEqual([]);
+ for (const bot of [adasResearcher, later, adasKeeper]) expect(await skillsOf(bot)).toEqual([]);
+ // The bot whose own skill it was keeps it.
+ expect(await skillsOf(adasWriter)).toEqual([expect.not.objectContaining({ allBots: true })]);
}, hostTimeout(120_000));
diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.ts
index 17a3327d1d..6eca12ce9d 100644
--- a/server/drivers/agents-call.ts
+++ b/server/drivers/agents-call.ts
@@ -888,7 +888,7 @@ export async function callTool(called: string, input: Json, context: ToolCallCon
// Unreviewed imports: a hostile description is still prompt content, so only names and status.
const revision = typeof row.revision === "string" ? `, shared with your team, revision ${row.revision}` : "";
const unlisted = row.enabled && row.listed === false ? ", not in your prompt: search to read it" : "";
- const kind = row.allBots === true ? "on all your bots, update or delete changes every one" : row.editable === true ? "learned/editable" : "imported";
+ const kind = row.allBots === true ? "on all your bots: update/delete changes all" : row.editable === true ? "learned/editable" : "imported";
return `- ${row.name} (${row.enabled ? "enabled" : "disabled"}, ${kind}${revision}${unlisted})`;
}).join("\n")
: "(none)";
diff --git a/server/drivers/agents-catalog-goldens/full.tools-list.json b/server/drivers/agents-catalog-goldens/full.tools-list.json
index a0fbfa984d..576b2a2d64 100644
--- a/server/drivers/agents-catalog-goldens/full.tools-list.json
+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json
@@ -2321,7 +2321,7 @@
},
{
"name": "skill_manage",
- "description": "Create or update a reusable skill (SKILL.md), import one from GitHub or skills.sh (action import with source; same review as create, brings SKILL.md and references/*.md), or turn one of your own skills on or off, or delete it. all_bots on create or import puts it on every bot the person has, including later ones, in one call; updating or deleting a skill skills_list marks \"on all your bots\" changes it on every one, and enable/disable switches it for you only. Never change a skill unless the person explicitly asked for that named skill. It applies at once, with an Undo where possible: read the result before saying it did. It never raises another bot's execution permissions.",
+ "description": "Create or update a reusable skill (SKILL.md), import one from GitHub or skills.sh (action import with source; same review as create, brings SKILL.md and references/*.md), or turn one of your own skills on or off, or delete it. Never change a skill unless the person explicitly asked for that named skill. It applies at once, with an Undo where possible: read the result before saying it did. It never raises another bot's execution permissions.",
"inputSchema": {
"type": "object",
"additionalProperties": false,
@@ -2381,7 +2381,7 @@
},
"all_bots": {
"type": "boolean",
- "description": "create or import: put it on all of the person's bots instead of only yours. Only when the person asked for that."
+ "description": "create/import: on all the person's bots, if they asked."
}
},
"required": [
diff --git a/server/drivers/agents-catalog-goldens/profiles.json b/server/drivers/agents-catalog-goldens/profiles.json
index c93b151b83..adf17865bb 100644
--- a/server/drivers/agents-catalog-goldens/profiles.json
+++ b/server/drivers/agents-catalog-goldens/profiles.json
@@ -250,8 +250,8 @@
]
},
"skills": {
- "bytes": 64499,
- "sha256": "504aef63abaa549246bddfcb8262a624959392c9efd519c700235fabe40f64e2",
+ "bytes": 64203,
+ "sha256": "aae7fad4f2ee229d3cf1af7b225cbe082a091f5b16a9decb456f90a789e3a872",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -313,8 +313,8 @@
]
},
"skills+voice": {
- "bytes": 65280,
- "sha256": "7be47b5b9edf5ee92bbb73e13c391e45fe0b985b6756ba2d02895d8eabd0ced1",
+ "bytes": 64984,
+ "sha256": "a382e7141a435fc634da264287ed046efb6096fd629fa6e6714ee7304a0fa49e",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -377,8 +377,8 @@
]
},
"skills+shared": {
- "bytes": 66764,
- "sha256": "4f13bae5624d35fcf13d13d909111f903cebf574692789f2992764cad765018c",
+ "bytes": 66468,
+ "sha256": "a176ee481e4e99440651cb9d133c1bcd9324505d4f9bace687490622ba0a8c94",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -442,8 +442,8 @@
]
},
"skills+shared+voice": {
- "bytes": 67545,
- "sha256": "56477e49960c1a54899108b28a4e91150e1fb861e482aad936f4ac355db385f7",
+ "bytes": 67249,
+ "sha256": "1dccd55bc2bf5b3ad66f06f8a9bf7dcd3b0a14f42b2ce2c73ff3e097a34b7b05",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -730,8 +730,8 @@
]
},
"skills+non-chief": {
- "bytes": 55951,
- "sha256": "82a281e38499efada80bc6fcfde71ac12baf50a95d60f49faa978ab4e7e14c35",
+ "bytes": 55655,
+ "sha256": "7d24a4ec0031339d81b21bdbdd01b3cf8fb334940fd5cc9dfc282dafc8008398",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -786,8 +786,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 56732,
- "sha256": "d65a50e4c558b8397a1bb11de30429c442aad2bece5a24aae281b171cf91d64d",
+ "bytes": 56436,
+ "sha256": "3bf375d2832c7e18754b0aeb4d79b4b4529d874f4663f0ba96c88d9925d79da3",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -843,8 +843,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 58216,
- "sha256": "63f633164e79d17af1b4d464bed3649e2bd31c008cd6c0c63d87f736dc44e334",
+ "bytes": 57920,
+ "sha256": "109b7ee0669199fbbc5f2662de8b7149ca9c9d768b6c7916f229d463163aa72e",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -901,8 +901,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 58997,
- "sha256": "d65c170d9574942ee2603a8c49156065edbc56e3b8f9ce691321fd8583b9efda",
+ "bytes": 58701,
+ "sha256": "4626029842609a7ea726d62a6b258b7f75c6d8618f67bfe816c37d2cdfca3a20",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -960,8 +960,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 67301,
- "sha256": "081c478dbca7902462157e6d59e43302999f8c0714d71df23c768c41267a1cc2",
+ "bytes": 67005,
+ "sha256": "50716fefc26fb873f60d8719d1b2ab48acb21ddc0f5e035cbcc3c9ef3bd5d0ce",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1026,8 +1026,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 58753,
- "sha256": "f6e23c1841ab47e176bdd707d252e3355b04146336ba498f1d99f189c509cf0c",
+ "bytes": 58457,
+ "sha256": "2b4255a135f9b7f62e62030101df9862cf35ed038a6e25237b66ace9d3f5b41f",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1085,8 +1085,8 @@
]
},
"skills+shared+voice+x": {
- "bytes": 71384,
- "sha256": "4df799f96a502614c18404e69815499d35350bca04edeed195dc9752b5b085f6",
+ "bytes": 71088,
+ "sha256": "94f66edb7f2feab42288d68bfc675ba58f6849f800bbdaa20935db445312a66f",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1155,8 +1155,8 @@
]
},
"skills+shared+voice+x+team": {
- "bytes": 71384,
- "sha256": "4df799f96a502614c18404e69815499d35350bca04edeed195dc9752b5b085f6",
+ "bytes": 71088,
+ "sha256": "94f66edb7f2feab42288d68bfc675ba58f6849f800bbdaa20935db445312a66f",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1225,8 +1225,8 @@
]
},
"skills+shared+voice+x+team+images": {
- "bytes": 73331,
- "sha256": "47004afef7777c96015fdb6d43e79bde906c3a4163e84649e11491b615ab80da",
+ "bytes": 73035,
+ "sha256": "5aba546aa45810cf041a0ab06a112ed1257d179e577a35f2cc4dfa4cfe8ca904",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1421,8 +1421,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 68196,
- "sha256": "4dc84c4c807f314b30aae88128f750e3fb8f762ef96426c6578e6fd3bea061cd",
+ "bytes": 67900,
+ "sha256": "d8c61c9e0ffdcd5413f4c314c85c259ba70a81d5878b6614be78b9bb17e256e4",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1713,8 +1713,8 @@
]
},
"skills+shared+voice+x+team+images+hosting": {
- "bytes": 75194,
- "sha256": "d51aea236aa8118ffa7adfaae35081b1f59ed794df54acfafffabe8d9fef74d9",
+ "bytes": 74898,
+ "sha256": "7aba59dd3ebb5d451f22f36344d571a9e6561947efe750c6b7d68e6bcaf38250",
"tools": [
"tool_result_read",
"list_shared_computers",
diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.ts
index e15d99453b..cc415255ff 100644
--- a/server/drivers/agents-catalog.ts
+++ b/server/drivers/agents-catalog.ts
@@ -734,7 +734,7 @@ const TOOL_DEFINITIONS = [
{
name: "skill_manage",
description:
- "Create or update a reusable skill (SKILL.md), import one from GitHub or skills.sh (action import with source; same review as create, brings SKILL.md and references/*.md), or turn one of your own skills on or off, or delete it. all_bots on create or import puts it on every bot the person has, including later ones, in one call; updating or deleting a skill skills_list marks \"on all your bots\" changes it on every one, and enable/disable switches it for you only. Never change a skill unless the person explicitly asked for that named skill." + APPLIES_OUTCOME,
+ "Create or update a reusable skill (SKILL.md), import one from GitHub or skills.sh (action import with source; same review as create, brings SKILL.md and references/*.md), or turn one of your own skills on or off, or delete it. Never change a skill unless the person explicitly asked for that named skill." + APPLIES_OUTCOME,
inputSchema: {
type: "object",
additionalProperties: false,
@@ -759,7 +759,7 @@ const TOOL_DEFINITIONS = [
gist: { type: "string", description: "Optional one-line summary of the change." },
base_revision: { type: "string", description: "To update a skill shared with your team: its revision from skills_list." },
source: { type: "string", description: "create or update: the URL, folder or 'conversation' it came from. import: owner/repo, a GitHub link to the skill's folder or SKILL.md, or a skills.sh link." },
- all_bots: { type: "boolean", description: "create or import: put it on all of the person's bots instead of only yours. Only when the person asked for that." },
+ all_bots: { type: "boolean", description: "create/import: on all the person's bots, if they asked." },
},
required: ["action"],
},
diff --git a/server/host/skill-switch-host.ts b/server/host/skill-switch-host.ts
index 593178b6a6..2b0129ce2e 100644
--- a/server/host/skill-switch-host.ts
+++ b/server/host/skill-switch-host.ts
@@ -12,7 +12,6 @@ import { appendDecision } from "../decision-log.ts";
import { UNDO_STALE, type DirectApply } from "../direct-apply.ts";
import { setImportedSkillEnabled } from "../imported-skills.ts";
import { applySkillWriteWithReceipt, listSkills, readSkillFile, readSkillReferences, rejectStagedSkillWrite, removeSkill, setSkillEnabled, stageSkillWrite } from "../skills.ts";
-import { setAllBotsSkillOff } from "../skills-for-all-bots.ts";
import { skillSwitchCardCopy, skillSwitchStillMatches, skillSwitchTarget, type SkillSwitchTarget, type SwitchableSkill } from "../skill-switch.ts";
import { conversationLanguage } from "../server-lines.ts";
import type { BotRecord, Message, Store } from "../store.ts";
@@ -62,7 +61,6 @@ export function createSkillSwitchHost(deps: SkillSwitchHostDeps) {
const seen = deps.listBotSkills(bot).find((skill) => skill.name === name);
if (!seen) return undefined;
const imported = (seen as { origin?: string }).origin === "imported";
- if ((seen as { allBots?: boolean }).allBots) return { kind: "all-bots", enabled: seen.enabled, text: deps.readBotSkillFile(bot, name), source: seen.source, description: seen.description };
return { kind: imported ? "imported" : "fixed", enabled: seen.enabled, text: imported ? deps.readBotSkillFile(bot, name) : null, source: seen.source, description: seen.description };
}
@@ -117,8 +115,6 @@ export function createSkillSwitchHost(deps: SkillSwitchHostDeps) {
function apply(botId: string, name: string, action: SkillSwitchAction, kind: SwitchableSkill["kind"] | undefined) {
if (action === "delete") return removeSkill(botId, name);
- // This bot's own switch for a skill on all of the person's bots; the others keep theirs.
- if (kind === "all-bots") return (setAllBotsSkillOff(botId, name, action === "disable"), { ok: true as const });
return (kind === "imported" ? setImportedSkillEnabled : setSkillEnabled)(botId, name, action === "enable");
}
diff --git a/server/host/skills-for-all-bots-host.ts b/server/host/skills-for-all-bots-host.ts
index 38dc6acfcb..00113f25a0 100644
--- a/server/host/skills-for-all-bots-host.ts
+++ b/server/host/skills-for-all-bots-host.ts
@@ -1,34 +1,35 @@
-// skill_manage on all of the person's bots in one call: create (or import) with all_bots, and update or delete of a skill
-// that is already on all their bots. Like the bot's own skill changes, it applies directly with a receipt and Undo where
-// those do, and otherwise waits on a card; approval applies only the exact files the card showed, pinned on the server.
-// "All their bots" is the calling bot's person's (skills-for-all-bots.ts): on a Team Cloud the member it reports to, so a
-// bot nobody owns is refused. Turning one on or off stays a per-bot switch (skill-switch-host.ts).
+// Changes to a skill on all of the person's bots: skill_manage create (or import) with all_bots, update or delete of a
+// skill already on all their bots, and the Skills page's "Use on all bots". Like the bot's own skill changes, each applies
+// directly with a receipt and Undo where those do, and otherwise waits on a card; approval applies only the exact files the
+// card showed, kept on the server. In a room it always waits on the card: words a teammate posted there must not put a
+// skill on the person's bots by themselves. "All their bots" is the calling bot's person's (skills-for-all-bots.ts); on a
+// Team Cloud only a turn acting for that person may change them. Turning one on or off stays a per-bot switch.
import { createHash, randomUUID } from "node:crypto";
import { mkdirSync, readFileSync, rmSync } from "node:fs";
import { dirname, join } from "node:path";
import { z } from "zod";
+import { botOwner } from "../../shared/bot-owner.ts";
import type { SkillRequestCardData } 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 { botOwner } from "../../shared/bot-owner.ts";
import { personKey } from "../person-key.ts";
import { redactSecretsInText } from "../redact.ts";
import { conversationLanguage, serverLine, type ServerLineKey } from "../server-lines.ts";
import { learnSource } from "../skill-learn.ts";
import { parseSkillManageReferences } from "../skill-request-card.ts";
import { listSkills, preparedLearnedSkill, STAGED_GIST_MAX, STAGED_SKILL_FILE_MAX_BYTES } from "../skills.ts";
-import { allBotsScopeOfBot, allBotsSkills, SKILLS_FOR_ALL_BOTS_DIR, skillsForAllBotsOnTeam } from "../skills-for-all-bots.ts";
-import { copyDigest, putOnAllBots, removeFromAllBots, restoreOwnCopies, sharedCopy, type RetiredCopy, type SkillCopy } from "../skills-for-all-bots-ops.ts";
+import { allBotsScopeOfBot, allBotsUnavailable, SHARED_WITHOUT_TEAM, SKILLS_FOR_ALL_BOTS_DIR, skillsForAllBotsOnTeam } from "../skills-for-all-bots.ts";
+import { copyDigest, ownCopy, putOnAllBots, removeFromAllBots, restoreSwitches, sharedCopy, type SkillCopy } from "../skills-for-all-bots-ops.ts";
import type { BotRecord, Message, Store } from "../store.ts";
type Action = "create" | "update" | "delete";
type Result = { status: number; body: Record<string, unknown> };
export interface SkillsForAllBotsHostDeps {
- store: Pick<Store, "bot" | "appendMessage" | "patchMessage">;
+ store: Pick<Store, "bot" | "appendMessage" | "patchMessage" | "groupByThread">;
dataDir: string;
persistence(botId: string, threadId: string, opensCard: boolean): { ok: true } | { ok: false; status: number; error: string };
noteSkillChange(botId: string, threadId: string): void;
@@ -39,7 +40,7 @@ const copySchema = z.object({ skillMd: z.string(), files: z.array(fileSchema), s
const recordSchema = z.object({
scope: z.string(), action: z.enum(["create", "update", "delete"]), name: z.string(), digest: z.string(),
copy: copySchema.optional(), previous: copySchema.optional(),
- retired: z.array(z.object({ botId: z.string(), wasOff: z.boolean(), copy: copySchema })).optional(),
+ switches: z.array(z.object({ botId: z.string(), enabled: z.boolean() })).optional(),
});
type StoredCopy = z.infer<typeof copySchema>;
type SkillRecord = z.infer<typeof recordSchema>;
@@ -65,7 +66,7 @@ function claimed(bot: BotRecord, body: Record<string, unknown>): { action: Actio
const name = typeof body.skill_name === "string" ? body.skill_name.trim() : "";
if ((body.action === "create" || body.action === "import") && body.all_bots === true) return { action: "create", name };
if (body.action !== "update" && body.action !== "delete") return null;
- if (body.all_bots !== true && (!name || listSkills(bot.id).some((skill) => skill.name === name) || !allBotsSkills(bot.id).some((skill) => skill.name === name))) return null;
+ if (body.all_bots !== true && !listSkills(bot.id).some((skill) => skill.name === name && skill.allBots)) return null;
return { action: body.action, name };
}
@@ -83,6 +84,7 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
writeFileAtomic(recordPath(requestId), `${JSON.stringify(record)}\n`, { mode: 0o600 });
};
const dropRecord = (requestId: string) => rmSync(recordPath(requestId), { force: true });
+ const botNames = (ids: readonly string[]) => ids.map((id) => store.bot(id)?.name ?? id);
/** The new files a create or update brings, checked as a bot's own learned skill is. An update keeps the files beside
* SKILL.md it does not mention, and a reference sent empty removes that one, as a bot's own update does. */
@@ -131,26 +133,45 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
}
/** Applies a recorded change; what Undo needs goes back into the record. */
- function apply(record: SkillRecord): { ok: true; record: SkillRecord; kept: string[] } | { error: string } {
+ function apply(record: SkillRecord): { ok: true; record: SkillRecord; kept: string[]; failed: string[] } | { error: string } {
const current = sharedCopy(record.scope, record.name);
if (record.action === "delete") {
if (!current || copyDigest(current) !== record.digest) return { error: `skill "${record.name}" changed after this card was shown; ask the bot to propose it again` };
const removed = removeFromAllBots(record.scope, record.name);
- return "error" in removed ? removed : { ok: true, record: { ...record, previous: stored(removed.removed) }, kept: [] };
+ if ("error" in removed) return removed;
+ return { ok: true, record: { ...record, previous: stored(removed.removed), switches: removed.switches }, kept: [], failed: removed.failed };
}
if (record.action === "create" && current) return { error: `"${record.name}" is already on all your bots; update it instead` };
if (record.action === "update" && (!current || copyDigest(current) !== record.digest)) return { error: `skill "${record.name}" changed after this card was shown; ask the bot to propose it again` };
const copy = loaded(record.copy!);
- const put = putOnAllBots(record.scope, record.name, copy, { fresh: record.action === "create" });
+ const put = putOnAllBots(record.scope, record.name, copy);
if ("error" in put) return put;
- return { ok: true, record: { ...record, digest: copyDigest(copy), ...(current ? { previous: stored(current) } : {}), retired: put.retired.map((one) => ({ ...one, copy: stored(one.copy) })) }, kept: put.kept };
+ return { ok: true, record: { ...record, digest: copyDigest(copy), ...(current ? { previous: stored(current) } : {}) }, kept: put.kept, failed: put.failed };
}
- const keptLine = (kept: readonly string[]) => {
- const names = kept.map((id) => store.bot(id)?.name).filter(Boolean);
- return names.length ? ` Kept their own different copy: ${names.join(", ")}.` : "";
+ const outcomeLine = (kept: readonly string[], failed: readonly string[]) =>
+ `${kept.length ? ` Kept their own different copy: ${botNames(kept).join(", ")}.` : ""}${failed.length ? ` Not yet on: ${botNames(failed).join(", ")}; it is tried again when each is next used.` : ""}`;
+
+ /** The person this bot's turn must act for on a Team Cloud, by person key; null where any turn of the bot may. */
+ const ownerKey = (bot: BotRecord | null | undefined): string | null | false => {
+ if (!skillsForAllBotsOnTeam()) return null;
+ const owner = bot ? botOwner(bot) : null;
+ return owner ? personKey({ id: "", email: owner }) : false;
};
+ function applyWithReceipt(bot: BotRecord, threadId: string, record: SkillRecord, card: { gist: string; preview: string; source: string; warnings: string[] }, direct: DirectApply):
+ { ok: true; done: string; kept: string[]; failed: string[] } | { error: string } {
+ const applied = apply(record);
+ if ("error" in applied) return applied;
+ const requestId = randomUUID();
+ writeRecord(requestId, applied.record);
+ const previous = applied.record.previous ? { preview: applied.record.previous.skillMd, source: applied.record.previous.source } : undefined;
+ const done = appendCard({ requestId, bot, threadId, action: record.action, name: record.name, ...card, applied: { previous } });
+ appendDecision(deps.dataDir, { threadId, requestId, botId: bot.id, botName: bot.name, tool: "stage_skill", summary: done, decision: "auto-approved", source: direct });
+ deps.noteSkillChange(bot.id, threadId);
+ return { ok: true, done, kept: applied.kept, failed: applied.failed };
+ }
+
/** Null when the call is about the bot's own skill; then the usual paths take it. `actsFor`: on a Team Cloud, the person
* key the turn acts for (host/acting-person.ts); only the bot's own person's turn may change all of their bots, so a
* teammate chatting with a shared bot cannot reach its owner's private bots through it. */
@@ -159,16 +180,18 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
actsFor: () => string | null = () => null): Promise<Result | null> {
const claim = claimed(from, received);
if (!claim) return null;
+ if (allBotsUnavailable()) return { status: 422, body: { error: SHARED_WITHOUT_TEAM } };
const live = store.bot(from.id), scope = allBotsScopeOfBot(live);
if (!scope) return { status: 422, body: { error: "This bot belongs to no one on this team, so it has no \"all my bots\". Ask the person to have their own Chief of Staff do it, or add the skill to this bot alone without all_bots." } };
- const owner = live ? botOwner(live) : null;
- if (skillsForAllBotsOnTeam() && (!owner || actsFor() !== personKey({ id: "", email: owner }))) {
+ const owner = ownerKey(live);
+ if (owner === false || (owner !== null && actsFor() !== owner)) {
return { status: 403, body: { error: "Only the person this bot reports to can change the skills on all of their bots, in their own conversation with it." } };
}
const body = claim.action === "create" ? await withImport(received) : received;
if ("importError" in body) return { status: 422, body: { error: body.importError } };
if (!active()) return { status: 401, body: { error: "This turn has ended." } };
- const applies = direct();
+ // In a room, the existing card: never on the strength of what a teammate wrote there.
+ const applies = store.groupByThread(threadId) ? null : direct();
const persistence = deps.persistence(from.id, threadId, !applies);
if (!persistence.ok) return { status: persistence.status, body: { error: persistence.error } };
let record: SkillRecord, gist: string, warnings: string[] = [], preview: string, source: string;
@@ -186,17 +209,12 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
record = { scope, action: claim.action, name: change.name, digest: current ? copyDigest(current) : "", copy: stored(change.copy) };
({ gist, warnings } = change); preview = change.copy.skillMd; source = change.copy.source;
}
- const requestId = randomUUID();
if (applies) {
- const applied = apply(record);
- if ("error" in applied) return { status: 422, body: { state: "failed", error: applied.error } };
- writeRecord(requestId, applied.record);
- const previous = applied.record.previous ? { preview: applied.record.previous.skillMd, source: applied.record.previous.source } : undefined;
- const done = appendCard({ requestId, bot: from, threadId, action: claim.action, name: record.name, gist, preview, source, warnings, applied: { previous } });
- appendDecision(deps.dataDir, { threadId, requestId, botId: from.id, botName: from.name, tool: "stage_skill", summary: done, decision: "auto-approved", source: applies });
- deps.noteSkillChange(from.id, threadId);
- return { status: 201, body: { state: "applied", name: record.name, action: claim.action, allBots: true, warnings, summary: `${done}.${keptLine(applied.kept)}` } };
+ const done = applyWithReceipt(from, threadId, record, { gist, preview, source, warnings }, applies);
+ if ("error" in done) return { status: 422, body: { state: "failed", error: done.error } };
+ return { status: 201, body: { state: "applied", name: record.name, action: claim.action, allBots: true, warnings, summary: `${done.done}.${outcomeLine(done.kept, done.failed)}` } };
}
+ const requestId = randomUUID();
writeRecord(requestId, record);
let summary: string;
try {
@@ -209,6 +227,29 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
return { status: 201, body: { state: "pending", name: record.name, action: claim.action, allBots: true, warnings, summary } };
}
+ /** The Skills page's "Use on all bots": one of this bot's own skills, on, put on all of the person's bots, with the same
+ * receipt and Undo in the bot's main conversation. A copy already there with the same files is only adopted. */
+ function fromSkillsPage(bot: BotRecord, name: string, scope: string): { status: number; body: Record<string, unknown> } {
+ const own = listSkills(bot.id).find((skill) => skill.name === name);
+ if (!own) return { status: 404, body: { error: `This bot has no skill of its own named "${name}".` } };
+ // A skill still off here may be an import nobody has read yet: it reaches every bot only once it is on somewhere.
+ if (!own.enabled) return { status: 409, body: { error: `Turn "${name}" on for this bot first, after reading it.` } };
+ const copy = ownCopy(bot.id, name);
+ if (!copy) return { status: 409, body: { error: `"${name}" changed outside OpenMausBot; remove it and add it again.` } };
+ const existing = sharedCopy(scope, name);
+ if (existing && copyDigest(existing) !== copyDigest(copy)) {
+ return { status: 409, body: { error: `A different "${name}" is already on all your bots. Remove this bot's own copy to use that one, or remove that one from all your bots first.` } };
+ }
+ if (existing) {
+ const put = putOnAllBots(scope, name, copy);
+ return "error" in put ? { status: 409, body: { error: put.error } } : { status: 200, body: { name, kept: botNames(put.kept), failed: botNames(put.failed) } };
+ }
+ const record: SkillRecord = { scope, action: "create", name, digest: "", copy: stored(copy) };
+ const done = applyWithReceipt(bot, bot.threadId, record, { gist: own.description, preview: copy.skillMd, source: copy.source, warnings: own.warnings }, "self");
+ if ("error" in done) return { status: 409, body: { error: done.error } };
+ return { status: 200, body: { name, kept: botNames(done.kept), failed: botNames(done.failed) } };
+ }
+
function resolve(args: { botId: string; botName?: string; threadId: string; requestId: string; behavior: "allow" | "deny" | "answer"; reviewedSha256?: string },
messageId: string, card: OptionCardData, request: SkillRequestCardData):
| { claimed: true; status: number; error: string }
@@ -237,7 +278,8 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
return { claimed: true, outcome: "allowed-once" };
}
- /** Puts things back as they were before the change, while nothing has changed the skill since. */
+ /** Puts things back as they were before the change, while nothing has changed the skill since. Bots it could not put
+ * back are named in the answer; the rest are put back. */
function undo(botId: string, threadId: string, message: Message, request: SkillRequestCardData):
| { claimed: true; state: "undone" }
| { claimed: true; state: "invalid"; error: string; status: number; stale?: true } {
@@ -245,30 +287,27 @@ export function createSkillsForAllBotsHost(deps: SkillsForAllBotsHostDeps) {
if (!record) return { claimed: true, state: "invalid", error: "This change can't be undone here.", status: 409 };
const current = sharedCopy(record.scope, record.name);
const stale = { claimed: true as const, state: "invalid" as const, error: UNDO_STALE, status: 409, stale: true as const };
- let undone: { ok: true } | { error: string };
+ let failed: string[];
if (record.action === "delete") {
if (current || !record.previous) return stale;
- const put = putOnAllBots(record.scope, record.name, loaded(record.previous), { fresh: false });
- undone = "error" in put ? put : { ok: true };
+ const put = putOnAllBots(record.scope, record.name, loaded(record.previous));
+ if ("error" in put) return { claimed: true, state: "invalid", error: put.error, status: 409 };
+ failed = [...new Set([...put.failed, ...restoreSwitches(record.name, record.switches ?? [])])];
} else {
if (!current || copyDigest(current) !== record.digest) return stale;
- if (record.previous) {
- const put = putOnAllBots(record.scope, record.name, loaded(record.previous), { fresh: false });
- undone = "error" in put ? put : { ok: true };
- } else {
- const removed = removeFromAllBots(record.scope, record.name);
- undone = "error" in removed ? removed : { ok: true };
- }
- if ("ok" in undone) restoreOwnCopies(record.name, (record.retired ?? []).map((one): RetiredCopy => ({ ...one, copy: loaded(one.copy) })));
+ // An adopted copy stays with its bot as the copy it had, when the skill comes off all bots.
+ const undone = record.previous ? putOnAllBots(record.scope, record.name, loaded(record.previous)) : removeFromAllBots(record.scope, record.name);
+ if ("error" in undone) return { claimed: true, state: "invalid", error: undone.error, status: 409 };
+ failed = undone.failed;
}
- if ("error" in undone) return { claimed: true, state: "invalid", error: undone.error, status: 409 };
dropRecord(request.requestId);
if (message.card) store.patchMessage(threadId, message.id, { card: { ...message.card, undone: true } });
deps.noteSkillChange(botId, threadId);
+ if (failed.length) return { claimed: true, state: "invalid", error: `Undone, except on ${botNames(failed).join(", ")}: open their Skills to check "${record.name}".`, status: 409 };
return { claimed: true, state: "undone" };
}
- return { stage, resolve, undo };
+ return { stage, fromSkillsPage, resolve, undo };
}
export type SkillsForAllBotsHost = ReturnType<typeof createSkillsForAllBotsHost>;
diff --git a/server/host/skills-library.ts b/server/host/skills-library.ts
index 8c53d8a5d4..782e884814 100644
--- a/server/host/skills-library.ts
+++ b/server/host/skills-library.ts
@@ -18,7 +18,6 @@ import { readSectionContext } from "../section-context.ts";
import { librarySkillFilePath, librarySkillOptOuts, listLibrarySkills, readLibrarySkillFile, readSkillLibraryIndex, skillsLibraryEnabled } from "../skill-library.ts";
import { findWorkflowSkill, skillBurgerEnabled, workflowSkillsPrompt } from "../skill-burger/store.ts";
import { librarySkillFiles, ownSkillFiles, type StoredSkillFiles } from "../skill-side-files.ts";
-import { allBotsRootOfBot, allBotsSkillFile, readAllBotsSkillFile } from "../skills-for-all-bots.ts";
import {
conversationAssignedSkills,
prepareShareNote,
@@ -91,7 +90,7 @@ export function createSkillsLibraryHost(deps: SkillsLibraryHostDeps) {
/** The bot's own skills, and its library skills while the library is on; an imported skill of the same name yields. */
const ownSkills = (bot: BotRecord) =>
- resolveBotSkills(bot.id, skillsLibraryEnabled(cfg) ? bot.assignedSkills ?? [] : undefined);
+ skillsLibraryEnabled(cfg) ? resolveBotSkills(bot.id, bot.assignedSkills ?? []) : listSkills(bot.id);
/** What the bot is for, as its settings and its department's shared instructions say: what its skills from this
* computer are picked by. */
const aboutBot = (bot: BotRecord): string => {
@@ -115,7 +114,6 @@ export function createSkillsLibraryHost(deps: SkillsLibraryHostDeps) {
if (own !== null) return own;
// Private wins collisions: a private skill that no longer verifies must not fall through to a same-named shared one.
if (listSkills(bot.id).some((skill) => skill.name === name)) return null;
- if (allBotsSkillFile(bot.id, name)) return readAllBotsSkillFile(bot.id, name);
// The library fallback is by assignment only, never by name alone.
if (skillsLibraryEnabled(cfg) && listLibrarySkills().some((skill) => skill.name === name && (bot.assignedSkills?.includes(name) || (skill.everyBot && !librarySkillOptOuts(bot.id).has(name))))) return readLibrarySkillFile(name);
if (readImportedSkills()[name]) return readImportedSkillFile(name);
@@ -127,8 +125,6 @@ export function createSkillsLibraryHost(deps: SkillsLibraryHostDeps) {
const readBotSkillFiles = (bot: BotRecord, name: string): StoredSkillFiles => {
if (readSkillFile(bot.id, name) !== null) return ownSkillFiles(bot.id, name);
if (listSkills(bot.id).some((skill) => skill.name === name)) return null;
- const everywhere = allBotsSkillFile(bot.id, name) && allBotsRootOfBot(bot.id);
- if (everywhere) return librarySkillFiles(name, everywhere);
if (skillsLibraryEnabled(cfg) && listLibrarySkills().some((skill) => skill.name === name && (bot.assignedSkills?.includes(name) || (skill.everyBot && !librarySkillOptOuts(bot.id).has(name))))) return librarySkillFiles(name);
return [];
};
@@ -321,7 +317,7 @@ export function createSkillsLibraryHost(deps: SkillsLibraryHostDeps) {
const project = thread ? projectInUse(bot, thread, cwd, instance, assigned) : [];
return skillsSystemPrompt(bot.id, assigned, threadId === undefined ? undefined : conversationStartedAt(threadId)) +
importedSkillsPrompt(listed, available.length - listed.length) + projectSkillsPrompt(project) +
- (skillsLibraryEnabled(cfg) || !skillBurgerEnabled(cfg) ? "" : workflowSkillsPrompt(bot.id)); // with the library on, saved workflows are every-bot library skills already
+ (skillsLibraryEnabled(cfg) || !skillBurgerEnabled(cfg) ? "" : workflowSkillsPrompt(bot.id, undefined, new Set(listSkills(bot.id).map((skill) => skill.name)))); // with the library on, saved workflows are every-bot library skills already
},
/** The imported skills a turn links into its task folder: the same ones its index lists, so an engine that loads
@@ -363,7 +359,7 @@ export function createSkillsLibraryHost(deps: SkillsLibraryHostDeps) {
}
if (files.size < mentioned.length) add(projectInUse(bot, threadId, cwd, instance, assigned).filter((skill) => !skill.modelOnly));
// A Skill Burger runs exactly with run_workflow, from any bot.
- const burgers = !skillBurgerEnabled(cfg) ? [] : mentioned.flatMap((name) => { const found = findWorkflowSkill(bot.id, name); return found ? [{ name, found }] : []; });
+ const burgers = !skillBurgerEnabled(cfg) ? [] : mentioned.flatMap((name) => { const found = !files.has(name) && findWorkflowSkill(bot.id, name); return found ? [{ name, found }] : []; });
for (const { name } of burgers) if (!files.has(name)) files.set(name, librarySkillFilePath(name));
const expanded = skillCommandTurnText(text, files, typed, ownStart);
return burgers.length ? `${expanded}\n\n${burgers.map(({ name, found }) => `/${name} is a saved Skill Burger: run it with the run_workflow tool (name "${name}"), filling its args from the request, rather than by hand.${burgerInputs(found.workflow)}`).join(" ")}` : expanded;
diff --git a/server/index.ts b/server/index.ts
index 951551ac0c..f11e8f5763 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -583,7 +583,7 @@ import { createBotPatchRoutes } from "./routes/bot-patch.ts";
import { createBotOrderRoutes } from "./routes/bot-order.ts";
import { createGroupOrderRoutes } from "./routes/group-order.ts";
import { createBotLifecycleRoutes } from "./routes/bot-lifecycle.ts";
-import { createBotSkillsRoutes } from "./routes/bot-skills.ts"; import { createSkillsForAllBotsRoutes } from "./routes/skills-for-all-bots.ts"; import { createSkillsForAllBotsHost } from "./host/skills-for-all-bots-host.ts"; import { wireSkillsForAllBots } from "./skills-for-all-bots.ts";
+import { createBotSkillsRoutes } from "./routes/bot-skills.ts"; import { createSkillsForAllBotsRoutes } from "./routes/skills-for-all-bots.ts"; import { createSkillsForAllBotsHost } from "./host/skills-for-all-bots-host.ts"; import { wireAllBotsSkills } from "./skills-for-all-bots-ops.ts";
import { createSkillShareRoutes } from "./routes/skill-share.ts";
import { createTeamContextRoutes } from "./routes/team-context.ts";
import { createAppSuggestions } from "./host/app-suggestions.ts"; import { createAppFindRoute, createAppSuggestionRoutes } from "./routes/app-suggestions.ts"; import { appPickAvailable } from "./decider/app-picks.ts"; import { managedConnectorUnavailableReason } from "../shared/connector-availability.ts"; import { createDeciderRoutes } from "./routes/decider.ts"; import { createCloudSendRoutes } from "./routes/cloud-send.ts"; import { claudeCodeSkillInputs } from "./setup-import.ts"; import { createCloudConnectionsHost } from "./cloud-connections-host.ts";
@@ -11155,7 +11155,7 @@ function appendSkillRequestCard(args: {
};
}
-const skillSwitch = createSkillSwitchHost({ store, dataDir: DATA_DIR, persistence: skillProposalPersistence, listBotSkills, readBotSkillFile, noteSkillChange: (botId, threadId) => skillReview.noteSkillChange(botId, threadId) }); wireSkillsForAllBots({ team: Boolean(CLOUD_TEAM), bot: (id) => store.bot(id), bots: () => store.bots }); const allBotsSkills = createSkillsForAllBotsHost({ store, dataDir: DATA_DIR, persistence: skillProposalPersistence, 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) }); wireAllBotsSkills({ team: Boolean(CLOUD_TEAM), sharedWithoutTeam: () => !CLOUD_TEAM && sharedMembership(), bot: (id) => store.bot(id), bots: () => store.bots }); const allBotsSkills = createSkillsForAllBotsHost({ store, dataDir: DATA_DIR, persistence: skillProposalPersistence, noteSkillChange: (botId, threadId) => skillReview.noteSkillChange(botId, threadId) });
function resolveSkillRequest(args: {
botId: string;
botName?: string;
@@ -12000,7 +12000,7 @@ ROUTES.push(createBotLifecycleRoutes({
store, routines: () => routines, interruptAllDirectThreads, cancelDirectTurnDispatch, revokeInternalCapabilitiesForThread,
activeGroupTurnForBot, cancelGroupTurnOperations, runningTurnInstance, closeOpenApprovals, deleteBotWithLifecycle, deleteRefusal: (auth, botId) => memberDeleteRefusal(auth, store.bot(botId), Boolean(CLOUD_TEAM)),
}));
-const skillsRoutes = createBotSkillsRoutes({ store, cfg, listBotSkills, readBotSkillFile, stagedSkillListing }); ROUTES.push(createSkillsForAllBotsRoutes({ store }), skillsRoutes);
+const skillsRoutes = createBotSkillsRoutes({ store, cfg, listBotSkills, readBotSkillFile, stagedSkillListing }); ROUTES.push(createSkillsForAllBotsRoutes({ store, host: allBotsSkills }), skillsRoutes);
ROUTES.push(createEmailRoutes({ service: emailService }));
ROUTES.push(phones.routes);
ROUTES.push(createSkillShareRoutes({ enabled: () => skillsHost.mode() !== "off", botExists: (id) => Boolean(store.bot(id)),
diff --git a/server/routes/bot-skills.ts b/server/routes/bot-skills.ts
index d9f27dc785..e43ced15c0 100644
--- a/server/routes/bot-skills.ts
+++ b/server/routes/bot-skills.ts
@@ -13,6 +13,7 @@ import {
type SkillListing, type StagedSkillWrite,
} from "../skills.ts";
import type { BotRecord, Store } from "../store.ts";
+import { withAllBotsOffer } from "./skills-for-all-bots.ts";
import { PASS, type RouteHandler } from "./table.ts";
export interface BotSkillsRouteDeps {
@@ -25,7 +26,7 @@ export interface BotSkillsRouteDeps {
export function createBotSkillsRoutes(deps: BotSkillsRouteDeps): RouteHandler {
const { store, cfg, listBotSkills, readBotSkillFile, stagedSkillListing } = deps;
- return async ({ req, res, url, path, method, json, readBody }) => {
+ return async ({ req, res, url, path, method, json, readBody, auth }) => {
let m: RegExpMatchArray | null = null;
// Imports land DISABLED: a person enables one after reading SKILL.md and its scan warnings.
m = path.match(/^\/api\/bots\/([\w-]+)\/skill-template$/);
@@ -55,14 +56,14 @@ export function createBotSkillsRoutes(deps: BotSkillsRouteDeps): RouteHandler {
const { skills, library } = listBotSkillsWithOrigin(m[1]!, store.bot(m[1])!.assignedSkills);
const names = new Set(skills.map((skill) => skill.name));
return json(res, 200, {
- skills: [...skills, ...listBotSkills(bot, threadId).filter((skill) => !names.has(skill.name))],
+ skills: withAllBotsOffer(bot, auth, [...skills, ...listBotSkills(bot, threadId).filter((skill) => !names.has(skill.name))]),
library,
assignedSkills: store.bot(m[1])!.assignedSkills,
staged: listStagedSkillWrites(m[1]).map(stagedSkillListing),
});
}
return json(res, 200, {
- skills: listBotSkills(bot, threadId),
+ skills: withAllBotsOffer(bot, auth, listBotSkills(bot, threadId)),
staged: listStagedSkillWrites(m[1]).map(stagedSkillListing),
});
}
diff --git a/server/routes/skills-for-all-bots.ts b/server/routes/skills-for-all-bots.ts
index 4a71d11afe..b03069b173 100644
--- a/server/routes/skills-for-all-bots.ts
+++ b/server/routes/skills-for-all-bots.ts
@@ -1,23 +1,24 @@
-// A bot's Skills page for a skill on all of the person's bots: put one of this bot's own skills on all of them, switch a
-// shared one off for this bot alone, or take it off every bot. On a Team Cloud only the member the bot reports to may
-// put a skill on, or take one off, all of their bots; anyone who may change the bot's skills may switch it for that bot.
-import { z } from "zod";
-
+// A bot's Skills page for a skill on all of the person's bots: put one of this bot's own skills on all of them, or take a
+// shared one off every bot. A bot's copy is one of its own skills, so its switch is the per-bot routes'. On a Team Cloud
+// only the member the bot reports to may change what all of their bots have.
import { ownerEmail } from "../../shared/bot-owner.ts";
+import type { SkillsForAllBotsHost } from "../host/skills-for-all-bots-host.ts";
import type { RequestAuth } from "../request-auth.ts";
import { listSkills } from "../skills.ts";
-import { allBotsScopeOfBot, allBotsScopeOfPerson, allBotsSkills, setAllBotsSkillOff, skillsForAllBotsOnTeam } from "../skills-for-all-bots.ts";
-import { copyDigest, ownCopy, putOnAllBots, removeFromAllBots, sharedCopy } from "../skills-for-all-bots-ops.ts";
+import { allBotsScopeOfBot, allBotsScopeOfPerson, allBotsUnavailable, SHARED_WITHOUT_TEAM, skillsForAllBotsOnTeam } from "../skills-for-all-bots.ts";
+import { removeFromAllBots } from "../skills-for-all-bots-ops.ts";
import type { BotRecord, Store } from "../store.ts";
import { PASS, type RouteHandler } from "./table.ts";
export interface SkillsForAllBotsRouteDeps {
store: Pick<Store, "bot">;
+ host: Pick<SkillsForAllBotsHost, "fromSkillsPage">;
}
/** The store this request may change through this bot: the bot's person's, and on a Team Cloud only when that is who
* is asking. */
export function requesterScope(bot: BotRecord, auth: RequestAuth): { scope: string } | { status: number; error: string } {
+ if (allBotsUnavailable()) return { status: 409, error: SHARED_WITHOUT_TEAM };
const scope = allBotsScopeOfBot(bot);
if (!scope) return { status: 409, error: "This bot belongs to no one, so it has no \"all my bots\"." };
if (!skillsForAllBotsOnTeam()) return { scope };
@@ -28,8 +29,16 @@ export function requesterScope(bot: BotRecord, auth: RequestAuth): { scope: stri
return { scope };
}
+/** A bot's skills as its Skills page lists them, each own skill that is on marked when this person may put it on all of
+ * their bots, so the button shows only where it works. */
+export function withAllBotsOffer<T extends { name: string; enabled: boolean; allBots?: true; origin?: string }>(bot: BotRecord, auth: RequestAuth, skills: T[]): Array<T & { canUseOnAllBots?: true }> {
+ if ("error" in requesterScope(bot, auth)) return skills;
+ const own = new Set(listSkills(bot.id).map((skill) => skill.name));
+ return skills.map((skill) => (own.has(skill.name) && skill.enabled && !skill.allBots && (skill.origin === undefined || skill.origin === "private") ? { ...skill, canUseOnAllBots: true as const } : skill));
+}
+
export function createSkillsForAllBotsRoutes(deps: SkillsForAllBotsRouteDeps): RouteHandler {
- return async ({ path, method, auth, json, readBody, req, res }) => {
+ return async ({ path, method, auth, json, res }) => {
const m = path.match(/^\/api\/bots\/([\w-]+)\/skills\/([a-z0-9-]+)(\/all-bots)?$/);
if (!m) return PASS;
const bot = deps.store.bot(m[1]!);
@@ -39,37 +48,15 @@ export function createSkillsForAllBotsRoutes(deps: SkillsForAllBotsRouteDeps): R
if (method !== "POST") return PASS;
const allowed = requesterScope(bot, auth);
if ("error" in allowed) return json(res, allowed.status, { error: allowed.error });
- const own = listSkills(bot.id).find((skill) => skill.name === name);
- if (!own) return json(res, 404, { error: `This bot has no skill of its own named "${name}".` });
- // A skill still off here may be an import nobody has read yet: it reaches every bot only once it is on somewhere.
- if (!own.enabled) return json(res, 409, { error: `Turn "${name}" on for this bot first, after reading it.` });
- const copy = ownCopy(bot.id, name);
- if (!copy) return json(res, 409, { error: `"${name}" changed outside OpenMausBot; remove it and add it again.` });
- // A different copy already on all of their bots stays: this bot keeps its own until one of the two is removed.
- const existing = sharedCopy(allowed.scope, name);
- if (existing && copyDigest(existing) !== copyDigest(copy)) {
- return json(res, 409, { error: `A different "${name}" is already on all your bots. Remove this bot's own copy to use that one, or remove that one from all your bots first.` });
- }
- const put = putOnAllBots(allowed.scope, name, copy, { fresh: !existing });
- if ("error" in put) return json(res, 409, { error: put.error });
- return json(res, 200, { name, kept: put.kept.map((id) => deps.store.bot(id)?.name ?? id), retired: put.retired.length });
- }
- // Only a name on all of the person's bots that this bot does not shadow with its own; the rest is the per-bot routes'.
- const shared = !listSkills(bot.id).some((skill) => skill.name === name) && allBotsSkills(bot.id).find((skill) => skill.name === name);
- if (!shared) return PASS;
- if (method === "PATCH") {
- const parsed = z.object({ enabled: z.boolean() }).safeParse(await readBody(req));
- if (!parsed.success) return json(res, 400, { error: "enabled must be true or false" });
- setAllBotsSkillOff(bot.id, name, !parsed.data.enabled);
- return json(res, 200, { skill: allBotsSkills(bot.id).find((skill) => skill.name === name) });
- }
- if (method === "DELETE") {
- const allowed = requesterScope(bot, auth);
- if ("error" in allowed) return json(res, allowed.status, { error: allowed.error });
- const removed = removeFromAllBots(allowed.scope, name);
- if ("error" in removed) return json(res, 409, { error: removed.error });
- return json(res, 200, { ok: true });
+ const done = deps.host.fromSkillsPage(bot, name, allowed.scope);
+ return json(res, done.status, done.body);
}
- return PASS;
+ // Remove on a shared skill takes it off every bot of the person's; the rest is the per-bot routes'.
+ if (method !== "DELETE" || !listSkills(bot.id).some((skill) => skill.name === name && skill.allBots)) return PASS;
+ const allowed = requesterScope(bot, auth);
+ if ("error" in allowed) return json(res, allowed.status, { error: allowed.error });
+ const removed = removeFromAllBots(allowed.scope, name);
+ if ("error" in removed) return json(res, 409, { error: removed.error });
+ return json(res, 200, { ok: true });
};
}
diff --git a/server/skill-burger/store.ts b/server/skill-burger/store.ts
index 6daf362dbb..e05bb60831 100644
--- a/server/skill-burger/store.ts
+++ b/server/skill-burger/store.ts
@@ -232,8 +232,9 @@ export function migrateBotBurgers(botIds: readonly string[], root: string = skil
/** The turn's list of burgers used in every chat, for a bot that doesn't already see them through the skills library.
* A bot's own burgers are its own skills and listed with them. */
-export function workflowSkillsPrompt(botId: string, root: string = skillsLibraryRoot()): string {
- const optedOut = librarySkillOptOuts(botId);
+/** `taken`: names the bot's own skills already hold (one on all of the person's bots among them): theirs is the one line. */
+export function workflowSkillsPrompt(botId: string, root: string = skillsLibraryRoot(), taken: ReadonlySet<string> = new Set()): string {
+ const optedOut = new Set([...librarySkillOptOuts(botId), ...taken]);
const lines: string[] = [];
let bytes = 0;
for (const saved of listWorkflowSkills(root)) {
diff --git a/server/skill-switch.ts b/server/skill-switch.ts
index b7f0ee88b7..96958e32ae 100644
--- a/server/skill-switch.ts
+++ b/server/skill-switch.ts
@@ -5,10 +5,9 @@ import { serverLine, type ServerLineKey } from "./server-lines.ts";
import { STAGED_GIST_MAX } from "./skills.ts";
import type { SkillSwitchAction } from "../shared/skill-request.ts";
-/** own: in this bot's own skills; imported: brought in from this computer for every bot, switched per bot; all-bots: on
- * all of the person's bots, switched per bot; fixed: shared from the team library or the engine's own, which only the
- * person changes. */
-export type SwitchableSkillKind = "own" | "imported" | "all-bots" | "fixed";
+/** own: in this bot's own skills; imported: brought in from this computer for every bot, switched per bot;
+ * fixed: shared from the team library or the engine's own, which only the person changes. */
+export type SwitchableSkillKind = "own" | "imported" | "fixed";
export interface SwitchableSkill {
kind: SwitchableSkillKind;
diff --git a/server/skills-for-all-bots-ops.ts b/server/skills-for-all-bots-ops.ts
index d2a89dff5b..541dc35640 100644
--- a/server/skills-for-all-bots-ops.ts
+++ b/server/skills-for-all-bots-ops.ts
@@ -1,15 +1,16 @@
-// Putting a skill on all of a person's bots, changing it there and taking it off again (skills-for-all-bots.ts reads
-// it). A bot that already has its own copy with the very same files gives that copy up for the shared one, keeping its
-// on/off state as its own switch; a bot whose own copy differs keeps it (its own skill wins the name) and is reported.
+// Putting a skill on all of a person's bots, changing it there and taking it off again, and keeping each bot's own copy
+// in step with the person's record (skills-for-all-bots.ts). A bot that already had the very same skill keeps its copy,
+// now marked as shared ("adopted"), and keeps it as its own again when the skill is taken off all bots; a bot whose own
+// copy differs keeps it (its own skill wins the name) and is reported.
import { createHash } from "node:crypto";
-import { LEARN_SOURCE_PREFIX } from "./skill-learn.ts";
import { installLibrarySkill, readLibrarySkillFile, readSkillLibraryIndex, retireLibrarySkill, updateLibrarySkill } from "./skill-library.ts";
import { librarySkillFiles, ownSkillFiles } from "./skill-side-files.ts";
+import { installSkill, listSkills, readManifest, readSkillFile, removeSkill, setSharedSkillMark, setSharedSkills, setSkillEnabled } from "./skills.ts";
import {
- applySkillWriteWithReceipt, installSkill, listSkills, readSkillFile, rejectStagedSkillWrite, removeSkill, setSkillEnabled, stageSkillWrite,
-} from "./skills.ts";
-import { allBotsRoot, botsInAllBotsScope, setAllBotsSkillOff } from "./skills-for-all-bots.ts";
+ allBotsRoot, allBotsScopeOfBot, allBotsStore, botsInAllBotsScope, ensureAllBotsStore, entryKey, forgetAllBotsStore, sharedMarkCurrent,
+ wireSkillsForAllBots, type AllBotsBot,
+} from "./skills-for-all-bots.ts";
export interface SkillCopy {
skillMd: string;
@@ -28,9 +29,9 @@ export function copyDigest(copy: Pick<SkillCopy, "skillMd" | "files">): string {
/** The bot's own copy as stored, while every file still verifies. */
export function ownCopy(botId: string, name: string): SkillCopy | null {
- const skillMd = readSkillFile(botId, name), files = ownSkillFiles(botId, name);
- const source = listSkills(botId).find((skill) => skill.name === name)?.source;
- return skillMd !== null && files !== null && source ? { skillMd, files, source } : null;
+ const entry = readManifest(botId)[name];
+ const skillMd = entry ? readSkillFile(botId, name) : null, files = entry ? ownSkillFiles(botId, name) : null;
+ return entry && skillMd !== null && files !== null ? { skillMd, files, source: entry.source } : null;
}
export function sharedCopy(scope: string, name: string): SkillCopy | null {
@@ -39,83 +40,152 @@ export function sharedCopy(scope: string, name: string): SkillCopy | null {
return entry && skillMd !== null && files !== null ? { skillMd, files, source: entry.source } : null;
}
-export interface RetiredCopy {
- botId: string;
- wasOff: boolean;
- copy: SkillCopy;
+const syncing = new Set<string>();
+/** Own copies already found to differ from the person's, so a listing does not read them again. */
+const differs = new Set<string>();
+
+function installCopy(botId: string, scope: string, store: string, name: string, enabled: boolean, adopted?: true): boolean {
+ const copy = sharedCopy(scope, name), entry = allBotsStore(scope).entries[name];
+ if (!copy || !entry) return false;
+ const installed = installSkill(botId, copy.source, [{ path: "SKILL.md", content: copy.skillMd }, ...copy.files]);
+ if ("error" in installed) return false;
+ if (enabled && "error" in setSkillEnabled(botId, name, true)) return false;
+ setSharedSkillMark(botId, name, { store, sha256: entryKey(entry), ...(adopted ? { adopted } : {}) });
+ return true;
+}
+
+/** Brings one bot's copies in step with its person's record: adds what it lacks, rewrites what changed (keeping its
+ * switch), takes away what was removed (giving an adopted copy back as its own), and adopts an identical own copy.
+ * Returns the names it could not bring in step; the next listing tries them again. */
+export function syncBotCopies(bot: AllBotsBot | null | undefined): string[] {
+ const scope = allBotsScopeOfBot(bot);
+ return scope && bot ? syncInScope(bot.id, scope) : [];
+}
+
+/** Set once by the server: whose bots are whose, and a bot's copies kept in step as its skills are listed. */
+export function wireAllBotsSkills(next: Parameters<typeof wireSkillsForAllBots>[0]): void {
+ wireSkillsForAllBots(next);
+ setSharedSkills(next ? { list: (botId) => { syncBotCopies(next.bot(botId)); }, current: sharedMarkCurrent } : null);
}
-export interface PutOnAllBots {
- name: string;
- sha256: string;
- /** Bots whose identical own copy gave way to the shared one. */
- retired: RetiredCopy[];
+export function syncInScope(botId: string, scope: string): string[] {
+ const store = allBotsStore(scope);
+ if (!store.id || syncing.has(botId)) return [];
+ syncing.add(botId);
+ const failed: string[] = [];
+ try {
+ const manifest = readManifest(botId);
+ for (const [name, entry] of Object.entries(manifest)) {
+ const mark = entry.allBots;
+ if (!mark || mark.store !== store.id) continue;
+ const wanted = store.entries[name];
+ if (!wanted) {
+ if (mark.adopted) setSharedSkillMark(botId, name, undefined);
+ else if ("error" in removeSkill(botId, name)) failed.push(name);
+ } else if (mark.sha256 !== entryKey(wanted)) {
+ if ("error" in removeSkill(botId, name) || !installCopy(botId, scope, store.id, name, entry.enabled, mark.adopted)) failed.push(name);
+ }
+ }
+ for (const [name, wanted] of Object.entries(store.entries)) {
+ const entry = manifest[name];
+ if (!entry) {
+ if (!installCopy(botId, scope, store.id, name, true)) failed.push(name);
+ continue;
+ }
+ if (entry.allBots?.store === store.id) continue;
+ const seen = [botId, name, entry.sha256, entry.filesSha256 ?? entry.referencesSha256 ?? "", entryKey(wanted)].join("\0");
+ if (differs.has(seen)) continue;
+ if (differs.size > 10_000) differs.clear();
+ const theirs = ownCopy(botId, name), shared = sharedCopy(scope, name);
+ if (theirs && shared && copyDigest(theirs) === copyDigest(shared)) setSharedSkillMark(botId, name, { store: store.id, sha256: entryKey(wanted), adopted: true });
+ else differs.add(seen);
+ }
+ } finally {
+ syncing.delete(botId);
+ }
+ return failed;
+}
+
+export interface Fanned {
/** Bots that keep a different copy of their own under the same name. */
kept: string[];
+ /** Bots that could not be brought in step yet; their next listing tries again. */
+ failed: string[];
+}
+
+function fanOut(scope: string, name: string): Fanned {
+ const kept: string[] = [], failed: string[] = [];
+ const store = allBotsStore(scope);
+ for (const bot of botsInAllBotsScope(scope)) {
+ if (syncInScope(bot.id, scope).includes(name)) failed.push(bot.id);
+ const entry = readManifest(bot.id)[name];
+ if (store.entries[name] && entry && entry.allBots?.store !== store.id) kept.push(bot.id);
+ }
+ return { kept, failed };
}
-/** Adds the skill to every bot of the person's, or replaces the copy they share. `fresh`: a new skill, so no bot keeps an
- * old switch for a skill of this name; Undo of a removal passes false and every bot keeps its switch. */
-export function putOnAllBots(scope: string, name: string, copy: SkillCopy, options: { fresh: boolean }): PutOnAllBots | { error: string } {
- const root = allBotsRoot(scope), current = readSkillLibraryIndex(root)[name];
+/** Adds the skill to every bot of the person's, or replaces the copy they share. The record changes all at once or not at
+ * all: when a replacement cannot be stored, the copy it replaced is put back. */
+export function putOnAllBots(scope: string, name: string, copy: SkillCopy): Fanned | { error: string } {
+ const root = allBotsRoot(scope);
+ ensureAllBotsStore(scope);
+ const current = readSkillLibraryIndex(root)[name];
const existing = current ? sharedCopy(scope, name) : null;
if (current && !existing) return { error: `the copy of "${name}" on all your bots changed outside OpenMausBot; remove it and add it again` };
- if (!existing || copyDigest(existing) !== copyDigest(copy)) {
- const files = copy.files.map((file) => ({ path: file.path, content: file.content }));
- if (current && !current.files?.length && !files.length) {
- const updated = updateLibrarySkill({ name, instructions: copy.skillMd, expectSha256: current.sha256, source: copy.source, root });
- if ("stale" in updated) return { error: `"${name}" changed while it was being updated; try again` };
- if ("error" in updated) return updated;
- } else {
- if (current) {
- const retired = retireLibrarySkill(name, current.sha256, root);
- if (!("retired" in retired)) return { error: "stale" in retired ? `"${name}" changed while it was being updated; try again` : retired.error };
+ try {
+ if (!existing || copyDigest(existing) !== copyDigest(copy)) {
+ const files = copy.files.map((file) => ({ path: file.path, content: file.content }));
+ if (current && !current.files?.length && !files.length) {
+ const updated = updateLibrarySkill({ name, instructions: copy.skillMd, expectSha256: current.sha256, source: copy.source, root });
+ if ("stale" in updated) return { error: `"${name}" changed while it was being updated; try again` };
+ if ("error" in updated) return updated;
+ } else {
+ if (current) {
+ const retired = retireLibrarySkill(name, current.sha256, root);
+ if (!("retired" in retired)) return { error: "stale" in retired ? `"${name}" changed while it was being updated; try again` : retired.error };
+ }
+ const installed = installLibrarySkill({ name, instructions: copy.skillMd, source: copy.source, reviewState: "approved", ...(files.length ? { files } : {}), root });
+ if ("error" in installed) {
+ if (existing) installLibrarySkill({ name, instructions: existing.skillMd, source: existing.source, reviewState: "approved", ...(existing.files.length ? { files: existing.files } : {}), root });
+ return installed;
+ }
}
- const installed = installLibrarySkill({ name, instructions: copy.skillMd, source: copy.source, reviewState: "approved", ...(files.length ? { files } : {}), root });
- if ("error" in installed) return installed;
}
+ } finally {
+ forgetAllBotsStore(scope);
}
- const sha256 = readSkillLibraryIndex(root)[name]?.sha256 ?? hex(copy.skillMd);
- const digest = copyDigest(copy), retired: RetiredCopy[] = [], kept: string[] = [];
- for (const bot of botsInAllBotsScope(scope)) {
- if (options.fresh) setAllBotsSkillOff(bot.id, name, false);
- const own = listSkills(bot.id).find((skill) => skill.name === name);
- if (!own) continue;
- const theirs = ownCopy(bot.id, name);
- if (!theirs || copyDigest(theirs) !== digest || "error" in removeSkill(bot.id, name)) {
- kept.push(bot.id);
- continue;
- }
- retired.push({ botId: bot.id, wasOff: !own.enabled, copy: theirs });
- if (!own.enabled) setAllBotsSkillOff(bot.id, name, true);
- }
- return { name, sha256, retired, kept };
+ return fanOut(scope, name);
}
-/** Takes the skill off every bot of the person's; the bytes go to the library's archive, never deleted. */
-export function removeFromAllBots(scope: string, name: string): { removed: SkillCopy } | { error: string } {
+export interface Removed extends Fanned {
+ removed: SkillCopy;
+ /** Each bot's switch for it as it was, so Undo puts them back. */
+ switches: Array<{ botId: string; enabled: boolean }>;
+}
+
+/** Takes the skill off every bot of the person's: a bot that had it before keeps that copy as its own; the record's bytes
+ * go to the library's archive, never deleted. */
+export function removeFromAllBots(scope: string, name: string): Removed | { error: string } {
const root = allBotsRoot(scope), current = readSkillLibraryIndex(root)[name], copy = sharedCopy(scope, name);
if (!current) return { error: `no skill named "${name}" is on all your bots` };
+ const store = allBotsStore(scope).id;
+ const switches = botsInAllBotsScope(scope).flatMap((bot) => {
+ const entry = readManifest(bot.id)[name];
+ return entry?.allBots?.store === store ? [{ botId: bot.id, enabled: entry.enabled }] : [];
+ });
const retired = retireLibrarySkill(name, current.sha256, root);
+ forgetAllBotsStore(scope);
if (!("retired" in retired)) return { error: "stale" in retired ? `"${name}" changed outside OpenMausBot; try again` : retired.error };
- return { removed: copy ?? { skillMd: "", files: [], source: current.source } };
+ const fanned = fanOut(scope, name);
+ return { ...fanned, removed: copy ?? { skillMd: "", files: [], source: current.source }, switches };
}
-/** Undo of a put: gives each bot that gave way its own copy back, in the state it was in. */
-export function restoreOwnCopies(name: string, retired: readonly RetiredCopy[]): void {
- for (const { botId, wasOff, copy } of retired) {
- if (listSkills(botId).some((skill) => skill.name === name)) continue;
- const learned = copy.source.startsWith(LEARN_SOURCE_PREFIX) && copy.files.every((file) => typeof file.content === "string" && file.path.startsWith("references/"));
- if (learned) {
- const staged = stageSkillWrite(botId, { action: "create", files: [{ path: "SKILL.md", content: copy.skillMd }, ...copy.files as Array<{ path: string; content: string }>], source: copy.source });
- if ("error" in staged) continue;
- const applied = applySkillWriteWithReceipt(botId, staged, () => {});
- if ("error" in applied) { rejectStagedSkillWrite(botId, staged.id); continue; }
- } else {
- const installed = installSkill(botId, copy.source, [{ path: "SKILL.md", content: copy.skillMd }, ...copy.files]);
- if ("error" in installed) continue;
- }
- setSkillEnabled(botId, name, !wasOff);
- setAllBotsSkillOff(botId, name, false);
+/** Undo of a removal: each bot's switch as it was. */
+export function restoreSwitches(name: string, switches: ReadonlyArray<{ botId: string; enabled: boolean }>): string[] {
+ const failed: string[] = [];
+ for (const { botId, enabled } of switches) {
+ const entry = listSkills(botId).find((skill) => skill.name === name);
+ if (!entry?.allBots || ("error" in setSkillEnabled(botId, name, enabled))) failed.push(botId);
}
+ return failed;
}
diff --git a/server/skills-for-all-bots.e2e.test.ts b/server/skills-for-all-bots.e2e.test.ts
index f1f2cafa1f..a72d57488a 100644
--- a/server/skills-for-all-bots.e2e.test.ts
+++ b/server/skills-for-all-bots.e2e.test.ts
@@ -47,7 +47,7 @@ it("puts a skill on every bot of the person's with one tool call, and takes it o
expect(receipt.card).toMatchObject({ autoApplied: true, skillRequest: { allBots: true, action: "create", name: "client-onboarding" } });
const listed = await run(writer, "Which skills do you have?", [{ tool: "skills_list", arguments: {}, expectError: false }]);
- expect(listed[0]).toContain("client-onboarding (enabled, on all your bots, update or delete changes every one)");
+ expect(listed[0]).toContain("client-onboarding (enabled, on all your bots: update/delete changes all)");
const [deleted] = await run(writer, "Remove client-onboarding from all my bots.", [
{ tool: "skill_manage", arguments: { action: "delete", skill_name: "client-onboarding" }, expectError: false },
diff --git a/server/skills-for-all-bots.test.ts b/server/skills-for-all-bots.test.ts
index 3fe6e51a0c..98f2359cf3 100644
--- a/server/skills-for-all-bots.test.ts
+++ b/server/skills-for-all-bots.test.ts
@@ -1,4 +1,4 @@
-import { mkdtempSync, rmSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -12,14 +12,15 @@ const library = await import("./skill-library.ts");
const everywhere = await import("./skills-for-all-bots.ts");
const ops = await import("./skills-for-all-bots-ops.ts");
const { createSkillsForAllBotsHost } = await import("./host/skills-for-all-bots-host.ts");
-const { createSkillSwitchHost } = await import("./host/skill-switch-host.ts");
-const { requesterScope } = await import("./routes/skills-for-all-bots.ts");
+const { requesterScope, withAllBotsOffer } = await import("./routes/skills-for-all-bots.ts");
const { learnSource } = await import("./skill-learn.ts");
const { flushDecisionLog } = await import("./decision-log.ts");
const { personKey } = await import("./person-key.ts");
+const { workspaceDir } = await import("./workspace.ts");
+const { saveWorkflowSkill, workflowSkillsPrompt } = await import("./skill-burger/store.ts");
const { DATA_DIR } = await import("./config.ts");
-type Bot = { id: string; name: string; color: string; createdBy?: string; reportsTo?: string; home?: unknown };
+type Bot = { id: string; name: string; color: string; threadId: string; createdBy?: string; reportsTo?: string; home?: unknown };
const SKILL = (name: string, body = "Do the thing.", description = "Sets up a new client the way this person does.") =>
`---\nname: ${name}\ndescription: ${description}\n---\n\n# ${name}\n\n${body}\n`;
@@ -27,12 +28,13 @@ const SKILL = (name: string, body = "Do the thing.", description = "Sets up a ne
const quoted = (path: string) => JSON.stringify(path).slice(1, -1);
const unique = (prefix: string) => `${prefix}-${Math.random().toString(36).slice(2, 10)}`;
let bots: Bot[] = [];
+let sharedWithoutTeam = false;
function wire(team = false) {
- everywhere.wireSkillsForAllBots({ team, bot: (id) => bots.find((bot) => bot.id === id), bots: () => bots });
+ ops.wireAllBotsSkills({ team, sharedWithoutTeam: () => sharedWithoutTeam, bot: (id) => bots.find((bot) => bot.id === id), bots: () => bots });
}
function bot(name: string, more: Partial<Bot> = {}): Bot {
- const made = { id: unique(name.toLowerCase()), name, color: "blue", ...more };
+ const made = { id: unique(name.toLowerCase().replace(/[^a-z]/g, "")), name, color: "blue", threadId: unique("t"), ...more };
bots.push(made);
return made;
}
@@ -42,92 +44,115 @@ function learn(botId: string, name: string, body?: string) {
const applied = skills.applyStagedSkillWrite(botId, staged.id, { expectedSha256: staged.sha256 });
if ("error" in applied) throw new Error(applied.error);
}
-const names = (botId: string, library?: string[]) => skills.resolveBotSkills(botId, library).filter((skill) => skill.enabled).map((skill) => skill.name);
+const on = (botId: string) => skills.listSkills(botId).filter((skill) => skill.enabled).map((skill) => skill.name);
+const shared = (botId: string) => skills.listSkills(botId).filter((skill) => skill.allBots).map((skill) => skill.name);
const indexLines = (botId: string, name: string) => skills.skillsSystemPrompt(botId).split("\n").filter((line) => line.startsWith(`- ${name}:`));
function putFrom(botId: string, name: string) {
const copy = ops.ownCopy(botId, name);
if (!copy) throw new Error("no own copy");
- const put = ops.putOnAllBots(everywhere.allBotsScopeOfBot(bots.find((one) => one.id === botId))!, name, copy, { fresh: true });
+ const put = ops.putOnAllBots(everywhere.allBotsScopeOfBot(bots.find((one) => one.id === botId))!, name, copy);
if ("error" in put) throw new Error(put.error);
return put;
}
beforeEach(() => {
bots = [];
+ sharedWithoutTeam = false;
rmSync(join(DATA_DIR, "skills-for-all-bots"), { recursive: true, force: true });
wire();
});
-afterEach(() => everywhere.wireSkillsForAllBots(null));
+afterEach(() => ops.wireAllBotsSkills(null));
describe("a skill on all of the person's bots", () => {
- it("reaches every bot, a bot made later too, with one index line each, and leaves with one removal", () => {
+ it("is a copy among each bot's own skills, a bot made later too, readable in its own folder and linked for its engine", () => {
const chief = bot("Chief"), writer = bot("Writer"), keeper = bot("Keeper");
learn(chief.id, "client-onboarding");
learn(keeper.id, "client-onboarding", "Keeper's own different way.");
- const put = putFrom(chief.id, "client-onboarding");
- expect(put.retired.map((one) => one.botId)).toEqual([chief.id]);
- expect(put.kept).toEqual([keeper.id]);
- expect(skills.listSkills(chief.id)).toEqual([]);
+ expect(putFrom(chief.id, "client-onboarding")).toEqual({ kept: [keeper.id], failed: [] });
const later = bot("Later");
for (const one of [chief, writer, later]) {
- expect(names(one.id)).toEqual(["client-onboarding"]);
+ expect(shared(one.id)).toEqual(["client-onboarding"]);
const lines = indexLines(one.id, "client-onboarding");
expect(lines).toHaveLength(1);
- expect(lines[0]).toContain(quoted(join(DATA_DIR, "skills-for-all-bots", "mine", "skills", "client-onboarding", "SKILL.md")));
+ // Inside the bot's own folder, which a bot box gives back and a move carries: no new path to mount.
+ expect(lines[0]).toContain(quoted(join(workspaceDir(one.id), "skills")));
+ expect(existsSync(join(workspaceDir(one.id), ".claude", "skills", "client-onboarding", "SKILL.md"))).toBe(true);
}
- // The bot with its own different copy keeps it: its own skill wins the name.
- expect(skills.resolveBotSkills(keeper.id, undefined).filter((skill) => skill.name === "client-onboarding")).toHaveLength(1);
- expect(indexLines(keeper.id, "client-onboarding")[0]).toContain(quoted(join("workspaces", keeper.id)));
- expect(skills.enabledSkillFile(writer.id, "client-onboarding")).toBe(everywhere.allBotsSkillFile(writer.id, "client-onboarding"));
+ expect(shared(keeper.id)).toEqual([]);
+ expect(skills.readSkillFile(keeper.id, "client-onboarding")).toContain("Keeper's own different way.");
+ // Removing it takes the copies away, and the bot that had it first keeps the one it had.
const removed = ops.removeFromAllBots("mine", "client-onboarding");
- expect("removed" in removed).toBe(true);
- for (const one of [chief, writer, later]) expect(names(one.id)).toEqual([]);
- expect(names(keeper.id)).toEqual(["client-onboarding"]);
+ expect("removed" in removed && removed.failed).toEqual([]);
+ expect([on(chief.id), on(writer.id), on(later.id), on(keeper.id)]).toEqual([["client-onboarding"], [], [], ["client-onboarding"]]);
+ expect(shared(chief.id)).toEqual([]);
});
- it("turns off for one bot only, and an identical copy that was off stays off there", () => {
- const chief = bot("Chief"), writer = bot("Writer"), quiet = bot("Quiet");
+ it("keeps each bot's switch its own, through an update too", () => {
+ const chief = bot("Chief"), writer = bot("Writer");
learn(chief.id, "weekly-report");
- learn(quiet.id, "weekly-report");
- skills.setSkillEnabled(quiet.id, "weekly-report", false);
- const put = putFrom(chief.id, "weekly-report");
- expect(put.retired.map((one) => [one.botId, one.wasOff])).toEqual([[chief.id, false], [quiet.id, true]]);
- expect(names(quiet.id)).toEqual([]);
- everywhere.setAllBotsSkillOff(writer.id, "weekly-report", true);
- expect(names(writer.id)).toEqual([]);
+ putFrom(chief.id, "weekly-report");
+ skills.setSkillEnabled(writer.id, "weekly-report", false);
+ expect([on(chief.id), on(writer.id)]).toEqual([["weekly-report"], []]);
expect(indexLines(writer.id, "weekly-report")).toEqual([]);
- expect(names(chief.id)).toEqual(["weekly-report"]);
- everywhere.setAllBotsSkillOff(writer.id, "weekly-report", false);
- expect(names(writer.id)).toEqual(["weekly-report"]);
+ const put = ops.putOnAllBots("mine", "weekly-report", { skillMd: SKILL("weekly-report", "New way."), files: [], source: "learned:conversation" });
+ expect(put).toEqual({ kept: [], failed: [] });
+ expect([on(chief.id), on(writer.id)]).toEqual([["weekly-report"], []]);
+ expect(skills.readSkillFile(writer.id, "weekly-report")).toContain("New way.");
+ });
+
+ it("an update that cannot be stored leaves the copy it would replace on every bot", () => {
+ const chief = bot("Chief"), writer = bot("Writer");
+ const refs = [{ path: "references/steps.md", content: "# Steps\n" }];
+ expect(ops.putOnAllBots("mine", "with-notes", { skillMd: SKILL("with-notes"), files: refs, source: "learned:conversation" })).toEqual({ kept: [], failed: [] });
+ const broken = ops.putOnAllBots("mine", "with-notes", { skillMd: SKILL("misnamed"), files: refs, source: "learned:conversation" });
+ expect(broken).toMatchObject({ error: expect.stringContaining("misnamed") });
+ expect(ops.sharedCopy("mine", "with-notes")?.skillMd).toBe(SKILL("with-notes"));
+ expect([shared(chief.id), shared(writer.id)]).toEqual([["with-notes"], ["with-notes"]]);
+ });
+
+ it("with no skill on all bots, a listing reads nothing of the store until the store is written", () => {
+ const chief = bot("Chief");
+ expect(skills.listSkills(chief.id)).toEqual([]);
+ // Written behind the cache's back: a listing does not look.
+ const root = everywhere.allBotsRoot("mine");
+ mkdirSync(root, { recursive: true });
+ writeFileSync(join(root, "store.json"), JSON.stringify({ id: "00000000-0000-4000-8000-000000000000" }));
+ library.installLibrarySkill({ name: "behind", instructions: SKILL("behind"), source: "test", reviewState: "approved", root });
+ expect(skills.listSkills(chief.id)).toEqual([]);
+ everywhere.forgetAllBotsStore("mine");
+ expect(shared(chief.id)).toEqual(["behind"]);
});
- it("with the library on too, a name in both shows once and is the person's all-bots copy", () => {
+ it("with the library on too, a name in both shows once and is the person's copy", () => {
const chief = bot("Chief");
const libraryRoot = library.skillsLibraryRoot();
const installed = library.installLibrarySkill({ name: "release-notes", instructions: SKILL("release-notes", "Library way.", "The library's copy."), source: "test", reviewState: "approved", root: libraryRoot });
if ("error" in installed) throw new Error(installed.error);
library.setLibrarySkillEveryBot("release-notes", true, libraryRoot);
- expect(skills.resolveBotSkills(chief.id, []).map((skill) => skill.name)).toEqual(["release-notes"]);
- learn(chief.id, "release-notes", "The person's way.");
- putFrom(chief.id, "release-notes");
+ ops.putOnAllBots("mine", "release-notes", { skillMd: SKILL("release-notes", "The person's way."), files: [], source: "learned:conversation" });
const listed = skills.resolveBotSkills(chief.id, []).filter((skill) => skill.name === "release-notes");
- expect(listed).toHaveLength(1);
- expect(listed[0]).toMatchObject({ allBots: true, description: "Sets up a new client the way this person does." });
- expect(skills.listBotSkillsWithOrigin(chief.id, []).skills.map((skill) => [skill.name, skill.origin])).toEqual([["release-notes", "all-bots"]]);
- expect(skills.enabledSkillFile(chief.id, "release-notes", [])).toBe(everywhere.allBotsSkillFile(chief.id, "release-notes"));
- expect(skills.skillsSystemPrompt(chief.id, []).split("\n").filter((line) => line.startsWith("- release-notes:"))).toEqual([
- expect.stringContaining(quoted(join("skills-for-all-bots", "mine"))),
- ]);
+ expect(listed).toEqual([expect.objectContaining({ allBots: true, description: "Sets up a new client the way this person does." })]);
+ expect(skills.listBotSkillsWithOrigin(chief.id, []).skills.map((skill) => [skill.name, skill.origin])).toEqual([["release-notes", "private"]]);
+ expect(skills.enabledSkillFile(chief.id, "release-notes", [])).toContain(join(workspaceDir(chief.id), "skills"));
ops.removeFromAllBots("mine", "release-notes");
- expect(skills.resolveBotSkills(chief.id, [])[0]).not.toHaveProperty("allBots");
+ expect(skills.resolveBotSkills(chief.id, [])[0]).toMatchObject({ name: "release-notes", description: "The library's copy." });
library.retireLibrarySkill("release-notes", library.readSkillLibraryIndex(libraryRoot)["release-notes"]!.sha256, libraryRoot);
});
+
+ it("gives a saved Skill Burger of the same name no second index line", () => {
+ const chief = bot("Chief");
+ const root = mkdtempSync(join(tmpdir(), "burger-"));
+ const saved = saveWorkflowSkill({ workflow: { version: 1, summary: "Send the weekly report", args: {}, steps: [{ id: "s1", kind: "ai", deterministic: false, label: "Write it", prompt: "Write it." }] } as never, botIds: [chief.id], name: "weekly-report", root });
+ if ("error" in saved) throw new Error(saved.error);
+ expect(workflowSkillsPrompt(chief.id, root)).toContain("- weekly-report:");
+ expect(workflowSkillsPrompt(chief.id, root, new Set(["weekly-report"]))).toBe("");
+ });
});
-describe("on a Team Cloud, all my bots is the member's own bots only", () => {
- it("never reaches another member's bot or a team bot nobody owns, and a stand-in has none", () => {
+describe("whose bots", () => {
+ it("on a Team Cloud: the member's own bots only, never another member's, a bot nobody owns or a stand-in", () => {
wire(true);
const alicesChief = bot("Alice's Chief", { createdBy: "[email protected]" });
const alicesWriter = bot("Alice's Writer", { createdBy: "[email protected]", reportsTo: "[email protected]" });
@@ -138,47 +163,60 @@ describe("on a Team Cloud, all my bots is the member's own bots only", () => {
expect(everywhere.allBotsScopeOfBot(standIn)).toBeNull();
learn(alicesChief.id, "client-onboarding");
putFrom(alicesChief.id, "client-onboarding");
- expect(names(alicesChief.id)).toEqual(["client-onboarding"]);
- expect(names(alicesWriter.id)).toEqual(["client-onboarding"]);
- for (const other of [bobs, team, standIn]) expect(names(other.id)).toEqual([]);
+ expect([shared(alicesChief.id), shared(alicesWriter.id)]).toEqual([["client-onboarding"], ["client-onboarding"]]);
+ for (const other of [bobs, team, standIn]) expect(skills.listSkills(other.id)).toEqual([]);
const session = (email?: string) => ({ kind: "session", session: { email }, via: "bearer", scopes: ["client"] }) as never;
expect(requesterScope(alicesWriter as never, session("[email protected]"))).toEqual({ scope: everywhere.allBotsScopeOfPerson("[email protected]", true) });
expect(requesterScope(alicesWriter as never, session("[email protected]"))).toMatchObject({ status: 403 });
- expect(requesterScope(alicesWriter as never, session())).toMatchObject({ status: 403 });
expect(requesterScope(alicesWriter as never, { kind: "loopback", scopes: ["admin"] } as never)).toMatchObject({ status: 403 });
expect(requesterScope(team as never, session("[email protected]"))).toMatchObject({ status: 409 });
+ // The button shows only to the bot's own person.
+ learn(alicesWriter.id, "own-thing");
+ const listed = skills.listSkills(alicesWriter.id);
+ expect(withAllBotsOffer(alicesWriter as never, session("[email protected]"), listed).filter((skill) => skill.canUseOnAllBots).map((skill) => skill.name)).toEqual(["own-thing"]);
+ expect(withAllBotsOffer(alicesWriter as never, session("[email protected]"), listed).some((skill) => skill.canUseOnAllBots)).toBe(false);
+ });
+
+ it("on a server several people share without a team: none, and the tool and the page say why", async () => {
+ sharedWithoutTeam = true;
+ const chief = bot("Chief");
+ expect(everywhere.allBotsScopeOfBot(chief)).toBeNull();
+ expect(requesterScope(chief as never, { kind: "loopback", scopes: ["admin"] } as never)).toEqual({ status: 409, error: everywhere.SHARED_WITHOUT_TEAM });
+ const { call } = host(true);
+ expect(await call(chief, { action: "create", all_bots: true, skill_md: SKILL("x-skill"), source: "conversation" })).toEqual({ status: 422, body: { error: everywhere.SHARED_WITHOUT_TEAM } });
});
});
-describe("skill_manage for all the person's bots", () => {
- const dataDirs: string[] = [];
- afterEach(async () => {
- for (const dir of dataDirs.splice(0)) await flushDecisionLog(dir);
+const dataDirs: string[] = [];
+afterEach(async () => {
+ for (const dir of dataDirs.splice(0)) await flushDecisionLog(dir);
+});
+function host(direct: boolean, room = false) {
+ const dataDir = mkdtempSync(join(tmpdir(), "omb-all-bots-host-"));
+ dataDirs.push(dataDir);
+ const messages: Array<{ id: string; threadId: string; card: any }> = [];
+ const made = createSkillsForAllBotsHost({
+ store: {
+ bot: (id: string) => bots.find((one) => one.id === id) as never,
+ appendMessage: ((threadId: string, message: { card: unknown }) => { messages.push({ id: `m${messages.length}`, threadId, card: message.card }); }) as never,
+ patchMessage: ((_thread: string, id: string, patch: { card: unknown }) => { messages.find((one) => one.id === id)!.card = patch.card; }) as never,
+ groupByThread: (() => (room ? { id: "room" } : undefined)) as never,
+ },
+ dataDir,
+ persistence: () => ({ ok: true }),
+ noteSkillChange: vi.fn(),
});
- function host(direct: boolean) {
- const dataDir = mkdtempSync(join(tmpdir(), "omb-all-bots-host-"));
- dataDirs.push(dataDir);
- const messages: Array<{ id: string; card: any }> = [];
- const made = createSkillsForAllBotsHost({
- store: {
- bot: (id: string) => bots.find((one) => one.id === id) as never,
- appendMessage: ((_thread: string, message: { card: unknown }) => { messages.push({ id: `m${messages.length}`, card: message.card }); }) as never,
- patchMessage: ((_thread: string, id: string, patch: { card: unknown }) => { messages.find((one) => one.id === id)!.card = patch.card; }) as never,
- },
- dataDir,
- persistence: () => ({ ok: true }),
- noteSkillChange: vi.fn(),
- });
- const call = (from: Bot, body: Record<string, unknown>, actsFor: string | null = null) =>
- made.stage(from as never, "t1", body, () => (direct ? "full-access" : null), async (asked) => asked, () => true, () => actsFor);
- const last = () => messages.at(-1)!;
- const undo = (from: Bot) => made.undo(from.id, "t1", last() as never, last().card.skillRequest);
- const answer = (from: Bot, behavior: "allow" | "deny") =>
- made.resolve({ botId: from.id, threadId: "t1", requestId: last().card.requestId, behavior, reviewedSha256: last().card.skillRequest.sha256 }, last().id, last().card, last().card.skillRequest);
- return { call, last, undo, answer, messages };
- }
+ const call = (from: Bot, body: Record<string, unknown>, actsFor: string | null = null) =>
+ made.stage(from as never, "t1", body, () => (direct ? "full-access" : null), async (asked) => asked, () => true, () => actsFor);
+ const last = () => messages.at(-1)!;
+ const undo = (from: Bot) => made.undo(from.id, last().threadId, last() as never, last().card.skillRequest);
+ const answer = (from: Bot, behavior: "allow" | "deny") =>
+ made.resolve({ botId: from.id, threadId: "t1", requestId: last().card.requestId, behavior, reviewedSha256: last().card.skillRequest.sha256 }, last().id, last().card, last().card.skillRequest);
+ return { made, call, last, undo, answer, messages };
+}
+describe("changing them through skill_manage and the Skills page", () => {
it("creates on every bot in one call with a receipt, and Undo gives each bot back what it had", async () => {
const chief = bot("Chief"), writer = bot("Writer"), quiet = bot("Quiet");
learn(quiet.id, "client-onboarding");
@@ -187,48 +225,58 @@ describe("skill_manage for all the person's bots", () => {
const result = await call(chief, { action: "create", all_bots: true, skill_md: SKILL("client-onboarding"), source: "conversation" });
expect(result).toMatchObject({ status: 201, body: { state: "applied", allBots: true, name: "client-onboarding" } });
expect(last().card).toMatchObject({ autoApplied: true, title: 'Skill "client-onboarding" is on all your bots', skillRequest: { allBots: true, action: "create" } });
- expect([names(chief.id), names(writer.id), names(quiet.id)]).toEqual([["client-onboarding"], ["client-onboarding"], []]);
- expect(skills.listSkills(quiet.id)).toEqual([]);
+ expect([on(chief.id), on(writer.id), on(quiet.id)]).toEqual([["client-onboarding"], ["client-onboarding"], []]);
+ expect(shared(quiet.id)).toEqual(["client-onboarding"]);
expect(undo(chief)).toEqual({ claimed: true, state: "undone" });
- expect([names(chief.id), names(writer.id)]).toEqual([[], []]);
- expect(skills.listSkills(quiet.id).map((skill) => [skill.name, skill.enabled])).toEqual([["client-onboarding", false]]);
- expect(everywhere.allBotsSkillOffs(quiet.id).has("client-onboarding")).toBe(false);
+ expect([skills.listSkills(chief.id), skills.listSkills(writer.id)]).toEqual([[], []]);
+ expect(skills.listSkills(quiet.id).map((skill) => [skill.name, skill.enabled, Boolean(skill.allBots)])).toEqual([["client-onboarding", false, false]]);
});
- it("updates and deletes a shared skill by its name alone, and Undo restores it", async () => {
+ it("updates and deletes a shared skill by its name alone; Undo of a delete brings back each bot's switch", async () => {
const chief = bot("Chief"), writer = bot("Writer");
const { call, undo } = host(true);
- await call(chief, { action: "create", all_bots: true, skill_md: SKILL("weekly-report"), source: "conversation" });
+ const references = [{ path: "references/steps.md", content: "# Steps\n\nOne, two.\n" }, { path: "references/tone.md", content: "# Tone\n\nPlain.\n" }];
+ await call(chief, { action: "create", all_bots: true, skill_md: SKILL("weekly-report"), references, source: "conversation" });
const updated = await call(writer, { action: "update", skill_name: "weekly-report", skill_md: SKILL("weekly-report", "New way."), source: "conversation" });
expect(updated).toMatchObject({ status: 201, body: { state: "applied", action: "update" } });
- expect(skills.enabledSkillFile(chief.id, "weekly-report")).toBeTruthy();
- expect(ops.sharedCopy("mine", "weekly-report")?.skillMd).toContain("New way.");
- expect(undo(writer)).toEqual({ claimed: true, state: "undone" });
- expect(ops.sharedCopy("mine", "weekly-report")?.skillMd).toContain("Do the thing.");
+ expect(ops.sharedCopy("mine", "weekly-report")?.files.map((file) => file.path)).toEqual(["references/steps.md", "references/tone.md"]);
+ expect(skills.readSkillFile(chief.id, "weekly-report")).toContain("New way.");
+ await call(chief, { action: "update", skill_name: "weekly-report", skill_md: SKILL("weekly-report", "Newer."), references: [{ path: "references/tone.md", content: "" }], source: "conversation" });
+ expect(ops.sharedCopy("mine", "weekly-report")?.files.map((file) => file.path)).toEqual(["references/steps.md"]);
+ expect(undo(chief)).toEqual({ claimed: true, state: "undone" });
+ expect(skills.readSkillFile(writer.id, "weekly-report")).toContain("New way.");
- everywhere.setAllBotsSkillOff(writer.id, "weekly-report", true);
- const deleted = await call(chief, { action: "delete", skill_name: "weekly-report" });
- expect(deleted).toMatchObject({ status: 201, body: { state: "applied", action: "delete" } });
- expect(names(chief.id)).toEqual([]);
+ skills.setSkillEnabled(writer.id, "weekly-report", false);
+ expect(await call(chief, { action: "delete", skill_name: "weekly-report" })).toMatchObject({ status: 201, body: { state: "applied", action: "delete" } });
+ expect([skills.listSkills(chief.id), skills.listSkills(writer.id)]).toEqual([[], []]);
expect(undo(chief)).toEqual({ claimed: true, state: "undone" });
- expect(names(chief.id)).toEqual(["weekly-report"]);
- expect(names(writer.id)).toEqual([]); // its own switch came back with it
- ops.removeFromAllBots("mine", "weekly-report");
+ expect([on(chief.id), on(writer.id), shared(writer.id)]).toEqual([["weekly-report"], [], ["weekly-report"]]);
});
- it("waits on a card where the bot's own skill changes would, and applies only on approval", async () => {
+ it("names the bots Undo could not put back, and puts back the rest", async () => {
const chief = bot("Chief"), writer = bot("Writer");
- const { call, last, answer } = host(false);
- expect(await call(chief, { action: "create", all_bots: true, skill_md: SKILL("invoice-check"), source: "conversation" })).toMatchObject({ status: 201, body: { state: "pending" } });
- expect(last().card).toMatchObject({ options: ["Enable", "Deny"], title: 'Put skill "invoice-check" on all your bots?' });
- expect(names(writer.id)).toEqual([]);
- expect(answer(chief, "allow")).toEqual({ claimed: true, outcome: "allowed-once" });
- expect(names(writer.id)).toEqual(["invoice-check"]);
- await call(chief, { action: "delete", skill_name: "invoice-check" });
- expect(answer(chief, "deny")).toEqual({ claimed: true, outcome: "rejected" });
- expect(names(writer.id)).toEqual(["invoice-check"]);
- ops.removeFromAllBots("mine", "invoice-check");
+ const { call, undo } = host(true);
+ await call(chief, { action: "create", all_bots: true, skill_md: SKILL("tidy-inbox"), source: "conversation" });
+ await call(chief, { action: "delete", skill_name: "tidy-inbox" });
+ // The writer's skills folder is no folder any more: its copy cannot come back there.
+ rmSync(join(workspaceDir(writer.id), "skills"), { recursive: true, force: true });
+ writeFileSync(join(workspaceDir(writer.id), "skills"), "not a folder");
+ expect(undo(chief)).toMatchObject({ claimed: true, state: "invalid", error: expect.stringContaining("Undone, except on Writer") });
+ expect(on(chief.id)).toEqual(["tidy-inbox"]);
+ });
+
+ it("waits on a card where the bot's own skill changes would, and in a room whatever the access level", async () => {
+ const chief = bot("Chief"), writer = bot("Writer");
+ for (const [direct, room] of [[false, false], [true, true]] as const) {
+ const name = room ? "in-room" : "invoice-check";
+ const { call, last, answer } = host(direct, room);
+ expect(await call(chief, { action: "create", all_bots: true, skill_md: SKILL(name), source: "conversation" })).toMatchObject({ status: 201, body: { state: "pending" } });
+ expect(last().card).toMatchObject({ options: ["Enable", "Deny"], title: `Put skill "${name}" on all your bots?` });
+ expect(on(writer.id)).not.toContain(name);
+ expect(answer(chief, "allow")).toEqual({ claimed: true, outcome: "allowed-once" });
+ expect(on(writer.id)).toContain(name);
+ }
});
it("leaves the bot's own skills to the usual paths, and refuses a team bot nobody owns", async () => {
@@ -248,41 +296,25 @@ describe("skill_manage for all the person's bots", () => {
const alicesWriter = bot("Alice's Writer", { createdBy: "[email protected]" });
const { call } = host(true);
const create = { action: "create", all_bots: true, skill_md: SKILL("team-thing"), source: "conversation" };
- // A teammate chatting with Alice's shared bot, and a routine acting for nobody, cannot reach all of Alice's bots.
expect(await call(alicesChief, create, personKey({ id: "", email: "[email protected]" }))).toMatchObject({ status: 403 });
expect(await call(alicesChief, create, null)).toMatchObject({ status: 403 });
- expect(names(alicesWriter.id)).toEqual([]);
+ expect(skills.listSkills(alicesWriter.id)).toEqual([]);
expect(await call(alicesChief, create, personKey({ id: "", email: "[email protected]" }))).toMatchObject({ status: 201, body: { state: "applied" } });
- expect(names(alicesWriter.id)).toEqual(["team-thing"]);
+ expect(shared(alicesWriter.id)).toEqual(["team-thing"]);
});
- it("an update keeps the reference files it does not mention, and an empty one removes that file", async () => {
- const chief = bot("Chief");
- const { call } = host(true);
- const references = [{ path: "references/steps.md", content: "# Steps\n\nOne, two.\n" }, { path: "references/tone.md", content: "# Tone\n\nPlain.\n" }];
- await call(chief, { action: "create", all_bots: true, skill_md: SKILL("with-notes"), references, source: "conversation" });
- await call(chief, { action: "update", skill_name: "with-notes", skill_md: SKILL("with-notes", "New way."), source: "conversation" });
- expect(ops.sharedCopy("mine", "with-notes")?.files.map((file) => file.path)).toEqual(["references/steps.md", "references/tone.md"]);
- await call(chief, { action: "update", skill_name: "with-notes", skill_md: SKILL("with-notes", "Newer way."), references: [{ path: "references/tone.md", content: "" }], source: "conversation" });
- expect(ops.sharedCopy("mine", "with-notes")).toMatchObject({ files: [{ path: "references/steps.md" }] });
- expect(ops.sharedCopy("mine", "with-notes")?.skillMd).toContain("Newer way.");
- });
-
- it("switches a shared skill on or off for the asking bot only", () => {
- const chief = bot("Chief"), writer = bot("Writer");
- learn(chief.id, "tidy-inbox");
- putFrom(chief.id, "tidy-inbox");
- const dataDir = mkdtempSync(join(tmpdir(), "omb-all-bots-switch-"));
- dataDirs.push(dataDir);
- const switches = createSkillSwitchHost({
- store: { bot: (id: string) => bots.find((one) => one.id === id) as never, appendMessage: (() => {}) as never, patchMessage: (() => {}) as never },
- dataDir, persistence: () => ({ ok: true }),
- listBotSkills: (one) => skills.resolveBotSkills(one.id, undefined),
- readBotSkillFile: (one, name) => everywhere.readAllBotsSkillFile(one.id, name),
- noteSkillChange: vi.fn(),
- });
- expect(switches.stage(writer as never, "t1", "disable", { skill_name: "tidy-inbox" }, "full-access")).toMatchObject({ status: 201, body: { state: "applied" } });
- expect(names(writer.id)).toEqual([]);
- expect(names(chief.id)).toEqual(["tidy-inbox"]);
+ it("the page's Use on all bots posts a receipt in the bot's chat whose Undo gives each bot back what it had", () => {
+ const chief = bot("Chief"), writer = bot("Writer"), keeper = bot("Keeper");
+ learn(chief.id, "client-onboarding");
+ learn(keeper.id, "client-onboarding", "Different.");
+ const { made, last, undo } = host(true);
+ expect(made.fromSkillsPage(chief as never, "client-onboarding", "mine")).toEqual({ status: 200, body: { name: "client-onboarding", kept: ["Keeper"], failed: [] } });
+ expect(last()).toMatchObject({ threadId: chief.threadId, card: { autoApplied: true, skillRequest: { allBots: true, action: "create" } } });
+ expect(shared(writer.id)).toEqual(["client-onboarding"]);
+ // From the bot that kept a different copy, it is refused rather than replacing the shared one.
+ expect(made.fromSkillsPage(keeper as never, "client-onboarding", "mine")).toMatchObject({ status: 409 });
+ expect(undo(chief)).toEqual({ claimed: true, state: "undone" });
+ expect([on(chief.id), on(writer.id), on(keeper.id)]).toEqual([["client-onboarding"], [], ["client-onboarding"]]);
+ expect(skills.readSkillFile(keeper.id, "client-onboarding")).toContain("Different.");
});
});
diff --git a/server/skills-for-all-bots.ts b/server/skills-for-all-bots.ts
index 59b934373a..da50bb2472 100644
--- a/server/skills-for-all-bots.ts
+++ b/server/skills-for-all-bots.ts
@@ -1,11 +1,12 @@
-// Skills a person keeps on all of their bots on this server: one copy per person, read by each bot of theirs when it
-// lists its skills, so a bot made later has them too and removing one takes it off every bot at once. The copy is kept in
-// the skills library's own record format (skill-library.ts), one library root per person: the per-person form of the
-// library's every-bot flag. Off a team that person is the server's one owner and every bot here is theirs; on a Team
-// Cloud a member's root reaches only the bots that report to them (botOwner), never a bot nobody owns and never another
-// member's. A bot can turn one off for itself only (all-bots-off.json beside its own skill state). Nothing here runs at
-// server start: the store is read when a bot lists its skills, as its own skills are.
-import { createHash } from "node:crypto";
+// Skills a person keeps on all of their bots on this server. The person's record is the source of truth: one copy per
+// person, kept in the skills library's own record format (skill-library.ts) under a root of its own, the per-person form
+// of the library's every-bot flag. Each bot of theirs holds a managed copy of it among its own skills, marked as shared,
+// so everything that reads a bot's own skills (its prompt index, its engine's skill folders, a bot box, a move, a
+// template) reads it with no new path. A bot's copy is brought up to date as its skills are listed, so a bot made later
+// gets it, an update rewrites it and a removal takes it away; the bot's own switch for it stays its own.
+// Whose bots: off a team, every bot on the server; on a Team Cloud only the bots that report to the member (botOwner),
+// never a bot nobody owns and never another member's. A server several people share without a team has none.
+import { createHash, randomUUID } from "node:crypto";
import { mkdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { z } from "zod";
@@ -13,8 +14,8 @@ import { z } from "zod";
import { writeFileAtomic } from "./atomic.ts";
import { DATA_DIR } from "./config.ts";
import { botOwner, type OwnedBot } from "../shared/bot-owner.ts";
-import { isSkillName } from "../shared/skill-md.ts";
-import { librarySkillFilePath, listLibrarySkills, readLibrarySkillFile, readSkillLibraryIndex, type LibrarySkillListing } from "./skill-library.ts";
+import { readLibrarySkillFile, readSkillLibraryIndex, type SkillLibraryEntry } from "./skill-library.ts";
+import type { SharedSkillMark } from "./skills.ts";
export const SKILLS_FOR_ALL_BOTS_DIR = "skills-for-all-bots";
@@ -23,6 +24,8 @@ export type AllBotsBot = OwnedBot & { id: string; home?: unknown };
interface Wiring {
team: boolean;
+ /** Several people sign in to this server without it being a Team Cloud: nobody's "all my bots" is known here. */
+ sharedWithoutTeam?(): boolean;
bot(id: string): AllBotsBot | null | undefined;
bots(): readonly AllBotsBot[];
}
@@ -32,12 +35,19 @@ let wiring: Wiring | null = null;
/** Set once by the server; unset (tests of one module, tools) there are no all-bots skills. */
export function wireSkillsForAllBots(next: Wiring | null): void {
wiring = next;
+ stores.clear();
}
export function skillsForAllBotsOnTeam(): boolean {
return wiring?.team === true;
}
+export const SHARED_WITHOUT_TEAM = "Several people use this server without it being a Team Cloud, so \"all my bots\" is not available here.";
+
+export function allBotsUnavailable(): boolean {
+ return !wiring || (!wiring.team && wiring.sharedWithoutTeam?.() === true);
+}
+
/** Whose store: "mine" off a team; on a Team Cloud the member's own, by a digest of their address. */
export function allBotsScopeOfPerson(email: string | null | undefined, team = skillsForAllBotsOnTeam()): string | null {
if (!team) return "mine";
@@ -45,9 +55,10 @@ export function allBotsScopeOfPerson(email: string | null | undefined, team = sk
return key ? `person-${createHash("sha256").update(key).digest("hex").slice(0, 32)}` : null;
}
-/** Null for a bot that has no all-bots skills: a stand-in, or on a Team Cloud a bot nobody owns. */
+/** Null for a bot that has no all-bots skills: a stand-in, on a Team Cloud a bot nobody owns, or any bot of a server
+ * several people share without a team. */
export function allBotsScopeOfBot(bot: AllBotsBot | null | undefined, team = skillsForAllBotsOnTeam()): string | null {
- if (!bot || bot.home) return null;
+ if (!bot || bot.home || allBotsUnavailable()) return null;
return team ? allBotsScopeOfPerson(botOwner(bot), true) : "mine";
}
@@ -57,83 +68,55 @@ export function allBotsRoot(scope: string, dataDir: string = DATA_DIR): string {
/** The bots a store reaches: every bot of that person here, the ones made later included. */
export function botsInAllBotsScope(scope: string): AllBotsBot[] {
- const team = skillsForAllBotsOnTeam();
- return (wiring?.bots() ?? []).filter((bot) => allBotsScopeOfBot(bot, team) === scope);
-}
-
-export function allBotsRootOfBot(botId: string): string | null {
- const scope = allBotsScopeOfBot(wiring?.bot(botId));
- return scope ? allBotsRoot(scope) : null;
-}
-
-export interface AllBotsSkillListing {
- name: string;
- description: string;
- enabled: boolean;
- editable: false;
- source: string;
- sha256: string;
- importedAt: string;
- warnings: string[];
- skippedFiles: string[];
- files?: string[];
- /** On all of the person's bots; `enabled` false here is this bot's own switch, or a copy that no longer verifies. */
- allBots: true;
-}
-
-function listing(skill: LibrarySkillListing, off: ReadonlySet<string>): AllBotsSkillListing {
- return {
- name: skill.name, description: skill.description, enabled: skill.enabled && !off.has(skill.name), editable: false,
- source: skill.source, sha256: skill.sha256, importedAt: skill.importedAt, warnings: skill.warnings, skippedFiles: skill.skippedFiles,
- ...(skill.files ? { files: skill.files } : {}), allBots: true,
- };
-}
-
-/** The person's all-bots skills as this bot has them. */
-export function allBotsSkills(botId: string): AllBotsSkillListing[] {
- const root = allBotsRootOfBot(botId);
- if (!root) return [];
- const off = allBotsSkillOffs(botId);
- return listLibrarySkills(root).map((skill) => listing(skill, off));
-}
-
-/** The SKILL.md path the bot's index points at, when the person has a skill of this name on all their bots. */
-export function allBotsSkillFile(botId: string, name: string): string | null {
- const root = allBotsRootOfBot(botId);
- return root && isSkillName(name) && Object.hasOwn(readSkillLibraryIndex(root), name) ? librarySkillFilePath(name, root) : null;
+ return (wiring?.bots() ?? []).filter((bot) => allBotsScopeOfBot(bot) === scope);
+}
+
+/** What a bot's copy is checked against: the store's SKILL.md and the files beside it. */
+export const entryKey = (entry: Pick<SkillLibraryEntry, "sha256" | "filesSha256">): string => `${entry.sha256}:${entry.filesSha256 ?? ""}`;
+
+const idSchema = z.object({ id: z.string().regex(/^[a-f0-9-]{36}$/) });
+interface StoreState { id: string | null; entries: Record<string, SkillLibraryEntry> }
+/** Each store as last read, so a person with no all-bots skills costs a listing no file reads; dropped on every write. */
+const stores = new Map<string, StoreState>();
+
+export function allBotsStore(scope: string): StoreState {
+ let state = stores.get(scope);
+ if (!state) {
+ let id: string | null = null;
+ try {
+ const parsed = idSchema.safeParse(JSON.parse(readFileSync(join(allBotsRoot(scope), "store.json"), "utf8")));
+ if (parsed.success) id = parsed.data.id;
+ } catch {}
+ state = { id, entries: id ? readSkillLibraryIndex(allBotsRoot(scope)) : {} };
+ stores.set(scope, state);
+ }
+ return state;
}
-/** Its SKILL.md while it still hashes as stored; null when there is none or it changed outside OpenMausBot. */
-export function readAllBotsSkillFile(botId: string, name: string): string | null {
- const root = allBotsRootOfBot(botId);
- return root ? readLibrarySkillFile(name, root) : null;
+/** The store's id, made on its first write: a bot's copy names it, so a copy that came from another server's store (a
+ * moved bot) is that bot's own skill here, never taken away for being missing from this store. */
+export function ensureAllBotsStore(scope: string): string {
+ const current = allBotsStore(scope).id;
+ if (current) return current;
+ const id = randomUUID();
+ mkdirSync(allBotsRoot(scope), { recursive: true, mode: 0o700 });
+ writeFileAtomic(join(allBotsRoot(scope), "store.json"), `${JSON.stringify({ id })}\n`, { mode: 0o600 });
+ stores.delete(scope);
+ return id;
}
-const offSchema = z.array(z.string());
-
-function offPath(botId: string): string | null {
- return /^[\w-]+$/.test(botId) ? join(DATA_DIR, "skill-state", botId, "all-bots-off.json") : null;
+export function forgetAllBotsStore(scope: string): void {
+ stores.delete(scope);
}
-/** The all-bots skills this one bot has switched off. A list that cannot be read counts as none: every one stays on. */
-export function allBotsSkillOffs(botId: string): ReadonlySet<string> {
- const path = offPath(botId);
- if (!path) return new Set();
- try {
- const parsed = offSchema.safeParse(JSON.parse(readFileSync(path, "utf8")));
- return new Set(parsed.success ? parsed.data.filter(isSkillName) : []);
- } catch {
- return new Set();
- }
+/** Whether a bot's copy belongs to the store of the bot's person here. A listing brings copies up to date first, so a
+ * current copy is of a skill the store still has. */
+export function sharedMarkCurrent(botId: string, mark: SharedSkillMark): boolean {
+ const scope = allBotsScopeOfBot(wiring?.bot(botId));
+ return Boolean(scope && allBotsStore(scope).id === mark.store);
}
-export function setAllBotsSkillOff(botId: string, name: string, off: boolean): void {
- const path = offPath(botId);
- if (!path || !isSkillName(name)) return;
- const names = new Set(allBotsSkillOffs(botId));
- if (names.has(name) === off) return;
- if (off) names.add(name);
- else names.delete(name);
- mkdirSync(join(DATA_DIR, "skill-state", botId), { recursive: true, mode: 0o700 });
- writeFileAtomic(path, `${JSON.stringify([...names].sort(), null, 2)}\n`, { mode: 0o600 });
+/** The store's SKILL.md while it still hashes as stored. */
+export function readAllBotsSkill(scope: string, name: string): string | null {
+ return readLibrarySkillFile(name, allBotsRoot(scope));
}
diff --git a/server/skills.ts b/server/skills.ts
index c37856a254..f9eae584ae 100644
--- a/server/skills.ts
+++ b/server/skills.ts
@@ -29,7 +29,6 @@ import {
import { LEARN_SOURCE_PREFIX } from "./skill-learn.ts";
import { libraryDescriptionsAt, librarySkillFilePath, librarySkillsForBot, librarySkillsToOffer, type LibrarySkillListing } from "./skill-library.ts";
import { readManagedLinks, writeManagedLinks } from "./skill-link-registry.ts";
-import { allBotsSkillFile, allBotsSkills } from "./skills-for-all-bots.ts";
import {
directoryEntryState, entryExistsWithoutFollowing, formatKb, isSkillReferencePath, learnedSkillDirectoryMatches, publishReviewedRevision,
readReferenceFiles, referenceLimitError, referencePathError, REFERENCES_ADVICE, skillReferencesSha256, STAGED_SKILL_FILE_MAX_BYTES,
@@ -37,9 +36,7 @@ import {
import { workspaceDir } from "./workspace.ts";
import { isSkillName, parseSkillMd, scanSkillText, SKILL_FILE_MAX_BYTES, type ParsedSkill } from "../shared/skill-md.ts";
-export {
- DESCRIPTION_MAX, isSkillName, parseSkillMd, scanSkillText, SKILL_FILE_MAX_BYTES, SKILL_NAME_MAX, type ParsedSkill,
-} from "../shared/skill-md.ts";
+export { DESCRIPTION_MAX, isSkillName, parseSkillMd, scanSkillText, SKILL_FILE_MAX_BYTES, SKILL_NAME_MAX, type ParsedSkill } from "../shared/skill-md.ts";
export { STAGED_SKILL_FILE_MAX_BYTES } from "./skill-storage.ts";
export const INDEX_MAX_SKILLS = 30;
@@ -66,7 +63,9 @@ export interface SkillManifestEntry {
appliedStageId?: string;
storageRevision?: string;
package?: SkillPackageStamp;
+ /** This bot's copy of a skill on all of the person's bots (skills-for-all-bots.ts); `adopted`: it had the same one before. */ allBots?: SharedSkillMark;
}
+export interface SharedSkillMark { store: string; sha256: string; adopted?: true }
export interface SkillPackageStamp {
installId: string;
@@ -96,14 +95,9 @@ const skillManifestEntrySchema = z.object({
github: githubSkillOriginSchema.optional(),
appliedStageId: z.string().optional(),
storageRevision: z.string().regex(/^[a-f0-9]{64}$/).optional(),
- package: z.object({
- installId: z.string().regex(/^[a-f0-9]{32}$/),
- key: z.string().min(1).max(64),
- release: z.string().min(1).max(40),
- r: z.string().regex(/^[a-f0-9]{64}$/),
- w: z.string().regex(/^[a-f0-9]{64}$/),
- via: z.literal("preset").optional(),
- }).optional(),
+ package: z.object({ installId: z.string().regex(/^[a-f0-9]{32}$/), key: z.string().min(1).max(64), release: z.string().min(1).max(40),
+ r: z.string().regex(/^[a-f0-9]{64}$/), w: z.string().regex(/^[a-f0-9]{64}$/), via: z.literal("preset").optional() }).optional(),
+ allBots: z.object({ store: z.string().max(64), sha256: z.string().max(200), adopted: z.literal(true).optional() }).optional(),
});
const skillManifestSchema = z.record(z.string(), skillManifestEntrySchema);
@@ -461,6 +455,8 @@ export interface SkillListing {
skippedFiles: string[];
files?: string[];
github?: GitHubSkillOrigin;
+ /** On all of the person's bots: this is the bot's copy, its switch the bot's own. */
+ allBots?: true;
}
function skillContentMatches(botId: string, name: string, entry: SkillManifestEntry): boolean {
@@ -480,11 +476,12 @@ function skillContentMatches(botId: string, name: string, entry: SkillManifestEn
}
function skillListing(botId: string, name: string, entry: SkillManifestEntry): SkillListing {
- const { appliedStageId, storageRevision: _storageRevision, package: _package, ...visible } = entry;
+ const { appliedStageId, storageRevision: _storageRevision, package: _package, allBots: mark, ...visible } = entry;
const intact = skillContentMatches(botId, name, entry);
return {
name,
...visible,
+ ...(mark && sharedSkills?.current(botId, mark) ? { allBots: true as const } : {}),
enabled: entry.enabled && intact,
editable: entry.source.startsWith(LEARN_SOURCE_PREFIX) && Boolean(appliedStageId),
warnings: intact
@@ -493,7 +490,15 @@ function skillListing(botId: string, name: string, entry: SkillManifestEntry): S
};
}
+let sharedSkills: { list(botId: string): void; current(botId: string, mark: SharedSkillMark): boolean } | null = null;
+/** skills-for-all-bots.ts brings a bot's copies of the person's all-bots skills up to date as its skills are listed. */
+export function setSharedSkills(hooks: typeof sharedSkills): void { sharedSkills = hooks; }
+export function setSharedSkillMark(botId: string, name: string, mark: SharedSkillMark | undefined): void {
+ const manifest = readManifest(botId), entry = manifest[name]; if (!entry) return; if (mark) entry.allBots = mark; else delete entry.allBots; writeManifest(botId, manifest);
+}
+
export function listSkills(botId: string): SkillListing[] {
+ sharedSkills?.list(botId);
const manifest = readManifest(botId);
return Object.entries(manifest)
.map(([name, entry]) => skillListing(botId, name, entry))
@@ -1269,8 +1274,8 @@ export function skillsSystemPrompt(botId: string, assignedLibrary?: readonly str
(omitted ? `${entries.length ? "\n" : ""}${notice(omitted, entries.length)}` : "");
for (const skill of enabled.slice(0, INDEX_MAX_SKILLS)) {
const entry = manifest[skill.name];
- const file = entry ? join(skillTarget(root, skill.name, entry), "SKILL.md") : allBotsSkillFile(botId, skill.name) ?? librarySkillFilePath(skill.name);
- const line = `- ${skill.name}: ${entry || "allBots" in skill ? skill.description : describe(skill.name, skill.description)} Read ${JSON.stringify(file)}.`;
+ const file = entry ? join(skillTarget(root, skill.name, entry), "SKILL.md") : librarySkillFilePath(skill.name);
+ const line = `- ${skill.name}: ${entry ? skill.description : describe(skill.name, skill.description)} Read ${JSON.stringify(file)}.`;
if (Buffer.byteLength(block([...lines, line], enabled.length - lines.length - 1), "utf8") > INDEX_MAX_BYTES) break;
lines.push(line);
}
@@ -1295,33 +1300,32 @@ export function enabledSkillFile(botId: string, name: string, assignedLibrary?:
export function enabledSkillFiles(botId: string, names: readonly string[], assignedLibrary?: readonly string[]): Map<string, string> {
if (!names.length) return new Map();
const on = new Set(resolveBotSkills(botId, assignedLibrary).filter((skill) => skill.enabled).map((skill) => skill.name)), manifest = readManifest(botId);
- return new Map(names.filter((name) => on.has(name)).map((name) => [name, manifest[name] ? join(skillTarget(workspaceDir(botId), name, manifest[name]), "SKILL.md") : allBotsSkillFile(botId, name) ?? librarySkillFilePath(name)] as const));
+ return new Map(names.filter((name) => on.has(name)).map((name) => [name, manifest[name] ? join(skillTarget(workspaceDir(botId), name, manifest[name]), "SKILL.md") : librarySkillFilePath(name)] as const));
}
-/** The bot's own skills, then the person's skills for all their bots, then (while the library is on) its library skills:
- * a name shows once, and the earlier kind wins it. */
export function resolveBotSkills(botId: string, assignedLibrary: readonly string[] | undefined): SkillListing[] {
- const own = listSkills(botId), ownNames = new Set(own.map((skill) => skill.name));
- const mine = [...own, ...allBotsSkills(botId).filter((skill) => !ownNames.has(skill.name))];
- if (assignedLibrary === undefined) return mine; // the library is off: no library every-bot skills either
- return [...mine, ...librarySkillsForBot(botId, new Set(assignedLibrary), new Set(mine.map((skill) => skill.name)))];
+ const own = listSkills(botId);
+ if (assignedLibrary === undefined) return own; // the library is off: no every-bot skills either
+ const ownNames = new Set(own.map((skill) => skill.name));
+ return [...own, ...librarySkillsForBot(botId, new Set(assignedLibrary), ownNames)];
}
export interface BotSkillWithOrigin extends SkillListing {
- origin: "private" | "library" | "all-bots";
+ origin: "private" | "library";
}
export function listBotSkillsWithOrigin(
botId: string,
assignedLibrary: readonly string[] | undefined,
): { skills: BotSkillWithOrigin[]; library: LibrarySkillListing[] } {
- const ownNames = new Set(listSkills(botId).map((skill) => skill.name));
+ const own = listSkills(botId);
+ const ownNames = new Set(own.map((skill) => skill.name));
const assigned = new Set(assignedLibrary ?? []);
const skills = resolveBotSkills(botId, assignedLibrary ?? []).map((skill) => ({
...skill,
- origin: ownNames.has(skill.name) ? ("private" as const) : "allBots" in skill ? ("all-bots" as const) : ("library" as const),
+ origin: ownNames.has(skill.name) ? ("private" as const) : ("library" as const),
}));
- const library = librarySkillsToOffer(botId, assigned, new Set(skills.map((skill) => skill.name)));
+ const library = librarySkillsToOffer(botId, assigned, ownNames);
return { skills, library };
}
diff --git a/src/components/SkillsSection.behavior.test.ts b/src/components/SkillsSection.behavior.test.ts
index 170f37f019..d5fd378db5 100644
--- a/src/components/SkillsSection.behavior.test.ts
+++ b/src/components/SkillsSection.behavior.test.ts
@@ -137,7 +137,7 @@ describe("Skills library review and assignment controls", () => {
expect(fixture.request).toHaveBeenCalledWith("/api/bots/bot/skills/pdf", expect.objectContaining({ method: "PATCH", body: '{"enabled":false}' }));
});
it("puts one of the bot's own skills on all bots, and marks one already there with this bot's own switch", async () => {
- const own = { name: "invoice-check", description: "Checks invoices", enabled: true, source: "learned:conversation", warnings: [] };
+ const own = { name: "invoice-check", description: "Checks invoices", enabled: true, source: "learned:conversation", warnings: [], canUseOnAllBots: true };
const shared = { name: "client-onboarding", description: "Onboards clients", enabled: true, source: "learned:conversation", warnings: [], allBots: true };
fixture.values = [[own, shared], [], [], "", [], false, "", "", null, { current: false }, "", null, "", false, ""];
fixture.request.mockImplementation(async (url: string) => (url.endsWith("/all-bots") ? { kept: ["Keeper"] } : { skills: [own, shared] }));
diff --git a/src/components/bot-settings/SkillsSection.tsx b/src/components/bot-settings/SkillsSection.tsx
index 2d1148d029..9483082d37 100644
--- a/src/components/bot-settings/SkillsSection.tsx
+++ b/src/components/bot-settings/SkillsSection.tsx
@@ -26,6 +26,7 @@ export interface ManagedSkill {
origin?: "private" | "library" | "all-bots" | "imported" | "native" | "project";
/** On all of the person's bots, a bot made later too; the switch is this bot's own. */
allBots?: boolean;
+ canUseOnAllBots?: boolean;
/** An imported skill that is on but not in this bot's list: the bot finds it when a task needs it. */
listed?: boolean;
}
@@ -33,9 +34,8 @@ export interface ManagedSkill {
/** On all of the person's bots, with this bot's own switch. */
export const onAllBots = (skill: ManagedSkill): boolean => skill.allBots === true;
-/** One of this bot's own skills, on, that it could put on all of the person's bots. */
-export const canUseOnAllBots = (skill: ManagedSkill): boolean =>
- skill.enabled && !skill.allBots && (skill.origin === undefined || skill.origin === "private");
+/** One of this bot's own skills, on, that this person may put on all of their bots (the server says so per skill). */
+export const canUseOnAllBots = (skill: ManagedSkill): boolean => skill.canUseOnAllBots === true;
/** A skill that lives in a folder of the person's, read only here. */
const inFolder = (skill: ManagedSkill): boolean => skill.origin === "native" || skill.origin === "project";
diff --git a/src/locales/de.json b/src/locales/de.json
index 65c6fd67c1..60c0664039 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -145,7 +145,7 @@
"server.allBotsSkill.delete.title": "Skill „{name}“ von allen deinen Bots entfernen?",
"server.allBotsSkill.delete.done": "Skill „{name}“ von allen deinen Bots entfernt",
"server.allBotsSkill.body": "Alle deine Bots nutzen dieselbe Kopie, auch Bots, die du später hinzufügst. Für einen einzelnen Bot schaltest du ihn auf dessen Skills-Seite aus.",
- "server.allBotsSkill.deleteBody": "Er verschwindet von jedem deiner Bots, der ihn hat. Seine SKILL.md steht unten, Geheimnisse sind ausgeblendet.",
+ "server.allBotsSkill.deleteBody": "Er verschwindet von allen deinen Bots; ein Bot, der ihn vorher schon hatte, behält seine eigene Kopie. Seine SKILL.md steht unten, Geheimnisse sind ausgeblendet.",
"skills.allBots.tag": "Alle Bots",
"skills.allBots.tagHint": "Auf allen deinen Bots, auch auf später hinzugefügten. Der Schalter schaltet ihn nur für diesen Bot aus.",
"skills.allBots.use": "Auf allen Bots nutzen",
diff --git a/src/locales/en.json b/src/locales/en.json
index b2ffa92c9a..70200b56ed 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -284,7 +284,7 @@
"server.allBotsSkill.delete.title": "Remove skill \"{name}\" from all your bots?",
"server.allBotsSkill.delete.done": "Skill \"{name}\" removed from all your bots",
"server.allBotsSkill.body": "Every bot of yours uses the same copy, including bots you add later. Turn it off for one bot on that bot's Skills page.",
- "server.allBotsSkill.deleteBody": "It goes from every bot of yours that has it. Its SKILL.md is shown below, with any secrets hidden.",
+ "server.allBotsSkill.deleteBody": "It goes from every bot of yours; a bot that had it before keeps its own copy. Its SKILL.md is shown below, with any secrets hidden.",
"server.mcp.listed": "Checked MCP servers",
"server.mcp.on": "Turned on",
"server.mcp.switchedOff": "Switched off",
diff --git a/src/locales/es.json b/src/locales/es.json
index 6b69e6c59f..a77646fb72 100644
--- a/src/locales/es.json
+++ b/src/locales/es.json
@@ -6632,5 +6632,20 @@
"skillBurger.pill.running": "Ejecutando… {count}",
"skillBurger.pill.stopped": "Detenido",
"skillBurger.pill.addPath": "Añadir camino",
- "skillBurger.card.madeBy": "Hecho por {name}"
+ "skillBurger.card.madeBy": "Hecho por {name}",
+ "server.allBotsSkill.create.title": "¿Poner la habilidad \"{name}\" en todos tus bots?",
+ "server.allBotsSkill.create.done": "La habilidad \"{name}\" está en todos tus bots",
+ "server.allBotsSkill.update.title": "¿Actualizar la habilidad \"{name}\" en todos tus bots?",
+ "server.allBotsSkill.update.done": "Habilidad \"{name}\" actualizada en todos tus bots",
+ "server.allBotsSkill.delete.title": "¿Quitar la habilidad \"{name}\" de todos tus bots?",
+ "server.allBotsSkill.delete.done": "Habilidad \"{name}\" quitada de todos tus bots",
+ "server.allBotsSkill.body": "Todos tus bots usan la misma copia, también los que añadas más adelante. Para desactivarla en un solo bot, usa la página Habilidades de ese bot.",
+ "server.allBotsSkill.deleteBody": "Se quita de todos tus bots; un bot que ya la tenía antes conserva su propia copia. Su SKILL.md se muestra abajo, con los secretos ocultos.",
+ "skills.allBots.tag": "Todos los bots",
+ "skills.allBots.tagHint": "En todos tus bots, también los que añadas más adelante. El interruptor la desactiva solo para este bot.",
+ "skills.allBots.use": "Usar en todos los bots",
+ "skills.allBots.useName": "Usar {name} en todos tus bots",
+ "skills.allBots.removeConfirm": "¿Quitar “{name}” de todos tus bots?",
+ "skills.allBots.kept": "Estos bots conservan su propia copia, que es distinta: {names}",
+ "skills.allBots.failed": "No se pudo poner esta habilidad en todos tus bots."
}
diff --git a/src/locales/fr.json b/src/locales/fr.json
index 5a15c23316..b2aae51ad1 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -4037,5 +4037,20 @@
"skillBurger.pill.running": "En cours… {count}",
"skillBurger.pill.stopped": "Arrêté",
"skillBurger.pill.addPath": "Ajouter le chemin",
- "skillBurger.card.madeBy": "Créé par {name}"
+ "skillBurger.card.madeBy": "Créé par {name}",
+ "server.allBotsSkill.create.title": "Mettre la compétence « {name} » sur tous vos bots ?",
+ "server.allBotsSkill.create.done": "La compétence « {name} » est sur tous vos bots",
+ "server.allBotsSkill.update.title": "Mettre à jour la compétence « {name} » sur tous vos bots ?",
+ "server.allBotsSkill.update.done": "Compétence « {name} » mise à jour sur tous vos bots",
+ "server.allBotsSkill.delete.title": "Retirer la compétence « {name} » de tous vos bots ?",
+ "server.allBotsSkill.delete.done": "Compétence « {name} » retirée de tous vos bots",
+ "server.allBotsSkill.body": "Tous vos bots utilisent la même copie, y compris ceux que vous ajouterez plus tard. Pour la désactiver sur un seul bot, utilisez la page Compétences de ce bot.",
+ "server.allBotsSkill.deleteBody": "Elle est retirée de tous vos bots ; un bot qui l'avait déjà avant garde sa propre copie. Son SKILL.md est affiché ci-dessous, secrets masqués.",
+ "skills.allBots.tag": "Tous les bots",
+ "skills.allBots.tagHint": "Sur tous vos bots, y compris ceux que vous ajouterez plus tard. L'interrupteur la désactive pour ce bot seulement.",
+ "skills.allBots.use": "Utiliser sur tous les bots",
+ "skills.allBots.useName": "Utiliser {name} sur tous vos bots",
+ "skills.allBots.removeConfirm": "Retirer « {name} » de tous vos bots ?",
+ "skills.allBots.kept": "Ces bots gardent leur propre copie, différente : {names}",
+ "skills.allBots.failed": "Impossible de mettre cette compétence sur tous vos bots."
}
diff --git a/src/locales/hi.json b/src/locales/hi.json
index 044528f21f..8240eddb19 100644
--- a/src/locales/hi.json
+++ b/src/locales/hi.json
@@ -3889,5 +3889,20 @@
"skillBurger.pill.running": "चल रहा है… {count}",
"skillBurger.pill.stopped": "रुका",
"skillBurger.pill.addPath": "रास्ता जोड़ें",
- "skillBurger.card.madeBy": "{name} ने बनाया"
+ "skillBurger.card.madeBy": "{name} ने बनाया",
+ "server.allBotsSkill.create.title": "स्किल \"{name}\" को अपने सभी बॉट्स पर लगाएँ?",
+ "server.allBotsSkill.create.done": "स्किल \"{name}\" आपके सभी बॉट्स पर है",
+ "server.allBotsSkill.update.title": "अपने सभी बॉट्स पर स्किल \"{name}\" अपडेट करें?",
+ "server.allBotsSkill.update.done": "आपके सभी बॉट्स पर स्किल \"{name}\" अपडेट हो गई",
+ "server.allBotsSkill.delete.title": "स्किल \"{name}\" को अपने सभी बॉट्स से हटाएँ?",
+ "server.allBotsSkill.delete.done": "स्किल \"{name}\" आपके सभी बॉट्स से हटा दी गई",
+ "server.allBotsSkill.body": "आपके सभी बॉट्स एक ही कॉपी इस्तेमाल करते हैं, बाद में जोड़े गए बॉट्स भी। किसी एक बॉट के लिए बंद करने हेतु उस बॉट का Skills पेज खोलें।",
+ "server.allBotsSkill.deleteBody": "यह आपके सभी बॉट्स से हट जाती है; जिस बॉट के पास यह पहले से थी, वह अपनी कॉपी रखता है। इसकी SKILL.md नीचे दिखाई गई है, सभी सीक्रेट छिपे हुए हैं।",
+ "skills.allBots.tag": "सभी बॉट्स",
+ "skills.allBots.tagHint": "आपके सभी बॉट्स पर, बाद में जोड़े गए बॉट्स पर भी। स्विच इसे केवल इस बॉट के लिए बंद करता है।",
+ "skills.allBots.use": "सभी बॉट्स पर इस्तेमाल करें",
+ "skills.allBots.useName": "{name} को अपने सभी बॉट्स पर इस्तेमाल करें",
+ "skills.allBots.removeConfirm": "“{name}” को अपने सभी बॉट्स से हटाएँ?",
+ "skills.allBots.kept": "ये बॉट्स अपनी अलग कॉपी रखते हैं: {names}",
+ "skills.allBots.failed": "यह स्किल आपके सभी बॉट्स पर नहीं लगाई जा सकी।"
}
diff --git a/src/locales/it.json b/src/locales/it.json
index 89962d1237..436881a120 100644
--- a/src/locales/it.json
+++ b/src/locales/it.json
@@ -284,7 +284,7 @@
"server.allBotsSkill.delete.title": "Rimuovere l'abilità \"{name}\" da tutti i tuoi bot?",
"server.allBotsSkill.delete.done": "Abilità \"{name}\" rimossa da tutti i tuoi bot",
"server.allBotsSkill.body": "Tutti i tuoi bot usano la stessa copia, anche quelli che aggiungerai dopo. Per spegnerla su un solo bot, usa la pagina Abilità di quel bot.",
- "server.allBotsSkill.deleteBody": "Sparisce da ogni tuo bot che la ha. Il suo SKILL.md è mostrato qui sotto, con tutti i segreti nascosti.",
+ "server.allBotsSkill.deleteBody": "Sparisce da tutti i tuoi bot; un bot che la aveva già prima tiene la sua copia. Il suo SKILL.md è mostrato qui sotto, con tutti i segreti nascosti.",
"skills.allBots.tag": "Tutti i bot",
"skills.allBots.tagHint": "Su tutti i tuoi bot, anche quelli che aggiungerai dopo. L'interruttore la spegne solo per questo bot.",
"skills.allBots.use": "Usa su tutti i bot",
diff --git a/src/locales/ja.json b/src/locales/ja.json
index f080a68f94..b0d0c6d996 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -8166,5 +8166,20 @@
"skillBurger.pill.running": "実行中… {count}",
"skillBurger.pill.stopped": "停止",
"skillBurger.pill.addPath": "手順を追加",
- "skillBurger.card.madeBy": "{name} が作成"
+ "skillBurger.card.madeBy": "{name} が作成",
+ "server.allBotsSkill.create.title": "スキル「{name}」をすべてのボットに追加しますか?",
+ "server.allBotsSkill.create.done": "スキル「{name}」はすべてのボットにあります",
+ "server.allBotsSkill.update.title": "すべてのボットでスキル「{name}」を更新しますか?",
+ "server.allBotsSkill.update.done": "すべてのボットでスキル「{name}」を更新しました",
+ "server.allBotsSkill.delete.title": "スキル「{name}」をすべてのボットから削除しますか?",
+ "server.allBotsSkill.delete.done": "スキル「{name}」をすべてのボットから削除しました",
+ "server.allBotsSkill.body": "すべてのボットが同じコピーを使います。あとから追加するボットも同じです。1つのボットだけでオフにするには、そのボットのスキルページで切り替えてください。",
+ "server.allBotsSkill.deleteBody": "すべてのボットから削除されます。以前から持っていたボットは自分のコピーを残します。SKILL.md を下に表示しています(秘密情報は伏せています)。",
+ "skills.allBots.tag": "すべてのボット",
+ "skills.allBots.tagHint": "すべてのボットにあります(あとから追加するボットにも)。スイッチはこのボットだけでオフにします。",
+ "skills.allBots.use": "すべてのボットで使う",
+ "skills.allBots.useName": "{name} をすべてのボットで使う",
+ "skills.allBots.removeConfirm": "「{name}」をすべてのボットから削除しますか?",
+ "skills.allBots.kept": "これらのボットは独自の別のコピーを残しています:{names}",
+ "skills.allBots.failed": "このスキルをすべてのボットに追加できませんでした。"
}
diff --git a/src/locales/ko.json b/src/locales/ko.json
index 99abf16edf..b22b633e05 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -7856,5 +7856,20 @@
"skillBurger.pill.running": "실행 중… {count}",
"skillBurger.pill.stopped": "멈춤",
"skillBurger.pill.addPath": "경로 추가",
- "skillBurger.card.madeBy": "{name}이(가) 만듦"
+ "skillBurger.card.madeBy": "{name}이(가) 만듦",
+ "server.allBotsSkill.create.title": "스킬 \"{name}\"을(를) 모든 봇에 넣을까요?",
+ "server.allBotsSkill.create.done": "스킬 \"{name}\"이(가) 모든 봇에 있습니다",
+ "server.allBotsSkill.update.title": "모든 봇에서 스킬 \"{name}\"을(를) 업데이트할까요?",
+ "server.allBotsSkill.update.done": "모든 봇에서 스킬 \"{name}\"을(를) 업데이트했습니다",
+ "server.allBotsSkill.delete.title": "모든 봇에서 스킬 \"{name}\"을(를) 제거할까요?",
+ "server.allBotsSkill.delete.done": "모든 봇에서 스킬 \"{name}\"을(를) 제거했습니다",
+ "server.allBotsSkill.body": "모든 봇이 같은 사본을 사용하며, 나중에 추가하는 봇도 마찬가지입니다. 한 봇에서만 끄려면 그 봇의 스킬 페이지에서 끄세요.",
+ "server.allBotsSkill.deleteBody": "모든 봇에서 제거됩니다. 이전부터 이 스킬이 있던 봇은 자신의 사본을 유지합니다. 아래에 SKILL.md가 표시되며 비밀 정보는 가려져 있습니다.",
+ "skills.allBots.tag": "모든 봇",
+ "skills.allBots.tagHint": "모든 봇에 있으며, 나중에 추가하는 봇에도 들어갑니다. 스위치는 이 봇에서만 끕니다.",
+ "skills.allBots.use": "모든 봇에서 사용",
+ "skills.allBots.useName": "{name}을(를) 모든 봇에서 사용",
+ "skills.allBots.removeConfirm": "“{name}”을(를) 모든 봇에서 제거할까요?",
+ "skills.allBots.kept": "이 봇들은 서로 다른 자체 사본을 유지합니다: {names}",
+ "skills.allBots.failed": "이 스킬을 모든 봇에 넣지 못했습니다."
}
diff --git a/src/locales/pl.json b/src/locales/pl.json
index 9773f285bf..1affa974e4 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -7328,5 +7328,20 @@
"skillBurger.pill.running": "Trwa… {count}",
"skillBurger.pill.stopped": "Zatrzymano",
"skillBurger.pill.addPath": "Dodaj ścieżkę",
- "skillBurger.card.madeBy": "Utworzone przez {name}"
+ "skillBurger.card.madeBy": "Utworzone przez {name}",
+ "server.allBotsSkill.create.title": "Dodać umiejętność „{name}” do wszystkich Twoich botów?",
+ "server.allBotsSkill.create.done": "Umiejętność „{name}” jest na wszystkich Twoich botach",
+ "server.allBotsSkill.update.title": "Zaktualizować umiejętność „{name}” na wszystkich Twoich botach?",
+ "server.allBotsSkill.update.done": "Umiejętność „{name}” zaktualizowana na wszystkich Twoich botach",
+ "server.allBotsSkill.delete.title": "Usunąć umiejętność „{name}” ze wszystkich Twoich botów?",
+ "server.allBotsSkill.delete.done": "Umiejętność „{name}” usunięta ze wszystkich Twoich botów",
+ "server.allBotsSkill.body": "Wszystkie Twoje boty używają tej samej kopii, także te dodane później. Aby wyłączyć ją dla jednego bota, użyj strony Umiejętności tego bota.",
+ "server.allBotsSkill.deleteBody": "Znika ze wszystkich Twoich botów; bot, który miał ją wcześniej, zachowuje własną kopię. Jej SKILL.md jest pokazany poniżej, z ukrytymi sekretami.",
+ "skills.allBots.tag": "Wszystkie boty",
+ "skills.allBots.tagHint": "Na wszystkich Twoich botach, także dodanych później. Przełącznik wyłącza ją tylko dla tego bota.",
+ "skills.allBots.use": "Użyj na wszystkich botach",
+ "skills.allBots.useName": "Użyj {name} na wszystkich Twoich botach",
+ "skills.allBots.removeConfirm": "Usunąć „{name}” ze wszystkich Twoich botów?",
+ "skills.allBots.kept": "Te boty zachowują własną, inną kopię: {names}",
+ "skills.allBots.failed": "Nie udało się dodać tej umiejętności do wszystkich Twoich botów."
}
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index e626d09655..d324fb525a 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -265,7 +265,7 @@
"server.allBotsSkill.delete.title": "Remover a habilidade “{name}” de todos os seus bots?",
"server.allBotsSkill.delete.done": "Habilidade “{name}” removida de todos os seus bots",
"server.allBotsSkill.body": "Todos os seus bots usam a mesma cópia, inclusive os que você adicionar depois. Para desligar em um só bot, use a página Habilidades desse bot.",
- "server.allBotsSkill.deleteBody": "Ela sai de todos os seus bots que a têm. O SKILL.md aparece abaixo, com os segredos ocultos.",
+ "server.allBotsSkill.deleteBody": "Ela sai de todos os seus bots; um bot que já a tinha antes fica com a própria cópia. O SKILL.md aparece abaixo, com os segredos ocultos.",
"skills.allBots.tag": "Todos os bots",
"skills.allBots.tagHint": "Em todos os seus bots, inclusive os que você adicionar depois. O botão desliga só para este bot.",
"skills.allBots.use": "Usar em todos os bots",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index 244330dae4..7e9ad59df2 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -7382,5 +7382,20 @@
"skillBurger.pill.running": "Выполняется… {count}",
"skillBurger.pill.stopped": "Остановлено",
"skillBurger.pill.addPath": "Добавить путь",
- "skillBurger.card.madeBy": "Создано: {name}"
+ "skillBurger.card.madeBy": "Создано: {name}",
+ "server.allBotsSkill.create.title": "Добавить навык «{name}» всем вашим ботам?",
+ "server.allBotsSkill.create.done": "Навык «{name}» есть у всех ваших ботов",
+ "server.allBotsSkill.update.title": "Обновить навык «{name}» у всех ваших ботов?",
+ "server.allBotsSkill.update.done": "Навык «{name}» обновлён у всех ваших ботов",
+ "server.allBotsSkill.delete.title": "Удалить навык «{name}» у всех ваших ботов?",
+ "server.allBotsSkill.delete.done": "Навык «{name}» удалён у всех ваших ботов",
+ "server.allBotsSkill.body": "Все ваши боты используют одну и ту же копию, включая тех, кого вы добавите позже. Чтобы выключить его только для одного бота, откройте страницу «Навыки» этого бота.",
+ "server.allBotsSkill.deleteBody": "Он удаляется у всех ваших ботов; бот, у которого он был раньше, сохраняет свою копию. Его SKILL.md показан ниже, секреты скрыты.",
+ "skills.allBots.tag": "Все боты",
+ "skills.allBots.tagHint": "У всех ваших ботов, включая добавленных позже. Переключатель выключает его только для этого бота.",
+ "skills.allBots.use": "Использовать во всех ботах",
+ "skills.allBots.useName": "Использовать {name} во всех ваших ботах",
+ "skills.allBots.removeConfirm": "Удалить «{name}» у всех ваших ботов?",
+ "skills.allBots.kept": "Эти боты сохраняют свою, другую копию: {names}",
+ "skills.allBots.failed": "Не удалось добавить этот навык всем вашим ботам."
}
diff --git a/src/locales/tr.json b/src/locales/tr.json
index 763800365a..e6150b17cb 100644
--- a/src/locales/tr.json
+++ b/src/locales/tr.json
@@ -6127,5 +6127,20 @@
"skillBurger.pill.running": "Çalışıyor… {count}",
"skillBurger.pill.stopped": "Durdu",
"skillBurger.pill.addPath": "Yol ekle",
- "skillBurger.card.madeBy": "{name} tarafından yapıldı"
+ "skillBurger.card.madeBy": "{name} tarafından yapıldı",
+ "server.allBotsSkill.create.title": "\"{name}\" becerisi tüm botlarınıza eklensin mi?",
+ "server.allBotsSkill.create.done": "\"{name}\" becerisi tüm botlarınızda",
+ "server.allBotsSkill.update.title": "\"{name}\" becerisi tüm botlarınızda güncellensin mi?",
+ "server.allBotsSkill.update.done": "\"{name}\" becerisi tüm botlarınızda güncellendi",
+ "server.allBotsSkill.delete.title": "\"{name}\" becerisi tüm botlarınızdan kaldırılsın mı?",
+ "server.allBotsSkill.delete.done": "\"{name}\" becerisi tüm botlarınızdan kaldırıldı",
+ "server.allBotsSkill.body": "Tüm botlarınız aynı kopyayı kullanır, sonradan eklediğiniz botlar da. Yalnızca bir bot için kapatmak isterseniz o botun Beceriler sayfasını kullanın.",
+ "server.allBotsSkill.deleteBody": "Tüm botlarınızdan kaldırılır; daha önce buna sahip olan bir bot kendi kopyasını korur. SKILL.md dosyası aşağıda, gizli bilgiler saklanmış olarak gösterilir.",
+ "skills.allBots.tag": "Tüm botlar",
+ "skills.allBots.tagHint": "Tüm botlarınızda, sonradan eklenenlerde de. Anahtar onu yalnızca bu bot için kapatır.",
+ "skills.allBots.use": "Tüm botlarda kullan",
+ "skills.allBots.useName": "{name} becerisini tüm botlarınızda kullan",
+ "skills.allBots.removeConfirm": "“{name}” tüm botlarınızdan kaldırılsın mı?",
+ "skills.allBots.kept": "Bu botlar kendi farklı kopyalarını korur: {names}",
+ "skills.allBots.failed": "Bu beceri tüm botlarınıza eklenemedi."
}
diff --git a/src/locales/uk.json b/src/locales/uk.json
index fced011fb9..60256b53cb 100644
--- a/src/locales/uk.json
+++ b/src/locales/uk.json
@@ -4309,5 +4309,20 @@
"skillBurger.pill.running": "Виконується… {count}",
"skillBurger.pill.stopped": "Зупинено",
"skillBurger.pill.addPath": "Додати шлях",
- "skillBurger.card.madeBy": "Створено: {name}"
+ "skillBurger.card.madeBy": "Створено: {name}",
+ "server.allBotsSkill.create.title": "Додати навичку «{name}» усім вашим ботам?",
+ "server.allBotsSkill.create.done": "Навичка «{name}» є в усіх ваших ботів",
+ "server.allBotsSkill.update.title": "Оновити навичку «{name}» в усіх ваших ботів?",
+ "server.allBotsSkill.update.done": "Навичку «{name}» оновлено в усіх ваших ботів",
+ "server.allBotsSkill.delete.title": "Видалити навичку «{name}» в усіх ваших ботів?",
+ "server.allBotsSkill.delete.done": "Навичку «{name}» видалено в усіх ваших ботів",
+ "server.allBotsSkill.body": "Усі ваші боти використовують ту саму копію, зокрема ті, яких ви додасте пізніше. Щоб вимкнути її лише для одного бота, відкрийте сторінку «Навички» цього бота.",
+ "server.allBotsSkill.deleteBody": "Її буде видалено в усіх ваших ботів; бот, який мав її раніше, зберігає власну копію. Її SKILL.md показано нижче, секрети приховано.",
+ "skills.allBots.tag": "Усі боти",
+ "skills.allBots.tagHint": "В усіх ваших ботів, зокрема доданих пізніше. Перемикач вимикає її лише для цього бота.",
+ "skills.allBots.use": "Використовувати в усіх ботах",
+ "skills.allBots.useName": "Використовувати {name} в усіх ваших ботах",
+ "skills.allBots.removeConfirm": "Видалити «{name}» в усіх ваших ботів?",
+ "skills.allBots.kept": "Ці боти зберігають власну, іншу копію: {names}",
+ "skills.allBots.failed": "Не вдалося додати цю навичку всім вашим ботам."
}
diff --git a/src/locales/vi.json b/src/locales/vi.json
index 0d7604cf0f..1e0a06f9c0 100644
--- a/src/locales/vi.json
+++ b/src/locales/vi.json
@@ -6127,5 +6127,20 @@
"skillBurger.pill.running": "Đang chạy… {count}",
"skillBurger.pill.stopped": "Đã dừng",
"skillBurger.pill.addPath": "Thêm nhánh",
- "skillBurger.card.madeBy": "Do {name} tạo"
+ "skillBurger.card.madeBy": "Do {name} tạo",
+ "server.allBotsSkill.create.title": "Đưa kỹ năng \"{name}\" vào tất cả bot của bạn?",
+ "server.allBotsSkill.create.done": "Kỹ năng \"{name}\" đã có trên tất cả bot của bạn",
+ "server.allBotsSkill.update.title": "Cập nhật kỹ năng \"{name}\" trên tất cả bot của bạn?",
+ "server.allBotsSkill.update.done": "Đã cập nhật kỹ năng \"{name}\" trên tất cả bot của bạn",
+ "server.allBotsSkill.delete.title": "Gỡ kỹ năng \"{name}\" khỏi tất cả bot của bạn?",
+ "server.allBotsSkill.delete.done": "Đã gỡ kỹ năng \"{name}\" khỏi tất cả bot của bạn",
+ "server.allBotsSkill.body": "Tất cả bot của bạn dùng cùng một bản sao, kể cả bot bạn thêm sau này. Để tắt cho riêng một bot, hãy dùng trang Kỹ năng của bot đó.",
+ "server.allBotsSkill.deleteBody": "Nó bị gỡ khỏi tất cả bot của bạn; bot nào đã có nó từ trước sẽ giữ bản sao riêng. SKILL.md của nó hiển thị bên dưới, các bí mật đã được ẩn.",
+ "skills.allBots.tag": "Tất cả bot",
+ "skills.allBots.tagHint": "Trên tất cả bot của bạn, kể cả bot thêm sau này. Công tắc chỉ tắt nó cho bot này.",
+ "skills.allBots.use": "Dùng trên tất cả bot",
+ "skills.allBots.useName": "Dùng {name} trên tất cả bot của bạn",
+ "skills.allBots.removeConfirm": "Gỡ “{name}” khỏi tất cả bot của bạn?",
+ "skills.allBots.kept": "Những bot này giữ bản sao riêng, khác: {names}",
+ "skills.allBots.failed": "Không thể đưa kỹ năng này vào tất cả bot của bạn."
}
diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.json
index 3fa2031295..52715ebf2e 100644
--- a/src/locales/zh-tw.json
+++ b/src/locales/zh-tw.json
@@ -262,7 +262,7 @@
"server.allBotsSkill.delete.title": "要從你所有的機器人移除技能「{name}」嗎?",
"server.allBotsSkill.delete.done": "已從你所有的機器人移除技能「{name}」",
"server.allBotsSkill.body": "你所有的機器人都使用同一份副本,包括之後新增的機器人。若只想為某個機器人關閉,請到該機器人的技能頁面操作。",
- "server.allBotsSkill.deleteBody": "它會從你所有擁有它的機器人上移除。下方顯示它的 SKILL.md,並已隱藏所有機密資訊。",
+ "server.allBotsSkill.deleteBody": "它會從你所有的機器人上移除;之前就有它的機器人會保留自己的副本。下方顯示它的 SKILL.md,並已隱藏所有機密資訊。",
"skills.allBots.tag": "所有機器人",
"skills.allBots.tagHint": "在你所有的機器人上,包括之後新增的。開關只會為這個機器人關閉它。",
"skills.allBots.use": "用於所有機器人",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index c10198541e..01ed3d7e95 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -42,7 +42,7 @@
"server.allBotsSkill.delete.title": "要从你的所有机器人上移除技能“{name}”吗?",
"server.allBotsSkill.delete.done": "已从你的所有机器人上移除技能“{name}”",
"server.allBotsSkill.body": "你的所有机器人都使用同一份副本,包括以后添加的机器人。要只为某个机器人关闭,请在该机器人的技能页面操作。",
- "server.allBotsSkill.deleteBody": "它会从你所有拥有它的机器人上移除。下面显示它的 SKILL.md,其中的机密已被隐藏。",
+ "server.allBotsSkill.deleteBody": "它会从你的所有机器人上移除;之前就有它的机器人会保留自己的副本。下面显示它的 SKILL.md,其中的机密已被隐藏。",
"skills.allBots.tag": "所有机器人",
"skills.allBots.tagHint": "在你的所有机器人上,包括以后添加的。开关只为这个机器人关闭它。",
"skills.allBots.use": "用于所有机器人",