import { recomaze_ai_personalization_env } from '../../env'; /** * Agent base URL for the copilot. ``agent_base_url`` already ends with * ``/api/`` (e.g. ``https://agent.recomaze.ai/api/``); a trailing slash is * stripped so appending ``/copilot/...`` never produces a double slash. * Mirrors the path-building convention in ``visibility.routes.ts``. */ const AGENT_BASE: string = ( recomaze_ai_personalization_env?.agent_base_url || '' ).replace(/\/+$/, ''); /** This app is always WordPress; assert it so the copilot uses the WordPress * setup step set even if the stored platform is stale. */ const PLATFORM_QUERY = 'platform=WORDPRESS'; /** Direct agent SSE endpoint for streaming copilot turns. */ export const COPILOT_STREAM_URL = `${AGENT_BASE}/copilot/stream`; /** Direct agent endpoint for loading/saving the persisted conversation thread. */ export const COPILOT_HISTORY_URL = `${AGENT_BASE}/copilot/history`; /** Direct agent endpoint for reading the merchant's quest overview. */ export const COPILOT_QUESTS_URL = `${AGENT_BASE}/copilot/quests?${PLATFORM_QUERY}`; /** Direct agent endpoint for refreshing the merchant's daily quests. */ export const COPILOT_QUESTS_REFRESH_URL = `${AGENT_BASE}/copilot/quests/refresh?${PLATFORM_QUERY}`; /** Direct agent endpoint that publishes a generated article to the store blog. */ export const COPILOT_PUBLISH_ARTICLE_URL = `${AGENT_BASE}/copilot/publish-article`; /** * Builds the direct agent endpoint for dismissing a proactive-nudge quest. * * @param questId - The quest to dismiss. * @return The fully-qualified dismiss URL. */ export function buildCopilotQuestDismissUrl(questId: string): string { return `${AGENT_BASE}/copilot/quests/${encodeURIComponent(questId)}/dismiss?${PLATFORM_QUERY}`; } /** * Builds the agent endpoint for an article's detail (status + title), forced * fresh so a finished article is never reported as still generating. * * @param articleId - The article to read. * @return The fully-qualified article-detail URL. */ export function buildCopilotArticleStatusUrl(articleId: string): string { return `${AGENT_BASE}/visibility/articles/${encodeURIComponent(articleId)}?force=true`; } /** * Builds the agent endpoint for a content-generator job's state. * * @param jobId - The content-generator job to poll. * @return The fully-qualified job-status URL. */ export function buildCopilotContentStatusUrl(jobId: string): string { return `${AGENT_BASE}/content-generator/status?job_id=${encodeURIComponent(jobId)}`; }