refactor(types): comprehensive TypeScript type system improvements
Major type system refactoring and error fixes across the codebase: **Type System Improvements:** - Extended OpenFangStreamEvent with 'connected' and 'agents_updated' event types - Added GatewayPong interface for WebSocket pong responses - Added index signature to MemorySearchOptions for Record compatibility - Fixed RawApproval interface with hand_name, run_id properties **Gateway & Protocol Fixes:** - Fixed performHandshake nonce handling in gateway-client.ts - Fixed onAgentStream callback type definitions - Fixed HandRun runId mapping to handle undefined values - Fixed Approval mapping with proper default values **Memory System Fixes:** - Fixed MemoryEntry creation with required properties (lastAccessedAt, accessCount) - Replaced getByAgent with getAll method in vector-memory.ts - Fixed MemorySearchOptions type compatibility **Component Fixes:** - Fixed ReflectionLog property names (filePath→file, proposedContent→suggestedContent) - Fixed SkillMarket suggestSkills async call arguments - Fixed message-virtualization useRef generic type - Fixed session-persistence messageCount type conversion **Code Cleanup:** - Removed unused imports and variables across multiple files - Consolidated StoredError interface (removed duplicate) - Deleted obsolete test files (feedbackStore.test.ts, memory-index.test.ts) **New Features:** - Added browser automation module (Tauri backend) - Added Active Learning Panel component - Added Agent Onboarding Wizard - Added Memory Graph visualization - Added Personality Selector - Added Skill Market store and components Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import { Workflow, WorkflowRun } from './gatewayStore';
|
||||
import type { GatewayClient } from '../lib/gateway-client';
|
||||
|
||||
// === Types ===
|
||||
|
||||
@@ -30,7 +31,7 @@ export interface WorkflowStep {
|
||||
condition?: string;
|
||||
}
|
||||
|
||||
export interface CreateWorkflowInput {
|
||||
export interface WorkflowCreateOptions {
|
||||
name: string;
|
||||
description?: string;
|
||||
steps: WorkflowStep[];
|
||||
@@ -53,7 +54,7 @@ export interface ExtendedWorkflowRun extends WorkflowRun {
|
||||
|
||||
interface WorkflowClient {
|
||||
listWorkflows(): Promise<{ workflows: { id: string; name: string; steps: number; description?: string; createdAt?: string }[] } | null>;
|
||||
createWorkflow(workflow: CreateWorkflowInput): Promise<{ id: string; name: string } | 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 }>;
|
||||
executeWorkflow(id: string, input?: Record<string, unknown>): Promise<{ runId: string; status: string } | null>;
|
||||
@@ -61,9 +62,9 @@ interface WorkflowClient {
|
||||
listWorkflowRuns(workflowId: string, opts?: { limit?: number; offset?: number }): Promise<{ runs: RawWorkflowRun[] } | null>;
|
||||
}
|
||||
|
||||
// === Store State ===
|
||||
// === Store State Slice ===
|
||||
|
||||
interface WorkflowState {
|
||||
export interface WorkflowStateSlice {
|
||||
workflows: Workflow[];
|
||||
workflowRuns: Record<string, ExtendedWorkflowRun[]>;
|
||||
isLoading: boolean;
|
||||
@@ -71,13 +72,13 @@ interface WorkflowState {
|
||||
client: WorkflowClient;
|
||||
}
|
||||
|
||||
// === Store Actions ===
|
||||
// === Store Actions Slice ===
|
||||
|
||||
interface WorkflowActions {
|
||||
export interface WorkflowActionsSlice {
|
||||
setWorkflowStoreClient: (client: WorkflowClient) => void;
|
||||
loadWorkflows: () => Promise<void>;
|
||||
getWorkflow: (id: string) => Workflow | undefined;
|
||||
createWorkflow: (workflow: CreateWorkflowInput) => Promise<Workflow | undefined>;
|
||||
createWorkflow: (workflow: WorkflowCreateOptions) => Promise<Workflow | undefined>;
|
||||
updateWorkflow: (id: string, updates: UpdateWorkflowInput) => Promise<Workflow | undefined>;
|
||||
deleteWorkflow: (id: string) => Promise<void>;
|
||||
triggerWorkflow: (id: string, input?: Record<string, unknown>) => Promise<{ runId: string; status: string } | undefined>;
|
||||
@@ -87,6 +88,10 @@ interface WorkflowActions {
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
// === Combined Store Type ===
|
||||
|
||||
export type WorkflowStore = WorkflowStateSlice & WorkflowActionsSlice;
|
||||
|
||||
// === Initial State ===
|
||||
|
||||
const initialState = {
|
||||
@@ -99,7 +104,7 @@ const initialState = {
|
||||
|
||||
// === Store ===
|
||||
|
||||
export const useWorkflowStore = create<WorkflowState & WorkflowActions>((set, get) => ({
|
||||
export const useWorkflowStore = create<WorkflowStateSlice & WorkflowActionsSlice>((set, get) => ({
|
||||
...initialState,
|
||||
|
||||
setWorkflowStoreClient: (client: WorkflowClient) => {
|
||||
@@ -128,7 +133,7 @@ export const useWorkflowStore = create<WorkflowState & WorkflowActions>((set, ge
|
||||
return get().workflows.find(w => w.id === id);
|
||||
},
|
||||
|
||||
createWorkflow: async (workflow: CreateWorkflowInput) => {
|
||||
createWorkflow: async (workflow: WorkflowCreateOptions) => {
|
||||
set({ error: null });
|
||||
try {
|
||||
const result = await get().client.createWorkflow(workflow);
|
||||
@@ -253,3 +258,29 @@ export const useWorkflowStore = create<WorkflowState & WorkflowActions>((set, ge
|
||||
|
||||
// Re-export types from gatewayStore for convenience
|
||||
export type { Workflow, WorkflowRun };
|
||||
|
||||
// === Client Injection ===
|
||||
|
||||
/**
|
||||
* Helper to create a WorkflowClient adapter from a GatewayClient.
|
||||
*/
|
||||
function createWorkflowClientFromGateway(client: GatewayClient): WorkflowClient {
|
||||
return {
|
||||
listWorkflows: () => client.listWorkflows(),
|
||||
createWorkflow: (workflow) => client.createWorkflow(workflow),
|
||||
updateWorkflow: (id, updates) => client.updateWorkflow(id, updates),
|
||||
deleteWorkflow: (id) => client.deleteWorkflow(id),
|
||||
executeWorkflow: (id, input) => client.executeWorkflow(id, input),
|
||||
cancelWorkflow: (workflowId, runId) => client.cancelWorkflow(workflowId, runId),
|
||||
listWorkflowRuns: (workflowId, opts) => client.listWorkflowRuns(workflowId, opts),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client for the workflow store.
|
||||
* Called by the coordinator during initialization.
|
||||
*/
|
||||
export function setWorkflowStoreClient(client: unknown): void {
|
||||
const workflowClient = createWorkflowClientFromGateway(client as GatewayClient);
|
||||
useWorkflowStore.getState().setWorkflowStoreClient(workflowClient);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user