Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

695 B
Raw Blame
export type PluginTopBarEntryKey = `plugin:${string}:${string}`;

const encodeTopBarEntryKeyPart = (value: string) => encodeURIComponent(value).replace(/\./g, "%2E");

export const getPluginTopBarEntryKey = (pluginName: string, topBarID: string): PluginTopBarEntryKey =>
    `plugin:${encodeTopBarEntryKeyPart(pluginName)}:${encodeTopBarEntryKeyPart(topBarID)}`;

export const getLegacyPluginTopBarEntryKey = (pluginName: string, index: number): PluginTopBarEntryKey =>
    getPluginTopBarEntryKey(pluginName, `legacy-index:${index}`);

export const isPluginTopBarEntryKey = (value: unknown): value is PluginTopBarEntryKey =>
    typeof value === "string" && /^plugin:[^:]+:[^:]+$/.test(value);