@indexnetwork/protocol 1.12.5-rc.171.1 → 1.13.0-rc.174.1
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/opportunity/opportunity.graph.d.ts.map +1 -1
- package/dist/opportunity/opportunity.graph.js +12 -178
- package/dist/opportunity/opportunity.graph.js.map +1 -1
- package/dist/opportunity/opportunity.state.d.ts +2 -3
- package/dist/opportunity/opportunity.state.d.ts.map +1 -1
- package/dist/opportunity/opportunity.state.js.map +1 -1
- package/dist/profile/profile.generator.d.ts +1 -1
- package/dist/profile/profile.generator.d.ts.map +1 -1
- package/dist/profile/profile.graph.d.ts +17 -101
- package/dist/profile/profile.graph.d.ts.map +1 -1
- package/dist/profile/profile.graph.js +21 -249
- package/dist/profile/profile.graph.js.map +1 -1
- package/dist/profile/profile.state.d.ts +4 -18
- package/dist/profile/profile.state.d.ts.map +1 -1
- package/dist/profile/profile.state.js +1 -21
- package/dist/profile/profile.state.js.map +1 -1
- package/dist/profile/profile.tools.d.ts.map +1 -1
- package/dist/profile/profile.tools.js +1 -2
- package/dist/profile/profile.tools.js.map +1 -1
- package/dist/shared/agent/model.config.d.ts +0 -3
- package/dist/shared/agent/model.config.d.ts.map +1 -1
- package/dist/shared/agent/model.config.js +0 -1
- package/dist/shared/agent/model.config.js.map +1 -1
- package/dist/shared/agent/tool.factory.js +1 -1
- package/dist/shared/agent/tool.factory.js.map +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +2 -2
- package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/embedder.interface.d.ts +0 -7
- package/dist/shared/interfaces/embedder.interface.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/profile/profile.hyde.generator.d.ts +0 -43
- package/dist/profile/profile.hyde.generator.d.ts.map +0 -1
- package/dist/profile/profile.hyde.generator.js +0 -108
- package/dist/profile/profile.hyde.generator.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
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,MAAM,EAAE,CAAC;;;sBAnF1B,MAAM;yBAAW,MAAM;uBAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;sBAuQvD,MAAM;yBAAW,MAAM;uBAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAooElG"}
|
|
@@ -591,18 +591,12 @@ export class OpportunityGraphFactory {
|
|
|
591
591
|
// Similarity threshold for recall (0.30 = 30% similarity)
|
|
592
592
|
const minScore = 0.3;
|
|
593
593
|
if (state.discoverySource === 'profile') {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
: Array.isArray(embedding) && Array.isArray(embedding[0])
|
|
598
|
-
? embedding[0]
|
|
599
|
-
: null;
|
|
600
|
-
// ALWAYS run query-based HyDE when we have a search query (e.g., "looking for investors")
|
|
601
|
-
// This ensures we use the right strategies (investor, mentor, etc.) not just mirror
|
|
594
|
+
// Profile-context discovery: HyDE (when search query exists) + premise-to-premise.
|
|
595
|
+
// Profile-embedding direct search (Path B) has been removed — all semantic
|
|
596
|
+
// matching goes through HyDE embeddings or premise-to-premise similarity.
|
|
602
597
|
if (state.searchQuery?.trim()) {
|
|
603
|
-
logger.verbose('[Graph:Discovery] Profile source with searchQuery → running query HyDE
|
|
598
|
+
logger.verbose('[Graph:Discovery] Profile source with searchQuery → running query HyDE + premise paths', {
|
|
604
599
|
searchQuery: state.searchQuery.trim().substring(0, 80),
|
|
605
|
-
hasProfileVector: !!vector,
|
|
606
600
|
});
|
|
607
601
|
const queryCandidates = await runQueryHydeDiscovery();
|
|
608
602
|
logger.verbose('[Graph:Discovery] Query HyDE path complete', { candidatesFound: queryCandidates.length });
|
|
@@ -658,59 +652,6 @@ export class OpportunityGraphFactory {
|
|
|
658
652
|
model: getModelName("hydeGenerator"),
|
|
659
653
|
},
|
|
660
654
|
});
|
|
661
|
-
// If we also have a profile vector, merge with profile-based results
|
|
662
|
-
if (vector && vector.length > 0) {
|
|
663
|
-
const profileCandidates = [];
|
|
664
|
-
for (const targetIndex of state.targetNetworks) {
|
|
665
|
-
const results = await this.embedder.searchWithProfileEmbedding(vector, {
|
|
666
|
-
indexScope: [targetIndex.networkId],
|
|
667
|
-
excludeUserId: discoveryUserId,
|
|
668
|
-
limitPerStrategy: Math.floor(limitPerStrategy / 2),
|
|
669
|
-
limit: Math.floor(perIndexLimit / 2),
|
|
670
|
-
minScore,
|
|
671
|
-
});
|
|
672
|
-
for (const result of results) {
|
|
673
|
-
profileCandidates.push({
|
|
674
|
-
candidateUserId: result.userId,
|
|
675
|
-
candidateIntentId: result.type === 'intent' ? result.id : undefined,
|
|
676
|
-
networkId: targetIndex.networkId,
|
|
677
|
-
similarity: result.score,
|
|
678
|
-
lens: result.matchedVia,
|
|
679
|
-
candidatePayload: '',
|
|
680
|
-
candidateSummary: undefined,
|
|
681
|
-
discoverySource: 'profile-similarity',
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
// Merge and dedupe - keep both intent and profile candidates per user
|
|
686
|
-
const byKey = new Map();
|
|
687
|
-
for (const c of [...queryCandidates, ...profileCandidates]) {
|
|
688
|
-
const key = `${c.candidateUserId}:${c.networkId}:${c.candidateIntentId ?? 'profile'}:${c.discoverySource ?? 'unknown'}`;
|
|
689
|
-
if (!byKey.has(key) || c.similarity > (byKey.get(key)?.similarity ?? 0)) {
|
|
690
|
-
byKey.set(key, c);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
const merged = Array.from(byKey.values());
|
|
694
|
-
logger.verbose('[Graph:Discovery] Merged HyDE + profile candidates', {
|
|
695
|
-
hydeCandidates: queryCandidates.length,
|
|
696
|
-
profileCandidates: profileCandidates.length,
|
|
697
|
-
merged: merged.length
|
|
698
|
-
});
|
|
699
|
-
traceEntries.push({
|
|
700
|
-
node: "discovery",
|
|
701
|
-
detail: `+ Profile search → ${profileCandidates.length} additional, merged to ${merged.length}`,
|
|
702
|
-
data: {
|
|
703
|
-
profileCandidates: profileCandidates.length,
|
|
704
|
-
merged: merged.length,
|
|
705
|
-
},
|
|
706
|
-
});
|
|
707
|
-
const premiseCands = await runPremiseDiscovery();
|
|
708
|
-
const withPremises = mergePremiseCandidates(merged, premiseCands);
|
|
709
|
-
if (premiseCands.length > 0) {
|
|
710
|
-
traceEntries.push({ node: "discovery", detail: `+ Premise search → ${premiseCands.length} candidate(s), merged to ${withPremises.length}` });
|
|
711
|
-
}
|
|
712
|
-
return { candidates: filterByTarget(withPremises), trace: traceEntries };
|
|
713
|
-
}
|
|
714
655
|
const premiseCands = await runPremiseDiscovery();
|
|
715
656
|
const withPremises = mergePremiseCandidates(queryCandidates, premiseCands);
|
|
716
657
|
if (premiseCands.length > 0) {
|
|
@@ -718,122 +659,15 @@ export class OpportunityGraphFactory {
|
|
|
718
659
|
}
|
|
719
660
|
return { candidates: filterByTarget(withPremises), trace: traceEntries };
|
|
720
661
|
}
|
|
721
|
-
// No search query -
|
|
722
|
-
if (!vector || vector.length === 0) {
|
|
723
|
-
// Still attempt premise-based discovery even without a profile vector
|
|
724
|
-
const premiseCands = await runPremiseDiscovery();
|
|
725
|
-
if (premiseCands.length > 0) {
|
|
726
|
-
return {
|
|
727
|
-
candidates: filterByTarget(premiseCands),
|
|
728
|
-
trace: [{ node: "discovery", detail: `No profile vector; premise search → ${premiseCands.length} candidate(s)` }],
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
return { candidates: [] };
|
|
732
|
-
}
|
|
733
|
-
const allCandidates = [];
|
|
734
|
-
for (const targetIndex of state.targetNetworks) {
|
|
735
|
-
const results = await this.embedder.searchWithProfileEmbedding(vector, {
|
|
736
|
-
indexScope: [targetIndex.networkId],
|
|
737
|
-
excludeUserId: discoveryUserId,
|
|
738
|
-
limitPerStrategy,
|
|
739
|
-
limit: perIndexLimit,
|
|
740
|
-
minScore,
|
|
741
|
-
});
|
|
742
|
-
for (const result of results) {
|
|
743
|
-
if (result.type === 'intent') {
|
|
744
|
-
allCandidates.push({
|
|
745
|
-
candidateUserId: result.userId,
|
|
746
|
-
candidateIntentId: result.id,
|
|
747
|
-
networkId: targetIndex.networkId,
|
|
748
|
-
similarity: result.score,
|
|
749
|
-
lens: result.matchedVia,
|
|
750
|
-
candidatePayload: '',
|
|
751
|
-
candidateSummary: undefined,
|
|
752
|
-
discoverySource: 'profile-similarity',
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
allCandidates.push({
|
|
757
|
-
candidateUserId: result.userId,
|
|
758
|
-
networkId: targetIndex.networkId,
|
|
759
|
-
similarity: result.score,
|
|
760
|
-
lens: result.matchedVia,
|
|
761
|
-
candidatePayload: '',
|
|
762
|
-
candidateSummary: undefined,
|
|
763
|
-
discoverySource: 'profile-similarity',
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
const byUserAndIndex = new Map();
|
|
769
|
-
for (const c of allCandidates) {
|
|
770
|
-
const key = `${c.candidateUserId}:${c.networkId}:${c.candidateIntentId ?? 'profile'}`;
|
|
771
|
-
if (!byUserAndIndex.has(key) || c.similarity > (byUserAndIndex.get(key)?.similarity ?? 0)) {
|
|
772
|
-
byUserAndIndex.set(key, c);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
const candidates = Array.from(byUserAndIndex.values());
|
|
776
|
-
logger.verbose('[Graph:Discovery] Profile-as-source discovery complete', { candidatesFound: candidates.length });
|
|
777
|
-
// Build trace with individual candidate similarity scores
|
|
778
|
-
const traceEntries = [];
|
|
779
|
-
// Show what the profile search is based on
|
|
780
|
-
const profileBio = state.sourceProfile?.identity?.bio;
|
|
781
|
-
const profileContext = state.sourceProfile?.narrative?.context;
|
|
782
|
-
const profileSummary = profileBio || profileContext || '(profile embedding)';
|
|
783
|
-
// Compute per-lens stats from deduped candidates
|
|
784
|
-
const lensStats = {};
|
|
785
|
-
for (const c of candidates) {
|
|
786
|
-
const s = c.lens || 'unknown';
|
|
787
|
-
if (!lensStats[s])
|
|
788
|
-
lensStats[s] = { count: 0, avgSimilarity: 0 };
|
|
789
|
-
lensStats[s].count++;
|
|
790
|
-
lensStats[s].avgSimilarity += c.similarity;
|
|
791
|
-
}
|
|
792
|
-
for (const s of Object.values(lensStats)) {
|
|
793
|
-
s.avgSimilarity = s.count > 0 ? Math.round((s.avgSimilarity / s.count) * 1000) / 1000 : 0;
|
|
794
|
-
}
|
|
795
|
-
traceEntries.push({
|
|
796
|
-
node: "discovery",
|
|
797
|
-
detail: `Profile-based search → ${candidates.length} candidate(s)`,
|
|
798
|
-
data: {
|
|
799
|
-
source: "profile",
|
|
800
|
-
candidateCount: candidates.length,
|
|
801
|
-
byLens: lensStats,
|
|
802
|
-
durationMs: Date.now() - startTime,
|
|
803
|
-
},
|
|
804
|
-
});
|
|
805
|
-
traceEntries.push({
|
|
806
|
-
node: "search_query",
|
|
807
|
-
detail: `Searching for matches to: "${profileSummary.slice(0, 150)}${profileSummary.length > 150 ? '...' : ''}"`,
|
|
808
|
-
data: {
|
|
809
|
-
type: "profile_embedding",
|
|
810
|
-
bio: profileBio,
|
|
811
|
-
context: profileContext,
|
|
812
|
-
},
|
|
813
|
-
});
|
|
814
|
-
// Add top candidates with similarity scores
|
|
815
|
-
const sortedCandidates = [...candidates].sort((a, b) => b.similarity - a.similarity).slice(0, 10);
|
|
816
|
-
for (const c of sortedCandidates) {
|
|
817
|
-
traceEntries.push({
|
|
818
|
-
node: "match",
|
|
819
|
-
detail: `Similarity ${Math.round(c.similarity * 100)}% via ${c.lens}`,
|
|
820
|
-
data: {
|
|
821
|
-
userId: c.candidateUserId,
|
|
822
|
-
similarity: Math.round(c.similarity * 100),
|
|
823
|
-
lens: c.lens,
|
|
824
|
-
hasIntent: !!c.candidateIntentId,
|
|
825
|
-
},
|
|
826
|
-
});
|
|
827
|
-
}
|
|
662
|
+
// No search query — premise-to-premise discovery only
|
|
828
663
|
const premiseCands = await runPremiseDiscovery();
|
|
829
|
-
const withPremises = mergePremiseCandidates(candidates, premiseCands);
|
|
830
664
|
if (premiseCands.length > 0) {
|
|
831
|
-
|
|
665
|
+
return {
|
|
666
|
+
candidates: filterByTarget(premiseCands),
|
|
667
|
+
trace: [{ node: "discovery", detail: `No search query; premise search → ${premiseCands.length} candidate(s)` }],
|
|
668
|
+
};
|
|
832
669
|
}
|
|
833
|
-
return {
|
|
834
|
-
candidates: filterByTarget(withPremises),
|
|
835
|
-
trace: traceEntries,
|
|
836
|
-
};
|
|
670
|
+
return { candidates: [] };
|
|
837
671
|
}
|
|
838
672
|
async function runQueryHydeDiscovery() {
|
|
839
673
|
const searchText = state.searchQuery?.trim() ?? '';
|
|
@@ -1261,13 +1095,13 @@ export class OpportunityGraphFactory {
|
|
|
1261
1095
|
const batchToEvaluate = dedupedCandidates.slice(0, EVAL_BATCH_SIZE);
|
|
1262
1096
|
const remaining = dedupedCandidates.slice(EVAL_BATCH_SIZE);
|
|
1263
1097
|
// Early termination: if search was query-driven and no query-sourced candidates remain,
|
|
1264
|
-
// clear remaining to prevent pointless pagination through
|
|
1098
|
+
// clear remaining to prevent pointless pagination through non-query leftovers
|
|
1265
1099
|
const isQueryDriven = !!state.searchQuery?.trim();
|
|
1266
1100
|
const queryRemaining = remaining.filter((c) => c.discoverySource === 'query' || c.discoverySource == null);
|
|
1267
1101
|
const effectiveRemaining = isQueryDriven && queryRemaining.length === 0 ? [] : remaining;
|
|
1268
1102
|
if (isQueryDriven && remaining.length > 0 && queryRemaining.length === 0) {
|
|
1269
1103
|
logger.info("[Graph:Evaluation] Early termination: no query-sourced candidates remain", {
|
|
1270
|
-
|
|
1104
|
+
droppedCandidates: remaining.length,
|
|
1271
1105
|
});
|
|
1272
1106
|
}
|
|
1273
1107
|
if (effectiveRemaining.length > 0) {
|