Files
openchamber/packages/ui/src/lib/messages/inlineMessageLinks.ts
T

30 lines
1.0 KiB
TypeScript
Raw Normal View History

const SKILL_LINK_PREFIX = '#openchamber-skill:';
const AGENT_LINK_PREFIX = '#openchamber-agent:';
export const buildAgentMentionUrl = (name: string): string => {
const encoded = encodeURIComponent(name);
return `https://opencode.ai/docs/agents/#${encoded}`;
};
export const buildSkillHref = (name: string): string => `${SKILL_LINK_PREFIX}${encodeURIComponent(name)}`;
export const buildAgentHref = (name: string): string => `${AGENT_LINK_PREFIX}${encodeURIComponent(name)}`;
export const parseSkillHref = (href: string | null | undefined): string | null => {
if (!href?.startsWith(SKILL_LINK_PREFIX)) return null;
try {
return decodeURIComponent(href.slice(SKILL_LINK_PREFIX.length));
} catch {
return null;
}
};
export const parseAgentHref = (href: string | null | undefined): string | null => {
if (!href?.startsWith(AGENT_LINK_PREFIX)) return null;
try {
return decodeURIComponent(href.slice(AGENT_LINK_PREFIX.length));
} catch {
return null;
}
};