@lucern/graph-sync 1.0.0 → 1.0.2

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.
@@ -1,12 +1,11 @@
1
1
  import { v } from 'convex/values';
2
2
  import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
3
- import { componentsGeneric, actionGeneric } from 'convex/server';
3
+ import { actionGeneric } from 'convex/server';
4
4
 
5
5
  // src/neo4jQueries.ts
6
- componentsGeneric();
7
6
  var action = actionGeneric;
8
7
 
9
- // src/neo4jQueries.ts
8
+ // src/neo4jQueriesCore.ts
10
9
  function toInt(value, defaultValue) {
11
10
  if (value === void 0 || value === null) {
12
11
  return defaultValue;
@@ -55,6 +54,9 @@ function buildProxyEndpoint(proxyBaseUrl) {
55
54
  }
56
55
  return endpoint.toString();
57
56
  }
57
+ function withTopicScope(args, params) {
58
+ return args.topicId ? { ...params, topicId: args.topicId } : params;
59
+ }
58
60
  async function callNeo4jQuery(queryName, params, apiBaseUrl) {
59
61
  const proxyUrl = resolveProxyBaseUrl(apiBaseUrl);
60
62
  if (!proxyUrl) {
@@ -128,101 +130,95 @@ async function callNeo4jQuery(queryName, params, apiBaseUrl) {
128
130
  );
129
131
  }
130
132
  }
131
- function withTopicScope(args, params) {
132
- return args.topicId ? { ...params, topicId: args.topicId } : params;
133
- }
134
- var getNodeLineageGraph = action({
133
+ var getHighPriorityQuestions = action({
135
134
  args: {
136
- globalId: v.string(),
135
+ limit: v.optional(v.number()),
137
136
  apiBaseUrl: v.optional(v.string()),
138
137
  topicId: v.optional(v.string())
139
138
  },
140
139
  returns: permissiveReturn,
141
140
  handler: async (_ctx, args) => {
142
141
  const result = await callNeo4jQuery(
143
- "nodeLineage",
142
+ "highPriorityQuestions",
144
143
  withTopicScope(args, {
145
- globalId: args.globalId
144
+ limit: toInt(args.limit, 50)
146
145
  }),
147
146
  args.apiBaseUrl
148
147
  );
149
148
  if (!result.success) {
150
- console.error("[Neo4j] Lineage query failed:", result.error);
151
- return { lineage: [], error: result.error };
149
+ return { questions: [], error: result.error };
152
150
  }
153
- const lineage = result.data?.[0]?.lineage || [];
154
- return { lineage };
151
+ return { questions: result.data || [] };
155
152
  }
156
153
  });
157
- var getConnectedNodesGraph = action({
154
+ var getEvidenceByMethodology = action({
158
155
  args: {
159
- globalId: v.string(),
160
- maxHops: v.optional(v.number()),
156
+ methodology: v.string(),
161
157
  limit: v.optional(v.number()),
162
158
  apiBaseUrl: v.optional(v.string()),
163
159
  topicId: v.optional(v.string())
164
160
  },
165
161
  returns: permissiveReturn,
166
162
  handler: async (_ctx, args) => {
167
- const maxHops = Math.min(toInt(args.maxHops, 2), 5);
168
- const limit = toInt(args.limit, 50);
169
163
  const result = await callNeo4jQuery(
170
- "connectedNodes",
164
+ "evidenceByMethodology",
171
165
  withTopicScope(args, {
172
- globalId: args.globalId,
173
- maxHops,
174
- limit
166
+ methodology: args.methodology,
167
+ limit: toInt(args.limit, 50)
175
168
  }),
176
169
  args.apiBaseUrl
177
170
  );
178
171
  if (!result.success) {
179
- console.error("[Neo4j] Connected nodes query failed:", result.error);
180
- return { nodes: [], error: result.error };
172
+ return { evidence: [], error: result.error };
181
173
  }
182
- return { nodes: result.data || [] };
174
+ return { evidence: result.data || [] };
183
175
  }
184
176
  });
185
- var getThemeBeliefsGraph = action({
177
+ var getProprietaryEvidence = action({
186
178
  args: {
187
- themeGlobalId: v.string()
179
+ limit: v.optional(v.number()),
180
+ apiBaseUrl: v.optional(v.string()),
181
+ topicId: v.optional(v.string())
188
182
  },
189
183
  returns: permissiveReturn,
190
184
  handler: async (_ctx, args) => {
191
- const result = await callNeo4jQuery("themeBeliefs", {
192
- themeGlobalId: args.themeGlobalId
193
- });
185
+ const result = await callNeo4jQuery(
186
+ "proprietaryEvidence",
187
+ withTopicScope(args, {
188
+ limit: toInt(args.limit, 50)
189
+ }),
190
+ args.apiBaseUrl
191
+ );
194
192
  if (!result.success) {
195
- return { beliefs: [], error: result.error };
193
+ return { evidence: [], error: result.error };
196
194
  }
197
- return {
198
- beliefs: result.data?.map((r) => r.belief) || []
199
- };
195
+ return { evidence: result.data || [] };
200
196
  }
201
197
  });
202
- var getBeliefEvidenceGraph = action({
198
+ var getBeliefsByEpistemicStatus = action({
203
199
  args: {
204
- beliefGlobalId: v.string(),
200
+ epistemicStatus: v.string(),
201
+ limit: v.optional(v.number()),
205
202
  apiBaseUrl: v.optional(v.string()),
206
203
  topicId: v.optional(v.string())
207
204
  },
208
205
  returns: permissiveReturn,
209
206
  handler: async (_ctx, args) => {
210
207
  const result = await callNeo4jQuery(
211
- "beliefEvidence",
208
+ "beliefsByEpistemicStatus",
212
209
  withTopicScope(args, {
213
- beliefGlobalId: args.beliefGlobalId
210
+ epistemicStatus: args.epistemicStatus,
211
+ limit: toInt(args.limit, 50)
214
212
  }),
215
213
  args.apiBaseUrl
216
214
  );
217
215
  if (!result.success) {
218
- return { evidence: [], error: result.error };
216
+ return { beliefs: [], error: result.error };
219
217
  }
220
- return {
221
- evidence: result.data?.map((r) => r.evidence) || []
222
- };
218
+ return { beliefs: result.data || [] };
223
219
  }
224
220
  });
225
- var getCrossThemeBeliefs = action({
221
+ var getChallengedBeliefs = action({
226
222
  args: {
227
223
  limit: v.optional(v.number()),
228
224
  apiBaseUrl: v.optional(v.string()),
@@ -231,21 +227,19 @@ var getCrossThemeBeliefs = action({
231
227
  returns: permissiveReturn,
232
228
  handler: async (_ctx, args) => {
233
229
  const result = await callNeo4jQuery(
234
- "crossThemeBeliefs",
230
+ "challengedBeliefs",
235
231
  withTopicScope(args, {
236
- limit: toInt(args.limit, 20)
232
+ limit: toInt(args.limit, 30)
237
233
  }),
238
234
  args.apiBaseUrl
239
235
  );
240
236
  if (!result.success) {
241
237
  return { beliefs: [], error: result.error };
242
238
  }
243
- return {
244
- beliefs: result.data?.map((r) => r.belief) || []
245
- };
239
+ return { beliefs: result.data || [] };
246
240
  }
247
241
  });
248
- var findPotentialContradictions = action({
242
+ var getPredictions = action({
249
243
  args: {
250
244
  limit: v.optional(v.number()),
251
245
  apiBaseUrl: v.optional(v.string()),
@@ -254,94 +248,82 @@ var findPotentialContradictions = action({
254
248
  returns: permissiveReturn,
255
249
  handler: async (_ctx, args) => {
256
250
  const result = await callNeo4jQuery(
257
- "potentialContradictions",
251
+ "predictions",
258
252
  withTopicScope(args, {
259
- limit: toInt(args.limit, 10)
253
+ limit: toInt(args.limit, 50)
260
254
  }),
261
255
  args.apiBaseUrl
262
256
  );
263
257
  if (!result.success) {
264
- return { contradictions: [], error: result.error };
258
+ return { predictions: [], error: result.error };
265
259
  }
266
- return {
267
- contradictions: result.data?.map(
268
- (r) => r.contradiction
269
- ) || []
270
- };
260
+ return { predictions: result.data || [] };
271
261
  }
272
262
  });
273
- var getThemeSubgraph = action({
263
+ var getCausalChains = action({
274
264
  args: {
275
- themeGlobalId: v.string(),
265
+ limit: v.optional(v.number()),
276
266
  apiBaseUrl: v.optional(v.string()),
277
267
  topicId: v.optional(v.string())
278
268
  },
279
269
  returns: permissiveReturn,
280
270
  handler: async (_ctx, args) => {
281
271
  const result = await callNeo4jQuery(
282
- "themeSubgraph",
272
+ "causalChains",
283
273
  withTopicScope(args, {
284
- themeGlobalId: args.themeGlobalId
274
+ limit: toInt(args.limit, 50)
285
275
  }),
286
276
  args.apiBaseUrl
287
277
  );
288
278
  if (!result.success) {
289
- return { subgraph: null, error: result.error };
279
+ return { chains: [], error: result.error };
290
280
  }
291
- return {
292
- subgraph: result.data?.[0]?.subgraph || null
293
- };
281
+ return { chains: result.data || [] };
294
282
  }
295
283
  });
296
- var getEvidenceToBeliefPath = action({
284
+ var getNecessaryEvidence = action({
297
285
  args: {
298
- evidenceGlobalId: v.string(),
299
- beliefGlobalId: v.string(),
286
+ limit: v.optional(v.number()),
300
287
  apiBaseUrl: v.optional(v.string()),
301
288
  topicId: v.optional(v.string())
302
289
  },
303
290
  returns: permissiveReturn,
304
291
  handler: async (_ctx, args) => {
305
292
  const result = await callNeo4jQuery(
306
- "evidenceToBeliefPath",
293
+ "necessaryEvidence",
307
294
  withTopicScope(args, {
308
- evidenceGlobalId: args.evidenceGlobalId,
309
- beliefGlobalId: args.beliefGlobalId
295
+ limit: toInt(args.limit, 50)
310
296
  }),
311
297
  args.apiBaseUrl
312
298
  );
313
299
  if (!result.success) {
314
- return { path: null, error: result.error };
315
- }
316
- const pathResult = result.data?.[0];
317
- if (!pathResult?.pathResult) {
318
- return { path: null, error: "No path found between evidence and belief" };
300
+ return { results: [], error: result.error };
319
301
  }
320
- return {
321
- path: {
322
- nodes: pathResult.pathResult.nodes || [],
323
- relationships: pathResult.pathResult.relationships || [],
324
- length: pathResult.pathResult.length || 0
325
- }
326
- };
302
+ return { results: result.data || [] };
327
303
  }
328
304
  });
329
- var getThemeStats = action({
305
+ var getFalsificationQuestions = action({
330
306
  args: {
331
- themeGlobalId: v.string()
307
+ limit: v.optional(v.number()),
308
+ apiBaseUrl: v.optional(v.string()),
309
+ topicId: v.optional(v.string())
332
310
  },
333
311
  returns: permissiveReturn,
334
312
  handler: async (_ctx, args) => {
335
- const result = await callNeo4jQuery("themeStats", {
336
- themeGlobalId: args.themeGlobalId
337
- });
313
+ const result = await callNeo4jQuery(
314
+ "falsificationQuestions",
315
+ withTopicScope(args, {
316
+ limit: toInt(args.limit, 50)
317
+ }),
318
+ args.apiBaseUrl
319
+ );
338
320
  if (!result.success) {
339
- return { stats: null, error: result.error };
321
+ return { questions: [], error: result.error };
340
322
  }
341
- return { stats: result.data?.[0]?.stats || null };
323
+ return { questions: result.data || [] };
342
324
  }
343
325
  });
344
- var getThemeValueChainCandidates = action({
326
+ var getConfirmationBiasScore = action({
345
327
  args: {
346
328
  limit: v.optional(v.number()),
347
329
  apiBaseUrl: v.optional(v.string()),
@@ -350,307 +332,196 @@ var getThemeValueChainCandidates = action({
350
332
  returns: permissiveReturn,
351
333
  handler: async (_ctx, args) => {
352
334
  const result = await callNeo4jQuery(
353
- "themeValueChainCandidates",
354
- withTopicScope(args, {
355
- limit: toInt(args.limit, 100)
356
- }),
335
+ "confirmationBiasScore",
336
+ {
337
+ ...args.topicId ? { topicId: args.topicId } : {},
338
+ limit: toInt(args.limit, 30)
339
+ },
357
340
  args.apiBaseUrl
358
341
  );
359
342
  if (!result.success) {
360
- return { candidates: [], error: result.error };
343
+ return { results: [], error: result.error };
361
344
  }
362
- return {
363
- candidates: result.data?.map((r) => r.candidate) || []
364
- };
345
+ return { results: result.data || [] };
365
346
  }
366
347
  });
367
- var getThemesImpactingCompany = action({
348
+ var getAnchoringBiasDetection = action({
368
349
  args: {
369
- companyName: v.string(),
370
- limit: v.optional(v.number())
350
+ limit: v.optional(v.number()),
351
+ apiBaseUrl: v.optional(v.string()),
352
+ topicId: v.optional(v.string())
371
353
  },
372
354
  returns: permissiveReturn,
373
355
  handler: async (_ctx, args) => {
374
- const result = await callNeo4jQuery("themesImpactingCompany", {
375
- companyName: args.companyName,
376
- limit: toInt(args.limit, 20)
377
- });
356
+ const result = await callNeo4jQuery(
357
+ "anchoringBiasDetection",
358
+ withTopicScope(args, {
359
+ limit: toInt(args.limit, 30)
360
+ }),
361
+ args.apiBaseUrl
362
+ );
378
363
  if (!result.success) {
379
364
  return { results: [], error: result.error };
380
365
  }
381
366
  return { results: result.data || [] };
382
367
  }
383
368
  });
384
- var getCompaniesByTheme = action({
369
+ var getSourceConcentrationRisk = action({
385
370
  args: {
386
- themeName: v.string(),
387
- limit: v.optional(v.number())
371
+ limit: v.optional(v.number()),
372
+ apiBaseUrl: v.optional(v.string()),
373
+ topicId: v.optional(v.string())
388
374
  },
389
375
  returns: permissiveReturn,
390
376
  handler: async (_ctx, args) => {
391
- const result = await callNeo4jQuery("companiesByTheme", {
392
- themeName: args.themeName,
393
- limit: toInt(args.limit, 50)
394
- });
377
+ const result = await callNeo4jQuery(
378
+ "sourceConcentrationRisk",
379
+ withTopicScope(args, {
380
+ limit: toInt(args.limit, 30)
381
+ }),
382
+ args.apiBaseUrl
383
+ );
395
384
  if (!result.success) {
396
385
  return { results: [], error: result.error };
397
386
  }
398
387
  return { results: result.data || [] };
399
388
  }
400
389
  });
401
- var getQuestionsByValueChain = action({
390
+ var getMinimumFalsificationSet = action({
402
391
  args: {
403
- valueChainName: v.string(),
404
- limit: v.optional(v.number())
392
+ apiBaseUrl: v.optional(v.string()),
393
+ topicId: v.optional(v.string())
405
394
  },
406
395
  returns: permissiveReturn,
407
396
  handler: async (_ctx, args) => {
408
- const result = await callNeo4jQuery("questionsByValueChain", {
409
- valueChainName: args.valueChainName,
410
- limit: toInt(args.limit, 50)
411
- });
397
+ const result = await callNeo4jQuery(
398
+ "minimumFalsificationSet",
399
+ withTopicScope(args, {}),
400
+ args.apiBaseUrl
401
+ );
412
402
  if (!result.success) {
413
- return { results: [], error: result.error };
403
+ return { result: null, error: result.error };
414
404
  }
415
- return { results: result.data || [] };
405
+ const data = result.data;
406
+ return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
416
407
  }
417
408
  });
418
- var getQuestionsByTheme = action({
409
+ var getContradictionTensionMap = action({
419
410
  args: {
420
- themeName: v.string(),
421
- limit: v.optional(v.number())
411
+ limit: v.optional(v.number()),
412
+ apiBaseUrl: v.optional(v.string()),
413
+ topicId: v.optional(v.string())
422
414
  },
423
415
  returns: permissiveReturn,
424
416
  handler: async (_ctx, args) => {
425
- const result = await callNeo4jQuery("questionsByTheme", {
426
- themeName: args.themeName,
427
- limit: toInt(args.limit, 50)
428
- });
417
+ const result = await callNeo4jQuery(
418
+ "contradictionTensionMap",
419
+ withTopicScope(args, {
420
+ limit: toInt(args.limit, 30)
421
+ }),
422
+ args.apiBaseUrl
423
+ );
429
424
  if (!result.success) {
430
425
  return { results: [], error: result.error };
431
426
  }
432
427
  return { results: result.data || [] };
433
428
  }
434
429
  });
435
- var getPeopleByTheme = action({
430
+ var getReasoningDepthScore = action({
436
431
  args: {
437
- themeName: v.string(),
438
- limit: v.optional(v.number())
439
- },
440
- returns: permissiveReturn,
441
- handler: async (_ctx, args) => {
442
- const result = await callNeo4jQuery("peopleByTheme", {
443
- themeName: args.themeName,
444
- limit: toInt(args.limit, 50)
445
- });
446
- if (!result.success) {
447
- return { results: [], error: result.error };
448
- }
449
- return { results: result.data || [] };
450
- }
451
- });
452
- var getPeopleByCompany = action({
453
- args: {
454
- companyName: v.string(),
455
- limit: v.optional(v.number())
456
- },
457
- returns: permissiveReturn,
458
- handler: async (_ctx, args) => {
459
- const result = await callNeo4jQuery("peopleByCompany", {
460
- companyName: args.companyName,
461
- limit: toInt(args.limit, 50)
462
- });
463
- if (!result.success) {
464
- return { results: [], error: result.error };
465
- }
466
- return { results: result.data || [] };
467
- }
468
- });
469
- var getValueChainsByTheme = action({
470
- args: {
471
- themeName: v.string(),
472
- limit: v.optional(v.number())
473
- },
474
- returns: permissiveReturn,
475
- handler: async (_ctx, args) => {
476
- const result = await callNeo4jQuery("valueChainsByTheme", {
477
- themeName: args.themeName,
478
- limit: toInt(args.limit, 20)
479
- });
480
- if (!result.success) {
481
- return { results: [], error: result.error };
482
- }
483
- return { results: result.data || [] };
484
- }
485
- });
486
- var getFunctionsByValueChain = action({
487
- args: {
488
- valueChainName: v.string(),
489
- limit: v.optional(v.number())
490
- },
491
- returns: permissiveReturn,
492
- handler: async (_ctx, args) => {
493
- const result = await callNeo4jQuery("functionsByValueChain", {
494
- valueChainName: args.valueChainName,
495
- limit: toInt(args.limit, 50)
496
- });
497
- if (!result.success) {
498
- return { results: [], error: result.error };
499
- }
500
- return { results: result.data || [] };
501
- }
502
- });
503
- var getBeliefsByCompany = action({
504
- args: {
505
- companyName: v.string(),
506
- limit: v.optional(v.number())
432
+ limit: v.optional(v.number()),
433
+ apiBaseUrl: v.optional(v.string()),
434
+ topicId: v.optional(v.string())
507
435
  },
508
436
  returns: permissiveReturn,
509
437
  handler: async (_ctx, args) => {
510
- const result = await callNeo4jQuery("beliefsByCompany", {
511
- companyName: args.companyName,
512
- limit: toInt(args.limit, 30)
513
- });
438
+ const result = await callNeo4jQuery(
439
+ "reasoningDepthScore",
440
+ withTopicScope(args, {
441
+ limit: toInt(args.limit, 50)
442
+ }),
443
+ args.apiBaseUrl
444
+ );
514
445
  if (!result.success) {
515
446
  return { results: [], error: result.error };
516
447
  }
517
448
  return { results: result.data || [] };
518
449
  }
519
450
  });
520
- var getEvidenceByCompany = action({
451
+ var getKnowledgeFrontier = action({
521
452
  args: {
522
- companyName: v.string(),
523
- limit: v.optional(v.number())
453
+ limit: v.optional(v.number()),
454
+ apiBaseUrl: v.optional(v.string()),
455
+ topicId: v.optional(v.string())
524
456
  },
525
457
  returns: permissiveReturn,
526
458
  handler: async (_ctx, args) => {
527
- const result = await callNeo4jQuery("evidenceByCompany", {
528
- companyName: args.companyName,
529
- limit: toInt(args.limit, 50)
530
- });
459
+ const result = await callNeo4jQuery(
460
+ "knowledgeFrontier",
461
+ withTopicScope(args, {
462
+ limit: toInt(args.limit, 30)
463
+ }),
464
+ args.apiBaseUrl
465
+ );
531
466
  if (!result.success) {
532
467
  return { results: [], error: result.error };
533
468
  }
534
469
  return { results: result.data || [] };
535
470
  }
536
471
  });
537
- var searchAllNodes = action({
472
+ var getBeliefHalfLife = action({
538
473
  args: {
539
- searchText: v.string(),
540
- limit: v.optional(v.number())
474
+ apiBaseUrl: v.optional(v.string()),
475
+ topicId: v.optional(v.string())
541
476
  },
542
477
  returns: permissiveReturn,
543
478
  handler: async (_ctx, args) => {
544
- const result = await callNeo4jQuery("searchAllNodes", {
545
- searchText: args.searchText,
546
- limit: toInt(args.limit, 50)
547
- });
479
+ const result = await callNeo4jQuery(
480
+ "beliefHalfLife",
481
+ withTopicScope(args, {}),
482
+ args.apiBaseUrl
483
+ );
548
484
  if (!result.success) {
549
- return { results: [], error: result.error };
485
+ return { result: null, error: result.error };
550
486
  }
551
- return { results: result.data || [] };
487
+ const data = result.data;
488
+ return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
552
489
  }
553
490
  });
554
- var getNodeRelationships = action({
491
+ var getMeetingPrepBrief = action({
555
492
  args: {
556
- globalId: v.optional(v.string()),
557
- searchText: v.optional(v.string()),
558
- limit: v.optional(v.number())
493
+ personGlobalId: v.string(),
494
+ apiBaseUrl: v.optional(v.string()),
495
+ topicId: v.optional(v.string())
559
496
  },
560
497
  returns: permissiveReturn,
561
498
  handler: async (_ctx, args) => {
562
- const result = await callNeo4jQuery("nodeRelationships", {
563
- globalId: args.globalId || "",
564
- searchText: args.searchText || "",
565
- limit: toInt(args.limit, 50)
566
- });
567
- if (!result.success) {
568
- return { results: [], error: result.error };
569
- }
570
- return { results: result.data || [] };
571
- }
572
- });
573
- var getGraphStats = action({
574
- args: {},
575
- returns: permissiveReturn,
576
- handler: async () => {
577
- const result = await callNeo4jQuery("graphStats", {});
499
+ const result = await callNeo4jQuery(
500
+ "meetingPrepBrief",
501
+ withTopicScope(args, {
502
+ personGlobalId: args.personGlobalId
503
+ }),
504
+ args.apiBaseUrl
505
+ );
578
506
  if (!result.success) {
579
- return { stats: [], error: result.error };
507
+ return { brief: null, error: result.error };
580
508
  }
581
- return { stats: result.data || [] };
509
+ const data = result.data;
510
+ return { brief: Array.isArray(data) && data.length > 0 ? data[0] : null };
582
511
  }
583
512
  });
584
- var queryGraph = action({
513
+ var getProprietarySignals = action({
585
514
  args: {
586
- queryType: v.union(
587
- v.literal("themesImpactingCompany"),
588
- v.literal("companiesByTheme"),
589
- v.literal("questionsByValueChain"),
590
- v.literal("questionsByTheme"),
591
- v.literal("peopleByTheme"),
592
- v.literal("peopleByCompany"),
593
- v.literal("valueChainsByTheme"),
594
- v.literal("functionsByValueChain"),
595
- v.literal("beliefsByCompany"),
596
- v.literal("evidenceByCompany"),
597
- v.literal("searchAllNodes"),
598
- v.literal("nodeRelationships"),
599
- v.literal("graphStats")
600
- ),
601
- params: v.object({
602
- companyName: v.optional(v.string()),
603
- themeName: v.optional(v.string()),
604
- valueChainName: v.optional(v.string()),
605
- searchText: v.optional(v.string()),
606
- globalId: v.optional(v.string()),
607
- limit: v.optional(v.number())
608
- }),
515
+ limit: v.optional(v.number()),
609
516
  apiBaseUrl: v.optional(v.string()),
610
517
  topicId: v.optional(v.string())
611
518
  },
612
519
  returns: permissiveReturn,
613
520
  handler: async (_ctx, args) => {
614
- const limit = toInt(args.params.limit, 30);
615
- const themeRequiredQueries = [
616
- "questionsByTheme",
617
- "peopleByTheme",
618
- "companiesByTheme",
619
- "valueChainsByTheme"
620
- ];
621
- const companyRequiredQueries = [
622
- "themesImpactingCompany",
623
- "peopleByCompany",
624
- "beliefsByCompany",
625
- "evidenceByCompany"
626
- ];
627
- const valueChainRequiredQueries = [
628
- "questionsByValueChain",
629
- "functionsByValueChain"
630
- ];
631
- if (themeRequiredQueries.includes(args.queryType) && !args.params.themeName) {
632
- return {
633
- results: [],
634
- error: `Query type '${args.queryType}' requires 'themeName' parameter`
635
- };
636
- }
637
- if (companyRequiredQueries.includes(args.queryType) && !args.params.companyName) {
638
- return {
639
- results: [],
640
- error: `Query type '${args.queryType}' requires 'companyName' parameter`
641
- };
642
- }
643
- if (valueChainRequiredQueries.includes(args.queryType) && !args.params.valueChainName) {
644
- return {
645
- results: [],
646
- error: `Query type '${args.queryType}' requires 'valueChainName' parameter`
647
- };
648
- }
649
521
  const result = await callNeo4jQuery(
650
- args.queryType,
522
+ "proprietarySignals",
651
523
  withTopicScope(args, {
652
- ...args.params,
653
- limit
524
+ limit: toInt(args.limit, 30)
654
525
  }),
655
526
  args.apiBaseUrl
656
527
  );
@@ -660,7 +531,7 @@ var queryGraph = action({
660
531
  return { results: result.data || [] };
661
532
  }
662
533
  });
663
- var getHighPriorityQuestions = action({
534
+ var getPortfolioConviction = action({
664
535
  args: {
665
536
  limit: v.optional(v.number()),
666
537
  apiBaseUrl: v.optional(v.string()),
@@ -669,21 +540,20 @@ var getHighPriorityQuestions = action({
669
540
  returns: permissiveReturn,
670
541
  handler: async (_ctx, args) => {
671
542
  const result = await callNeo4jQuery(
672
- "highPriorityQuestions",
543
+ "portfolioConviction",
673
544
  withTopicScope(args, {
674
545
  limit: toInt(args.limit, 50)
675
546
  }),
676
547
  args.apiBaseUrl
677
548
  );
678
549
  if (!result.success) {
679
- return { questions: [], error: result.error };
550
+ return { portfolio: [], error: result.error };
680
551
  }
681
- return { questions: result.data || [] };
552
+ return { portfolio: result.data || [] };
682
553
  }
683
554
  });
684
- var getEvidenceByMethodology = action({
555
+ var getStaleThemes = action({
685
556
  args: {
686
- methodology: v.string(),
687
557
  limit: v.optional(v.number()),
688
558
  apiBaseUrl: v.optional(v.string()),
689
559
  topicId: v.optional(v.string())
@@ -691,20 +561,19 @@ var getEvidenceByMethodology = action({
691
561
  returns: permissiveReturn,
692
562
  handler: async (_ctx, args) => {
693
563
  const result = await callNeo4jQuery(
694
- "evidenceByMethodology",
564
+ "staleThemes",
695
565
  withTopicScope(args, {
696
- methodology: args.methodology,
697
- limit: toInt(args.limit, 50)
566
+ limit: toInt(args.limit, 30)
698
567
  }),
699
568
  args.apiBaseUrl
700
569
  );
701
570
  if (!result.success) {
702
- return { evidence: [], error: result.error };
571
+ return { themes: [], error: result.error };
703
572
  }
704
- return { evidence: result.data || [] };
573
+ return { themes: result.data || [] };
705
574
  }
706
575
  });
707
- var getProprietaryEvidence = action({
576
+ var getMissingQuestionDetection = action({
708
577
  args: {
709
578
  limit: v.optional(v.number()),
710
579
  apiBaseUrl: v.optional(v.string()),
@@ -713,21 +582,20 @@ var getProprietaryEvidence = action({
713
582
  returns: permissiveReturn,
714
583
  handler: async (_ctx, args) => {
715
584
  const result = await callNeo4jQuery(
716
- "proprietaryEvidence",
585
+ "missingQuestionDetection",
717
586
  withTopicScope(args, {
718
- limit: toInt(args.limit, 50)
587
+ limit: toInt(args.limit, 30)
719
588
  }),
720
589
  args.apiBaseUrl
721
590
  );
722
591
  if (!result.success) {
723
- return { evidence: [], error: result.error };
592
+ return { results: [], error: result.error };
724
593
  }
725
- return { evidence: result.data || [] };
594
+ return { results: result.data || [] };
726
595
  }
727
596
  });
728
- var getBeliefsByEpistemicStatus = action({
597
+ var getSurpriseDetection = action({
729
598
  args: {
730
- epistemicStatus: v.string(),
731
599
  limit: v.optional(v.number()),
732
600
  apiBaseUrl: v.optional(v.string()),
733
601
  topicId: v.optional(v.string())
@@ -735,20 +603,19 @@ var getBeliefsByEpistemicStatus = action({
735
603
  returns: permissiveReturn,
736
604
  handler: async (_ctx, args) => {
737
605
  const result = await callNeo4jQuery(
738
- "beliefsByEpistemicStatus",
606
+ "surpriseDetection",
739
607
  withTopicScope(args, {
740
- epistemicStatus: args.epistemicStatus,
741
- limit: toInt(args.limit, 50)
608
+ limit: toInt(args.limit, 30)
742
609
  }),
743
610
  args.apiBaseUrl
744
611
  );
745
612
  if (!result.success) {
746
- return { beliefs: [], error: result.error };
613
+ return { results: [], error: result.error };
747
614
  }
748
- return { beliefs: result.data || [] };
615
+ return { results: result.data || [] };
749
616
  }
750
617
  });
751
- var getChallengedBeliefs = action({
618
+ var getNonConsensusBeliefs = action({
752
619
  args: {
753
620
  limit: v.optional(v.number()),
754
621
  apiBaseUrl: v.optional(v.string()),
@@ -757,41 +624,70 @@ var getChallengedBeliefs = action({
757
624
  returns: permissiveReturn,
758
625
  handler: async (_ctx, args) => {
759
626
  const result = await callNeo4jQuery(
760
- "challengedBeliefs",
627
+ "nonConsensusBeliefs",
761
628
  withTopicScope(args, {
762
629
  limit: toInt(args.limit, 30)
763
630
  }),
764
631
  args.apiBaseUrl
765
632
  );
766
633
  if (!result.success) {
767
- return { beliefs: [], error: result.error };
634
+ return { results: [], error: result.error };
768
635
  }
769
- return { beliefs: result.data || [] };
636
+ return { results: result.data || [] };
770
637
  }
771
638
  });
772
- var getPredictions = action({
639
+ var EMBEDDING_DIMENSIONS = 1024;
640
+ var VALID_INDEX_NAMES = /* @__PURE__ */ new Set([
641
+ "belief_embedding_index",
642
+ "question_embedding_index",
643
+ "evidence_embedding_index",
644
+ "theme_embedding_index",
645
+ "source_embedding_index",
646
+ "synthesis_embedding_index"
647
+ ]);
648
+ function clamp(value, min, max) {
649
+ return Math.max(min, Math.min(max, value));
650
+ }
651
+ var semanticSearch = action({
773
652
  args: {
774
- limit: v.optional(v.number()),
653
+ embedding: v.array(v.float64()),
654
+ indexName: v.optional(v.string()),
655
+ topK: v.optional(v.number()),
656
+ minScore: v.optional(v.number()),
775
657
  apiBaseUrl: v.optional(v.string()),
776
658
  topicId: v.optional(v.string())
777
659
  },
778
660
  returns: permissiveReturn,
779
661
  handler: async (_ctx, args) => {
662
+ if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
663
+ return {
664
+ results: [],
665
+ error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
666
+ };
667
+ }
668
+ const indexName = args.indexName || "belief_embedding_index";
669
+ if (!VALID_INDEX_NAMES.has(indexName)) {
670
+ return { results: [], error: `Invalid index name: ${indexName}` };
671
+ }
780
672
  const result = await callNeo4jQuery(
781
- "predictions",
782
- withTopicScope(args, {
783
- limit: toInt(args.limit, 50)
784
- }),
673
+ "semanticSearch",
674
+ {
675
+ embedding: args.embedding,
676
+ indexName,
677
+ topK: toInt(args.topK, 10),
678
+ minScore: clamp(args.minScore ?? 0.5, 0, 1)
679
+ },
785
680
  args.apiBaseUrl
786
681
  );
787
682
  if (!result.success) {
788
- return { predictions: [], error: result.error };
683
+ return { results: [], error: result.error };
789
684
  }
790
- return { predictions: result.data || [] };
685
+ return { results: result.data || [] };
791
686
  }
792
687
  });
793
- var getCausalChains = action({
688
+ var getSemanticOrphans = action({
794
689
  args: {
690
+ threshold: v.optional(v.number()),
795
691
  limit: v.optional(v.number()),
796
692
  apiBaseUrl: v.optional(v.string()),
797
693
  topicId: v.optional(v.string())
@@ -799,20 +695,22 @@ var getCausalChains = action({
799
695
  returns: permissiveReturn,
800
696
  handler: async (_ctx, args) => {
801
697
  const result = await callNeo4jQuery(
802
- "causalChains",
698
+ "semanticOrphans",
803
699
  withTopicScope(args, {
804
- limit: toInt(args.limit, 50)
700
+ threshold: clamp(args.threshold ?? 0.4, 0, 1),
701
+ limit: toInt(args.limit, 20)
805
702
  }),
806
703
  args.apiBaseUrl
807
704
  );
808
705
  if (!result.success) {
809
- return { chains: [], error: result.error };
706
+ return { results: [], error: result.error };
810
707
  }
811
- return { chains: result.data || [] };
708
+ return { results: result.data || [] };
812
709
  }
813
710
  });
814
- var getNecessaryEvidence = action({
711
+ var getSoftContradictions = action({
815
712
  args: {
713
+ similarityThreshold: v.optional(v.number()),
816
714
  limit: v.optional(v.number()),
817
715
  apiBaseUrl: v.optional(v.string()),
818
716
  topicId: v.optional(v.string())
@@ -820,9 +718,10 @@ var getNecessaryEvidence = action({
820
718
  returns: permissiveReturn,
821
719
  handler: async (_ctx, args) => {
822
720
  const result = await callNeo4jQuery(
823
- "necessaryEvidence",
721
+ "softContradictions",
824
722
  withTopicScope(args, {
825
- limit: toInt(args.limit, 50)
723
+ similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
724
+ limit: toInt(args.limit, 20)
826
725
  }),
827
726
  args.apiBaseUrl
828
727
  );
@@ -832,8 +731,9 @@ var getNecessaryEvidence = action({
832
731
  return { results: result.data || [] };
833
732
  }
834
733
  });
835
- var getFalsificationQuestions = action({
734
+ var getSemanticBridges = action({
836
735
  args: {
736
+ similarityThreshold: v.optional(v.number()),
837
737
  limit: v.optional(v.number()),
838
738
  apiBaseUrl: v.optional(v.string()),
839
739
  topicId: v.optional(v.string())
@@ -841,32 +741,48 @@ var getFalsificationQuestions = action({
841
741
  returns: permissiveReturn,
842
742
  handler: async (_ctx, args) => {
843
743
  const result = await callNeo4jQuery(
844
- "falsificationQuestions",
744
+ "semanticBridges",
845
745
  withTopicScope(args, {
846
- limit: toInt(args.limit, 50)
746
+ similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
747
+ limit: toInt(args.limit, 20)
847
748
  }),
848
749
  args.apiBaseUrl
849
750
  );
850
751
  if (!result.success) {
851
- return { questions: [], error: result.error };
752
+ return { results: [], error: result.error };
852
753
  }
853
- return { questions: result.data || [] };
754
+ return { results: result.data || [] };
854
755
  }
855
756
  });
856
- var getConfirmationBiasScore = action({
757
+ var graphAwareSearch = action({
857
758
  args: {
858
- limit: v.optional(v.number()),
759
+ embedding: v.array(v.float64()),
760
+ indexName: v.optional(v.string()),
761
+ topK: v.optional(v.number()),
762
+ minScore: v.optional(v.number()),
859
763
  apiBaseUrl: v.optional(v.string()),
860
764
  topicId: v.optional(v.string())
861
765
  },
862
766
  returns: permissiveReturn,
863
767
  handler: async (_ctx, args) => {
768
+ if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
769
+ return {
770
+ results: [],
771
+ error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
772
+ };
773
+ }
774
+ const indexName = args.indexName || "belief_embedding_index";
775
+ if (!VALID_INDEX_NAMES.has(indexName)) {
776
+ return { results: [], error: `Invalid index name: ${indexName}` };
777
+ }
864
778
  const result = await callNeo4jQuery(
865
- "confirmationBiasScore",
866
- {
867
- ...args.topicId ? { topicId: args.topicId } : {},
868
- limit: toInt(args.limit, 30)
869
- },
779
+ "graphAwareSearch",
780
+ withTopicScope(args, {
781
+ embedding: args.embedding,
782
+ indexName,
783
+ topK: toInt(args.topK, 10),
784
+ minScore: clamp(args.minScore ?? 0.5, 0, 1)
785
+ }),
870
786
  args.apiBaseUrl
871
787
  );
872
788
  if (!result.success) {
@@ -875,89 +791,100 @@ var getConfirmationBiasScore = action({
875
791
  return { results: result.data || [] };
876
792
  }
877
793
  });
878
- var getAnchoringBiasDetection = action({
794
+
795
+ // src/neo4jQueries.ts
796
+ var getNodeLineageGraph = action({
879
797
  args: {
880
- limit: v.optional(v.number()),
798
+ globalId: v.string(),
881
799
  apiBaseUrl: v.optional(v.string()),
882
800
  topicId: v.optional(v.string())
883
801
  },
884
802
  returns: permissiveReturn,
885
803
  handler: async (_ctx, args) => {
886
804
  const result = await callNeo4jQuery(
887
- "anchoringBiasDetection",
805
+ "nodeLineage",
888
806
  withTopicScope(args, {
889
- limit: toInt(args.limit, 30)
807
+ globalId: args.globalId
890
808
  }),
891
809
  args.apiBaseUrl
892
810
  );
893
811
  if (!result.success) {
894
- return { results: [], error: result.error };
812
+ console.error("[Neo4j] Lineage query failed:", result.error);
813
+ return { lineage: [], error: result.error };
895
814
  }
896
- return { results: result.data || [] };
815
+ const lineage = result.data?.[0]?.lineage || [];
816
+ return { lineage };
897
817
  }
898
818
  });
899
- var getSourceConcentrationRisk = action({
819
+ var getConnectedNodesGraph = action({
900
820
  args: {
821
+ globalId: v.string(),
822
+ maxHops: v.optional(v.number()),
901
823
  limit: v.optional(v.number()),
902
824
  apiBaseUrl: v.optional(v.string()),
903
825
  topicId: v.optional(v.string())
904
826
  },
905
827
  returns: permissiveReturn,
906
828
  handler: async (_ctx, args) => {
829
+ const maxHops = Math.min(toInt(args.maxHops, 2), 5);
830
+ const limit = toInt(args.limit, 50);
907
831
  const result = await callNeo4jQuery(
908
- "sourceConcentrationRisk",
832
+ "connectedNodes",
909
833
  withTopicScope(args, {
910
- limit: toInt(args.limit, 30)
834
+ globalId: args.globalId,
835
+ maxHops,
836
+ limit
911
837
  }),
912
838
  args.apiBaseUrl
913
839
  );
914
840
  if (!result.success) {
915
- return { results: [], error: result.error };
841
+ console.error("[Neo4j] Connected nodes query failed:", result.error);
842
+ return { nodes: [], error: result.error };
916
843
  }
917
- return { results: result.data || [] };
844
+ return { nodes: result.data || [] };
918
845
  }
919
846
  });
920
- var getMinimumFalsificationSet = action({
847
+ var getThemeBeliefsGraph = action({
921
848
  args: {
922
- apiBaseUrl: v.optional(v.string()),
923
- topicId: v.optional(v.string())
849
+ themeGlobalId: v.string()
924
850
  },
925
851
  returns: permissiveReturn,
926
852
  handler: async (_ctx, args) => {
927
- const result = await callNeo4jQuery(
928
- "minimumFalsificationSet",
929
- withTopicScope(args, {}),
930
- args.apiBaseUrl
931
- );
853
+ const result = await callNeo4jQuery("themeBeliefs", {
854
+ themeGlobalId: args.themeGlobalId
855
+ });
932
856
  if (!result.success) {
933
- return { result: null, error: result.error };
857
+ return { beliefs: [], error: result.error };
934
858
  }
935
- const data = result.data;
936
- return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
859
+ return {
860
+ beliefs: result.data?.map((r) => r.belief) || []
861
+ };
937
862
  }
938
863
  });
939
- var getContradictionTensionMap = action({
864
+ var getBeliefEvidenceGraph = action({
940
865
  args: {
941
- limit: v.optional(v.number()),
866
+ beliefGlobalId: v.string(),
942
867
  apiBaseUrl: v.optional(v.string()),
943
868
  topicId: v.optional(v.string())
944
869
  },
945
870
  returns: permissiveReturn,
946
871
  handler: async (_ctx, args) => {
947
872
  const result = await callNeo4jQuery(
948
- "contradictionTensionMap",
873
+ "beliefEvidence",
949
874
  withTopicScope(args, {
950
- limit: toInt(args.limit, 30)
875
+ beliefGlobalId: args.beliefGlobalId
951
876
  }),
952
877
  args.apiBaseUrl
953
878
  );
954
879
  if (!result.success) {
955
- return { results: [], error: result.error };
880
+ return { evidence: [], error: result.error };
956
881
  }
957
- return { results: result.data || [] };
882
+ return {
883
+ evidence: result.data?.map((r) => r.evidence) || []
884
+ };
958
885
  }
959
886
  });
960
- var getReasoningDepthScore = action({
887
+ var getCrossThemeBeliefs = action({
961
888
  args: {
962
889
  limit: v.optional(v.number()),
963
890
  apiBaseUrl: v.optional(v.string()),
@@ -966,19 +893,21 @@ var getReasoningDepthScore = action({
966
893
  returns: permissiveReturn,
967
894
  handler: async (_ctx, args) => {
968
895
  const result = await callNeo4jQuery(
969
- "reasoningDepthScore",
896
+ "crossThemeBeliefs",
970
897
  withTopicScope(args, {
971
- limit: toInt(args.limit, 50)
898
+ limit: toInt(args.limit, 20)
972
899
  }),
973
900
  args.apiBaseUrl
974
901
  );
975
902
  if (!result.success) {
976
- return { results: [], error: result.error };
903
+ return { beliefs: [], error: result.error };
977
904
  }
978
- return { results: result.data || [] };
905
+ return {
906
+ beliefs: result.data?.map((r) => r.belief) || []
907
+ };
979
908
  }
980
909
  });
981
- var getKnowledgeFrontier = action({
910
+ var findPotentialContradictions = action({
982
911
  args: {
983
912
  limit: v.optional(v.number()),
984
913
  apiBaseUrl: v.optional(v.string()),
@@ -987,60 +916,94 @@ var getKnowledgeFrontier = action({
987
916
  returns: permissiveReturn,
988
917
  handler: async (_ctx, args) => {
989
918
  const result = await callNeo4jQuery(
990
- "knowledgeFrontier",
919
+ "potentialContradictions",
991
920
  withTopicScope(args, {
992
- limit: toInt(args.limit, 30)
921
+ limit: toInt(args.limit, 10)
993
922
  }),
994
923
  args.apiBaseUrl
995
924
  );
996
925
  if (!result.success) {
997
- return { results: [], error: result.error };
926
+ return { contradictions: [], error: result.error };
998
927
  }
999
- return { results: result.data || [] };
928
+ return {
929
+ contradictions: result.data?.map(
930
+ (r) => r.contradiction
931
+ ) || []
932
+ };
1000
933
  }
1001
934
  });
1002
- var getBeliefHalfLife = action({
935
+ var getThemeSubgraph = action({
1003
936
  args: {
937
+ themeGlobalId: v.string(),
1004
938
  apiBaseUrl: v.optional(v.string()),
1005
939
  topicId: v.optional(v.string())
1006
940
  },
1007
941
  returns: permissiveReturn,
1008
942
  handler: async (_ctx, args) => {
1009
943
  const result = await callNeo4jQuery(
1010
- "beliefHalfLife",
1011
- withTopicScope(args, {}),
944
+ "themeSubgraph",
945
+ withTopicScope(args, {
946
+ themeGlobalId: args.themeGlobalId
947
+ }),
1012
948
  args.apiBaseUrl
1013
949
  );
1014
950
  if (!result.success) {
1015
- return { result: null, error: result.error };
951
+ return { subgraph: null, error: result.error };
1016
952
  }
1017
- const data = result.data;
1018
- return { result: Array.isArray(data) && data.length > 0 ? data[0] : null };
953
+ return {
954
+ subgraph: result.data?.[0]?.subgraph || null
955
+ };
1019
956
  }
1020
957
  });
1021
- var getMeetingPrepBrief = action({
958
+ var getEvidenceToBeliefPath = action({
1022
959
  args: {
1023
- personGlobalId: v.string(),
960
+ evidenceGlobalId: v.string(),
961
+ beliefGlobalId: v.string(),
1024
962
  apiBaseUrl: v.optional(v.string()),
1025
963
  topicId: v.optional(v.string())
1026
964
  },
1027
965
  returns: permissiveReturn,
1028
966
  handler: async (_ctx, args) => {
1029
967
  const result = await callNeo4jQuery(
1030
- "meetingPrepBrief",
968
+ "evidenceToBeliefPath",
1031
969
  withTopicScope(args, {
1032
- personGlobalId: args.personGlobalId
970
+ evidenceGlobalId: args.evidenceGlobalId,
971
+ beliefGlobalId: args.beliefGlobalId
1033
972
  }),
1034
973
  args.apiBaseUrl
1035
974
  );
1036
975
  if (!result.success) {
1037
- return { brief: null, error: result.error };
976
+ return { path: null, error: result.error };
1038
977
  }
1039
- const data = result.data;
1040
- return { brief: Array.isArray(data) && data.length > 0 ? data[0] : null };
978
+ const pathResult = result.data?.[0];
979
+ if (!pathResult?.pathResult) {
980
+ return { path: null, error: "No path found between evidence and belief" };
981
+ }
982
+ return {
983
+ path: {
984
+ nodes: pathResult.pathResult.nodes || [],
985
+ relationships: pathResult.pathResult.relationships || [],
986
+ length: pathResult.pathResult.length || 0
987
+ }
988
+ };
1041
989
  }
1042
990
  });
1043
- var getProprietarySignals = action({
991
+ var getThemeStats = action({
992
+ args: {
993
+ themeGlobalId: v.string()
994
+ },
995
+ returns: permissiveReturn,
996
+ handler: async (_ctx, args) => {
997
+ const result = await callNeo4jQuery("themeStats", {
998
+ themeGlobalId: args.themeGlobalId
999
+ });
1000
+ if (!result.success) {
1001
+ return { stats: null, error: result.error };
1002
+ }
1003
+ return { stats: result.data?.[0]?.stats || null };
1004
+ }
1005
+ });
1006
+ var getThemeValueChainCandidates = action({
1044
1007
  args: {
1045
1008
  limit: v.optional(v.number()),
1046
1009
  apiBaseUrl: v.optional(v.string()),
@@ -1049,269 +1012,307 @@ var getProprietarySignals = action({
1049
1012
  returns: permissiveReturn,
1050
1013
  handler: async (_ctx, args) => {
1051
1014
  const result = await callNeo4jQuery(
1052
- "proprietarySignals",
1015
+ "themeValueChainCandidates",
1053
1016
  withTopicScope(args, {
1054
- limit: toInt(args.limit, 30)
1017
+ limit: toInt(args.limit, 100)
1055
1018
  }),
1056
1019
  args.apiBaseUrl
1057
1020
  );
1021
+ if (!result.success) {
1022
+ return { candidates: [], error: result.error };
1023
+ }
1024
+ return {
1025
+ candidates: result.data?.map((r) => r.candidate) || []
1026
+ };
1027
+ }
1028
+ });
1029
+ var getThemesImpactingCompany = action({
1030
+ args: {
1031
+ companyName: v.string(),
1032
+ limit: v.optional(v.number())
1033
+ },
1034
+ returns: permissiveReturn,
1035
+ handler: async (_ctx, args) => {
1036
+ const result = await callNeo4jQuery("themesImpactingCompany", {
1037
+ companyName: args.companyName,
1038
+ limit: toInt(args.limit, 20)
1039
+ });
1058
1040
  if (!result.success) {
1059
1041
  return { results: [], error: result.error };
1060
1042
  }
1061
1043
  return { results: result.data || [] };
1062
1044
  }
1063
1045
  });
1064
- var getPortfolioConviction = action({
1046
+ var getCompaniesByTheme = action({
1065
1047
  args: {
1066
- limit: v.optional(v.number()),
1067
- apiBaseUrl: v.optional(v.string()),
1068
- topicId: v.optional(v.string())
1048
+ themeName: v.string(),
1049
+ limit: v.optional(v.number())
1069
1050
  },
1070
1051
  returns: permissiveReturn,
1071
1052
  handler: async (_ctx, args) => {
1072
- const result = await callNeo4jQuery(
1073
- "portfolioConviction",
1074
- withTopicScope(args, {
1075
- limit: toInt(args.limit, 50)
1076
- }),
1077
- args.apiBaseUrl
1078
- );
1053
+ const result = await callNeo4jQuery("companiesByTheme", {
1054
+ themeName: args.themeName,
1055
+ limit: toInt(args.limit, 50)
1056
+ });
1079
1057
  if (!result.success) {
1080
- return { portfolio: [], error: result.error };
1058
+ return { results: [], error: result.error };
1081
1059
  }
1082
- return { portfolio: result.data || [] };
1060
+ return { results: result.data || [] };
1083
1061
  }
1084
1062
  });
1085
- var getStaleThemes = action({
1063
+ var getQuestionsByValueChain = action({
1086
1064
  args: {
1087
- limit: v.optional(v.number()),
1088
- apiBaseUrl: v.optional(v.string()),
1089
- topicId: v.optional(v.string())
1065
+ valueChainName: v.string(),
1066
+ limit: v.optional(v.number())
1090
1067
  },
1091
1068
  returns: permissiveReturn,
1092
1069
  handler: async (_ctx, args) => {
1093
- const result = await callNeo4jQuery(
1094
- "staleThemes",
1095
- withTopicScope(args, {
1096
- limit: toInt(args.limit, 30)
1097
- }),
1098
- args.apiBaseUrl
1099
- );
1070
+ const result = await callNeo4jQuery("questionsByValueChain", {
1071
+ valueChainName: args.valueChainName,
1072
+ limit: toInt(args.limit, 50)
1073
+ });
1100
1074
  if (!result.success) {
1101
- return { themes: [], error: result.error };
1075
+ return { results: [], error: result.error };
1102
1076
  }
1103
- return { themes: result.data || [] };
1077
+ return { results: result.data || [] };
1104
1078
  }
1105
1079
  });
1106
- var getMissingQuestionDetection = action({
1080
+ var getQuestionsByTheme = action({
1107
1081
  args: {
1108
- limit: v.optional(v.number()),
1109
- apiBaseUrl: v.optional(v.string()),
1110
- topicId: v.optional(v.string())
1082
+ themeName: v.string(),
1083
+ limit: v.optional(v.number())
1111
1084
  },
1112
1085
  returns: permissiveReturn,
1113
1086
  handler: async (_ctx, args) => {
1114
- const result = await callNeo4jQuery(
1115
- "missingQuestionDetection",
1116
- withTopicScope(args, {
1117
- limit: toInt(args.limit, 30)
1118
- }),
1119
- args.apiBaseUrl
1120
- );
1087
+ const result = await callNeo4jQuery("questionsByTheme", {
1088
+ themeName: args.themeName,
1089
+ limit: toInt(args.limit, 50)
1090
+ });
1121
1091
  if (!result.success) {
1122
1092
  return { results: [], error: result.error };
1123
1093
  }
1124
1094
  return { results: result.data || [] };
1125
1095
  }
1126
1096
  });
1127
- var getSurpriseDetection = action({
1097
+ var getPeopleByTheme = action({
1128
1098
  args: {
1129
- limit: v.optional(v.number()),
1130
- apiBaseUrl: v.optional(v.string()),
1131
- topicId: v.optional(v.string())
1099
+ themeName: v.string(),
1100
+ limit: v.optional(v.number())
1132
1101
  },
1133
1102
  returns: permissiveReturn,
1134
1103
  handler: async (_ctx, args) => {
1135
- const result = await callNeo4jQuery(
1136
- "surpriseDetection",
1137
- withTopicScope(args, {
1138
- limit: toInt(args.limit, 30)
1139
- }),
1140
- args.apiBaseUrl
1141
- );
1104
+ const result = await callNeo4jQuery("peopleByTheme", {
1105
+ themeName: args.themeName,
1106
+ limit: toInt(args.limit, 50)
1107
+ });
1142
1108
  if (!result.success) {
1143
1109
  return { results: [], error: result.error };
1144
1110
  }
1145
1111
  return { results: result.data || [] };
1146
1112
  }
1147
1113
  });
1148
- var getNonConsensusBeliefs = action({
1114
+ var getPeopleByCompany = action({
1149
1115
  args: {
1150
- limit: v.optional(v.number()),
1151
- apiBaseUrl: v.optional(v.string()),
1152
- topicId: v.optional(v.string())
1116
+ companyName: v.string(),
1117
+ limit: v.optional(v.number())
1153
1118
  },
1154
1119
  returns: permissiveReturn,
1155
1120
  handler: async (_ctx, args) => {
1156
- const result = await callNeo4jQuery(
1157
- "nonConsensusBeliefs",
1158
- withTopicScope(args, {
1159
- limit: toInt(args.limit, 30)
1160
- }),
1161
- args.apiBaseUrl
1162
- );
1121
+ const result = await callNeo4jQuery("peopleByCompany", {
1122
+ companyName: args.companyName,
1123
+ limit: toInt(args.limit, 50)
1124
+ });
1163
1125
  if (!result.success) {
1164
1126
  return { results: [], error: result.error };
1165
1127
  }
1166
1128
  return { results: result.data || [] };
1167
1129
  }
1168
1130
  });
1169
- var EMBEDDING_DIMENSIONS = 1024;
1170
- var VALID_INDEX_NAMES = /* @__PURE__ */ new Set([
1171
- "belief_embedding_index",
1172
- "question_embedding_index",
1173
- "evidence_embedding_index",
1174
- "theme_embedding_index",
1175
- "source_embedding_index",
1176
- "synthesis_embedding_index"
1177
- ]);
1178
- function clamp(value, min, max) {
1179
- return Math.max(min, Math.min(max, value));
1180
- }
1181
- var semanticSearch = action({
1131
+ var getValueChainsByTheme = action({
1182
1132
  args: {
1183
- embedding: v.array(v.float64()),
1184
- indexName: v.optional(v.string()),
1185
- topK: v.optional(v.number()),
1186
- minScore: v.optional(v.number()),
1187
- apiBaseUrl: v.optional(v.string()),
1188
- topicId: v.optional(v.string())
1133
+ themeName: v.string(),
1134
+ limit: v.optional(v.number())
1189
1135
  },
1190
1136
  returns: permissiveReturn,
1191
1137
  handler: async (_ctx, args) => {
1192
- if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
1193
- return {
1194
- results: [],
1195
- error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
1196
- };
1138
+ const result = await callNeo4jQuery("valueChainsByTheme", {
1139
+ themeName: args.themeName,
1140
+ limit: toInt(args.limit, 20)
1141
+ });
1142
+ if (!result.success) {
1143
+ return { results: [], error: result.error };
1197
1144
  }
1198
- const indexName = args.indexName || "belief_embedding_index";
1199
- if (!VALID_INDEX_NAMES.has(indexName)) {
1200
- return { results: [], error: `Invalid index name: ${indexName}` };
1145
+ return { results: result.data || [] };
1146
+ }
1147
+ });
1148
+ var getFunctionsByValueChain = action({
1149
+ args: {
1150
+ valueChainName: v.string(),
1151
+ limit: v.optional(v.number())
1152
+ },
1153
+ returns: permissiveReturn,
1154
+ handler: async (_ctx, args) => {
1155
+ const result = await callNeo4jQuery("functionsByValueChain", {
1156
+ valueChainName: args.valueChainName,
1157
+ limit: toInt(args.limit, 50)
1158
+ });
1159
+ if (!result.success) {
1160
+ return { results: [], error: result.error };
1201
1161
  }
1202
- const result = await callNeo4jQuery(
1203
- "semanticSearch",
1204
- {
1205
- embedding: args.embedding,
1206
- indexName,
1207
- topK: toInt(args.topK, 10),
1208
- minScore: clamp(args.minScore ?? 0.5, 0, 1)
1209
- },
1210
- args.apiBaseUrl
1211
- );
1162
+ return { results: result.data || [] };
1163
+ }
1164
+ });
1165
+ var getBeliefsByCompany = action({
1166
+ args: {
1167
+ companyName: v.string(),
1168
+ limit: v.optional(v.number())
1169
+ },
1170
+ returns: permissiveReturn,
1171
+ handler: async (_ctx, args) => {
1172
+ const result = await callNeo4jQuery("beliefsByCompany", {
1173
+ companyName: args.companyName,
1174
+ limit: toInt(args.limit, 30)
1175
+ });
1212
1176
  if (!result.success) {
1213
1177
  return { results: [], error: result.error };
1214
1178
  }
1215
1179
  return { results: result.data || [] };
1216
1180
  }
1217
1181
  });
1218
- var getSemanticOrphans = action({
1182
+ var getEvidenceByCompany = action({
1219
1183
  args: {
1220
- threshold: v.optional(v.number()),
1221
- limit: v.optional(v.number()),
1222
- apiBaseUrl: v.optional(v.string()),
1223
- topicId: v.optional(v.string())
1184
+ companyName: v.string(),
1185
+ limit: v.optional(v.number())
1224
1186
  },
1225
1187
  returns: permissiveReturn,
1226
1188
  handler: async (_ctx, args) => {
1227
- const result = await callNeo4jQuery(
1228
- "semanticOrphans",
1229
- withTopicScope(args, {
1230
- threshold: clamp(args.threshold ?? 0.4, 0, 1),
1231
- limit: toInt(args.limit, 20)
1232
- }),
1233
- args.apiBaseUrl
1234
- );
1189
+ const result = await callNeo4jQuery("evidenceByCompany", {
1190
+ companyName: args.companyName,
1191
+ limit: toInt(args.limit, 50)
1192
+ });
1235
1193
  if (!result.success) {
1236
1194
  return { results: [], error: result.error };
1237
1195
  }
1238
1196
  return { results: result.data || [] };
1239
1197
  }
1240
1198
  });
1241
- var getSoftContradictions = action({
1199
+ var searchAllNodes = action({
1242
1200
  args: {
1243
- similarityThreshold: v.optional(v.number()),
1244
- limit: v.optional(v.number()),
1245
- apiBaseUrl: v.optional(v.string()),
1246
- topicId: v.optional(v.string())
1201
+ searchText: v.string(),
1202
+ limit: v.optional(v.number())
1247
1203
  },
1248
1204
  returns: permissiveReturn,
1249
1205
  handler: async (_ctx, args) => {
1250
- const result = await callNeo4jQuery(
1251
- "softContradictions",
1252
- withTopicScope(args, {
1253
- similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
1254
- limit: toInt(args.limit, 20)
1255
- }),
1256
- args.apiBaseUrl
1257
- );
1206
+ const result = await callNeo4jQuery("searchAllNodes", {
1207
+ searchText: args.searchText,
1208
+ limit: toInt(args.limit, 50)
1209
+ });
1258
1210
  if (!result.success) {
1259
1211
  return { results: [], error: result.error };
1260
1212
  }
1261
1213
  return { results: result.data || [] };
1262
1214
  }
1263
1215
  });
1264
- var getSemanticBridges = action({
1216
+ var getNodeRelationships = action({
1265
1217
  args: {
1266
- similarityThreshold: v.optional(v.number()),
1267
- limit: v.optional(v.number()),
1268
- apiBaseUrl: v.optional(v.string()),
1269
- topicId: v.optional(v.string())
1218
+ globalId: v.optional(v.string()),
1219
+ searchText: v.optional(v.string()),
1220
+ limit: v.optional(v.number())
1270
1221
  },
1271
1222
  returns: permissiveReturn,
1272
1223
  handler: async (_ctx, args) => {
1273
- const result = await callNeo4jQuery(
1274
- "semanticBridges",
1275
- withTopicScope(args, {
1276
- similarityThreshold: clamp(args.similarityThreshold ?? 0.7, 0, 1),
1277
- limit: toInt(args.limit, 20)
1278
- }),
1279
- args.apiBaseUrl
1280
- );
1224
+ const result = await callNeo4jQuery("nodeRelationships", {
1225
+ globalId: args.globalId || "",
1226
+ searchText: args.searchText || "",
1227
+ limit: toInt(args.limit, 50)
1228
+ });
1281
1229
  if (!result.success) {
1282
1230
  return { results: [], error: result.error };
1283
1231
  }
1284
1232
  return { results: result.data || [] };
1285
1233
  }
1286
1234
  });
1287
- var graphAwareSearch = action({
1235
+ var getGraphStats = action({
1236
+ args: {},
1237
+ returns: permissiveReturn,
1238
+ handler: async () => {
1239
+ const result = await callNeo4jQuery("graphStats", {});
1240
+ if (!result.success) {
1241
+ return { stats: [], error: result.error };
1242
+ }
1243
+ return { stats: result.data || [] };
1244
+ }
1245
+ });
1246
+ var queryGraph = action({
1288
1247
  args: {
1289
- embedding: v.array(v.float64()),
1290
- indexName: v.optional(v.string()),
1291
- topK: v.optional(v.number()),
1292
- minScore: v.optional(v.number()),
1248
+ queryType: v.union(
1249
+ v.literal("themesImpactingCompany"),
1250
+ v.literal("companiesByTheme"),
1251
+ v.literal("questionsByValueChain"),
1252
+ v.literal("questionsByTheme"),
1253
+ v.literal("peopleByTheme"),
1254
+ v.literal("peopleByCompany"),
1255
+ v.literal("valueChainsByTheme"),
1256
+ v.literal("functionsByValueChain"),
1257
+ v.literal("beliefsByCompany"),
1258
+ v.literal("evidenceByCompany"),
1259
+ v.literal("searchAllNodes"),
1260
+ v.literal("nodeRelationships"),
1261
+ v.literal("graphStats")
1262
+ ),
1263
+ params: v.object({
1264
+ companyName: v.optional(v.string()),
1265
+ themeName: v.optional(v.string()),
1266
+ valueChainName: v.optional(v.string()),
1267
+ searchText: v.optional(v.string()),
1268
+ globalId: v.optional(v.string()),
1269
+ limit: v.optional(v.number())
1270
+ }),
1293
1271
  apiBaseUrl: v.optional(v.string()),
1294
1272
  topicId: v.optional(v.string())
1295
1273
  },
1296
1274
  returns: permissiveReturn,
1297
1275
  handler: async (_ctx, args) => {
1298
- if (args.embedding.length !== EMBEDDING_DIMENSIONS) {
1276
+ const limit = toInt(args.params.limit, 30);
1277
+ const themeRequiredQueries = [
1278
+ "questionsByTheme",
1279
+ "peopleByTheme",
1280
+ "companiesByTheme",
1281
+ "valueChainsByTheme"
1282
+ ];
1283
+ const companyRequiredQueries = [
1284
+ "themesImpactingCompany",
1285
+ "peopleByCompany",
1286
+ "beliefsByCompany",
1287
+ "evidenceByCompany"
1288
+ ];
1289
+ const valueChainRequiredQueries = [
1290
+ "questionsByValueChain",
1291
+ "functionsByValueChain"
1292
+ ];
1293
+ if (themeRequiredQueries.includes(args.queryType) && !args.params.themeName) {
1299
1294
  return {
1300
1295
  results: [],
1301
- error: `Embedding must be ${EMBEDDING_DIMENSIONS} dimensions, got ${args.embedding.length}`
1296
+ error: `Query type '${args.queryType}' requires 'themeName' parameter`
1302
1297
  };
1303
1298
  }
1304
- const indexName = args.indexName || "belief_embedding_index";
1305
- if (!VALID_INDEX_NAMES.has(indexName)) {
1306
- return { results: [], error: `Invalid index name: ${indexName}` };
1299
+ if (companyRequiredQueries.includes(args.queryType) && !args.params.companyName) {
1300
+ return {
1301
+ results: [],
1302
+ error: `Query type '${args.queryType}' requires 'companyName' parameter`
1303
+ };
1304
+ }
1305
+ if (valueChainRequiredQueries.includes(args.queryType) && !args.params.valueChainName) {
1306
+ return {
1307
+ results: [],
1308
+ error: `Query type '${args.queryType}' requires 'valueChainName' parameter`
1309
+ };
1307
1310
  }
1308
1311
  const result = await callNeo4jQuery(
1309
- "graphAwareSearch",
1312
+ args.queryType,
1310
1313
  withTopicScope(args, {
1311
- embedding: args.embedding,
1312
- indexName,
1313
- topK: toInt(args.topK, 10),
1314
- minScore: clamp(args.minScore ?? 0.5, 0, 1)
1314
+ ...args.params,
1315
+ limit
1315
1316
  }),
1316
1317
  args.apiBaseUrl
1317
1318
  );