refactor: 清理未使用代码并添加未来功能标记
Some checks failed
CI / Rust Check (push) Has been cancelled
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

style: 统一代码格式和注释风格

docs: 更新多个功能文档的完整度和状态

feat(runtime): 添加路径验证工具支持

fix(pipeline): 改进条件判断和变量解析逻辑

test(types): 为ID类型添加全面测试用例

chore: 更新依赖项和Cargo.lock文件

perf(mcp): 优化MCP协议传输和错误处理
This commit is contained in:
iven
2026-03-25 21:55:12 +08:00
parent aa6a9cbd84
commit bf6d81f9c6
109 changed files with 12271 additions and 815 deletions

View File

@@ -753,36 +753,210 @@ export class KernelClient {
});
}
// === Triggers API (stubs for compatibility) ===
// === Triggers API ===
async listTriggers(): Promise<{ triggers?: { id: string; type: string; enabled: boolean }[] }> {
return { triggers: [] };
/**
* List all triggers
* Returns empty array on error for graceful degradation
*/
async listTriggers(): Promise<{
triggers?: Array<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
}>
}> {
try {
const triggers = await invoke<Array<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
}>>('trigger_list');
return { triggers };
} catch (error) {
this.log('error', `[TriggersAPI] listTriggers failed: ${this.formatError(error)}`);
return { triggers: [] };
}
}
async getTrigger(_id: string): Promise<{ id: string; type: string; enabled: boolean } | null> {
return null;
/**
* Get a single trigger by ID
* Returns null on error for graceful degradation
*/
async getTrigger(id: string): Promise<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
} | null> {
try {
return await invoke<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
} | null>('trigger_get', { id });
} catch (error) {
this.log('error', `[TriggersAPI] getTrigger(${id}) failed: ${this.formatError(error)}`);
return null;
}
}
async createTrigger(_trigger: { type: string; name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }): Promise<{ id?: string } | null> {
return null;
/**
* Create a new trigger
* Returns null on error for graceful degradation
*/
async createTrigger(trigger: {
id: string;
name: string;
handId: string;
triggerType: { type: string; cron?: string; pattern?: string; path?: string; secret?: string; events?: string[] };
enabled?: boolean;
description?: string;
tags?: string[];
}): Promise<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
} | null> {
try {
return await invoke<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
}>('trigger_create', { request: trigger });
} catch (error) {
this.log('error', `[TriggersAPI] createTrigger(${trigger.id}) failed: ${this.formatError(error)}`);
return null;
}
}
async updateTrigger(_id: string, _updates: { name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }): Promise<{ id: string }> {
throw new Error('Triggers not implemented');
/**
* Update an existing trigger
* Throws on error as this is a mutation operation that callers need to handle
*/
async updateTrigger(id: string, updates: {
name?: string;
enabled?: boolean;
handId?: string;
triggerType?: { type: string; cron?: string; pattern?: string; path?: string; secret?: string; events?: string[] };
}): Promise<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
}> {
try {
return await invoke<{
id: string;
name: string;
handId: string;
triggerType: string;
enabled: boolean;
createdAt: string;
modifiedAt: string;
description?: string;
tags: string[];
}>('trigger_update', { id, updates });
} catch (error) {
this.log('error', `[TriggersAPI] updateTrigger(${id}) failed: ${this.formatError(error)}`);
throw error;
}
}
async deleteTrigger(_id: string): Promise<{ status: string }> {
throw new Error('Triggers not implemented');
/**
* Delete a trigger
* Throws on error as this is a destructive operation that callers need to handle
*/
async deleteTrigger(id: string): Promise<void> {
try {
await invoke('trigger_delete', { id });
} catch (error) {
this.log('error', `[TriggersAPI] deleteTrigger(${id}) failed: ${this.formatError(error)}`);
throw error;
}
}
// === Approvals API (stubs for compatibility) ===
async listApprovals(_status?: string): Promise<{ approvals?: unknown[] }> {
return { approvals: [] };
/**
* Execute a trigger
* Throws on error as callers need to know if execution failed
*/
async executeTrigger(id: string, input?: Record<string, unknown>): Promise<Record<string, unknown>> {
try {
return await invoke<Record<string, unknown>>('trigger_execute', { id, input: input || {} });
} catch (error) {
this.log('error', `[TriggersAPI] executeTrigger(${id}) failed: ${this.formatError(error)}`);
throw error;
}
}
async respondToApproval(_approvalId: string, _approved: boolean, _reason?: string): Promise<{ status: string }> {
throw new Error('Approvals not implemented');
// === Approvals API ===
async listApprovals(_status?: string): Promise<{
approvals: Array<{
id: string;
handId: string;
status: string;
createdAt: string;
input: Record<string, unknown>;
}>
}> {
try {
const approvals = await invoke<Array<{
id: string;
handId: string;
status: string;
createdAt: string;
input: Record<string, unknown>;
}>>('approval_list');
return { approvals };
} catch (error) {
console.error('[kernel-client] listApprovals error:', error);
return { approvals: [] };
}
}
async respondToApproval(approvalId: string, approved: boolean, reason?: string): Promise<void> {
return invoke('approval_respond', { id: approvalId, approved, reason });
}
/**
@@ -871,6 +1045,16 @@ export class KernelClient {
private log(level: string, message: string): void {
this.onLog?.(level, message);
}
/**
* Format error for consistent logging
*/
private formatError(error: unknown): string {
if (error instanceof Error) {
return error.message;
}
return String(error);
}
}
// === Singleton ===