feat: complete Phase 1-3 architecture optimization

Phase 1 - Security:
- Add AES-GCM encryption for localStorage fallback
- Enforce WSS protocol for non-localhost WebSocket connections
- Add URL sanitization to prevent XSS in markdown links

Phase 2 - Domain Reorganization:
- Create Intelligence Domain with Valtio store and caching
- Add unified intelligence-client for Rust backend integration
- Migrate from legacy agent-memory, heartbeat, reflection modules

Phase 3 - Core Optimization:
- Add virtual scrolling for ChatArea with react-window
- Implement LRU cache with TTL for intelligence operations
- Add message virtualization utilities

Additional:
- Add OpenFang compatibility test suite
- Update E2E test fixtures
- Add audit logging infrastructure
- Update project documentation and plans

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-21 22:11:50 +08:00
parent 815c56326b
commit ce562e8bfc
36 changed files with 5241 additions and 201 deletions

View File

@@ -47,6 +47,14 @@ export interface WorkflowStep {
condition?: string;
}
export interface WorkflowDetail {
id: string;
name: string;
description?: string;
steps: WorkflowStep[];
createdAt?: string;
}
export interface WorkflowCreateOptions {
name: string;
description?: string;
@@ -70,6 +78,7 @@ export interface ExtendedWorkflowRun extends WorkflowRun {
interface WorkflowClient {
listWorkflows(): Promise<{ workflows: { id: string; name: string; steps: number; description?: string; createdAt?: string }[] } | null>;
getWorkflow(id: string): Promise<WorkflowDetail | null>;
createWorkflow(workflow: WorkflowCreateOptions): Promise<{ id: string; name: string } | null>;
updateWorkflow(id: string, updates: UpdateWorkflowInput): Promise<{ id: string; name: string } | null>;
deleteWorkflow(id: string): Promise<{ status: string }>;
@@ -94,6 +103,7 @@ export interface WorkflowActionsSlice {
setWorkflowStoreClient: (client: WorkflowClient) => void;
loadWorkflows: () => Promise<void>;
getWorkflow: (id: string) => Workflow | undefined;
getWorkflowDetail: (id: string) => Promise<WorkflowDetail | undefined>;
createWorkflow: (workflow: WorkflowCreateOptions) => Promise<Workflow | undefined>;
updateWorkflow: (id: string, updates: UpdateWorkflowInput) => Promise<Workflow | undefined>;
deleteWorkflow: (id: string) => Promise<void>;
@@ -149,6 +159,24 @@ export const useWorkflowStore = create<WorkflowStateSlice & WorkflowActionsSlice
return get().workflows.find(w => w.id === id);
},
getWorkflowDetail: async (id: string) => {
try {
const result = await get().client.getWorkflow(id);
if (!result) return undefined;
return {
id: result.id,
name: result.name,
description: result.description,
steps: Array.isArray(result.steps) ? result.steps : [],
createdAt: result.createdAt,
};
} catch (err: unknown) {
const message = err instanceof Error ? err.message : 'Failed to load workflow details';
set({ error: message });
return undefined;
}
},
createWorkflow: async (workflow: WorkflowCreateOptions) => {
set({ error: null });
try {
@@ -281,6 +309,14 @@ export const useWorkflowStore = create<WorkflowStateSlice & WorkflowActionsSlice
*/
function createWorkflowClientFromGateway(client: GatewayClient): WorkflowClient {
return {
getWorkflow: async (id: string) => {
const result = await client.getWorkflow(id);
if (!result) return null;
return {
...result,
steps: result.steps as WorkflowStep[],
};
},
listWorkflows: () => client.listWorkflows(),
createWorkflow: (workflow) => client.createWorkflow(workflow),
updateWorkflow: (id, updates) => client.updateWorkflow(id, updates),