Skip to main content
Glama
policy-vector-service.ts2.68 kB
/** * Policy Vector Service * * Handles policy intent-specific Vector DB operations * Extends BaseVectorService for policy intents */ import { VectorDBService } from './vector-db-service'; import { PolicyIntent } from './organizational-types'; import { EmbeddingService } from './embedding-service'; import { BaseVectorService, BaseSearchOptions, BaseSearchResult } from './base-vector-service'; export interface PolicySearchOptions extends BaseSearchOptions {} export interface PolicySearchResult extends BaseSearchResult<PolicyIntent> {} export class PolicyVectorService extends BaseVectorService<PolicyIntent> { constructor(vectorDB?: VectorDBService, embeddingService?: EmbeddingService) { super('policies', vectorDB, embeddingService); } // Implement abstract methods from BaseVectorService protected createSearchText(policyIntent: PolicyIntent): string { const triggerText = policyIntent.triggers.join(' '); return `${policyIntent.description} ${triggerText} ${policyIntent.rationale}`.toLowerCase(); } protected extractId(policyIntent: PolicyIntent): string { return policyIntent.id; } protected createPayload(policyIntent: PolicyIntent): Record<string, any> { return { description: policyIntent.description, triggers: policyIntent.triggers.map(t => t.toLowerCase()), rationale: policyIntent.rationale, createdAt: policyIntent.createdAt, createdBy: policyIntent.createdBy, deployedPolicies: policyIntent.deployedPolicies || [] }; } protected payloadToData(payload: Record<string, any>): PolicyIntent { return { id: '', // Will be set from document ID in base class description: payload.description, triggers: payload.triggers, rationale: payload.rationale, createdAt: payload.createdAt, createdBy: payload.createdBy, deployedPolicies: payload.deployedPolicies || [] }; } // Public API methods - delegate to base class with appropriate names async storePolicyIntent(policyIntent: PolicyIntent): Promise<void> { await this.storeData(policyIntent); } async searchPolicyIntents(query: string, options: PolicySearchOptions = {}): Promise<PolicySearchResult[]> { return await this.searchData(query, options); } async getPolicyIntent(id: string): Promise<PolicyIntent | null> { return await this.getData(id); } async getAllPolicyIntents(): Promise<PolicyIntent[]> { return await this.getAllData(); } async deletePolicyIntent(id: string): Promise<void> { await this.deleteData(id); } async getPolicyIntentsCount(): Promise<number> { return await this.getDataCount(); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vfarcic/dot-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server