Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: opt in to private skill links and preserve category filters (#19534)

Mocha093a76764602
diff --git a/.env.example b/.env.example
index 54b54350f19..8274ca5a0d3 100644
--- a/.env.example
+++ b/.env.example
@@ -533,3 +533,13 @@ OPENAI_API_KEY=sk-xxxxxxxxx
# Verify-im link token TTL in seconds (default 1800 = 30 min)
# LOBE_LINK_TOKEN_TTL_SECONDS=1800
+
+########################################
+######### Skills Installation ##########
+########################################
+
+# Optional public Market origin used only for Skill installation instruction links.
+# Example: https://market.example.com generates https://market.example.com/s/skills/<identifier>.
+# Leave unset to keep official lobehub.com links, even when MARKET_BASE_URL is configured.
+# This does not change the Market API endpoint or authentication.
+# MARKET_SKILL_INSTALL_BASE_URL=https://market.example.com
diff --git a/apps/server/src/routers/lambda/market/skill.test.ts b/apps/server/src/routers/lambda/market/skill.test.ts
index aab91244fd8..597467515a8 100644
--- a/apps/server/src/routers/lambda/market/skill.test.ts
+++ b/apps/server/src/routers/lambda/market/skill.test.ts
@@ -4,12 +4,14 @@ import { TRPCError } from '@trpc/server';
import { beforeEach, describe, expect, it, vi } from 'vitest';
const {
+ mockGetSkillCategories,
mockGetSkillComments,
mockGetSkillDetail,
mockGetSkillDownloadUrl,
mockGetSkillRatingDistribution,
mockSearchSkill,
} = vi.hoisted(() => ({
+ mockGetSkillCategories: vi.fn(),
mockGetSkillComments: vi.fn(),
mockGetSkillDetail: vi.fn(),
mockGetSkillDownloadUrl: vi.fn(),
@@ -34,6 +36,7 @@ vi.mock('@/libs/trpc/lambda/middleware', () => ({
vi.mock('@/server/services/market', () => ({
MarketService: vi.fn(function () {
return {
+ getSkillCategories: mockGetSkillCategories,
getSkillComments: mockGetSkillComments,
getSkillDetail: mockGetSkillDetail,
getSkillDownloadUrl: mockGetSkillDownloadUrl,
@@ -257,3 +260,21 @@ describe('skillRouter.getSkillList error mapping', () => {
expect(error.message).toBe('Failed to fetch skill list');
});
});
+
+describe('skillRouter.getSkillCategories', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it.each([{ locale: 'zh-CN', q: 'meeting' }, undefined])(
+ 'should preserve category query parameters: %j',
+ async (params) => {
+ const categories = [{ category: 'productivity-tasks', count: 2 }];
+ mockGetSkillCategories.mockResolvedValue(categories);
+ const caller = await createCaller();
+
+ expect(await caller.getSkillCategories(params)).toEqual(categories);
+ if (params) expect(mockGetSkillCategories).toHaveBeenCalledWith(params);
+ },
+ );
+});
diff --git a/apps/server/src/routers/lambda/market/skill.ts b/apps/server/src/routers/lambda/market/skill.ts
index 8fd626303f1..837ce3e1203 100644
--- a/apps/server/src/routers/lambda/market/skill.ts
+++ b/apps/server/src/routers/lambda/market/skill.ts
@@ -84,7 +84,7 @@ export const skillRouter = router({
log('getSkillCategories input: %O', input);
try {
- return await ctx.marketService.getSkillCategories();
+ return await ctx.marketService.getSkillCategories(input);
} catch (error) {
log('Error fetching skill categories: %O', error);
throw mapMarketError(error, 'Failed to fetch skill categories');
diff --git a/apps/server/src/services/market/index.test.ts b/apps/server/src/services/market/index.test.ts
index 8273e9f3cac..7cf85e5e19c 100644
--- a/apps/server/src/services/market/index.test.ts
+++ b/apps/server/src/services/market/index.test.ts
@@ -1000,3 +1000,21 @@ describe('MarketService.searchSkill', () => {
);
});
});
+
+describe('MarketService.getSkillCategories', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it.each([{ locale: 'zh-CN', q: 'meeting' }, undefined])(
+ 'should forward category filters to Market: %j',
+ async (params) => {
+ const service = new MarketService();
+ const categories = [{ category: 'productivity-tasks', count: 2 }];
+ vi.mocked(service.market.marketSkills.getCategories).mockResolvedValue(categories);
+
+ expect(await service.getSkillCategories(params)).toEqual(categories);
+ if (params) expect(service.market.marketSkills.getCategories).toHaveBeenCalledWith(params);
+ },
+ );
+});
diff --git a/apps/server/src/services/market/index.ts b/apps/server/src/services/market/index.ts
index e0b598fd19e..3cebf083e01 100644
--- a/apps/server/src/services/market/index.ts
+++ b/apps/server/src/services/market/index.ts
@@ -692,10 +692,10 @@ export class MarketService {
/**
* Get skill categories
*/
- async getSkillCategories() {
- log('getSkillCategories');
+ async getSkillCategories(params?: { locale?: string; q?: string }) {
+ log('getSkillCategories: %O', params);
- return this.market.marketSkills.getCategories();
+ return this.market.marketSkills.getCategories(params);
}
/**
diff --git a/packages/env/src/app.ts b/packages/env/src/app.ts
index 1a1902beae2..c7c98999fe9 100644
--- a/packages/env/src/app.ts
+++ b/packages/env/src/app.ts
@@ -63,6 +63,7 @@ export const getAppConfig = () => {
SSRF_ALLOW_IP_ADDRESS_LIST: z.string().optional(),
MARKET_BASE_URL: z.string().optional(),
+ MARKET_SKILL_INSTALL_BASE_URL: z.string().url().optional(),
/**
* Trusted Client Secret for Market API authentication
* 64-character hex string (32 bytes) shared with Market server
@@ -138,6 +139,7 @@ export const getAppConfig = () => {
SSRF_ALLOW_PRIVATE_IP_ADDRESS: process.env.SSRF_ALLOW_PRIVATE_IP_ADDRESS === '1',
SSRF_ALLOW_IP_ADDRESS_LIST: process.env.SSRF_ALLOW_IP_ADDRESS_LIST,
MARKET_BASE_URL: process.env.MARKET_BASE_URL,
+ MARKET_SKILL_INSTALL_BASE_URL: process.env.MARKET_SKILL_INSTALL_BASE_URL || undefined,
MARKET_TRUSTED_CLIENT_SECRET: process.env.MARKET_TRUSTED_CLIENT_SECRET,
MARKET_TRUSTED_CLIENT_ID: process.env.MARKET_TRUSTED_CLIENT_ID,
diff --git a/src/app/spa-share/[locale]/[[...path]]/route.ts b/src/app/spa-share/[locale]/[[...path]]/route.ts
index 0248a92d318..935e98b5a84 100644
--- a/src/app/spa-share/[locale]/[[...path]]/route.ts
+++ b/src/app/spa-share/[locale]/[[...path]]/route.ts
@@ -31,6 +31,7 @@ async function getTemplate(): Promise<string> {
function buildClientEnv(): SPAClientEnv {
return {
marketBaseUrl: appEnv.MARKET_BASE_URL,
+ marketSkillInstallBaseUrl: appEnv.MARKET_SKILL_INSTALL_BASE_URL,
pyodideIndexUrl: pythonEnv.NEXT_PUBLIC_PYODIDE_INDEX_URL,
pyodidePipIndexUrl: pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL,
s3FilePath: fileEnv.NEXT_PUBLIC_S3_FILE_PATH,
diff --git a/src/app/spa-workbench/[locale]/[[...path]]/route.ts b/src/app/spa-workbench/[locale]/[[...path]]/route.ts
index ce6d2482d3c..9ac26429b65 100644
--- a/src/app/spa-workbench/[locale]/[[...path]]/route.ts
+++ b/src/app/spa-workbench/[locale]/[[...path]]/route.ts
@@ -28,6 +28,7 @@ async function getTemplate(): Promise<string> {
function buildClientEnv(): SPAClientEnv {
return {
marketBaseUrl: appEnv.MARKET_BASE_URL,
+ marketSkillInstallBaseUrl: appEnv.MARKET_SKILL_INSTALL_BASE_URL,
pyodideIndexUrl: pythonEnv.NEXT_PUBLIC_PYODIDE_INDEX_URL,
pyodidePipIndexUrl: pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL,
s3FilePath: fileEnv.NEXT_PUBLIC_S3_FILE_PATH,
diff --git a/src/app/spa/[variants]/[[...path]]/route.ts b/src/app/spa/[variants]/[[...path]]/route.ts
index c46ef44ef28..2729d829053 100644
--- a/src/app/spa/[variants]/[[...path]]/route.ts
+++ b/src/app/spa/[variants]/[[...path]]/route.ts
@@ -44,6 +44,7 @@ async function getTemplate(isMobile: boolean): Promise<string> {
function buildClientEnv(): SPAClientEnv {
return {
marketBaseUrl: appEnv.MARKET_BASE_URL,
+ marketSkillInstallBaseUrl: appEnv.MARKET_SKILL_INSTALL_BASE_URL,
pyodideIndexUrl: pythonEnv.NEXT_PUBLIC_PYODIDE_INDEX_URL,
pyodidePipIndexUrl: pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL,
s3FilePath: fileEnv.NEXT_PUBLIC_S3_FILE_PATH,
diff --git a/src/features/CommunitySkillDetail/Details/Install/Platform.tsx b/src/features/CommunitySkillDetail/Details/Install/Platform.tsx
index 2813c3ad4ca..7a595362ed0 100644
--- a/src/features/CommunitySkillDetail/Details/Install/Platform.tsx
+++ b/src/features/CommunitySkillDetail/Details/Install/Platform.tsx
@@ -15,6 +15,7 @@ import { builtinAgentSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
import { useDetailActionContext } from '../../DetailProvider';
+import { getSkillInstructionsUrl } from './getSkillInstructionsUrl';
import VsCodeIcon from './VsCodeIcon';
const Title = ({ children }: { children?: React.ReactNode }) => (
@@ -189,7 +190,7 @@ const Platform = memo<PlatformProps>(
const command = genInstallCommand(identifier, active);
- const agentPrompt = `Curl https://lobehub.com/skills/${identifier}/skill.md, then follow the instructions to set up LobeHub Skills Marketplace and install the skill. Once installed, read the SKILL.md file in the installed directory and follow its instructions to complete the task.`;
+ const agentPrompt = `Curl ${getSkillInstructionsUrl(identifier || '<skill-identifier>')}, then follow the instructions to set up LobeHub Skills Marketplace and install the skill. Once installed, read the SKILL.md file in the installed directory and follow its instructions to complete the task.`;
const handleUseOnLobeAI = useCallback(() => {
if (!inboxAgentId) return;
diff --git a/src/features/CommunitySkillDetail/Details/Install/getSkillInstructionsUrl.test.ts b/src/features/CommunitySkillDetail/Details/Install/getSkillInstructionsUrl.test.ts
new file mode 100644
index 00000000000..999c5c0a974
--- /dev/null
+++ b/src/features/CommunitySkillDetail/Details/Install/getSkillInstructionsUrl.test.ts
@@ -0,0 +1,52 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { getSkillInstructionsUrl } from './getSkillInstructionsUrl';
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.unstubAllEnvs();
+});
+
+describe('getSkillInstructionsUrl', () => {
+ it('should keep the official instructions URL when no Market is configured', () => {
+ vi.stubGlobal('__SERVER_CONFIG__', undefined);
+ vi.stubEnv('NEXT_PUBLIC_MARKET_BASE_URL', '');
+
+ expect(getSkillInstructionsUrl('meeting-notes')).toBe(
+ 'https://lobehub.com/skills/meeting-notes/skill.md',
+ );
+ });
+
+ it('should keep official links when only the Market API URL is configured', () => {
+ vi.stubGlobal('__SERVER_CONFIG__', { clientEnv: { marketBaseUrl: 'https://api.example.com' } });
+ vi.stubEnv('NEXT_PUBLIC_MARKET_BASE_URL', 'https://build.example.com');
+
+ expect(getSkillInstructionsUrl('meeting-notes')).toBe(
+ 'https://lobehub.com/skills/meeting-notes/skill.md',
+ );
+ });
+
+ it.each(['https://market.example.com', 'https://market.example.com/'])(
+ 'should use the dedicated installation URL configuration: %s',
+ (marketSkillInstallBaseUrl) => {
+ vi.stubGlobal('__SERVER_CONFIG__', {
+ clientEnv: { marketBaseUrl: 'https://api.example.com', marketSkillInstallBaseUrl },
+ });
+ vi.stubEnv('NEXT_PUBLIC_MARKET_BASE_URL', 'https://build.example.com');
+
+ expect(getSkillInstructionsUrl('meeting-notes')).toBe(
+ 'https://market.example.com/s/skills/meeting-notes',
+ );
+ },
+ );
+
+ it('should preserve a configured base path and encode the identifier', () => {
+ vi.stubGlobal('__SERVER_CONFIG__', {
+ clientEnv: { marketSkillInstallBaseUrl: 'https://market.example.com/base/' },
+ });
+
+ expect(getSkillInstructionsUrl('team/meeting notes')).toBe(
+ 'https://market.example.com/base/s/skills/team%2Fmeeting%20notes',
+ );
+ });
+});
diff --git a/src/features/CommunitySkillDetail/Details/Install/getSkillInstructionsUrl.ts b/src/features/CommunitySkillDetail/Details/Install/getSkillInstructionsUrl.ts
new file mode 100644
index 00000000000..8a74efdd9ff
--- /dev/null
+++ b/src/features/CommunitySkillDetail/Details/Install/getSkillInstructionsUrl.ts
@@ -0,0 +1,9 @@
+export const getSkillInstructionsUrl = (identifier: string) => {
+ // Installation links are opt-in and independent of the Market API used by SaaS.
+ const marketBaseUrl = window.__SERVER_CONFIG__?.clientEnv?.marketSkillInstallBaseUrl;
+ const id = encodeURIComponent(identifier);
+
+ return marketBaseUrl
+ ? `${marketBaseUrl.replace(/\/+$/, '')}/s/skills/${id}`
+ : `https://lobehub.com/skills/${id}/skill.md`;
+};
diff --git a/src/types/spaServerConfig.ts b/src/types/spaServerConfig.ts
index 348e08fcf7c..6cf7b62d0fa 100644
--- a/src/types/spaServerConfig.ts
+++ b/src/types/spaServerConfig.ts
@@ -19,6 +19,7 @@ export interface AnalyticsConfig {
export interface SPAClientEnv {
marketBaseUrl?: string;
+ marketSkillInstallBaseUrl?: string;
pyodideIndexUrl?: string;
pyodidePipIndexUrl?: string;
s3FilePath?: string;