@lucern/mcp 0.3.0-alpha.4 → 0.3.0-alpha.5
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/cli.js +3700 -165
- package/dist/cli.js.map +1 -1
- package/dist/gateway.js +737 -2
- package/dist/gateway.js.map +1 -1
- package/dist/hosted-route.js +4141 -148
- package/dist/hosted-route.js.map +1 -1
- package/dist/index.js +3806 -269
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +753 -2
- package/dist/runtime.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -11,11 +11,30 @@ import { createServer } from 'http';
|
|
|
11
11
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
12
12
|
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
13
13
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
14
|
+
import * as graphIntel_star from '@lucern/reasoning-kernel/graphIntel';
|
|
14
15
|
import 'crypto';
|
|
15
16
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
16
17
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
17
18
|
import { config } from 'dotenv';
|
|
18
19
|
|
|
20
|
+
var __defProp = Object.defineProperty;
|
|
21
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
22
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
23
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
|
|
37
|
+
|
|
19
38
|
// src/execution.ts
|
|
20
39
|
var SCOPE_ALIAS_GROUPS = [];
|
|
21
40
|
function classifyTransportParityDrift(kind) {
|
|
@@ -382,6 +401,598 @@ function stripQuotes(value) {
|
|
|
382
401
|
return trimmed;
|
|
383
402
|
}
|
|
384
403
|
|
|
404
|
+
// ../contracts/src/graph-intelligence.contract.ts
|
|
405
|
+
var GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION = "graph_intelligence_query_catalog.v1";
|
|
406
|
+
var GRAPH_INTELLIGENCE_QUERY_MODES = [
|
|
407
|
+
"core",
|
|
408
|
+
"bias",
|
|
409
|
+
"stress",
|
|
410
|
+
"operational",
|
|
411
|
+
"alpha",
|
|
412
|
+
"semantic",
|
|
413
|
+
"evidence"
|
|
414
|
+
];
|
|
415
|
+
var GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES = [
|
|
416
|
+
"get_graph_structure_analysis",
|
|
417
|
+
"detect_confirmation_bias",
|
|
418
|
+
"get_graph_gaps",
|
|
419
|
+
"get_topic_coverage",
|
|
420
|
+
"find_contradictions",
|
|
421
|
+
"get_falsification_questions",
|
|
422
|
+
"search_beliefs",
|
|
423
|
+
"search_evidence",
|
|
424
|
+
"list_beliefs",
|
|
425
|
+
"list_questions",
|
|
426
|
+
"traverse_graph",
|
|
427
|
+
"query_lineage",
|
|
428
|
+
"get_graph_neighborhood"
|
|
429
|
+
];
|
|
430
|
+
var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
|
|
431
|
+
core: [
|
|
432
|
+
"get_graph_structure_analysis",
|
|
433
|
+
"get_topic_coverage",
|
|
434
|
+
"get_graph_gaps",
|
|
435
|
+
"list_beliefs",
|
|
436
|
+
"list_questions",
|
|
437
|
+
"search_evidence"
|
|
438
|
+
],
|
|
439
|
+
bias: [
|
|
440
|
+
"get_graph_structure_analysis",
|
|
441
|
+
"detect_confirmation_bias",
|
|
442
|
+
"find_contradictions",
|
|
443
|
+
"search_evidence",
|
|
444
|
+
"list_beliefs"
|
|
445
|
+
],
|
|
446
|
+
stress: [
|
|
447
|
+
"get_graph_structure_analysis",
|
|
448
|
+
"get_graph_gaps",
|
|
449
|
+
"find_contradictions",
|
|
450
|
+
"get_falsification_questions",
|
|
451
|
+
"list_beliefs",
|
|
452
|
+
"list_questions"
|
|
453
|
+
],
|
|
454
|
+
operational: [
|
|
455
|
+
"get_topic_coverage",
|
|
456
|
+
"get_graph_gaps",
|
|
457
|
+
"list_beliefs",
|
|
458
|
+
"list_questions",
|
|
459
|
+
"search_evidence"
|
|
460
|
+
],
|
|
461
|
+
alpha: [
|
|
462
|
+
"get_graph_structure_analysis",
|
|
463
|
+
"detect_confirmation_bias",
|
|
464
|
+
"find_contradictions",
|
|
465
|
+
"search_beliefs",
|
|
466
|
+
"search_evidence"
|
|
467
|
+
],
|
|
468
|
+
semantic: [
|
|
469
|
+
"get_graph_structure_analysis",
|
|
470
|
+
"search_beliefs",
|
|
471
|
+
"search_evidence",
|
|
472
|
+
"traverse_graph",
|
|
473
|
+
"query_lineage",
|
|
474
|
+
"get_graph_neighborhood"
|
|
475
|
+
],
|
|
476
|
+
evidence: [
|
|
477
|
+
"get_graph_structure_analysis",
|
|
478
|
+
"get_topic_coverage",
|
|
479
|
+
"search_evidence",
|
|
480
|
+
"get_falsification_questions",
|
|
481
|
+
"find_contradictions"
|
|
482
|
+
]
|
|
483
|
+
};
|
|
484
|
+
var GRAPH_INTELLIGENCE_QUERY_CATEGORIES = [
|
|
485
|
+
{
|
|
486
|
+
id: "problems",
|
|
487
|
+
name: "Find Problems",
|
|
488
|
+
description: "Risk, contradiction, bias, and structural weakness queries."
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
id: "gaps",
|
|
492
|
+
name: "Find Gaps",
|
|
493
|
+
description: "Missing evidence, unanswered questions, and sparse areas."
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: "reasoning",
|
|
497
|
+
name: "Reasoning Quality",
|
|
498
|
+
description: "Assumption chains, evidence convergence, and weak links."
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
id: "strategic",
|
|
502
|
+
name: "Strategic Analysis",
|
|
503
|
+
description: "Pre-mortems, falsification, contrarian signals, and bets."
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
id: "deep",
|
|
507
|
+
name: "Deep Graph Analysis",
|
|
508
|
+
description: "Centrality, propagation, underdetermination, and topology."
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: "browse",
|
|
512
|
+
name: "Browse and Explore",
|
|
513
|
+
description: "Narrative summaries, search, theme exploration, and bridges."
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
id: "prep",
|
|
517
|
+
name: "Meeting Prep",
|
|
518
|
+
description: "Company, entity, and question prep from graph context."
|
|
519
|
+
}
|
|
520
|
+
];
|
|
521
|
+
var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
|
|
522
|
+
var GRAPH_INTELLIGENCE_QUERIES = [
|
|
523
|
+
{
|
|
524
|
+
id: "confirmation-bias",
|
|
525
|
+
categoryId: "problems",
|
|
526
|
+
mode: "bias",
|
|
527
|
+
name: "Find Confirmation Bias",
|
|
528
|
+
description: "Find beliefs supported mainly by confirming evidence.",
|
|
529
|
+
prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
|
|
530
|
+
highlightStrategy: "bias-risk",
|
|
531
|
+
riskLevel: "high"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
id: "contradiction-map",
|
|
535
|
+
categoryId: "problems",
|
|
536
|
+
mode: "stress",
|
|
537
|
+
name: "Map Contradictions",
|
|
538
|
+
description: "Surface direct and indirect contradiction clusters.",
|
|
539
|
+
prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
|
|
540
|
+
highlightStrategy: "contradictions",
|
|
541
|
+
riskLevel: "high"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
id: "weak-evidence",
|
|
545
|
+
categoryId: "problems",
|
|
546
|
+
mode: "stress",
|
|
547
|
+
name: "Weak Evidence Chains",
|
|
548
|
+
description: "Find important claims with thin or indirect evidence.",
|
|
549
|
+
prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
|
|
550
|
+
highlightStrategy: "weak-support",
|
|
551
|
+
riskLevel: "medium"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
id: "single-source",
|
|
555
|
+
categoryId: "problems",
|
|
556
|
+
mode: "bias",
|
|
557
|
+
name: "Single-Source Risk",
|
|
558
|
+
description: "Find claims overly dependent on one source or source type.",
|
|
559
|
+
prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
|
|
560
|
+
highlightStrategy: "source-concentration",
|
|
561
|
+
riskLevel: "medium"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
id: "untested-assumptions",
|
|
565
|
+
categoryId: "problems",
|
|
566
|
+
mode: "stress",
|
|
567
|
+
name: "Untested Assumptions",
|
|
568
|
+
description: "Find load-bearing assumptions without falsification paths.",
|
|
569
|
+
prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
|
|
570
|
+
highlightStrategy: "untested",
|
|
571
|
+
riskLevel: "high"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
id: "load-bearing-beliefs",
|
|
575
|
+
categoryId: "problems",
|
|
576
|
+
mode: "stress",
|
|
577
|
+
name: "Load-Bearing Beliefs",
|
|
578
|
+
description: "Find central beliefs whose failure would affect many claims.",
|
|
579
|
+
prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
|
|
580
|
+
highlightStrategy: "load-bearing",
|
|
581
|
+
riskLevel: "high"
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
id: "cascade-analysis",
|
|
585
|
+
categoryId: "problems",
|
|
586
|
+
mode: "stress",
|
|
587
|
+
name: "Cascade Analysis",
|
|
588
|
+
description: "Trace what changes if a belief is weakened or invalidated.",
|
|
589
|
+
prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
|
|
590
|
+
highlightStrategy: "cascade",
|
|
591
|
+
riskLevel: "high"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
id: "unanswered-questions",
|
|
595
|
+
categoryId: "gaps",
|
|
596
|
+
mode: "operational",
|
|
597
|
+
name: "Unanswered Questions",
|
|
598
|
+
description: "Find important open questions that block confidence.",
|
|
599
|
+
prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
|
|
600
|
+
highlightStrategy: "open-questions"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
id: "thin-themes",
|
|
604
|
+
categoryId: "gaps",
|
|
605
|
+
mode: "operational",
|
|
606
|
+
name: "Thin Themes",
|
|
607
|
+
description: "Find topics with shallow belief or evidence coverage.",
|
|
608
|
+
prompt: "Find themes that look underdeveloped relative to their role in the graph.",
|
|
609
|
+
highlightStrategy: "thin-themes"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
id: "missing-evidence",
|
|
613
|
+
categoryId: "gaps",
|
|
614
|
+
mode: "stress",
|
|
615
|
+
name: "Missing Evidence",
|
|
616
|
+
description: "Find beliefs that need specific missing evidence.",
|
|
617
|
+
prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
|
|
618
|
+
highlightStrategy: "missing-evidence"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
id: "isolated-clusters",
|
|
622
|
+
categoryId: "gaps",
|
|
623
|
+
mode: "operational",
|
|
624
|
+
name: "Isolated Clusters",
|
|
625
|
+
description: "Find clusters not connected to the broader graph.",
|
|
626
|
+
prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
|
|
627
|
+
highlightStrategy: "isolated-clusters"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "source-contribution",
|
|
631
|
+
categoryId: "gaps",
|
|
632
|
+
mode: "evidence",
|
|
633
|
+
name: "Source Contribution",
|
|
634
|
+
description: "Assess how source mix shapes the graph.",
|
|
635
|
+
prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
|
|
636
|
+
highlightStrategy: "source-mix"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
id: "stale-beliefs",
|
|
640
|
+
categoryId: "gaps",
|
|
641
|
+
mode: "operational",
|
|
642
|
+
name: "Stale Beliefs",
|
|
643
|
+
description: "Find beliefs that need review because they are old or stale.",
|
|
644
|
+
prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
|
|
645
|
+
highlightStrategy: "staleness"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
id: "assumption-pyramid",
|
|
649
|
+
categoryId: "reasoning",
|
|
650
|
+
mode: "operational",
|
|
651
|
+
name: "Assumption Pyramid",
|
|
652
|
+
description: "Show which conclusions rest on which assumptions.",
|
|
653
|
+
prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
|
|
654
|
+
highlightStrategy: "assumptions"
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
id: "converging-evidence",
|
|
658
|
+
categoryId: "reasoning",
|
|
659
|
+
mode: "evidence",
|
|
660
|
+
name: "Converging Evidence",
|
|
661
|
+
description: "Find claims supported by independent evidence streams.",
|
|
662
|
+
prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
|
|
663
|
+
highlightStrategy: "convergence"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
id: "weakest-links",
|
|
667
|
+
categoryId: "reasoning",
|
|
668
|
+
mode: "stress",
|
|
669
|
+
name: "Weakest Links",
|
|
670
|
+
description: "Find the weakest links in important reasoning chains.",
|
|
671
|
+
prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
|
|
672
|
+
highlightStrategy: "weak-links",
|
|
673
|
+
riskLevel: "medium"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
id: "challenged-beliefs",
|
|
677
|
+
categoryId: "reasoning",
|
|
678
|
+
mode: "stress",
|
|
679
|
+
name: "Challenged Beliefs",
|
|
680
|
+
description: "Find beliefs with active challenges or defeaters.",
|
|
681
|
+
prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
|
|
682
|
+
highlightStrategy: "challenged"
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
id: "contrarian-map",
|
|
686
|
+
categoryId: "strategic",
|
|
687
|
+
mode: "alpha",
|
|
688
|
+
name: "Contrarian Map",
|
|
689
|
+
description: "Find non-consensus beliefs and where they are grounded.",
|
|
690
|
+
prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
|
|
691
|
+
highlightStrategy: "contrarian"
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
id: "irreversibility-audit",
|
|
695
|
+
categoryId: "strategic",
|
|
696
|
+
mode: "stress",
|
|
697
|
+
name: "Irreversibility Audit",
|
|
698
|
+
description: "Find irreversible bets and assumptions behind them.",
|
|
699
|
+
prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
|
|
700
|
+
highlightStrategy: "irreversible",
|
|
701
|
+
riskLevel: "high"
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
id: "pre-mortem",
|
|
705
|
+
categoryId: "strategic",
|
|
706
|
+
mode: "stress",
|
|
707
|
+
name: "Pre-Mortem",
|
|
708
|
+
description: "Explain how the graph could be wrong.",
|
|
709
|
+
prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
|
|
710
|
+
highlightStrategy: "failure-paths",
|
|
711
|
+
riskLevel: "high"
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
id: "devils-advocate",
|
|
715
|
+
categoryId: "strategic",
|
|
716
|
+
mode: "stress",
|
|
717
|
+
name: "Devil's Advocate",
|
|
718
|
+
description: "Generate the strongest critique of the graph.",
|
|
719
|
+
prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
|
|
720
|
+
highlightStrategy: "critique"
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
id: "falsification-map",
|
|
724
|
+
categoryId: "strategic",
|
|
725
|
+
mode: "stress",
|
|
726
|
+
name: "Falsification Map",
|
|
727
|
+
description: "Find the cheapest tests that would disprove key beliefs.",
|
|
728
|
+
prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
|
|
729
|
+
highlightStrategy: "falsification",
|
|
730
|
+
riskLevel: "high"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
id: "prediction-tracker",
|
|
734
|
+
categoryId: "strategic",
|
|
735
|
+
mode: "evidence",
|
|
736
|
+
name: "Prediction Tracker",
|
|
737
|
+
description: "Find beliefs that imply measurable predictions.",
|
|
738
|
+
prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
|
|
739
|
+
highlightStrategy: "predictions"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
id: "belief-pagerank",
|
|
743
|
+
categoryId: "deep",
|
|
744
|
+
mode: "semantic",
|
|
745
|
+
name: "Belief PageRank",
|
|
746
|
+
description: "Identify structurally central beliefs.",
|
|
747
|
+
prompt: "Use graph centrality to identify the most structurally important beliefs.",
|
|
748
|
+
highlightStrategy: "centrality"
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
id: "underdetermination",
|
|
752
|
+
categoryId: "deep",
|
|
753
|
+
mode: "semantic",
|
|
754
|
+
name: "Underdetermination",
|
|
755
|
+
description: "Find places where evidence supports multiple explanations.",
|
|
756
|
+
prompt: "Find places where the same evidence could support multiple incompatible explanations.",
|
|
757
|
+
highlightStrategy: "underdetermination"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
id: "confidence-propagation",
|
|
761
|
+
categoryId: "deep",
|
|
762
|
+
mode: "semantic",
|
|
763
|
+
name: "Confidence Propagation",
|
|
764
|
+
description: "Assess how uncertainty moves through the graph.",
|
|
765
|
+
prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
|
|
766
|
+
highlightStrategy: "confidence-flow"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
id: "argument-depth",
|
|
770
|
+
categoryId: "deep",
|
|
771
|
+
mode: "evidence",
|
|
772
|
+
name: "Argument Depth",
|
|
773
|
+
description: "Assess reasoning depth and chain quality.",
|
|
774
|
+
prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
|
|
775
|
+
highlightStrategy: "depth"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
id: "information-edge",
|
|
779
|
+
categoryId: "deep",
|
|
780
|
+
mode: "alpha",
|
|
781
|
+
name: "Information Edge",
|
|
782
|
+
description: "Find differentiated evidence or signals.",
|
|
783
|
+
prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
|
|
784
|
+
highlightStrategy: "information-edge"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
id: "thesis-summary",
|
|
788
|
+
categoryId: "browse",
|
|
789
|
+
mode: "semantic",
|
|
790
|
+
name: "Thesis Summary",
|
|
791
|
+
description: "Summarize the graph's core thesis and support.",
|
|
792
|
+
prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
|
|
793
|
+
highlightStrategy: "summary"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
id: "theme-deep-dive",
|
|
797
|
+
categoryId: "browse",
|
|
798
|
+
mode: "semantic",
|
|
799
|
+
name: "Theme Deep Dive",
|
|
800
|
+
description: "Deep dive into a named theme.",
|
|
801
|
+
prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
|
|
802
|
+
inputType: "theme",
|
|
803
|
+
highlightStrategy: "theme"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
id: "belief-detail",
|
|
807
|
+
categoryId: "browse",
|
|
808
|
+
mode: "semantic",
|
|
809
|
+
name: "Belief Detail",
|
|
810
|
+
description: "Explain one belief and its graph neighborhood.",
|
|
811
|
+
prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
|
|
812
|
+
inputType: "belief",
|
|
813
|
+
highlightStrategy: "belief"
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
id: "strongest-beliefs",
|
|
817
|
+
categoryId: "browse",
|
|
818
|
+
mode: "operational",
|
|
819
|
+
name: "Strongest Beliefs",
|
|
820
|
+
description: "Find the graph's strongest current beliefs.",
|
|
821
|
+
prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
|
|
822
|
+
highlightStrategy: "strongest"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
id: "cross-theme-connection",
|
|
826
|
+
categoryId: "browse",
|
|
827
|
+
mode: "semantic",
|
|
828
|
+
name: "Cross-Theme Connections",
|
|
829
|
+
description: "Find bridges between themes.",
|
|
830
|
+
prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
|
|
831
|
+
highlightStrategy: "bridges"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
id: "research-velocity",
|
|
835
|
+
categoryId: "browse",
|
|
836
|
+
mode: "operational",
|
|
837
|
+
name: "Research Velocity",
|
|
838
|
+
description: "Summarize recent graph movement and momentum.",
|
|
839
|
+
prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
|
|
840
|
+
highlightStrategy: "velocity"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
id: "search",
|
|
844
|
+
categoryId: "browse",
|
|
845
|
+
mode: "semantic",
|
|
846
|
+
name: "Graph Search",
|
|
847
|
+
description: "Search the graph with semantic context.",
|
|
848
|
+
prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
|
|
849
|
+
inputType: "search",
|
|
850
|
+
highlightStrategy: "search"
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
id: "expert-coverage",
|
|
854
|
+
categoryId: "browse",
|
|
855
|
+
mode: "semantic",
|
|
856
|
+
name: "Expert Coverage",
|
|
857
|
+
description: "Assess coverage from expert/source perspectives.",
|
|
858
|
+
prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
|
|
859
|
+
highlightStrategy: "expert-coverage"
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
id: "value-chain-map",
|
|
863
|
+
categoryId: "browse",
|
|
864
|
+
mode: "semantic",
|
|
865
|
+
name: "Value Chain Map",
|
|
866
|
+
description: "Map entities, dependencies, and value-chain logic.",
|
|
867
|
+
prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
|
|
868
|
+
highlightStrategy: "value-chain"
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
id: "meeting-brief",
|
|
872
|
+
categoryId: "prep",
|
|
873
|
+
mode: "semantic",
|
|
874
|
+
name: "Meeting Brief",
|
|
875
|
+
description: "Prepare a meeting brief from graph context.",
|
|
876
|
+
prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
|
|
877
|
+
highlightStrategy: "brief"
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
id: "open-questions-entity",
|
|
881
|
+
categoryId: "prep",
|
|
882
|
+
mode: "semantic",
|
|
883
|
+
name: "Entity Open Questions",
|
|
884
|
+
description: "Find open questions about a specific entity.",
|
|
885
|
+
prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
|
|
886
|
+
inputType: "entity",
|
|
887
|
+
highlightStrategy: "entity-questions"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
id: "company-context",
|
|
891
|
+
categoryId: "prep",
|
|
892
|
+
mode: "semantic",
|
|
893
|
+
name: "Company Context",
|
|
894
|
+
description: "Summarize graph context about a company.",
|
|
895
|
+
prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
|
|
896
|
+
inputType: "company",
|
|
897
|
+
highlightStrategy: "company"
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
id: "company-theme-fit",
|
|
901
|
+
categoryId: "prep",
|
|
902
|
+
mode: "semantic",
|
|
903
|
+
name: "Company Theme Fit",
|
|
904
|
+
description: "Assess how a company fits graph themes.",
|
|
905
|
+
prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
|
|
906
|
+
inputType: "company",
|
|
907
|
+
highlightStrategy: "fit"
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
id: "company-comparison",
|
|
911
|
+
categoryId: "prep",
|
|
912
|
+
mode: "semantic",
|
|
913
|
+
name: "Company Comparison",
|
|
914
|
+
description: "Compare companies through graph context.",
|
|
915
|
+
prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
|
|
916
|
+
inputType: "company-list",
|
|
917
|
+
highlightStrategy: "comparison"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
id: "questions-to-ask",
|
|
921
|
+
categoryId: "prep",
|
|
922
|
+
mode: "operational",
|
|
923
|
+
name: "Questions to Ask",
|
|
924
|
+
description: "Generate high-signal questions from graph gaps.",
|
|
925
|
+
prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
|
|
926
|
+
highlightStrategy: "questions"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
id: "beliefs-to-test",
|
|
930
|
+
categoryId: "prep",
|
|
931
|
+
mode: "stress",
|
|
932
|
+
name: "Beliefs to Test",
|
|
933
|
+
description: "Prioritize beliefs that should be tested next.",
|
|
934
|
+
prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
|
|
935
|
+
highlightStrategy: "tests",
|
|
936
|
+
riskLevel: "medium"
|
|
937
|
+
}
|
|
938
|
+
];
|
|
939
|
+
var GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS = GRAPH_INTELLIGENCE_QUERIES.map((query5) => {
|
|
940
|
+
const definition = query5;
|
|
941
|
+
return {
|
|
942
|
+
...definition,
|
|
943
|
+
tools: definition.tools ?? byMode(definition.mode)
|
|
944
|
+
};
|
|
945
|
+
});
|
|
946
|
+
var GRAPH_INTELLIGENCE_QUICK_QUERIES = [
|
|
947
|
+
{
|
|
948
|
+
id: "health-check",
|
|
949
|
+
name: "Health Check",
|
|
950
|
+
queryId: "thesis-summary",
|
|
951
|
+
prompt: "Give me a fast graph health check: biggest strengths, biggest risks, and next best action."
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
id: "find-risks",
|
|
955
|
+
name: "Find Risks",
|
|
956
|
+
queryId: "weakest-links",
|
|
957
|
+
prompt: "Find the most important risks in this graph and the beliefs or evidence behind each one."
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
id: "pre-mortem",
|
|
961
|
+
name: "Pre-Mortem",
|
|
962
|
+
queryId: "pre-mortem",
|
|
963
|
+
prompt: "Assume this thesis fails. Explain the most plausible failure paths and what would reveal them early."
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
id: "whats-next",
|
|
967
|
+
name: "What's Next",
|
|
968
|
+
queryId: "questions-to-ask",
|
|
969
|
+
prompt: "What should I learn or test next to make this graph more useful?"
|
|
970
|
+
}
|
|
971
|
+
];
|
|
972
|
+
function isGraphIntelligenceQueryMode(value) {
|
|
973
|
+
return typeof value === "string" && GRAPH_INTELLIGENCE_QUERY_MODES.includes(value);
|
|
974
|
+
}
|
|
975
|
+
function getGraphIntelligenceQuery(queryId) {
|
|
976
|
+
return GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS.find(
|
|
977
|
+
(query5) => query5.id === queryId
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
function listGraphIntelligenceQueries(filter = {}) {
|
|
981
|
+
return GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS.filter((query5) => {
|
|
982
|
+
if (filter.categoryId && query5.categoryId !== filter.categoryId) {
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
if (filter.mode && query5.mode !== filter.mode) {
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
return true;
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
function fillGraphIntelligencePromptTemplate(prompt, input) {
|
|
992
|
+
const replacement = input?.trim() || "the current topic";
|
|
993
|
+
return prompt.split("{input}").join(replacement);
|
|
994
|
+
}
|
|
995
|
+
|
|
385
996
|
// ../contracts/src/dsl/defineTable.ts
|
|
386
997
|
function defineTable(spec) {
|
|
387
998
|
return spec;
|
|
@@ -398,7 +1009,10 @@ function idOf(table) {
|
|
|
398
1009
|
return schema;
|
|
399
1010
|
}
|
|
400
1011
|
var NODE_TYPE = z.enum(["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain"]);
|
|
401
|
-
var
|
|
1012
|
+
var EDGE_TYPE_VALUES = ["supports", "informs", "depends_on", "derived_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"];
|
|
1013
|
+
var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
|
|
1014
|
+
z.enum(EDGE_TYPE_VALUES);
|
|
1015
|
+
var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
|
|
402
1016
|
var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
|
|
403
1017
|
var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
|
|
404
1018
|
defineTable({
|
|
@@ -1883,7 +2497,7 @@ defineTable({
|
|
|
1883
2497
|
"toNodeId": z.string().optional(),
|
|
1884
2498
|
"sourceGlobalId": z.string().optional(),
|
|
1885
2499
|
"targetGlobalId": z.string().optional(),
|
|
1886
|
-
"edgeType":
|
|
2500
|
+
"edgeType": STORAGE_EDGE_TYPE,
|
|
1887
2501
|
"edgeTier": z.string().optional(),
|
|
1888
2502
|
"domainNamespace": z.string().optional(),
|
|
1889
2503
|
"constraint": z.string().optional(),
|
|
@@ -4657,6 +5271,126 @@ var edgePolicyManifest = {
|
|
|
4657
5271
|
|
|
4658
5272
|
// ../contracts/src/tenant-client.contract.ts
|
|
4659
5273
|
var TENANT_CLIENT_INSTALL_TOKEN_INFISICAL_PATH = "tenants/shared";
|
|
5274
|
+
var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
|
|
5275
|
+
{
|
|
5276
|
+
packageName: "@lucern/access-control",
|
|
5277
|
+
role: "runtime_entrypoint",
|
|
5278
|
+
directTenantImport: true
|
|
5279
|
+
},
|
|
5280
|
+
{
|
|
5281
|
+
packageName: "@lucern/agent",
|
|
5282
|
+
role: "platform_runtime",
|
|
5283
|
+
directTenantImport: false
|
|
5284
|
+
},
|
|
5285
|
+
{
|
|
5286
|
+
packageName: "@lucern/auth",
|
|
5287
|
+
role: "sdk_dependency",
|
|
5288
|
+
directTenantImport: false
|
|
5289
|
+
},
|
|
5290
|
+
{
|
|
5291
|
+
packageName: "@lucern/cli",
|
|
5292
|
+
role: "developer_tool",
|
|
5293
|
+
directTenantImport: false
|
|
5294
|
+
},
|
|
5295
|
+
{
|
|
5296
|
+
packageName: "@lucern/client-core",
|
|
5297
|
+
role: "sdk_dependency",
|
|
5298
|
+
directTenantImport: false
|
|
5299
|
+
},
|
|
5300
|
+
{
|
|
5301
|
+
packageName: "@lucern/confidence",
|
|
5302
|
+
role: "sdk_dependency",
|
|
5303
|
+
directTenantImport: false
|
|
5304
|
+
},
|
|
5305
|
+
{
|
|
5306
|
+
packageName: "@lucern/config",
|
|
5307
|
+
role: "configuration",
|
|
5308
|
+
directTenantImport: false
|
|
5309
|
+
},
|
|
5310
|
+
{
|
|
5311
|
+
packageName: "@lucern/contracts",
|
|
5312
|
+
role: "contract_entrypoint",
|
|
5313
|
+
directTenantImport: true
|
|
5314
|
+
},
|
|
5315
|
+
{
|
|
5316
|
+
packageName: "@lucern/control-plane",
|
|
5317
|
+
role: "platform_runtime",
|
|
5318
|
+
directTenantImport: false
|
|
5319
|
+
},
|
|
5320
|
+
{
|
|
5321
|
+
packageName: "@lucern/developer-kit",
|
|
5322
|
+
role: "developer_tool",
|
|
5323
|
+
directTenantImport: false
|
|
5324
|
+
},
|
|
5325
|
+
{
|
|
5326
|
+
packageName: "@lucern/events",
|
|
5327
|
+
role: "sdk_dependency",
|
|
5328
|
+
directTenantImport: false
|
|
5329
|
+
},
|
|
5330
|
+
{
|
|
5331
|
+
packageName: "@lucern/graph-primitives",
|
|
5332
|
+
role: "sdk_dependency",
|
|
5333
|
+
directTenantImport: false
|
|
5334
|
+
},
|
|
5335
|
+
{
|
|
5336
|
+
packageName: "@lucern/identity",
|
|
5337
|
+
role: "component_runtime",
|
|
5338
|
+
directTenantImport: false
|
|
5339
|
+
},
|
|
5340
|
+
{
|
|
5341
|
+
packageName: "@lucern/mcp",
|
|
5342
|
+
role: "runtime_entrypoint",
|
|
5343
|
+
directTenantImport: true
|
|
5344
|
+
},
|
|
5345
|
+
{
|
|
5346
|
+
packageName: "@lucern/pack-host",
|
|
5347
|
+
role: "platform_runtime",
|
|
5348
|
+
directTenantImport: false
|
|
5349
|
+
},
|
|
5350
|
+
{
|
|
5351
|
+
packageName: "@lucern/pack-installer",
|
|
5352
|
+
role: "developer_tool",
|
|
5353
|
+
directTenantImport: false
|
|
5354
|
+
},
|
|
5355
|
+
{
|
|
5356
|
+
packageName: "@lucern/proof-compiler",
|
|
5357
|
+
role: "developer_tool",
|
|
5358
|
+
directTenantImport: false
|
|
5359
|
+
},
|
|
5360
|
+
{
|
|
5361
|
+
packageName: "@lucern/react",
|
|
5362
|
+
role: "runtime_entrypoint",
|
|
5363
|
+
directTenantImport: true
|
|
5364
|
+
},
|
|
5365
|
+
{
|
|
5366
|
+
packageName: "@lucern/reasoning-kernel",
|
|
5367
|
+
role: "component_runtime",
|
|
5368
|
+
directTenantImport: false
|
|
5369
|
+
},
|
|
5370
|
+
{
|
|
5371
|
+
packageName: "@lucern/sdk",
|
|
5372
|
+
role: "runtime_entrypoint",
|
|
5373
|
+
directTenantImport: true
|
|
5374
|
+
},
|
|
5375
|
+
{
|
|
5376
|
+
packageName: "@lucern/server-core",
|
|
5377
|
+
role: "platform_runtime",
|
|
5378
|
+
directTenantImport: false
|
|
5379
|
+
},
|
|
5380
|
+
{
|
|
5381
|
+
packageName: "@lucern/testing",
|
|
5382
|
+
role: "test_support",
|
|
5383
|
+
directTenantImport: false
|
|
5384
|
+
},
|
|
5385
|
+
{
|
|
5386
|
+
packageName: "@lucern/types",
|
|
5387
|
+
role: "contract_entrypoint",
|
|
5388
|
+
directTenantImport: true
|
|
5389
|
+
}
|
|
5390
|
+
];
|
|
5391
|
+
TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
|
|
5392
|
+
(entry) => entry.packageName
|
|
5393
|
+
);
|
|
4660
5394
|
var INFISICAL_RUNTIME_DEFAULT_API_URL = "https://app.infisical.com";
|
|
4661
5395
|
var INFISICAL_RUNTIME_DEFAULT_PROJECT_ID = "344b0526-90df-4606-ba50-22c647a36c65";
|
|
4662
5396
|
var INFISICAL_RUNTIME_BOOTSTRAP_ENV = {
|
|
@@ -6311,6 +7045,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
|
|
|
6311
7045
|
ontologyPrimitive: "graph",
|
|
6312
7046
|
tier: "showcase"
|
|
6313
7047
|
};
|
|
7048
|
+
var LIST_GRAPH_INTELLIGENCE_QUERIES = {
|
|
7049
|
+
name: "list_graph_intelligence_queries",
|
|
7050
|
+
description: "List the Graph Intelligence query catalog that powers structural graph analysis experiences. Returns categories, query IDs, prompt templates, modes, and the public tool plan each query can use.",
|
|
7051
|
+
parameters: {
|
|
7052
|
+
categoryId: {
|
|
7053
|
+
type: "string",
|
|
7054
|
+
description: "Optional category filter, such as problems or strategic"
|
|
7055
|
+
},
|
|
7056
|
+
mode: {
|
|
7057
|
+
type: "string",
|
|
7058
|
+
description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
|
|
7059
|
+
}
|
|
7060
|
+
},
|
|
7061
|
+
required: [],
|
|
7062
|
+
response: {
|
|
7063
|
+
description: "Graph Intelligence query catalog and mode-to-tool mapping",
|
|
7064
|
+
fields: {
|
|
7065
|
+
categories: "array \u2014 query categories",
|
|
7066
|
+
queries: "array \u2014 query definitions with prompt templates and tools",
|
|
7067
|
+
quickQueries: "array \u2014 recommended one-click query presets",
|
|
7068
|
+
publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
|
|
7069
|
+
}
|
|
7070
|
+
},
|
|
7071
|
+
ownerModule: "graph-intelligence",
|
|
7072
|
+
ontologyPrimitive: "graph",
|
|
7073
|
+
tier: "showcase"
|
|
7074
|
+
};
|
|
7075
|
+
var RUN_GRAPH_INTELLIGENCE_QUERY = {
|
|
7076
|
+
name: "run_graph_intelligence_query",
|
|
7077
|
+
description: "Run a named Graph Intelligence query against a tenant topic graph. Returns the selected query, prompt, deterministic graph-analysis bundle, graph context, and public tool plan for model synthesis.",
|
|
7078
|
+
parameters: {
|
|
7079
|
+
topicId: { type: "string", description: "Topic to analyze" },
|
|
7080
|
+
queryId: {
|
|
7081
|
+
type: "string",
|
|
7082
|
+
description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
|
|
7083
|
+
},
|
|
7084
|
+
prompt: {
|
|
7085
|
+
type: "string",
|
|
7086
|
+
description: "Optional custom prompt for custom analysis runs"
|
|
7087
|
+
},
|
|
7088
|
+
input: {
|
|
7089
|
+
type: "string",
|
|
7090
|
+
description: "Optional entity, theme, belief, company, or search text for input-driven queries"
|
|
7091
|
+
},
|
|
7092
|
+
mode: {
|
|
7093
|
+
type: "string",
|
|
7094
|
+
description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
|
|
7095
|
+
},
|
|
7096
|
+
limit: {
|
|
7097
|
+
type: "number",
|
|
7098
|
+
description: "Maximum graph context rows to return"
|
|
7099
|
+
}
|
|
7100
|
+
},
|
|
7101
|
+
required: ["topicId"],
|
|
7102
|
+
response: {
|
|
7103
|
+
description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
|
|
7104
|
+
fields: {
|
|
7105
|
+
query: "object \u2014 selected query definition",
|
|
7106
|
+
prompt: "string \u2014 resolved prompt template",
|
|
7107
|
+
toolPlan: "array \u2014 public tools and args the model can call next",
|
|
7108
|
+
analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
|
|
7109
|
+
context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
|
|
7110
|
+
}
|
|
7111
|
+
},
|
|
7112
|
+
ownerModule: "graph-intelligence",
|
|
7113
|
+
ontologyPrimitive: "graph",
|
|
7114
|
+
tier: "showcase"
|
|
7115
|
+
};
|
|
6314
7116
|
var GET_FALSIFICATION_QUESTIONS = {
|
|
6315
7117
|
name: "get_falsification_questions",
|
|
6316
7118
|
description: "Generate Popperian falsification questions for beliefs. Like `git test` \u2014 identifies the questions most likely to disprove current beliefs. Karl Popper as a tool: surfaces what would need to be true to invalidate each belief.",
|
|
@@ -8886,6 +9688,8 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
8886
9688
|
// Graph intelligence (showcase)
|
|
8887
9689
|
detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
|
|
8888
9690
|
get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
|
|
9691
|
+
list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
|
|
9692
|
+
run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
|
|
8889
9693
|
get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
|
|
8890
9694
|
// Evidence operations (workhorse)
|
|
8891
9695
|
search_evidence: SEARCH_EVIDENCE,
|
|
@@ -8973,6 +9777,18 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
8973
9777
|
deprecate_ontology_version: DEPRECATE_ONTOLOGY_VERSION,
|
|
8974
9778
|
resolve_effective_ontology: RESOLVE_EFFECTIVE_ONTOLOGY
|
|
8975
9779
|
};
|
|
9780
|
+
var GIT_SEMANTIC_REQUIRED_TOOLS = Object.keys(MCP_TOOL_CONTRACTS);
|
|
9781
|
+
function validateGitSemantics(tool) {
|
|
9782
|
+
const desc = tool.description;
|
|
9783
|
+
const hasGitReference = /Like (`git |a `git |a merge conflict|opening a `git)/.test(desc);
|
|
9784
|
+
if (!hasGitReference) {
|
|
9785
|
+
return {
|
|
9786
|
+
valid: false,
|
|
9787
|
+
reason: `Tool "${tool.name}" description missing git-semantic reference`
|
|
9788
|
+
};
|
|
9789
|
+
}
|
|
9790
|
+
return { valid: true };
|
|
9791
|
+
}
|
|
8976
9792
|
|
|
8977
9793
|
// ../contracts/src/function-registry/manifest.ts
|
|
8978
9794
|
var publicEverywhere = {
|
|
@@ -9068,6 +9884,8 @@ var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
|
|
|
9068
9884
|
"traverse_graph",
|
|
9069
9885
|
"get_graph_neighborhood",
|
|
9070
9886
|
"get_graph_structure_analysis",
|
|
9887
|
+
"list_graph_intelligence_queries",
|
|
9888
|
+
"run_graph_intelligence_query",
|
|
9071
9889
|
"find_contradictions",
|
|
9072
9890
|
"flag_contradiction",
|
|
9073
9891
|
"detect_confirmation_bias",
|
|
@@ -11688,6 +12506,15 @@ var edgesContracts = [
|
|
|
11688
12506
|
args: queryLineageArgs
|
|
11689
12507
|
})
|
|
11690
12508
|
];
|
|
12509
|
+
var graphIntelligenceQueryModes = [
|
|
12510
|
+
"core",
|
|
12511
|
+
"bias",
|
|
12512
|
+
"stress",
|
|
12513
|
+
"operational",
|
|
12514
|
+
"alpha",
|
|
12515
|
+
"semantic",
|
|
12516
|
+
"evidence"
|
|
12517
|
+
];
|
|
11691
12518
|
var traversalLayerSchema = z.enum([
|
|
11692
12519
|
"L4",
|
|
11693
12520
|
"L3",
|
|
@@ -11721,6 +12548,22 @@ var graphNeighborhoodArgs = z.object({
|
|
|
11721
12548
|
topicId: z.string().optional().describe("Topic scope for edge lookup."),
|
|
11722
12549
|
limit: z.number().optional().describe("Maximum edges to return.")
|
|
11723
12550
|
});
|
|
12551
|
+
var graphIntelligenceModeSchema = z.enum([
|
|
12552
|
+
graphIntelligenceQueryModes[0],
|
|
12553
|
+
...graphIntelligenceQueryModes.slice(1)
|
|
12554
|
+
]);
|
|
12555
|
+
var graphIntelligenceCatalogArgs = z.object({
|
|
12556
|
+
categoryId: z.string().optional().describe("Optional query category filter."),
|
|
12557
|
+
mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
|
|
12558
|
+
});
|
|
12559
|
+
var graphIntelligenceRunArgs = z.object({
|
|
12560
|
+
topicId: z.string().describe("Topic to analyze."),
|
|
12561
|
+
queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
|
|
12562
|
+
prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
|
|
12563
|
+
input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
|
|
12564
|
+
mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
|
|
12565
|
+
limit: z.number().optional().describe("Maximum graph context rows to return.")
|
|
12566
|
+
});
|
|
11724
12567
|
var flagContradictionArgs = z.object({
|
|
11725
12568
|
beliefA: z.string().describe("First belief in tension."),
|
|
11726
12569
|
beliefB: z.string().describe("Second belief in tension."),
|
|
@@ -11827,17 +12670,49 @@ var graphContracts = [
|
|
|
11827
12670
|
}
|
|
11828
12671
|
}),
|
|
11829
12672
|
surfaceContract({
|
|
11830
|
-
name: "
|
|
12673
|
+
name: "list_graph_intelligence_queries",
|
|
11831
12674
|
kind: "query",
|
|
11832
12675
|
domain: "graph",
|
|
11833
12676
|
surfaceClass: "platform_public",
|
|
11834
|
-
path: "/graph/
|
|
11835
|
-
sdkNamespace: "
|
|
11836
|
-
sdkMethod: "
|
|
11837
|
-
summary: "
|
|
12677
|
+
path: "/graph-intelligence/queries",
|
|
12678
|
+
sdkNamespace: "graphAnalysis",
|
|
12679
|
+
sdkMethod: "listGraphIntelligenceQueries",
|
|
12680
|
+
summary: "List Graph Intelligence query catalog entries.",
|
|
11838
12681
|
convex: {
|
|
11839
|
-
module: "
|
|
11840
|
-
functionName: "
|
|
12682
|
+
module: "contextCompiler",
|
|
12683
|
+
functionName: "listGraphIntelligenceQueries",
|
|
12684
|
+
kind: "query"
|
|
12685
|
+
},
|
|
12686
|
+
args: graphIntelligenceCatalogArgs
|
|
12687
|
+
}),
|
|
12688
|
+
surfaceContract({
|
|
12689
|
+
name: "run_graph_intelligence_query",
|
|
12690
|
+
kind: "query",
|
|
12691
|
+
domain: "graph",
|
|
12692
|
+
surfaceClass: "platform_public",
|
|
12693
|
+
path: "/graph-intelligence/run",
|
|
12694
|
+
sdkNamespace: "graphAnalysis",
|
|
12695
|
+
sdkMethod: "runGraphIntelligenceQuery",
|
|
12696
|
+
summary: "Run a Graph Intelligence query against a topic graph.",
|
|
12697
|
+
convex: {
|
|
12698
|
+
module: "contextCompiler",
|
|
12699
|
+
functionName: "runGraphIntelligenceQuery",
|
|
12700
|
+
kind: "query"
|
|
12701
|
+
},
|
|
12702
|
+
args: graphIntelligenceRunArgs
|
|
12703
|
+
}),
|
|
12704
|
+
surfaceContract({
|
|
12705
|
+
name: "find_contradictions",
|
|
12706
|
+
kind: "query",
|
|
12707
|
+
domain: "graph",
|
|
12708
|
+
surfaceClass: "platform_public",
|
|
12709
|
+
path: "/graph/contradictions",
|
|
12710
|
+
sdkNamespace: "graph",
|
|
12711
|
+
sdkMethod: "findContradictions",
|
|
12712
|
+
summary: "Find contradiction edges.",
|
|
12713
|
+
convex: {
|
|
12714
|
+
module: "edges",
|
|
12715
|
+
functionName: "findContradictions",
|
|
11841
12716
|
kind: "query",
|
|
11842
12717
|
inputProjection: (input) => compactRecord4({
|
|
11843
12718
|
nodeId: input.nodeId ?? input.beliefId
|
|
@@ -13594,6 +14469,353 @@ function scoreObservation(record, terms) {
|
|
|
13594
14469
|
return score;
|
|
13595
14470
|
}
|
|
13596
14471
|
|
|
14472
|
+
// ../sdk/src/index.ts
|
|
14473
|
+
var src_exports = {};
|
|
14474
|
+
__export(src_exports, {
|
|
14475
|
+
ACTIVATE_WORKTREE: () => ACTIVATE_WORKTREE,
|
|
14476
|
+
ADD_EVIDENCE: () => ADD_EVIDENCE,
|
|
14477
|
+
ADD_WORKTREE: () => ADD_WORKTREE,
|
|
14478
|
+
ANALYZE_TOPIC_DENSITY: () => ANALYZE_TOPIC_DENSITY,
|
|
14479
|
+
ANSWER_QUESTION: () => ANSWER_QUESTION,
|
|
14480
|
+
APPLY_AUTO_BRANCHING: () => APPLY_AUTO_BRANCHING,
|
|
14481
|
+
APPLY_LENS_TO_TOPIC: () => APPLY_LENS_TO_TOPIC,
|
|
14482
|
+
APPLY_ONTOLOGY: () => APPLY_ONTOLOGY,
|
|
14483
|
+
ARCHIVE_BELIEF: () => ARCHIVE_BELIEF,
|
|
14484
|
+
ARCHIVE_ONTOLOGY: () => ARCHIVE_ONTOLOGY,
|
|
14485
|
+
ARCHIVE_QUESTION: () => ARCHIVE_QUESTION,
|
|
14486
|
+
BEGIN_BUILD_SESSION: () => BEGIN_BUILD_SESSION,
|
|
14487
|
+
BELIEF_STATUSES: () => BELIEF_STATUSES,
|
|
14488
|
+
BISECT_CONFIDENCE: () => BISECT_CONFIDENCE,
|
|
14489
|
+
BRANCH_DEPRECATION_MESSAGE: () => BRANCH_DEPRECATION_MESSAGE,
|
|
14490
|
+
BROADCAST_MESSAGE: () => BROADCAST_MESSAGE,
|
|
14491
|
+
CANONICAL_WORKFLOW_DEFINITIONS: () => CANONICAL_WORKFLOW_DEFINITIONS,
|
|
14492
|
+
CHECK_PERMISSION: () => CHECK_PERMISSION,
|
|
14493
|
+
CLAIM_FILES: () => CLAIM_FILES,
|
|
14494
|
+
COMPILE_CONTEXT: () => COMPILE_CONTEXT,
|
|
14495
|
+
COMPLETE_TASK: () => COMPLETE_TASK,
|
|
14496
|
+
CONFIDENCE_TRIGGERS: () => CONFIDENCE_TRIGGERS,
|
|
14497
|
+
CONTRADICTION_SEVERITIES: () => CONTRADICTION_SEVERITIES,
|
|
14498
|
+
CONTRADICTION_STATUSES: () => CONTRADICTION_STATUSES,
|
|
14499
|
+
CONTROL_OBJECT_BLAST_RADII: () => CONTROL_OBJECT_BLAST_RADII,
|
|
14500
|
+
CONTROL_OBJECT_EDIT_SURFACES: () => CONTROL_OBJECT_EDIT_SURFACES,
|
|
14501
|
+
CONTROL_OBJECT_INHERITANCE_RULES: () => CONTROL_OBJECT_INHERITANCE_RULES,
|
|
14502
|
+
CONTROL_OBJECT_KINDS: () => CONTROL_OBJECT_KINDS,
|
|
14503
|
+
CONTROL_OBJECT_OWNERSHIP_CONTRACT: () => CONTROL_OBJECT_OWNERSHIP_CONTRACT,
|
|
14504
|
+
CONTROL_OBJECT_OWNERSHIP_MATRIX: () => CONTROL_OBJECT_OWNERSHIP_MATRIX,
|
|
14505
|
+
CONTROL_OBJECT_OWNERSHIP_ROWS: () => CONTROL_OBJECT_OWNERSHIP_ROWS,
|
|
14506
|
+
CONTROL_OBJECT_OWNER_SCOPES: () => CONTROL_OBJECT_OWNER_SCOPES,
|
|
14507
|
+
CREATE_ANSWER: () => CREATE_ANSWER,
|
|
14508
|
+
CREATE_BELIEF: () => CREATE_BELIEF,
|
|
14509
|
+
CREATE_EDGE: () => CREATE_EDGE,
|
|
14510
|
+
CREATE_EPISTEMIC_CONTRACT: () => CREATE_EPISTEMIC_CONTRACT,
|
|
14511
|
+
CREATE_EVIDENCE: () => CREATE_EVIDENCE,
|
|
14512
|
+
CREATE_LENS: () => CREATE_LENS,
|
|
14513
|
+
CREATE_ONTOLOGY: () => CREATE_ONTOLOGY,
|
|
14514
|
+
CREATE_ONTOLOGY_VERSION: () => CREATE_ONTOLOGY_VERSION,
|
|
14515
|
+
CREATE_QUESTION: () => CREATE_QUESTION,
|
|
14516
|
+
CREATE_TASK: () => CREATE_TASK,
|
|
14517
|
+
CREATE_TOPIC: () => CREATE_TOPIC,
|
|
14518
|
+
CustomToolRegistryError: () => CustomToolRegistryError,
|
|
14519
|
+
DEFAULT_TIER_APPROVAL_MODE: () => DEFAULT_TIER_APPROVAL_MODE,
|
|
14520
|
+
DEFAULT_WORKFLOW_AUTO_FIX_POLICY: () => DEFAULT_WORKFLOW_AUTO_FIX_POLICY,
|
|
14521
|
+
DEFEAT_TYPES: () => DEFEAT_TYPES,
|
|
14522
|
+
DEPRECATE_ONTOLOGY_VERSION: () => DEPRECATE_ONTOLOGY_VERSION,
|
|
14523
|
+
DETECT_CONFIRMATION_BIAS: () => DETECT_CONFIRMATION_BIAS,
|
|
14524
|
+
DISCOVER: () => DISCOVER,
|
|
14525
|
+
DISCOVER_ENTITY_CONNECTIONS: () => DISCOVER_ENTITY_CONNECTIONS,
|
|
14526
|
+
DOMAIN_EVENT_TYPES: () => DOMAIN_EVENT_TYPES,
|
|
14527
|
+
DOMAIN_EVENT_VERSION: () => DOMAIN_EVENT_VERSION,
|
|
14528
|
+
DeviceAuthorizationError: () => DeviceAuthorizationError,
|
|
14529
|
+
EDGE_TYPES: () => EDGE_TYPES,
|
|
14530
|
+
EMBEDDINGS_FIELDS: () => EMBEDDINGS_FIELDS,
|
|
14531
|
+
END_SESSION: () => END_SESSION,
|
|
14532
|
+
EPISTEMIC_EDGE_TYPES: () => EPISTEMIC_EDGE_TYPES,
|
|
14533
|
+
EPISTEMIC_LAYERS: () => EPISTEMIC_LAYERS,
|
|
14534
|
+
EVALUATE_CONTRACT: () => EVALUATE_CONTRACT,
|
|
14535
|
+
EVENTING_FIELDS: () => EVENTING_FIELDS,
|
|
14536
|
+
EVENT_RETENTION_DEFAULT_DAYS: () => EVENT_RETENTION_DEFAULT_DAYS,
|
|
14537
|
+
FILTER_BY_PERMISSION: () => FILTER_BY_PERMISSION,
|
|
14538
|
+
FIND_CONTRADICTIONS: () => FIND_CONTRADICTIONS,
|
|
14539
|
+
FIND_MISSING_QUESTIONS: () => FIND_MISSING_QUESTIONS,
|
|
14540
|
+
FLAG_CONTRADICTION: () => FLAG_CONTRADICTION,
|
|
14541
|
+
FORK_BELIEF: () => FORK_BELIEF,
|
|
14542
|
+
FORK_REASONS: () => FORK_REASONS,
|
|
14543
|
+
FUNCTION_SURFACE_METHOD_PATHS: () => FUNCTION_SURFACE_METHOD_PATHS,
|
|
14544
|
+
GENERATE_SESSION_HANDOFF: () => GENERATE_SESSION_HANDOFF,
|
|
14545
|
+
GET_AGENT_INBOX: () => GET_AGENT_INBOX,
|
|
14546
|
+
GET_ANSWER: () => GET_ANSWER,
|
|
14547
|
+
GET_AUDIT_TRAIL: () => GET_AUDIT_TRAIL,
|
|
14548
|
+
GET_BELIEF: () => GET_BELIEF,
|
|
14549
|
+
GET_CHANGE_HISTORY: () => GET_CHANGE_HISTORY,
|
|
14550
|
+
GET_CODE_CONTEXT: () => GET_CODE_CONTEXT,
|
|
14551
|
+
GET_CONFIDENCE_HISTORY: () => GET_CONFIDENCE_HISTORY,
|
|
14552
|
+
GET_CONTRACT_STATUS: () => GET_CONTRACT_STATUS,
|
|
14553
|
+
GET_EVIDENCE: () => GET_EVIDENCE,
|
|
14554
|
+
GET_FAILURE_LOG: () => GET_FAILURE_LOG,
|
|
14555
|
+
GET_FALSIFICATION_QUESTIONS: () => GET_FALSIFICATION_QUESTIONS,
|
|
14556
|
+
GET_GRAPH_GAPS: () => GET_GRAPH_GAPS,
|
|
14557
|
+
GET_GRAPH_NEIGHBORHOOD: () => GET_GRAPH_NEIGHBORHOOD,
|
|
14558
|
+
GET_GRAPH_STRUCTURE_ANALYSIS: () => GET_GRAPH_STRUCTURE_ANALYSIS,
|
|
14559
|
+
GET_HIGH_PRIORITY_QUESTIONS: () => GET_HIGH_PRIORITY_QUESTIONS,
|
|
14560
|
+
GET_LATTICE_COVERAGE: () => GET_LATTICE_COVERAGE,
|
|
14561
|
+
GET_OBSERVATION_CONTEXT: () => GET_OBSERVATION_CONTEXT,
|
|
14562
|
+
GET_ONTOLOGY: () => GET_ONTOLOGY,
|
|
14563
|
+
GET_QUESTION: () => GET_QUESTION,
|
|
14564
|
+
GET_TOPIC: () => GET_TOPIC,
|
|
14565
|
+
GET_TOPIC_COVERAGE: () => GET_TOPIC_COVERAGE,
|
|
14566
|
+
GET_TOPIC_TREE: () => GET_TOPIC_TREE,
|
|
14567
|
+
GIT_SEMANTIC_REQUIRED_TOOLS: () => GIT_SEMANTIC_REQUIRED_TOOLS,
|
|
14568
|
+
GRAPH_ANALYSIS_ANALYSIS_FIELDS: () => GRAPH_ANALYSIS_ANALYSIS_FIELDS,
|
|
14569
|
+
GRAPH_ANALYSIS_COMPUTE_FIELDS: () => GRAPH_ANALYSIS_COMPUTE_FIELDS,
|
|
14570
|
+
GRAPH_ANALYSIS_SUGGESTION_FIELDS: () => GRAPH_ANALYSIS_SUGGESTION_FIELDS,
|
|
14571
|
+
GRAPH_INTELLIGENCE_MODE_TOOL_NAMES: () => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES,
|
|
14572
|
+
GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES: () => GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES,
|
|
14573
|
+
GRAPH_INTELLIGENCE_QUERIES: () => GRAPH_INTELLIGENCE_QUERIES,
|
|
14574
|
+
GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS: () => GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS,
|
|
14575
|
+
GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION: () => GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION,
|
|
14576
|
+
GRAPH_INTELLIGENCE_QUERY_CATEGORIES: () => GRAPH_INTELLIGENCE_QUERY_CATEGORIES,
|
|
14577
|
+
GRAPH_INTELLIGENCE_QUERY_MODES: () => GRAPH_INTELLIGENCE_QUERY_MODES,
|
|
14578
|
+
GRAPH_INTELLIGENCE_QUICK_QUERIES: () => GRAPH_INTELLIGENCE_QUICK_QUERIES,
|
|
14579
|
+
GRAPH_RECOMMENDATION_FIELDS: () => GRAPH_RECOMMENDATION_FIELDS,
|
|
14580
|
+
GRAPH_STATE_CLASSIFIER_FIELDS: () => GRAPH_STATE_CLASSIFIER_FIELDS,
|
|
14581
|
+
HEARTBEAT_SESSION: () => HEARTBEAT_SESSION,
|
|
14582
|
+
IDENTITY_WHOAMI: () => IDENTITY_WHOAMI,
|
|
14583
|
+
INGEST_OBSERVATION: () => INGEST_OBSERVATION,
|
|
14584
|
+
InfisicalRuntimeError: () => InfisicalRuntimeError,
|
|
14585
|
+
JOBS_FIELDS: () => JOBS_FIELDS,
|
|
14586
|
+
JUDGMENT_TYPES: () => JUDGMENT_TYPES,
|
|
14587
|
+
LENS_PERSPECTIVE_TYPES: () => LENS_PERSPECTIVE_TYPES2,
|
|
14588
|
+
LENS_STATUSES: () => LENS_STATUSES,
|
|
14589
|
+
LENS_TASK_TEMPLATE_PRIORITIES: () => LENS_TASK_TEMPLATE_PRIORITIES,
|
|
14590
|
+
LINK_EVIDENCE: () => LINK_EVIDENCE,
|
|
14591
|
+
LINK_EVIDENCE_TO_BELIEF: () => LINK_EVIDENCE_TO_BELIEF,
|
|
14592
|
+
LINK_EVIDENCE_TO_QUESTION: () => LINK_EVIDENCE_TO_QUESTION,
|
|
14593
|
+
LIST_ACTIVE_SESSIONS: () => LIST_ACTIVE_SESSIONS,
|
|
14594
|
+
LIST_ALL_WORKTREES: () => LIST_ALL_WORKTREES,
|
|
14595
|
+
LIST_BELIEFS: () => LIST_BELIEFS,
|
|
14596
|
+
LIST_CAMPAIGNS: () => LIST_CAMPAIGNS,
|
|
14597
|
+
LIST_EVIDENCE: () => LIST_EVIDENCE,
|
|
14598
|
+
LIST_GRAPH_INTELLIGENCE_QUERIES: () => LIST_GRAPH_INTELLIGENCE_QUERIES,
|
|
14599
|
+
LIST_LENSES: () => LIST_LENSES,
|
|
14600
|
+
LIST_ONTOLOGIES: () => LIST_ONTOLOGIES,
|
|
14601
|
+
LIST_QUESTIONS: () => LIST_QUESTIONS,
|
|
14602
|
+
LIST_TASKS: () => LIST_TASKS,
|
|
14603
|
+
LIST_TOPICS: () => LIST_TOPICS,
|
|
14604
|
+
LIST_WORKTREES: () => LIST_WORKTREES,
|
|
14605
|
+
LUCERN_SDK_VERSION: () => LUCERN_SDK_VERSION,
|
|
14606
|
+
LucernApiError: () => LucernApiError,
|
|
14607
|
+
LucernSdkAuthContextError: () => LucernSdkAuthContextError,
|
|
14608
|
+
MANAGE_WRITE_POLICY: () => MANAGE_WRITE_POLICY,
|
|
14609
|
+
MATCH_ENTITY_TYPE: () => MATCH_ENTITY_TYPE,
|
|
14610
|
+
MAX_ENTITY_LIMIT: () => MAX_ENTITY_LIMIT,
|
|
14611
|
+
MCP_ALWAYS_ALLOWED_TOOL_NAMES: () => MCP_ALWAYS_ALLOWED_TOOL_NAMES,
|
|
14612
|
+
MCP_TOOL_CONTRACTS: () => MCP_TOOL_CONTRACTS,
|
|
14613
|
+
MERGE: () => MERGE,
|
|
14614
|
+
MERGE_OUTCOMES: () => MERGE_OUTCOMES,
|
|
14615
|
+
MODEL_RUNTIME_FIELDS: () => MODEL_RUNTIME_FIELDS,
|
|
14616
|
+
MODULATE_CONFIDENCE: () => MODULATE_CONFIDENCE,
|
|
14617
|
+
MORNING_BRIEF_WORKFLOW_ID: () => MORNING_BRIEF_WORKFLOW_ID,
|
|
14618
|
+
NIGHTLY_RECONCILIATION_WORKFLOW_ID: () => NIGHTLY_RECONCILIATION_WORKFLOW_ID,
|
|
14619
|
+
ONTOLOGY_LINK_FIELDS: () => ONTOLOGY_LINK_FIELDS,
|
|
14620
|
+
OPEN_PULL_REQUEST: () => OPEN_PULL_REQUEST,
|
|
14621
|
+
ORG_GRAPH_SEARCH_FIELDS: () => ORG_GRAPH_SEARCH_FIELDS,
|
|
14622
|
+
PIPELINE_SNAPSHOT: () => PIPELINE_SNAPSHOT,
|
|
14623
|
+
PUBLISH_ONTOLOGY_VERSION: () => PUBLISH_ONTOLOGY_VERSION,
|
|
14624
|
+
PUSH: () => PUSH,
|
|
14625
|
+
QUERY_LINEAGE: () => QUERY_LINEAGE,
|
|
14626
|
+
REASONING_METHODS: () => REASONING_METHODS,
|
|
14627
|
+
RECORD_ATTEMPT: () => RECORD_ATTEMPT,
|
|
14628
|
+
RECORD_JUDGMENT: () => RECORD_JUDGMENT,
|
|
14629
|
+
RECORD_SCOPE_LEARNING: () => RECORD_SCOPE_LEARNING,
|
|
14630
|
+
REFINE_BELIEF: () => REFINE_BELIEF,
|
|
14631
|
+
REFINE_QUESTION: () => REFINE_QUESTION,
|
|
14632
|
+
REGISTER_SESSION: () => REGISTER_SESSION,
|
|
14633
|
+
REMOVE_LENS_FROM_TOPIC: () => REMOVE_LENS_FROM_TOPIC,
|
|
14634
|
+
RESOLVE_EFFECTIVE_ONTOLOGY: () => RESOLVE_EFFECTIVE_ONTOLOGY,
|
|
14635
|
+
RUN_GRAPH_INTELLIGENCE_QUERY: () => RUN_GRAPH_INTELLIGENCE_QUERY,
|
|
14636
|
+
SEARCH_BELIEFS: () => SEARCH_BELIEFS,
|
|
14637
|
+
SEARCH_EVIDENCE: () => SEARCH_EVIDENCE,
|
|
14638
|
+
SEED_BELIEF_LATTICE: () => SEED_BELIEF_LATTICE,
|
|
14639
|
+
SEND_AGENT_MESSAGE: () => SEND_AGENT_MESSAGE,
|
|
14640
|
+
SESSION_AUTH_MODES: () => SESSION_AUTH_MODES,
|
|
14641
|
+
SESSION_LIFECYCLE_STATUSES: () => SESSION_LIFECYCLE_STATUSES,
|
|
14642
|
+
SESSION_PRINCIPAL_TYPES: () => SESSION_PRINCIPAL_TYPES,
|
|
14643
|
+
STRUCTURAL_EDGE_TYPES: () => STRUCTURAL_EDGE_TYPES,
|
|
14644
|
+
TELEMETRY_FIELDS: () => TELEMETRY_FIELDS,
|
|
14645
|
+
TENANT_IDENTITY_FIELDS: () => TENANT_IDENTITY_FIELDS,
|
|
14646
|
+
TOOL_REGISTRY_FIELDS: () => TOOL_REGISTRY_FIELDS,
|
|
14647
|
+
TRACE_ENTITY_IMPACT: () => TRACE_ENTITY_IMPACT,
|
|
14648
|
+
TRAVERSE_GRAPH: () => TRAVERSE_GRAPH,
|
|
14649
|
+
TRIGGER_BELIEF_REVIEW: () => TRIGGER_BELIEF_REVIEW,
|
|
14650
|
+
UPDATE_ONTOLOGY: () => UPDATE_ONTOLOGY,
|
|
14651
|
+
UPDATE_QUESTION_STATUS: () => UPDATE_QUESTION_STATUS,
|
|
14652
|
+
UPDATE_TASK: () => UPDATE_TASK,
|
|
14653
|
+
UPDATE_TOPIC: () => UPDATE_TOPIC,
|
|
14654
|
+
UPDATE_WORKTREE_METADATA: () => UPDATE_WORKTREE_METADATA,
|
|
14655
|
+
UPDATE_WORKTREE_TARGETS: () => UPDATE_WORKTREE_TARGETS,
|
|
14656
|
+
WEBHOOK_MAX_ATTEMPTS: () => WEBHOOK_MAX_ATTEMPTS,
|
|
14657
|
+
WEBHOOK_RETRY_DELAYS_MS: () => WEBHOOK_RETRY_DELAYS_MS,
|
|
14658
|
+
WORKFLOW_ACTION_KINDS: () => WORKFLOW_ACTION_KINDS,
|
|
14659
|
+
WORKFLOW_APPROVAL_MODES: () => WORKFLOW_APPROVAL_MODES,
|
|
14660
|
+
WORKFLOW_AUTO_FIX_MODES: () => WORKFLOW_AUTO_FIX_MODES,
|
|
14661
|
+
WORKFLOW_HOOK_EVENTS: () => WORKFLOW_HOOK_EVENTS,
|
|
14662
|
+
WORKFLOW_INTEGRITY_CHECKS: () => WORKFLOW_INTEGRITY_CHECKS,
|
|
14663
|
+
WORKFLOW_MUTATION_TIERS: () => WORKFLOW_MUTATION_TIERS,
|
|
14664
|
+
WORKFLOW_OUTPUT_KINDS: () => WORKFLOW_OUTPUT_KINDS,
|
|
14665
|
+
WORKFLOW_PROOF_ARTIFACT_KINDS: () => WORKFLOW_PROOF_ARTIFACT_KINDS,
|
|
14666
|
+
WORKFLOW_RUNTIME_SCHEMA_VERSION: () => WORKFLOW_RUNTIME_SCHEMA_VERSION,
|
|
14667
|
+
WORKFLOW_RUN_STATUSES: () => WORKFLOW_RUN_STATUSES,
|
|
14668
|
+
WORKFLOW_STAFFING_HINTS: () => WORKFLOW_STAFFING_HINTS,
|
|
14669
|
+
WORKFLOW_TRIGGER_KINDS: () => WORKFLOW_TRIGGER_KINDS,
|
|
14670
|
+
WORKTREE_PHASES: () => WORKTREE_PHASES,
|
|
14671
|
+
applyInfisicalRuntimeEnv: () => applyInfisicalRuntimeEnv,
|
|
14672
|
+
asListItems: () => asListItems,
|
|
14673
|
+
assertValidWebhookSecret: () => assertValidWebhookSecret,
|
|
14674
|
+
assertValidWebhookUrl: () => assertValidWebhookUrl,
|
|
14675
|
+
buildDeprecatedBranchMetadata: () => buildDeprecatedBranchMetadata,
|
|
14676
|
+
buildDomainEvent: () => buildDomainEvent,
|
|
14677
|
+
buildMcpToolContracts: () => buildMcpToolContracts,
|
|
14678
|
+
buildMcpToolManifest: () => buildMcpToolManifest,
|
|
14679
|
+
clearRegisteredCustomTools: () => clearRegisteredCustomTools,
|
|
14680
|
+
compareEventCursor: () => compareEventCursor,
|
|
14681
|
+
compileContextPackFromSnapshot: () => compileContextPackFromSnapshot,
|
|
14682
|
+
computeWebhookSignature: () => computeWebhookSignature,
|
|
14683
|
+
createAdminClient: () => createAdminClient,
|
|
14684
|
+
createAnswersClient: () => createAnswersClient,
|
|
14685
|
+
createAudiencesClient: () => createAudiencesClient,
|
|
14686
|
+
createAuditClient: () => createAuditClient,
|
|
14687
|
+
createAuthDeviceClient: () => createAuthDeviceClient,
|
|
14688
|
+
createBeliefsClient: () => createBeliefsClient,
|
|
14689
|
+
createCanonicalAuthHeaders: () => createCanonicalAuthHeaders,
|
|
14690
|
+
createContextClient: () => createContextClient,
|
|
14691
|
+
createContextFacade: () => createContextFacade,
|
|
14692
|
+
createDecisionsClient: () => createDecisionsClient,
|
|
14693
|
+
createEmbeddingsClient: () => createEmbeddingsClient,
|
|
14694
|
+
createEventId: () => createEventId,
|
|
14695
|
+
createEventingClient: () => createEventingClient,
|
|
14696
|
+
createEventsClientCore: () => createEventsClientCore,
|
|
14697
|
+
createEvidenceClient: () => createEvidenceClient,
|
|
14698
|
+
createFunctionSurfaceClient: () => createFunctionSurfaceClient,
|
|
14699
|
+
createGatewayRequestClient: () => createGatewayRequestClient,
|
|
14700
|
+
createGraphAnalysisClient: () => createGraphAnalysisClient,
|
|
14701
|
+
createGraphClient: () => createGraphClient,
|
|
14702
|
+
createGraphRecommendationsClient: () => createGraphRecommendationsClient,
|
|
14703
|
+
createGraphStateClassifierClient: () => createGraphStateClassifierClient,
|
|
14704
|
+
createHarnessClient: () => createHarnessClient,
|
|
14705
|
+
createIdentityClient: () => createIdentityClient,
|
|
14706
|
+
createJobsClient: () => createJobsClient,
|
|
14707
|
+
createLearningClient: () => createLearningClient,
|
|
14708
|
+
createListResult: () => createListResult,
|
|
14709
|
+
createLucernClient: () => createLucernClient,
|
|
14710
|
+
createModelRuntimeClient: () => createModelRuntimeClient,
|
|
14711
|
+
createOntologyClient: () => createOntologyClient,
|
|
14712
|
+
createOntologyLinksClient: () => createOntologyLinksClient,
|
|
14713
|
+
createOrgGraphSearchClient: () => createOrgGraphSearchClient,
|
|
14714
|
+
createPacksClient: () => createPacksClient,
|
|
14715
|
+
createPolicyClient: () => createPolicyClient,
|
|
14716
|
+
createReportsClient: () => createReportsClient,
|
|
14717
|
+
createSchemaClient: () => createSchemaClient,
|
|
14718
|
+
createSourcesClient: () => createSourcesClient,
|
|
14719
|
+
createTelemetryClient: () => createTelemetryClient,
|
|
14720
|
+
createToolRegistryClient: () => createToolRegistryClient,
|
|
14721
|
+
createTopicsClient: () => createTopicsClient,
|
|
14722
|
+
createWebhooksClientCore: () => createWebhooksClientCore,
|
|
14723
|
+
createWorkflowClient: () => createWorkflowClient,
|
|
14724
|
+
decodeEventCursor: () => decodeEventCursor,
|
|
14725
|
+
emitDomainEvent: () => emitDomainEvent,
|
|
14726
|
+
encodeEventCursor: () => encodeEventCursor,
|
|
14727
|
+
eventPatternToRegExp: () => eventPatternToRegExp,
|
|
14728
|
+
fillGraphIntelligencePromptTemplate: () => fillGraphIntelligencePromptTemplate,
|
|
14729
|
+
getControlObjectOwnershipCase: () => getControlObjectOwnershipCase,
|
|
14730
|
+
getGraphIntelligenceQuery: () => getGraphIntelligenceQuery,
|
|
14731
|
+
getMcpToolExposure: () => getMcpToolExposure,
|
|
14732
|
+
getRegisteredCustomTool: () => getRegisteredCustomTool,
|
|
14733
|
+
hydrateInfisicalRuntimeEnv: () => hydrateInfisicalRuntimeEnv,
|
|
14734
|
+
inferActorType: () => inferActorType,
|
|
14735
|
+
inferLensPerspectiveTypeFromBranchSchema: () => inferLensPerspectiveTypeFromBranchSchema,
|
|
14736
|
+
inferSessionPrincipalType: () => inferSessionPrincipalType,
|
|
14737
|
+
invokeRegisteredCustomTool: () => invokeRegisteredCustomTool,
|
|
14738
|
+
isAfterCursor: () => isAfterCursor,
|
|
14739
|
+
isGraphIntelligenceQueryMode: () => isGraphIntelligenceQueryMode,
|
|
14740
|
+
isInfisicalRuntimeDisabled: () => isInfisicalRuntimeDisabled,
|
|
14741
|
+
isLensFilterCriteria: () => isLensFilterCriteria2,
|
|
14742
|
+
isLucernPrompt: () => isLucernPrompt,
|
|
14743
|
+
isMcpToolAllowed: () => isMcpToolAllowed,
|
|
14744
|
+
isTaxonomyFilterCriteriaV1: () => isTaxonomyFilterCriteriaV12,
|
|
14745
|
+
lastDelegator: () => lastDelegator,
|
|
14746
|
+
listControlObjectOwnershipCases: () => listControlObjectOwnershipCases,
|
|
14747
|
+
listGraphIntelligenceQueries: () => listGraphIntelligenceQueries,
|
|
14748
|
+
listRegisteredCustomTools: () => listRegisteredCustomTools,
|
|
14749
|
+
mapAliasedList: () => mapAliasedList,
|
|
14750
|
+
mapGatewayData: () => mapGatewayData,
|
|
14751
|
+
mapOpinionHistoryEntriesFromGatewayData: () => mapOpinionHistoryEntriesFromGatewayData,
|
|
14752
|
+
matchesAnyEventPattern: () => matchesAnyEventPattern,
|
|
14753
|
+
matchesEventPattern: () => matchesEventPattern,
|
|
14754
|
+
mcpContractToInputSchema: () => mcpContractToInputSchema,
|
|
14755
|
+
mcpContractToManifestEntry: () => mcpContractToManifestEntry,
|
|
14756
|
+
migrateBranchToLens: () => migrateBranchToLens,
|
|
14757
|
+
nextDeliveryAttemptAt: () => nextDeliveryAttemptAt,
|
|
14758
|
+
normalizeCanonicalLucernAuthContext: () => normalizeCanonicalLucernAuthContext,
|
|
14759
|
+
normalizeDelegationChain: () => normalizeDelegationChain,
|
|
14760
|
+
normalizeNodeVerificationStatus: () => normalizeNodeVerificationStatus,
|
|
14761
|
+
normalizeNodeWriteInput: () => normalizeNodeWriteInput,
|
|
14762
|
+
normalizeRetentionDays: () => normalizeRetentionDays,
|
|
14763
|
+
normalizeTopicQuery: () => normalizeTopicQuery,
|
|
14764
|
+
normalizeWebhookPatterns: () => normalizeWebhookPatterns,
|
|
14765
|
+
opinionFromBaseRate: () => opinionFromBaseRate,
|
|
14766
|
+
opinionFromDogmatic: () => opinionFromDogmatic,
|
|
14767
|
+
opinionFromProjected: () => opinionFromProjected,
|
|
14768
|
+
planContextPackCompilation: () => planContextPackCompilation,
|
|
14769
|
+
randomIdempotencyKey: () => randomIdempotencyKey,
|
|
14770
|
+
readInfisicalRuntimeBootstrap: () => readInfisicalRuntimeBootstrap,
|
|
14771
|
+
registerCustomTool: () => registerCustomTool,
|
|
14772
|
+
resolveDeliveryFailureStatus: () => resolveDeliveryFailureStatus,
|
|
14773
|
+
resolveText: () => resolveText,
|
|
14774
|
+
resolveTopicId: () => resolveTopicId,
|
|
14775
|
+
sanitizeWebhookRecord: () => sanitizeWebhookRecord,
|
|
14776
|
+
sortEventsByCursor: () => sortEventsByCursor,
|
|
14777
|
+
toQueryString: () => toQueryString,
|
|
14778
|
+
truncateWebhookResponseBody: () => truncateWebhookResponseBody,
|
|
14779
|
+
unregisterCustomTool: () => unregisterCustomTool,
|
|
14780
|
+
validateFilterCriteria: () => validateFilterCriteria2,
|
|
14781
|
+
validateGitSemantics: () => validateGitSemantics,
|
|
14782
|
+
withSdkAliases: () => withSdkAliases,
|
|
14783
|
+
withTextAlias: () => withTextAlias,
|
|
14784
|
+
withTopicAlias: () => withTopicAlias
|
|
14785
|
+
});
|
|
14786
|
+
|
|
14787
|
+
// ../sdk/src/opinion.ts
|
|
14788
|
+
function clamp01(value) {
|
|
14789
|
+
if (!Number.isFinite(value)) {
|
|
14790
|
+
return 0;
|
|
14791
|
+
}
|
|
14792
|
+
return Math.max(0, Math.min(1, value));
|
|
14793
|
+
}
|
|
14794
|
+
function vacuous(baseRate) {
|
|
14795
|
+
return { b: 0, d: 0, u: 1, a: clamp01(baseRate) };
|
|
14796
|
+
}
|
|
14797
|
+
function dogmatic(probability, baseRate) {
|
|
14798
|
+
const p = clamp01(probability);
|
|
14799
|
+
return { b: p, d: 1 - p, u: 0, a: clamp01(baseRate) };
|
|
14800
|
+
}
|
|
14801
|
+
function opinionFromBaseRate(probability) {
|
|
14802
|
+
return vacuous(clamp01(probability));
|
|
14803
|
+
}
|
|
14804
|
+
function opinionFromDogmatic(probability, baseRate) {
|
|
14805
|
+
return dogmatic(clamp01(probability), clamp01(baseRate));
|
|
14806
|
+
}
|
|
14807
|
+
function opinionFromProjected(probability, uncertainty, baseRate) {
|
|
14808
|
+
const p = clamp01(probability);
|
|
14809
|
+
const u = clamp01(uncertainty);
|
|
14810
|
+
const remainingMass = 1 - u;
|
|
14811
|
+
return {
|
|
14812
|
+
b: p * remainingMass,
|
|
14813
|
+
d: (1 - p) * remainingMass,
|
|
14814
|
+
u,
|
|
14815
|
+
a: clamp01(baseRate)
|
|
14816
|
+
};
|
|
14817
|
+
}
|
|
14818
|
+
|
|
13597
14819
|
// ../sdk/src/authContext.ts
|
|
13598
14820
|
var LucernSdkAuthContextError = class extends Error {
|
|
13599
14821
|
reason;
|
|
@@ -14902,7 +16124,7 @@ function readString2(value) {
|
|
|
14902
16124
|
function readNumber(value) {
|
|
14903
16125
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
14904
16126
|
}
|
|
14905
|
-
function
|
|
16127
|
+
function clamp012(value) {
|
|
14906
16128
|
return Math.max(0, Math.min(1, value));
|
|
14907
16129
|
}
|
|
14908
16130
|
function normalizeOpinionTuple(record) {
|
|
@@ -14917,10 +16139,10 @@ function normalizeOpinionTuple(record) {
|
|
|
14917
16139
|
);
|
|
14918
16140
|
}
|
|
14919
16141
|
return {
|
|
14920
|
-
b:
|
|
14921
|
-
d:
|
|
14922
|
-
u:
|
|
14923
|
-
a:
|
|
16142
|
+
b: clamp012(rawBelief),
|
|
16143
|
+
d: clamp012(rawDisbelief),
|
|
16144
|
+
u: clamp012(rawUncertainty),
|
|
16145
|
+
a: clamp012(rawBaseRate)
|
|
14924
16146
|
};
|
|
14925
16147
|
}
|
|
14926
16148
|
function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
@@ -14928,7 +16150,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
14928
16150
|
return entries2.map((value) => {
|
|
14929
16151
|
const record = asRecord2(value);
|
|
14930
16152
|
const tuple = normalizeOpinionTuple(record);
|
|
14931
|
-
const projected = readNumber(record.confidence) ??
|
|
16153
|
+
const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
|
|
14932
16154
|
const triggeringEvidenceId = readString2(record.triggeringEvidenceId);
|
|
14933
16155
|
const triggeringQuestionId = readString2(record.triggeringQuestionId);
|
|
14934
16156
|
const triggeringAnswerId = readString2(record.triggeringAnswerId);
|
|
@@ -14947,7 +16169,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
14947
16169
|
d: tuple.d,
|
|
14948
16170
|
u: tuple.u,
|
|
14949
16171
|
a: tuple.a,
|
|
14950
|
-
P:
|
|
16172
|
+
P: clamp012(projected),
|
|
14951
16173
|
trigger,
|
|
14952
16174
|
...triggeringRef ? { triggeringRef } : {},
|
|
14953
16175
|
...readString2(record.rationale) ? { rationale: readString2(record.rationale) } : {},
|
|
@@ -17709,9 +18931,33 @@ function graphAnalysisQuery(input) {
|
|
|
17709
18931
|
cursor: input.cursor
|
|
17710
18932
|
};
|
|
17711
18933
|
}
|
|
18934
|
+
function normalizeRunQueryPayload(input) {
|
|
18935
|
+
return {
|
|
18936
|
+
...input,
|
|
18937
|
+
topicId: requireTopicId2(input),
|
|
18938
|
+
projectId: void 0
|
|
18939
|
+
};
|
|
18940
|
+
}
|
|
17712
18941
|
function createGraphAnalysisClient(config = {}) {
|
|
17713
18942
|
const gateway = createGatewayRequestClient(config);
|
|
17714
18943
|
return {
|
|
18944
|
+
listGraphIntelligenceQueries(input = {}) {
|
|
18945
|
+
return gateway.request({
|
|
18946
|
+
path: "/api/platform/v1/graph-intelligence/queries",
|
|
18947
|
+
method: "POST",
|
|
18948
|
+
body: {
|
|
18949
|
+
categoryId: input.categoryId,
|
|
18950
|
+
mode: input.mode
|
|
18951
|
+
}
|
|
18952
|
+
});
|
|
18953
|
+
},
|
|
18954
|
+
runGraphIntelligenceQuery(input) {
|
|
18955
|
+
return gateway.request({
|
|
18956
|
+
path: "/api/platform/v1/graph-intelligence/run",
|
|
18957
|
+
method: "POST",
|
|
18958
|
+
body: normalizeRunQueryPayload(input)
|
|
18959
|
+
});
|
|
18960
|
+
},
|
|
17715
18961
|
saveAnalysis(input, idempotencyKey) {
|
|
17716
18962
|
return gateway.request({
|
|
17717
18963
|
path: "/api/platform/v1/graph-analysis/analyses",
|
|
@@ -18548,6 +19794,120 @@ function createMcpClient(config = {}) {
|
|
|
18548
19794
|
}
|
|
18549
19795
|
|
|
18550
19796
|
// ../sdk/src/generated/functionSurface.ts
|
|
19797
|
+
var FUNCTION_SURFACE_METHOD_PATHS = [
|
|
19798
|
+
"answers.answerQuestion",
|
|
19799
|
+
"answers.createAnswer",
|
|
19800
|
+
"answers.getAnswer",
|
|
19801
|
+
"beliefs.archiveBelief",
|
|
19802
|
+
"beliefs.bisectConfidence",
|
|
19803
|
+
"beliefs.createBelief",
|
|
19804
|
+
"beliefs.forkBelief",
|
|
19805
|
+
"beliefs.getBelief",
|
|
19806
|
+
"beliefs.getConfidenceHistory",
|
|
19807
|
+
"beliefs.listBeliefs",
|
|
19808
|
+
"beliefs.modulateConfidence",
|
|
19809
|
+
"beliefs.refineBelief",
|
|
19810
|
+
"beliefs.searchBeliefs",
|
|
19811
|
+
"bootstrap.generateSessionHandoff",
|
|
19812
|
+
"coding.getChangeHistory",
|
|
19813
|
+
"coding.getCodeContext",
|
|
19814
|
+
"coding.getFailureLog",
|
|
19815
|
+
"coding.recordAttempt",
|
|
19816
|
+
"context.analyzeTopicDensity",
|
|
19817
|
+
"context.applyAutoBranching",
|
|
19818
|
+
"context.compileContext",
|
|
19819
|
+
"context.discover",
|
|
19820
|
+
"context.discoverEntityConnections",
|
|
19821
|
+
"context.getLatticeCoverage",
|
|
19822
|
+
"context.recordScopeLearning",
|
|
19823
|
+
"context.seedBeliefLattice",
|
|
19824
|
+
"context.triggerBeliefReview",
|
|
19825
|
+
"contracts.createEpistemicContract",
|
|
19826
|
+
"contracts.evaluateContract",
|
|
19827
|
+
"contracts.getContractStatus",
|
|
19828
|
+
"contradictions.flagContradiction",
|
|
19829
|
+
"coordination.broadcastMessage",
|
|
19830
|
+
"coordination.claimFiles",
|
|
19831
|
+
"coordination.endSession",
|
|
19832
|
+
"coordination.getAgentInbox",
|
|
19833
|
+
"coordination.heartbeatSession",
|
|
19834
|
+
"coordination.listActiveSessions",
|
|
19835
|
+
"coordination.registerSession",
|
|
19836
|
+
"coordination.sendAgentMessage",
|
|
19837
|
+
"edges.createEdge",
|
|
19838
|
+
"edges.queryLineage",
|
|
19839
|
+
"evidence.addEvidence",
|
|
19840
|
+
"evidence.createEvidence",
|
|
19841
|
+
"evidence.getEvidence",
|
|
19842
|
+
"evidence.linkEvidence",
|
|
19843
|
+
"evidence.linkEvidenceToBelief",
|
|
19844
|
+
"evidence.linkEvidenceToQuestion",
|
|
19845
|
+
"evidence.listEvidence",
|
|
19846
|
+
"evidence.searchEvidence",
|
|
19847
|
+
"graph.detectConfirmationBias",
|
|
19848
|
+
"graph.findContradictions",
|
|
19849
|
+
"graph.getGraphGaps",
|
|
19850
|
+
"graph.getGraphNeighborhood",
|
|
19851
|
+
"graph.getGraphStructureAnalysis",
|
|
19852
|
+
"graph.getTopicCoverage",
|
|
19853
|
+
"graph.traceEntityImpact",
|
|
19854
|
+
"graph.traverseGraph",
|
|
19855
|
+
"graphAnalysis.listGraphIntelligenceQueries",
|
|
19856
|
+
"graphAnalysis.runGraphIntelligenceQuery",
|
|
19857
|
+
"identity.checkPermission",
|
|
19858
|
+
"identity.filterByPermission",
|
|
19859
|
+
"identity.whoami",
|
|
19860
|
+
"judgments.getAuditTrail",
|
|
19861
|
+
"judgments.recordJudgment",
|
|
19862
|
+
"lenses.applyLensToTopic",
|
|
19863
|
+
"lenses.createLens",
|
|
19864
|
+
"lenses.listLenses",
|
|
19865
|
+
"lenses.removeLensFromTopic",
|
|
19866
|
+
"observations.getObservationContext",
|
|
19867
|
+
"observations.ingestObservation",
|
|
19868
|
+
"ontologies.applyOntology",
|
|
19869
|
+
"ontologies.archiveOntology",
|
|
19870
|
+
"ontologies.createOntology",
|
|
19871
|
+
"ontologies.createOntologyVersion",
|
|
19872
|
+
"ontologies.deprecateOntologyVersion",
|
|
19873
|
+
"ontologies.getOntology",
|
|
19874
|
+
"ontologies.listOntologies",
|
|
19875
|
+
"ontologies.matchEntityType",
|
|
19876
|
+
"ontologies.publishOntologyVersion",
|
|
19877
|
+
"ontologies.resolveEffectiveOntology",
|
|
19878
|
+
"ontologies.updateOntology",
|
|
19879
|
+
"policy.manageWritePolicy",
|
|
19880
|
+
"questions.archiveQuestion",
|
|
19881
|
+
"questions.createQuestion",
|
|
19882
|
+
"questions.findMissingQuestions",
|
|
19883
|
+
"questions.getFalsificationQuestions",
|
|
19884
|
+
"questions.getHighPriorityQuestions",
|
|
19885
|
+
"questions.getQuestion",
|
|
19886
|
+
"questions.listQuestions",
|
|
19887
|
+
"questions.refineQuestion",
|
|
19888
|
+
"questions.updateQuestionStatus",
|
|
19889
|
+
"tasks.completeTask",
|
|
19890
|
+
"tasks.createTask",
|
|
19891
|
+
"tasks.listTasks",
|
|
19892
|
+
"tasks.updateTask",
|
|
19893
|
+
"topics.createTopic",
|
|
19894
|
+
"topics.getTopic",
|
|
19895
|
+
"topics.getTopicTree",
|
|
19896
|
+
"topics.listTopics",
|
|
19897
|
+
"topics.updateTopic",
|
|
19898
|
+
"worktrees.activateWorktree",
|
|
19899
|
+
"worktrees.addWorktree",
|
|
19900
|
+
"worktrees.beginBuildSession",
|
|
19901
|
+
"worktrees.listAllWorktrees",
|
|
19902
|
+
"worktrees.listCampaigns",
|
|
19903
|
+
"worktrees.listWorktrees",
|
|
19904
|
+
"worktrees.merge",
|
|
19905
|
+
"worktrees.openPullRequest",
|
|
19906
|
+
"worktrees.pipelineSnapshot",
|
|
19907
|
+
"worktrees.push",
|
|
19908
|
+
"worktrees.updateWorktreeMetadata",
|
|
19909
|
+
"worktrees.updateWorktreeTargets"
|
|
19910
|
+
];
|
|
18551
19911
|
var CONTRACTS = {
|
|
18552
19912
|
"activate_worktree": { method: "POST", path: "/worktrees/activate", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
|
|
18553
19913
|
"add_evidence": { method: "POST", path: "/evidence/add", kind: "mutation", idempotent: true, surfaceIntent: "compatibility" },
|
|
@@ -18623,6 +19983,7 @@ var CONTRACTS = {
|
|
|
18623
19983
|
"list_beliefs": { method: "GET", path: "/beliefs", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
18624
19984
|
"list_campaigns": { method: "GET", path: "/worktrees/campaigns", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
18625
19985
|
"list_evidence": { method: "GET", path: "/evidence", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
19986
|
+
"list_graph_intelligence_queries": { method: "POST", path: "/graph-intelligence/queries", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
|
|
18626
19987
|
"list_lenses": { method: "GET", path: "/lenses", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
18627
19988
|
"list_ontologies": { method: "GET", path: "/ontologies", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
18628
19989
|
"list_questions": { method: "GET", path: "/questions", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
@@ -18646,6 +20007,7 @@ var CONTRACTS = {
|
|
|
18646
20007
|
"register_session": { method: "POST", path: "/coordination/register-session", kind: "mutation", idempotent: true, surfaceIntent: "system" },
|
|
18647
20008
|
"remove_lens_from_topic": { method: "DELETE", path: "/lenses/apply", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
|
|
18648
20009
|
"resolve_effective_ontology": { method: "POST", path: "/ontologies/effective", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
20010
|
+
"run_graph_intelligence_query": { method: "POST", path: "/graph-intelligence/run", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
|
|
18649
20011
|
"search_beliefs": { method: "POST", path: "/beliefs/search", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
18650
20012
|
"search_evidence": { method: "POST", path: "/evidence/search", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
18651
20013
|
"seed_belief_lattice": { method: "POST", path: "/scope/belief-lattice/seed", kind: "mutation", idempotent: true, surfaceIntent: "system" },
|
|
@@ -18921,6 +20283,9 @@ function createFunctionSurfaceClient(config = {}) {
|
|
|
18921
20283
|
listEvidence(input = {}, idempotencyKey) {
|
|
18922
20284
|
return execute("list_evidence", input, idempotencyKey);
|
|
18923
20285
|
},
|
|
20286
|
+
listGraphIntelligenceQueries(input = {}, idempotencyKey) {
|
|
20287
|
+
return execute("list_graph_intelligence_queries", input, idempotencyKey);
|
|
20288
|
+
},
|
|
18924
20289
|
listLenses(input = {}, idempotencyKey) {
|
|
18925
20290
|
return execute("list_lenses", input, idempotencyKey);
|
|
18926
20291
|
},
|
|
@@ -18990,6 +20355,9 @@ function createFunctionSurfaceClient(config = {}) {
|
|
|
18990
20355
|
resolveEffectiveOntology(input = {}, idempotencyKey) {
|
|
18991
20356
|
return execute("resolve_effective_ontology", input, idempotencyKey);
|
|
18992
20357
|
},
|
|
20358
|
+
runGraphIntelligenceQuery(input = {}, idempotencyKey) {
|
|
20359
|
+
return execute("run_graph_intelligence_query", input, idempotencyKey);
|
|
20360
|
+
},
|
|
18993
20361
|
searchBeliefs(input = {}, idempotencyKey) {
|
|
18994
20362
|
return execute("search_beliefs", input, idempotencyKey);
|
|
18995
20363
|
},
|
|
@@ -22591,198 +23959,2367 @@ function createLucernClient(config = {}) {
|
|
|
22591
23959
|
};
|
|
22592
23960
|
}
|
|
22593
23961
|
|
|
22594
|
-
// ../sdk/src/
|
|
22595
|
-
|
|
22596
|
-
"
|
|
22597
|
-
"workspace",
|
|
22598
|
-
"principal",
|
|
22599
|
-
"tool",
|
|
22600
|
-
"pack",
|
|
22601
|
-
"ontology",
|
|
22602
|
-
"belief",
|
|
22603
|
-
"policy_rule"
|
|
22604
|
-
];
|
|
22605
|
-
function defineCases(cases) {
|
|
22606
|
-
return cases;
|
|
23962
|
+
// ../sdk/src/facade/context.ts
|
|
23963
|
+
function cleanString6(value) {
|
|
23964
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
22607
23965
|
}
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
{
|
|
22611
|
-
caseKey: "platform-record",
|
|
22612
|
-
caseLabel: "Platform Record",
|
|
22613
|
-
kind: "tenant",
|
|
22614
|
-
canonicalOwnerScope: "platform",
|
|
22615
|
-
editSurface: "platform_admin",
|
|
22616
|
-
inheritanceRule: "none",
|
|
22617
|
-
blastRadius: "tenant"
|
|
22618
|
-
}
|
|
22619
|
-
]),
|
|
22620
|
-
workspace: defineCases([
|
|
22621
|
-
{
|
|
22622
|
-
caseKey: "tenant-workspace",
|
|
22623
|
-
caseLabel: "Tenant Workspace",
|
|
22624
|
-
kind: "workspace",
|
|
22625
|
-
canonicalOwnerScope: "tenant",
|
|
22626
|
-
editSurface: "tenant_admin",
|
|
22627
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
22628
|
-
blastRadius: "workspace"
|
|
22629
|
-
}
|
|
22630
|
-
]),
|
|
22631
|
-
principal: defineCases([
|
|
22632
|
-
{
|
|
22633
|
-
caseKey: "tenant-principal",
|
|
22634
|
-
caseLabel: "Tenant Principal",
|
|
22635
|
-
kind: "principal",
|
|
22636
|
-
canonicalOwnerScope: "tenant",
|
|
22637
|
-
editSurface: "tenant_admin",
|
|
22638
|
-
inheritanceRule: "workspace_narrowing_only",
|
|
22639
|
-
blastRadius: "resource"
|
|
22640
|
-
}
|
|
22641
|
-
]),
|
|
22642
|
-
tool: defineCases([
|
|
22643
|
-
{
|
|
22644
|
-
caseKey: "platform-core",
|
|
22645
|
-
caseLabel: "Platform Core",
|
|
22646
|
-
kind: "tool",
|
|
22647
|
-
canonicalOwnerScope: "platform",
|
|
22648
|
-
editSurface: "platform_admin",
|
|
22649
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
22650
|
-
blastRadius: "platform"
|
|
22651
|
-
},
|
|
22652
|
-
{
|
|
22653
|
-
caseKey: "tenant-custom",
|
|
22654
|
-
caseLabel: "Tenant Custom",
|
|
22655
|
-
kind: "tool",
|
|
22656
|
-
canonicalOwnerScope: "tenant",
|
|
22657
|
-
editSurface: "tenant_admin",
|
|
22658
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
22659
|
-
blastRadius: "tenant"
|
|
22660
|
-
}
|
|
22661
|
-
]),
|
|
22662
|
-
pack: defineCases([
|
|
22663
|
-
{
|
|
22664
|
-
caseKey: "platform-definition",
|
|
22665
|
-
caseLabel: "Platform Definition",
|
|
22666
|
-
kind: "pack",
|
|
22667
|
-
canonicalOwnerScope: "platform",
|
|
22668
|
-
editSurface: "platform_admin",
|
|
22669
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
22670
|
-
blastRadius: "platform"
|
|
22671
|
-
},
|
|
22672
|
-
{
|
|
22673
|
-
caseKey: "tenant-installation",
|
|
22674
|
-
caseLabel: "Tenant Installation",
|
|
22675
|
-
kind: "pack",
|
|
22676
|
-
canonicalOwnerScope: "tenant",
|
|
22677
|
-
editSurface: "tenant_admin",
|
|
22678
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
22679
|
-
blastRadius: "tenant"
|
|
22680
|
-
}
|
|
22681
|
-
]),
|
|
22682
|
-
ontology: defineCases([
|
|
22683
|
-
{
|
|
22684
|
-
caseKey: "platform-base",
|
|
22685
|
-
caseLabel: "Platform Base",
|
|
22686
|
-
kind: "ontology",
|
|
22687
|
-
canonicalOwnerScope: "platform",
|
|
22688
|
-
editSurface: "platform_admin",
|
|
22689
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
22690
|
-
blastRadius: "platform"
|
|
22691
|
-
},
|
|
22692
|
-
{
|
|
22693
|
-
caseKey: "pack-overlay",
|
|
22694
|
-
caseLabel: "Pack Overlay",
|
|
22695
|
-
kind: "ontology",
|
|
22696
|
-
canonicalOwnerScope: "platform",
|
|
22697
|
-
editSurface: "platform_admin",
|
|
22698
|
-
inheritanceRule: "pack_overlay_to_tenant",
|
|
22699
|
-
blastRadius: "platform"
|
|
22700
|
-
},
|
|
22701
|
-
{
|
|
22702
|
-
caseKey: "tenant-extension",
|
|
22703
|
-
caseLabel: "Tenant Extension",
|
|
22704
|
-
kind: "ontology",
|
|
22705
|
-
canonicalOwnerScope: "tenant",
|
|
22706
|
-
editSurface: "tenant_admin",
|
|
22707
|
-
inheritanceRule: "topic_lineage_to_resource",
|
|
22708
|
-
blastRadius: "tenant"
|
|
22709
|
-
}
|
|
22710
|
-
]),
|
|
22711
|
-
belief: defineCases([
|
|
22712
|
-
{
|
|
22713
|
-
caseKey: "topic-resource",
|
|
22714
|
-
caseLabel: "Topic Resource",
|
|
22715
|
-
kind: "belief",
|
|
22716
|
-
canonicalOwnerScope: "resource",
|
|
22717
|
-
editSurface: "graph_worktree",
|
|
22718
|
-
inheritanceRule: "topic_lineage_to_resource",
|
|
22719
|
-
blastRadius: "resource"
|
|
22720
|
-
}
|
|
22721
|
-
]),
|
|
22722
|
-
policy_rule: defineCases([
|
|
22723
|
-
{
|
|
22724
|
-
caseKey: "platform-baseline",
|
|
22725
|
-
caseLabel: "Platform Baseline",
|
|
22726
|
-
kind: "policy_rule",
|
|
22727
|
-
canonicalOwnerScope: "platform",
|
|
22728
|
-
editSurface: "platform_admin",
|
|
22729
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
22730
|
-
blastRadius: "platform"
|
|
22731
|
-
},
|
|
22732
|
-
{
|
|
22733
|
-
caseKey: "tenant-bundle",
|
|
22734
|
-
caseLabel: "Tenant Bundle",
|
|
22735
|
-
kind: "policy_rule",
|
|
22736
|
-
canonicalOwnerScope: "tenant",
|
|
22737
|
-
editSurface: "tenant_admin",
|
|
22738
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
22739
|
-
blastRadius: "tenant"
|
|
22740
|
-
},
|
|
22741
|
-
{
|
|
22742
|
-
caseKey: "workspace-override",
|
|
22743
|
-
caseLabel: "Workspace Override",
|
|
22744
|
-
kind: "policy_rule",
|
|
22745
|
-
canonicalOwnerScope: "workspace",
|
|
22746
|
-
editSurface: "workspace_admin",
|
|
22747
|
-
inheritanceRule: "none",
|
|
22748
|
-
blastRadius: "workspace"
|
|
22749
|
-
}
|
|
22750
|
-
])
|
|
22751
|
-
};
|
|
22752
|
-
function flattenOwnershipMatrix(matrix) {
|
|
22753
|
-
return CONTROL_OBJECT_KINDS.flatMap((kind) => [...matrix[kind]]);
|
|
23966
|
+
function cleanNumber2(value) {
|
|
23967
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
22754
23968
|
}
|
|
22755
|
-
|
|
22756
|
-
|
|
22757
|
-
|
|
22758
|
-
|
|
22759
|
-
|
|
22760
|
-
|
|
22761
|
-
|
|
22762
|
-
|
|
22763
|
-
status;
|
|
22764
|
-
suggestion;
|
|
22765
|
-
constructor(message, code = "INVALID_REQUEST", status = 400, suggestion) {
|
|
22766
|
-
super(message);
|
|
22767
|
-
this.name = "McpHandlerError";
|
|
22768
|
-
this.code = code;
|
|
22769
|
-
this.status = status;
|
|
22770
|
-
this.suggestion = suggestion;
|
|
23969
|
+
function cleanBoolean2(value) {
|
|
23970
|
+
return typeof value === "boolean" ? value : void 0;
|
|
23971
|
+
}
|
|
23972
|
+
function buildCompileContextRequest2(topicId, input = {}) {
|
|
23973
|
+
const payload = { topicId };
|
|
23974
|
+
const query5 = cleanString6(input.query);
|
|
23975
|
+
if (query5) {
|
|
23976
|
+
payload.query = query5;
|
|
22771
23977
|
}
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
function isMissing(value) {
|
|
22776
|
-
if (value === void 0 || value === null) {
|
|
22777
|
-
return true;
|
|
23978
|
+
const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
|
|
23979
|
+
if (budget !== void 0) {
|
|
23980
|
+
payload.budget = budget;
|
|
22778
23981
|
}
|
|
22779
|
-
|
|
22780
|
-
|
|
23982
|
+
const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
|
|
23983
|
+
if (ranking) {
|
|
23984
|
+
payload.ranking = ranking;
|
|
22781
23985
|
}
|
|
22782
|
-
|
|
22783
|
-
|
|
23986
|
+
const limit = cleanNumber2(input.limit);
|
|
23987
|
+
if (limit !== void 0) {
|
|
23988
|
+
payload.limit = limit;
|
|
22784
23989
|
}
|
|
22785
|
-
|
|
23990
|
+
const maxDepth = cleanNumber2(input.maxDepth);
|
|
23991
|
+
if (maxDepth !== void 0) {
|
|
23992
|
+
payload.maxDepth = maxDepth;
|
|
23993
|
+
}
|
|
23994
|
+
const includeEntities = cleanBoolean2(input.includeEntities);
|
|
23995
|
+
if (includeEntities !== void 0) {
|
|
23996
|
+
payload.includeEntities = includeEntities;
|
|
23997
|
+
}
|
|
23998
|
+
const mode = cleanString6(input.mode);
|
|
23999
|
+
if (mode) {
|
|
24000
|
+
payload.mode = mode;
|
|
24001
|
+
}
|
|
24002
|
+
const includeFailures = cleanBoolean2(input.includeFailures);
|
|
24003
|
+
if (includeFailures !== void 0) {
|
|
24004
|
+
payload.includeFailures = includeFailures;
|
|
24005
|
+
}
|
|
24006
|
+
const worktreeId = cleanString6(input.worktreeId);
|
|
24007
|
+
if (worktreeId) {
|
|
24008
|
+
payload.worktreeId = worktreeId;
|
|
24009
|
+
}
|
|
24010
|
+
const sessionId = cleanString6(input.sessionId);
|
|
24011
|
+
if (sessionId) {
|
|
24012
|
+
payload.sessionId = sessionId;
|
|
24013
|
+
}
|
|
24014
|
+
if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
|
|
24015
|
+
payload.packWeightOverrides = input.packWeightOverrides;
|
|
24016
|
+
}
|
|
24017
|
+
return {
|
|
24018
|
+
path: "/api/platform/v1/context/compile",
|
|
24019
|
+
method: "POST",
|
|
24020
|
+
body: payload
|
|
24021
|
+
};
|
|
24022
|
+
}
|
|
24023
|
+
function createContextFacade(config) {
|
|
24024
|
+
return {
|
|
24025
|
+
compile(topicId, input = {}) {
|
|
24026
|
+
const request = buildCompileContextRequest2(topicId, input);
|
|
24027
|
+
return config.transport.request(request);
|
|
24028
|
+
}
|
|
24029
|
+
};
|
|
24030
|
+
}
|
|
24031
|
+
|
|
24032
|
+
// ../sdk/src/contracts/context-pack.contract.ts
|
|
24033
|
+
var CONTEXT_PACK_SCHEMA_VERSION = "1.0.0";
|
|
24034
|
+
var DEFAULT_COMPILATION_MODE = "standard";
|
|
24035
|
+
var SECTION_BUDGET_RATIOS = {
|
|
24036
|
+
invariants: 0.28,
|
|
24037
|
+
activeBeliefs: 0.3,
|
|
24038
|
+
openQuestions: 0.17,
|
|
24039
|
+
recentEvidence: 0.17,
|
|
24040
|
+
contradictions: 0.08
|
|
24041
|
+
};
|
|
24042
|
+
var MIN_TOKEN_BUDGET = 400;
|
|
24043
|
+
var MAX_TOKEN_BUDGET = 8e3;
|
|
24044
|
+
var DEFAULT_TOKEN_BUDGET = 1800;
|
|
24045
|
+
var MIN_CONTRADICTION_BUDGET = 40;
|
|
24046
|
+
var RANKING_WEIGHTS = {
|
|
24047
|
+
invariants: {
|
|
24048
|
+
query: 0.35,
|
|
24049
|
+
recency: 0.1,
|
|
24050
|
+
confidence: 0.4,
|
|
24051
|
+
beliefType: 0.15
|
|
24052
|
+
},
|
|
24053
|
+
activeBeliefs: {
|
|
24054
|
+
query: 0.5,
|
|
24055
|
+
recency: 0.2,
|
|
24056
|
+
confidence: 0.2,
|
|
24057
|
+
beliefType: 0.1
|
|
24058
|
+
},
|
|
24059
|
+
openQuestions: {
|
|
24060
|
+
query: 0.55,
|
|
24061
|
+
recency: 0.2,
|
|
24062
|
+
priority: 0.25
|
|
24063
|
+
},
|
|
24064
|
+
recentEvidence: {
|
|
24065
|
+
query: 0.6,
|
|
24066
|
+
recency: 0.4
|
|
24067
|
+
},
|
|
24068
|
+
contradictions: {
|
|
24069
|
+
query: 0.4,
|
|
24070
|
+
recency: 0.2,
|
|
24071
|
+
severity: 0.4
|
|
24072
|
+
}
|
|
24073
|
+
};
|
|
24074
|
+
var RECENCY_HALF_LIFE_DAYS = 30;
|
|
24075
|
+
var ENTITY_RANKING_WEIGHTS = {
|
|
24076
|
+
query: 0.4,
|
|
24077
|
+
connectivity: 0.6
|
|
24078
|
+
};
|
|
24079
|
+
var DEFAULT_ENTITY_LIMIT = 10;
|
|
24080
|
+
var MAX_ENTITY_LIMIT = 50;
|
|
24081
|
+
var BELIEF_TYPE_BONUS = {
|
|
24082
|
+
invariant: 1,
|
|
24083
|
+
tenet: 0.8,
|
|
24084
|
+
principle: 0.6
|
|
24085
|
+
};
|
|
24086
|
+
var DEFAULT_BELIEF_TYPE_BONUS = 0.4;
|
|
24087
|
+
var PRIORITY_SCORES = {
|
|
24088
|
+
critical: 1,
|
|
24089
|
+
high: 0.85,
|
|
24090
|
+
medium: 0.55,
|
|
24091
|
+
low: 0.35
|
|
24092
|
+
};
|
|
24093
|
+
var DEFAULT_PRIORITY_SCORE = 0.5;
|
|
24094
|
+
var SEVERITY_SCORES = {
|
|
24095
|
+
critical: 1,
|
|
24096
|
+
high: 0.85,
|
|
24097
|
+
medium: 0.6,
|
|
24098
|
+
low: 0.35
|
|
24099
|
+
};
|
|
24100
|
+
var DEFAULT_SEVERITY_SCORE = 0.5;
|
|
24101
|
+
var TOKENS_PER_WORD = 1.35;
|
|
24102
|
+
var MIN_TOKEN_ESTIMATE = 8;
|
|
24103
|
+
|
|
24104
|
+
// ../sdk/src/contextPackPolicy.ts
|
|
24105
|
+
function nowMs() {
|
|
24106
|
+
return Date.now();
|
|
24107
|
+
}
|
|
24108
|
+
function normalizeText(text) {
|
|
24109
|
+
return text.trim().toLowerCase();
|
|
24110
|
+
}
|
|
24111
|
+
function tokenHits(text, tokens) {
|
|
24112
|
+
if (tokens.length === 0) {
|
|
24113
|
+
return 1;
|
|
24114
|
+
}
|
|
24115
|
+
const haystack = normalizeText(text);
|
|
24116
|
+
let hits = 0;
|
|
24117
|
+
for (const token of tokens) {
|
|
24118
|
+
if (haystack.includes(token)) {
|
|
24119
|
+
hits += 1;
|
|
24120
|
+
}
|
|
24121
|
+
}
|
|
24122
|
+
return hits;
|
|
24123
|
+
}
|
|
24124
|
+
function clamp013(value) {
|
|
24125
|
+
if (!Number.isFinite(value)) {
|
|
24126
|
+
return 0;
|
|
24127
|
+
}
|
|
24128
|
+
return Math.max(0, Math.min(1, value));
|
|
24129
|
+
}
|
|
24130
|
+
function recencyScore(updatedAt, referenceTimeMs = nowMs()) {
|
|
24131
|
+
if (!updatedAt || !Number.isFinite(updatedAt)) {
|
|
24132
|
+
return 0.25;
|
|
24133
|
+
}
|
|
24134
|
+
const ageMs = Math.max(0, referenceTimeMs - updatedAt);
|
|
24135
|
+
const ageDays = ageMs / (1e3 * 60 * 60 * 24);
|
|
24136
|
+
const decay = 0.5 ** (ageDays / RECENCY_HALF_LIFE_DAYS);
|
|
24137
|
+
return clamp013(decay);
|
|
24138
|
+
}
|
|
24139
|
+
function confidenceScore(confidence) {
|
|
24140
|
+
if (typeof confidence !== "number" || !Number.isFinite(confidence)) {
|
|
24141
|
+
return 0.5;
|
|
24142
|
+
}
|
|
24143
|
+
return clamp013(confidence);
|
|
24144
|
+
}
|
|
24145
|
+
function priorityScore(priority) {
|
|
24146
|
+
const value = normalizeText(priority || "");
|
|
24147
|
+
return PRIORITY_SCORES[value] ?? DEFAULT_PRIORITY_SCORE;
|
|
24148
|
+
}
|
|
24149
|
+
function severityScore(severity) {
|
|
24150
|
+
const value = normalizeText(severity || "");
|
|
24151
|
+
return SEVERITY_SCORES[value] ?? DEFAULT_SEVERITY_SCORE;
|
|
24152
|
+
}
|
|
24153
|
+
function beliefTypeBonus(beliefType) {
|
|
24154
|
+
const value = normalizeText(beliefType || "");
|
|
24155
|
+
return BELIEF_TYPE_BONUS[value] ?? DEFAULT_BELIEF_TYPE_BONUS;
|
|
24156
|
+
}
|
|
24157
|
+
function resolveEffectiveWeights(overrides) {
|
|
24158
|
+
if (!overrides || overrides.length === 0) {
|
|
24159
|
+
return RANKING_WEIGHTS;
|
|
24160
|
+
}
|
|
24161
|
+
const result = { ...RANKING_WEIGHTS };
|
|
24162
|
+
for (const override of overrides) {
|
|
24163
|
+
const base = RANKING_WEIGHTS[override.section];
|
|
24164
|
+
if (base) {
|
|
24165
|
+
result[override.section] = { ...base, ...override.weights };
|
|
24166
|
+
}
|
|
24167
|
+
}
|
|
24168
|
+
return result;
|
|
24169
|
+
}
|
|
24170
|
+
function generateJustification(_section, candidate, queryTokens, weights) {
|
|
24171
|
+
const parts = [];
|
|
24172
|
+
const hits = tokenHits(candidate.text, queryTokens);
|
|
24173
|
+
if (queryTokens.length > 0 && hits > 0) {
|
|
24174
|
+
parts.push(`${hits}/${queryTokens.length} query terms matched`);
|
|
24175
|
+
} else if (queryTokens.length === 0) {
|
|
24176
|
+
parts.push("no query filter");
|
|
24177
|
+
}
|
|
24178
|
+
const ts = candidate.updatedAt || candidate.createdAt || null;
|
|
24179
|
+
if (ts && Number.isFinite(ts)) {
|
|
24180
|
+
const ageDays = Math.max(0, nowMs() - ts) / (1e3 * 60 * 60 * 24);
|
|
24181
|
+
if (ageDays < 1) {
|
|
24182
|
+
parts.push("updated today");
|
|
24183
|
+
} else if (ageDays < 7) {
|
|
24184
|
+
parts.push(`updated ${Math.floor(ageDays)}d ago`);
|
|
24185
|
+
} else if (ageDays < 30) {
|
|
24186
|
+
parts.push(`updated ${Math.floor(ageDays / 7)}w ago`);
|
|
24187
|
+
} else {
|
|
24188
|
+
parts.push(`updated ${Math.floor(ageDays)}d ago (decayed)`);
|
|
24189
|
+
}
|
|
24190
|
+
}
|
|
24191
|
+
if (weights.confidence !== void 0 && candidate.confidence !== null && candidate.confidence !== void 0) {
|
|
24192
|
+
parts.push(`confidence=${candidate.confidence.toFixed(2)}`);
|
|
24193
|
+
}
|
|
24194
|
+
if (weights.beliefType !== void 0 && candidate.beliefType) {
|
|
24195
|
+
parts.push(`type=${candidate.beliefType}`);
|
|
24196
|
+
}
|
|
24197
|
+
if (weights.priority !== void 0 && candidate.priority) {
|
|
24198
|
+
parts.push(`priority=${candidate.priority}`);
|
|
24199
|
+
}
|
|
24200
|
+
if (weights.severity !== void 0 && candidate.severity) {
|
|
24201
|
+
parts.push(`severity=${candidate.severity}`);
|
|
24202
|
+
}
|
|
24203
|
+
return parts.join(", ");
|
|
24204
|
+
}
|
|
24205
|
+
function computeBaselineScore(candidate, queryTokens) {
|
|
24206
|
+
const hits = tokenHits(candidate.text, queryTokens);
|
|
24207
|
+
return queryTokens.length === 0 ? 1 : hits;
|
|
24208
|
+
}
|
|
24209
|
+
function computeWeightedScore(section, candidate, queryTokens, effectiveWeights, referenceTimeMs) {
|
|
24210
|
+
const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
|
|
24211
|
+
const queryComponent = queryTokens.length === 0 ? 0.4 : clamp013(tokenHits(candidate.text, queryTokens) / queryTokens.length);
|
|
24212
|
+
const recencyComponent = recencyScore(
|
|
24213
|
+
candidate.updatedAt || candidate.createdAt || null,
|
|
24214
|
+
referenceTimeMs
|
|
24215
|
+
);
|
|
24216
|
+
let score = queryComponent * weights.query + recencyComponent * weights.recency;
|
|
24217
|
+
if (weights.confidence !== void 0) {
|
|
24218
|
+
score += confidenceScore(candidate.confidence) * weights.confidence;
|
|
24219
|
+
}
|
|
24220
|
+
if (weights.beliefType !== void 0) {
|
|
24221
|
+
score += beliefTypeBonus(candidate.beliefType) * weights.beliefType;
|
|
24222
|
+
}
|
|
24223
|
+
if (weights.priority !== void 0) {
|
|
24224
|
+
score += priorityScore(candidate.priority) * weights.priority;
|
|
24225
|
+
}
|
|
24226
|
+
if (weights.severity !== void 0) {
|
|
24227
|
+
score += severityScore(candidate.severity) * weights.severity;
|
|
24228
|
+
}
|
|
24229
|
+
return score;
|
|
24230
|
+
}
|
|
24231
|
+
function rankContextSection(section, rows, queryTokens, limit, profile, options) {
|
|
24232
|
+
const effectiveWeights = options?.effectiveWeights;
|
|
24233
|
+
const includeJustifications = options?.includeJustifications ?? false;
|
|
24234
|
+
const referenceTimeMs = options?.referenceTimeMs;
|
|
24235
|
+
const scored = rows.map((row) => {
|
|
24236
|
+
const score = profile === "weighted_v1" ? computeWeightedScore(
|
|
24237
|
+
section,
|
|
24238
|
+
row,
|
|
24239
|
+
queryTokens,
|
|
24240
|
+
effectiveWeights,
|
|
24241
|
+
referenceTimeMs
|
|
24242
|
+
) : computeBaselineScore(row, queryTokens);
|
|
24243
|
+
const result = { ...row, score };
|
|
24244
|
+
if (includeJustifications && profile === "weighted_v1") {
|
|
24245
|
+
const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
|
|
24246
|
+
result.justification = generateJustification(section, row, queryTokens, weights);
|
|
24247
|
+
}
|
|
24248
|
+
return result;
|
|
24249
|
+
});
|
|
24250
|
+
const filtered = queryTokens.length === 0 ? scored : scored.filter((row) => row.score > 0);
|
|
24251
|
+
filtered.sort((left, right) => {
|
|
24252
|
+
if (right.score !== left.score) {
|
|
24253
|
+
return right.score - left.score;
|
|
24254
|
+
}
|
|
24255
|
+
const rightTs = right.updatedAt || right.createdAt || 0;
|
|
24256
|
+
const leftTs = left.updatedAt || left.createdAt || 0;
|
|
24257
|
+
return rightTs - leftTs;
|
|
24258
|
+
});
|
|
24259
|
+
return filtered.slice(0, limit);
|
|
24260
|
+
}
|
|
24261
|
+
function parseTokenBudget(value, fallback = DEFAULT_TOKEN_BUDGET) {
|
|
24262
|
+
const parsed = typeof value === "number" && Number.isFinite(value) ? Math.floor(value) : fallback;
|
|
24263
|
+
return Math.max(MIN_TOKEN_BUDGET, Math.min(MAX_TOKEN_BUDGET, parsed));
|
|
24264
|
+
}
|
|
24265
|
+
function estimateTokens(text) {
|
|
24266
|
+
const words = text.trim().split(/\s+/).filter(Boolean).length;
|
|
24267
|
+
return Math.max(MIN_TOKEN_ESTIMATE, Math.ceil(words * TOKENS_PER_WORD));
|
|
24268
|
+
}
|
|
24269
|
+
function buildInjectionPlan(args) {
|
|
24270
|
+
const tokenBudget = parseTokenBudget(args.tokenBudget);
|
|
24271
|
+
const trackExclusions = args.trackExclusions ?? false;
|
|
24272
|
+
const sectionBudgets = {
|
|
24273
|
+
invariants: Math.floor(tokenBudget * SECTION_BUDGET_RATIOS.invariants),
|
|
24274
|
+
activeBeliefs: Math.floor(
|
|
24275
|
+
tokenBudget * SECTION_BUDGET_RATIOS.activeBeliefs
|
|
24276
|
+
),
|
|
24277
|
+
openQuestions: Math.floor(
|
|
24278
|
+
tokenBudget * SECTION_BUDGET_RATIOS.openQuestions
|
|
24279
|
+
),
|
|
24280
|
+
recentEvidence: Math.floor(
|
|
24281
|
+
tokenBudget * SECTION_BUDGET_RATIOS.recentEvidence
|
|
24282
|
+
),
|
|
24283
|
+
contradictions: Math.max(
|
|
24284
|
+
MIN_CONTRADICTION_BUDGET,
|
|
24285
|
+
Math.floor(tokenBudget * SECTION_BUDGET_RATIOS.contradictions)
|
|
24286
|
+
)
|
|
24287
|
+
};
|
|
24288
|
+
const selected = {
|
|
24289
|
+
invariants: [],
|
|
24290
|
+
activeBeliefs: [],
|
|
24291
|
+
openQuestions: [],
|
|
24292
|
+
recentEvidence: [],
|
|
24293
|
+
contradictions: []
|
|
24294
|
+
};
|
|
24295
|
+
const sectionUsage = {
|
|
24296
|
+
invariants: 0,
|
|
24297
|
+
activeBeliefs: 0,
|
|
24298
|
+
openQuestions: 0,
|
|
24299
|
+
recentEvidence: 0,
|
|
24300
|
+
contradictions: 0
|
|
24301
|
+
};
|
|
24302
|
+
const excludedItems = [];
|
|
24303
|
+
const pushItem = (section, id, text, score) => {
|
|
24304
|
+
const itemTokens = estimateTokens(text);
|
|
24305
|
+
const nextUsage = sectionUsage[section] + itemTokens;
|
|
24306
|
+
if (nextUsage > sectionBudgets[section]) {
|
|
24307
|
+
if (trackExclusions) {
|
|
24308
|
+
excludedItems.push({
|
|
24309
|
+
id,
|
|
24310
|
+
section,
|
|
24311
|
+
reason: "budget_exceeded",
|
|
24312
|
+
score: score ?? 0
|
|
24313
|
+
});
|
|
24314
|
+
}
|
|
24315
|
+
return;
|
|
24316
|
+
}
|
|
24317
|
+
selected[section].push(id);
|
|
24318
|
+
sectionUsage[section] = nextUsage;
|
|
24319
|
+
};
|
|
24320
|
+
for (const row of args.invariants) {
|
|
24321
|
+
pushItem("invariants", row.nodeId, row.canonicalText, row.score);
|
|
24322
|
+
}
|
|
24323
|
+
for (const row of args.activeBeliefs) {
|
|
24324
|
+
pushItem("activeBeliefs", row.nodeId, row.canonicalText, row.score);
|
|
24325
|
+
}
|
|
24326
|
+
for (const row of args.openQuestions) {
|
|
24327
|
+
pushItem("openQuestions", row.questionId, row.text, row.score);
|
|
24328
|
+
}
|
|
24329
|
+
for (const row of args.recentEvidence) {
|
|
24330
|
+
pushItem("recentEvidence", row.nodeId, row.canonicalText, row.score);
|
|
24331
|
+
}
|
|
24332
|
+
for (const row of args.contradictions) {
|
|
24333
|
+
pushItem("contradictions", row.contradictionId, row.description, row.score);
|
|
24334
|
+
}
|
|
24335
|
+
const estimatedTokens = sectionUsage.invariants + sectionUsage.activeBeliefs + sectionUsage.openQuestions + sectionUsage.recentEvidence + sectionUsage.contradictions;
|
|
24336
|
+
return {
|
|
24337
|
+
tokenBudget,
|
|
24338
|
+
estimatedTokens,
|
|
24339
|
+
sectionBudgets,
|
|
24340
|
+
sectionUsage,
|
|
24341
|
+
selected,
|
|
24342
|
+
...trackExclusions ? { excludedItems } : {}
|
|
24343
|
+
};
|
|
24344
|
+
}
|
|
24345
|
+
function rankEntities(candidates, queryTokens, limit) {
|
|
24346
|
+
if (candidates.length === 0) {
|
|
24347
|
+
return [];
|
|
24348
|
+
}
|
|
24349
|
+
const effectiveLimit = Math.max(
|
|
24350
|
+
1,
|
|
24351
|
+
Math.min(limit ?? DEFAULT_ENTITY_LIMIT, MAX_ENTITY_LIMIT)
|
|
24352
|
+
);
|
|
24353
|
+
const maxConnections = Math.max(
|
|
24354
|
+
1,
|
|
24355
|
+
...candidates.map(
|
|
24356
|
+
(candidate) => candidate.connectedBeliefCount + candidate.connectedEvidenceCount
|
|
24357
|
+
)
|
|
24358
|
+
);
|
|
24359
|
+
const scored = candidates.map((candidate) => {
|
|
24360
|
+
const searchText = `${candidate.title} ${candidate.entityType} ${candidate.canonicalText}`;
|
|
24361
|
+
const queryScore = queryTokens.length === 0 ? 0.4 : clamp013(tokenHits(searchText, queryTokens) / queryTokens.length);
|
|
24362
|
+
const totalConnections = candidate.connectedBeliefCount + candidate.connectedEvidenceCount;
|
|
24363
|
+
const connectivityScore = clamp013(totalConnections / maxConnections);
|
|
24364
|
+
const score = queryScore * ENTITY_RANKING_WEIGHTS.query + connectivityScore * ENTITY_RANKING_WEIGHTS.connectivity;
|
|
24365
|
+
return { ...candidate, score };
|
|
24366
|
+
});
|
|
24367
|
+
scored.sort((left, right) => {
|
|
24368
|
+
if (right.score !== left.score) {
|
|
24369
|
+
return right.score - left.score;
|
|
24370
|
+
}
|
|
24371
|
+
const rightConn = right.connectedBeliefCount + right.connectedEvidenceCount;
|
|
24372
|
+
const leftConn = left.connectedBeliefCount + left.connectedEvidenceCount;
|
|
24373
|
+
return rightConn - leftConn;
|
|
24374
|
+
});
|
|
24375
|
+
return scored.slice(0, effectiveLimit);
|
|
24376
|
+
}
|
|
24377
|
+
|
|
24378
|
+
// ../sdk/src/contextPackSchema.ts
|
|
24379
|
+
var CONTEXT_PACK_SCHEMA_VERSION2 = "1.0.0";
|
|
24380
|
+
function isObject(value) {
|
|
24381
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24382
|
+
}
|
|
24383
|
+
function isString(value) {
|
|
24384
|
+
return typeof value === "string";
|
|
24385
|
+
}
|
|
24386
|
+
function isNumber(value) {
|
|
24387
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
24388
|
+
}
|
|
24389
|
+
function isNullableNumber(value) {
|
|
24390
|
+
return value === null || isNumber(value);
|
|
24391
|
+
}
|
|
24392
|
+
function isStringArray(value) {
|
|
24393
|
+
return Array.isArray(value) && value.every((entry) => isString(entry));
|
|
24394
|
+
}
|
|
24395
|
+
function requireObject(parent, key, errors) {
|
|
24396
|
+
const value = parent[key];
|
|
24397
|
+
if (!isObject(value)) {
|
|
24398
|
+
errors.push(`Expected '${key}' to be an object`);
|
|
24399
|
+
return null;
|
|
24400
|
+
}
|
|
24401
|
+
return value;
|
|
24402
|
+
}
|
|
24403
|
+
function validateBeliefArray(key, value, errors) {
|
|
24404
|
+
if (!Array.isArray(value)) {
|
|
24405
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24406
|
+
return;
|
|
24407
|
+
}
|
|
24408
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24409
|
+
const row = value[index];
|
|
24410
|
+
if (!isObject(row)) {
|
|
24411
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24412
|
+
continue;
|
|
24413
|
+
}
|
|
24414
|
+
if (!isString(row.nodeId)) {
|
|
24415
|
+
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
24416
|
+
}
|
|
24417
|
+
if (!isString(row.canonicalText)) {
|
|
24418
|
+
errors.push(`Expected '${key}[${index}].canonicalText' to be a string`);
|
|
24419
|
+
}
|
|
24420
|
+
if (!isNullableNumber(row.confidence)) {
|
|
24421
|
+
errors.push(`Expected '${key}[${index}].confidence' to be number|null`);
|
|
24422
|
+
}
|
|
24423
|
+
}
|
|
24424
|
+
}
|
|
24425
|
+
function validateQuestionArray(key, value, errors) {
|
|
24426
|
+
if (!Array.isArray(value)) {
|
|
24427
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24428
|
+
return;
|
|
24429
|
+
}
|
|
24430
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24431
|
+
const row = value[index];
|
|
24432
|
+
if (!isObject(row)) {
|
|
24433
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24434
|
+
continue;
|
|
24435
|
+
}
|
|
24436
|
+
if (!isString(row.questionId)) {
|
|
24437
|
+
errors.push(`Expected '${key}[${index}].questionId' to be a string`);
|
|
24438
|
+
}
|
|
24439
|
+
if (!isString(row.text)) {
|
|
24440
|
+
errors.push(`Expected '${key}[${index}].text' to be a string`);
|
|
24441
|
+
}
|
|
24442
|
+
if (!isString(row.status)) {
|
|
24443
|
+
errors.push(`Expected '${key}[${index}].status' to be a string`);
|
|
24444
|
+
}
|
|
24445
|
+
}
|
|
24446
|
+
}
|
|
24447
|
+
function validateEvidenceArray(key, value, errors) {
|
|
24448
|
+
if (!Array.isArray(value)) {
|
|
24449
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24450
|
+
return;
|
|
24451
|
+
}
|
|
24452
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24453
|
+
const row = value[index];
|
|
24454
|
+
if (!isObject(row)) {
|
|
24455
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24456
|
+
continue;
|
|
24457
|
+
}
|
|
24458
|
+
if (!isString(row.nodeId)) {
|
|
24459
|
+
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
24460
|
+
}
|
|
24461
|
+
if (!isString(row.canonicalText)) {
|
|
24462
|
+
errors.push(`Expected '${key}[${index}].canonicalText' to be a string`);
|
|
24463
|
+
}
|
|
24464
|
+
}
|
|
24465
|
+
}
|
|
24466
|
+
function validateEntityArray(key, value, errors) {
|
|
24467
|
+
if (!Array.isArray(value)) {
|
|
24468
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24469
|
+
return;
|
|
24470
|
+
}
|
|
24471
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24472
|
+
const row = value[index];
|
|
24473
|
+
if (!isObject(row)) {
|
|
24474
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24475
|
+
continue;
|
|
24476
|
+
}
|
|
24477
|
+
if (!isString(row.nodeId)) {
|
|
24478
|
+
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
24479
|
+
}
|
|
24480
|
+
if (!isString(row.entityType)) {
|
|
24481
|
+
errors.push(`Expected '${key}[${index}].entityType' to be a string`);
|
|
24482
|
+
}
|
|
24483
|
+
if (!isString(row.title)) {
|
|
24484
|
+
errors.push(`Expected '${key}[${index}].title' to be a string`);
|
|
24485
|
+
}
|
|
24486
|
+
if (!isNumber(row.connectedBeliefCount)) {
|
|
24487
|
+
errors.push(`Expected '${key}[${index}].connectedBeliefCount' to be a number`);
|
|
24488
|
+
}
|
|
24489
|
+
if (!isNumber(row.connectedEvidenceCount)) {
|
|
24490
|
+
errors.push(`Expected '${key}[${index}].connectedEvidenceCount' to be a number`);
|
|
24491
|
+
}
|
|
24492
|
+
if (!isNumber(row.score)) {
|
|
24493
|
+
errors.push(`Expected '${key}[${index}].score' to be a number`);
|
|
24494
|
+
}
|
|
24495
|
+
}
|
|
24496
|
+
}
|
|
24497
|
+
function validateContradictionArray(key, value, errors) {
|
|
24498
|
+
if (!Array.isArray(value)) {
|
|
24499
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24500
|
+
return;
|
|
24501
|
+
}
|
|
24502
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24503
|
+
const row = value[index];
|
|
24504
|
+
if (!isObject(row)) {
|
|
24505
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24506
|
+
continue;
|
|
24507
|
+
}
|
|
24508
|
+
if (!isString(row.contradictionId)) {
|
|
24509
|
+
errors.push(`Expected '${key}[${index}].contradictionId' to be a string`);
|
|
24510
|
+
}
|
|
24511
|
+
if (!isString(row.status)) {
|
|
24512
|
+
errors.push(`Expected '${key}[${index}].status' to be a string`);
|
|
24513
|
+
}
|
|
24514
|
+
}
|
|
24515
|
+
}
|
|
24516
|
+
function validateContextPackSchema(payload) {
|
|
24517
|
+
const errors = [];
|
|
24518
|
+
if (!isObject(payload)) {
|
|
24519
|
+
return {
|
|
24520
|
+
valid: false,
|
|
24521
|
+
errors: ["Expected context pack payload to be an object"]
|
|
24522
|
+
};
|
|
24523
|
+
}
|
|
24524
|
+
if (payload.schemaVersion !== CONTEXT_PACK_SCHEMA_VERSION2) {
|
|
24525
|
+
errors.push(
|
|
24526
|
+
`Expected schemaVersion='${CONTEXT_PACK_SCHEMA_VERSION2}', received '${String(
|
|
24527
|
+
payload.schemaVersion
|
|
24528
|
+
)}'`
|
|
24529
|
+
);
|
|
24530
|
+
}
|
|
24531
|
+
if (!isString(payload.topicId)) {
|
|
24532
|
+
errors.push("Expected 'topicId' to be a string");
|
|
24533
|
+
}
|
|
24534
|
+
if (!isString(payload.topicName)) {
|
|
24535
|
+
errors.push("Expected 'topicName' to be a string");
|
|
24536
|
+
}
|
|
24537
|
+
if (!isStringArray(payload.scopedTopicIds)) {
|
|
24538
|
+
errors.push("Expected 'scopedTopicIds' to be string[]");
|
|
24539
|
+
}
|
|
24540
|
+
if (!isNumber(payload.generatedAt)) {
|
|
24541
|
+
errors.push("Expected 'generatedAt' to be a number");
|
|
24542
|
+
}
|
|
24543
|
+
if (!isString(payload.ranking)) {
|
|
24544
|
+
errors.push("Expected 'ranking' to be a string");
|
|
24545
|
+
}
|
|
24546
|
+
validateBeliefArray("invariants", payload.invariants, errors);
|
|
24547
|
+
validateBeliefArray("activeBeliefs", payload.activeBeliefs, errors);
|
|
24548
|
+
validateQuestionArray("openQuestions", payload.openQuestions, errors);
|
|
24549
|
+
validateEvidenceArray("recentEvidence", payload.recentEvidence, errors);
|
|
24550
|
+
validateContradictionArray("contradictions", payload.contradictions, errors);
|
|
24551
|
+
if (payload.relatedEntities !== void 0 && payload.relatedEntities !== null) {
|
|
24552
|
+
validateEntityArray("relatedEntities", payload.relatedEntities, errors);
|
|
24553
|
+
}
|
|
24554
|
+
if (!Array.isArray(payload.contextNarrative)) {
|
|
24555
|
+
errors.push("Expected 'contextNarrative' to be an array");
|
|
24556
|
+
}
|
|
24557
|
+
const injectionPolicy = requireObject(payload, "injectionPolicy", errors);
|
|
24558
|
+
if (injectionPolicy) {
|
|
24559
|
+
if (!isNumber(injectionPolicy.tokenBudget)) {
|
|
24560
|
+
errors.push("Expected 'injectionPolicy.tokenBudget' to be a number");
|
|
24561
|
+
}
|
|
24562
|
+
if (!isNumber(injectionPolicy.estimatedTokens)) {
|
|
24563
|
+
errors.push("Expected 'injectionPolicy.estimatedTokens' to be a number");
|
|
24564
|
+
}
|
|
24565
|
+
}
|
|
24566
|
+
if (!isObject(payload.summary)) {
|
|
24567
|
+
errors.push("Expected 'summary' to be an object");
|
|
24568
|
+
}
|
|
24569
|
+
if (!isObject(payload.diagnostics)) {
|
|
24570
|
+
errors.push("Expected 'diagnostics' to be an object");
|
|
24571
|
+
}
|
|
24572
|
+
return {
|
|
24573
|
+
valid: errors.length === 0,
|
|
24574
|
+
errors
|
|
24575
|
+
};
|
|
24576
|
+
}
|
|
24577
|
+
|
|
24578
|
+
// ../sdk/src/contextPackCompiler.ts
|
|
24579
|
+
function assertContextPackSchema(payload) {
|
|
24580
|
+
const result = validateContextPackSchema(payload);
|
|
24581
|
+
if (!result.valid) {
|
|
24582
|
+
throw new Error(
|
|
24583
|
+
`Invalid context pack payload: ${result.errors.join("; ")}`
|
|
24584
|
+
);
|
|
24585
|
+
}
|
|
24586
|
+
}
|
|
24587
|
+
function asStringArray(value) {
|
|
24588
|
+
if (!Array.isArray(value)) {
|
|
24589
|
+
return [];
|
|
24590
|
+
}
|
|
24591
|
+
return value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
24592
|
+
}
|
|
24593
|
+
function toPositiveInt(value, fallback, max) {
|
|
24594
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
24595
|
+
return fallback;
|
|
24596
|
+
}
|
|
24597
|
+
const floored = Math.floor(value);
|
|
24598
|
+
return Math.max(1, Math.min(floored, max));
|
|
24599
|
+
}
|
|
24600
|
+
function normalizeQueryTokens(query5) {
|
|
24601
|
+
if (!query5) {
|
|
24602
|
+
return [];
|
|
24603
|
+
}
|
|
24604
|
+
return query5.toLowerCase().split(/[^a-z0-9]+/).map((token) => token.trim()).filter((token) => token.length >= 2);
|
|
24605
|
+
}
|
|
24606
|
+
function parseRankingProfile(value) {
|
|
24607
|
+
return value === "baseline_v1" ? "baseline_v1" : "weighted_v1";
|
|
24608
|
+
}
|
|
24609
|
+
function beliefTypeOf(node) {
|
|
24610
|
+
if (typeof node.beliefType === "string") {
|
|
24611
|
+
return node.beliefType;
|
|
24612
|
+
}
|
|
24613
|
+
const metadata = node.metadata || {};
|
|
24614
|
+
if (typeof metadata.beliefType === "string") {
|
|
24615
|
+
return metadata.beliefType;
|
|
24616
|
+
}
|
|
24617
|
+
return "";
|
|
24618
|
+
}
|
|
24619
|
+
function questionStatusOf(node) {
|
|
24620
|
+
const metadata = node.metadata || {};
|
|
24621
|
+
const direct = typeof node.status === "string" ? node.status : "";
|
|
24622
|
+
const questionStatus = typeof metadata.questionStatus === "string" ? metadata.questionStatus : "";
|
|
24623
|
+
return (questionStatus || direct || "open").toLowerCase();
|
|
24624
|
+
}
|
|
24625
|
+
function isOpenQuestion(status) {
|
|
24626
|
+
return ![
|
|
24627
|
+
"answered",
|
|
24628
|
+
"archived",
|
|
24629
|
+
"closed",
|
|
24630
|
+
"resolved",
|
|
24631
|
+
"resolved_support",
|
|
24632
|
+
"resolved_contra",
|
|
24633
|
+
"belief_forked"
|
|
24634
|
+
].includes(status);
|
|
24635
|
+
}
|
|
24636
|
+
function metadataText(payload) {
|
|
24637
|
+
return JSON.stringify(payload).toLowerCase();
|
|
24638
|
+
}
|
|
24639
|
+
function collectTopicNeighborhood(topics2, rootTopicId, maxDescendantDepth = 2) {
|
|
24640
|
+
const byId = /* @__PURE__ */ new Map();
|
|
24641
|
+
const children = /* @__PURE__ */ new Map();
|
|
24642
|
+
for (const topic of topics2) {
|
|
24643
|
+
const id = String(topic._id);
|
|
24644
|
+
byId.set(id, topic);
|
|
24645
|
+
if (!children.has(id)) {
|
|
24646
|
+
children.set(id, []);
|
|
24647
|
+
}
|
|
24648
|
+
}
|
|
24649
|
+
for (const topic of topics2) {
|
|
24650
|
+
if (!topic.parentTopicId) {
|
|
24651
|
+
continue;
|
|
24652
|
+
}
|
|
24653
|
+
const parent = String(topic.parentTopicId);
|
|
24654
|
+
const id = String(topic._id);
|
|
24655
|
+
const list = children.get(parent) || [];
|
|
24656
|
+
list.push(id);
|
|
24657
|
+
children.set(parent, list);
|
|
24658
|
+
}
|
|
24659
|
+
const selected = /* @__PURE__ */ new Set([rootTopicId]);
|
|
24660
|
+
let cursor = byId.get(rootTopicId);
|
|
24661
|
+
while (cursor?.parentTopicId) {
|
|
24662
|
+
const parentId = String(cursor.parentTopicId);
|
|
24663
|
+
if (selected.has(parentId)) {
|
|
24664
|
+
break;
|
|
24665
|
+
}
|
|
24666
|
+
selected.add(parentId);
|
|
24667
|
+
cursor = byId.get(parentId);
|
|
24668
|
+
}
|
|
24669
|
+
const queue = [
|
|
24670
|
+
{ id: rootTopicId, depth: 0 }
|
|
24671
|
+
];
|
|
24672
|
+
while (queue.length > 0) {
|
|
24673
|
+
const current = queue.shift();
|
|
24674
|
+
if (!current || current.depth >= maxDescendantDepth) {
|
|
24675
|
+
continue;
|
|
24676
|
+
}
|
|
24677
|
+
for (const childId of children.get(current.id) || []) {
|
|
24678
|
+
if (!selected.has(childId)) {
|
|
24679
|
+
selected.add(childId);
|
|
24680
|
+
}
|
|
24681
|
+
queue.push({ id: childId, depth: current.depth + 1 });
|
|
24682
|
+
}
|
|
24683
|
+
}
|
|
24684
|
+
return Array.from(selected);
|
|
24685
|
+
}
|
|
24686
|
+
function dedupeById(rows) {
|
|
24687
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24688
|
+
const output = [];
|
|
24689
|
+
for (const row of rows) {
|
|
24690
|
+
const id = row?._id ? String(row._id) : "";
|
|
24691
|
+
if (!id || seen.has(id)) {
|
|
24692
|
+
continue;
|
|
24693
|
+
}
|
|
24694
|
+
seen.add(id);
|
|
24695
|
+
output.push(row);
|
|
24696
|
+
}
|
|
24697
|
+
return output;
|
|
24698
|
+
}
|
|
24699
|
+
function candidateTimestamp(candidate) {
|
|
24700
|
+
if (!candidate || typeof candidate !== "object") {
|
|
24701
|
+
return 0;
|
|
24702
|
+
}
|
|
24703
|
+
const record = candidate;
|
|
24704
|
+
const timestamps = [record.updatedAt, record.createdAt, record.generatedAt].filter(
|
|
24705
|
+
(value) => typeof value === "number" && Number.isFinite(value)
|
|
24706
|
+
);
|
|
24707
|
+
return timestamps.length > 0 ? Math.max(...timestamps) : 0;
|
|
24708
|
+
}
|
|
24709
|
+
function resolveReferenceTimeMs(...collections) {
|
|
24710
|
+
let maxTimestamp = 0;
|
|
24711
|
+
for (const collection of collections) {
|
|
24712
|
+
for (const item of collection) {
|
|
24713
|
+
const timestamp = candidateTimestamp(item);
|
|
24714
|
+
if (timestamp > maxTimestamp) {
|
|
24715
|
+
maxTimestamp = timestamp;
|
|
24716
|
+
}
|
|
24717
|
+
}
|
|
24718
|
+
}
|
|
24719
|
+
return maxTimestamp;
|
|
24720
|
+
}
|
|
24721
|
+
function planContextPackCompilation(input) {
|
|
24722
|
+
const args = input.args ?? {};
|
|
24723
|
+
const topicId = String(input.topic._id);
|
|
24724
|
+
const queryText = typeof args.query === "string" && args.query.trim().length > 0 ? args.query.trim() : void 0;
|
|
24725
|
+
const tokens = normalizeQueryTokens(queryText);
|
|
24726
|
+
const limit = toPositiveInt(args.limit, 8, 25);
|
|
24727
|
+
const rankingProfile = parseRankingProfile(
|
|
24728
|
+
typeof args.ranking === "string" ? args.ranking : args.rankingProfile
|
|
24729
|
+
);
|
|
24730
|
+
const tokenBudget = parseTokenBudget(
|
|
24731
|
+
typeof args.budget === "number" ? args.budget : args.tokenBudget,
|
|
24732
|
+
1800
|
|
24733
|
+
);
|
|
24734
|
+
const topicDepth = typeof input.topic.depth === "number" && Number.isFinite(input.topic.depth) ? input.topic.depth : 0;
|
|
24735
|
+
const requestedMaxDepth = typeof args.maxDepth === "number" && Number.isFinite(args.maxDepth) ? Math.max(1, Math.min(Math.floor(args.maxDepth), 6)) : void 0;
|
|
24736
|
+
const descendantDepth = requestedMaxDepth ?? (topicDepth <= 1 ? 4 : 2);
|
|
24737
|
+
const includeEntities = args.includeEntities !== false;
|
|
24738
|
+
const compilationMode = args.mode === "delta" ? "delta" : DEFAULT_COMPILATION_MODE;
|
|
24739
|
+
const includeFailures = compilationMode === "delta" || args.includeFailures === true;
|
|
24740
|
+
const worktreeId = typeof args.worktreeId === "string" && args.worktreeId.trim().length > 0 ? args.worktreeId.trim() : void 0;
|
|
24741
|
+
const sessionId = typeof args.sessionId === "string" && args.sessionId.trim().length > 0 ? args.sessionId.trim() : void 0;
|
|
24742
|
+
const packWeightOverrides = Array.isArray(args.packWeightOverrides) ? args.packWeightOverrides : void 0;
|
|
24743
|
+
const effectiveWeights = resolveEffectiveWeights(packWeightOverrides);
|
|
24744
|
+
let scopedTopicIds = collectTopicNeighborhood(
|
|
24745
|
+
input.allTopics,
|
|
24746
|
+
topicId,
|
|
24747
|
+
descendantDepth
|
|
24748
|
+
);
|
|
24749
|
+
const allowedTopicIds = asStringArray(args.allowedTopicIds);
|
|
24750
|
+
if (allowedTopicIds.length > 0) {
|
|
24751
|
+
const allowedSet = new Set(allowedTopicIds);
|
|
24752
|
+
if (!allowedSet.has(topicId)) {
|
|
24753
|
+
throw new Error(`Access denied to compile context for topic ${topicId}.`);
|
|
24754
|
+
}
|
|
24755
|
+
scopedTopicIds = scopedTopicIds.filter((id) => allowedSet.has(id));
|
|
24756
|
+
}
|
|
24757
|
+
return {
|
|
24758
|
+
topicId,
|
|
24759
|
+
...queryText ? { queryText } : {},
|
|
24760
|
+
tokens,
|
|
24761
|
+
limit,
|
|
24762
|
+
rankingProfile,
|
|
24763
|
+
tokenBudget,
|
|
24764
|
+
descendantDepth,
|
|
24765
|
+
includeEntities,
|
|
24766
|
+
compilationMode,
|
|
24767
|
+
includeFailures,
|
|
24768
|
+
...worktreeId ? { worktreeId } : {},
|
|
24769
|
+
...sessionId ? { sessionId } : {},
|
|
24770
|
+
...packWeightOverrides ? { packWeightOverrides } : {},
|
|
24771
|
+
effectiveWeights,
|
|
24772
|
+
scopedTopicIds
|
|
24773
|
+
};
|
|
24774
|
+
}
|
|
24775
|
+
function compileContextPackFromSnapshot(snapshot) {
|
|
24776
|
+
const uniqueBeliefs = dedupeById(snapshot.beliefs);
|
|
24777
|
+
const uniqueQuestions = dedupeById(snapshot.questions);
|
|
24778
|
+
const uniqueEvidence = dedupeById(snapshot.evidence);
|
|
24779
|
+
const uniqueContradictions = dedupeById(snapshot.contradictions);
|
|
24780
|
+
const referenceTimeMs = resolveReferenceTimeMs(
|
|
24781
|
+
[snapshot.topic],
|
|
24782
|
+
uniqueBeliefs,
|
|
24783
|
+
uniqueQuestions,
|
|
24784
|
+
uniqueEvidence,
|
|
24785
|
+
uniqueContradictions,
|
|
24786
|
+
snapshot.entities
|
|
24787
|
+
) || 0;
|
|
24788
|
+
const rankOptions = {
|
|
24789
|
+
effectiveWeights: snapshot.plan.effectiveWeights,
|
|
24790
|
+
includeJustifications: snapshot.plan.compilationMode === "delta",
|
|
24791
|
+
referenceTimeMs
|
|
24792
|
+
};
|
|
24793
|
+
const invariantCandidates = uniqueBeliefs.filter((belief) => beliefTypeOf(belief).toLowerCase() === "invariant").map((belief) => ({
|
|
24794
|
+
nodeId: String(belief._id),
|
|
24795
|
+
canonicalText: String(belief.canonicalText || ""),
|
|
24796
|
+
confidence: typeof belief.confidence === "number" ? belief.confidence : null,
|
|
24797
|
+
beliefType: beliefTypeOf(belief) || "invariant",
|
|
24798
|
+
updatedAt: belief.updatedAt || belief.createdAt || null
|
|
24799
|
+
}));
|
|
24800
|
+
const invariants = rankContextSection(
|
|
24801
|
+
"invariants",
|
|
24802
|
+
invariantCandidates.map((candidate) => ({
|
|
24803
|
+
...candidate,
|
|
24804
|
+
id: candidate.nodeId,
|
|
24805
|
+
text: `${candidate.canonicalText} ${candidate.beliefType}`
|
|
24806
|
+
})),
|
|
24807
|
+
snapshot.plan.tokens,
|
|
24808
|
+
snapshot.plan.limit,
|
|
24809
|
+
snapshot.plan.rankingProfile,
|
|
24810
|
+
rankOptions
|
|
24811
|
+
).map((row) => ({
|
|
24812
|
+
nodeId: row.nodeId,
|
|
24813
|
+
canonicalText: row.canonicalText,
|
|
24814
|
+
confidence: row.confidence,
|
|
24815
|
+
beliefType: row.beliefType,
|
|
24816
|
+
score: row.score,
|
|
24817
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24818
|
+
}));
|
|
24819
|
+
const activeBeliefCandidates = uniqueBeliefs.filter((belief) => (belief.status || "active") !== "archived").map((belief) => ({
|
|
24820
|
+
nodeId: String(belief._id),
|
|
24821
|
+
canonicalText: String(belief.canonicalText || ""),
|
|
24822
|
+
confidence: typeof belief.confidence === "number" ? belief.confidence : null,
|
|
24823
|
+
beliefType: beliefTypeOf(belief) || null,
|
|
24824
|
+
status: belief.status || "active",
|
|
24825
|
+
updatedAt: belief.updatedAt || belief.createdAt || null,
|
|
24826
|
+
metadataText: belief.metadata && typeof belief.metadata === "object" ? metadataText(belief.metadata) : ""
|
|
24827
|
+
}));
|
|
24828
|
+
const activeBeliefs = rankContextSection(
|
|
24829
|
+
"activeBeliefs",
|
|
24830
|
+
activeBeliefCandidates.map((candidate) => ({
|
|
24831
|
+
...candidate,
|
|
24832
|
+
id: candidate.nodeId,
|
|
24833
|
+
text: `${candidate.canonicalText} ${candidate.metadataText}`
|
|
24834
|
+
})),
|
|
24835
|
+
snapshot.plan.tokens,
|
|
24836
|
+
snapshot.plan.limit,
|
|
24837
|
+
snapshot.plan.rankingProfile,
|
|
24838
|
+
rankOptions
|
|
24839
|
+
).map((row) => ({
|
|
24840
|
+
nodeId: row.nodeId,
|
|
24841
|
+
canonicalText: row.canonicalText,
|
|
24842
|
+
confidence: row.confidence,
|
|
24843
|
+
beliefType: row.beliefType,
|
|
24844
|
+
status: row.status,
|
|
24845
|
+
updatedAt: row.updatedAt,
|
|
24846
|
+
score: row.score,
|
|
24847
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24848
|
+
}));
|
|
24849
|
+
const openQuestionCandidates = uniqueQuestions.map((question) => {
|
|
24850
|
+
const status = questionStatusOf(question);
|
|
24851
|
+
const metadata = question.metadata && typeof question.metadata === "object" ? question.metadata : {};
|
|
24852
|
+
return {
|
|
24853
|
+
questionId: String(question._id),
|
|
24854
|
+
text: String(question.canonicalText || ""),
|
|
24855
|
+
status,
|
|
24856
|
+
priority: typeof metadata.priority === "string" ? metadata.priority : "medium",
|
|
24857
|
+
updatedAt: question.updatedAt || question.createdAt || null,
|
|
24858
|
+
metadataText: metadataText(metadata)
|
|
24859
|
+
};
|
|
24860
|
+
}).filter((row) => isOpenQuestion(row.status));
|
|
24861
|
+
const openQuestions = rankContextSection(
|
|
24862
|
+
"openQuestions",
|
|
24863
|
+
openQuestionCandidates.map((candidate) => ({
|
|
24864
|
+
...candidate,
|
|
24865
|
+
id: candidate.questionId,
|
|
24866
|
+
text: `${candidate.text} ${candidate.metadataText}`
|
|
24867
|
+
})),
|
|
24868
|
+
snapshot.plan.tokens,
|
|
24869
|
+
snapshot.plan.limit,
|
|
24870
|
+
snapshot.plan.rankingProfile,
|
|
24871
|
+
rankOptions
|
|
24872
|
+
).map((row) => ({
|
|
24873
|
+
questionId: row.questionId,
|
|
24874
|
+
text: row.text,
|
|
24875
|
+
status: row.status,
|
|
24876
|
+
priority: row.priority,
|
|
24877
|
+
updatedAt: row.updatedAt,
|
|
24878
|
+
score: row.score,
|
|
24879
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24880
|
+
}));
|
|
24881
|
+
const evidenceCandidates = uniqueEvidence.map((item) => {
|
|
24882
|
+
const metadata = item.metadata && typeof item.metadata === "object" ? item.metadata : {};
|
|
24883
|
+
return {
|
|
24884
|
+
nodeId: String(item._id),
|
|
24885
|
+
canonicalText: String(item.canonicalText || ""),
|
|
24886
|
+
sourceUrl: typeof metadata.sourceUrl === "string" && metadata.sourceUrl || typeof item.sourceUrl === "string" && item.sourceUrl || null,
|
|
24887
|
+
kind: typeof metadata.kind === "string" && metadata.kind || "observation",
|
|
24888
|
+
createdAt: item.createdAt || null,
|
|
24889
|
+
updatedAt: item.updatedAt || item.createdAt || null,
|
|
24890
|
+
metadataText: metadataText(metadata)
|
|
24891
|
+
};
|
|
24892
|
+
});
|
|
24893
|
+
const recentEvidence = rankContextSection(
|
|
24894
|
+
"recentEvidence",
|
|
24895
|
+
evidenceCandidates.map((candidate) => ({
|
|
24896
|
+
...candidate,
|
|
24897
|
+
id: candidate.nodeId,
|
|
24898
|
+
text: `${candidate.canonicalText} ${candidate.metadataText}`
|
|
24899
|
+
})),
|
|
24900
|
+
snapshot.plan.tokens,
|
|
24901
|
+
snapshot.plan.limit,
|
|
24902
|
+
snapshot.plan.rankingProfile,
|
|
24903
|
+
rankOptions
|
|
24904
|
+
).map((row) => ({
|
|
24905
|
+
nodeId: row.nodeId,
|
|
24906
|
+
canonicalText: row.canonicalText,
|
|
24907
|
+
sourceUrl: row.sourceUrl,
|
|
24908
|
+
kind: row.kind,
|
|
24909
|
+
createdAt: row.createdAt,
|
|
24910
|
+
score: row.score,
|
|
24911
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24912
|
+
}));
|
|
24913
|
+
const contradictionCandidates = uniqueContradictions.map((row) => {
|
|
24914
|
+
const weight = typeof row.weight === "number" ? row.weight : 0;
|
|
24915
|
+
const severity = weight <= -0.9 ? "critical" : weight <= -0.7 ? "high" : weight <= -0.5 ? "medium" : "low";
|
|
24916
|
+
return {
|
|
24917
|
+
contradictionId: String(row._id || row.globalId || ""),
|
|
24918
|
+
severity,
|
|
24919
|
+
status: "active",
|
|
24920
|
+
description: row.context || row.description || row.summary || "",
|
|
24921
|
+
updatedAt: row.updatedAt || row.createdAt || null
|
|
24922
|
+
};
|
|
24923
|
+
});
|
|
24924
|
+
const contradictions2 = rankContextSection(
|
|
24925
|
+
"contradictions",
|
|
24926
|
+
contradictionCandidates.map((candidate) => ({
|
|
24927
|
+
...candidate,
|
|
24928
|
+
id: candidate.contradictionId,
|
|
24929
|
+
text: `${candidate.description} ${candidate.severity}`
|
|
24930
|
+
})),
|
|
24931
|
+
snapshot.plan.tokens,
|
|
24932
|
+
snapshot.plan.limit,
|
|
24933
|
+
snapshot.plan.rankingProfile,
|
|
24934
|
+
rankOptions
|
|
24935
|
+
).map((row) => ({
|
|
24936
|
+
contradictionId: row.contradictionId,
|
|
24937
|
+
severity: row.severity,
|
|
24938
|
+
status: row.status,
|
|
24939
|
+
description: row.description,
|
|
24940
|
+
score: row.score,
|
|
24941
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24942
|
+
}));
|
|
24943
|
+
const entityCandidates = snapshot.entities.map((row) => ({
|
|
24944
|
+
nodeId: String(row._id),
|
|
24945
|
+
entityType: String(row.nodeType || ""),
|
|
24946
|
+
title: String(row.title || ""),
|
|
24947
|
+
canonicalText: String(row.canonicalText || ""),
|
|
24948
|
+
connectedBeliefCount: typeof row.connectedBeliefCount === "number" ? row.connectedBeliefCount : 0,
|
|
24949
|
+
connectedEvidenceCount: typeof row.connectedEvidenceCount === "number" ? row.connectedEvidenceCount : 0,
|
|
24950
|
+
metadata: row.metadata && typeof row.metadata === "object" ? row.metadata : {},
|
|
24951
|
+
updatedAt: row.updatedAt || null
|
|
24952
|
+
}));
|
|
24953
|
+
const entityLimit = toPositiveInt(
|
|
24954
|
+
snapshot.plan.limit,
|
|
24955
|
+
DEFAULT_ENTITY_LIMIT,
|
|
24956
|
+
MAX_ENTITY_LIMIT
|
|
24957
|
+
);
|
|
24958
|
+
const rankedEntities = snapshot.plan.includeEntities ? rankEntities(entityCandidates, snapshot.plan.tokens, entityLimit).map(
|
|
24959
|
+
(row) => ({
|
|
24960
|
+
nodeId: row.nodeId,
|
|
24961
|
+
entityType: row.entityType,
|
|
24962
|
+
title: row.title,
|
|
24963
|
+
connectedBeliefCount: row.connectedBeliefCount,
|
|
24964
|
+
connectedEvidenceCount: row.connectedEvidenceCount,
|
|
24965
|
+
score: row.score,
|
|
24966
|
+
...Object.keys(row.metadata).length > 0 ? { metadata: row.metadata } : {}
|
|
24967
|
+
})
|
|
24968
|
+
) : void 0;
|
|
24969
|
+
let failureContext;
|
|
24970
|
+
if (snapshot.plan.includeFailures && snapshot.failures) {
|
|
24971
|
+
const allFailures = snapshot.failures.filter((node) => {
|
|
24972
|
+
const metadata = node.metadata || {};
|
|
24973
|
+
return metadata.failedApproach === true || metadata.isFailedAttempt === true;
|
|
24974
|
+
});
|
|
24975
|
+
const rankedFailures = rankContextSection(
|
|
24976
|
+
"recentEvidence",
|
|
24977
|
+
allFailures.map((node) => ({
|
|
24978
|
+
id: String(node._id),
|
|
24979
|
+
text: String(node.canonicalText || ""),
|
|
24980
|
+
createdAt: node.createdAt || null,
|
|
24981
|
+
updatedAt: node.updatedAt || node.createdAt || null
|
|
24982
|
+
})),
|
|
24983
|
+
snapshot.plan.tokens,
|
|
24984
|
+
10,
|
|
24985
|
+
snapshot.plan.rankingProfile,
|
|
24986
|
+
rankOptions
|
|
24987
|
+
);
|
|
24988
|
+
const failures = rankedFailures.map((row) => {
|
|
24989
|
+
const original = allFailures.find((node) => String(node._id) === row.id);
|
|
24990
|
+
const metadata = original?.metadata || {};
|
|
24991
|
+
return {
|
|
24992
|
+
attemptId: row.id,
|
|
24993
|
+
approach: String(row.text || ""),
|
|
24994
|
+
outcome: String(metadata.errorMessage || "Failed"),
|
|
24995
|
+
recordedAt: row.createdAt || referenceTimeMs || 0,
|
|
24996
|
+
score: row.score
|
|
24997
|
+
};
|
|
24998
|
+
});
|
|
24999
|
+
const failureTexts = new Set(
|
|
25000
|
+
failures.map((failure) => failure.approach.toLowerCase().slice(0, 100))
|
|
25001
|
+
);
|
|
25002
|
+
const suppressionIds = /* @__PURE__ */ new Set();
|
|
25003
|
+
if (snapshot.plan.sessionId && failureTexts.size > 0) {
|
|
25004
|
+
for (const evidenceRow of recentEvidence) {
|
|
25005
|
+
const evidenceText = evidenceRow.canonicalText.toLowerCase().slice(0, 100);
|
|
25006
|
+
for (const failureText of failureTexts) {
|
|
25007
|
+
if (evidenceText.includes(failureText) || failureText.includes(evidenceText)) {
|
|
25008
|
+
suppressionIds.add(evidenceRow.nodeId);
|
|
25009
|
+
break;
|
|
25010
|
+
}
|
|
25011
|
+
}
|
|
25012
|
+
}
|
|
25013
|
+
}
|
|
25014
|
+
if (failures.length > 0) {
|
|
25015
|
+
failureContext = {
|
|
25016
|
+
failures,
|
|
25017
|
+
suppressedIds: Array.from(suppressionIds)
|
|
25018
|
+
};
|
|
25019
|
+
}
|
|
25020
|
+
}
|
|
25021
|
+
const suppressionSet = new Set(failureContext?.suppressedIds || []);
|
|
25022
|
+
const effectiveEvidence = suppressionSet.size > 0 ? recentEvidence.filter((row) => !suppressionSet.has(row.nodeId)) : recentEvidence;
|
|
25023
|
+
const suppressedEvidenceIds = suppressionSet.size > 0 ? recentEvidence.filter((row) => suppressionSet.has(row.nodeId)).map((row) => row.nodeId) : [];
|
|
25024
|
+
const summary = {
|
|
25025
|
+
totalBeliefs: uniqueBeliefs.length,
|
|
25026
|
+
invariants: invariants.length,
|
|
25027
|
+
openQuestions: openQuestions.length,
|
|
25028
|
+
evidenceItems: uniqueEvidence.length,
|
|
25029
|
+
contradictions: contradictions2.length,
|
|
25030
|
+
...rankedEntities ? { relatedEntities: rankedEntities.length } : {},
|
|
25031
|
+
scopedTopics: snapshot.plan.scopedTopicIds.length,
|
|
25032
|
+
descendantDepth: snapshot.plan.descendantDepth,
|
|
25033
|
+
query: snapshot.plan.queryText || null
|
|
25034
|
+
};
|
|
25035
|
+
const injectionPolicy = buildInjectionPlan({
|
|
25036
|
+
tokenBudget: snapshot.plan.tokenBudget,
|
|
25037
|
+
invariants: invariants.map((row) => ({
|
|
25038
|
+
nodeId: row.nodeId,
|
|
25039
|
+
canonicalText: row.canonicalText,
|
|
25040
|
+
score: row.score
|
|
25041
|
+
})),
|
|
25042
|
+
activeBeliefs: activeBeliefs.map((row) => ({
|
|
25043
|
+
nodeId: row.nodeId,
|
|
25044
|
+
canonicalText: row.canonicalText,
|
|
25045
|
+
score: row.score
|
|
25046
|
+
})),
|
|
25047
|
+
openQuestions: openQuestions.map((row) => ({
|
|
25048
|
+
questionId: row.questionId,
|
|
25049
|
+
text: row.text,
|
|
25050
|
+
score: row.score
|
|
25051
|
+
})),
|
|
25052
|
+
recentEvidence: effectiveEvidence.map((row) => ({
|
|
25053
|
+
nodeId: row.nodeId,
|
|
25054
|
+
canonicalText: row.canonicalText,
|
|
25055
|
+
score: row.score
|
|
25056
|
+
})),
|
|
25057
|
+
contradictions: contradictions2.map((row) => ({
|
|
25058
|
+
contradictionId: row.contradictionId,
|
|
25059
|
+
description: row.description,
|
|
25060
|
+
score: row.score
|
|
25061
|
+
})),
|
|
25062
|
+
trackExclusions: snapshot.plan.compilationMode === "delta"
|
|
25063
|
+
});
|
|
25064
|
+
const contextNarrative = [
|
|
25065
|
+
"Prefer invariant beliefs as hard constraints while reasoning over this scope.",
|
|
25066
|
+
"Treat open questions as unresolved work items and avoid claiming closure without evidence.",
|
|
25067
|
+
"Use recent evidence for implementation context before creating new beliefs.",
|
|
25068
|
+
"When contradictions exist, resolve explicitly (fork, lower confidence, or gather counter-evidence).",
|
|
25069
|
+
`Apply injection token budget of ${injectionPolicy.tokenBudget} with section quotas before prompt assembly.`
|
|
25070
|
+
];
|
|
25071
|
+
const deltaReport = snapshot.plan.compilationMode === "delta" && snapshot.plan.worktreeId ? {
|
|
25072
|
+
changedItems: [],
|
|
25073
|
+
verificationObligations: [],
|
|
25074
|
+
referencePoint: snapshot.plan.worktreeId
|
|
25075
|
+
} : void 0;
|
|
25076
|
+
const excludedItems = [
|
|
25077
|
+
...injectionPolicy.excludedItems || [],
|
|
25078
|
+
...suppressedEvidenceIds.map((id) => ({
|
|
25079
|
+
id,
|
|
25080
|
+
section: "recentEvidence",
|
|
25081
|
+
reason: "anti_repetition",
|
|
25082
|
+
score: recentEvidence.find((row) => row.nodeId === id)?.score ?? 0
|
|
25083
|
+
}))
|
|
25084
|
+
];
|
|
25085
|
+
const result = {
|
|
25086
|
+
schemaVersion: CONTEXT_PACK_SCHEMA_VERSION,
|
|
25087
|
+
topicId: snapshot.plan.topicId,
|
|
25088
|
+
topicName: snapshot.topic.name || "Untitled Topic",
|
|
25089
|
+
scopedTopicIds: snapshot.plan.scopedTopicIds,
|
|
25090
|
+
generatedAt: referenceTimeMs,
|
|
25091
|
+
rankingProfile: snapshot.plan.rankingProfile,
|
|
25092
|
+
summary,
|
|
25093
|
+
invariants,
|
|
25094
|
+
activeBeliefs,
|
|
25095
|
+
openQuestions,
|
|
25096
|
+
recentEvidence: effectiveEvidence,
|
|
25097
|
+
contradictions: contradictions2,
|
|
25098
|
+
...rankedEntities ? { relatedEntities: rankedEntities } : {},
|
|
25099
|
+
contextNarrative,
|
|
25100
|
+
injectionPolicy: {
|
|
25101
|
+
...injectionPolicy,
|
|
25102
|
+
...excludedItems.length > 0 ? { excludedItems } : {}
|
|
25103
|
+
},
|
|
25104
|
+
diagnostics: {
|
|
25105
|
+
itemsScored: invariantCandidates.length + activeBeliefCandidates.length + openQuestionCandidates.length + evidenceCandidates.length + contradictionCandidates.length + entityCandidates.length,
|
|
25106
|
+
tokenBudgetUtilization: injectionPolicy.tokenBudget === 0 ? 0 : Number(
|
|
25107
|
+
(injectionPolicy.estimatedTokens / injectionPolicy.tokenBudget).toFixed(4)
|
|
25108
|
+
),
|
|
25109
|
+
referenceTimeMs
|
|
25110
|
+
},
|
|
25111
|
+
...snapshot.plan.compilationMode !== "standard" ? { compilationMode: snapshot.plan.compilationMode } : {},
|
|
25112
|
+
...failureContext ? { failureContext } : {},
|
|
25113
|
+
...deltaReport ? { deltaReport } : {},
|
|
25114
|
+
...snapshot.plan.packWeightOverrides && snapshot.plan.packWeightOverrides.length > 0 ? { appliedWeightOverrides: snapshot.plan.packWeightOverrides } : {}
|
|
25115
|
+
};
|
|
25116
|
+
assertContextPackSchema(result);
|
|
25117
|
+
return result;
|
|
25118
|
+
}
|
|
25119
|
+
|
|
25120
|
+
// ../sdk/src/controlObjectOwnership.ts
|
|
25121
|
+
var CONTROL_OBJECT_KINDS = [
|
|
25122
|
+
"tenant",
|
|
25123
|
+
"workspace",
|
|
25124
|
+
"principal",
|
|
25125
|
+
"tool",
|
|
25126
|
+
"pack",
|
|
25127
|
+
"ontology",
|
|
25128
|
+
"belief",
|
|
25129
|
+
"policy_rule"
|
|
25130
|
+
];
|
|
25131
|
+
var CONTROL_OBJECT_OWNER_SCOPES = [
|
|
25132
|
+
"platform",
|
|
25133
|
+
"tenant",
|
|
25134
|
+
"workspace",
|
|
25135
|
+
"resource"
|
|
25136
|
+
];
|
|
25137
|
+
var CONTROL_OBJECT_EDIT_SURFACES = [
|
|
25138
|
+
"platform_admin",
|
|
25139
|
+
"tenant_admin",
|
|
25140
|
+
"workspace_admin",
|
|
25141
|
+
"graph_worktree"
|
|
25142
|
+
];
|
|
25143
|
+
var CONTROL_OBJECT_INHERITANCE_RULES = [
|
|
25144
|
+
"none",
|
|
25145
|
+
"platform_seed_to_tenant",
|
|
25146
|
+
"tenant_default_to_workspace",
|
|
25147
|
+
"workspace_narrowing_only",
|
|
25148
|
+
"pack_overlay_to_tenant",
|
|
25149
|
+
"topic_lineage_to_resource"
|
|
25150
|
+
];
|
|
25151
|
+
var CONTROL_OBJECT_BLAST_RADII = [
|
|
25152
|
+
"platform",
|
|
25153
|
+
"tenant",
|
|
25154
|
+
"workspace",
|
|
25155
|
+
"resource"
|
|
25156
|
+
];
|
|
25157
|
+
function defineCases(cases) {
|
|
25158
|
+
return cases;
|
|
25159
|
+
}
|
|
25160
|
+
var CONTROL_OBJECT_OWNERSHIP_MATRIX = {
|
|
25161
|
+
tenant: defineCases([
|
|
25162
|
+
{
|
|
25163
|
+
caseKey: "platform-record",
|
|
25164
|
+
caseLabel: "Platform Record",
|
|
25165
|
+
kind: "tenant",
|
|
25166
|
+
canonicalOwnerScope: "platform",
|
|
25167
|
+
editSurface: "platform_admin",
|
|
25168
|
+
inheritanceRule: "none",
|
|
25169
|
+
blastRadius: "tenant"
|
|
25170
|
+
}
|
|
25171
|
+
]),
|
|
25172
|
+
workspace: defineCases([
|
|
25173
|
+
{
|
|
25174
|
+
caseKey: "tenant-workspace",
|
|
25175
|
+
caseLabel: "Tenant Workspace",
|
|
25176
|
+
kind: "workspace",
|
|
25177
|
+
canonicalOwnerScope: "tenant",
|
|
25178
|
+
editSurface: "tenant_admin",
|
|
25179
|
+
inheritanceRule: "tenant_default_to_workspace",
|
|
25180
|
+
blastRadius: "workspace"
|
|
25181
|
+
}
|
|
25182
|
+
]),
|
|
25183
|
+
principal: defineCases([
|
|
25184
|
+
{
|
|
25185
|
+
caseKey: "tenant-principal",
|
|
25186
|
+
caseLabel: "Tenant Principal",
|
|
25187
|
+
kind: "principal",
|
|
25188
|
+
canonicalOwnerScope: "tenant",
|
|
25189
|
+
editSurface: "tenant_admin",
|
|
25190
|
+
inheritanceRule: "workspace_narrowing_only",
|
|
25191
|
+
blastRadius: "resource"
|
|
25192
|
+
}
|
|
25193
|
+
]),
|
|
25194
|
+
tool: defineCases([
|
|
25195
|
+
{
|
|
25196
|
+
caseKey: "platform-core",
|
|
25197
|
+
caseLabel: "Platform Core",
|
|
25198
|
+
kind: "tool",
|
|
25199
|
+
canonicalOwnerScope: "platform",
|
|
25200
|
+
editSurface: "platform_admin",
|
|
25201
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25202
|
+
blastRadius: "platform"
|
|
25203
|
+
},
|
|
25204
|
+
{
|
|
25205
|
+
caseKey: "tenant-custom",
|
|
25206
|
+
caseLabel: "Tenant Custom",
|
|
25207
|
+
kind: "tool",
|
|
25208
|
+
canonicalOwnerScope: "tenant",
|
|
25209
|
+
editSurface: "tenant_admin",
|
|
25210
|
+
inheritanceRule: "tenant_default_to_workspace",
|
|
25211
|
+
blastRadius: "tenant"
|
|
25212
|
+
}
|
|
25213
|
+
]),
|
|
25214
|
+
pack: defineCases([
|
|
25215
|
+
{
|
|
25216
|
+
caseKey: "platform-definition",
|
|
25217
|
+
caseLabel: "Platform Definition",
|
|
25218
|
+
kind: "pack",
|
|
25219
|
+
canonicalOwnerScope: "platform",
|
|
25220
|
+
editSurface: "platform_admin",
|
|
25221
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25222
|
+
blastRadius: "platform"
|
|
25223
|
+
},
|
|
25224
|
+
{
|
|
25225
|
+
caseKey: "tenant-installation",
|
|
25226
|
+
caseLabel: "Tenant Installation",
|
|
25227
|
+
kind: "pack",
|
|
25228
|
+
canonicalOwnerScope: "tenant",
|
|
25229
|
+
editSurface: "tenant_admin",
|
|
25230
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25231
|
+
blastRadius: "tenant"
|
|
25232
|
+
}
|
|
25233
|
+
]),
|
|
25234
|
+
ontology: defineCases([
|
|
25235
|
+
{
|
|
25236
|
+
caseKey: "platform-base",
|
|
25237
|
+
caseLabel: "Platform Base",
|
|
25238
|
+
kind: "ontology",
|
|
25239
|
+
canonicalOwnerScope: "platform",
|
|
25240
|
+
editSurface: "platform_admin",
|
|
25241
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25242
|
+
blastRadius: "platform"
|
|
25243
|
+
},
|
|
25244
|
+
{
|
|
25245
|
+
caseKey: "pack-overlay",
|
|
25246
|
+
caseLabel: "Pack Overlay",
|
|
25247
|
+
kind: "ontology",
|
|
25248
|
+
canonicalOwnerScope: "platform",
|
|
25249
|
+
editSurface: "platform_admin",
|
|
25250
|
+
inheritanceRule: "pack_overlay_to_tenant",
|
|
25251
|
+
blastRadius: "platform"
|
|
25252
|
+
},
|
|
25253
|
+
{
|
|
25254
|
+
caseKey: "tenant-extension",
|
|
25255
|
+
caseLabel: "Tenant Extension",
|
|
25256
|
+
kind: "ontology",
|
|
25257
|
+
canonicalOwnerScope: "tenant",
|
|
25258
|
+
editSurface: "tenant_admin",
|
|
25259
|
+
inheritanceRule: "topic_lineage_to_resource",
|
|
25260
|
+
blastRadius: "tenant"
|
|
25261
|
+
}
|
|
25262
|
+
]),
|
|
25263
|
+
belief: defineCases([
|
|
25264
|
+
{
|
|
25265
|
+
caseKey: "topic-resource",
|
|
25266
|
+
caseLabel: "Topic Resource",
|
|
25267
|
+
kind: "belief",
|
|
25268
|
+
canonicalOwnerScope: "resource",
|
|
25269
|
+
editSurface: "graph_worktree",
|
|
25270
|
+
inheritanceRule: "topic_lineage_to_resource",
|
|
25271
|
+
blastRadius: "resource"
|
|
25272
|
+
}
|
|
25273
|
+
]),
|
|
25274
|
+
policy_rule: defineCases([
|
|
25275
|
+
{
|
|
25276
|
+
caseKey: "platform-baseline",
|
|
25277
|
+
caseLabel: "Platform Baseline",
|
|
25278
|
+
kind: "policy_rule",
|
|
25279
|
+
canonicalOwnerScope: "platform",
|
|
25280
|
+
editSurface: "platform_admin",
|
|
25281
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25282
|
+
blastRadius: "platform"
|
|
25283
|
+
},
|
|
25284
|
+
{
|
|
25285
|
+
caseKey: "tenant-bundle",
|
|
25286
|
+
caseLabel: "Tenant Bundle",
|
|
25287
|
+
kind: "policy_rule",
|
|
25288
|
+
canonicalOwnerScope: "tenant",
|
|
25289
|
+
editSurface: "tenant_admin",
|
|
25290
|
+
inheritanceRule: "tenant_default_to_workspace",
|
|
25291
|
+
blastRadius: "tenant"
|
|
25292
|
+
},
|
|
25293
|
+
{
|
|
25294
|
+
caseKey: "workspace-override",
|
|
25295
|
+
caseLabel: "Workspace Override",
|
|
25296
|
+
kind: "policy_rule",
|
|
25297
|
+
canonicalOwnerScope: "workspace",
|
|
25298
|
+
editSurface: "workspace_admin",
|
|
25299
|
+
inheritanceRule: "none",
|
|
25300
|
+
blastRadius: "workspace"
|
|
25301
|
+
}
|
|
25302
|
+
])
|
|
25303
|
+
};
|
|
25304
|
+
function flattenOwnershipMatrix(matrix) {
|
|
25305
|
+
return CONTROL_OBJECT_KINDS.flatMap((kind) => [...matrix[kind]]);
|
|
25306
|
+
}
|
|
25307
|
+
var CONTROL_OBJECT_OWNERSHIP_ROWS = Object.freeze(
|
|
25308
|
+
flattenOwnershipMatrix(CONTROL_OBJECT_OWNERSHIP_MATRIX)
|
|
25309
|
+
);
|
|
25310
|
+
var CONTROL_OBJECT_OWNERSHIP_CONTRACT = {
|
|
25311
|
+
version: "1.0.0",
|
|
25312
|
+
kinds: CONTROL_OBJECT_KINDS,
|
|
25313
|
+
ownerScopes: CONTROL_OBJECT_OWNER_SCOPES,
|
|
25314
|
+
editSurfaces: CONTROL_OBJECT_EDIT_SURFACES,
|
|
25315
|
+
inheritanceRules: CONTROL_OBJECT_INHERITANCE_RULES,
|
|
25316
|
+
blastRadii: CONTROL_OBJECT_BLAST_RADII,
|
|
25317
|
+
matrix: CONTROL_OBJECT_OWNERSHIP_MATRIX,
|
|
25318
|
+
rows: CONTROL_OBJECT_OWNERSHIP_ROWS
|
|
25319
|
+
};
|
|
25320
|
+
function listControlObjectOwnershipCases(kind) {
|
|
25321
|
+
if (!kind) {
|
|
25322
|
+
return CONTROL_OBJECT_OWNERSHIP_ROWS;
|
|
25323
|
+
}
|
|
25324
|
+
return CONTROL_OBJECT_OWNERSHIP_MATRIX[kind];
|
|
25325
|
+
}
|
|
25326
|
+
function getControlObjectOwnershipCase(kind, caseKey) {
|
|
25327
|
+
return CONTROL_OBJECT_OWNERSHIP_MATRIX[kind].find(
|
|
25328
|
+
(ownershipCase) => ownershipCase.caseKey === caseKey
|
|
25329
|
+
);
|
|
25330
|
+
}
|
|
25331
|
+
|
|
25332
|
+
// ../sdk/src/contracts/api-enums.contract.ts
|
|
25333
|
+
var BELIEF_STATUSES = [
|
|
25334
|
+
"assumption",
|
|
25335
|
+
"hypothesis",
|
|
25336
|
+
"belief",
|
|
25337
|
+
"fact"
|
|
25338
|
+
];
|
|
25339
|
+
var FORK_REASONS = [
|
|
25340
|
+
"refinement",
|
|
25341
|
+
"contradiction_response",
|
|
25342
|
+
"scope_change",
|
|
25343
|
+
"confidence_collapse",
|
|
25344
|
+
"manual"
|
|
25345
|
+
];
|
|
25346
|
+
var CONFIDENCE_TRIGGERS = [
|
|
25347
|
+
"evidence_added",
|
|
25348
|
+
"evidence_removed",
|
|
25349
|
+
"contradiction_detected",
|
|
25350
|
+
"contradiction_resolved",
|
|
25351
|
+
"agent_assessment",
|
|
25352
|
+
"worktree_outcome",
|
|
25353
|
+
"worktree_completed",
|
|
25354
|
+
"manual",
|
|
25355
|
+
"decay",
|
|
25356
|
+
"fusion",
|
|
25357
|
+
"discount",
|
|
25358
|
+
"deduction"
|
|
25359
|
+
];
|
|
25360
|
+
var EPISTEMIC_EDGE_TYPES = [
|
|
25361
|
+
"supports",
|
|
25362
|
+
"informs",
|
|
25363
|
+
"depends_on",
|
|
25364
|
+
"derived_from",
|
|
25365
|
+
"contains",
|
|
25366
|
+
"tests"
|
|
25367
|
+
];
|
|
25368
|
+
var STRUCTURAL_EDGE_TYPES = [
|
|
25369
|
+
"supersedes",
|
|
25370
|
+
"responds_to",
|
|
25371
|
+
"belongs_to",
|
|
25372
|
+
"relates_to_thesis"
|
|
25373
|
+
];
|
|
25374
|
+
var EDGE_TYPES = [
|
|
25375
|
+
...EPISTEMIC_EDGE_TYPES,
|
|
25376
|
+
...STRUCTURAL_EDGE_TYPES
|
|
25377
|
+
];
|
|
25378
|
+
var REASONING_METHODS = [
|
|
25379
|
+
"deductive",
|
|
25380
|
+
"inductive",
|
|
25381
|
+
"abductive",
|
|
25382
|
+
"analogical",
|
|
25383
|
+
"empirical"
|
|
25384
|
+
];
|
|
25385
|
+
var DEFEAT_TYPES = [
|
|
25386
|
+
"rebuts",
|
|
25387
|
+
"undercuts",
|
|
25388
|
+
"undermines"
|
|
25389
|
+
];
|
|
25390
|
+
var CONTRADICTION_SEVERITIES = [
|
|
25391
|
+
"low",
|
|
25392
|
+
"medium",
|
|
25393
|
+
"high",
|
|
25394
|
+
"critical"
|
|
25395
|
+
];
|
|
25396
|
+
var CONTRADICTION_STATUSES = [
|
|
25397
|
+
"unresolved",
|
|
25398
|
+
"resolved",
|
|
25399
|
+
"accepted"
|
|
25400
|
+
];
|
|
25401
|
+
var MERGE_OUTCOMES = [
|
|
25402
|
+
"validated",
|
|
25403
|
+
"invalidated",
|
|
25404
|
+
"forked",
|
|
25405
|
+
"inconclusive"
|
|
25406
|
+
];
|
|
25407
|
+
var WORKTREE_PHASES = [
|
|
25408
|
+
"hypothesis",
|
|
25409
|
+
"investigation",
|
|
25410
|
+
"evaluation",
|
|
25411
|
+
"resolution"
|
|
25412
|
+
];
|
|
25413
|
+
var EPISTEMIC_LAYERS = [
|
|
25414
|
+
"L1",
|
|
25415
|
+
"L2",
|
|
25416
|
+
"L3",
|
|
25417
|
+
"L4"
|
|
25418
|
+
];
|
|
25419
|
+
var JUDGMENT_TYPES = [
|
|
25420
|
+
"thesis",
|
|
25421
|
+
"thesis_maturity",
|
|
25422
|
+
"contradiction_ruling",
|
|
25423
|
+
"scope_determination",
|
|
25424
|
+
"confidence_ruling"
|
|
25425
|
+
];
|
|
25426
|
+
|
|
25427
|
+
// ../sdk/src/contracts/auth-session.contract.ts
|
|
25428
|
+
var SESSION_AUTH_MODES = [
|
|
25429
|
+
"interactive_user",
|
|
25430
|
+
"service_principal",
|
|
25431
|
+
"tenant_api_key",
|
|
25432
|
+
"session_token"
|
|
25433
|
+
];
|
|
25434
|
+
var SESSION_PRINCIPAL_TYPES = ["human", "service", "agent"];
|
|
25435
|
+
var SESSION_LIFECYCLE_STATUSES = [
|
|
25436
|
+
"active",
|
|
25437
|
+
"expired",
|
|
25438
|
+
"revoked"
|
|
25439
|
+
];
|
|
25440
|
+
function inferSessionPrincipalType(principalId) {
|
|
25441
|
+
if (principalId.startsWith("user:")) {
|
|
25442
|
+
return "human";
|
|
25443
|
+
}
|
|
25444
|
+
if (principalId.startsWith("agent:")) {
|
|
25445
|
+
return "agent";
|
|
25446
|
+
}
|
|
25447
|
+
return "service";
|
|
25448
|
+
}
|
|
25449
|
+
function normalizeDelegationChain(args) {
|
|
25450
|
+
if (args.delegationChain && args.delegationChain.length > 0) {
|
|
25451
|
+
return [...args.delegationChain];
|
|
25452
|
+
}
|
|
25453
|
+
if (!args.delegatedBy) {
|
|
25454
|
+
return;
|
|
25455
|
+
}
|
|
25456
|
+
return [
|
|
25457
|
+
{
|
|
25458
|
+
principalId: args.delegatedBy,
|
|
25459
|
+
principalType: args.delegatedByType ?? inferSessionPrincipalType(args.delegatedBy),
|
|
25460
|
+
delegatedAt: args.delegatedAt,
|
|
25461
|
+
reason: args.reason
|
|
25462
|
+
}
|
|
25463
|
+
];
|
|
25464
|
+
}
|
|
25465
|
+
function lastDelegator(delegationChain) {
|
|
25466
|
+
if (!delegationChain || delegationChain.length === 0) {
|
|
25467
|
+
return;
|
|
25468
|
+
}
|
|
25469
|
+
return delegationChain[delegationChain.length - 1]?.principalId;
|
|
25470
|
+
}
|
|
25471
|
+
|
|
25472
|
+
// ../sdk/src/contracts/lens-filter.contract.ts
|
|
25473
|
+
function isLensFilterCriteria2(value) {
|
|
25474
|
+
if (!value || typeof value !== "object") return false;
|
|
25475
|
+
const obj = value;
|
|
25476
|
+
return typeof obj.version === "number" && typeof obj.kind === "string";
|
|
25477
|
+
}
|
|
25478
|
+
function isTaxonomyFilterCriteriaV12(value) {
|
|
25479
|
+
if (!isLensFilterCriteria2(value)) return false;
|
|
25480
|
+
return value.version === 1 && value.kind === "taxonomy";
|
|
25481
|
+
}
|
|
25482
|
+
function validateFilterCriteria2(value) {
|
|
25483
|
+
if (value === void 0 || value === null) {
|
|
25484
|
+
return { valid: true };
|
|
25485
|
+
}
|
|
25486
|
+
if (!isLensFilterCriteria2(value)) {
|
|
25487
|
+
return {
|
|
25488
|
+
valid: false,
|
|
25489
|
+
errors: [
|
|
25490
|
+
'filterCriteria must have numeric "version" and string "kind" fields'
|
|
25491
|
+
]
|
|
25492
|
+
};
|
|
25493
|
+
}
|
|
25494
|
+
if (isTaxonomyFilterCriteriaV12(value)) {
|
|
25495
|
+
return validateTaxonomyFilterV1(value);
|
|
25496
|
+
}
|
|
25497
|
+
const raw = value;
|
|
25498
|
+
return {
|
|
25499
|
+
valid: false,
|
|
25500
|
+
errors: [
|
|
25501
|
+
`Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`
|
|
25502
|
+
]
|
|
25503
|
+
};
|
|
25504
|
+
}
|
|
25505
|
+
function validateTaxonomyFilterV1(criteria) {
|
|
25506
|
+
const errors = [];
|
|
25507
|
+
if (!Array.isArray(criteria.entityTypeFilters)) {
|
|
25508
|
+
errors.push("entityTypeFilters must be an array");
|
|
25509
|
+
return { valid: false, errors };
|
|
25510
|
+
}
|
|
25511
|
+
if (criteria.entityTypeFilters.length === 0) {
|
|
25512
|
+
errors.push("entityTypeFilters must contain at least one entry");
|
|
25513
|
+
return { valid: false, errors };
|
|
25514
|
+
}
|
|
25515
|
+
for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
|
|
25516
|
+
const filter = criteria.entityTypeFilters[i];
|
|
25517
|
+
if (!filter || typeof filter.entityTypeValue !== "string") {
|
|
25518
|
+
errors.push(
|
|
25519
|
+
`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
|
|
25520
|
+
);
|
|
25521
|
+
continue;
|
|
25522
|
+
}
|
|
25523
|
+
if (filter.entityTypeValue.trim().length === 0) {
|
|
25524
|
+
errors.push(
|
|
25525
|
+
`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
|
|
25526
|
+
);
|
|
25527
|
+
}
|
|
25528
|
+
if (filter.subtypeValues !== void 0 && !Array.isArray(filter.subtypeValues)) {
|
|
25529
|
+
errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
|
|
25530
|
+
}
|
|
25531
|
+
}
|
|
25532
|
+
if (criteria.ontologyScope !== void 0) {
|
|
25533
|
+
if (typeof criteria.ontologyScope !== "object" || criteria.ontologyScope === null) {
|
|
25534
|
+
errors.push("ontologyScope must be an object");
|
|
25535
|
+
}
|
|
25536
|
+
}
|
|
25537
|
+
return errors.length === 0 ? { valid: true } : { valid: false, errors };
|
|
25538
|
+
}
|
|
25539
|
+
|
|
25540
|
+
// ../sdk/src/contracts/lens-workflow.contract.ts
|
|
25541
|
+
var LENS_PERSPECTIVE_TYPES2 = [
|
|
25542
|
+
"investigation",
|
|
25543
|
+
"monitoring",
|
|
25544
|
+
"analysis",
|
|
25545
|
+
"comparison",
|
|
25546
|
+
"taxonomy"
|
|
25547
|
+
];
|
|
25548
|
+
var LENS_STATUSES = ["draft", "active", "archived"];
|
|
25549
|
+
var LENS_TASK_TEMPLATE_PRIORITIES = [
|
|
25550
|
+
"critical",
|
|
25551
|
+
"high",
|
|
25552
|
+
"medium",
|
|
25553
|
+
"low"
|
|
25554
|
+
];
|
|
25555
|
+
var BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
|
|
25556
|
+
function inferLensPerspectiveTypeFromBranchSchema(schema) {
|
|
25557
|
+
const normalized = schema?.trim().toLowerCase();
|
|
25558
|
+
if (normalized === "phase") {
|
|
25559
|
+
return "monitoring";
|
|
25560
|
+
}
|
|
25561
|
+
if (normalized === "axis" || normalized === "dimension") {
|
|
25562
|
+
return "comparison";
|
|
25563
|
+
}
|
|
25564
|
+
if (normalized === "track") {
|
|
25565
|
+
return "investigation";
|
|
25566
|
+
}
|
|
25567
|
+
return "analysis";
|
|
25568
|
+
}
|
|
25569
|
+
function migrateBranchToLens(args) {
|
|
25570
|
+
const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);
|
|
25571
|
+
return {
|
|
25572
|
+
recommendedTool: "create_lens",
|
|
25573
|
+
perspectiveType,
|
|
25574
|
+
message: "Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.",
|
|
25575
|
+
suggestedPayload: {
|
|
25576
|
+
name: args.name,
|
|
25577
|
+
description: args.description,
|
|
25578
|
+
topicId: args.topicId,
|
|
25579
|
+
workspaceId: args.workspaceId,
|
|
25580
|
+
perspectiveType
|
|
25581
|
+
}
|
|
25582
|
+
};
|
|
25583
|
+
}
|
|
25584
|
+
function buildDeprecatedBranchMetadata(args) {
|
|
25585
|
+
return {
|
|
25586
|
+
deprecated: true,
|
|
25587
|
+
deprecationMessage: BRANCH_DEPRECATION_MESSAGE,
|
|
25588
|
+
lensSuggestion: migrateBranchToLens(args)
|
|
25589
|
+
};
|
|
25590
|
+
}
|
|
25591
|
+
|
|
25592
|
+
// ../sdk/src/contracts/mcpTools.ts
|
|
25593
|
+
var OPERATION_MANIFEST = LUCERN_OPERATION_MANIFEST;
|
|
25594
|
+
var MCP_ALWAYS_ALLOWED_TOOL_NAMES = ["identity_whoami"];
|
|
25595
|
+
function getMcpToolExposure(toolName) {
|
|
25596
|
+
return OPERATION_MANIFEST[toolName]?.surfaces.mcp ?? "none";
|
|
25597
|
+
}
|
|
25598
|
+
function decorateMcpToolContract(toolName, contract) {
|
|
25599
|
+
const exposure = getMcpToolExposure(toolName);
|
|
25600
|
+
if (exposure === "none") {
|
|
25601
|
+
return null;
|
|
25602
|
+
}
|
|
25603
|
+
return exposure === "internal" || contract.internal ? { ...contract, internal: true } : contract;
|
|
25604
|
+
}
|
|
25605
|
+
function buildMcpToolContracts(options = {}) {
|
|
25606
|
+
const merged = {
|
|
25607
|
+
...MCP_TOOL_CONTRACTS,
|
|
25608
|
+
...options.extensions ?? {}
|
|
25609
|
+
};
|
|
25610
|
+
return Object.fromEntries(
|
|
25611
|
+
Object.entries(merged).flatMap(([toolName, contract]) => {
|
|
25612
|
+
const decorated = decorateMcpToolContract(toolName, contract);
|
|
25613
|
+
return decorated ? [[toolName, decorated]] : [];
|
|
25614
|
+
})
|
|
25615
|
+
);
|
|
25616
|
+
}
|
|
25617
|
+
function mcpContractToInputSchema(contract) {
|
|
25618
|
+
const properties = {};
|
|
25619
|
+
for (const [paramName, paramDef] of Object.entries(contract.parameters)) {
|
|
25620
|
+
const prop = {
|
|
25621
|
+
type: paramDef.type,
|
|
25622
|
+
description: paramDef.description
|
|
25623
|
+
};
|
|
25624
|
+
if (paramDef.enum) {
|
|
25625
|
+
prop.enum = paramDef.enum;
|
|
25626
|
+
}
|
|
25627
|
+
properties[paramName] = prop;
|
|
25628
|
+
}
|
|
25629
|
+
return {
|
|
25630
|
+
type: "object",
|
|
25631
|
+
properties,
|
|
25632
|
+
required: contract.required
|
|
25633
|
+
};
|
|
25634
|
+
}
|
|
25635
|
+
function mcpContractToManifestEntry(name, contract) {
|
|
25636
|
+
return {
|
|
25637
|
+
name,
|
|
25638
|
+
description: contract.description,
|
|
25639
|
+
inputSchema: mcpContractToInputSchema(contract),
|
|
25640
|
+
internal: Boolean(contract.internal),
|
|
25641
|
+
ownerModule: contract.ownerModule,
|
|
25642
|
+
ontologyPrimitive: contract.ontologyPrimitive,
|
|
25643
|
+
tier: contract.tier
|
|
25644
|
+
};
|
|
25645
|
+
}
|
|
25646
|
+
function isMcpToolAllowed(toolName, options = {}) {
|
|
25647
|
+
const contracts = options.contracts ?? buildMcpToolContracts();
|
|
25648
|
+
const contract = contracts[toolName];
|
|
25649
|
+
const alwaysAllowed = /* @__PURE__ */ new Set([
|
|
25650
|
+
...MCP_ALWAYS_ALLOWED_TOOL_NAMES,
|
|
25651
|
+
...options.alwaysAllowedTools ?? []
|
|
25652
|
+
]);
|
|
25653
|
+
if (alwaysAllowed.has(toolName)) {
|
|
25654
|
+
return true;
|
|
25655
|
+
}
|
|
25656
|
+
if (options.sessionType === "user" && contract?.internal) {
|
|
25657
|
+
return false;
|
|
25658
|
+
}
|
|
25659
|
+
if (options.permittedTools !== void 0 && options.permittedTools !== null) {
|
|
25660
|
+
return options.permittedTools.some((tool) => tool.toolName === toolName);
|
|
25661
|
+
}
|
|
25662
|
+
if (options.allowedTools === null || options.allowedTools === void 0) {
|
|
25663
|
+
return true;
|
|
25664
|
+
}
|
|
25665
|
+
return options.allowedTools.includes(toolName);
|
|
25666
|
+
}
|
|
25667
|
+
function buildMcpToolManifest(args = {}) {
|
|
25668
|
+
const contracts = args.contracts ?? buildMcpToolContracts();
|
|
25669
|
+
return Object.entries(contracts).filter(([name, contract]) => {
|
|
25670
|
+
if (args.visibility?.sessionType === "user" && contract.internal) {
|
|
25671
|
+
return false;
|
|
25672
|
+
}
|
|
25673
|
+
return isMcpToolAllowed(name, {
|
|
25674
|
+
...args.visibility,
|
|
25675
|
+
contracts
|
|
25676
|
+
});
|
|
25677
|
+
}).map(([name, contract]) => mcpContractToManifestEntry(name, contract));
|
|
25678
|
+
}
|
|
25679
|
+
|
|
25680
|
+
// ../sdk/src/contracts/prompt.contract.ts
|
|
25681
|
+
function isLucernPrompt(value) {
|
|
25682
|
+
if (!value || typeof value !== "object") {
|
|
25683
|
+
return false;
|
|
25684
|
+
}
|
|
25685
|
+
const prompt = value;
|
|
25686
|
+
return typeof prompt.slug === "string" && typeof prompt.version === "string" && typeof prompt.template === "string" && Array.isArray(prompt.variables) && prompt.variables.every((entry) => typeof entry === "string") && (prompt.modelHint === "fast" || prompt.modelHint === "balanced" || prompt.modelHint === "strong") && !!prompt.metadata && typeof prompt.metadata === "object" && typeof prompt.metadata.author === "string" && typeof prompt.metadata.createdAt === "string" && typeof prompt.metadata.description === "string" && Array.isArray(prompt.metadata.tags) && prompt.metadata.tags.every((entry) => typeof entry === "string");
|
|
25687
|
+
}
|
|
25688
|
+
|
|
25689
|
+
// ../sdk/src/contracts/workflow-runtime.contract.ts
|
|
25690
|
+
var WORKFLOW_RUNTIME_SCHEMA_VERSION = "1.0.0";
|
|
25691
|
+
var WORKFLOW_MUTATION_TIERS = [
|
|
25692
|
+
"read_only",
|
|
25693
|
+
"low_risk_write",
|
|
25694
|
+
"high_risk_write"
|
|
25695
|
+
];
|
|
25696
|
+
var WORKFLOW_APPROVAL_MODES = [
|
|
25697
|
+
"none",
|
|
25698
|
+
"audit_only",
|
|
25699
|
+
"human_required",
|
|
25700
|
+
"auto_approve"
|
|
25701
|
+
];
|
|
25702
|
+
var DEFAULT_TIER_APPROVAL_MODE = {
|
|
25703
|
+
read_only: "none",
|
|
25704
|
+
low_risk_write: "audit_only",
|
|
25705
|
+
high_risk_write: "human_required"
|
|
25706
|
+
};
|
|
25707
|
+
var WORKFLOW_ACTION_KINDS = [
|
|
25708
|
+
"context_pack",
|
|
25709
|
+
"integrity_check",
|
|
25710
|
+
"lucern_tool",
|
|
25711
|
+
"report_compile",
|
|
25712
|
+
"brief_publish",
|
|
25713
|
+
"notification",
|
|
25714
|
+
"custom"
|
|
25715
|
+
];
|
|
25716
|
+
var WORKFLOW_HOOK_EVENTS = [
|
|
25717
|
+
"schedule.tick",
|
|
25718
|
+
"worktree.activated",
|
|
25719
|
+
"worktree.completed",
|
|
25720
|
+
"question.created",
|
|
25721
|
+
"question.answered",
|
|
25722
|
+
"evidence.appended",
|
|
25723
|
+
"inbox.item_created"
|
|
25724
|
+
];
|
|
25725
|
+
var WORKFLOW_OUTPUT_KINDS = [
|
|
25726
|
+
"engineering_brief",
|
|
25727
|
+
"research_memo",
|
|
25728
|
+
"strategy_artifact",
|
|
25729
|
+
"inbox_summary",
|
|
25730
|
+
"pipeline_brief",
|
|
25731
|
+
"structured_payload"
|
|
25732
|
+
];
|
|
25733
|
+
var WORKFLOW_RUN_STATUSES = [
|
|
25734
|
+
"queued",
|
|
25735
|
+
"running",
|
|
25736
|
+
"awaiting_approval",
|
|
25737
|
+
"completed",
|
|
25738
|
+
"failed",
|
|
25739
|
+
"cancelled"
|
|
25740
|
+
];
|
|
25741
|
+
var WORKFLOW_TRIGGER_KINDS = [
|
|
25742
|
+
"manual",
|
|
25743
|
+
"schedule",
|
|
25744
|
+
"hook"
|
|
25745
|
+
];
|
|
25746
|
+
var WORKFLOW_PROOF_ARTIFACT_KINDS = [
|
|
25747
|
+
"report",
|
|
25748
|
+
"brief",
|
|
25749
|
+
"artifact",
|
|
25750
|
+
"dashboard",
|
|
25751
|
+
"test_evidence"
|
|
25752
|
+
];
|
|
25753
|
+
var WORKFLOW_STAFFING_HINTS = [
|
|
25754
|
+
"solo",
|
|
25755
|
+
"backend+tests",
|
|
25756
|
+
"fullstack",
|
|
25757
|
+
"mcp+tests"
|
|
25758
|
+
];
|
|
25759
|
+
var WORKFLOW_AUTO_FIX_MODES = [
|
|
25760
|
+
"disabled",
|
|
25761
|
+
"dry_run",
|
|
25762
|
+
"safe",
|
|
25763
|
+
"aggressive"
|
|
25764
|
+
];
|
|
25765
|
+
var WORKFLOW_INTEGRITY_CHECKS = [
|
|
25766
|
+
"null_dependency_refs",
|
|
25767
|
+
"superseded_blockers",
|
|
25768
|
+
"band_order_inconsistency",
|
|
25769
|
+
"sparse_shaping",
|
|
25770
|
+
"failed_completed_gate"
|
|
25771
|
+
];
|
|
25772
|
+
var DEFAULT_WORKFLOW_AUTO_FIX_POLICY = {
|
|
25773
|
+
mode: "disabled",
|
|
25774
|
+
permittedMutationTiers: ["read_only"],
|
|
25775
|
+
requireAuditTrail: true
|
|
25776
|
+
};
|
|
25777
|
+
var NIGHTLY_RECONCILIATION_WORKFLOW_ID = "workflow.pipeline_reconciliation.v1";
|
|
25778
|
+
var MORNING_BRIEF_WORKFLOW_ID = "workflow.morning_brief.v1";
|
|
25779
|
+
var CANONICAL_WORKFLOW_DEFINITIONS = [
|
|
25780
|
+
{
|
|
25781
|
+
workflowId: NIGHTLY_RECONCILIATION_WORKFLOW_ID,
|
|
25782
|
+
version: WORKFLOW_RUNTIME_SCHEMA_VERSION,
|
|
25783
|
+
title: "Nightly Pipeline Reconciliation",
|
|
25784
|
+
description: "Runs deterministic integrity checks, compiles pipeline state, and emits an operator-facing reconciliation brief.",
|
|
25785
|
+
trigger: {
|
|
25786
|
+
kind: "schedule",
|
|
25787
|
+
cadence: "daily",
|
|
25788
|
+
timezone: "America/New_York"
|
|
25789
|
+
},
|
|
25790
|
+
staffingHint: "backend+tests",
|
|
25791
|
+
proofArtifacts: [
|
|
25792
|
+
{
|
|
25793
|
+
kind: "report",
|
|
25794
|
+
label: "Pipeline reconciliation report",
|
|
25795
|
+
required: true
|
|
25796
|
+
},
|
|
25797
|
+
{
|
|
25798
|
+
kind: "test_evidence",
|
|
25799
|
+
label: "Integrity check receipt",
|
|
25800
|
+
required: true
|
|
25801
|
+
}
|
|
25802
|
+
],
|
|
25803
|
+
autoFixPolicy: {
|
|
25804
|
+
mode: "safe",
|
|
25805
|
+
maxActionsPerRun: 5,
|
|
25806
|
+
permittedMutationTiers: ["read_only", "low_risk_write"],
|
|
25807
|
+
requireAuditTrail: true,
|
|
25808
|
+
escalationGate: "gate:workflow-runtime-contract-live"
|
|
25809
|
+
},
|
|
25810
|
+
actions: [
|
|
25811
|
+
{
|
|
25812
|
+
actionId: "compile_context_pack",
|
|
25813
|
+
kind: "context_pack",
|
|
25814
|
+
title: "Compile pipeline context",
|
|
25815
|
+
description: "Build the ranked context needed for deterministic checks.",
|
|
25816
|
+
mutationTier: "read_only",
|
|
25817
|
+
produces: ["structured_payload"],
|
|
25818
|
+
idempotent: true,
|
|
25819
|
+
approval: { mode: "none" }
|
|
25820
|
+
},
|
|
25821
|
+
{
|
|
25822
|
+
actionId: "run_integrity_checks",
|
|
25823
|
+
kind: "integrity_check",
|
|
25824
|
+
title: "Run integrity checks",
|
|
25825
|
+
description: "Evaluate dependency references, blockers, campaign/lane placement, shaping coverage, and completed gates.",
|
|
25826
|
+
mutationTier: "read_only",
|
|
25827
|
+
produces: ["structured_payload"],
|
|
25828
|
+
idempotent: true,
|
|
25829
|
+
approval: { mode: "none" }
|
|
25830
|
+
},
|
|
25831
|
+
{
|
|
25832
|
+
actionId: "record_followup_questions",
|
|
25833
|
+
kind: "lucern_tool",
|
|
25834
|
+
title: "Record follow-up questions",
|
|
25835
|
+
description: "Create or reopen operator-facing questions for integrity failures that require human review.",
|
|
25836
|
+
mutationTier: "low_risk_write",
|
|
25837
|
+
toolName: "create_question",
|
|
25838
|
+
produces: ["pipeline_brief"],
|
|
25839
|
+
approval: { mode: "audit_only", rationaleRequired: true }
|
|
25840
|
+
},
|
|
25841
|
+
{
|
|
25842
|
+
actionId: "publish_reconciliation_brief",
|
|
25843
|
+
kind: "brief_publish",
|
|
25844
|
+
title: "Publish reconciliation brief",
|
|
25845
|
+
description: "Emit an inbox-routed brief summarizing the nightly pipeline state and grouped blockers.",
|
|
25846
|
+
mutationTier: "low_risk_write",
|
|
25847
|
+
produces: ["pipeline_brief", "inbox_summary"],
|
|
25848
|
+
approval: { mode: "audit_only" }
|
|
25849
|
+
}
|
|
25850
|
+
],
|
|
25851
|
+
hooks: [
|
|
25852
|
+
{
|
|
25853
|
+
hookId: "nightly-schedule",
|
|
25854
|
+
event: "schedule.tick",
|
|
25855
|
+
description: "Run once per nightly cadence.",
|
|
25856
|
+
actionIds: [
|
|
25857
|
+
"compile_context_pack",
|
|
25858
|
+
"run_integrity_checks",
|
|
25859
|
+
"record_followup_questions",
|
|
25860
|
+
"publish_reconciliation_brief"
|
|
25861
|
+
]
|
|
25862
|
+
}
|
|
25863
|
+
],
|
|
25864
|
+
outputs: ["pipeline_brief", "inbox_summary", "structured_payload"],
|
|
25865
|
+
integrityChecks: WORKFLOW_INTEGRITY_CHECKS
|
|
25866
|
+
},
|
|
25867
|
+
{
|
|
25868
|
+
workflowId: MORNING_BRIEF_WORKFLOW_ID,
|
|
25869
|
+
version: WORKFLOW_RUNTIME_SCHEMA_VERSION,
|
|
25870
|
+
title: "Morning Brief",
|
|
25871
|
+
description: "Compiles a developer-facing morning brief from graph state, overnight workflow outputs, and inbox routing preferences.",
|
|
25872
|
+
trigger: {
|
|
25873
|
+
kind: "schedule",
|
|
25874
|
+
cadence: "daily",
|
|
25875
|
+
timezone: "America/New_York"
|
|
25876
|
+
},
|
|
25877
|
+
staffingHint: "solo",
|
|
25878
|
+
proofArtifacts: [
|
|
25879
|
+
{
|
|
25880
|
+
kind: "brief",
|
|
25881
|
+
label: "Morning brief",
|
|
25882
|
+
required: true
|
|
25883
|
+
}
|
|
25884
|
+
],
|
|
25885
|
+
autoFixPolicy: {
|
|
25886
|
+
mode: "dry_run",
|
|
25887
|
+
maxActionsPerRun: 1,
|
|
25888
|
+
permittedMutationTiers: ["read_only", "low_risk_write"],
|
|
25889
|
+
requireAuditTrail: true
|
|
25890
|
+
},
|
|
25891
|
+
actions: [
|
|
25892
|
+
{
|
|
25893
|
+
actionId: "compile_brief_inputs",
|
|
25894
|
+
kind: "context_pack",
|
|
25895
|
+
title: "Compile brief inputs",
|
|
25896
|
+
description: "Read graph state, worktree state, and overnight workflow receipts.",
|
|
25897
|
+
mutationTier: "read_only",
|
|
25898
|
+
produces: ["structured_payload"],
|
|
25899
|
+
idempotent: true,
|
|
25900
|
+
approval: { mode: "none" }
|
|
25901
|
+
},
|
|
25902
|
+
{
|
|
25903
|
+
actionId: "publish_morning_brief",
|
|
25904
|
+
kind: "brief_publish",
|
|
25905
|
+
title: "Publish morning brief",
|
|
25906
|
+
description: "Publish a typed inbox summary with prioritized worktree and question context.",
|
|
25907
|
+
mutationTier: "low_risk_write",
|
|
25908
|
+
produces: ["engineering_brief", "inbox_summary"],
|
|
25909
|
+
approval: { mode: "audit_only" }
|
|
25910
|
+
}
|
|
25911
|
+
],
|
|
25912
|
+
hooks: [
|
|
25913
|
+
{
|
|
25914
|
+
hookId: "morning-schedule",
|
|
25915
|
+
event: "schedule.tick",
|
|
25916
|
+
description: "Run once per morning cadence.",
|
|
25917
|
+
actionIds: ["compile_brief_inputs", "publish_morning_brief"]
|
|
25918
|
+
},
|
|
25919
|
+
{
|
|
25920
|
+
hookId: "worktree-complete-refresh",
|
|
25921
|
+
event: "worktree.completed",
|
|
25922
|
+
description: "Refresh the queued morning brief inputs when worktree outcomes land overnight.",
|
|
25923
|
+
actionIds: ["compile_brief_inputs"]
|
|
25924
|
+
}
|
|
25925
|
+
],
|
|
25926
|
+
outputs: ["engineering_brief", "inbox_summary", "structured_payload"],
|
|
25927
|
+
integrityChecks: ["sparse_shaping"]
|
|
25928
|
+
}
|
|
25929
|
+
];
|
|
25930
|
+
|
|
25931
|
+
// ../sdk/src/events.ts
|
|
25932
|
+
var DOMAIN_EVENT_VERSION = "1.0";
|
|
25933
|
+
var EVENT_RETENTION_DEFAULT_DAYS = 30;
|
|
25934
|
+
var WEBHOOK_MAX_ATTEMPTS = 5;
|
|
25935
|
+
var WEBHOOK_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 3e5];
|
|
25936
|
+
var DOMAIN_EVENT_TYPES = [
|
|
25937
|
+
"belief.created",
|
|
25938
|
+
"belief.forked",
|
|
25939
|
+
"belief.confidence_updated",
|
|
25940
|
+
"belief.archived",
|
|
25941
|
+
"belief.refined",
|
|
25942
|
+
"belief.contract_created",
|
|
25943
|
+
"belief.contract_evaluated",
|
|
25944
|
+
"belief.lineage_queried",
|
|
25945
|
+
"evidence.created",
|
|
25946
|
+
"evidence.linked",
|
|
25947
|
+
"evidence.search_executed",
|
|
25948
|
+
"question.created",
|
|
25949
|
+
"question.answered",
|
|
25950
|
+
"question.refined",
|
|
25951
|
+
"question.status_updated",
|
|
25952
|
+
"question.archived",
|
|
25953
|
+
"edge.created",
|
|
25954
|
+
"contradiction.flagged",
|
|
25955
|
+
"worktree.created",
|
|
25956
|
+
"worktree.activated",
|
|
25957
|
+
"worktree.merged",
|
|
25958
|
+
"worktree.targets_updated",
|
|
25959
|
+
"worktree.metadata_updated",
|
|
25960
|
+
"topic.created",
|
|
25961
|
+
"topic.updated",
|
|
25962
|
+
"topic.archived",
|
|
25963
|
+
"task.created",
|
|
25964
|
+
"task.completed",
|
|
25965
|
+
"task.updated",
|
|
25966
|
+
"ontology.bound",
|
|
25967
|
+
"context.compiled",
|
|
25968
|
+
"identity.key_created",
|
|
25969
|
+
"identity.key_rotated",
|
|
25970
|
+
"identity.key_revoked",
|
|
25971
|
+
"webhook.test"
|
|
25972
|
+
];
|
|
25973
|
+
var RUNTIME_BUFFER2 = globalThis.Buffer;
|
|
25974
|
+
var RUNTIME_ENV = globalThis.process?.env;
|
|
25975
|
+
function escapeRegex(value) {
|
|
25976
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25977
|
+
}
|
|
25978
|
+
function eventPatternToRegExp(pattern) {
|
|
25979
|
+
const normalized = pattern.trim();
|
|
25980
|
+
if (!normalized) {
|
|
25981
|
+
return /^$/;
|
|
25982
|
+
}
|
|
25983
|
+
if (normalized === "*") {
|
|
25984
|
+
return /^.*$/;
|
|
25985
|
+
}
|
|
25986
|
+
const source = escapeRegex(normalized).replace(/\\\*/g, ".*");
|
|
25987
|
+
return new RegExp(`^${source}$`);
|
|
25988
|
+
}
|
|
25989
|
+
function matchesEventPattern(eventType, pattern) {
|
|
25990
|
+
return eventPatternToRegExp(pattern).test(eventType.trim());
|
|
25991
|
+
}
|
|
25992
|
+
function matchesAnyEventPattern(eventType, patterns) {
|
|
25993
|
+
if (patterns.length === 0) {
|
|
25994
|
+
return true;
|
|
25995
|
+
}
|
|
25996
|
+
return patterns.some((pattern) => matchesEventPattern(eventType, pattern));
|
|
25997
|
+
}
|
|
25998
|
+
function toBase64(value) {
|
|
25999
|
+
if (RUNTIME_BUFFER2) {
|
|
26000
|
+
return RUNTIME_BUFFER2.from(value, "utf8").toString("base64url");
|
|
26001
|
+
}
|
|
26002
|
+
return btoa(unescape(encodeURIComponent(value))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
26003
|
+
}
|
|
26004
|
+
function fromBase64(value) {
|
|
26005
|
+
if (RUNTIME_BUFFER2) {
|
|
26006
|
+
return RUNTIME_BUFFER2.from(value, "base64url").toString("utf8");
|
|
26007
|
+
}
|
|
26008
|
+
const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
26009
|
+
return decodeURIComponent(escape(atob(normalized)));
|
|
26010
|
+
}
|
|
26011
|
+
function createEventId() {
|
|
26012
|
+
const random = typeof globalThis.crypto?.randomUUID === "function" ? globalThis.crypto.randomUUID().replace(/-/g, "") : Array.from(
|
|
26013
|
+
typeof globalThis.crypto?.getRandomValues === "function" ? globalThis.crypto.getRandomValues(new Uint8Array(16)) : Array.from({ length: 16 }, () => Math.floor(Math.random() * 256)),
|
|
26014
|
+
(value) => value.toString(16).padStart(2, "0")
|
|
26015
|
+
).join("");
|
|
26016
|
+
return `evt_${random}`;
|
|
26017
|
+
}
|
|
26018
|
+
function normalizeRetentionDays(value) {
|
|
26019
|
+
if (!Number.isFinite(value) || typeof value !== "number" || value <= 0) {
|
|
26020
|
+
return EVENT_RETENTION_DEFAULT_DAYS;
|
|
26021
|
+
}
|
|
26022
|
+
return Math.max(1, Math.trunc(value));
|
|
26023
|
+
}
|
|
26024
|
+
function buildDomainEvent(input) {
|
|
26025
|
+
const timestamp = input.timestamp ?? Date.now();
|
|
26026
|
+
const retentionDays = normalizeRetentionDays(input.retentionDays);
|
|
26027
|
+
return {
|
|
26028
|
+
eventId: input.eventId?.trim() || createEventId(),
|
|
26029
|
+
type: input.type.trim(),
|
|
26030
|
+
version: DOMAIN_EVENT_VERSION,
|
|
26031
|
+
timestamp,
|
|
26032
|
+
tenantId: input.tenantId?.trim() || void 0,
|
|
26033
|
+
workspaceId: input.workspaceId?.trim() || void 0,
|
|
26034
|
+
topicId: input.topicId.trim(),
|
|
26035
|
+
resourceId: input.resourceId.trim(),
|
|
26036
|
+
resourceType: input.resourceType.trim(),
|
|
26037
|
+
actorId: input.actorId.trim(),
|
|
26038
|
+
actorType: input.actorType,
|
|
26039
|
+
data: input.data ?? {},
|
|
26040
|
+
correlationId: input.correlationId?.trim() || void 0,
|
|
26041
|
+
expiresAt: timestamp + retentionDays * 24 * 60 * 60 * 1e3
|
|
26042
|
+
};
|
|
26043
|
+
}
|
|
26044
|
+
function compareEventCursor(left, right) {
|
|
26045
|
+
if (left.timestamp !== right.timestamp) {
|
|
26046
|
+
return left.timestamp - right.timestamp;
|
|
26047
|
+
}
|
|
26048
|
+
return left.eventId.localeCompare(right.eventId);
|
|
26049
|
+
}
|
|
26050
|
+
function encodeEventCursor(cursor) {
|
|
26051
|
+
return toBase64(JSON.stringify(cursor));
|
|
26052
|
+
}
|
|
26053
|
+
function decodeEventCursor(cursor) {
|
|
26054
|
+
if (!cursor || cursor.trim().length === 0) {
|
|
26055
|
+
return null;
|
|
26056
|
+
}
|
|
26057
|
+
try {
|
|
26058
|
+
const parsed = JSON.parse(fromBase64(cursor.trim()));
|
|
26059
|
+
if (typeof parsed.timestamp !== "number" || !Number.isFinite(parsed.timestamp) || typeof parsed.eventId !== "string" || parsed.eventId.trim().length === 0) {
|
|
26060
|
+
return null;
|
|
26061
|
+
}
|
|
26062
|
+
return {
|
|
26063
|
+
timestamp: parsed.timestamp,
|
|
26064
|
+
eventId: parsed.eventId.trim()
|
|
26065
|
+
};
|
|
26066
|
+
} catch {
|
|
26067
|
+
return null;
|
|
26068
|
+
}
|
|
26069
|
+
}
|
|
26070
|
+
function isAfterCursor(event, cursor) {
|
|
26071
|
+
if (!cursor) {
|
|
26072
|
+
return true;
|
|
26073
|
+
}
|
|
26074
|
+
return compareEventCursor(event, cursor) > 0;
|
|
26075
|
+
}
|
|
26076
|
+
function sortEventsByCursor(events) {
|
|
26077
|
+
return [...events].sort((left, right) => compareEventCursor(left, right));
|
|
26078
|
+
}
|
|
26079
|
+
function inferActorType(args) {
|
|
26080
|
+
if (args.sessionType === "agent") {
|
|
26081
|
+
return "agent";
|
|
26082
|
+
}
|
|
26083
|
+
if (args.authMode === "service_principal" || args.authMode === "tenant_api_key" || args.principalType === "service") {
|
|
26084
|
+
return "service";
|
|
26085
|
+
}
|
|
26086
|
+
return "human";
|
|
26087
|
+
}
|
|
26088
|
+
async function emitDomainEvent(invokeMutation, input) {
|
|
26089
|
+
return await invokeMutation("events:recordEvent", input);
|
|
26090
|
+
}
|
|
26091
|
+
var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
|
|
26092
|
+
function normalizeUrl(url) {
|
|
26093
|
+
try {
|
|
26094
|
+
return new URL(url.trim());
|
|
26095
|
+
} catch {
|
|
26096
|
+
throw new Error("Webhook URL must be a valid absolute URL.");
|
|
26097
|
+
}
|
|
26098
|
+
}
|
|
26099
|
+
function assertValidWebhookUrl(url) {
|
|
26100
|
+
const parsed = normalizeUrl(url);
|
|
26101
|
+
const hostname = parsed.hostname.trim().toLowerCase();
|
|
26102
|
+
const nodeEnv = RUNTIME_ENV?.NODE_ENV;
|
|
26103
|
+
const allowLocalHttp = nodeEnv === "test" || LOCALHOST_HOSTS.has(hostname);
|
|
26104
|
+
if (parsed.protocol !== "https:" && !(allowLocalHttp && parsed.protocol === "http:")) {
|
|
26105
|
+
throw new Error("Webhook URL must use HTTPS.");
|
|
26106
|
+
}
|
|
26107
|
+
return parsed.toString();
|
|
26108
|
+
}
|
|
26109
|
+
function normalizeWebhookPatterns(patterns) {
|
|
26110
|
+
const normalized = Array.from(
|
|
26111
|
+
new Set(
|
|
26112
|
+
patterns.map((pattern) => pattern.trim()).filter((pattern) => pattern.length > 0)
|
|
26113
|
+
)
|
|
26114
|
+
);
|
|
26115
|
+
if (normalized.length === 0) {
|
|
26116
|
+
throw new Error("At least one webhook event pattern is required.");
|
|
26117
|
+
}
|
|
26118
|
+
return normalized;
|
|
26119
|
+
}
|
|
26120
|
+
function assertValidWebhookSecret(secret) {
|
|
26121
|
+
const normalized = secret.trim();
|
|
26122
|
+
if (normalized.length < 8) {
|
|
26123
|
+
throw new Error("Webhook secret must be at least 8 characters.");
|
|
26124
|
+
}
|
|
26125
|
+
return normalized;
|
|
26126
|
+
}
|
|
26127
|
+
async function computeWebhookSignature(payload, secret) {
|
|
26128
|
+
const encoder = new TextEncoder();
|
|
26129
|
+
const key = await crypto.subtle.importKey(
|
|
26130
|
+
"raw",
|
|
26131
|
+
encoder.encode(secret),
|
|
26132
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
26133
|
+
false,
|
|
26134
|
+
["sign"]
|
|
26135
|
+
);
|
|
26136
|
+
const signature = await crypto.subtle.sign("HMAC", key, encoder.encode(payload));
|
|
26137
|
+
return Array.from(new Uint8Array(signature)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
26138
|
+
}
|
|
26139
|
+
function nextDeliveryAttemptAt(currentAttemptCount, now = Date.now()) {
|
|
26140
|
+
if (currentAttemptCount >= WEBHOOK_MAX_ATTEMPTS) {
|
|
26141
|
+
return void 0;
|
|
26142
|
+
}
|
|
26143
|
+
const retryIndex = currentAttemptCount - 1;
|
|
26144
|
+
const delay2 = WEBHOOK_RETRY_DELAYS_MS[retryIndex];
|
|
26145
|
+
return typeof delay2 === "number" ? now + delay2 : void 0;
|
|
26146
|
+
}
|
|
26147
|
+
function resolveDeliveryFailureStatus(attemptCount) {
|
|
26148
|
+
return attemptCount >= WEBHOOK_MAX_ATTEMPTS ? "dead_letter" : "failed";
|
|
26149
|
+
}
|
|
26150
|
+
function sanitizeWebhookRecord(value) {
|
|
26151
|
+
return {
|
|
26152
|
+
id: String(value.id ?? value.webhookId ?? value._id ?? ""),
|
|
26153
|
+
webhookId: String(value.webhookId ?? value.id ?? value._id ?? ""),
|
|
26154
|
+
tenantId: typeof value.tenantId === "string" && value.tenantId.trim().length > 0 ? value.tenantId : void 0,
|
|
26155
|
+
workspaceId: typeof value.workspaceId === "string" && value.workspaceId.trim().length > 0 ? value.workspaceId : void 0,
|
|
26156
|
+
topicId: typeof value.topicId === "string" && value.topicId.trim().length > 0 ? value.topicId : void 0,
|
|
26157
|
+
url: String(value.url ?? ""),
|
|
26158
|
+
events: Array.isArray(value.events) ? value.events.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean) : [],
|
|
26159
|
+
active: value.active !== false,
|
|
26160
|
+
secretConfigured: true,
|
|
26161
|
+
createdAt: Number(value.createdAt ?? Date.now()),
|
|
26162
|
+
updatedAt: Number(value.updatedAt ?? value.createdAt ?? Date.now()),
|
|
26163
|
+
createdBy: String(value.createdBy ?? ""),
|
|
26164
|
+
updatedBy: String(value.updatedBy ?? value.createdBy ?? ""),
|
|
26165
|
+
lastDeliveryAt: typeof value.lastDeliveryAt === "number" ? value.lastDeliveryAt : void 0,
|
|
26166
|
+
lastSuccessfulDeliveryAt: typeof value.lastSuccessfulDeliveryAt === "number" ? value.lastSuccessfulDeliveryAt : void 0
|
|
26167
|
+
};
|
|
26168
|
+
}
|
|
26169
|
+
function truncateWebhookResponseBody(responseBody, maxLength = 2e3) {
|
|
26170
|
+
if (!responseBody) {
|
|
26171
|
+
return void 0;
|
|
26172
|
+
}
|
|
26173
|
+
if (responseBody.length <= maxLength) {
|
|
26174
|
+
return responseBody;
|
|
26175
|
+
}
|
|
26176
|
+
return `${responseBody.slice(0, maxLength - 3)}...`;
|
|
26177
|
+
}
|
|
26178
|
+
|
|
26179
|
+
// ../sdk/src/eventsCore.ts
|
|
26180
|
+
function serializeTypes2(types) {
|
|
26181
|
+
return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
|
|
26182
|
+
}
|
|
26183
|
+
function createEventsClientCore(config = {}) {
|
|
26184
|
+
const gateway = createGatewayRequestClient(config);
|
|
26185
|
+
return {
|
|
26186
|
+
async list(query5 = {}) {
|
|
26187
|
+
return gateway.request({
|
|
26188
|
+
path: `/v1/events${toQueryString({
|
|
26189
|
+
topicId: query5.topicId,
|
|
26190
|
+
after: query5.after,
|
|
26191
|
+
types: serializeTypes2(query5.types),
|
|
26192
|
+
startTime: query5.startTime,
|
|
26193
|
+
endTime: query5.endTime,
|
|
26194
|
+
limit: query5.limit
|
|
26195
|
+
})}`
|
|
26196
|
+
});
|
|
26197
|
+
},
|
|
26198
|
+
async replay(input, idempotencyKey = randomIdempotencyKey()) {
|
|
26199
|
+
return gateway.request({
|
|
26200
|
+
path: "/v1/events/replay",
|
|
26201
|
+
method: "POST",
|
|
26202
|
+
body: input,
|
|
26203
|
+
idempotencyKey
|
|
26204
|
+
});
|
|
26205
|
+
}
|
|
26206
|
+
};
|
|
26207
|
+
}
|
|
26208
|
+
function createWebhooksClientCore(config = {}) {
|
|
26209
|
+
const gateway = createGatewayRequestClient(config);
|
|
26210
|
+
return {
|
|
26211
|
+
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
26212
|
+
return gateway.request({
|
|
26213
|
+
path: "/v1/webhooks",
|
|
26214
|
+
method: "POST",
|
|
26215
|
+
body: input,
|
|
26216
|
+
idempotencyKey
|
|
26217
|
+
});
|
|
26218
|
+
},
|
|
26219
|
+
async list(query5 = {}) {
|
|
26220
|
+
return gateway.request({
|
|
26221
|
+
path: `/v1/webhooks${toQueryString({
|
|
26222
|
+
topicId: query5.topicId
|
|
26223
|
+
})}`
|
|
26224
|
+
});
|
|
26225
|
+
},
|
|
26226
|
+
async get(id) {
|
|
26227
|
+
return gateway.request({
|
|
26228
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}`
|
|
26229
|
+
});
|
|
26230
|
+
},
|
|
26231
|
+
async update(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
26232
|
+
return gateway.request({
|
|
26233
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}`,
|
|
26234
|
+
method: "PATCH",
|
|
26235
|
+
body: input,
|
|
26236
|
+
idempotencyKey
|
|
26237
|
+
});
|
|
26238
|
+
},
|
|
26239
|
+
async delete(id, idempotencyKey = randomIdempotencyKey()) {
|
|
26240
|
+
return gateway.request({
|
|
26241
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}`,
|
|
26242
|
+
method: "DELETE",
|
|
26243
|
+
idempotencyKey
|
|
26244
|
+
});
|
|
26245
|
+
},
|
|
26246
|
+
async test(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
|
|
26247
|
+
return gateway.request({
|
|
26248
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}/test`,
|
|
26249
|
+
method: "POST",
|
|
26250
|
+
body: input,
|
|
26251
|
+
idempotencyKey
|
|
26252
|
+
});
|
|
26253
|
+
},
|
|
26254
|
+
async deliveries(id, query5 = {}) {
|
|
26255
|
+
return gateway.request({
|
|
26256
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
|
|
26257
|
+
limit: query5.limit
|
|
26258
|
+
})}`
|
|
26259
|
+
});
|
|
26260
|
+
},
|
|
26261
|
+
async health(id) {
|
|
26262
|
+
return gateway.request({
|
|
26263
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}/health`
|
|
26264
|
+
});
|
|
26265
|
+
}
|
|
26266
|
+
};
|
|
26267
|
+
}
|
|
26268
|
+
|
|
26269
|
+
// ../sdk/src/graphIntel.ts
|
|
26270
|
+
var graphIntel_exports = {};
|
|
26271
|
+
__reExport(graphIntel_exports, graphIntel_star);
|
|
26272
|
+
|
|
26273
|
+
// ../sdk/src/index.ts
|
|
26274
|
+
__reExport(src_exports, graphIntel_exports);
|
|
26275
|
+
|
|
26276
|
+
// ../sdk/src/graphIntelligence.ts
|
|
26277
|
+
var graphIntelligence_exports = {};
|
|
26278
|
+
__export(graphIntelligence_exports, {
|
|
26279
|
+
GRAPH_INTELLIGENCE_MODE_TOOL_NAMES: () => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES,
|
|
26280
|
+
GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES: () => GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES,
|
|
26281
|
+
GRAPH_INTELLIGENCE_QUERIES: () => GRAPH_INTELLIGENCE_QUERIES,
|
|
26282
|
+
GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS: () => GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS,
|
|
26283
|
+
GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION: () => GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION,
|
|
26284
|
+
GRAPH_INTELLIGENCE_QUERY_CATEGORIES: () => GRAPH_INTELLIGENCE_QUERY_CATEGORIES,
|
|
26285
|
+
GRAPH_INTELLIGENCE_QUERY_MODES: () => GRAPH_INTELLIGENCE_QUERY_MODES,
|
|
26286
|
+
GRAPH_INTELLIGENCE_QUICK_QUERIES: () => GRAPH_INTELLIGENCE_QUICK_QUERIES,
|
|
26287
|
+
fillGraphIntelligencePromptTemplate: () => fillGraphIntelligencePromptTemplate,
|
|
26288
|
+
getGraphIntelligenceQuery: () => getGraphIntelligenceQuery,
|
|
26289
|
+
isGraphIntelligenceQueryMode: () => isGraphIntelligenceQueryMode,
|
|
26290
|
+
listGraphIntelligenceQueries: () => listGraphIntelligenceQueries
|
|
26291
|
+
});
|
|
26292
|
+
__reExport(graphIntelligence_exports, graphIntel_exports);
|
|
26293
|
+
|
|
26294
|
+
// ../sdk/src/index.ts
|
|
26295
|
+
__reExport(src_exports, graphIntelligence_exports);
|
|
26296
|
+
|
|
26297
|
+
// src/types.ts
|
|
26298
|
+
var McpHandlerError = class extends Error {
|
|
26299
|
+
code;
|
|
26300
|
+
status;
|
|
26301
|
+
suggestion;
|
|
26302
|
+
constructor(message, code = "INVALID_REQUEST", status = 400, suggestion) {
|
|
26303
|
+
super(message);
|
|
26304
|
+
this.name = "McpHandlerError";
|
|
26305
|
+
this.code = code;
|
|
26306
|
+
this.status = status;
|
|
26307
|
+
this.suggestion = suggestion;
|
|
26308
|
+
}
|
|
26309
|
+
};
|
|
26310
|
+
|
|
26311
|
+
// src/handler-factory.ts
|
|
26312
|
+
function isMissing(value) {
|
|
26313
|
+
if (value === void 0 || value === null) {
|
|
26314
|
+
return true;
|
|
26315
|
+
}
|
|
26316
|
+
if (typeof value === "string") {
|
|
26317
|
+
return value.trim().length === 0;
|
|
26318
|
+
}
|
|
26319
|
+
if (Array.isArray(value)) {
|
|
26320
|
+
return value.length === 0;
|
|
26321
|
+
}
|
|
26322
|
+
return false;
|
|
22786
26323
|
}
|
|
22787
26324
|
function readString3(params, key, options = {}) {
|
|
22788
26325
|
const value = params[key];
|
|
@@ -24418,9 +27955,9 @@ var MCP_RATE_LIMIT_SIGNALS = [
|
|
|
24418
27955
|
"RATE_LIMIT_EXCEEDED",
|
|
24419
27956
|
"Retry-After"
|
|
24420
27957
|
];
|
|
24421
|
-
var
|
|
27958
|
+
var OPERATION_MANIFEST2 = LUCERN_OPERATION_MANIFEST;
|
|
24422
27959
|
function mcpExposureFor(toolName) {
|
|
24423
|
-
return
|
|
27960
|
+
return OPERATION_MANIFEST2[toolName]?.surfaces.mcp ?? "none";
|
|
24424
27961
|
}
|
|
24425
27962
|
function withManifestVisibility(toolName, contract) {
|
|
24426
27963
|
return mcpExposureFor(toolName) === "internal" || contract.internal ? { ...contract, internal: true } : contract;
|
|
@@ -25767,7 +29304,7 @@ async function loadDiscoveryHandlers() {
|
|
|
25767
29304
|
}
|
|
25768
29305
|
|
|
25769
29306
|
// src/contextPackSchema.ts
|
|
25770
|
-
var
|
|
29307
|
+
var CONTEXT_PACK_SCHEMA_VERSION3 = "1.0.0";
|
|
25771
29308
|
var CONTEXT_PACK_SECTION_KEYS = [
|
|
25772
29309
|
"invariants",
|
|
25773
29310
|
"activeBeliefs",
|
|
@@ -25775,171 +29312,171 @@ var CONTEXT_PACK_SECTION_KEYS = [
|
|
|
25775
29312
|
"recentEvidence",
|
|
25776
29313
|
"contradictions"
|
|
25777
29314
|
];
|
|
25778
|
-
function
|
|
29315
|
+
function isObject2(value) {
|
|
25779
29316
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25780
29317
|
}
|
|
25781
|
-
function
|
|
29318
|
+
function isString2(value) {
|
|
25782
29319
|
return typeof value === "string";
|
|
25783
29320
|
}
|
|
25784
|
-
function
|
|
29321
|
+
function isNumber2(value) {
|
|
25785
29322
|
return typeof value === "number" && Number.isFinite(value);
|
|
25786
29323
|
}
|
|
25787
|
-
function
|
|
25788
|
-
return value === null ||
|
|
29324
|
+
function isNullableNumber2(value) {
|
|
29325
|
+
return value === null || isNumber2(value);
|
|
25789
29326
|
}
|
|
25790
|
-
function
|
|
25791
|
-
return Array.isArray(value) && value.every((entry) =>
|
|
29327
|
+
function isStringArray2(value) {
|
|
29328
|
+
return Array.isArray(value) && value.every((entry) => isString2(entry));
|
|
25792
29329
|
}
|
|
25793
|
-
function
|
|
29330
|
+
function requireObject2(parent, key, errors) {
|
|
25794
29331
|
const value = parent[key];
|
|
25795
|
-
if (!
|
|
29332
|
+
if (!isObject2(value)) {
|
|
25796
29333
|
errors.push(`Expected '${key}' to be an object`);
|
|
25797
29334
|
return null;
|
|
25798
29335
|
}
|
|
25799
29336
|
return value;
|
|
25800
29337
|
}
|
|
25801
|
-
function
|
|
29338
|
+
function validateBeliefArray2(key, value, errors) {
|
|
25802
29339
|
if (!Array.isArray(value)) {
|
|
25803
29340
|
errors.push(`Expected '${key}' to be an array`);
|
|
25804
29341
|
return;
|
|
25805
29342
|
}
|
|
25806
29343
|
for (let index = 0; index < value.length; index += 1) {
|
|
25807
29344
|
const row = value[index];
|
|
25808
|
-
if (!
|
|
29345
|
+
if (!isObject2(row)) {
|
|
25809
29346
|
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
25810
29347
|
continue;
|
|
25811
29348
|
}
|
|
25812
|
-
if (!
|
|
29349
|
+
if (!isString2(row.nodeId)) {
|
|
25813
29350
|
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
25814
29351
|
}
|
|
25815
|
-
if (!
|
|
29352
|
+
if (!isString2(row.canonicalText)) {
|
|
25816
29353
|
errors.push(`Expected '${key}[${index}].canonicalText' to be a string`);
|
|
25817
29354
|
}
|
|
25818
|
-
if (!
|
|
29355
|
+
if (!isNullableNumber2(row.confidence)) {
|
|
25819
29356
|
errors.push(`Expected '${key}[${index}].confidence' to be number|null`);
|
|
25820
29357
|
}
|
|
25821
29358
|
}
|
|
25822
29359
|
}
|
|
25823
|
-
function
|
|
29360
|
+
function validateQuestionArray2(key, value, errors) {
|
|
25824
29361
|
if (!Array.isArray(value)) {
|
|
25825
29362
|
errors.push(`Expected '${key}' to be an array`);
|
|
25826
29363
|
return;
|
|
25827
29364
|
}
|
|
25828
29365
|
for (let index = 0; index < value.length; index += 1) {
|
|
25829
29366
|
const row = value[index];
|
|
25830
|
-
if (!
|
|
29367
|
+
if (!isObject2(row)) {
|
|
25831
29368
|
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
25832
29369
|
continue;
|
|
25833
29370
|
}
|
|
25834
|
-
if (!
|
|
29371
|
+
if (!isString2(row.questionId)) {
|
|
25835
29372
|
errors.push(`Expected '${key}[${index}].questionId' to be a string`);
|
|
25836
29373
|
}
|
|
25837
|
-
if (!
|
|
29374
|
+
if (!isString2(row.text)) {
|
|
25838
29375
|
errors.push(`Expected '${key}[${index}].text' to be a string`);
|
|
25839
29376
|
}
|
|
25840
|
-
if (!
|
|
29377
|
+
if (!isString2(row.status)) {
|
|
25841
29378
|
errors.push(`Expected '${key}[${index}].status' to be a string`);
|
|
25842
29379
|
}
|
|
25843
29380
|
}
|
|
25844
29381
|
}
|
|
25845
|
-
function
|
|
29382
|
+
function validateEvidenceArray2(key, value, errors) {
|
|
25846
29383
|
if (!Array.isArray(value)) {
|
|
25847
29384
|
errors.push(`Expected '${key}' to be an array`);
|
|
25848
29385
|
return;
|
|
25849
29386
|
}
|
|
25850
29387
|
for (let index = 0; index < value.length; index += 1) {
|
|
25851
29388
|
const row = value[index];
|
|
25852
|
-
if (!
|
|
29389
|
+
if (!isObject2(row)) {
|
|
25853
29390
|
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
25854
29391
|
continue;
|
|
25855
29392
|
}
|
|
25856
|
-
if (!
|
|
29393
|
+
if (!isString2(row.nodeId)) {
|
|
25857
29394
|
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
25858
29395
|
}
|
|
25859
|
-
if (!
|
|
29396
|
+
if (!isString2(row.canonicalText)) {
|
|
25860
29397
|
errors.push(`Expected '${key}[${index}].canonicalText' to be a string`);
|
|
25861
29398
|
}
|
|
25862
29399
|
}
|
|
25863
29400
|
}
|
|
25864
|
-
function
|
|
29401
|
+
function validateEntityArray2(key, value, errors) {
|
|
25865
29402
|
if (!Array.isArray(value)) {
|
|
25866
29403
|
errors.push(`Expected '${key}' to be an array`);
|
|
25867
29404
|
return;
|
|
25868
29405
|
}
|
|
25869
29406
|
for (let index = 0; index < value.length; index += 1) {
|
|
25870
29407
|
const row = value[index];
|
|
25871
|
-
if (!
|
|
29408
|
+
if (!isObject2(row)) {
|
|
25872
29409
|
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
25873
29410
|
continue;
|
|
25874
29411
|
}
|
|
25875
|
-
if (!
|
|
29412
|
+
if (!isString2(row.nodeId)) {
|
|
25876
29413
|
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
25877
29414
|
}
|
|
25878
|
-
if (!
|
|
29415
|
+
if (!isString2(row.entityType)) {
|
|
25879
29416
|
errors.push(`Expected '${key}[${index}].entityType' to be a string`);
|
|
25880
29417
|
}
|
|
25881
|
-
if (!
|
|
29418
|
+
if (!isString2(row.title)) {
|
|
25882
29419
|
errors.push(`Expected '${key}[${index}].title' to be a string`);
|
|
25883
29420
|
}
|
|
25884
|
-
if (!
|
|
29421
|
+
if (!isNumber2(row.connectedBeliefCount)) {
|
|
25885
29422
|
errors.push(
|
|
25886
29423
|
`Expected '${key}[${index}].connectedBeliefCount' to be a number`
|
|
25887
29424
|
);
|
|
25888
29425
|
}
|
|
25889
|
-
if (!
|
|
29426
|
+
if (!isNumber2(row.connectedEvidenceCount)) {
|
|
25890
29427
|
errors.push(
|
|
25891
29428
|
`Expected '${key}[${index}].connectedEvidenceCount' to be a number`
|
|
25892
29429
|
);
|
|
25893
29430
|
}
|
|
25894
|
-
if (!
|
|
29431
|
+
if (!isNumber2(row.score)) {
|
|
25895
29432
|
errors.push(`Expected '${key}[${index}].score' to be a number`);
|
|
25896
29433
|
}
|
|
25897
29434
|
}
|
|
25898
29435
|
}
|
|
25899
|
-
function
|
|
29436
|
+
function validateContradictionArray2(key, value, errors) {
|
|
25900
29437
|
if (!Array.isArray(value)) {
|
|
25901
29438
|
errors.push(`Expected '${key}' to be an array`);
|
|
25902
29439
|
return;
|
|
25903
29440
|
}
|
|
25904
29441
|
for (let index = 0; index < value.length; index += 1) {
|
|
25905
29442
|
const row = value[index];
|
|
25906
|
-
if (!
|
|
29443
|
+
if (!isObject2(row)) {
|
|
25907
29444
|
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
25908
29445
|
continue;
|
|
25909
29446
|
}
|
|
25910
|
-
if (!
|
|
29447
|
+
if (!isString2(row.contradictionId)) {
|
|
25911
29448
|
errors.push(`Expected '${key}[${index}].contradictionId' to be a string`);
|
|
25912
29449
|
}
|
|
25913
|
-
if (!
|
|
29450
|
+
if (!isString2(row.status)) {
|
|
25914
29451
|
errors.push(`Expected '${key}[${index}].status' to be a string`);
|
|
25915
29452
|
}
|
|
25916
29453
|
}
|
|
25917
29454
|
}
|
|
25918
29455
|
function validateContextPackSchema2(payload) {
|
|
25919
29456
|
const errors = [];
|
|
25920
|
-
if (!
|
|
29457
|
+
if (!isObject2(payload)) {
|
|
25921
29458
|
return {
|
|
25922
29459
|
valid: false,
|
|
25923
29460
|
errors: ["Expected context pack payload to be an object"]
|
|
25924
29461
|
};
|
|
25925
29462
|
}
|
|
25926
|
-
if (payload.schemaVersion !==
|
|
29463
|
+
if (payload.schemaVersion !== CONTEXT_PACK_SCHEMA_VERSION3) {
|
|
25927
29464
|
errors.push(
|
|
25928
|
-
`Expected schemaVersion='${
|
|
29465
|
+
`Expected schemaVersion='${CONTEXT_PACK_SCHEMA_VERSION3}', received '${String(
|
|
25929
29466
|
payload.schemaVersion
|
|
25930
29467
|
)}'`
|
|
25931
29468
|
);
|
|
25932
29469
|
}
|
|
25933
|
-
if (!
|
|
29470
|
+
if (!isString2(payload.topicId)) {
|
|
25934
29471
|
errors.push("Expected 'topicId' to be a string");
|
|
25935
29472
|
}
|
|
25936
|
-
if (!
|
|
29473
|
+
if (!isString2(payload.topicName)) {
|
|
25937
29474
|
errors.push("Expected 'topicName' to be a string");
|
|
25938
29475
|
}
|
|
25939
|
-
if (!
|
|
29476
|
+
if (!isStringArray2(payload.scopedTopicIds)) {
|
|
25940
29477
|
errors.push("Expected 'scopedTopicIds' to be string[]");
|
|
25941
29478
|
}
|
|
25942
|
-
if (!
|
|
29479
|
+
if (!isNumber2(payload.generatedAt)) {
|
|
25943
29480
|
errors.push("Expected 'generatedAt' to be a number");
|
|
25944
29481
|
}
|
|
25945
29482
|
if (payload.rankingProfile !== "baseline_v1" && payload.rankingProfile !== "hybrid_v1" && payload.rankingProfile !== "weighted_v1") {
|
|
@@ -25947,7 +29484,7 @@ function validateContextPackSchema2(payload) {
|
|
|
25947
29484
|
"Expected 'rankingProfile' to be 'baseline_v1', 'hybrid_v1', or 'weighted_v1'"
|
|
25948
29485
|
);
|
|
25949
29486
|
}
|
|
25950
|
-
const summary =
|
|
29487
|
+
const summary = requireObject2(payload, "summary", errors);
|
|
25951
29488
|
if (summary) {
|
|
25952
29489
|
const summaryKeys = [
|
|
25953
29490
|
"totalBeliefs",
|
|
@@ -25958,18 +29495,18 @@ function validateContextPackSchema2(payload) {
|
|
|
25958
29495
|
"scopedTopics"
|
|
25959
29496
|
];
|
|
25960
29497
|
for (const key of summaryKeys) {
|
|
25961
|
-
if (!
|
|
29498
|
+
if (!isNumber2(summary[key])) {
|
|
25962
29499
|
errors.push(`Expected 'summary.${key}' to be a number`);
|
|
25963
29500
|
}
|
|
25964
29501
|
}
|
|
25965
29502
|
}
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
|
|
25969
|
-
|
|
25970
|
-
|
|
29503
|
+
validateBeliefArray2("invariants", payload.invariants, errors);
|
|
29504
|
+
validateBeliefArray2("activeBeliefs", payload.activeBeliefs, errors);
|
|
29505
|
+
validateQuestionArray2("openQuestions", payload.openQuestions, errors);
|
|
29506
|
+
validateEvidenceArray2("recentEvidence", payload.recentEvidence, errors);
|
|
29507
|
+
validateContradictionArray2("contradictions", payload.contradictions, errors);
|
|
25971
29508
|
if (payload.relatedEntities !== void 0) {
|
|
25972
|
-
|
|
29509
|
+
validateEntityArray2("relatedEntities", payload.relatedEntities, errors);
|
|
25973
29510
|
}
|
|
25974
29511
|
if (payload.compilationMode !== void 0 && payload.compilationMode !== "standard" && payload.compilationMode !== "delta") {
|
|
25975
29512
|
errors.push(
|
|
@@ -25977,7 +29514,7 @@ function validateContextPackSchema2(payload) {
|
|
|
25977
29514
|
);
|
|
25978
29515
|
}
|
|
25979
29516
|
if (payload.failureContext !== void 0) {
|
|
25980
|
-
if (!
|
|
29517
|
+
if (!isObject2(payload.failureContext)) {
|
|
25981
29518
|
errors.push("Expected 'failureContext' to be an object");
|
|
25982
29519
|
} else {
|
|
25983
29520
|
const failureContext = payload.failureContext;
|
|
@@ -25990,7 +29527,7 @@ function validateContextPackSchema2(payload) {
|
|
|
25990
29527
|
}
|
|
25991
29528
|
}
|
|
25992
29529
|
if (payload.deltaReport !== void 0) {
|
|
25993
|
-
if (!
|
|
29530
|
+
if (!isObject2(payload.deltaReport)) {
|
|
25994
29531
|
errors.push("Expected 'deltaReport' to be an object");
|
|
25995
29532
|
} else {
|
|
25996
29533
|
const deltaReport = payload.deltaReport;
|
|
@@ -26002,38 +29539,38 @@ function validateContextPackSchema2(payload) {
|
|
|
26002
29539
|
"Expected 'deltaReport.verificationObligations' to be an array"
|
|
26003
29540
|
);
|
|
26004
29541
|
}
|
|
26005
|
-
if (!
|
|
29542
|
+
if (!isString2(deltaReport.referencePoint)) {
|
|
26006
29543
|
errors.push("Expected 'deltaReport.referencePoint' to be a string");
|
|
26007
29544
|
}
|
|
26008
29545
|
}
|
|
26009
29546
|
}
|
|
26010
29547
|
if (!Array.isArray(payload.contextNarrative)) {
|
|
26011
29548
|
errors.push("Expected 'contextNarrative' to be an array");
|
|
26012
|
-
} else if (!payload.contextNarrative.every((entry) =>
|
|
29549
|
+
} else if (!payload.contextNarrative.every((entry) => isString2(entry))) {
|
|
26013
29550
|
errors.push("Expected each 'contextNarrative' entry to be a string");
|
|
26014
29551
|
}
|
|
26015
|
-
const injectionPolicy =
|
|
29552
|
+
const injectionPolicy = requireObject2(payload, "injectionPolicy", errors);
|
|
26016
29553
|
if (injectionPolicy) {
|
|
26017
|
-
if (!
|
|
29554
|
+
if (!isNumber2(injectionPolicy.tokenBudget)) {
|
|
26018
29555
|
errors.push("Expected 'injectionPolicy.tokenBudget' to be a number");
|
|
26019
29556
|
}
|
|
26020
|
-
if (!
|
|
29557
|
+
if (!isNumber2(injectionPolicy.estimatedTokens)) {
|
|
26021
29558
|
errors.push("Expected 'injectionPolicy.estimatedTokens' to be a number");
|
|
26022
29559
|
}
|
|
26023
|
-
const selected =
|
|
29560
|
+
const selected = requireObject2(injectionPolicy, "selected", errors);
|
|
26024
29561
|
if (selected) {
|
|
26025
29562
|
for (const key of CONTEXT_PACK_SECTION_KEYS) {
|
|
26026
|
-
if (!
|
|
29563
|
+
if (!isStringArray2(selected[key])) {
|
|
26027
29564
|
errors.push(
|
|
26028
29565
|
`Expected 'injectionPolicy.selected.${key}' to be string[]`
|
|
26029
29566
|
);
|
|
26030
29567
|
}
|
|
26031
29568
|
}
|
|
26032
29569
|
}
|
|
26033
|
-
const sectionUsage =
|
|
29570
|
+
const sectionUsage = requireObject2(injectionPolicy, "sectionUsage", errors);
|
|
26034
29571
|
if (sectionUsage) {
|
|
26035
29572
|
for (const key of CONTEXT_PACK_SECTION_KEYS) {
|
|
26036
|
-
if (!
|
|
29573
|
+
if (!isNumber2(sectionUsage[key])) {
|
|
26037
29574
|
errors.push(
|
|
26038
29575
|
`Expected 'injectionPolicy.sectionUsage.${key}' to be a number`
|
|
26039
29576
|
);
|
|
@@ -26041,12 +29578,12 @@ function validateContextPackSchema2(payload) {
|
|
|
26041
29578
|
}
|
|
26042
29579
|
}
|
|
26043
29580
|
}
|
|
26044
|
-
const diagnostics =
|
|
29581
|
+
const diagnostics = requireObject2(payload, "diagnostics", errors);
|
|
26045
29582
|
if (diagnostics) {
|
|
26046
|
-
if (!
|
|
29583
|
+
if (!isNumber2(diagnostics.itemsScored)) {
|
|
26047
29584
|
errors.push("Expected 'diagnostics.itemsScored' to be a number");
|
|
26048
29585
|
}
|
|
26049
|
-
if (!
|
|
29586
|
+
if (!isNumber2(diagnostics.tokenBudgetUtilization)) {
|
|
26050
29587
|
errors.push(
|
|
26051
29588
|
"Expected 'diagnostics.tokenBudgetUtilization' to be a number"
|
|
26052
29589
|
);
|