Give bots skills: runbooks they load when a job matches
A skill is a runbook: a name, a unique slug, a one-line description of when it applies, and the markdown body. A run only ever sees the slug and description (one load_skill tool carries them), and reads the whole body only when it calls the tool, so a long runbook costs nothing until needed. Skills are the third extension kind beside MCP servers and custom tools, on the same botExtensionsSql path, so per-bot, per-workspace and all-bots grants work the same way, and attachDefaultExtensions hands an every-bot skill to new bots. load_skill is a reserved tool name, so a custom tool cannot shadow it, and a built-in wins a clash. Managed on Settings > Skills; ExtensionRow links each kind to its own page and a skill never reports a failure, since nothing connects or runs.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import BunSQLite from "@moduletrace/bun-sqlite";
|
||||
import type { BUN_SQLITE_COBBLE_SKILLS } from "@/db/types/db";
|
||||
import type { SkillsOverviewPayload } from "@/src/types";
|
||||
import grabCrewRole from "../access/grab-crew-role";
|
||||
import grabExtensionAccess from "./grab-extension-access";
|
||||
import grabExtensionTargets from "./grab-extension-targets";
|
||||
import parseSkillRow from "./parse-skill-row";
|
||||
|
||||
type Params = {
|
||||
user_id: number | string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The Skills settings page: every skill with who gets it, and what it can
|
||||
* be attached to. A skill holds nothing secret, so admins read it too;
|
||||
* only a super admin adds, edits or deletes.
|
||||
*/
|
||||
export default async function grabSkillsOverview({ user_id }: Params): Promise<SkillsOverviewPayload> {
|
||||
const role = await grabCrewRole({ user_id });
|
||||
const [rows, access, targets] = await Promise.all([
|
||||
BunSQLite.sql<BUN_SQLITE_COBBLE_SKILLS>({ sql: `SELECT * FROM skills ORDER BY name COLLATE NOCASE ASC, id ASC` }),
|
||||
grabExtensionAccess({ kind: "skill" }),
|
||||
grabExtensionTargets({ role }),
|
||||
]);
|
||||
|
||||
return {
|
||||
...targets,
|
||||
skills: (rows.payload || []).map((row) => {
|
||||
const { all_bots, ...skill } = parseSkillRow({ row });
|
||||
|
||||
return { ...skill, access: { all_bots, ...access(skill.id) } };
|
||||
}),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user