@kybernesis/brain-contracts 0.1.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.
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ export declare const TierSchema: z.ZodEnum<["hot", "warm", "archive"]>;
3
+ export type Tier = z.infer<typeof TierSchema>;
4
+ export declare const EventTypeSchema: z.ZodEnum<["conversation", "idea", "file", "transcript", "note", "intake"]>;
5
+ export type EventType = z.infer<typeof EventTypeSchema>;
6
+ export declare const FactCategorySchema: z.ZodEnum<["biographical", "preference", "event", "relationship", "temporal", "opinion", "plan", "general"]>;
7
+ export type FactCategory = z.infer<typeof FactCategorySchema>;
8
+ export declare const EntityTypeSchema: z.ZodEnum<["person", "company", "project", "place", "topic"]>;
9
+ export type EntityType = z.infer<typeof EntityTypeSchema>;
10
+ export declare const RelationshipTypeSchema: z.ZodEnum<["co-occurred", "founded", "works_at", "invested_in", "met_with", "created", "manages", "partners_with", "located_in", "discussed", "related_to", "reports_to", "uses", "depends_on", "part_of"]>;
11
+ export type RelationshipType = z.infer<typeof RelationshipTypeSchema>;
12
+ export declare const DIRECTIONAL_RELATIONSHIPS: ReadonlySet<RelationshipType>;
13
+ export declare const MemoryEdgeRelationSchema: z.ZodEnum<["related", "continuation", "referenced", "same_topic", "same_person"]>;
14
+ export type MemoryEdgeRelation = z.infer<typeof MemoryEdgeRelationSchema>;
15
+ export declare const MemoryEdgeMethodSchema: z.ZodEnum<["sleep-agent", "manual", "co-occurred", "ai-suggested"]>;
16
+ export type MemoryEdgeMethod = z.infer<typeof MemoryEdgeMethodSchema>;
17
+ export declare const InsightTypeSchema: z.ZodEnum<["inference", "pattern", "quality", "synthesis"]>;
18
+ export type InsightType = z.infer<typeof InsightTypeSchema>;
19
+ export declare const SleepStatusSchema: z.ZodEnum<["running", "completed", "failed", "paused"]>;
20
+ export type SleepStatus = z.infer<typeof SleepStatusSchema>;
21
+ export declare const SOURCE_CONFIDENCE: {
22
+ readonly 'user-correction': 1;
23
+ readonly 'user-direct': 0.95;
24
+ readonly chat: 0.85;
25
+ readonly heartbeat: 0.8;
26
+ readonly 'ai-extraction': 0.6;
27
+ };
28
+ export type SourceConfidenceKey = keyof typeof SOURCE_CONFIDENCE;
29
+ export declare const CHANNEL_SOURCE_TYPE: Record<string, SourceConfidenceKey>;
30
+ export declare function channelToSourceType(channel: string): SourceConfidenceKey;
31
+ export declare const EMBEDDING_MODEL = "text-embedding-3-small";
32
+ export declare const EMBEDDING_DIM = 1536;
33
+ export declare const EMBEDDING_INPUT_CAP = 8192;
34
+ export declare const RRF_K = 60;
35
+ export declare const MAX_SEGMENTS_PER_PARENT = 3;
36
+ export declare const CLAUDE_MODEL_ALIASES: {
37
+ readonly haiku: "claude-haiku-4-5-20251001";
38
+ readonly sonnet: "claude-sonnet-4-6";
39
+ readonly opus: "claude-opus-4-7";
40
+ };
41
+ export type ClaudeModelAlias = keyof typeof CLAUDE_MODEL_ALIASES;
42
+ export declare const HOP_PENALTY: Record<number, number>;
43
+ export declare const DEFAULT_SLEEP_CONFIG: {
44
+ readonly intervalMinutes: 60;
45
+ readonly initialDelayMinutes: 5;
46
+ readonly batchSize: 50;
47
+ readonly maxTagsPerRun: 5;
48
+ readonly maxLinksPerRun: 100;
49
+ readonly maxSummariesPerRun: 5;
50
+ readonly maxFactsPerRun: 5;
51
+ readonly maxContradictionChecksPerRun: 5;
52
+ readonly maxMergesPerRun: 10;
53
+ readonly maxReasoningPerRun: 5;
54
+ readonly maxDecay: 1;
55
+ readonly decayRatePerHour: 0.002;
56
+ readonly minConfidenceForLink: 0.15;
57
+ readonly maxEdgesPerMemory: 5;
58
+ readonly hotPriorityThreshold: 0.65;
59
+ readonly warmPriorityThreshold: 0.3;
60
+ readonly hotDecayThreshold: 0.25;
61
+ readonly hotAccessDays: 3;
62
+ readonly warmAccessDays: 21;
63
+ readonly hotEdgeCount: 6;
64
+ readonly warmEdgeCount: 3;
65
+ readonly tagStaleDays: 7;
66
+ readonly hotWarmSummarySentences: 5;
67
+ readonly archiveSummarySentences: 3;
68
+ readonly hygieneConfidenceThreshold: 0.8;
69
+ readonly pruneMinAgeDays: 30;
70
+ readonly profileRefreshMinutes: 60;
71
+ readonly repetitiveDecayMultiplier: 3;
72
+ readonly consolidationTitleThreshold: 3;
73
+ };
74
+ export type SleepConfig = typeof DEFAULT_SLEEP_CONFIG;
75
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU,uCAAqC,CAAC;AAC7D,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,eAAe,6EAO1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB,8GAS7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,gBAAgB,+DAM3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,sBAAsB,6MAgBjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAGtE,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,gBAAgB,CAOlE,CAAC;AAEH,eAAO,MAAM,wBAAwB,mFAMnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,sBAAsB,qEAKjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,iBAAiB,6DAK5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,iBAAiB,yDAK5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAG5D,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAGjE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAMnE,CAAC;AACF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAExE;AAGD,eAAO,MAAM,eAAe,2BAA2B,CAAC;AACxD,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAGxC,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAGzC,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAGjE,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAsC,CAAC;AAGtF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BvB,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,OAAO,oBAAoB,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { z } from 'zod';
2
+ export const TierSchema = z.enum(['hot', 'warm', 'archive']);
3
+ export const EventTypeSchema = z.enum([
4
+ 'conversation',
5
+ 'idea',
6
+ 'file',
7
+ 'transcript',
8
+ 'note',
9
+ 'intake',
10
+ ]);
11
+ export const FactCategorySchema = z.enum([
12
+ 'biographical',
13
+ 'preference',
14
+ 'event',
15
+ 'relationship',
16
+ 'temporal',
17
+ 'opinion',
18
+ 'plan',
19
+ 'general',
20
+ ]);
21
+ export const EntityTypeSchema = z.enum([
22
+ 'person',
23
+ 'company',
24
+ 'project',
25
+ 'place',
26
+ 'topic',
27
+ ]);
28
+ export const RelationshipTypeSchema = z.enum([
29
+ 'co-occurred',
30
+ 'founded',
31
+ 'works_at',
32
+ 'invested_in',
33
+ 'met_with',
34
+ 'created',
35
+ 'manages',
36
+ 'partners_with',
37
+ 'located_in',
38
+ 'discussed',
39
+ 'related_to',
40
+ 'reports_to',
41
+ 'uses',
42
+ 'depends_on',
43
+ 'part_of',
44
+ ]);
45
+ // Relationships where source/target order is meaningful (asymmetric).
46
+ export const DIRECTIONAL_RELATIONSHIPS = new Set([
47
+ 'founded',
48
+ 'works_at',
49
+ 'invested_in',
50
+ 'created',
51
+ 'manages',
52
+ 'located_in',
53
+ ]);
54
+ export const MemoryEdgeRelationSchema = z.enum([
55
+ 'related',
56
+ 'continuation',
57
+ 'referenced',
58
+ 'same_topic',
59
+ 'same_person',
60
+ ]);
61
+ export const MemoryEdgeMethodSchema = z.enum([
62
+ 'sleep-agent',
63
+ 'manual',
64
+ 'co-occurred',
65
+ 'ai-suggested',
66
+ ]);
67
+ export const InsightTypeSchema = z.enum([
68
+ 'inference',
69
+ 'pattern',
70
+ 'quality',
71
+ 'synthesis',
72
+ ]);
73
+ export const SleepStatusSchema = z.enum([
74
+ 'running',
75
+ 'completed',
76
+ 'failed',
77
+ 'paused',
78
+ ]);
79
+ // Source confidence values — never change without an ADR.
80
+ export const SOURCE_CONFIDENCE = {
81
+ 'user-correction': 1.0,
82
+ 'user-direct': 0.95,
83
+ chat: 0.85,
84
+ heartbeat: 0.80,
85
+ 'ai-extraction': 0.60,
86
+ };
87
+ // Channel → sourceType mapping (matches KAD store-conversation.ts).
88
+ export const CHANNEL_SOURCE_TYPE = {
89
+ terminal: 'user-direct',
90
+ heartbeat: 'heartbeat',
91
+ telegram: 'chat',
92
+ whatsapp: 'chat',
93
+ web: 'chat',
94
+ };
95
+ export function channelToSourceType(channel) {
96
+ return CHANNEL_SOURCE_TYPE[channel] ?? 'chat';
97
+ }
98
+ // Embedding constants.
99
+ export const EMBEDDING_MODEL = 'text-embedding-3-small';
100
+ export const EMBEDDING_DIM = 1536;
101
+ export const EMBEDDING_INPUT_CAP = 8192;
102
+ // Hybrid search constants.
103
+ export const RRF_K = 60;
104
+ export const MAX_SEGMENTS_PER_PARENT = 3;
105
+ // Claude model aliases.
106
+ export const CLAUDE_MODEL_ALIASES = {
107
+ haiku: 'claude-haiku-4-5-20251001',
108
+ sonnet: 'claude-sonnet-4-6',
109
+ opus: 'claude-opus-4-7',
110
+ };
111
+ // Fact-retrieval hop-distance score penalty.
112
+ export const HOP_PENALTY = { 0: 1.0, 1: 0.7, 2: 0.5, 3: 0.3 };
113
+ // Default sleep config (matches KAD sleep/config.ts:61-119).
114
+ export const DEFAULT_SLEEP_CONFIG = {
115
+ intervalMinutes: 60,
116
+ initialDelayMinutes: 5,
117
+ batchSize: 50,
118
+ maxTagsPerRun: 5,
119
+ maxLinksPerRun: 100,
120
+ maxSummariesPerRun: 5,
121
+ maxFactsPerRun: 5,
122
+ maxContradictionChecksPerRun: 5,
123
+ maxMergesPerRun: 10,
124
+ maxReasoningPerRun: 5,
125
+ maxDecay: 1.0,
126
+ decayRatePerHour: 0.002,
127
+ minConfidenceForLink: 0.15,
128
+ maxEdgesPerMemory: 5,
129
+ hotPriorityThreshold: 0.65,
130
+ warmPriorityThreshold: 0.3,
131
+ hotDecayThreshold: 0.25,
132
+ hotAccessDays: 3,
133
+ warmAccessDays: 21,
134
+ hotEdgeCount: 6,
135
+ warmEdgeCount: 3,
136
+ tagStaleDays: 7,
137
+ hotWarmSummarySentences: 5,
138
+ archiveSummarySentences: 3,
139
+ hygieneConfidenceThreshold: 0.8,
140
+ pruneMinAgeDays: 30,
141
+ profileRefreshMinutes: 60,
142
+ repetitiveDecayMultiplier: 3.0,
143
+ consolidationTitleThreshold: 3,
144
+ };
145
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAG7D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,cAAc;IACd,MAAM;IACN,MAAM;IACN,YAAY;IACZ,MAAM;IACN,QAAQ;CACT,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC;IACvC,cAAc;IACd,YAAY;IACZ,OAAO;IACP,cAAc;IACd,UAAU;IACV,SAAS;IACT,MAAM;IACN,SAAS;CACV,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC;IACrC,QAAQ;IACR,SAAS;IACT,SAAS;IACT,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3C,aAAa;IACb,SAAS;IACT,UAAU;IACV,aAAa;IACb,UAAU;IACV,SAAS;IACT,SAAS;IACT,eAAe;IACf,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,YAAY;IACZ,SAAS;CACV,CAAC,CAAC;AAGH,sEAAsE;AACtE,MAAM,CAAC,MAAM,yBAAyB,GAAkC,IAAI,GAAG,CAAC;IAC9E,SAAS;IACT,UAAU;IACV,aAAa;IACb,SAAS;IACT,SAAS;IACT,YAAY;CAC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z.ZodObject<{
3
+ id: z.ZodNumber;
4
+ name: z.ZodString;
5
+ normalizedName: z.ZodString;
6
+ aliases: z.ZodArray<z.ZodString, "many">;
7
+ type: z.ZodEnum<["person", "company", "project", "place", "topic"]>;
8
+ firstSeen: z.ZodString;
9
+ lastSeen: z.ZodString;
10
+ mentionCount: z.ZodNumber;
11
+ priority: z.ZodNumber;
12
+ decayScore: z.ZodNumber;
13
+ tier: z.ZodEnum<["hot", "warm", "archive"]>;
14
+ lastAccessed: z.ZodOptional<z.ZodString>;
15
+ accessCount: z.ZodNumber;
16
+ isPinned: z.ZodBoolean;
17
+ lastReasonedAt: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ type: "person" | "company" | "project" | "place" | "topic";
20
+ id: number;
21
+ name: string;
22
+ normalizedName: string;
23
+ aliases: string[];
24
+ firstSeen: string;
25
+ lastSeen: string;
26
+ mentionCount: number;
27
+ priority: number;
28
+ decayScore: number;
29
+ tier: "hot" | "warm" | "archive";
30
+ accessCount: number;
31
+ isPinned: boolean;
32
+ lastAccessed?: string | undefined;
33
+ lastReasonedAt?: string | undefined;
34
+ }, {
35
+ type: "person" | "company" | "project" | "place" | "topic";
36
+ id: number;
37
+ name: string;
38
+ normalizedName: string;
39
+ aliases: string[];
40
+ firstSeen: string;
41
+ lastSeen: string;
42
+ mentionCount: number;
43
+ priority: number;
44
+ decayScore: number;
45
+ tier: "hot" | "warm" | "archive";
46
+ accessCount: number;
47
+ isPinned: boolean;
48
+ lastAccessed?: string | undefined;
49
+ lastReasonedAt?: string | undefined;
50
+ }>;
51
+ export type Entity = z.infer<typeof EntitySchema>;
52
+ export declare const EntityMentionSchema: z.ZodObject<{
53
+ id: z.ZodNumber;
54
+ entityId: z.ZodNumber;
55
+ conversationId: z.ZodString;
56
+ sourcePath: z.ZodString;
57
+ context: z.ZodOptional<z.ZodString>;
58
+ timestamp: z.ZodString;
59
+ sourceType: z.ZodString;
60
+ confidence: z.ZodNumber;
61
+ }, "strip", z.ZodTypeAny, {
62
+ id: number;
63
+ entityId: number;
64
+ conversationId: string;
65
+ sourcePath: string;
66
+ timestamp: string;
67
+ sourceType: string;
68
+ confidence: number;
69
+ context?: string | undefined;
70
+ }, {
71
+ id: number;
72
+ entityId: number;
73
+ conversationId: string;
74
+ sourcePath: string;
75
+ timestamp: string;
76
+ sourceType: string;
77
+ confidence: number;
78
+ context?: string | undefined;
79
+ }>;
80
+ export type EntityMention = z.infer<typeof EntityMentionSchema>;
81
+ export declare const EntityRelationSchema: z.ZodObject<{
82
+ sourceId: z.ZodNumber;
83
+ targetId: z.ZodNumber;
84
+ relationship: z.ZodEnum<["co-occurred", "founded", "works_at", "invested_in", "met_with", "created", "manages", "partners_with", "located_in", "discussed", "related_to", "reports_to", "uses", "depends_on", "part_of"]>;
85
+ strength: z.ZodNumber;
86
+ confidence: z.ZodNumber;
87
+ method: z.ZodString;
88
+ rationale: z.ZodOptional<z.ZodString>;
89
+ lastVerified: z.ZodOptional<z.ZodString>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ relationship: "co-occurred" | "founded" | "works_at" | "invested_in" | "met_with" | "created" | "manages" | "partners_with" | "located_in" | "discussed" | "related_to" | "reports_to" | "uses" | "depends_on" | "part_of";
92
+ confidence: number;
93
+ sourceId: number;
94
+ targetId: number;
95
+ strength: number;
96
+ method: string;
97
+ rationale?: string | undefined;
98
+ lastVerified?: string | undefined;
99
+ }, {
100
+ relationship: "co-occurred" | "founded" | "works_at" | "invested_in" | "met_with" | "created" | "manages" | "partners_with" | "located_in" | "discussed" | "related_to" | "reports_to" | "uses" | "depends_on" | "part_of";
101
+ confidence: number;
102
+ sourceId: number;
103
+ targetId: number;
104
+ strength: number;
105
+ method: string;
106
+ rationale?: string | undefined;
107
+ lastVerified?: string | undefined;
108
+ }>;
109
+ export type EntityRelation = z.infer<typeof EntityRelationSchema>;
110
+ export declare const EntityMergeSchema: z.ZodObject<{
111
+ id: z.ZodNumber;
112
+ keepId: z.ZodNumber;
113
+ removeId: z.ZodNumber;
114
+ keepName: z.ZodOptional<z.ZodString>;
115
+ removeName: z.ZodOptional<z.ZodString>;
116
+ keepType: z.ZodOptional<z.ZodString>;
117
+ removeType: z.ZodOptional<z.ZodString>;
118
+ reason: z.ZodString;
119
+ confidence: z.ZodOptional<z.ZodNumber>;
120
+ aiRationale: z.ZodOptional<z.ZodString>;
121
+ mentionsMoved: z.ZodNumber;
122
+ relationsMoved: z.ZodNumber;
123
+ mergedAt: z.ZodString;
124
+ mergedBy: z.ZodString;
125
+ }, "strip", z.ZodTypeAny, {
126
+ id: number;
127
+ keepId: number;
128
+ removeId: number;
129
+ reason: string;
130
+ mentionsMoved: number;
131
+ relationsMoved: number;
132
+ mergedAt: string;
133
+ mergedBy: string;
134
+ confidence?: number | undefined;
135
+ keepName?: string | undefined;
136
+ removeName?: string | undefined;
137
+ keepType?: string | undefined;
138
+ removeType?: string | undefined;
139
+ aiRationale?: string | undefined;
140
+ }, {
141
+ id: number;
142
+ keepId: number;
143
+ removeId: number;
144
+ reason: string;
145
+ mentionsMoved: number;
146
+ relationsMoved: number;
147
+ mergedAt: string;
148
+ mergedBy: string;
149
+ confidence?: number | undefined;
150
+ keepName?: string | undefined;
151
+ removeName?: string | undefined;
152
+ keepType?: string | undefined;
153
+ removeType?: string | undefined;
154
+ aiRationale?: string | undefined;
155
+ }>;
156
+ export type EntityMerge = z.infer<typeof EntityMergeSchema>;
157
+ export declare const EntityProfileSchema: z.ZodObject<{
158
+ entityId: z.ZodNumber;
159
+ profile: z.ZodString;
160
+ generatedAt: z.ZodString;
161
+ factCount: z.ZodNumber;
162
+ }, "strip", z.ZodTypeAny, {
163
+ entityId: number;
164
+ profile: string;
165
+ generatedAt: string;
166
+ factCount: number;
167
+ }, {
168
+ entityId: number;
169
+ profile: string;
170
+ generatedAt: string;
171
+ factCount: number;
172
+ }>;
173
+ export type EntityProfile = z.infer<typeof EntityProfileSchema>;
174
+ export declare const ContradictionStatusSchema: z.ZodEnum<["open", "resolved"]>;
175
+ export type ContradictionStatus = z.infer<typeof ContradictionStatusSchema>;
176
+ export declare const ContradictionSchema: z.ZodObject<{
177
+ id: z.ZodNumber;
178
+ entityId: z.ZodOptional<z.ZodNumber>;
179
+ factAId: z.ZodOptional<z.ZodNumber>;
180
+ factBId: z.ZodOptional<z.ZodNumber>;
181
+ factA: z.ZodOptional<z.ZodString>;
182
+ factB: z.ZodOptional<z.ZodString>;
183
+ description: z.ZodOptional<z.ZodString>;
184
+ status: z.ZodEnum<["open", "resolved"]>;
185
+ resolvedBy: z.ZodOptional<z.ZodString>;
186
+ createdAt: z.ZodString;
187
+ }, "strip", z.ZodTypeAny, {
188
+ status: "open" | "resolved";
189
+ id: number;
190
+ createdAt: string;
191
+ entityId?: number | undefined;
192
+ factAId?: number | undefined;
193
+ factBId?: number | undefined;
194
+ factA?: string | undefined;
195
+ factB?: string | undefined;
196
+ description?: string | undefined;
197
+ resolvedBy?: string | undefined;
198
+ }, {
199
+ status: "open" | "resolved";
200
+ id: number;
201
+ createdAt: string;
202
+ entityId?: number | undefined;
203
+ factAId?: number | undefined;
204
+ factBId?: number | undefined;
205
+ factA?: string | undefined;
206
+ factB?: string | undefined;
207
+ description?: string | undefined;
208
+ resolvedBy?: string | undefined;
209
+ }>;
210
+ export type Contradiction = z.infer<typeof ContradictionSchema>;
211
+ export declare const EntityInsightSchema: z.ZodObject<{
212
+ id: z.ZodNumber;
213
+ entityId: z.ZodNumber;
214
+ insightType: z.ZodEnum<["inference", "pattern", "quality", "synthesis"]>;
215
+ insight: z.ZodString;
216
+ reasoning: z.ZodString;
217
+ confidence: z.ZodNumber;
218
+ sourceEntityIds: z.ZodArray<z.ZodNumber, "many">;
219
+ createdAt: z.ZodString;
220
+ expiresAt: z.ZodOptional<z.ZodString>;
221
+ isStale: z.ZodBoolean;
222
+ }, "strip", z.ZodTypeAny, {
223
+ id: number;
224
+ entityId: number;
225
+ confidence: number;
226
+ createdAt: string;
227
+ insightType: "inference" | "pattern" | "quality" | "synthesis";
228
+ insight: string;
229
+ reasoning: string;
230
+ sourceEntityIds: number[];
231
+ isStale: boolean;
232
+ expiresAt?: string | undefined;
233
+ }, {
234
+ id: number;
235
+ entityId: number;
236
+ confidence: number;
237
+ createdAt: string;
238
+ insightType: "inference" | "pattern" | "quality" | "synthesis";
239
+ insight: string;
240
+ reasoning: string;
241
+ sourceEntityIds: number[];
242
+ isStale: boolean;
243
+ expiresAt?: string | undefined;
244
+ }>;
245
+ export type EntityInsight = z.infer<typeof EntityInsightSchema>;
246
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAGlD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAG5D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGhE,eAAO,MAAM,yBAAyB,iCAA+B,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGhE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
package/dist/entity.js ADDED
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+ import { EntityTypeSchema, RelationshipTypeSchema, TierSchema, InsightTypeSchema } from './constants.js';
3
+ // Maps to entities table in entity-graph.db.
4
+ export const EntitySchema = z.object({
5
+ id: z.number().int(),
6
+ name: z.string(),
7
+ normalizedName: z.string(),
8
+ aliases: z.array(z.string()),
9
+ type: EntityTypeSchema,
10
+ firstSeen: z.string(),
11
+ lastSeen: z.string(),
12
+ mentionCount: z.number().int(),
13
+ priority: z.number(),
14
+ decayScore: z.number(),
15
+ tier: TierSchema,
16
+ lastAccessed: z.string().optional(),
17
+ accessCount: z.number().int(),
18
+ isPinned: z.boolean(),
19
+ lastReasonedAt: z.string().optional(),
20
+ });
21
+ // Maps to entity_mentions table.
22
+ export const EntityMentionSchema = z.object({
23
+ id: z.number().int(),
24
+ entityId: z.number().int(),
25
+ conversationId: z.string(),
26
+ sourcePath: z.string(),
27
+ context: z.string().optional(),
28
+ timestamp: z.string(),
29
+ sourceType: z.string(),
30
+ confidence: z.number(),
31
+ });
32
+ // Maps to entity_relations table.
33
+ export const EntityRelationSchema = z.object({
34
+ sourceId: z.number().int(),
35
+ targetId: z.number().int(),
36
+ relationship: RelationshipTypeSchema,
37
+ strength: z.number().int(),
38
+ confidence: z.number(),
39
+ method: z.string(),
40
+ rationale: z.string().optional(),
41
+ lastVerified: z.string().optional(),
42
+ });
43
+ // Maps to entity_merges table.
44
+ export const EntityMergeSchema = z.object({
45
+ id: z.number().int(),
46
+ keepId: z.number().int(),
47
+ removeId: z.number().int(),
48
+ keepName: z.string().optional(),
49
+ removeName: z.string().optional(),
50
+ keepType: z.string().optional(),
51
+ removeType: z.string().optional(),
52
+ reason: z.string(),
53
+ confidence: z.number().optional(),
54
+ aiRationale: z.string().optional(),
55
+ mentionsMoved: z.number().int(),
56
+ relationsMoved: z.number().int(),
57
+ mergedAt: z.string(),
58
+ mergedBy: z.string(),
59
+ });
60
+ // Maps to entity_profiles table.
61
+ export const EntityProfileSchema = z.object({
62
+ entityId: z.number().int(),
63
+ profile: z.string(),
64
+ generatedAt: z.string(),
65
+ factCount: z.number().int(),
66
+ });
67
+ // Maps to contradictions table.
68
+ export const ContradictionStatusSchema = z.enum(['open', 'resolved']);
69
+ export const ContradictionSchema = z.object({
70
+ id: z.number().int(),
71
+ entityId: z.number().int().optional(),
72
+ factAId: z.number().int().optional(),
73
+ factBId: z.number().int().optional(),
74
+ factA: z.string().optional(),
75
+ factB: z.string().optional(),
76
+ description: z.string().optional(),
77
+ status: ContradictionStatusSchema,
78
+ resolvedBy: z.string().optional(),
79
+ createdAt: z.string(),
80
+ });
81
+ // Maps to entity_insights table.
82
+ export const EntityInsightSchema = z.object({
83
+ id: z.number().int(),
84
+ entityId: z.number().int(),
85
+ insightType: InsightTypeSchema,
86
+ insight: z.string(),
87
+ reasoning: z.string(),
88
+ confidence: z.number(),
89
+ sourceEntityIds: z.array(z.number().int()),
90
+ createdAt: z.string(),
91
+ expiresAt: z.string().optional(),
92
+ isStale: z.boolean(),
93
+ });
94
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["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