feat(agents): 新增云端智能体入口与草稿编辑
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { LucideIcon } from 'lucide-react';
|
||||
import { Bot, Code2, Paintbrush } from 'lucide-react';
|
||||
import { Bot, Code2, Paintbrush, Sparkles } from 'lucide-react';
|
||||
import type { ModuleAccess, ModuleAccessKey } from '../../shared/module-access';
|
||||
|
||||
export const AI_MODULE_SELECTION_PATH = '/module-select';
|
||||
|
||||
export type AiModuleId = 'programming' | 'painting' | 'robot';
|
||||
export type AiModuleId = 'programming' | 'painting' | 'robot' | 'cloud_agents';
|
||||
|
||||
export type AiModuleDefinition = {
|
||||
id: AiModuleId;
|
||||
@@ -46,12 +46,23 @@ export const aiModules: readonly AiModuleDefinition[] = [
|
||||
Icon: Bot,
|
||||
switcherLabel: 'Robot 机器',
|
||||
},
|
||||
{
|
||||
id: 'cloud_agents',
|
||||
title: 'Makelore Agents',
|
||||
subtitle: 'AI 智能体',
|
||||
description: '配置专属智能体,从定义用途与角色开始',
|
||||
route: '/cloud-agents',
|
||||
enabled: true,
|
||||
Icon: Sparkles,
|
||||
switcherLabel: 'Agents 智能体',
|
||||
},
|
||||
];
|
||||
|
||||
const moduleAccessKeyById: Record<AiModuleId, ModuleAccessKey> = {
|
||||
programming: 'programming',
|
||||
painting: 'design',
|
||||
robot: 'robot',
|
||||
cloud_agents: 'cloud_agents',
|
||||
};
|
||||
|
||||
const PROGRAMMING_ROUTE_PREFIXES = [
|
||||
@@ -95,6 +106,7 @@ export function isProgrammingProviderRoute(pathname: string): boolean {
|
||||
}
|
||||
|
||||
export function getGuardedAiModuleForPath(pathname: string): AiModuleId | null {
|
||||
if (matchesRoute(pathname, '/cloud-agents')) return 'cloud_agents';
|
||||
if (pathname === '/image-canvas'
|
||||
|| pathname.startsWith('/image-canvas/')
|
||||
|| pathname === '/image-prompts'
|
||||
|
||||
16
src/lib/cloud-agents-api.ts
Normal file
16
src/lib/cloud-agents-api.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { hostApiFetch } from './host-api';
|
||||
import { CLOUD_AGENTS_PATH, type CloudAgentDraft, type CloudAgentPage, type CreateCloudAgent, type SaveCloudAgentDraft } from '../../shared/cloud-agents';
|
||||
|
||||
export const cloudAgentsApi = {
|
||||
list: (cursor: string | null = null) => hostApiFetch<CloudAgentPage>(
|
||||
CLOUD_AGENTS_PATH + '/agents' + (cursor ? `?cursor=${encodeURIComponent(cursor)}` : ''),
|
||||
),
|
||||
get: (slug: string) => hostApiFetch<CloudAgentDraft>(`${CLOUD_AGENTS_PATH}/agents/${encodeURIComponent(slug)}`),
|
||||
create: (input: CreateCloudAgent) => hostApiFetch<CloudAgentDraft>(CLOUD_AGENTS_PATH + '/agents', {
|
||||
method: 'POST', body: JSON.stringify(input),
|
||||
}),
|
||||
save: (slug: string, input: SaveCloudAgentDraft) => hostApiFetch<CloudAgentDraft>(
|
||||
`${CLOUD_AGENTS_PATH}/agents/${encodeURIComponent(slug)}/draft`,
|
||||
{ method: 'PATCH', body: JSON.stringify(input) },
|
||||
),
|
||||
};
|
||||
Reference in New Issue
Block a user