Append install-wide instructions to every bot's prompt
Settings > General gains a prompt appendix the super admin sets once: markdown every bot runs with, right after its own core instructions. - The text lives in app_settings (bot_system_prompt_append, read through grabSystemPromptAppend, cached like every app setting), so it changes without a deploy and applies to every bot on the next run. - composeBotPrompt takes an appendix and pushes it as # Install-wide instructions directly after system_prompt, before the workspace block and memory, so the bot's own more specific rules still win. grabBotPrompt feeds it in, so chat replies, tasks, scheduled runs and the coordinator all get it with no call site touched. - api/admin/settings/system-prompt-append saves it (super admin only, capped at AppData.PromptMaxLength, empty clears it) and is audit logged under system. - The section and its form are hidden from everyone but the super admin, save in place with a character count and no reload, and say what an empty text does.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { BotSystemPromptAppendSettingKey } from "@/src/dict/bot-dict";
|
||||
import grabAppSetting from "./grab-app-setting";
|
||||
|
||||
/**
|
||||
* The install-wide text appended to every bot's prompt, right after its own
|
||||
* core instructions (`bot_system_prompt_append`, from Settings > General).
|
||||
* Empty when the install never set one.
|
||||
*/
|
||||
export default async function grabSystemPromptAppend() {
|
||||
const saved = await grabAppSetting({ key: BotSystemPromptAppendSettingKey });
|
||||
|
||||
return saved?.trim() || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* The same text with its setting key, for the settings page.
|
||||
*/
|
||||
export async function grabSystemPromptAppendOverview() {
|
||||
return {
|
||||
setting_key: BotSystemPromptAppendSettingKey,
|
||||
text: await grabSystemPromptAppend(),
|
||||
};
|
||||
}
|
||||
|
||||
export type SystemPromptAppendOverview = Awaited<
|
||||
ReturnType<typeof grabSystemPromptAppendOverview>
|
||||
>;
|
||||
Reference in New Issue
Block a user