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.
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import userAuth from "@/src/functions/backend/auth/user-auth";
|
|
import { AdminHomePath } from "@/src/dict/admin-sections-dict";
|
|
import grabUsers from "@/src/functions/backend/db/users/grab-users";
|
|
import sanitizeUserBio from "@/src/functions/backend/db/users/sanitize-user-bio";
|
|
import grabUserPasswordHash from "@/src/functions/backend/auth/grab-user-password-hash";
|
|
import type { PagePropsType } from "@/src/types";
|
|
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
|
import grabStorageQuotaOverview from "@/src/functions/backend/db/app-settings/grab-storage-quota-overview";
|
|
import { grabSystemPromptAppendOverview } from "@/src/functions/backend/db/app-settings/grab-system-prompt-append";
|
|
|
|
type Params = Parameters<BunextPageServerFn<PagePropsType>>[0];
|
|
|
|
/**
|
|
* Shared server props for the `/admin/settings` sub-pages.
|
|
*/
|
|
export default async function grabSettingsServerProps({ req }: Params) {
|
|
const { user } = await userAuth({ req });
|
|
|
|
if (!user?.id) {
|
|
return {
|
|
redirect: {
|
|
destination: "/auth/login",
|
|
},
|
|
};
|
|
}
|
|
|
|
const user_res = await grabUsers({ user_id: user.id });
|
|
|
|
if (!user_res.singleRes) {
|
|
return {
|
|
redirect: {
|
|
destination: AdminHomePath,
|
|
},
|
|
};
|
|
}
|
|
|
|
const has_password = Boolean(
|
|
await grabUserPasswordHash({ user_id: user.id }),
|
|
);
|
|
|
|
return {
|
|
props: {
|
|
person: sanitizeUserBio({ user: user_res.singleRes }),
|
|
has_password,
|
|
storage_quota: await grabStorageQuotaOverview().catch(() => null),
|
|
system_prompt_append: await grabSystemPromptAppendOverview().catch(() => null),
|
|
},
|
|
};
|
|
}
|