feat: 新增技能编排引擎和工作流构建器组件
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
refactor: 统一Hands系统常量到单个源文件 refactor: 更新Hands中文名称和描述 fix: 修复技能市场在连接状态变化时重新加载 fix: 修复身份变更提案的错误处理逻辑 docs: 更新多个功能文档的验证状态和实现位置 docs: 更新Hands系统文档 test: 添加测试文件验证工作区路径
This commit is contained in:
@@ -62,9 +62,13 @@ export interface ScheduledTask {
|
||||
export interface SkillInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
path: string;
|
||||
source: 'builtin' | 'extra';
|
||||
path?: string;
|
||||
source?: 'builtin' | 'extra';
|
||||
description?: string;
|
||||
version?: string;
|
||||
capabilities?: string[];
|
||||
tags?: string[];
|
||||
mode?: string;
|
||||
triggers?: Array<{ type: string; pattern?: string }>;
|
||||
actions?: Array<{ type: string; params?: Record<string, unknown> }>;
|
||||
enabled?: boolean;
|
||||
@@ -539,6 +543,8 @@ export type {
|
||||
|
||||
// === Client Injection ===
|
||||
|
||||
import type { KernelClient } from '../lib/kernel-client';
|
||||
|
||||
/**
|
||||
* Helper to create a ConfigStoreClient adapter from a GatewayClient.
|
||||
*/
|
||||
@@ -572,11 +578,135 @@ function createConfigClientFromGateway(client: GatewayClient): ConfigStoreClient
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to create a ConfigStoreClient adapter from a KernelClient.
|
||||
*/
|
||||
function createConfigClientFromKernel(client: KernelClient): ConfigStoreClient {
|
||||
return {
|
||||
getWorkspaceInfo: async () => {
|
||||
try {
|
||||
const status = await client.status();
|
||||
return {
|
||||
path: '',
|
||||
resolvedPath: '',
|
||||
exists: status.initialized as boolean,
|
||||
fileCount: 0,
|
||||
totalSize: 0,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
getQuickConfig: async () => ({ quickConfig: {} }),
|
||||
saveQuickConfig: async () => null,
|
||||
listSkills: async () => {
|
||||
try {
|
||||
const result = await client.listSkills();
|
||||
if (result?.skills) {
|
||||
return {
|
||||
skills: result.skills.map((s) => ({
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
description: s.description || '',
|
||||
version: s.version,
|
||||
// Use capabilities directly
|
||||
capabilities: s.capabilities || [],
|
||||
tags: s.tags || [],
|
||||
mode: s.mode,
|
||||
// Map triggers to the expected format
|
||||
triggers: (s.triggers || []).map((t: string) => ({
|
||||
type: 'keyword',
|
||||
pattern: t,
|
||||
})),
|
||||
// Create actions from capabilities for UI display
|
||||
actions: (s.capabilities || []).map((cap: string) => ({
|
||||
type: cap,
|
||||
params: undefined,
|
||||
})),
|
||||
enabled: s.enabled ?? true,
|
||||
category: s.category,
|
||||
})),
|
||||
};
|
||||
}
|
||||
return { skills: [] };
|
||||
} catch {
|
||||
return { skills: [] };
|
||||
}
|
||||
},
|
||||
getSkill: async (id: string) => {
|
||||
return { skill: { id, name: id, description: '' } };
|
||||
},
|
||||
createSkill: async () => {
|
||||
throw new Error('Skill creation not supported in KernelClient');
|
||||
},
|
||||
updateSkill: async () => {
|
||||
throw new Error('Skill update not supported in KernelClient');
|
||||
},
|
||||
deleteSkill: async () => {
|
||||
throw new Error('Skill deletion not supported in KernelClient');
|
||||
},
|
||||
listChannels: async () => ({ channels: [] }),
|
||||
getChannel: async () => null,
|
||||
createChannel: async () => null,
|
||||
updateChannel: async () => null,
|
||||
deleteChannel: async () => {},
|
||||
listScheduledTasks: async () => ({ tasks: [] }),
|
||||
createScheduledTask: async () => {
|
||||
throw new Error('Scheduled tasks not supported in KernelClient');
|
||||
},
|
||||
listModels: async () => {
|
||||
try {
|
||||
const status = await client.status();
|
||||
return {
|
||||
models: status.defaultModel ? [{
|
||||
id: status.defaultModel as string,
|
||||
name: status.defaultModel as string,
|
||||
provider: (status.defaultProvider as string) || 'default',
|
||||
}] : [],
|
||||
};
|
||||
} catch {
|
||||
return { models: [] };
|
||||
}
|
||||
},
|
||||
getFeishuStatus: async () => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client for the config store.
|
||||
* Called by the coordinator during initialization.
|
||||
*/
|
||||
export function setConfigStoreClient(client: unknown): void {
|
||||
const configClient = createConfigClientFromGateway(client as GatewayClient);
|
||||
let configClient: ConfigStoreClient;
|
||||
|
||||
// Check if it's a KernelClient (has listHands method)
|
||||
if (client && typeof client === 'object' && 'listHands' in client) {
|
||||
configClient = createConfigClientFromKernel(client as KernelClient);
|
||||
} else if (client && typeof client === 'object') {
|
||||
// It's GatewayClient
|
||||
configClient = createConfigClientFromGateway(client as GatewayClient);
|
||||
} else {
|
||||
// Fallback stub client
|
||||
configClient = {
|
||||
getWorkspaceInfo: async () => null,
|
||||
getQuickConfig: async () => null,
|
||||
saveQuickConfig: async () => null,
|
||||
listSkills: async () => ({ skills: [] }),
|
||||
getSkill: async () => null,
|
||||
createSkill: async () => null,
|
||||
updateSkill: async () => null,
|
||||
deleteSkill: async () => {},
|
||||
listChannels: async () => ({ channels: [] }),
|
||||
getChannel: async () => null,
|
||||
createChannel: async () => null,
|
||||
updateChannel: async () => null,
|
||||
deleteChannel: async () => {},
|
||||
listScheduledTasks: async () => ({ tasks: [] }),
|
||||
createScheduledTask: async () => { throw new Error('Not implemented'); },
|
||||
listModels: async () => ({ models: [] }),
|
||||
getFeishuStatus: async () => null,
|
||||
};
|
||||
}
|
||||
|
||||
useConfigStore.getState().setConfigStoreClient(configClient);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user