The longest runbook a skill may save and how much of it load_skill hands back are now set on Settings > General (skill_body_max_chars, skill_body_shown_chars), defaulting to AppData.SkillBodyMaxChars and SkillBodyShownChars. Saving, confirming and proposing a skill check the install's limit; a skill saved before it was lowered can still be toggled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import type { BUN_SQLITE_COBBLE_SKILLS } from "@/db/types/db";
|
|
import type { SkillsOverviewPayload } from "@/src/types";
|
|
import grabSkillLimitsOverview from "../app-settings/grab-skill-limits";
|
|
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, limits] = 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 }),
|
|
grabSkillLimitsOverview(),
|
|
]);
|
|
|
|
return {
|
|
...targets,
|
|
limits,
|
|
skills: (rows.payload || []).map((row) => {
|
|
const { all_bots, ...skill } = parseSkillRow({ row });
|
|
|
|
return { ...skill, access: { all_bots, ...access(skill.id) } };
|
|
}),
|
|
};
|
|
}
|