@auxiora/knowledge-graph 1.10.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/LICENSE +191 -0
- package/dist/entity-linker.d.ts +12 -0
- package/dist/entity-linker.d.ts.map +1 -0
- package/dist/entity-linker.js +181 -0
- package/dist/entity-linker.js.map +1 -0
- package/dist/graph-store.d.ts +30 -0
- package/dist/graph-store.d.ts.map +1 -0
- package/dist/graph-store.js +279 -0
- package/dist/graph-store.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Auxiora Contributors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GraphStore } from './graph-store.js';
|
|
2
|
+
import type { ExtractedEntity, ExtractedRelation, GraphEdge, GraphNode } from './types.js';
|
|
3
|
+
export declare class EntityLinker {
|
|
4
|
+
extractEntities(text: string): ExtractedEntity[];
|
|
5
|
+
extractRelationships(text: string, entities: ExtractedEntity[]): ExtractedRelation[];
|
|
6
|
+
linkToGraph(text: string, graph: GraphStore): {
|
|
7
|
+
newNodes: GraphNode[];
|
|
8
|
+
newEdges: GraphEdge[];
|
|
9
|
+
};
|
|
10
|
+
private inferEntityType;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=entity-linker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-linker.d.ts","sourceRoot":"","sources":["../src/entity-linker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAc,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AA2BrH,qBAAa,YAAY;IACvB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE;IAqFhD,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,iBAAiB,EAAE;IAuBpF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG;QAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;QAAC,QAAQ,EAAE,SAAS,EAAE,CAAA;KAAE;IAqC9F,OAAO,CAAC,eAAe;CAkBxB"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { getLogger } from '@auxiora/logger';
|
|
2
|
+
const log = getLogger('knowledge-graph:linker');
|
|
3
|
+
const COMPANY_SUFFIXES = /\b(Inc|Corp|Corporation|Ltd|LLC|GmbH|Co|PLC|AG|SA|NV|BV)\b\.?/;
|
|
4
|
+
const RELATION_PATTERNS = [
|
|
5
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+works?\s+at\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'works_at', sourceGroup: 1, targetGroup: 2 },
|
|
6
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+manages?\s+([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)/g, relation: 'manages', sourceGroup: 1, targetGroup: 2 },
|
|
7
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+reports?\s+to\s+([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)/g, relation: 'reports_to', sourceGroup: 1, targetGroup: 2 },
|
|
8
|
+
{ pattern: /([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)\s+(?:competes?|is a competitor)\s+(?:with|of)\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'competes_with', sourceGroup: 1, targetGroup: 2 },
|
|
9
|
+
{ pattern: /([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)\s+(?:partners?|partnered)\s+with\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'partners_with', sourceGroup: 1, targetGroup: 2 },
|
|
10
|
+
{ pattern: /([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)\s+(?:is |are )?located\s+in\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'located_in', sourceGroup: 1, targetGroup: 2 },
|
|
11
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+(?:is |are )?(?:a )?(?:CEO|CTO|CFO|founder|director|president|VP|head)\s+(?:of|at)\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'manages', sourceGroup: 1, targetGroup: 2 },
|
|
12
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+(?:uses?|utilizes?)\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'uses', sourceGroup: 1, targetGroup: 2 },
|
|
13
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+(?:created|founded|built)\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'created', sourceGroup: 1, targetGroup: 2 },
|
|
14
|
+
{ pattern: /([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)\s+(?:owns?|acquired)\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)/g, relation: 'owns', sourceGroup: 1, targetGroup: 2 },
|
|
15
|
+
{ pattern: /([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)\s+and\s+([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*)\s+are\s+(?:competitors|rivals)/g, relation: 'competes_with', sourceGroup: 1, targetGroup: 2 },
|
|
16
|
+
];
|
|
17
|
+
export class EntityLinker {
|
|
18
|
+
extractEntities(text) {
|
|
19
|
+
const entities = [];
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
// Capitalized multi-word phrases (person/org names)
|
|
22
|
+
const namePattern = /\b([A-Z][a-z]+(?:\s[A-Z][a-z]+)+)\b/g;
|
|
23
|
+
for (const match of text.matchAll(namePattern)) {
|
|
24
|
+
const name = match[1];
|
|
25
|
+
if (seen.has(name.toLowerCase()))
|
|
26
|
+
continue;
|
|
27
|
+
seen.add(name.toLowerCase());
|
|
28
|
+
const type = this.inferEntityType(name, text);
|
|
29
|
+
entities.push({
|
|
30
|
+
name,
|
|
31
|
+
type,
|
|
32
|
+
confidence: 0.7,
|
|
33
|
+
span: [match.index, match.index + match[0].length],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Company suffixes -> organization
|
|
37
|
+
const orgPattern = /\b([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)*\s+(?:Inc|Corp|Corporation|Ltd|LLC|GmbH|Co|PLC|AG|SA|NV|BV))\.?\b/g;
|
|
38
|
+
for (const match of text.matchAll(orgPattern)) {
|
|
39
|
+
const name = match[1];
|
|
40
|
+
if (seen.has(name.toLowerCase()))
|
|
41
|
+
continue;
|
|
42
|
+
seen.add(name.toLowerCase());
|
|
43
|
+
entities.push({
|
|
44
|
+
name,
|
|
45
|
+
type: 'organization',
|
|
46
|
+
confidence: 0.9,
|
|
47
|
+
span: [match.index, match.index + match[0].length],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// Single capitalized words near relation keywords
|
|
51
|
+
const singleCapPattern = /\b([A-Z][a-z]{2,})\b/g;
|
|
52
|
+
for (const match of text.matchAll(singleCapPattern)) {
|
|
53
|
+
const name = match[1];
|
|
54
|
+
if (seen.has(name.toLowerCase()))
|
|
55
|
+
continue;
|
|
56
|
+
if (COMMON_WORDS.has(name.toLowerCase()))
|
|
57
|
+
continue;
|
|
58
|
+
const surroundingText = text.slice(Math.max(0, match.index - 50), match.index + name.length + 50);
|
|
59
|
+
if (/(?:works?|manages?|CEO|CTO|founded|competes?|partners?|located|reports?|uses?|created|owns?)/i.test(surroundingText)) {
|
|
60
|
+
seen.add(name.toLowerCase());
|
|
61
|
+
entities.push({
|
|
62
|
+
name,
|
|
63
|
+
type: this.inferEntityType(name, text),
|
|
64
|
+
confidence: 0.5,
|
|
65
|
+
span: [match.index, match.index + match[0].length],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Email addresses -> person
|
|
70
|
+
const emailPattern = /\b([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\b/g;
|
|
71
|
+
for (const match of text.matchAll(emailPattern)) {
|
|
72
|
+
const localPart = match[1];
|
|
73
|
+
const name = localPart.replace(/[._]/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
|
|
74
|
+
if (seen.has(name.toLowerCase()))
|
|
75
|
+
continue;
|
|
76
|
+
seen.add(name.toLowerCase());
|
|
77
|
+
entities.push({
|
|
78
|
+
name,
|
|
79
|
+
type: 'person',
|
|
80
|
+
confidence: 0.6,
|
|
81
|
+
span: [match.index, match.index + match[0].length],
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// @mentions -> person
|
|
85
|
+
const mentionPattern = /@([a-zA-Z][a-zA-Z0-9_]+)/g;
|
|
86
|
+
for (const match of text.matchAll(mentionPattern)) {
|
|
87
|
+
const name = match[1];
|
|
88
|
+
if (seen.has(name.toLowerCase()))
|
|
89
|
+
continue;
|
|
90
|
+
seen.add(name.toLowerCase());
|
|
91
|
+
entities.push({
|
|
92
|
+
name,
|
|
93
|
+
type: 'person',
|
|
94
|
+
confidence: 0.6,
|
|
95
|
+
span: [match.index, match.index + match[0].length],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
log.debug(`Extracted ${entities.length} entities from text`);
|
|
99
|
+
return entities;
|
|
100
|
+
}
|
|
101
|
+
extractRelationships(text, entities) {
|
|
102
|
+
const relations = [];
|
|
103
|
+
for (const rp of RELATION_PATTERNS) {
|
|
104
|
+
const pattern = new RegExp(rp.pattern.source, rp.pattern.flags);
|
|
105
|
+
for (const match of text.matchAll(pattern)) {
|
|
106
|
+
const source = match[rp.sourceGroup];
|
|
107
|
+
const target = match[rp.targetGroup];
|
|
108
|
+
if (!source || !target)
|
|
109
|
+
continue;
|
|
110
|
+
relations.push({
|
|
111
|
+
source,
|
|
112
|
+
target,
|
|
113
|
+
relation: rp.relation,
|
|
114
|
+
evidence: match[0],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
log.debug(`Extracted ${relations.length} relationships from text`);
|
|
119
|
+
return relations;
|
|
120
|
+
}
|
|
121
|
+
linkToGraph(text, graph) {
|
|
122
|
+
const entities = this.extractEntities(text);
|
|
123
|
+
const relations = this.extractRelationships(text, entities);
|
|
124
|
+
const newNodes = [];
|
|
125
|
+
const newEdges = [];
|
|
126
|
+
for (const entity of entities) {
|
|
127
|
+
const existing = graph.getNode(entity.name);
|
|
128
|
+
const node = graph.addNode({
|
|
129
|
+
name: entity.name,
|
|
130
|
+
type: entity.type,
|
|
131
|
+
aliases: [],
|
|
132
|
+
properties: {},
|
|
133
|
+
confidence: entity.confidence,
|
|
134
|
+
});
|
|
135
|
+
if (!existing) {
|
|
136
|
+
newNodes.push(node);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const rel of relations) {
|
|
140
|
+
try {
|
|
141
|
+
const edge = graph.addEdge(rel.source, rel.target, rel.relation, {
|
|
142
|
+
evidence: [rel.evidence],
|
|
143
|
+
label: rel.label,
|
|
144
|
+
});
|
|
145
|
+
newEdges.push(edge);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
log.debug(`Could not link relationship: ${rel.source} -> ${rel.target}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
log.debug(`Linked ${newNodes.length} new nodes and ${newEdges.length} new edges`);
|
|
152
|
+
return { newNodes, newEdges };
|
|
153
|
+
}
|
|
154
|
+
inferEntityType(name, context) {
|
|
155
|
+
if (COMPANY_SUFFIXES.test(name))
|
|
156
|
+
return 'organization';
|
|
157
|
+
const nameEscaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
158
|
+
const surrounding = new RegExp(`(?:${nameEscaped})\\s+(?:Inc|Corp|Ltd|LLC|Company|Group)`, 'i');
|
|
159
|
+
if (surrounding.test(context))
|
|
160
|
+
return 'organization';
|
|
161
|
+
const rolePattern = new RegExp(`(?:${nameEscaped})\\s+(?:is|was)\\s+(?:a\\s+)?(?:CEO|CTO|CFO|manager|engineer|developer|designer|director|president|founder)`, 'i');
|
|
162
|
+
if (rolePattern.test(context))
|
|
163
|
+
return 'person';
|
|
164
|
+
const worksPattern = new RegExp(`(?:${nameEscaped})\\s+(?:works?|manages?|reports?|joined)`, 'i');
|
|
165
|
+
if (worksPattern.test(context))
|
|
166
|
+
return 'person';
|
|
167
|
+
const placePattern = new RegExp(`(?:in|at|from|near)\\s+${nameEscaped}`, 'i');
|
|
168
|
+
if (placePattern.test(context))
|
|
169
|
+
return 'place';
|
|
170
|
+
return 'person';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const COMMON_WORDS = new Set([
|
|
174
|
+
'the', 'this', 'that', 'with', 'from', 'have', 'has', 'had', 'been', 'were',
|
|
175
|
+
'was', 'are', 'but', 'not', 'you', 'all', 'can', 'her', 'his', 'one',
|
|
176
|
+
'our', 'out', 'day', 'get', 'him', 'how', 'its', 'may', 'new',
|
|
177
|
+
'now', 'old', 'see', 'way', 'who', 'did', 'let', 'say', 'she', 'too',
|
|
178
|
+
'use', 'and', 'for', 'also', 'just', 'will', 'than', 'then', 'when',
|
|
179
|
+
'what', 'some', 'into', 'them', 'they', 'here', 'there', 'where',
|
|
180
|
+
]);
|
|
181
|
+
//# sourceMappingURL=entity-linker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-linker.js","sourceRoot":"","sources":["../src/entity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AAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IAC7D,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IACpE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACnE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;CACjE,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GraphEdge, GraphNode, GraphQuery, QueryResult, RelationType } from './types.js';
|
|
2
|
+
export declare class GraphStore {
|
|
3
|
+
private nodes;
|
|
4
|
+
private edges;
|
|
5
|
+
private nodeIndex;
|
|
6
|
+
addNode(input: Omit<GraphNode, 'id' | 'createdAt' | 'updatedAt' | 'mentionCount'>): GraphNode;
|
|
7
|
+
addEdge(source: string, target: string, relation: RelationType, opts?: {
|
|
8
|
+
weight?: number;
|
|
9
|
+
label?: string;
|
|
10
|
+
evidence?: string[];
|
|
11
|
+
properties?: Record<string, unknown>;
|
|
12
|
+
}): GraphEdge;
|
|
13
|
+
getNode(idOrName: string): GraphNode | undefined;
|
|
14
|
+
getEdges(nodeId: string, direction?: 'outgoing' | 'incoming' | 'both'): GraphEdge[];
|
|
15
|
+
getNeighbors(nodeId: string, relation?: RelationType): GraphNode[];
|
|
16
|
+
query(q: GraphQuery): QueryResult;
|
|
17
|
+
private bfs;
|
|
18
|
+
merge(nodeId1: string, nodeId2: string): GraphNode;
|
|
19
|
+
removeNode(id: string): void;
|
|
20
|
+
removeEdge(id: string): void;
|
|
21
|
+
stats(): {
|
|
22
|
+
nodeCount: number;
|
|
23
|
+
edgeCount: number;
|
|
24
|
+
relationCounts: Record<string, number>;
|
|
25
|
+
};
|
|
26
|
+
toJSON(): string;
|
|
27
|
+
static fromJSON(json: string): GraphStore;
|
|
28
|
+
private resolveNode;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=graph-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-store.d.ts","sourceRoot":"","sources":["../src/graph-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,SAAS,EAAE,SAAS,EAAa,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAIrH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,SAAS,CAA6B;IAE9C,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,WAAW,GAAG,WAAW,GAAG,cAAc,CAAC,GAAG,SAAS;IAyC7F,OAAO,CACL,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GACpG,SAAS;IAwBZ,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIhD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,UAAU,GAAG,UAAU,GAAG,MAAe,GAAG,SAAS,EAAE;IAa3F,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,EAAE;IAelE,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,WAAW;IAkCjC,OAAO,CAAC,GAAG;IA2DX,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS;IA2ClD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAqB5B,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI5B,KAAK,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE;IAYzF,MAAM,IAAI,MAAM;IAOhB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAmBzC,OAAO,CAAC,WAAW;CAWpB"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { getLogger } from '@auxiora/logger';
|
|
3
|
+
const log = getLogger('knowledge-graph:store');
|
|
4
|
+
export class GraphStore {
|
|
5
|
+
nodes = new Map();
|
|
6
|
+
edges = new Map();
|
|
7
|
+
nodeIndex = new Map(); // lowercase name/alias → node ID
|
|
8
|
+
addNode(input) {
|
|
9
|
+
// Check for existing node by name
|
|
10
|
+
const existing = this.resolveNode(input.name);
|
|
11
|
+
if (existing) {
|
|
12
|
+
existing.mentionCount++;
|
|
13
|
+
existing.updatedAt = Date.now();
|
|
14
|
+
// Merge aliases
|
|
15
|
+
for (const alias of input.aliases) {
|
|
16
|
+
if (!existing.aliases.includes(alias)) {
|
|
17
|
+
existing.aliases.push(alias);
|
|
18
|
+
this.nodeIndex.set(alias.toLowerCase(), existing.id);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Merge properties
|
|
22
|
+
Object.assign(existing.properties, input.properties);
|
|
23
|
+
if (input.confidence > existing.confidence) {
|
|
24
|
+
existing.confidence = input.confidence;
|
|
25
|
+
}
|
|
26
|
+
log.debug(`Merged into existing node: ${existing.name} (${existing.id})`);
|
|
27
|
+
return existing;
|
|
28
|
+
}
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
const node = {
|
|
31
|
+
...input,
|
|
32
|
+
id: randomUUID(),
|
|
33
|
+
createdAt: now,
|
|
34
|
+
updatedAt: now,
|
|
35
|
+
mentionCount: 1,
|
|
36
|
+
};
|
|
37
|
+
this.nodes.set(node.id, node);
|
|
38
|
+
this.nodeIndex.set(node.name.toLowerCase(), node.id);
|
|
39
|
+
for (const alias of node.aliases) {
|
|
40
|
+
this.nodeIndex.set(alias.toLowerCase(), node.id);
|
|
41
|
+
}
|
|
42
|
+
log.debug(`Added node: ${node.name} (${node.id})`);
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
addEdge(source, target, relation, opts) {
|
|
46
|
+
const sourceNode = this.resolveNode(source);
|
|
47
|
+
const targetNode = this.resolveNode(target);
|
|
48
|
+
if (!sourceNode)
|
|
49
|
+
throw new Error(`Source node not found: ${source}`);
|
|
50
|
+
if (!targetNode)
|
|
51
|
+
throw new Error(`Target node not found: ${target}`);
|
|
52
|
+
const edge = {
|
|
53
|
+
id: randomUUID(),
|
|
54
|
+
source: sourceNode.id,
|
|
55
|
+
target: targetNode.id,
|
|
56
|
+
relation,
|
|
57
|
+
label: opts?.label,
|
|
58
|
+
weight: opts?.weight ?? 0.5,
|
|
59
|
+
properties: opts?.properties ?? {},
|
|
60
|
+
createdAt: Date.now(),
|
|
61
|
+
evidence: opts?.evidence ?? [],
|
|
62
|
+
};
|
|
63
|
+
this.edges.set(edge.id, edge);
|
|
64
|
+
log.debug(`Added edge: ${sourceNode.name} -[${relation}]-> ${targetNode.name}`);
|
|
65
|
+
return edge;
|
|
66
|
+
}
|
|
67
|
+
getNode(idOrName) {
|
|
68
|
+
return this.resolveNode(idOrName);
|
|
69
|
+
}
|
|
70
|
+
getEdges(nodeId, direction = 'both') {
|
|
71
|
+
const results = [];
|
|
72
|
+
for (const edge of this.edges.values()) {
|
|
73
|
+
if (direction === 'outgoing' || direction === 'both') {
|
|
74
|
+
if (edge.source === nodeId)
|
|
75
|
+
results.push(edge);
|
|
76
|
+
}
|
|
77
|
+
if (direction === 'incoming' || direction === 'both') {
|
|
78
|
+
if (edge.target === nodeId)
|
|
79
|
+
results.push(edge);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
getNeighbors(nodeId, relation) {
|
|
85
|
+
const neighborIds = new Set();
|
|
86
|
+
for (const edge of this.edges.values()) {
|
|
87
|
+
if (relation && edge.relation !== relation)
|
|
88
|
+
continue;
|
|
89
|
+
if (edge.source === nodeId)
|
|
90
|
+
neighborIds.add(edge.target);
|
|
91
|
+
if (edge.target === nodeId)
|
|
92
|
+
neighborIds.add(edge.source);
|
|
93
|
+
}
|
|
94
|
+
const results = [];
|
|
95
|
+
for (const nid of neighborIds) {
|
|
96
|
+
const node = this.nodes.get(nid);
|
|
97
|
+
if (node)
|
|
98
|
+
results.push(node);
|
|
99
|
+
}
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
query(q) {
|
|
103
|
+
const maxDepth = q.maxDepth ?? 2;
|
|
104
|
+
const minConfidence = q.minConfidence ?? 0;
|
|
105
|
+
// Resolve start node
|
|
106
|
+
let startNode;
|
|
107
|
+
if (q.startNode) {
|
|
108
|
+
startNode = this.resolveNode(q.startNode);
|
|
109
|
+
if (!startNode)
|
|
110
|
+
return { paths: [], nodes: [], edges: [] };
|
|
111
|
+
}
|
|
112
|
+
// BFS traversal
|
|
113
|
+
const visitedNodes = new Map();
|
|
114
|
+
const collectedEdges = new Map();
|
|
115
|
+
const paths = [];
|
|
116
|
+
if (startNode) {
|
|
117
|
+
this.bfs(startNode, maxDepth, minConfidence, q.relation, q.targetType, visitedNodes, collectedEdges, paths);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// No start node: filter all nodes by criteria
|
|
121
|
+
for (const node of this.nodes.values()) {
|
|
122
|
+
if (node.confidence < minConfidence)
|
|
123
|
+
continue;
|
|
124
|
+
if (q.targetType && node.type !== q.targetType)
|
|
125
|
+
continue;
|
|
126
|
+
visitedNodes.set(node.id, node);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
paths,
|
|
131
|
+
nodes: [...visitedNodes.values()],
|
|
132
|
+
edges: [...collectedEdges.values()],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
bfs(start, maxDepth, minConfidence, relation, targetType, visitedNodes, collectedEdges, paths) {
|
|
136
|
+
const queue = [{ node: start, depth: 0, pathNodes: [start], pathEdges: [], totalWeight: 0 }];
|
|
137
|
+
const visited = new Set([start.id]);
|
|
138
|
+
visitedNodes.set(start.id, start);
|
|
139
|
+
while (queue.length > 0) {
|
|
140
|
+
const item = queue.shift();
|
|
141
|
+
if (item.depth >= maxDepth)
|
|
142
|
+
continue;
|
|
143
|
+
for (const edge of this.edges.values()) {
|
|
144
|
+
let neighborId;
|
|
145
|
+
if (edge.source === item.node.id)
|
|
146
|
+
neighborId = edge.target;
|
|
147
|
+
else if (edge.target === item.node.id)
|
|
148
|
+
neighborId = edge.source;
|
|
149
|
+
if (!neighborId || visited.has(neighborId))
|
|
150
|
+
continue;
|
|
151
|
+
if (relation && edge.relation !== relation)
|
|
152
|
+
continue;
|
|
153
|
+
const neighbor = this.nodes.get(neighborId);
|
|
154
|
+
if (!neighbor || neighbor.confidence < minConfidence)
|
|
155
|
+
continue;
|
|
156
|
+
visited.add(neighborId);
|
|
157
|
+
visitedNodes.set(neighborId, neighbor);
|
|
158
|
+
collectedEdges.set(edge.id, edge);
|
|
159
|
+
const newPathNodes = [...item.pathNodes, neighbor];
|
|
160
|
+
const newPathEdges = [...item.pathEdges, edge];
|
|
161
|
+
const newWeight = item.totalWeight + edge.weight;
|
|
162
|
+
if (!targetType || neighbor.type === targetType) {
|
|
163
|
+
paths.push({ nodes: newPathNodes, edges: newPathEdges, totalWeight: newWeight });
|
|
164
|
+
}
|
|
165
|
+
queue.push({
|
|
166
|
+
node: neighbor,
|
|
167
|
+
depth: item.depth + 1,
|
|
168
|
+
pathNodes: newPathNodes,
|
|
169
|
+
pathEdges: newPathEdges,
|
|
170
|
+
totalWeight: newWeight,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
merge(nodeId1, nodeId2) {
|
|
176
|
+
const node1 = this.nodes.get(nodeId1);
|
|
177
|
+
const node2 = this.nodes.get(nodeId2);
|
|
178
|
+
if (!node1)
|
|
179
|
+
throw new Error(`Node not found: ${nodeId1}`);
|
|
180
|
+
if (!node2)
|
|
181
|
+
throw new Error(`Node not found: ${nodeId2}`);
|
|
182
|
+
// Merge into node1
|
|
183
|
+
node1.mentionCount += node2.mentionCount;
|
|
184
|
+
node1.confidence = Math.max(node1.confidence, node2.confidence);
|
|
185
|
+
node1.updatedAt = Date.now();
|
|
186
|
+
// Merge aliases
|
|
187
|
+
if (!node1.aliases.includes(node2.name)) {
|
|
188
|
+
node1.aliases.push(node2.name);
|
|
189
|
+
}
|
|
190
|
+
for (const alias of node2.aliases) {
|
|
191
|
+
if (!node1.aliases.includes(alias)) {
|
|
192
|
+
node1.aliases.push(alias);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Merge properties
|
|
196
|
+
Object.assign(node1.properties, node2.properties);
|
|
197
|
+
// Reassign edges
|
|
198
|
+
for (const edge of this.edges.values()) {
|
|
199
|
+
if (edge.source === nodeId2)
|
|
200
|
+
edge.source = nodeId1;
|
|
201
|
+
if (edge.target === nodeId2)
|
|
202
|
+
edge.target = nodeId1;
|
|
203
|
+
}
|
|
204
|
+
// Update index
|
|
205
|
+
this.nodeIndex.set(node2.name.toLowerCase(), nodeId1);
|
|
206
|
+
for (const alias of node2.aliases) {
|
|
207
|
+
this.nodeIndex.set(alias.toLowerCase(), nodeId1);
|
|
208
|
+
}
|
|
209
|
+
// Remove node2
|
|
210
|
+
this.nodes.delete(nodeId2);
|
|
211
|
+
log.debug(`Merged node ${node2.name} into ${node1.name}`);
|
|
212
|
+
return node1;
|
|
213
|
+
}
|
|
214
|
+
removeNode(id) {
|
|
215
|
+
const node = this.nodes.get(id);
|
|
216
|
+
if (!node)
|
|
217
|
+
return;
|
|
218
|
+
// Remove connected edges
|
|
219
|
+
for (const [edgeId, edge] of this.edges) {
|
|
220
|
+
if (edge.source === id || edge.target === id) {
|
|
221
|
+
this.edges.delete(edgeId);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Remove from index
|
|
225
|
+
this.nodeIndex.delete(node.name.toLowerCase());
|
|
226
|
+
for (const alias of node.aliases) {
|
|
227
|
+
this.nodeIndex.delete(alias.toLowerCase());
|
|
228
|
+
}
|
|
229
|
+
this.nodes.delete(id);
|
|
230
|
+
log.debug(`Removed node: ${node.name}`);
|
|
231
|
+
}
|
|
232
|
+
removeEdge(id) {
|
|
233
|
+
this.edges.delete(id);
|
|
234
|
+
}
|
|
235
|
+
stats() {
|
|
236
|
+
const relationCounts = {};
|
|
237
|
+
for (const edge of this.edges.values()) {
|
|
238
|
+
relationCounts[edge.relation] = (relationCounts[edge.relation] ?? 0) + 1;
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
nodeCount: this.nodes.size,
|
|
242
|
+
edgeCount: this.edges.size,
|
|
243
|
+
relationCounts,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
toJSON() {
|
|
247
|
+
return JSON.stringify({
|
|
248
|
+
nodes: [...this.nodes.values()],
|
|
249
|
+
edges: [...this.edges.values()],
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
static fromJSON(json) {
|
|
253
|
+
const data = JSON.parse(json);
|
|
254
|
+
const store = new GraphStore();
|
|
255
|
+
for (const node of data.nodes) {
|
|
256
|
+
store.nodes.set(node.id, node);
|
|
257
|
+
store.nodeIndex.set(node.name.toLowerCase(), node.id);
|
|
258
|
+
for (const alias of node.aliases) {
|
|
259
|
+
store.nodeIndex.set(alias.toLowerCase(), node.id);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
for (const edge of data.edges) {
|
|
263
|
+
store.edges.set(edge.id, edge);
|
|
264
|
+
}
|
|
265
|
+
return store;
|
|
266
|
+
}
|
|
267
|
+
resolveNode(idOrName) {
|
|
268
|
+
// Try direct ID lookup first
|
|
269
|
+
const byId = this.nodes.get(idOrName);
|
|
270
|
+
if (byId)
|
|
271
|
+
return byId;
|
|
272
|
+
// Try name/alias index
|
|
273
|
+
const nodeId = this.nodeIndex.get(idOrName.toLowerCase());
|
|
274
|
+
if (nodeId)
|
|
275
|
+
return this.nodes.get(nodeId);
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=graph-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-store.js","sourceRoot":"","sources":["../src/graph-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,GAAG,GAAG,SAAS,CAAC,uBAAuB,CAAC,CAAC;AAE/C,MAAM,OAAO,UAAU;IACb,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IACrC,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IACrC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,iCAAiC;IAEhF,OAAO,CAAC,KAAyE;QAC/E,kCAAkC;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,YAAY,EAAE,CAAC;YACxB,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAChC,gBAAgB;YAChB,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,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AAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,QAAgB;QAClC,6BAA6B;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAEtB,uBAAuB;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAC1D,IAAI,MAAM;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE1C,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { GraphStore } from './graph-store.js';
|
|
2
|
+
export { EntityLinker } from './entity-linker.js';
|
|
3
|
+
export type { EntityType, RelationType, GraphNode, GraphEdge, GraphQuery, QueryResult, GraphPath, ExtractedEntity, ExtractedRelation, } from './types.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,EACT,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type EntityType = 'person' | 'organization' | 'place' | 'project' | 'concept' | 'event' | 'tool' | 'custom';
|
|
2
|
+
export type RelationType = 'works_at' | 'manages' | 'reports_to' | 'competes_with' | 'partners_with' | 'located_in' | 'member_of' | 'related_to' | 'uses' | 'created' | 'owns' | 'depends_on' | 'custom';
|
|
3
|
+
export interface GraphNode {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: EntityType;
|
|
7
|
+
aliases: string[];
|
|
8
|
+
properties: Record<string, unknown>;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
mentionCount: number;
|
|
12
|
+
confidence: number;
|
|
13
|
+
}
|
|
14
|
+
export interface GraphEdge {
|
|
15
|
+
id: string;
|
|
16
|
+
source: string;
|
|
17
|
+
target: string;
|
|
18
|
+
relation: RelationType;
|
|
19
|
+
label?: string;
|
|
20
|
+
weight: number;
|
|
21
|
+
properties: Record<string, unknown>;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
evidence: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface GraphQuery {
|
|
26
|
+
startNode?: string;
|
|
27
|
+
relation?: RelationType;
|
|
28
|
+
targetType?: EntityType;
|
|
29
|
+
maxDepth?: number;
|
|
30
|
+
minConfidence?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface QueryResult {
|
|
33
|
+
paths: GraphPath[];
|
|
34
|
+
nodes: GraphNode[];
|
|
35
|
+
edges: GraphEdge[];
|
|
36
|
+
}
|
|
37
|
+
export interface GraphPath {
|
|
38
|
+
nodes: GraphNode[];
|
|
39
|
+
edges: GraphEdge[];
|
|
40
|
+
totalWeight: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ExtractedEntity {
|
|
43
|
+
name: string;
|
|
44
|
+
type: EntityType;
|
|
45
|
+
confidence: number;
|
|
46
|
+
span: [number, number];
|
|
47
|
+
}
|
|
48
|
+
export interface ExtractedRelation {
|
|
49
|
+
source: string;
|
|
50
|
+
target: string;
|
|
51
|
+
relation: RelationType;
|
|
52
|
+
label?: string;
|
|
53
|
+
evidence: string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AACnH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,eAAe,GAAG,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEzM,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@auxiora/knowledge-graph",
|
|
3
|
+
"version": "1.10.0",
|
|
4
|
+
"description": "Relationship-aware knowledge graph memory",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@auxiora/logger": "1.10.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.0.0"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"typecheck": "tsc --noEmit"
|
|
31
|
+
}
|
|
32
|
+
}
|