@lucern/graph-sync 0.3.0-alpha.9 → 1.0.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/index.js CHANGED
@@ -2,7 +2,7 @@ import neo4j from 'neo4j-driver';
2
2
  import { v } from 'convex/values';
3
3
  import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
4
4
  import { NODE_TYPE_TO_LABEL, EDGE_TYPE_TO_REL, getNeo4jRelType } from '@lucern/graph-primitives/graphTypes';
5
- import { componentsGeneric, anyApi, internalActionGeneric, actionGeneric, internalMutationGeneric, internalQueryGeneric } from 'convex/server';
5
+ import { anyApi, internalActionGeneric, actionGeneric, internalMutationGeneric, internalQueryGeneric } from 'convex/server';
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __export = (target, all) => {
@@ -148,7 +148,7 @@ function toNeo4jParams(params) {
148
148
  result[key] = neo4j.int(value);
149
149
  } else if (Array.isArray(value)) {
150
150
  result[key] = value.map(
151
- (v5) => typeof v5 === "number" && Number.isInteger(v5) ? neo4j.int(v5) : v5
151
+ (v6) => typeof v6 === "number" && Number.isInteger(v6) ? neo4j.int(v6) : v6
152
152
  );
153
153
  } else {
154
154
  result[key] = value;
@@ -346,15 +346,15 @@ function convertNeo4jValue(value) {
346
346
  if (value && typeof value === "object" && "properties" in value) {
347
347
  const nodeObj = value;
348
348
  const result = {};
349
- for (const [k, v5] of Object.entries(nodeObj.properties)) {
350
- result[k] = convertNeo4jValue(v5);
349
+ for (const [k, v6] of Object.entries(nodeObj.properties)) {
350
+ result[k] = convertNeo4jValue(v6);
351
351
  }
352
352
  return result;
353
353
  }
354
354
  if (typeof value === "object") {
355
355
  const result = {};
356
- for (const [k, v5] of Object.entries(value)) {
357
- result[k] = convertNeo4jValue(v5);
356
+ for (const [k, v6] of Object.entries(value)) {
357
+ result[k] = convertNeo4jValue(v6);
358
358
  }
359
359
  return result;
360
360
  }
@@ -378,7 +378,6 @@ __export(neo4jEdgeAPI_exports, {
378
378
  retryProjectionByGlobalId: () => retryProjectionByGlobalId,
379
379
  updateEdge: () => updateEdge
380
380
  });
381
- componentsGeneric();
382
381
  var internal = anyApi;
383
382
  var action = actionGeneric;
384
383
  var internalAction = internalActionGeneric;
@@ -829,6 +828,8 @@ __export(neo4jQueries_exports, {
829
828
  searchAllNodes: () => searchAllNodes,
830
829
  semanticSearch: () => semanticSearch
831
830
  });
831
+
832
+ // src/neo4jQueriesCore.ts
832
833
  function toInt(value, defaultValue) {
833
834
  if (value === void 0 || value === null) {
834
835
  return defaultValue;
@@ -877,6 +878,9 @@ function buildProxyEndpoint(proxyBaseUrl) {
877
878
  }
878
879
  return endpoint.toString();
879
880
  }
881
+ function withTopicScope(args, params) {
882
+ return args.topicId ? { ...params, topicId: args.topicId } : params;
883
+ }
880
884
  async function callNeo4jQuery(queryName, params, apiBaseUrl) {
881
885
  const proxyUrl = resolveProxyBaseUrl(apiBaseUrl);
882
886
  if (!proxyUrl) {
@@ -950,101 +954,95 @@ async function callNeo4jQuery(queryName, params, apiBaseUrl) {
950
954
  );
951
955
  }
952
956
  }
953
- function withTopicScope(args, params) {
954
- return args.topicId ? { ...params, topicId: args.topicId } : params;
955
- }
956
- var getNodeLineageGraph = action({
957
+ var getHighPriorityQuestions = action({
957
958
  args: {
958
- globalId: v.string(),
959
+ limit: v.optional(v.number()),
959
960
  apiBaseUrl: v.optional(v.string()),
960
961
  topicId: v.optional(v.string())
961
962
  },
962
963
  returns: permissiveReturn,
963
964
  handler: async (_ctx, args) => {
964
965
  const result = await callNeo4jQuery(
965
- "nodeLineage",
966
+ "highPriorityQuestions",
966
967
  withTopicScope(args, {
967
- globalId: args.globalId
968
+ limit: toInt(args.limit, 50)
968
969
  }),
969
970
  args.apiBaseUrl
970
971
  );
971
972
  if (!result.success) {
972
- console.error("[Neo4j] Lineage query failed:", result.error);
973
- return { lineage: [], error: result.error };
973
+ return { questions: [], error: result.error };
974
974
  }
975
- const lineage = result.data?.[0]?.lineage || [];
976
- return { lineage };
975
+ return { questions: result.data || [] };
977
976
  }
978
977
  });
979
- var getConnectedNodesGraph = action({
978
+ var getEvidenceByMethodology = action({
980
979
  args: {
981
- globalId: v.string(),
982
- maxHops: v.optional(v.number()),
980
+ methodology: v.string(),
983
981
  limit: v.optional(v.number()),
984
982
  apiBaseUrl: v.optional(v.string()),
985
983
  topicId: v.optional(v.string())
986
984
  },
987
985
  returns: permissiveReturn,
988
986
  handler: async (_ctx, args) => {
989
- const maxHops = Math.min(toInt(args.maxHops, 2), 5);
990
- const limit = toInt(args.limit, 50);
991
987
  const result = await callNeo4jQuery(
992
- "connectedNodes",
988
+ "evidenceByMethodology",
993
989
  withTopicScope(args, {
994
- globalId: args.globalId,
995
- maxHops,
996
- limit
990
+ methodology: args.methodology,
991
+ limit: toInt(args.limit, 50)
997
992
  }),
998
993
  args.apiBaseUrl
999
994
  );
1000
995
  if (!result.success) {
1001
- console.error("[Neo4j] Connected nodes query failed:", result.error);
1002
- return { nodes: [], error: result.error };
996
+ return { evidence: [], error: result.error };
1003
997
  }
1004
- return { nodes: result.data || [] };
998
+ return { evidence: result.data || [] };
1005
999
  }
1006
1000
  });
1007
- var getThemeBeliefsGraph = action({
1001
+ var getProprietaryEvidence = action({
1008
1002
  args: {
1009
- themeGlobalId: v.string()
1003
+ limit: v.optional(v.number()),
1004
+ apiBaseUrl: v.optional(v.string()),
1005
+ topicId: v.optional(v.string())
1010
1006
  },
1011
1007
  returns: permissiveReturn,
1012
1008
  handler: async (_ctx, args) => {
1013
- const result = await callNeo4jQuery("themeBeliefs", {
1014
- themeGlobalId: args.themeGlobalId
1015
- });
1009
+ const result = await callNeo4jQuery(
1010
+ "proprietaryEvidence",
1011
+ withTopicScope(args, {
1012
+ limit: toInt(args.limit, 50)
1013
+ }),
1014
+ args.apiBaseUrl
1015
+ );
1016
1016
  if (!result.success) {
1017
- return { beliefs: [], error: result.error };
1017
+ return { evidence: [], error: result.error };
1018
1018
  }
1019
- return {
1020
- beliefs: result.data?.map((r) => r.belief) || []
1021
- };
1019
+ return { evidence: result.data || [] };
1022
1020
  }
1023
1021
  });
1024
- var getBeliefEvidenceGraph = action({
1022
+ var getBeliefsByEpistemicStatus = action({
1025
1023
  args: {
1026
- beliefGlobalId: v.string(),
1024
+ epistemicStatus: v.string(),
1025
+ limit: v.optional(v.number()),
1027
1026
  apiBaseUrl: v.optional(v.string()),
1028
1027
  topicId: v.optional(v.string())
1029
1028
  },
1030
1029
  returns: permissiveReturn,
1031
1030
  handler: async (_ctx, args) => {
1032
1031
  const result = await callNeo4jQuery(
1033
- "beliefEvidence",
1032
+ "beliefsByEpistemicStatus",
1034
1033
  withTopicScope(args, {
1035
- beliefGlobalId: args.beliefGlobalId
1034
+ epistemicStatus: args.epistemicStatus,
1035
+ limit: toInt(args.limit, 50)
1036
1036
  }),
1037
1037
  args.apiBaseUrl
1038
1038
  );
1039
1039
  if (!result.success) {
1040
- return { evidence: [], error: result.error };
1040
+ return { beliefs: [], error: result.error };
1041
1041
  }
1042
- return {
1043
- evidence: result.data?.map((r) => r.evidence) || []
1044
- };
1042
+ return { beliefs: result.data || [] };
1045
1043
  }
1046
1044
  });
1047
- var getCrossThemeBeliefs = action({
1045
+ var getChallengedBeliefs = action({
1048
1046
  args: {
1049
1047
  limit: v.optional(v.number()),
1050
1048
  apiBaseUrl: v.optional(v.string()),
@@ -1053,21 +1051,19 @@ var getCrossThemeBeliefs = action({
1053
1051
  returns: permissiveReturn,
1054
1052
  handler: async (_ctx, args) => {
1055
1053
  const result = await callNeo4jQuery(
1056
- "crossThemeBeliefs",
1054
+ "challengedBeliefs",
1057
1055
  withTopicScope(args, {
1058
- limit: toInt(args.limit, 20)
1056
+ limit: toInt(args.limit, 30)
1059
1057
  }),
1060
1058
  args.apiBaseUrl
1061
1059
  );
1062
1060
  if (!result.success) {
1063
1061
  return { beliefs: [], error: result.error };
1064
1062
  }
1065
- return {
1066
- beliefs: result.data?.map((r) => r.belief) || []
1067
- };
1063
+ return { beliefs: result.data || [] };
1068
1064
  }
1069
1065
  });
1070
- var findPotentialContradictions = action({
1066
+ var getPredictions = action({
1071
1067
  args: {
1072
1068
  limit: v.optional(v.number()),
1073
1069
  apiBaseUrl: v.optional(v.string()),
@@ -1076,94 +1072,82 @@ var findPotentialContradictions = action({
1076
1072
  returns: permissiveReturn,
1077
1073
  handler: async (_ctx, args) => {
1078
1074
  const result = await callNeo4jQuery(
1079
- "potentialContradictions",
1075
+ "predictions",
1080
1076
  withTopicScope(args, {
1081
- limit: toInt(args.limit, 10)
1077
+ limit: toInt(args.limit, 50)
1082
1078
  }),
1083
1079
  args.apiBaseUrl
1084
1080
  );
1085
1081
  if (!result.success) {
1086
- return { contradictions: [], error: result.error };
1082
+ return { predictions: [], error: result.error };
1087
1083
  }
1088
- return {
1089
- contradictions: result.data?.map(
1090
- (r) => r.contradiction
1091
- ) || []
1092
- };
1084
+ return { predictions: result.data || [] };
1093
1085
  }
1094
1086
  });
1095
- var getThemeSubgraph = action({
1087
+ var getCausalChains = action({
1096
1088
  args: {
1097
- themeGlobalId: v.string(),
1089
+ limit: v.optional(v.number()),
1098
1090
  apiBaseUrl: v.optional(v.string()),
1099
1091
  topicId: v.optional(v.string())
1100
1092
  },
1101
1093
  returns: permissiveReturn,
1102
1094
  handler: async (_ctx, args) => {
1103
1095
  const result = await callNeo4jQuery(
1104
- "themeSubgraph",
1096
+ "causalChains",
1105
1097
  withTopicScope(args, {
1106
- themeGlobalId: args.themeGlobalId
1098
+ limit: toInt(args.limit, 50)
1107
1099
  }),
1108
1100
  args.apiBaseUrl
1109
1101
  );
1110
1102
  if (!result.success) {
1111
- return { subgraph: null, error: result.error };
1103
+ return { chains: [], error: result.error };
1112
1104
  }
1113
- return {
1114
- subgraph: result.data?.[0]?.subgraph || null
1115
- };
1105
+ return { chains: result.data || [] };
1116
1106
  }
1117
1107
  });
1118
- var getEvidenceToBeliefPath = action({
1108
+ var getNecessaryEvidence = action({
1119
1109
  args: {
1120
- evidenceGlobalId: v.string(),
1121
- beliefGlobalId: v.string(),
1110
+ limit: v.optional(v.number()),
1122
1111
  apiBaseUrl: v.optional(v.string()),
1123
1112
  topicId: v.optional(v.string())
1124
1113
  },
1125
1114
  returns: permissiveReturn,
1126
1115
  handler: async (_ctx, args) => {
1127
1116
  const result = await callNeo4jQuery(
1128
- "evidenceToBeliefPath",
1117
+ "necessaryEvidence",
1129
1118
  withTopicScope(args, {
1130
- evidenceGlobalId: args.evidenceGlobalId,
1131
- beliefGlobalId: args.beliefGlobalId
1119
+ limit: toInt(args.limit, 50)
1132
1120
  }),
1133
1121
  args.apiBaseUrl
1134
1122
  );
1135
1123
  if (!result.success) {
1136
- return { path: null, error: result.error };
1137
- }
1138
- const pathResult = result.data?.[0];
1139
- if (!pathResult?.pathResult) {
1140
- return { path: null, error: "No path found between evidence and belief" };
1124
+ return { results: [], error: result.error };
1141
1125
  }
1142
- return {
1143
- path: {
1144
- nodes: pathResult.pathResult.nodes || [],
1145
- relationships: pathResult.pathResult.relationships || [],
1146
- length: pathResult.pathResult.length || 0
1147
- }
1148
- };
1126
+ return { results: result.data || [] };
1149
1127
  }
1150
1128
  });
1151
- var getThemeStats = action({
1129
+ var getFalsificationQuestions = action({
1152
1130
  args: {
1153
- themeGlobalId: v.string()
1131
+ limit: v.optional(v.number()),
1132
+ apiBaseUrl: v.optional(v.string()),
1133
+ topicId: v.optional(v.string())
1154
1134
  },
1155
1135
  returns: permissiveReturn,
1156
1136
  handler: async (_ctx, args) => {
1157
- const result = await callNeo4jQuery("themeStats", {
1158
- themeGlobalId: args.themeGlobalId
1159
- });
1137
+ const result = await callNeo4jQuery(
1138
+ "falsificationQuestions",
1139
+ withTopicScope(args, {
1140
+ limit: toInt(args.limit, 50)
1141
+ }),
1142
+ args.apiBaseUrl
1143
+ );
1160
1144
  if (!result.success) {
1161
- return { stats: null, error: result.error };
1145
+ return { questions: [], error: result.error };
1162
1146
  }
1163
- return { stats: result.data?.[0]?.stats || null };
1147
+ return { questions: result.data || [] };
1164
1148
  }
1165
1149
  });
1166
- var getThemeValueChainCandidates = action({
1150
+ var getConfirmationBiasScore = action({
1167
1151
  args: {
1168
1152
  limit: v.optional(v.number()),
1169
1153
  apiBaseUrl: v.optional(v.string()),
@@ -1172,307 +1156,196 @@ var getThemeValueChainCandidates = action({
1172
1156
  returns: permissiveReturn,
1173
1157
  handler: async (_ctx, args) => {
1174
1158
  const result = await callNeo4jQuery(
1175
- "themeValueChainCandidates",
1176
- withTopicScope(args, {
1177
- limit: toInt(args.limit, 100)
1178
- }),
1159
+ "confirmationBiasScore",
1160
+ {
1161
+ ...args.topicId ? { topicId: args.topicId } : {},
1162
+ limit: toInt(args.limit, 30)
1163
+ },
1179
1164
  args.apiBaseUrl
1180
1165
  );
1181
1166
  if (!result.success) {
1182
- return { candidates: [], error: result.error };
1167
+ return { results: [], error: result.error };
1183
1168
  }
1184
- return {
1185
- candidates: result.data?.map((r) => r.candidate) || []
1186
- };
1169
+ return { results: result.data || [] };
1187
1170
  }
1188
1171
  });
1189
- var getThemesImpactingCompany = action({
1172
+ var getAnchoringBiasDetection = action({
1190
1173
  args: {
1191
- companyName: v.string(),
1192
- limit: v.optional(v.number())
1174
+ limit: v.optional(v.number()),
1175
+ apiBaseUrl: v.optional(v.string()),
1176
+ topicId: v.optional(v.string())
1193
1177
  },
1194
1178
  returns: permissiveReturn,
1195
1179
  handler: async (_ctx, args) => {
1196
- const result = await callNeo4jQuery("themesImpactingCompany", {
1197
- companyName: args.companyName,
1198
- limit: toInt(args.limit, 20)
1199
- });
1180
+ const result = await callNeo4jQuery(
1181
+ "anchoringBiasDetection",
1182
+ withTopicScope(args, {
1183
+ limit: toInt(args.limit, 30)
1184
+ }),
1185
+ args.apiBaseUrl
1186
+ );
1200
1187
  if (!result.success) {
1201
1188
  return { results: [], error: result.error };
1202
1189
  }
1203
1190
  return { results: result.data || [] };
1204
1191
  }
1205
1192
  });
1206
- var getCompaniesByTheme = action({
1193
+ var getSourceConcentrationRisk = action({
1207
1194
  args: {
1208
- themeName: v.string(),
1209
- limit: v.optional(v.number())
1195
+ limit: v.optional(v.number()),
1196
+ apiBaseUrl: v.optional(v.string()),
1197
+ topicId: v.optional(v.string())
1210
1198
  },
1211
1199
  returns: permissiveReturn,
1212
1200
  handler: async (_ctx, args) => {
1213
- const result = await callNeo4jQuery("companiesByTheme", {
1214
- themeName: args.themeName,
1215
- limit: toInt(args.limit, 50)
1216
- });
1201
+ const result = await callNeo4jQuery(
1202
+ "sourceConcentrationRisk",
1203
+ withTopicScope(args, {
1204
+ limit: toInt(args.limit, 30)
1205
+ }),
1206
+ args.apiBaseUrl
1207
+ );
1217
1208
  if (!result.success) {
1218
1209
  return { results: [], error: result.error };
1219
1210
  }
1220
1211
  return { results: result.data || [] };
1221
1212
  }
1222
1213
  });
1223
- var getQuestionsByValueChain = action({
1214
+ var getMinimumFalsificationSet = action({
1224
1215
  args: {
1225
- valueChainName: v.string(),
1226
- limit: v.optional(v.number())
1216
+ apiBaseUrl: v.optional(v.string()),
1217
+ topicId: v.optional(v.string())
1227
1218
  },
1228
1219
  returns: permissiveReturn,
1229
1220
  handler: async (_ctx, args) => {
1230
- const result = await callNeo4jQuery("questionsByValueChain", {
1231
- valueChainName: args.valueChainName,
1232
- limit: toInt(args.limit, 50)
1233
- });
1221
+ const result = await callNeo4jQuery(
1222
+ "minimumFalsificationSet",
1223
+ withTopicScope(args, {}),
1224
+ args.apiBaseUrl
1225
+ );
1234
1226
  if (!result.success) {
1235
- return { results: [], error: result.error };
1227
+ return { result: null, error: result.error };
1236
1228
  }
1237
- return { results: result.data || [] };
1229
+ const data = result.data;
1230
+ return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
1238
1231
  }
1239
1232
  });
1240
- var getQuestionsByTheme = action({
1233
+ var getContradictionTensionMap = action({
1241
1234
  args: {
1242
- themeName: v.string(),
1243
- limit: v.optional(v.number())
1235
+ limit: v.optional(v.number()),
1236
+ apiBaseUrl: v.optional(v.string()),
1237
+ topicId: v.optional(v.string())
1244
1238
  },
1245
1239
  returns: permissiveReturn,
1246
1240
  handler: async (_ctx, args) => {
1247
- const result = await callNeo4jQuery("questionsByTheme", {
1248
- themeName: args.themeName,
1249
- limit: toInt(args.limit, 50)
1250
- });
1241
+ const result = await callNeo4jQuery(
1242
+ "contradictionTensionMap",
1243
+ withTopicScope(args, {
1244
+ limit: toInt(args.limit, 30)
1245
+ }),
1246
+ args.apiBaseUrl
1247
+ );
1251
1248
  if (!result.success) {
1252
1249
  return { results: [], error: result.error };
1253
1250
  }
1254
1251
  return { results: result.data || [] };
1255
1252
  }
1256
1253
  });
1257
- var getPeopleByTheme = action({
1254
+ var getReasoningDepthScore = action({
1258
1255
  args: {
1259
- themeName: v.string(),
1260
- limit: v.optional(v.number())
1261
- },
1262
- returns: permissiveReturn,
1263
- handler: async (_ctx, args) => {
1264
- const result = await callNeo4jQuery("peopleByTheme", {
1265
- themeName: args.themeName,
1266
- limit: toInt(args.limit, 50)
1267
- });
1268
- if (!result.success) {
1269
- return { results: [], error: result.error };
1270
- }
1271
- return { results: result.data || [] };
1272
- }
1273
- });
1274
- var getPeopleByCompany = action({
1275
- args: {
1276
- companyName: v.string(),
1277
- limit: v.optional(v.number())
1278
- },
1279
- returns: permissiveReturn,
1280
- handler: async (_ctx, args) => {
1281
- const result = await callNeo4jQuery("peopleByCompany", {
1282
- companyName: args.companyName,
1283
- limit: toInt(args.limit, 50)
1284
- });
1285
- if (!result.success) {
1286
- return { results: [], error: result.error };
1287
- }
1288
- return { results: result.data || [] };
1289
- }
1290
- });
1291
- var getValueChainsByTheme = action({
1292
- args: {
1293
- themeName: v.string(),
1294
- limit: v.optional(v.number())
1295
- },
1296
- returns: permissiveReturn,
1297
- handler: async (_ctx, args) => {
1298
- const result = await callNeo4jQuery("valueChainsByTheme", {
1299
- themeName: args.themeName,
1300
- limit: toInt(args.limit, 20)
1301
- });
1302
- if (!result.success) {
1303
- return { results: [], error: result.error };
1304
- }
1305
- return { results: result.data || [] };
1306
- }
1307
- });
1308
- var getFunctionsByValueChain = action({
1309
- args: {
1310
- valueChainName: v.string(),
1311
- limit: v.optional(v.number())
1312
- },
1313
- returns: permissiveReturn,
1314
- handler: async (_ctx, args) => {
1315
- const result = await callNeo4jQuery("functionsByValueChain", {
1316
- valueChainName: args.valueChainName,
1317
- limit: toInt(args.limit, 50)
1318
- });
1319
- if (!result.success) {
1320
- return { results: [], error: result.error };
1321
- }
1322
- return { results: result.data || [] };
1323
- }
1324
- });
1325
- var getBeliefsByCompany = action({
1326
- args: {
1327
- companyName: v.string(),
1328
- limit: v.optional(v.number())
1256
+ limit: v.optional(v.number()),
1257
+ apiBaseUrl: v.optional(v.string()),
1258
+ topicId: v.optional(v.string())
1329
1259
  },
1330
1260
  returns: permissiveReturn,
1331
1261
  handler: async (_ctx, args) => {
1332
- const result = await callNeo4jQuery("beliefsByCompany", {
1333
- companyName: args.companyName,
1334
- limit: toInt(args.limit, 30)
1335
- });
1262
+ const result = await callNeo4jQuery(
1263
+ "reasoningDepthScore",
1264
+ withTopicScope(args, {
1265
+ limit: toInt(args.limit, 50)
1266
+ }),
1267
+ args.apiBaseUrl
1268
+ );
1336
1269
  if (!result.success) {
1337
1270
  return { results: [], error: result.error };
1338
1271
  }
1339
1272
  return { results: result.data || [] };
1340
1273
  }
1341
1274
  });
1342
- var getEvidenceByCompany = action({
1275
+ var getKnowledgeFrontier = action({
1343
1276
  args: {
1344
- companyName: v.string(),
1345
- limit: v.optional(v.number())
1277
+ limit: v.optional(v.number()),
1278
+ apiBaseUrl: v.optional(v.string()),
1279
+ topicId: v.optional(v.string())
1346
1280
  },
1347
1281
  returns: permissiveReturn,
1348
1282
  handler: async (_ctx, args) => {
1349
- const result = await callNeo4jQuery("evidenceByCompany", {
1350
- companyName: args.companyName,
1351
- limit: toInt(args.limit, 50)
1352
- });
1283
+ const result = await callNeo4jQuery(
1284
+ "knowledgeFrontier",
1285
+ withTopicScope(args, {
1286
+ limit: toInt(args.limit, 30)
1287
+ }),
1288
+ args.apiBaseUrl
1289
+ );
1353
1290
  if (!result.success) {
1354
1291
  return { results: [], error: result.error };
1355
1292
  }
1356
1293
  return { results: result.data || [] };
1357
1294
  }
1358
1295
  });
1359
- var searchAllNodes = action({
1296
+ var getBeliefHalfLife = action({
1360
1297
  args: {
1361
- searchText: v.string(),
1362
- limit: v.optional(v.number())
1298
+ apiBaseUrl: v.optional(v.string()),
1299
+ topicId: v.optional(v.string())
1363
1300
  },
1364
1301
  returns: permissiveReturn,
1365
1302
  handler: async (_ctx, args) => {
1366
- const result = await callNeo4jQuery("searchAllNodes", {
1367
- searchText: args.searchText,
1368
- limit: toInt(args.limit, 50)
1369
- });
1303
+ const result = await callNeo4jQuery(
1304
+ "beliefHalfLife",
1305
+ withTopicScope(args, {}),
1306
+ args.apiBaseUrl
1307
+ );
1370
1308
  if (!result.success) {
1371
- return { results: [], error: result.error };
1309
+ return { result: null, error: result.error };
1372
1310
  }
1373
- return { results: result.data || [] };
1311
+ const data = result.data;
1312
+ return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
1374
1313
  }
1375
1314
  });
1376
- var getNodeRelationships = action({
1315
+ var getMeetingPrepBrief = action({
1377
1316
  args: {
1378
- globalId: v.optional(v.string()),
1379
- searchText: v.optional(v.string()),
1380
- limit: v.optional(v.number())
1317
+ personGlobalId: v.string(),
1318
+ apiBaseUrl: v.optional(v.string()),
1319
+ topicId: v.optional(v.string())
1381
1320
  },
1382
1321
  returns: permissiveReturn,
1383
1322
  handler: async (_ctx, args) => {
1384
- const result = await callNeo4jQuery("nodeRelationships", {
1385
- globalId: args.globalId || "",
1386
- searchText: args.searchText || "",
1387
- limit: toInt(args.limit, 50)
1388
- });
1389
- if (!result.success) {
1390
- return { results: [], error: result.error };
1391
- }
1392
- return { results: result.data || [] };
1393
- }
1394
- });
1395
- var getGraphStats = action({
1396
- args: {},
1397
- returns: permissiveReturn,
1398
- handler: async () => {
1399
- const result = await callNeo4jQuery("graphStats", {});
1323
+ const result = await callNeo4jQuery(
1324
+ "meetingPrepBrief",
1325
+ withTopicScope(args, {
1326
+ personGlobalId: args.personGlobalId
1327
+ }),
1328
+ args.apiBaseUrl
1329
+ );
1400
1330
  if (!result.success) {
1401
- return { stats: [], error: result.error };
1331
+ return { brief: null, error: result.error };
1402
1332
  }
1403
- return { stats: result.data || [] };
1333
+ const data = result.data;
1334
+ return { brief: Array.isArray(data) && data.length > 0 ? data[0] : null };
1404
1335
  }
1405
1336
  });
1406
- var queryGraph = action({
1337
+ var getProprietarySignals = action({
1407
1338
  args: {
1408
- queryType: v.union(
1409
- v.literal("themesImpactingCompany"),
1410
- v.literal("companiesByTheme"),
1411
- v.literal("questionsByValueChain"),
1412
- v.literal("questionsByTheme"),
1413
- v.literal("peopleByTheme"),
1414
- v.literal("peopleByCompany"),
1415
- v.literal("valueChainsByTheme"),
1416
- v.literal("functionsByValueChain"),
1417
- v.literal("beliefsByCompany"),
1418
- v.literal("evidenceByCompany"),
1419
- v.literal("searchAllNodes"),
1420
- v.literal("nodeRelationships"),
1421
- v.literal("graphStats")
1422
- ),
1423
- params: v.object({
1424
- companyName: v.optional(v.string()),
1425
- themeName: v.optional(v.string()),
1426
- valueChainName: v.optional(v.string()),
1427
- searchText: v.optional(v.string()),
1428
- globalId: v.optional(v.string()),
1429
- limit: v.optional(v.number())
1430
- }),
1339
+ limit: v.optional(v.number()),
1431
1340
  apiBaseUrl: v.optional(v.string()),
1432
1341
  topicId: v.optional(v.string())
1433
1342
  },
1434
1343
  returns: permissiveReturn,
1435
1344
  handler: async (_ctx, args) => {
1436
- const limit = toInt(args.params.limit, 30);
1437
- const themeRequiredQueries = [
1438
- "questionsByTheme",
1439
- "peopleByTheme",
1440
- "companiesByTheme",
1441
- "valueChainsByTheme"
1442
- ];
1443
- const companyRequiredQueries = [
1444
- "themesImpactingCompany",
1445
- "peopleByCompany",
1446
- "beliefsByCompany",
1447
- "evidenceByCompany"
1448
- ];
1449
- const valueChainRequiredQueries = [
1450
- "questionsByValueChain",
1451
- "functionsByValueChain"
1452
- ];
1453
- if (themeRequiredQueries.includes(args.queryType) && !args.params.themeName) {
1454
- return {
1455
- results: [],
1456
- error: `Query type '${args.queryType}' requires 'themeName' parameter`
1457
- };
1458
- }
1459
- if (companyRequiredQueries.includes(args.queryType) && !args.params.companyName) {
1460
- return {
1461
- results: [],
1462
- error: `Query type '${args.queryType}' requires 'companyName' parameter`
1463
- };
1464
- }
1465
- if (valueChainRequiredQueries.includes(args.queryType) && !args.params.valueChainName) {
1466
- return {
1467
- results: [],
1468
- error: `Query type '${args.queryType}' requires 'valueChainName' parameter`
1469
- };
1470
- }
1471
1345
  const result = await callNeo4jQuery(
1472
- args.queryType,
1346
+ "proprietarySignals",
1473
1347
  withTopicScope(args, {
1474
- ...args.params,
1475
- limit
1348
+ limit: toInt(args.limit, 30)
1476
1349
  }),
1477
1350
  args.apiBaseUrl
1478
1351
  );
@@ -1482,7 +1355,7 @@ var queryGraph = action({
1482
1355
  return { results: result.data || [] };
1483
1356
  }
1484
1357
  });
1485
- var getHighPriorityQuestions = action({
1358
+ var getPortfolioConviction = action({
1486
1359
  args: {
1487
1360
  limit: v.optional(v.number()),
1488
1361
  apiBaseUrl: v.optional(v.string()),
@@ -1491,21 +1364,20 @@ var getHighPriorityQuestions = action({
1491
1364
  returns: permissiveReturn,
1492
1365
  handler: async (_ctx, args) => {
1493
1366
  const result = await callNeo4jQuery(
1494
- "highPriorityQuestions",
1367
+ "portfolioConviction",
1495
1368
  withTopicScope(args, {
1496
1369
  limit: toInt(args.limit, 50)
1497
1370
  }),
1498
1371
  args.apiBaseUrl
1499
1372
  );
1500
1373
  if (!result.success) {
1501
- return { questions: [], error: result.error };
1374
+ return { portfolio: [], error: result.error };
1502
1375
  }
1503
- return { questions: result.data || [] };
1376
+ return { portfolio: result.data || [] };
1504
1377
  }
1505
1378
  });
1506
- var getEvidenceByMethodology = action({
1379
+ var getStaleThemes = action({
1507
1380
  args: {
1508
- methodology: v.string(),
1509
1381
  limit: v.optional(v.number()),
1510
1382
  apiBaseUrl: v.optional(v.string()),
1511
1383
  topicId: v.optional(v.string())
@@ -1513,20 +1385,19 @@ var getEvidenceByMethodology = action({
1513
1385
  returns: permissiveReturn,
1514
1386
  handler: async (_ctx, args) => {
1515
1387
  const result = await callNeo4jQuery(
1516
- "evidenceByMethodology",
1388
+ "staleThemes",
1517
1389
  withTopicScope(args, {
1518
- methodology: args.methodology,
1519
- limit: toInt(args.limit, 50)
1390
+ limit: toInt(args.limit, 30)
1520
1391
  }),
1521
1392
  args.apiBaseUrl
1522
1393
  );
1523
1394
  if (!result.success) {
1524
- return { evidence: [], error: result.error };
1395
+ return { themes: [], error: result.error };
1525
1396
  }
1526
- return { evidence: result.data || [] };
1397
+ return { themes: result.data || [] };
1527
1398
  }
1528
1399
  });
1529
- var getProprietaryEvidence = action({
1400
+ var getMissingQuestionDetection = action({
1530
1401
  args: {
1531
1402
  limit: v.optional(v.number()),
1532
1403
  apiBaseUrl: v.optional(v.string()),
@@ -1535,21 +1406,20 @@ var getProprietaryEvidence = action({
1535
1406
  returns: permissiveReturn,
1536
1407
  handler: async (_ctx, args) => {
1537
1408
  const result = await callNeo4jQuery(
1538
- "proprietaryEvidence",
1409
+ "missingQuestionDetection",
1539
1410
  withTopicScope(args, {
1540
- limit: toInt(args.limit, 50)
1411
+ limit: toInt(args.limit, 30)
1541
1412
  }),
1542
1413
  args.apiBaseUrl
1543
1414
  );
1544
1415
  if (!result.success) {
1545
- return { evidence: [], error: result.error };
1416
+ return { results: [], error: result.error };
1546
1417
  }
1547
- return { evidence: result.data || [] };
1418
+ return { results: result.data || [] };
1548
1419
  }
1549
1420
  });
1550
- var getBeliefsByEpistemicStatus = action({
1421
+ var getSurpriseDetection = action({
1551
1422
  args: {
1552
- epistemicStatus: v.string(),
1553
1423
  limit: v.optional(v.number()),
1554
1424
  apiBaseUrl: v.optional(v.string()),
1555
1425
  topicId: v.optional(v.string())
@@ -1557,20 +1427,19 @@ var getBeliefsByEpistemicStatus = action({
1557
1427
  returns: permissiveReturn,
1558
1428
  handler: async (_ctx, args) => {
1559
1429
  const result = await callNeo4jQuery(
1560
- "beliefsByEpistemicStatus",
1430
+ "surpriseDetection",
1561
1431
  withTopicScope(args, {
1562
- epistemicStatus: args.epistemicStatus,
1563
- limit: toInt(args.limit, 50)
1432
+ limit: toInt(args.limit, 30)
1564
1433
  }),
1565
1434
  args.apiBaseUrl
1566
1435
  );
1567
1436
  if (!result.success) {
1568
- return { beliefs: [], error: result.error };
1437
+ return { results: [], error: result.error };
1569
1438
  }
1570
- return { beliefs: result.data || [] };
1439
+ return { results: result.data || [] };
1571
1440
  }
1572
1441
  });
1573
- var getChallengedBeliefs = action({
1442
+ var getNonConsensusBeliefs = action({
1574
1443
  args: {
1575
1444
  limit: v.optional(v.number()),
1576
1445
  apiBaseUrl: v.optional(v.string()),
@@ -1579,41 +1448,70 @@ var getChallengedBeliefs = action({
1579
1448
  returns: permissiveReturn,
1580
1449
  handler: async (_ctx, args) => {
1581
1450
  const result = await callNeo4jQuery(
1582
- "challengedBeliefs",
1451
+ "nonConsensusBeliefs",
1583
1452
  withTopicScope(args, {
1584
1453
  limit: toInt(args.limit, 30)
1585
1454
  }),
1586
1455
  args.apiBaseUrl
1587
1456
  );
1588
1457
  if (!result.success) {
1589
- return { beliefs: [], error: result.error };
1458
+ return { results: [], error: result.error };
1590
1459
  }
1591
- return { beliefs: result.data || [] };
1460
+ return { results: result.data || [] };
1592
1461
  }
1593
1462
  });
1594
- var getPredictions = action({
1463
+ var EMBEDDING_DIMENSIONS = 1024;
1464
+ var VALID_INDEX_NAMES = /* @__PURE__ */ new Set([
1465
+ "belief_embedding_index",
1466
+ "question_embedding_index",
1467
+ "evidence_embedding_index",
1468
+ "theme_embedding_index",
1469
+ "source_embedding_index",
1470
+ "synthesis_embedding_index"
1471
+ ]);
1472
+ function clamp(value, min, max) {
1473
+ return Math.max(min, Math.min(max, value));
1474
+ }
1475
+ var semanticSearch = action({
1595
1476
  args: {
1596
- limit: v.optional(v.number()),
1477
+ embedding: v.array(v.float64()),
1478
+ indexName: v.optional(v.string()),
1479
+ topK: v.optional(v.number()),
1480
+ minScore: v.optional(v.number()),
1597
1481
  apiBaseUrl: v.optional(v.string()),
1598
1482
  topicId: v.optional(v.string())
1599
1483
  },
1600
1484
  returns: permissiveReturn,
1601
1485
  handler: async (_ctx, args) => {
1486
+ if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
1487
+ return {
1488
+ results: [],
1489
+ error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
1490
+ };
1491
+ }
1492
+ const indexName = args.indexName || "belief_embedding_index";
1493
+ if (!VALID_INDEX_NAMES.has(indexName)) {
1494
+ return { results: [], error: `Invalid index name: ${indexName}` };
1495
+ }
1602
1496
  const result = await callNeo4jQuery(
1603
- "predictions",
1604
- withTopicScope(args, {
1605
- limit: toInt(args.limit, 50)
1606
- }),
1497
+ "semanticSearch",
1498
+ {
1499
+ embedding: args.embedding,
1500
+ indexName,
1501
+ topK: toInt(args.topK, 10),
1502
+ minScore: clamp(args.minScore ?? 0.5, 0, 1)
1503
+ },
1607
1504
  args.apiBaseUrl
1608
1505
  );
1609
1506
  if (!result.success) {
1610
- return { predictions: [], error: result.error };
1507
+ return { results: [], error: result.error };
1611
1508
  }
1612
- return { predictions: result.data || [] };
1509
+ return { results: result.data || [] };
1613
1510
  }
1614
1511
  });
1615
- var getCausalChains = action({
1512
+ var getSemanticOrphans = action({
1616
1513
  args: {
1514
+ threshold: v.optional(v.number()),
1617
1515
  limit: v.optional(v.number()),
1618
1516
  apiBaseUrl: v.optional(v.string()),
1619
1517
  topicId: v.optional(v.string())
@@ -1621,20 +1519,22 @@ var getCausalChains = action({
1621
1519
  returns: permissiveReturn,
1622
1520
  handler: async (_ctx, args) => {
1623
1521
  const result = await callNeo4jQuery(
1624
- "causalChains",
1522
+ "semanticOrphans",
1625
1523
  withTopicScope(args, {
1626
- limit: toInt(args.limit, 50)
1524
+ threshold: clamp(args.threshold ?? 0.4, 0, 1),
1525
+ limit: toInt(args.limit, 20)
1627
1526
  }),
1628
1527
  args.apiBaseUrl
1629
1528
  );
1630
1529
  if (!result.success) {
1631
- return { chains: [], error: result.error };
1530
+ return { results: [], error: result.error };
1632
1531
  }
1633
- return { chains: result.data || [] };
1532
+ return { results: result.data || [] };
1634
1533
  }
1635
1534
  });
1636
- var getNecessaryEvidence = action({
1535
+ var getSoftContradictions = action({
1637
1536
  args: {
1537
+ similarityThreshold: v.optional(v.number()),
1638
1538
  limit: v.optional(v.number()),
1639
1539
  apiBaseUrl: v.optional(v.string()),
1640
1540
  topicId: v.optional(v.string())
@@ -1642,9 +1542,10 @@ var getNecessaryEvidence = action({
1642
1542
  returns: permissiveReturn,
1643
1543
  handler: async (_ctx, args) => {
1644
1544
  const result = await callNeo4jQuery(
1645
- "necessaryEvidence",
1545
+ "softContradictions",
1646
1546
  withTopicScope(args, {
1647
- limit: toInt(args.limit, 50)
1547
+ similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
1548
+ limit: toInt(args.limit, 20)
1648
1549
  }),
1649
1550
  args.apiBaseUrl
1650
1551
  );
@@ -1654,8 +1555,9 @@ var getNecessaryEvidence = action({
1654
1555
  return { results: result.data || [] };
1655
1556
  }
1656
1557
  });
1657
- var getFalsificationQuestions = action({
1558
+ var getSemanticBridges = action({
1658
1559
  args: {
1560
+ similarityThreshold: v.optional(v.number()),
1659
1561
  limit: v.optional(v.number()),
1660
1562
  apiBaseUrl: v.optional(v.string()),
1661
1563
  topicId: v.optional(v.string())
@@ -1663,32 +1565,48 @@ var getFalsificationQuestions = action({
1663
1565
  returns: permissiveReturn,
1664
1566
  handler: async (_ctx, args) => {
1665
1567
  const result = await callNeo4jQuery(
1666
- "falsificationQuestions",
1568
+ "semanticBridges",
1667
1569
  withTopicScope(args, {
1668
- limit: toInt(args.limit, 50)
1570
+ similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
1571
+ limit: toInt(args.limit, 20)
1669
1572
  }),
1670
1573
  args.apiBaseUrl
1671
1574
  );
1672
1575
  if (!result.success) {
1673
- return { questions: [], error: result.error };
1576
+ return { results: [], error: result.error };
1674
1577
  }
1675
- return { questions: result.data || [] };
1578
+ return { results: result.data || [] };
1676
1579
  }
1677
1580
  });
1678
- var getConfirmationBiasScore = action({
1581
+ var graphAwareSearch = action({
1679
1582
  args: {
1680
- limit: v.optional(v.number()),
1583
+ embedding: v.array(v.float64()),
1584
+ indexName: v.optional(v.string()),
1585
+ topK: v.optional(v.number()),
1586
+ minScore: v.optional(v.number()),
1681
1587
  apiBaseUrl: v.optional(v.string()),
1682
1588
  topicId: v.optional(v.string())
1683
1589
  },
1684
1590
  returns: permissiveReturn,
1685
1591
  handler: async (_ctx, args) => {
1592
+ if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
1593
+ return {
1594
+ results: [],
1595
+ error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
1596
+ };
1597
+ }
1598
+ const indexName = args.indexName || "belief_embedding_index";
1599
+ if (!VALID_INDEX_NAMES.has(indexName)) {
1600
+ return { results: [], error: `Invalid index name: ${indexName}` };
1601
+ }
1686
1602
  const result = await callNeo4jQuery(
1687
- "confirmationBiasScore",
1688
- {
1689
- ...args.topicId ? { topicId: args.topicId } : {},
1690
- limit: toInt(args.limit, 30)
1691
- },
1603
+ "graphAwareSearch",
1604
+ withTopicScope(args, {
1605
+ embedding: args.embedding,
1606
+ indexName,
1607
+ topK: toInt(args.topK, 10),
1608
+ minScore: clamp(args.minScore ?? 0.5, 0, 1)
1609
+ }),
1692
1610
  args.apiBaseUrl
1693
1611
  );
1694
1612
  if (!result.success) {
@@ -1697,89 +1615,100 @@ var getConfirmationBiasScore = action({
1697
1615
  return { results: result.data || [] };
1698
1616
  }
1699
1617
  });
1700
- var getAnchoringBiasDetection = action({
1618
+
1619
+ // src/neo4jQueries.ts
1620
+ var getNodeLineageGraph = action({
1701
1621
  args: {
1702
- limit: v.optional(v.number()),
1622
+ globalId: v.string(),
1703
1623
  apiBaseUrl: v.optional(v.string()),
1704
1624
  topicId: v.optional(v.string())
1705
1625
  },
1706
1626
  returns: permissiveReturn,
1707
1627
  handler: async (_ctx, args) => {
1708
1628
  const result = await callNeo4jQuery(
1709
- "anchoringBiasDetection",
1629
+ "nodeLineage",
1710
1630
  withTopicScope(args, {
1711
- limit: toInt(args.limit, 30)
1631
+ globalId: args.globalId
1712
1632
  }),
1713
1633
  args.apiBaseUrl
1714
1634
  );
1715
1635
  if (!result.success) {
1716
- return { results: [], error: result.error };
1636
+ console.error("[Neo4j] Lineage query failed:", result.error);
1637
+ return { lineage: [], error: result.error };
1717
1638
  }
1718
- return { results: result.data || [] };
1639
+ const lineage = result.data?.[0]?.lineage || [];
1640
+ return { lineage };
1719
1641
  }
1720
1642
  });
1721
- var getSourceConcentrationRisk = action({
1643
+ var getConnectedNodesGraph = action({
1722
1644
  args: {
1645
+ globalId: v.string(),
1646
+ maxHops: v.optional(v.number()),
1723
1647
  limit: v.optional(v.number()),
1724
1648
  apiBaseUrl: v.optional(v.string()),
1725
1649
  topicId: v.optional(v.string())
1726
1650
  },
1727
1651
  returns: permissiveReturn,
1728
1652
  handler: async (_ctx, args) => {
1653
+ const maxHops = Math.min(toInt(args.maxHops, 2), 5);
1654
+ const limit = toInt(args.limit, 50);
1729
1655
  const result = await callNeo4jQuery(
1730
- "sourceConcentrationRisk",
1656
+ "connectedNodes",
1731
1657
  withTopicScope(args, {
1732
- limit: toInt(args.limit, 30)
1658
+ globalId: args.globalId,
1659
+ maxHops,
1660
+ limit
1733
1661
  }),
1734
1662
  args.apiBaseUrl
1735
1663
  );
1736
1664
  if (!result.success) {
1737
- return { results: [], error: result.error };
1665
+ console.error("[Neo4j] Connected nodes query failed:", result.error);
1666
+ return { nodes: [], error: result.error };
1738
1667
  }
1739
- return { results: result.data || [] };
1668
+ return { nodes: result.data || [] };
1740
1669
  }
1741
1670
  });
1742
- var getMinimumFalsificationSet = action({
1671
+ var getThemeBeliefsGraph = action({
1743
1672
  args: {
1744
- apiBaseUrl: v.optional(v.string()),
1745
- topicId: v.optional(v.string())
1673
+ themeGlobalId: v.string()
1746
1674
  },
1747
1675
  returns: permissiveReturn,
1748
1676
  handler: async (_ctx, args) => {
1749
- const result = await callNeo4jQuery(
1750
- "minimumFalsificationSet",
1751
- withTopicScope(args, {}),
1752
- args.apiBaseUrl
1753
- );
1677
+ const result = await callNeo4jQuery("themeBeliefs", {
1678
+ themeGlobalId: args.themeGlobalId
1679
+ });
1754
1680
  if (!result.success) {
1755
- return { result: null, error: result.error };
1681
+ return { beliefs: [], error: result.error };
1756
1682
  }
1757
- const data = result.data;
1758
- return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
1683
+ return {
1684
+ beliefs: result.data?.map((r) => r.belief) || []
1685
+ };
1759
1686
  }
1760
1687
  });
1761
- var getContradictionTensionMap = action({
1688
+ var getBeliefEvidenceGraph = action({
1762
1689
  args: {
1763
- limit: v.optional(v.number()),
1690
+ beliefGlobalId: v.string(),
1764
1691
  apiBaseUrl: v.optional(v.string()),
1765
1692
  topicId: v.optional(v.string())
1766
1693
  },
1767
1694
  returns: permissiveReturn,
1768
1695
  handler: async (_ctx, args) => {
1769
1696
  const result = await callNeo4jQuery(
1770
- "contradictionTensionMap",
1697
+ "beliefEvidence",
1771
1698
  withTopicScope(args, {
1772
- limit: toInt(args.limit, 30)
1699
+ beliefGlobalId: args.beliefGlobalId
1773
1700
  }),
1774
1701
  args.apiBaseUrl
1775
1702
  );
1776
1703
  if (!result.success) {
1777
- return { results: [], error: result.error };
1704
+ return { evidence: [], error: result.error };
1778
1705
  }
1779
- return { results: result.data || [] };
1706
+ return {
1707
+ evidence: result.data?.map((r) => r.evidence) || []
1708
+ };
1780
1709
  }
1781
1710
  });
1782
- var getReasoningDepthScore = action({
1711
+ var getCrossThemeBeliefs = action({
1783
1712
  args: {
1784
1713
  limit: v.optional(v.number()),
1785
1714
  apiBaseUrl: v.optional(v.string()),
@@ -1788,19 +1717,21 @@ var getReasoningDepthScore = action({
1788
1717
  returns: permissiveReturn,
1789
1718
  handler: async (_ctx, args) => {
1790
1719
  const result = await callNeo4jQuery(
1791
- "reasoningDepthScore",
1720
+ "crossThemeBeliefs",
1792
1721
  withTopicScope(args, {
1793
- limit: toInt(args.limit, 50)
1722
+ limit: toInt(args.limit, 20)
1794
1723
  }),
1795
1724
  args.apiBaseUrl
1796
1725
  );
1797
1726
  if (!result.success) {
1798
- return { results: [], error: result.error };
1727
+ return { beliefs: [], error: result.error };
1799
1728
  }
1800
- return { results: result.data || [] };
1729
+ return {
1730
+ beliefs: result.data?.map((r) => r.belief) || []
1731
+ };
1801
1732
  }
1802
1733
  });
1803
- var getKnowledgeFrontier = action({
1734
+ var findPotentialContradictions = action({
1804
1735
  args: {
1805
1736
  limit: v.optional(v.number()),
1806
1737
  apiBaseUrl: v.optional(v.string()),
@@ -1809,60 +1740,94 @@ var getKnowledgeFrontier = action({
1809
1740
  returns: permissiveReturn,
1810
1741
  handler: async (_ctx, args) => {
1811
1742
  const result = await callNeo4jQuery(
1812
- "knowledgeFrontier",
1743
+ "potentialContradictions",
1813
1744
  withTopicScope(args, {
1814
- limit: toInt(args.limit, 30)
1745
+ limit: toInt(args.limit, 10)
1815
1746
  }),
1816
1747
  args.apiBaseUrl
1817
1748
  );
1818
1749
  if (!result.success) {
1819
- return { results: [], error: result.error };
1750
+ return { contradictions: [], error: result.error };
1820
1751
  }
1821
- return { results: result.data || [] };
1752
+ return {
1753
+ contradictions: result.data?.map(
1754
+ (r) => r.contradiction
1755
+ ) || []
1756
+ };
1822
1757
  }
1823
1758
  });
1824
- var getBeliefHalfLife = action({
1759
+ var getThemeSubgraph = action({
1825
1760
  args: {
1761
+ themeGlobalId: v.string(),
1826
1762
  apiBaseUrl: v.optional(v.string()),
1827
1763
  topicId: v.optional(v.string())
1828
1764
  },
1829
1765
  returns: permissiveReturn,
1830
1766
  handler: async (_ctx, args) => {
1831
1767
  const result = await callNeo4jQuery(
1832
- "beliefHalfLife",
1833
- withTopicScope(args, {}),
1768
+ "themeSubgraph",
1769
+ withTopicScope(args, {
1770
+ themeGlobalId: args.themeGlobalId
1771
+ }),
1834
1772
  args.apiBaseUrl
1835
1773
  );
1836
1774
  if (!result.success) {
1837
- return { result: null, error: result.error };
1775
+ return { subgraph: null, error: result.error };
1838
1776
  }
1839
- const data = result.data;
1840
- return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
1777
+ return {
1778
+ subgraph: result.data?.[0]?.subgraph || null
1779
+ };
1841
1780
  }
1842
1781
  });
1843
- var getMeetingPrepBrief = action({
1782
+ var getEvidenceToBeliefPath = action({
1844
1783
  args: {
1845
- personGlobalId: v.string(),
1784
+ evidenceGlobalId: v.string(),
1785
+ beliefGlobalId: v.string(),
1846
1786
  apiBaseUrl: v.optional(v.string()),
1847
1787
  topicId: v.optional(v.string())
1848
1788
  },
1849
1789
  returns: permissiveReturn,
1850
1790
  handler: async (_ctx, args) => {
1851
1791
  const result = await callNeo4jQuery(
1852
- "meetingPrepBrief",
1792
+ "evidenceToBeliefPath",
1853
1793
  withTopicScope(args, {
1854
- personGlobalId: args.personGlobalId
1794
+ evidenceGlobalId: args.evidenceGlobalId,
1795
+ beliefGlobalId: args.beliefGlobalId
1855
1796
  }),
1856
1797
  args.apiBaseUrl
1857
1798
  );
1858
1799
  if (!result.success) {
1859
- return { brief: null, error: result.error };
1800
+ return { path: null, error: result.error };
1860
1801
  }
1861
- const data = result.data;
1862
- return { brief: Array.isArray(data) && data.length > 0 ? data[0] : null };
1802
+ const pathResult = result.data?.[0];
1803
+ if (!pathResult?.pathResult) {
1804
+ return { path: null, error: "No path found between evidence and belief" };
1805
+ }
1806
+ return {
1807
+ path: {
1808
+ nodes: pathResult.pathResult.nodes || [],
1809
+ relationships: pathResult.pathResult.relationships || [],
1810
+ length: pathResult.pathResult.length || 0
1811
+ }
1812
+ };
1863
1813
  }
1864
1814
  });
1865
- var getProprietarySignals = action({
1815
+ var getThemeStats = action({
1816
+ args: {
1817
+ themeGlobalId: v.string()
1818
+ },
1819
+ returns: permissiveReturn,
1820
+ handler: async (_ctx, args) => {
1821
+ const result = await callNeo4jQuery("themeStats", {
1822
+ themeGlobalId: args.themeGlobalId
1823
+ });
1824
+ if (!result.success) {
1825
+ return { stats: null, error: result.error };
1826
+ }
1827
+ return { stats: result.data?.[0]?.stats || null };
1828
+ }
1829
+ });
1830
+ var getThemeValueChainCandidates = action({
1866
1831
  args: {
1867
1832
  limit: v.optional(v.number()),
1868
1833
  apiBaseUrl: v.optional(v.string()),
@@ -1871,269 +1836,307 @@ var getProprietarySignals = action({
1871
1836
  returns: permissiveReturn,
1872
1837
  handler: async (_ctx, args) => {
1873
1838
  const result = await callNeo4jQuery(
1874
- "proprietarySignals",
1839
+ "themeValueChainCandidates",
1875
1840
  withTopicScope(args, {
1876
- limit: toInt(args.limit, 30)
1841
+ limit: toInt(args.limit, 100)
1877
1842
  }),
1878
1843
  args.apiBaseUrl
1879
1844
  );
1845
+ if (!result.success) {
1846
+ return { candidates: [], error: result.error };
1847
+ }
1848
+ return {
1849
+ candidates: result.data?.map((r) => r.candidate) || []
1850
+ };
1851
+ }
1852
+ });
1853
+ var getThemesImpactingCompany = action({
1854
+ args: {
1855
+ companyName: v.string(),
1856
+ limit: v.optional(v.number())
1857
+ },
1858
+ returns: permissiveReturn,
1859
+ handler: async (_ctx, args) => {
1860
+ const result = await callNeo4jQuery("themesImpactingCompany", {
1861
+ companyName: args.companyName,
1862
+ limit: toInt(args.limit, 20)
1863
+ });
1880
1864
  if (!result.success) {
1881
1865
  return { results: [], error: result.error };
1882
1866
  }
1883
1867
  return { results: result.data || [] };
1884
1868
  }
1885
1869
  });
1886
- var getPortfolioConviction = action({
1870
+ var getCompaniesByTheme = action({
1887
1871
  args: {
1888
- limit: v.optional(v.number()),
1889
- apiBaseUrl: v.optional(v.string()),
1890
- topicId: v.optional(v.string())
1872
+ themeName: v.string(),
1873
+ limit: v.optional(v.number())
1891
1874
  },
1892
1875
  returns: permissiveReturn,
1893
1876
  handler: async (_ctx, args) => {
1894
- const result = await callNeo4jQuery(
1895
- "portfolioConviction",
1896
- withTopicScope(args, {
1897
- limit: toInt(args.limit, 50)
1898
- }),
1899
- args.apiBaseUrl
1900
- );
1877
+ const result = await callNeo4jQuery("companiesByTheme", {
1878
+ themeName: args.themeName,
1879
+ limit: toInt(args.limit, 50)
1880
+ });
1901
1881
  if (!result.success) {
1902
- return { portfolio: [], error: result.error };
1882
+ return { results: [], error: result.error };
1903
1883
  }
1904
- return { portfolio: result.data || [] };
1884
+ return { results: result.data || [] };
1905
1885
  }
1906
1886
  });
1907
- var getStaleThemes = action({
1887
+ var getQuestionsByValueChain = action({
1908
1888
  args: {
1909
- limit: v.optional(v.number()),
1910
- apiBaseUrl: v.optional(v.string()),
1911
- topicId: v.optional(v.string())
1889
+ valueChainName: v.string(),
1890
+ limit: v.optional(v.number())
1912
1891
  },
1913
1892
  returns: permissiveReturn,
1914
1893
  handler: async (_ctx, args) => {
1915
- const result = await callNeo4jQuery(
1916
- "staleThemes",
1917
- withTopicScope(args, {
1918
- limit: toInt(args.limit, 30)
1919
- }),
1920
- args.apiBaseUrl
1921
- );
1894
+ const result = await callNeo4jQuery("questionsByValueChain", {
1895
+ valueChainName: args.valueChainName,
1896
+ limit: toInt(args.limit, 50)
1897
+ });
1922
1898
  if (!result.success) {
1923
- return { themes: [], error: result.error };
1899
+ return { results: [], error: result.error };
1924
1900
  }
1925
- return { themes: result.data || [] };
1901
+ return { results: result.data || [] };
1926
1902
  }
1927
1903
  });
1928
- var getMissingQuestionDetection = action({
1904
+ var getQuestionsByTheme = action({
1929
1905
  args: {
1930
- limit: v.optional(v.number()),
1931
- apiBaseUrl: v.optional(v.string()),
1932
- topicId: v.optional(v.string())
1906
+ themeName: v.string(),
1907
+ limit: v.optional(v.number())
1933
1908
  },
1934
1909
  returns: permissiveReturn,
1935
1910
  handler: async (_ctx, args) => {
1936
- const result = await callNeo4jQuery(
1937
- "missingQuestionDetection",
1938
- withTopicScope(args, {
1939
- limit: toInt(args.limit, 30)
1940
- }),
1941
- args.apiBaseUrl
1942
- );
1911
+ const result = await callNeo4jQuery("questionsByTheme", {
1912
+ themeName: args.themeName,
1913
+ limit: toInt(args.limit, 50)
1914
+ });
1943
1915
  if (!result.success) {
1944
1916
  return { results: [], error: result.error };
1945
1917
  }
1946
1918
  return { results: result.data || [] };
1947
1919
  }
1948
1920
  });
1949
- var getSurpriseDetection = action({
1921
+ var getPeopleByTheme = action({
1950
1922
  args: {
1951
- limit: v.optional(v.number()),
1952
- apiBaseUrl: v.optional(v.string()),
1953
- topicId: v.optional(v.string())
1923
+ themeName: v.string(),
1924
+ limit: v.optional(v.number())
1954
1925
  },
1955
1926
  returns: permissiveReturn,
1956
1927
  handler: async (_ctx, args) => {
1957
- const result = await callNeo4jQuery(
1958
- "surpriseDetection",
1959
- withTopicScope(args, {
1960
- limit: toInt(args.limit, 30)
1961
- }),
1962
- args.apiBaseUrl
1963
- );
1928
+ const result = await callNeo4jQuery("peopleByTheme", {
1929
+ themeName: args.themeName,
1930
+ limit: toInt(args.limit, 50)
1931
+ });
1964
1932
  if (!result.success) {
1965
1933
  return { results: [], error: result.error };
1966
1934
  }
1967
1935
  return { results: result.data || [] };
1968
1936
  }
1969
1937
  });
1970
- var getNonConsensusBeliefs = action({
1938
+ var getPeopleByCompany = action({
1971
1939
  args: {
1972
- limit: v.optional(v.number()),
1973
- apiBaseUrl: v.optional(v.string()),
1974
- topicId: v.optional(v.string())
1940
+ companyName: v.string(),
1941
+ limit: v.optional(v.number())
1975
1942
  },
1976
1943
  returns: permissiveReturn,
1977
1944
  handler: async (_ctx, args) => {
1978
- const result = await callNeo4jQuery(
1979
- "nonConsensusBeliefs",
1980
- withTopicScope(args, {
1981
- limit: toInt(args.limit, 30)
1982
- }),
1983
- args.apiBaseUrl
1984
- );
1945
+ const result = await callNeo4jQuery("peopleByCompany", {
1946
+ companyName: args.companyName,
1947
+ limit: toInt(args.limit, 50)
1948
+ });
1985
1949
  if (!result.success) {
1986
1950
  return { results: [], error: result.error };
1987
1951
  }
1988
1952
  return { results: result.data || [] };
1989
1953
  }
1990
1954
  });
1991
- var EMBEDDING_DIMENSIONS = 1024;
1992
- var VALID_INDEX_NAMES = /* @__PURE__ */ new Set([
1993
- "belief_embedding_index",
1994
- "question_embedding_index",
1995
- "evidence_embedding_index",
1996
- "theme_embedding_index",
1997
- "source_embedding_index",
1998
- "synthesis_embedding_index"
1999
- ]);
2000
- function clamp(value, min, max) {
2001
- return Math.max(min, Math.min(max, value));
2002
- }
2003
- var semanticSearch = action({
1955
+ var getValueChainsByTheme = action({
2004
1956
  args: {
2005
- embedding: v.array(v.float64()),
2006
- indexName: v.optional(v.string()),
2007
- topK: v.optional(v.number()),
2008
- minScore: v.optional(v.number()),
2009
- apiBaseUrl: v.optional(v.string()),
2010
- topicId: v.optional(v.string())
1957
+ themeName: v.string(),
1958
+ limit: v.optional(v.number())
2011
1959
  },
2012
1960
  returns: permissiveReturn,
2013
1961
  handler: async (_ctx, args) => {
2014
- if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
2015
- return {
2016
- results: [],
2017
- error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
2018
- };
1962
+ const result = await callNeo4jQuery("valueChainsByTheme", {
1963
+ themeName: args.themeName,
1964
+ limit: toInt(args.limit, 20)
1965
+ });
1966
+ if (!result.success) {
1967
+ return { results: [], error: result.error };
2019
1968
  }
2020
- const indexName = args.indexName || "belief_embedding_index";
2021
- if (!VALID_INDEX_NAMES.has(indexName)) {
2022
- return { results: [], error: `Invalid index name: ${indexName}` };
1969
+ return { results: result.data || [] };
1970
+ }
1971
+ });
1972
+ var getFunctionsByValueChain = action({
1973
+ args: {
1974
+ valueChainName: v.string(),
1975
+ limit: v.optional(v.number())
1976
+ },
1977
+ returns: permissiveReturn,
1978
+ handler: async (_ctx, args) => {
1979
+ const result = await callNeo4jQuery("functionsByValueChain", {
1980
+ valueChainName: args.valueChainName,
1981
+ limit: toInt(args.limit, 50)
1982
+ });
1983
+ if (!result.success) {
1984
+ return { results: [], error: result.error };
2023
1985
  }
2024
- const result = await callNeo4jQuery(
2025
- "semanticSearch",
2026
- {
2027
- embedding: args.embedding,
2028
- indexName,
2029
- topK: toInt(args.topK, 10),
2030
- minScore: clamp(args.minScore ?? 0.5, 0, 1)
2031
- },
2032
- args.apiBaseUrl
2033
- );
1986
+ return { results: result.data || [] };
1987
+ }
1988
+ });
1989
+ var getBeliefsByCompany = action({
1990
+ args: {
1991
+ companyName: v.string(),
1992
+ limit: v.optional(v.number())
1993
+ },
1994
+ returns: permissiveReturn,
1995
+ handler: async (_ctx, args) => {
1996
+ const result = await callNeo4jQuery("beliefsByCompany", {
1997
+ companyName: args.companyName,
1998
+ limit: toInt(args.limit, 30)
1999
+ });
2034
2000
  if (!result.success) {
2035
2001
  return { results: [], error: result.error };
2036
2002
  }
2037
2003
  return { results: result.data || [] };
2038
2004
  }
2039
2005
  });
2040
- var getSemanticOrphans = action({
2006
+ var getEvidenceByCompany = action({
2041
2007
  args: {
2042
- threshold: v.optional(v.number()),
2043
- limit: v.optional(v.number()),
2044
- apiBaseUrl: v.optional(v.string()),
2045
- topicId: v.optional(v.string())
2008
+ companyName: v.string(),
2009
+ limit: v.optional(v.number())
2046
2010
  },
2047
2011
  returns: permissiveReturn,
2048
2012
  handler: async (_ctx, args) => {
2049
- const result = await callNeo4jQuery(
2050
- "semanticOrphans",
2051
- withTopicScope(args, {
2052
- threshold: clamp(args.threshold ?? 0.4, 0, 1),
2053
- limit: toInt(args.limit, 20)
2054
- }),
2055
- args.apiBaseUrl
2056
- );
2013
+ const result = await callNeo4jQuery("evidenceByCompany", {
2014
+ companyName: args.companyName,
2015
+ limit: toInt(args.limit, 50)
2016
+ });
2057
2017
  if (!result.success) {
2058
2018
  return { results: [], error: result.error };
2059
2019
  }
2060
2020
  return { results: result.data || [] };
2061
2021
  }
2062
2022
  });
2063
- var getSoftContradictions = action({
2023
+ var searchAllNodes = action({
2064
2024
  args: {
2065
- similarityThreshold: v.optional(v.number()),
2066
- limit: v.optional(v.number()),
2067
- apiBaseUrl: v.optional(v.string()),
2068
- topicId: v.optional(v.string())
2025
+ searchText: v.string(),
2026
+ limit: v.optional(v.number())
2069
2027
  },
2070
2028
  returns: permissiveReturn,
2071
2029
  handler: async (_ctx, args) => {
2072
- const result = await callNeo4jQuery(
2073
- "softContradictions",
2074
- withTopicScope(args, {
2075
- similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
2076
- limit: toInt(args.limit, 20)
2077
- }),
2078
- args.apiBaseUrl
2079
- );
2030
+ const result = await callNeo4jQuery("searchAllNodes", {
2031
+ searchText: args.searchText,
2032
+ limit: toInt(args.limit, 50)
2033
+ });
2080
2034
  if (!result.success) {
2081
2035
  return { results: [], error: result.error };
2082
2036
  }
2083
2037
  return { results: result.data || [] };
2084
2038
  }
2085
2039
  });
2086
- var getSemanticBridges = action({
2040
+ var getNodeRelationships = action({
2087
2041
  args: {
2088
- similarityThreshold: v.optional(v.number()),
2089
- limit: v.optional(v.number()),
2090
- apiBaseUrl: v.optional(v.string()),
2091
- topicId: v.optional(v.string())
2042
+ globalId: v.optional(v.string()),
2043
+ searchText: v.optional(v.string()),
2044
+ limit: v.optional(v.number())
2092
2045
  },
2093
2046
  returns: permissiveReturn,
2094
2047
  handler: async (_ctx, args) => {
2095
- const result = await callNeo4jQuery(
2096
- "semanticBridges",
2097
- withTopicScope(args, {
2098
- similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
2099
- limit: toInt(args.limit, 20)
2100
- }),
2101
- args.apiBaseUrl
2102
- );
2048
+ const result = await callNeo4jQuery("nodeRelationships", {
2049
+ globalId: args.globalId || "",
2050
+ searchText: args.searchText || "",
2051
+ limit: toInt(args.limit, 50)
2052
+ });
2103
2053
  if (!result.success) {
2104
2054
  return { results: [], error: result.error };
2105
2055
  }
2106
2056
  return { results: result.data || [] };
2107
2057
  }
2108
2058
  });
2109
- var graphAwareSearch = action({
2059
+ var getGraphStats = action({
2060
+ args: {},
2061
+ returns: permissiveReturn,
2062
+ handler: async () => {
2063
+ const result = await callNeo4jQuery("graphStats", {});
2064
+ if (!result.success) {
2065
+ return { stats: [], error: result.error };
2066
+ }
2067
+ return { stats: result.data || [] };
2068
+ }
2069
+ });
2070
+ var queryGraph = action({
2110
2071
  args: {
2111
- embedding: v.array(v.float64()),
2112
- indexName: v.optional(v.string()),
2113
- topK: v.optional(v.number()),
2114
- minScore: v.optional(v.number()),
2072
+ queryType: v.union(
2073
+ v.literal("themesImpactingCompany"),
2074
+ v.literal("companiesByTheme"),
2075
+ v.literal("questionsByValueChain"),
2076
+ v.literal("questionsByTheme"),
2077
+ v.literal("peopleByTheme"),
2078
+ v.literal("peopleByCompany"),
2079
+ v.literal("valueChainsByTheme"),
2080
+ v.literal("functionsByValueChain"),
2081
+ v.literal("beliefsByCompany"),
2082
+ v.literal("evidenceByCompany"),
2083
+ v.literal("searchAllNodes"),
2084
+ v.literal("nodeRelationships"),
2085
+ v.literal("graphStats")
2086
+ ),
2087
+ params: v.object({
2088
+ companyName: v.optional(v.string()),
2089
+ themeName: v.optional(v.string()),
2090
+ valueChainName: v.optional(v.string()),
2091
+ searchText: v.optional(v.string()),
2092
+ globalId: v.optional(v.string()),
2093
+ limit: v.optional(v.number())
2094
+ }),
2115
2095
  apiBaseUrl: v.optional(v.string()),
2116
2096
  topicId: v.optional(v.string())
2117
2097
  },
2118
2098
  returns: permissiveReturn,
2119
2099
  handler: async (_ctx, args) => {
2120
- if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
2100
+ const limit = toInt(args.params.limit, 30);
2101
+ const themeRequiredQueries = [
2102
+ "questionsByTheme",
2103
+ "peopleByTheme",
2104
+ "companiesByTheme",
2105
+ "valueChainsByTheme"
2106
+ ];
2107
+ const companyRequiredQueries = [
2108
+ "themesImpactingCompany",
2109
+ "peopleByCompany",
2110
+ "beliefsByCompany",
2111
+ "evidenceByCompany"
2112
+ ];
2113
+ const valueChainRequiredQueries = [
2114
+ "questionsByValueChain",
2115
+ "functionsByValueChain"
2116
+ ];
2117
+ if (themeRequiredQueries.includes(args.queryType) && !args.params.themeName) {
2121
2118
  return {
2122
2119
  results: [],
2123
- error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
2120
+ error: `Query type '${args.queryType}' requires 'themeName' parameter`
2124
2121
  };
2125
2122
  }
2126
- const indexName = args.indexName || "belief_embedding_index";
2127
- if (!VALID_INDEX_NAMES.has(indexName)) {
2128
- return { results: [], error: `Invalid index name: ${indexName}` };
2123
+ if (companyRequiredQueries.includes(args.queryType) && !args.params.companyName) {
2124
+ return {
2125
+ results: [],
2126
+ error: `Query type '${args.queryType}' requires 'companyName' parameter`
2127
+ };
2128
+ }
2129
+ if (valueChainRequiredQueries.includes(args.queryType) && !args.params.valueChainName) {
2130
+ return {
2131
+ results: [],
2132
+ error: `Query type '${args.queryType}' requires 'valueChainName' parameter`
2133
+ };
2129
2134
  }
2130
2135
  const result = await callNeo4jQuery(
2131
- "graphAwareSearch",
2136
+ args.queryType,
2132
2137
  withTopicScope(args, {
2133
- embedding: args.embedding,
2134
- indexName,
2135
- topK: toInt(args.topK, 10),
2136
- minScore: clamp(args.minScore ?? 0.5, 0, 1)
2138
+ ...args.params,
2139
+ limit
2137
2140
  }),
2138
2141
  args.apiBaseUrl
2139
2142
  );