File size: 1,376 Bytes
4e7644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { create } from "zustand";

export interface VerifiedEmbedding {
  fingerprint: string;
  dimensions: number;
  latency: number;
  verifiedAt: number;
}

interface EmbeddingVerificationStore {
  verificationByAgent: Record<string, VerifiedEmbedding>;
  setVerification: (agentId: string, verification: VerifiedEmbedding) => void;
  clearVerification: (agentId: string) => void;
}

/**
 * Keep successful embedding checks for the lifetime of the Console session.
 *
 * This state deliberately is not persisted to browser storage: a successful
 * connectivity check is a point-in-time observation and should not survive an
 * application restart. The service fingerprint makes the result valid only
 * for the exact settings that were tested.
 */
export const useEmbeddingVerificationStore = create<EmbeddingVerificationStore>(
  (set) => ({
    verificationByAgent: {},
    setVerification: (agentId, verification) =>
      set((state) => ({
        verificationByAgent: {
          ...state.verificationByAgent,
          [agentId]: verification,
        },
      })),
    clearVerification: (agentId) =>
      set((state) => {
        if (!(agentId in state.verificationByAgent)) return state;
        const verificationByAgent = { ...state.verificationByAgent };
        delete verificationByAgent[agentId];
        return { verificationByAgent };
      }),
  }),
);