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:
@@ -65,6 +65,17 @@ export interface Approval {
|
||||
responseReason?: string;
|
||||
}
|
||||
|
||||
// === Trigger Create Options ===
|
||||
|
||||
export interface TriggerCreateOptions {
|
||||
type: string;
|
||||
name?: string;
|
||||
enabled?: boolean;
|
||||
config?: Record<string, unknown>;
|
||||
handName?: string;
|
||||
workflowId?: string;
|
||||
}
|
||||
|
||||
// === Raw API Response Types (for mapping) ===
|
||||
|
||||
interface RawHandRequirement {
|
||||
@@ -129,30 +140,32 @@ interface HandClient {
|
||||
getHand: (name: string) => Promise<Record<string, unknown> | null>;
|
||||
listHandRuns: (name: string, opts?: { limit?: number; offset?: number }) => Promise<{ runs?: RawHandRun[] } | null>;
|
||||
triggerHand: (name: string, params?: Record<string, unknown>) => Promise<{ runId?: string; status?: string } | null>;
|
||||
approveHand: (name: string, runId: string, approved: boolean, reason?: string) => Promise<void>;
|
||||
cancelHand: (name: string, runId: string) => Promise<void>;
|
||||
approveHand: (name: string, runId: string, approved: boolean, reason?: string) => Promise<{ status: string }>;
|
||||
cancelHand: (name: string, runId: string) => Promise<{ status: string }>;
|
||||
listTriggers: () => Promise<{ triggers?: Trigger[] } | null>;
|
||||
getTrigger: (id: string) => Promise<Trigger | null>;
|
||||
createTrigger: (trigger: { type: string; name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }) => Promise<{ id?: string } | null>;
|
||||
updateTrigger: (id: string, updates: { name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }) => Promise<void>;
|
||||
deleteTrigger: (id: string) => Promise<void>;
|
||||
updateTrigger: (id: string, updates: { name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }) => Promise<{ id: string }>;
|
||||
deleteTrigger: (id: string) => Promise<{ status: string }>;
|
||||
listApprovals: (status?: ApprovalStatus) => Promise<{ approvals?: RawApproval[] } | null>;
|
||||
respondToApproval: (approvalId: string, approved: boolean, reason?: string) => Promise<void>;
|
||||
respondToApproval: (approvalId: string, approved: boolean, reason?: string) => Promise<{ status: string }>;
|
||||
}
|
||||
|
||||
interface HandStore {
|
||||
// State
|
||||
// === Store State Slice ===
|
||||
|
||||
export interface HandStateSlice {
|
||||
hands: Hand[];
|
||||
handRuns: Record<string, HandRun[]>;
|
||||
triggers: Trigger[];
|
||||
approvals: Approval[];
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
|
||||
// Client reference (injected via setHandStoreClient)
|
||||
client: HandClient | null;
|
||||
}
|
||||
|
||||
// Actions
|
||||
// === Store Actions Slice ===
|
||||
|
||||
export interface HandActionsSlice {
|
||||
setHandStoreClient: (client: HandClient) => void;
|
||||
loadHands: () => Promise<void>;
|
||||
getHandDetails: (name: string) => Promise<Hand | undefined>;
|
||||
@@ -162,7 +175,7 @@ interface HandStore {
|
||||
cancelHand: (name: string, runId: string) => Promise<void>;
|
||||
loadTriggers: () => Promise<void>;
|
||||
getTrigger: (id: string) => Promise<Trigger | undefined>;
|
||||
createTrigger: (trigger: { type: string; name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }) => Promise<Trigger | undefined>;
|
||||
createTrigger: (trigger: TriggerCreateOptions) => Promise<Trigger | undefined>;
|
||||
updateTrigger: (id: string, updates: { name?: string; enabled?: boolean; config?: Record<string, unknown>; handName?: string; workflowId?: string }) => Promise<Trigger | undefined>;
|
||||
deleteTrigger: (id: string) => Promise<void>;
|
||||
loadApprovals: (status?: ApprovalStatus) => Promise<void>;
|
||||
@@ -170,6 +183,10 @@ interface HandStore {
|
||||
clearError: () => void;
|
||||
}
|
||||
|
||||
// === Combined Store Type ===
|
||||
|
||||
export type HandStore = HandStateSlice & HandActionsSlice;
|
||||
|
||||
export const useHandStore = create<HandStore>((set, get) => ({
|
||||
// Initial State
|
||||
hands: [],
|
||||
@@ -383,7 +400,7 @@ export const useHandStore = create<HandStore>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
createTrigger: async (trigger) => {
|
||||
createTrigger: async (trigger: TriggerCreateOptions) => {
|
||||
const client = get().client;
|
||||
if (!client) return undefined;
|
||||
|
||||
@@ -496,3 +513,14 @@ export function createHandClientFromGateway(client: GatewayClient): HandClient {
|
||||
respondToApproval: (approvalId, approved, reason) => client.respondToApproval(approvalId, approved, reason),
|
||||
};
|
||||
}
|
||||
|
||||
// === Client Injection ===
|
||||
|
||||
/**
|
||||
* Sets the client for the hand store.
|
||||
* Called by the coordinator during initialization.
|
||||
*/
|
||||
export function setHandStoreClient(client: unknown): void {
|
||||
const handClient = createHandClientFromGateway(client as GatewayClient);
|
||||
useHandStore.getState().setHandStoreClient(handClient);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user