@team-semicolon/semo-cli 3.14.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kb.d.ts ADDED
@@ -0,0 +1,134 @@
1
+ /**
2
+ * SEMO KB/Ontology Module
3
+ *
4
+ * Knowledge Base and Ontology management for SEMO bot ecosystem.
5
+ * Uses the team's core PostgreSQL database as Single Source of Truth.
6
+ *
7
+ * v3.15.0: Initial implementation
8
+ * v3.15.1: pgvector embedding integration
9
+ */
10
+ import { Pool } from "pg";
11
+ /**
12
+ * Generate embedding vector for text using OpenAI API
13
+ * Requires OPENAI_API_KEY environment variable
14
+ */
15
+ export declare function generateEmbedding(text: string): Promise<number[] | null>;
16
+ /**
17
+ * Generate embeddings for multiple texts (batched)
18
+ */
19
+ export declare function generateEmbeddings(texts: string[]): Promise<(number[] | null)[]>;
20
+ export interface KBEntry {
21
+ domain: string;
22
+ key: string;
23
+ content: string;
24
+ metadata?: Record<string, unknown>;
25
+ created_by?: string;
26
+ version?: number;
27
+ created_at?: string;
28
+ updated_at?: string;
29
+ }
30
+ export interface BotKBEntry extends KBEntry {
31
+ bot_id: string;
32
+ synced_at?: string;
33
+ }
34
+ export interface OntologyDomain {
35
+ domain: string;
36
+ schema: Record<string, unknown>;
37
+ description: string | null;
38
+ version: number;
39
+ updated_at?: string;
40
+ }
41
+ export interface KBStatusInfo {
42
+ shared: {
43
+ total: number;
44
+ domains: Record<string, number>;
45
+ lastUpdated: string | null;
46
+ };
47
+ bot: {
48
+ total: number;
49
+ domains: Record<string, number>;
50
+ lastUpdated: string | null;
51
+ lastSynced: string | null;
52
+ };
53
+ }
54
+ export interface KBDiffResult {
55
+ added: KBEntry[];
56
+ removed: KBEntry[];
57
+ modified: Array<{
58
+ local: KBEntry;
59
+ remote: KBEntry;
60
+ }>;
61
+ unchanged: number;
62
+ }
63
+ export interface SyncState {
64
+ botId: string;
65
+ lastPull: string | null;
66
+ lastPush: string | null;
67
+ sharedCount: number;
68
+ botCount: number;
69
+ }
70
+ /**
71
+ * Get shared KB entries from semo.knowledge_base
72
+ */
73
+ export declare function kbPull(pool: Pool, botId: string, domain?: string, cwd?: string): Promise<{
74
+ shared: KBEntry[];
75
+ bot: BotKBEntry[];
76
+ }>;
77
+ /**
78
+ * Push local KB entries to database
79
+ */
80
+ export declare function kbPush(pool: Pool, botId: string, entries: KBEntry[], target?: "shared" | "bot", cwd?: string): Promise<{
81
+ upserted: number;
82
+ errors: string[];
83
+ }>;
84
+ /**
85
+ * Get KB status for a bot
86
+ */
87
+ export declare function kbStatus(pool: Pool, botId: string): Promise<KBStatusInfo>;
88
+ /**
89
+ * List KB entries with optional filters
90
+ */
91
+ export declare function kbList(pool: Pool, options: {
92
+ domain?: string;
93
+ botId?: string;
94
+ limit?: number;
95
+ offset?: number;
96
+ }): Promise<{
97
+ shared: KBEntry[];
98
+ bot: BotKBEntry[];
99
+ }>;
100
+ /**
101
+ * Diff local KB files against database
102
+ */
103
+ export declare function kbDiff(pool: Pool, botId: string, cwd: string): Promise<KBDiffResult>;
104
+ /**
105
+ * Search KB — hybrid: vector similarity (if embedding available) + text fallback
106
+ */
107
+ export declare function kbSearch(pool: Pool, query: string, options: {
108
+ domain?: string;
109
+ botId?: string;
110
+ limit?: number;
111
+ mode?: "semantic" | "text" | "hybrid";
112
+ }): Promise<KBEntry[]>;
113
+ /**
114
+ * List all ontology domains
115
+ */
116
+ export declare function ontoList(pool: Pool): Promise<OntologyDomain[]>;
117
+ /**
118
+ * Show ontology detail for a domain
119
+ */
120
+ export declare function ontoShow(pool: Pool, domain: string): Promise<OntologyDomain | null>;
121
+ /**
122
+ * Validate KB entries against ontology schema (basic JSON Schema validation)
123
+ */
124
+ export declare function ontoValidate(pool: Pool, domain: string, entries?: KBEntry[]): Promise<{
125
+ valid: number;
126
+ invalid: Array<{
127
+ key: string;
128
+ errors: string[];
129
+ }>;
130
+ }>;
131
+ /**
132
+ * Write ontology schemas to local cache
133
+ */
134
+ export declare function ontoPullToLocal(pool: Pool, cwd: string): Promise<number>;