@lucern/mcp 0.3.0-alpha.4 → 0.3.0-alpha.6
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/cli.js
CHANGED
|
@@ -10,8 +10,25 @@ import { createServer } from 'http';
|
|
|
10
10
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
11
11
|
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
12
12
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
13
|
+
import * as graphIntel_star from '@lucern/reasoning-kernel/graphIntel';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
17
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
18
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
|
|
15
32
|
|
|
16
33
|
// ../cli/src/types.ts
|
|
17
34
|
var EXIT = {
|
|
@@ -227,6 +244,598 @@ function stripQuotes(value) {
|
|
|
227
244
|
return trimmed;
|
|
228
245
|
}
|
|
229
246
|
|
|
247
|
+
// ../contracts/src/graph-intelligence.contract.ts
|
|
248
|
+
var GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION = "graph_intelligence_query_catalog.v1";
|
|
249
|
+
var GRAPH_INTELLIGENCE_QUERY_MODES = [
|
|
250
|
+
"core",
|
|
251
|
+
"bias",
|
|
252
|
+
"stress",
|
|
253
|
+
"operational",
|
|
254
|
+
"alpha",
|
|
255
|
+
"semantic",
|
|
256
|
+
"evidence"
|
|
257
|
+
];
|
|
258
|
+
var GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES = [
|
|
259
|
+
"get_graph_structure_analysis",
|
|
260
|
+
"detect_confirmation_bias",
|
|
261
|
+
"get_graph_gaps",
|
|
262
|
+
"get_topic_coverage",
|
|
263
|
+
"find_contradictions",
|
|
264
|
+
"get_falsification_questions",
|
|
265
|
+
"search_beliefs",
|
|
266
|
+
"search_evidence",
|
|
267
|
+
"list_beliefs",
|
|
268
|
+
"list_questions",
|
|
269
|
+
"traverse_graph",
|
|
270
|
+
"query_lineage",
|
|
271
|
+
"get_graph_neighborhood"
|
|
272
|
+
];
|
|
273
|
+
var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
|
|
274
|
+
core: [
|
|
275
|
+
"get_graph_structure_analysis",
|
|
276
|
+
"get_topic_coverage",
|
|
277
|
+
"get_graph_gaps",
|
|
278
|
+
"list_beliefs",
|
|
279
|
+
"list_questions",
|
|
280
|
+
"search_evidence"
|
|
281
|
+
],
|
|
282
|
+
bias: [
|
|
283
|
+
"get_graph_structure_analysis",
|
|
284
|
+
"detect_confirmation_bias",
|
|
285
|
+
"find_contradictions",
|
|
286
|
+
"search_evidence",
|
|
287
|
+
"list_beliefs"
|
|
288
|
+
],
|
|
289
|
+
stress: [
|
|
290
|
+
"get_graph_structure_analysis",
|
|
291
|
+
"get_graph_gaps",
|
|
292
|
+
"find_contradictions",
|
|
293
|
+
"get_falsification_questions",
|
|
294
|
+
"list_beliefs",
|
|
295
|
+
"list_questions"
|
|
296
|
+
],
|
|
297
|
+
operational: [
|
|
298
|
+
"get_topic_coverage",
|
|
299
|
+
"get_graph_gaps",
|
|
300
|
+
"list_beliefs",
|
|
301
|
+
"list_questions",
|
|
302
|
+
"search_evidence"
|
|
303
|
+
],
|
|
304
|
+
alpha: [
|
|
305
|
+
"get_graph_structure_analysis",
|
|
306
|
+
"detect_confirmation_bias",
|
|
307
|
+
"find_contradictions",
|
|
308
|
+
"search_beliefs",
|
|
309
|
+
"search_evidence"
|
|
310
|
+
],
|
|
311
|
+
semantic: [
|
|
312
|
+
"get_graph_structure_analysis",
|
|
313
|
+
"search_beliefs",
|
|
314
|
+
"search_evidence",
|
|
315
|
+
"traverse_graph",
|
|
316
|
+
"query_lineage",
|
|
317
|
+
"get_graph_neighborhood"
|
|
318
|
+
],
|
|
319
|
+
evidence: [
|
|
320
|
+
"get_graph_structure_analysis",
|
|
321
|
+
"get_topic_coverage",
|
|
322
|
+
"search_evidence",
|
|
323
|
+
"get_falsification_questions",
|
|
324
|
+
"find_contradictions"
|
|
325
|
+
]
|
|
326
|
+
};
|
|
327
|
+
var GRAPH_INTELLIGENCE_QUERY_CATEGORIES = [
|
|
328
|
+
{
|
|
329
|
+
id: "problems",
|
|
330
|
+
name: "Find Problems",
|
|
331
|
+
description: "Risk, contradiction, bias, and structural weakness queries."
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
id: "gaps",
|
|
335
|
+
name: "Find Gaps",
|
|
336
|
+
description: "Missing evidence, unanswered questions, and sparse areas."
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
id: "reasoning",
|
|
340
|
+
name: "Reasoning Quality",
|
|
341
|
+
description: "Assumption chains, evidence convergence, and weak links."
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: "strategic",
|
|
345
|
+
name: "Strategic Analysis",
|
|
346
|
+
description: "Pre-mortems, falsification, contrarian signals, and bets."
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
id: "deep",
|
|
350
|
+
name: "Deep Graph Analysis",
|
|
351
|
+
description: "Centrality, propagation, underdetermination, and topology."
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: "browse",
|
|
355
|
+
name: "Browse and Explore",
|
|
356
|
+
description: "Narrative summaries, search, theme exploration, and bridges."
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
id: "prep",
|
|
360
|
+
name: "Meeting Prep",
|
|
361
|
+
description: "Company, entity, and question prep from graph context."
|
|
362
|
+
}
|
|
363
|
+
];
|
|
364
|
+
var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
|
|
365
|
+
var GRAPH_INTELLIGENCE_QUERIES = [
|
|
366
|
+
{
|
|
367
|
+
id: "confirmation-bias",
|
|
368
|
+
categoryId: "problems",
|
|
369
|
+
mode: "bias",
|
|
370
|
+
name: "Find Confirmation Bias",
|
|
371
|
+
description: "Find beliefs supported mainly by confirming evidence.",
|
|
372
|
+
prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
|
|
373
|
+
highlightStrategy: "bias-risk",
|
|
374
|
+
riskLevel: "high"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: "contradiction-map",
|
|
378
|
+
categoryId: "problems",
|
|
379
|
+
mode: "stress",
|
|
380
|
+
name: "Map Contradictions",
|
|
381
|
+
description: "Surface direct and indirect contradiction clusters.",
|
|
382
|
+
prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
|
|
383
|
+
highlightStrategy: "contradictions",
|
|
384
|
+
riskLevel: "high"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
id: "weak-evidence",
|
|
388
|
+
categoryId: "problems",
|
|
389
|
+
mode: "stress",
|
|
390
|
+
name: "Weak Evidence Chains",
|
|
391
|
+
description: "Find important claims with thin or indirect evidence.",
|
|
392
|
+
prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
|
|
393
|
+
highlightStrategy: "weak-support",
|
|
394
|
+
riskLevel: "medium"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
id: "single-source",
|
|
398
|
+
categoryId: "problems",
|
|
399
|
+
mode: "bias",
|
|
400
|
+
name: "Single-Source Risk",
|
|
401
|
+
description: "Find claims overly dependent on one source or source type.",
|
|
402
|
+
prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
|
|
403
|
+
highlightStrategy: "source-concentration",
|
|
404
|
+
riskLevel: "medium"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
id: "untested-assumptions",
|
|
408
|
+
categoryId: "problems",
|
|
409
|
+
mode: "stress",
|
|
410
|
+
name: "Untested Assumptions",
|
|
411
|
+
description: "Find load-bearing assumptions without falsification paths.",
|
|
412
|
+
prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
|
|
413
|
+
highlightStrategy: "untested",
|
|
414
|
+
riskLevel: "high"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
id: "load-bearing-beliefs",
|
|
418
|
+
categoryId: "problems",
|
|
419
|
+
mode: "stress",
|
|
420
|
+
name: "Load-Bearing Beliefs",
|
|
421
|
+
description: "Find central beliefs whose failure would affect many claims.",
|
|
422
|
+
prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
|
|
423
|
+
highlightStrategy: "load-bearing",
|
|
424
|
+
riskLevel: "high"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
id: "cascade-analysis",
|
|
428
|
+
categoryId: "problems",
|
|
429
|
+
mode: "stress",
|
|
430
|
+
name: "Cascade Analysis",
|
|
431
|
+
description: "Trace what changes if a belief is weakened or invalidated.",
|
|
432
|
+
prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
|
|
433
|
+
highlightStrategy: "cascade",
|
|
434
|
+
riskLevel: "high"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "unanswered-questions",
|
|
438
|
+
categoryId: "gaps",
|
|
439
|
+
mode: "operational",
|
|
440
|
+
name: "Unanswered Questions",
|
|
441
|
+
description: "Find important open questions that block confidence.",
|
|
442
|
+
prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
|
|
443
|
+
highlightStrategy: "open-questions"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: "thin-themes",
|
|
447
|
+
categoryId: "gaps",
|
|
448
|
+
mode: "operational",
|
|
449
|
+
name: "Thin Themes",
|
|
450
|
+
description: "Find topics with shallow belief or evidence coverage.",
|
|
451
|
+
prompt: "Find themes that look underdeveloped relative to their role in the graph.",
|
|
452
|
+
highlightStrategy: "thin-themes"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
id: "missing-evidence",
|
|
456
|
+
categoryId: "gaps",
|
|
457
|
+
mode: "stress",
|
|
458
|
+
name: "Missing Evidence",
|
|
459
|
+
description: "Find beliefs that need specific missing evidence.",
|
|
460
|
+
prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
|
|
461
|
+
highlightStrategy: "missing-evidence"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: "isolated-clusters",
|
|
465
|
+
categoryId: "gaps",
|
|
466
|
+
mode: "operational",
|
|
467
|
+
name: "Isolated Clusters",
|
|
468
|
+
description: "Find clusters not connected to the broader graph.",
|
|
469
|
+
prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
|
|
470
|
+
highlightStrategy: "isolated-clusters"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
id: "source-contribution",
|
|
474
|
+
categoryId: "gaps",
|
|
475
|
+
mode: "evidence",
|
|
476
|
+
name: "Source Contribution",
|
|
477
|
+
description: "Assess how source mix shapes the graph.",
|
|
478
|
+
prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
|
|
479
|
+
highlightStrategy: "source-mix"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
id: "stale-beliefs",
|
|
483
|
+
categoryId: "gaps",
|
|
484
|
+
mode: "operational",
|
|
485
|
+
name: "Stale Beliefs",
|
|
486
|
+
description: "Find beliefs that need review because they are old or stale.",
|
|
487
|
+
prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
|
|
488
|
+
highlightStrategy: "staleness"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
id: "assumption-pyramid",
|
|
492
|
+
categoryId: "reasoning",
|
|
493
|
+
mode: "operational",
|
|
494
|
+
name: "Assumption Pyramid",
|
|
495
|
+
description: "Show which conclusions rest on which assumptions.",
|
|
496
|
+
prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
|
|
497
|
+
highlightStrategy: "assumptions"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: "converging-evidence",
|
|
501
|
+
categoryId: "reasoning",
|
|
502
|
+
mode: "evidence",
|
|
503
|
+
name: "Converging Evidence",
|
|
504
|
+
description: "Find claims supported by independent evidence streams.",
|
|
505
|
+
prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
|
|
506
|
+
highlightStrategy: "convergence"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
id: "weakest-links",
|
|
510
|
+
categoryId: "reasoning",
|
|
511
|
+
mode: "stress",
|
|
512
|
+
name: "Weakest Links",
|
|
513
|
+
description: "Find the weakest links in important reasoning chains.",
|
|
514
|
+
prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
|
|
515
|
+
highlightStrategy: "weak-links",
|
|
516
|
+
riskLevel: "medium"
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
id: "challenged-beliefs",
|
|
520
|
+
categoryId: "reasoning",
|
|
521
|
+
mode: "stress",
|
|
522
|
+
name: "Challenged Beliefs",
|
|
523
|
+
description: "Find beliefs with active challenges or defeaters.",
|
|
524
|
+
prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
|
|
525
|
+
highlightStrategy: "challenged"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
id: "contrarian-map",
|
|
529
|
+
categoryId: "strategic",
|
|
530
|
+
mode: "alpha",
|
|
531
|
+
name: "Contrarian Map",
|
|
532
|
+
description: "Find non-consensus beliefs and where they are grounded.",
|
|
533
|
+
prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
|
|
534
|
+
highlightStrategy: "contrarian"
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
id: "irreversibility-audit",
|
|
538
|
+
categoryId: "strategic",
|
|
539
|
+
mode: "stress",
|
|
540
|
+
name: "Irreversibility Audit",
|
|
541
|
+
description: "Find irreversible bets and assumptions behind them.",
|
|
542
|
+
prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
|
|
543
|
+
highlightStrategy: "irreversible",
|
|
544
|
+
riskLevel: "high"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
id: "pre-mortem",
|
|
548
|
+
categoryId: "strategic",
|
|
549
|
+
mode: "stress",
|
|
550
|
+
name: "Pre-Mortem",
|
|
551
|
+
description: "Explain how the graph could be wrong.",
|
|
552
|
+
prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
|
|
553
|
+
highlightStrategy: "failure-paths",
|
|
554
|
+
riskLevel: "high"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
id: "devils-advocate",
|
|
558
|
+
categoryId: "strategic",
|
|
559
|
+
mode: "stress",
|
|
560
|
+
name: "Devil's Advocate",
|
|
561
|
+
description: "Generate the strongest critique of the graph.",
|
|
562
|
+
prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
|
|
563
|
+
highlightStrategy: "critique"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
id: "falsification-map",
|
|
567
|
+
categoryId: "strategic",
|
|
568
|
+
mode: "stress",
|
|
569
|
+
name: "Falsification Map",
|
|
570
|
+
description: "Find the cheapest tests that would disprove key beliefs.",
|
|
571
|
+
prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
|
|
572
|
+
highlightStrategy: "falsification",
|
|
573
|
+
riskLevel: "high"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
id: "prediction-tracker",
|
|
577
|
+
categoryId: "strategic",
|
|
578
|
+
mode: "evidence",
|
|
579
|
+
name: "Prediction Tracker",
|
|
580
|
+
description: "Find beliefs that imply measurable predictions.",
|
|
581
|
+
prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
|
|
582
|
+
highlightStrategy: "predictions"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
id: "belief-pagerank",
|
|
586
|
+
categoryId: "deep",
|
|
587
|
+
mode: "semantic",
|
|
588
|
+
name: "Belief PageRank",
|
|
589
|
+
description: "Identify structurally central beliefs.",
|
|
590
|
+
prompt: "Use graph centrality to identify the most structurally important beliefs.",
|
|
591
|
+
highlightStrategy: "centrality"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
id: "underdetermination",
|
|
595
|
+
categoryId: "deep",
|
|
596
|
+
mode: "semantic",
|
|
597
|
+
name: "Underdetermination",
|
|
598
|
+
description: "Find places where evidence supports multiple explanations.",
|
|
599
|
+
prompt: "Find places where the same evidence could support multiple incompatible explanations.",
|
|
600
|
+
highlightStrategy: "underdetermination"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
id: "confidence-propagation",
|
|
604
|
+
categoryId: "deep",
|
|
605
|
+
mode: "semantic",
|
|
606
|
+
name: "Confidence Propagation",
|
|
607
|
+
description: "Assess how uncertainty moves through the graph.",
|
|
608
|
+
prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
|
|
609
|
+
highlightStrategy: "confidence-flow"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
id: "argument-depth",
|
|
613
|
+
categoryId: "deep",
|
|
614
|
+
mode: "evidence",
|
|
615
|
+
name: "Argument Depth",
|
|
616
|
+
description: "Assess reasoning depth and chain quality.",
|
|
617
|
+
prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
|
|
618
|
+
highlightStrategy: "depth"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
id: "information-edge",
|
|
622
|
+
categoryId: "deep",
|
|
623
|
+
mode: "alpha",
|
|
624
|
+
name: "Information Edge",
|
|
625
|
+
description: "Find differentiated evidence or signals.",
|
|
626
|
+
prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
|
|
627
|
+
highlightStrategy: "information-edge"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "thesis-summary",
|
|
631
|
+
categoryId: "browse",
|
|
632
|
+
mode: "semantic",
|
|
633
|
+
name: "Thesis Summary",
|
|
634
|
+
description: "Summarize the graph's core thesis and support.",
|
|
635
|
+
prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
|
|
636
|
+
highlightStrategy: "summary"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
id: "theme-deep-dive",
|
|
640
|
+
categoryId: "browse",
|
|
641
|
+
mode: "semantic",
|
|
642
|
+
name: "Theme Deep Dive",
|
|
643
|
+
description: "Deep dive into a named theme.",
|
|
644
|
+
prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
|
|
645
|
+
inputType: "theme",
|
|
646
|
+
highlightStrategy: "theme"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
id: "belief-detail",
|
|
650
|
+
categoryId: "browse",
|
|
651
|
+
mode: "semantic",
|
|
652
|
+
name: "Belief Detail",
|
|
653
|
+
description: "Explain one belief and its graph neighborhood.",
|
|
654
|
+
prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
|
|
655
|
+
inputType: "belief",
|
|
656
|
+
highlightStrategy: "belief"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
id: "strongest-beliefs",
|
|
660
|
+
categoryId: "browse",
|
|
661
|
+
mode: "operational",
|
|
662
|
+
name: "Strongest Beliefs",
|
|
663
|
+
description: "Find the graph's strongest current beliefs.",
|
|
664
|
+
prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
|
|
665
|
+
highlightStrategy: "strongest"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
id: "cross-theme-connection",
|
|
669
|
+
categoryId: "browse",
|
|
670
|
+
mode: "semantic",
|
|
671
|
+
name: "Cross-Theme Connections",
|
|
672
|
+
description: "Find bridges between themes.",
|
|
673
|
+
prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
|
|
674
|
+
highlightStrategy: "bridges"
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
id: "research-velocity",
|
|
678
|
+
categoryId: "browse",
|
|
679
|
+
mode: "operational",
|
|
680
|
+
name: "Research Velocity",
|
|
681
|
+
description: "Summarize recent graph movement and momentum.",
|
|
682
|
+
prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
|
|
683
|
+
highlightStrategy: "velocity"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
id: "search",
|
|
687
|
+
categoryId: "browse",
|
|
688
|
+
mode: "semantic",
|
|
689
|
+
name: "Graph Search",
|
|
690
|
+
description: "Search the graph with semantic context.",
|
|
691
|
+
prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
|
|
692
|
+
inputType: "search",
|
|
693
|
+
highlightStrategy: "search"
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
id: "expert-coverage",
|
|
697
|
+
categoryId: "browse",
|
|
698
|
+
mode: "semantic",
|
|
699
|
+
name: "Expert Coverage",
|
|
700
|
+
description: "Assess coverage from expert/source perspectives.",
|
|
701
|
+
prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
|
|
702
|
+
highlightStrategy: "expert-coverage"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
id: "value-chain-map",
|
|
706
|
+
categoryId: "browse",
|
|
707
|
+
mode: "semantic",
|
|
708
|
+
name: "Value Chain Map",
|
|
709
|
+
description: "Map entities, dependencies, and value-chain logic.",
|
|
710
|
+
prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
|
|
711
|
+
highlightStrategy: "value-chain"
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
id: "meeting-brief",
|
|
715
|
+
categoryId: "prep",
|
|
716
|
+
mode: "semantic",
|
|
717
|
+
name: "Meeting Brief",
|
|
718
|
+
description: "Prepare a meeting brief from graph context.",
|
|
719
|
+
prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
|
|
720
|
+
highlightStrategy: "brief"
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
id: "open-questions-entity",
|
|
724
|
+
categoryId: "prep",
|
|
725
|
+
mode: "semantic",
|
|
726
|
+
name: "Entity Open Questions",
|
|
727
|
+
description: "Find open questions about a specific entity.",
|
|
728
|
+
prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
|
|
729
|
+
inputType: "entity",
|
|
730
|
+
highlightStrategy: "entity-questions"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
id: "company-context",
|
|
734
|
+
categoryId: "prep",
|
|
735
|
+
mode: "semantic",
|
|
736
|
+
name: "Company Context",
|
|
737
|
+
description: "Summarize graph context about a company.",
|
|
738
|
+
prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
|
|
739
|
+
inputType: "company",
|
|
740
|
+
highlightStrategy: "company"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
id: "company-theme-fit",
|
|
744
|
+
categoryId: "prep",
|
|
745
|
+
mode: "semantic",
|
|
746
|
+
name: "Company Theme Fit",
|
|
747
|
+
description: "Assess how a company fits graph themes.",
|
|
748
|
+
prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
|
|
749
|
+
inputType: "company",
|
|
750
|
+
highlightStrategy: "fit"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
id: "company-comparison",
|
|
754
|
+
categoryId: "prep",
|
|
755
|
+
mode: "semantic",
|
|
756
|
+
name: "Company Comparison",
|
|
757
|
+
description: "Compare companies through graph context.",
|
|
758
|
+
prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
|
|
759
|
+
inputType: "company-list",
|
|
760
|
+
highlightStrategy: "comparison"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
id: "questions-to-ask",
|
|
764
|
+
categoryId: "prep",
|
|
765
|
+
mode: "operational",
|
|
766
|
+
name: "Questions to Ask",
|
|
767
|
+
description: "Generate high-signal questions from graph gaps.",
|
|
768
|
+
prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
|
|
769
|
+
highlightStrategy: "questions"
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
id: "beliefs-to-test",
|
|
773
|
+
categoryId: "prep",
|
|
774
|
+
mode: "stress",
|
|
775
|
+
name: "Beliefs to Test",
|
|
776
|
+
description: "Prioritize beliefs that should be tested next.",
|
|
777
|
+
prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
|
|
778
|
+
highlightStrategy: "tests",
|
|
779
|
+
riskLevel: "medium"
|
|
780
|
+
}
|
|
781
|
+
];
|
|
782
|
+
var GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS = GRAPH_INTELLIGENCE_QUERIES.map((query5) => {
|
|
783
|
+
const definition = query5;
|
|
784
|
+
return {
|
|
785
|
+
...definition,
|
|
786
|
+
tools: definition.tools ?? byMode(definition.mode)
|
|
787
|
+
};
|
|
788
|
+
});
|
|
789
|
+
var GRAPH_INTELLIGENCE_QUICK_QUERIES = [
|
|
790
|
+
{
|
|
791
|
+
id: "health-check",
|
|
792
|
+
name: "Health Check",
|
|
793
|
+
queryId: "thesis-summary",
|
|
794
|
+
prompt: "Give me a fast graph health check: biggest strengths, biggest risks, and next best action."
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
id: "find-risks",
|
|
798
|
+
name: "Find Risks",
|
|
799
|
+
queryId: "weakest-links",
|
|
800
|
+
prompt: "Find the most important risks in this graph and the beliefs or evidence behind each one."
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
id: "pre-mortem",
|
|
804
|
+
name: "Pre-Mortem",
|
|
805
|
+
queryId: "pre-mortem",
|
|
806
|
+
prompt: "Assume this thesis fails. Explain the most plausible failure paths and what would reveal them early."
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
id: "whats-next",
|
|
810
|
+
name: "What's Next",
|
|
811
|
+
queryId: "questions-to-ask",
|
|
812
|
+
prompt: "What should I learn or test next to make this graph more useful?"
|
|
813
|
+
}
|
|
814
|
+
];
|
|
815
|
+
function isGraphIntelligenceQueryMode(value) {
|
|
816
|
+
return typeof value === "string" && GRAPH_INTELLIGENCE_QUERY_MODES.includes(value);
|
|
817
|
+
}
|
|
818
|
+
function getGraphIntelligenceQuery(queryId) {
|
|
819
|
+
return GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS.find(
|
|
820
|
+
(query5) => query5.id === queryId
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
function listGraphIntelligenceQueries(filter = {}) {
|
|
824
|
+
return GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS.filter((query5) => {
|
|
825
|
+
if (filter.categoryId && query5.categoryId !== filter.categoryId) {
|
|
826
|
+
return false;
|
|
827
|
+
}
|
|
828
|
+
if (filter.mode && query5.mode !== filter.mode) {
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
return true;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
function fillGraphIntelligencePromptTemplate(prompt, input) {
|
|
835
|
+
const replacement = input?.trim() || "the current topic";
|
|
836
|
+
return prompt.split("{input}").join(replacement);
|
|
837
|
+
}
|
|
838
|
+
|
|
230
839
|
// ../contracts/src/dsl/defineTable.ts
|
|
231
840
|
function defineTable(spec) {
|
|
232
841
|
return spec;
|
|
@@ -243,7 +852,10 @@ function idOf(table) {
|
|
|
243
852
|
return schema;
|
|
244
853
|
}
|
|
245
854
|
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"]);
|
|
246
|
-
var
|
|
855
|
+
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"];
|
|
856
|
+
var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
|
|
857
|
+
z.enum(EDGE_TYPE_VALUES);
|
|
858
|
+
var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
|
|
247
859
|
var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
|
|
248
860
|
var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
|
|
249
861
|
defineTable({
|
|
@@ -1728,7 +2340,7 @@ defineTable({
|
|
|
1728
2340
|
"toNodeId": z.string().optional(),
|
|
1729
2341
|
"sourceGlobalId": z.string().optional(),
|
|
1730
2342
|
"targetGlobalId": z.string().optional(),
|
|
1731
|
-
"edgeType":
|
|
2343
|
+
"edgeType": STORAGE_EDGE_TYPE,
|
|
1732
2344
|
"edgeTier": z.string().optional(),
|
|
1733
2345
|
"domainNamespace": z.string().optional(),
|
|
1734
2346
|
"constraint": z.string().optional(),
|
|
@@ -4502,6 +5114,126 @@ var edgePolicyManifest = {
|
|
|
4502
5114
|
|
|
4503
5115
|
// ../contracts/src/tenant-client.contract.ts
|
|
4504
5116
|
var TENANT_CLIENT_INSTALL_TOKEN_INFISICAL_PATH = "tenants/shared";
|
|
5117
|
+
var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
|
|
5118
|
+
{
|
|
5119
|
+
packageName: "@lucern/access-control",
|
|
5120
|
+
role: "runtime_entrypoint",
|
|
5121
|
+
directTenantImport: true
|
|
5122
|
+
},
|
|
5123
|
+
{
|
|
5124
|
+
packageName: "@lucern/agent",
|
|
5125
|
+
role: "platform_runtime",
|
|
5126
|
+
directTenantImport: false
|
|
5127
|
+
},
|
|
5128
|
+
{
|
|
5129
|
+
packageName: "@lucern/auth",
|
|
5130
|
+
role: "sdk_dependency",
|
|
5131
|
+
directTenantImport: false
|
|
5132
|
+
},
|
|
5133
|
+
{
|
|
5134
|
+
packageName: "@lucern/cli",
|
|
5135
|
+
role: "developer_tool",
|
|
5136
|
+
directTenantImport: false
|
|
5137
|
+
},
|
|
5138
|
+
{
|
|
5139
|
+
packageName: "@lucern/client-core",
|
|
5140
|
+
role: "sdk_dependency",
|
|
5141
|
+
directTenantImport: false
|
|
5142
|
+
},
|
|
5143
|
+
{
|
|
5144
|
+
packageName: "@lucern/confidence",
|
|
5145
|
+
role: "sdk_dependency",
|
|
5146
|
+
directTenantImport: false
|
|
5147
|
+
},
|
|
5148
|
+
{
|
|
5149
|
+
packageName: "@lucern/config",
|
|
5150
|
+
role: "configuration",
|
|
5151
|
+
directTenantImport: false
|
|
5152
|
+
},
|
|
5153
|
+
{
|
|
5154
|
+
packageName: "@lucern/contracts",
|
|
5155
|
+
role: "contract_entrypoint",
|
|
5156
|
+
directTenantImport: true
|
|
5157
|
+
},
|
|
5158
|
+
{
|
|
5159
|
+
packageName: "@lucern/control-plane",
|
|
5160
|
+
role: "platform_runtime",
|
|
5161
|
+
directTenantImport: false
|
|
5162
|
+
},
|
|
5163
|
+
{
|
|
5164
|
+
packageName: "@lucern/developer-kit",
|
|
5165
|
+
role: "developer_tool",
|
|
5166
|
+
directTenantImport: false
|
|
5167
|
+
},
|
|
5168
|
+
{
|
|
5169
|
+
packageName: "@lucern/events",
|
|
5170
|
+
role: "sdk_dependency",
|
|
5171
|
+
directTenantImport: false
|
|
5172
|
+
},
|
|
5173
|
+
{
|
|
5174
|
+
packageName: "@lucern/graph-primitives",
|
|
5175
|
+
role: "sdk_dependency",
|
|
5176
|
+
directTenantImport: false
|
|
5177
|
+
},
|
|
5178
|
+
{
|
|
5179
|
+
packageName: "@lucern/identity",
|
|
5180
|
+
role: "component_runtime",
|
|
5181
|
+
directTenantImport: false
|
|
5182
|
+
},
|
|
5183
|
+
{
|
|
5184
|
+
packageName: "@lucern/mcp",
|
|
5185
|
+
role: "runtime_entrypoint",
|
|
5186
|
+
directTenantImport: true
|
|
5187
|
+
},
|
|
5188
|
+
{
|
|
5189
|
+
packageName: "@lucern/pack-host",
|
|
5190
|
+
role: "platform_runtime",
|
|
5191
|
+
directTenantImport: false
|
|
5192
|
+
},
|
|
5193
|
+
{
|
|
5194
|
+
packageName: "@lucern/pack-installer",
|
|
5195
|
+
role: "developer_tool",
|
|
5196
|
+
directTenantImport: false
|
|
5197
|
+
},
|
|
5198
|
+
{
|
|
5199
|
+
packageName: "@lucern/proof-compiler",
|
|
5200
|
+
role: "developer_tool",
|
|
5201
|
+
directTenantImport: false
|
|
5202
|
+
},
|
|
5203
|
+
{
|
|
5204
|
+
packageName: "@lucern/react",
|
|
5205
|
+
role: "runtime_entrypoint",
|
|
5206
|
+
directTenantImport: true
|
|
5207
|
+
},
|
|
5208
|
+
{
|
|
5209
|
+
packageName: "@lucern/reasoning-kernel",
|
|
5210
|
+
role: "component_runtime",
|
|
5211
|
+
directTenantImport: false
|
|
5212
|
+
},
|
|
5213
|
+
{
|
|
5214
|
+
packageName: "@lucern/sdk",
|
|
5215
|
+
role: "runtime_entrypoint",
|
|
5216
|
+
directTenantImport: true
|
|
5217
|
+
},
|
|
5218
|
+
{
|
|
5219
|
+
packageName: "@lucern/server-core",
|
|
5220
|
+
role: "platform_runtime",
|
|
5221
|
+
directTenantImport: false
|
|
5222
|
+
},
|
|
5223
|
+
{
|
|
5224
|
+
packageName: "@lucern/testing",
|
|
5225
|
+
role: "test_support",
|
|
5226
|
+
directTenantImport: false
|
|
5227
|
+
},
|
|
5228
|
+
{
|
|
5229
|
+
packageName: "@lucern/types",
|
|
5230
|
+
role: "contract_entrypoint",
|
|
5231
|
+
directTenantImport: true
|
|
5232
|
+
}
|
|
5233
|
+
];
|
|
5234
|
+
TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
|
|
5235
|
+
(entry) => entry.packageName
|
|
5236
|
+
);
|
|
4505
5237
|
var INFISICAL_RUNTIME_DEFAULT_API_URL = "https://app.infisical.com";
|
|
4506
5238
|
var INFISICAL_RUNTIME_DEFAULT_PROJECT_ID = "344b0526-90df-4606-ba50-22c647a36c65";
|
|
4507
5239
|
var INFISICAL_RUNTIME_BOOTSTRAP_ENV = {
|
|
@@ -6156,6 +6888,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
|
|
|
6156
6888
|
ontologyPrimitive: "graph",
|
|
6157
6889
|
tier: "showcase"
|
|
6158
6890
|
};
|
|
6891
|
+
var LIST_GRAPH_INTELLIGENCE_QUERIES = {
|
|
6892
|
+
name: "list_graph_intelligence_queries",
|
|
6893
|
+
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.",
|
|
6894
|
+
parameters: {
|
|
6895
|
+
categoryId: {
|
|
6896
|
+
type: "string",
|
|
6897
|
+
description: "Optional category filter, such as problems or strategic"
|
|
6898
|
+
},
|
|
6899
|
+
mode: {
|
|
6900
|
+
type: "string",
|
|
6901
|
+
description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
|
|
6902
|
+
}
|
|
6903
|
+
},
|
|
6904
|
+
required: [],
|
|
6905
|
+
response: {
|
|
6906
|
+
description: "Graph Intelligence query catalog and mode-to-tool mapping",
|
|
6907
|
+
fields: {
|
|
6908
|
+
categories: "array \u2014 query categories",
|
|
6909
|
+
queries: "array \u2014 query definitions with prompt templates and tools",
|
|
6910
|
+
quickQueries: "array \u2014 recommended one-click query presets",
|
|
6911
|
+
publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
|
|
6912
|
+
}
|
|
6913
|
+
},
|
|
6914
|
+
ownerModule: "graph-intelligence",
|
|
6915
|
+
ontologyPrimitive: "graph",
|
|
6916
|
+
tier: "showcase"
|
|
6917
|
+
};
|
|
6918
|
+
var RUN_GRAPH_INTELLIGENCE_QUERY = {
|
|
6919
|
+
name: "run_graph_intelligence_query",
|
|
6920
|
+
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.",
|
|
6921
|
+
parameters: {
|
|
6922
|
+
topicId: { type: "string", description: "Topic to analyze" },
|
|
6923
|
+
queryId: {
|
|
6924
|
+
type: "string",
|
|
6925
|
+
description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
|
|
6926
|
+
},
|
|
6927
|
+
prompt: {
|
|
6928
|
+
type: "string",
|
|
6929
|
+
description: "Optional custom prompt for custom analysis runs"
|
|
6930
|
+
},
|
|
6931
|
+
input: {
|
|
6932
|
+
type: "string",
|
|
6933
|
+
description: "Optional entity, theme, belief, company, or search text for input-driven queries"
|
|
6934
|
+
},
|
|
6935
|
+
mode: {
|
|
6936
|
+
type: "string",
|
|
6937
|
+
description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
|
|
6938
|
+
},
|
|
6939
|
+
limit: {
|
|
6940
|
+
type: "number",
|
|
6941
|
+
description: "Maximum graph context rows to return"
|
|
6942
|
+
}
|
|
6943
|
+
},
|
|
6944
|
+
required: ["topicId"],
|
|
6945
|
+
response: {
|
|
6946
|
+
description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
|
|
6947
|
+
fields: {
|
|
6948
|
+
query: "object \u2014 selected query definition",
|
|
6949
|
+
prompt: "string \u2014 resolved prompt template",
|
|
6950
|
+
toolPlan: "array \u2014 public tools and args the model can call next",
|
|
6951
|
+
analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
|
|
6952
|
+
context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
|
|
6953
|
+
}
|
|
6954
|
+
},
|
|
6955
|
+
ownerModule: "graph-intelligence",
|
|
6956
|
+
ontologyPrimitive: "graph",
|
|
6957
|
+
tier: "showcase"
|
|
6958
|
+
};
|
|
6159
6959
|
var GET_FALSIFICATION_QUESTIONS = {
|
|
6160
6960
|
name: "get_falsification_questions",
|
|
6161
6961
|
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.",
|
|
@@ -8731,6 +9531,8 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
8731
9531
|
// Graph intelligence (showcase)
|
|
8732
9532
|
detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
|
|
8733
9533
|
get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
|
|
9534
|
+
list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
|
|
9535
|
+
run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
|
|
8734
9536
|
get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
|
|
8735
9537
|
// Evidence operations (workhorse)
|
|
8736
9538
|
search_evidence: SEARCH_EVIDENCE,
|
|
@@ -8818,6 +9620,18 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
8818
9620
|
deprecate_ontology_version: DEPRECATE_ONTOLOGY_VERSION,
|
|
8819
9621
|
resolve_effective_ontology: RESOLVE_EFFECTIVE_ONTOLOGY
|
|
8820
9622
|
};
|
|
9623
|
+
var GIT_SEMANTIC_REQUIRED_TOOLS = Object.keys(MCP_TOOL_CONTRACTS);
|
|
9624
|
+
function validateGitSemantics(tool) {
|
|
9625
|
+
const desc = tool.description;
|
|
9626
|
+
const hasGitReference = /Like (`git |a `git |a merge conflict|opening a `git)/.test(desc);
|
|
9627
|
+
if (!hasGitReference) {
|
|
9628
|
+
return {
|
|
9629
|
+
valid: false,
|
|
9630
|
+
reason: `Tool "${tool.name}" description missing git-semantic reference`
|
|
9631
|
+
};
|
|
9632
|
+
}
|
|
9633
|
+
return { valid: true };
|
|
9634
|
+
}
|
|
8821
9635
|
|
|
8822
9636
|
// ../contracts/src/function-registry/manifest.ts
|
|
8823
9637
|
var publicEverywhere = {
|
|
@@ -8913,6 +9727,8 @@ var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
|
|
|
8913
9727
|
"traverse_graph",
|
|
8914
9728
|
"get_graph_neighborhood",
|
|
8915
9729
|
"get_graph_structure_analysis",
|
|
9730
|
+
"list_graph_intelligence_queries",
|
|
9731
|
+
"run_graph_intelligence_query",
|
|
8916
9732
|
"find_contradictions",
|
|
8917
9733
|
"flag_contradiction",
|
|
8918
9734
|
"detect_confirmation_bias",
|
|
@@ -11533,6 +12349,15 @@ var edgesContracts = [
|
|
|
11533
12349
|
args: queryLineageArgs
|
|
11534
12350
|
})
|
|
11535
12351
|
];
|
|
12352
|
+
var graphIntelligenceQueryModes = [
|
|
12353
|
+
"core",
|
|
12354
|
+
"bias",
|
|
12355
|
+
"stress",
|
|
12356
|
+
"operational",
|
|
12357
|
+
"alpha",
|
|
12358
|
+
"semantic",
|
|
12359
|
+
"evidence"
|
|
12360
|
+
];
|
|
11536
12361
|
var traversalLayerSchema = z.enum([
|
|
11537
12362
|
"L4",
|
|
11538
12363
|
"L3",
|
|
@@ -11566,6 +12391,22 @@ var graphNeighborhoodArgs = z.object({
|
|
|
11566
12391
|
topicId: z.string().optional().describe("Topic scope for edge lookup."),
|
|
11567
12392
|
limit: z.number().optional().describe("Maximum edges to return.")
|
|
11568
12393
|
});
|
|
12394
|
+
var graphIntelligenceModeSchema = z.enum([
|
|
12395
|
+
graphIntelligenceQueryModes[0],
|
|
12396
|
+
...graphIntelligenceQueryModes.slice(1)
|
|
12397
|
+
]);
|
|
12398
|
+
var graphIntelligenceCatalogArgs = z.object({
|
|
12399
|
+
categoryId: z.string().optional().describe("Optional query category filter."),
|
|
12400
|
+
mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
|
|
12401
|
+
});
|
|
12402
|
+
var graphIntelligenceRunArgs = z.object({
|
|
12403
|
+
topicId: z.string().describe("Topic to analyze."),
|
|
12404
|
+
queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
|
|
12405
|
+
prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
|
|
12406
|
+
input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
|
|
12407
|
+
mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
|
|
12408
|
+
limit: z.number().optional().describe("Maximum graph context rows to return.")
|
|
12409
|
+
});
|
|
11569
12410
|
var flagContradictionArgs = z.object({
|
|
11570
12411
|
beliefA: z.string().describe("First belief in tension."),
|
|
11571
12412
|
beliefB: z.string().describe("Second belief in tension."),
|
|
@@ -11672,18 +12513,50 @@ var graphContracts = [
|
|
|
11672
12513
|
}
|
|
11673
12514
|
}),
|
|
11674
12515
|
surfaceContract({
|
|
11675
|
-
name: "
|
|
12516
|
+
name: "list_graph_intelligence_queries",
|
|
11676
12517
|
kind: "query",
|
|
11677
12518
|
domain: "graph",
|
|
11678
12519
|
surfaceClass: "platform_public",
|
|
11679
|
-
path: "/graph/
|
|
11680
|
-
sdkNamespace: "
|
|
11681
|
-
sdkMethod: "
|
|
11682
|
-
summary: "
|
|
12520
|
+
path: "/graph-intelligence/queries",
|
|
12521
|
+
sdkNamespace: "graphAnalysis",
|
|
12522
|
+
sdkMethod: "listGraphIntelligenceQueries",
|
|
12523
|
+
summary: "List Graph Intelligence query catalog entries.",
|
|
11683
12524
|
convex: {
|
|
11684
|
-
module: "
|
|
11685
|
-
functionName: "
|
|
11686
|
-
kind: "query"
|
|
12525
|
+
module: "contextCompiler",
|
|
12526
|
+
functionName: "listGraphIntelligenceQueries",
|
|
12527
|
+
kind: "query"
|
|
12528
|
+
},
|
|
12529
|
+
args: graphIntelligenceCatalogArgs
|
|
12530
|
+
}),
|
|
12531
|
+
surfaceContract({
|
|
12532
|
+
name: "run_graph_intelligence_query",
|
|
12533
|
+
kind: "query",
|
|
12534
|
+
domain: "graph",
|
|
12535
|
+
surfaceClass: "platform_public",
|
|
12536
|
+
path: "/graph-intelligence/run",
|
|
12537
|
+
sdkNamespace: "graphAnalysis",
|
|
12538
|
+
sdkMethod: "runGraphIntelligenceQuery",
|
|
12539
|
+
summary: "Run a Graph Intelligence query against a topic graph.",
|
|
12540
|
+
convex: {
|
|
12541
|
+
module: "contextCompiler",
|
|
12542
|
+
functionName: "runGraphIntelligenceQuery",
|
|
12543
|
+
kind: "query"
|
|
12544
|
+
},
|
|
12545
|
+
args: graphIntelligenceRunArgs
|
|
12546
|
+
}),
|
|
12547
|
+
surfaceContract({
|
|
12548
|
+
name: "find_contradictions",
|
|
12549
|
+
kind: "query",
|
|
12550
|
+
domain: "graph",
|
|
12551
|
+
surfaceClass: "platform_public",
|
|
12552
|
+
path: "/graph/contradictions",
|
|
12553
|
+
sdkNamespace: "graph",
|
|
12554
|
+
sdkMethod: "findContradictions",
|
|
12555
|
+
summary: "Find contradiction edges.",
|
|
12556
|
+
convex: {
|
|
12557
|
+
module: "edges",
|
|
12558
|
+
functionName: "findContradictions",
|
|
12559
|
+
kind: "query",
|
|
11687
12560
|
inputProjection: (input) => compactRecord4({
|
|
11688
12561
|
nodeId: input.nodeId ?? input.beliefId
|
|
11689
12562
|
})
|
|
@@ -13486,6 +14359,353 @@ function scoreObservation(record, terms) {
|
|
|
13486
14359
|
return score;
|
|
13487
14360
|
}
|
|
13488
14361
|
|
|
14362
|
+
// ../sdk/src/index.ts
|
|
14363
|
+
var src_exports = {};
|
|
14364
|
+
__export(src_exports, {
|
|
14365
|
+
ACTIVATE_WORKTREE: () => ACTIVATE_WORKTREE,
|
|
14366
|
+
ADD_EVIDENCE: () => ADD_EVIDENCE,
|
|
14367
|
+
ADD_WORKTREE: () => ADD_WORKTREE,
|
|
14368
|
+
ANALYZE_TOPIC_DENSITY: () => ANALYZE_TOPIC_DENSITY,
|
|
14369
|
+
ANSWER_QUESTION: () => ANSWER_QUESTION,
|
|
14370
|
+
APPLY_AUTO_BRANCHING: () => APPLY_AUTO_BRANCHING,
|
|
14371
|
+
APPLY_LENS_TO_TOPIC: () => APPLY_LENS_TO_TOPIC,
|
|
14372
|
+
APPLY_ONTOLOGY: () => APPLY_ONTOLOGY,
|
|
14373
|
+
ARCHIVE_BELIEF: () => ARCHIVE_BELIEF,
|
|
14374
|
+
ARCHIVE_ONTOLOGY: () => ARCHIVE_ONTOLOGY,
|
|
14375
|
+
ARCHIVE_QUESTION: () => ARCHIVE_QUESTION,
|
|
14376
|
+
BEGIN_BUILD_SESSION: () => BEGIN_BUILD_SESSION,
|
|
14377
|
+
BELIEF_STATUSES: () => BELIEF_STATUSES,
|
|
14378
|
+
BISECT_CONFIDENCE: () => BISECT_CONFIDENCE,
|
|
14379
|
+
BRANCH_DEPRECATION_MESSAGE: () => BRANCH_DEPRECATION_MESSAGE,
|
|
14380
|
+
BROADCAST_MESSAGE: () => BROADCAST_MESSAGE,
|
|
14381
|
+
CANONICAL_WORKFLOW_DEFINITIONS: () => CANONICAL_WORKFLOW_DEFINITIONS,
|
|
14382
|
+
CHECK_PERMISSION: () => CHECK_PERMISSION,
|
|
14383
|
+
CLAIM_FILES: () => CLAIM_FILES,
|
|
14384
|
+
COMPILE_CONTEXT: () => COMPILE_CONTEXT,
|
|
14385
|
+
COMPLETE_TASK: () => COMPLETE_TASK,
|
|
14386
|
+
CONFIDENCE_TRIGGERS: () => CONFIDENCE_TRIGGERS,
|
|
14387
|
+
CONTRADICTION_SEVERITIES: () => CONTRADICTION_SEVERITIES,
|
|
14388
|
+
CONTRADICTION_STATUSES: () => CONTRADICTION_STATUSES,
|
|
14389
|
+
CONTROL_OBJECT_BLAST_RADII: () => CONTROL_OBJECT_BLAST_RADII,
|
|
14390
|
+
CONTROL_OBJECT_EDIT_SURFACES: () => CONTROL_OBJECT_EDIT_SURFACES,
|
|
14391
|
+
CONTROL_OBJECT_INHERITANCE_RULES: () => CONTROL_OBJECT_INHERITANCE_RULES,
|
|
14392
|
+
CONTROL_OBJECT_KINDS: () => CONTROL_OBJECT_KINDS,
|
|
14393
|
+
CONTROL_OBJECT_OWNERSHIP_CONTRACT: () => CONTROL_OBJECT_OWNERSHIP_CONTRACT,
|
|
14394
|
+
CONTROL_OBJECT_OWNERSHIP_MATRIX: () => CONTROL_OBJECT_OWNERSHIP_MATRIX,
|
|
14395
|
+
CONTROL_OBJECT_OWNERSHIP_ROWS: () => CONTROL_OBJECT_OWNERSHIP_ROWS,
|
|
14396
|
+
CONTROL_OBJECT_OWNER_SCOPES: () => CONTROL_OBJECT_OWNER_SCOPES,
|
|
14397
|
+
CREATE_ANSWER: () => CREATE_ANSWER,
|
|
14398
|
+
CREATE_BELIEF: () => CREATE_BELIEF,
|
|
14399
|
+
CREATE_EDGE: () => CREATE_EDGE,
|
|
14400
|
+
CREATE_EPISTEMIC_CONTRACT: () => CREATE_EPISTEMIC_CONTRACT,
|
|
14401
|
+
CREATE_EVIDENCE: () => CREATE_EVIDENCE,
|
|
14402
|
+
CREATE_LENS: () => CREATE_LENS,
|
|
14403
|
+
CREATE_ONTOLOGY: () => CREATE_ONTOLOGY,
|
|
14404
|
+
CREATE_ONTOLOGY_VERSION: () => CREATE_ONTOLOGY_VERSION,
|
|
14405
|
+
CREATE_QUESTION: () => CREATE_QUESTION,
|
|
14406
|
+
CREATE_TASK: () => CREATE_TASK,
|
|
14407
|
+
CREATE_TOPIC: () => CREATE_TOPIC,
|
|
14408
|
+
CustomToolRegistryError: () => CustomToolRegistryError,
|
|
14409
|
+
DEFAULT_TIER_APPROVAL_MODE: () => DEFAULT_TIER_APPROVAL_MODE,
|
|
14410
|
+
DEFAULT_WORKFLOW_AUTO_FIX_POLICY: () => DEFAULT_WORKFLOW_AUTO_FIX_POLICY,
|
|
14411
|
+
DEFEAT_TYPES: () => DEFEAT_TYPES,
|
|
14412
|
+
DEPRECATE_ONTOLOGY_VERSION: () => DEPRECATE_ONTOLOGY_VERSION,
|
|
14413
|
+
DETECT_CONFIRMATION_BIAS: () => DETECT_CONFIRMATION_BIAS,
|
|
14414
|
+
DISCOVER: () => DISCOVER,
|
|
14415
|
+
DISCOVER_ENTITY_CONNECTIONS: () => DISCOVER_ENTITY_CONNECTIONS,
|
|
14416
|
+
DOMAIN_EVENT_TYPES: () => DOMAIN_EVENT_TYPES,
|
|
14417
|
+
DOMAIN_EVENT_VERSION: () => DOMAIN_EVENT_VERSION,
|
|
14418
|
+
DeviceAuthorizationError: () => DeviceAuthorizationError,
|
|
14419
|
+
EDGE_TYPES: () => EDGE_TYPES,
|
|
14420
|
+
EMBEDDINGS_FIELDS: () => EMBEDDINGS_FIELDS,
|
|
14421
|
+
END_SESSION: () => END_SESSION,
|
|
14422
|
+
EPISTEMIC_EDGE_TYPES: () => EPISTEMIC_EDGE_TYPES,
|
|
14423
|
+
EPISTEMIC_LAYERS: () => EPISTEMIC_LAYERS,
|
|
14424
|
+
EVALUATE_CONTRACT: () => EVALUATE_CONTRACT,
|
|
14425
|
+
EVENTING_FIELDS: () => EVENTING_FIELDS,
|
|
14426
|
+
EVENT_RETENTION_DEFAULT_DAYS: () => EVENT_RETENTION_DEFAULT_DAYS,
|
|
14427
|
+
FILTER_BY_PERMISSION: () => FILTER_BY_PERMISSION,
|
|
14428
|
+
FIND_CONTRADICTIONS: () => FIND_CONTRADICTIONS,
|
|
14429
|
+
FIND_MISSING_QUESTIONS: () => FIND_MISSING_QUESTIONS,
|
|
14430
|
+
FLAG_CONTRADICTION: () => FLAG_CONTRADICTION,
|
|
14431
|
+
FORK_BELIEF: () => FORK_BELIEF,
|
|
14432
|
+
FORK_REASONS: () => FORK_REASONS,
|
|
14433
|
+
FUNCTION_SURFACE_METHOD_PATHS: () => FUNCTION_SURFACE_METHOD_PATHS,
|
|
14434
|
+
GENERATE_SESSION_HANDOFF: () => GENERATE_SESSION_HANDOFF,
|
|
14435
|
+
GET_AGENT_INBOX: () => GET_AGENT_INBOX,
|
|
14436
|
+
GET_ANSWER: () => GET_ANSWER,
|
|
14437
|
+
GET_AUDIT_TRAIL: () => GET_AUDIT_TRAIL,
|
|
14438
|
+
GET_BELIEF: () => GET_BELIEF,
|
|
14439
|
+
GET_CHANGE_HISTORY: () => GET_CHANGE_HISTORY,
|
|
14440
|
+
GET_CODE_CONTEXT: () => GET_CODE_CONTEXT,
|
|
14441
|
+
GET_CONFIDENCE_HISTORY: () => GET_CONFIDENCE_HISTORY,
|
|
14442
|
+
GET_CONTRACT_STATUS: () => GET_CONTRACT_STATUS,
|
|
14443
|
+
GET_EVIDENCE: () => GET_EVIDENCE,
|
|
14444
|
+
GET_FAILURE_LOG: () => GET_FAILURE_LOG,
|
|
14445
|
+
GET_FALSIFICATION_QUESTIONS: () => GET_FALSIFICATION_QUESTIONS,
|
|
14446
|
+
GET_GRAPH_GAPS: () => GET_GRAPH_GAPS,
|
|
14447
|
+
GET_GRAPH_NEIGHBORHOOD: () => GET_GRAPH_NEIGHBORHOOD,
|
|
14448
|
+
GET_GRAPH_STRUCTURE_ANALYSIS: () => GET_GRAPH_STRUCTURE_ANALYSIS,
|
|
14449
|
+
GET_HIGH_PRIORITY_QUESTIONS: () => GET_HIGH_PRIORITY_QUESTIONS,
|
|
14450
|
+
GET_LATTICE_COVERAGE: () => GET_LATTICE_COVERAGE,
|
|
14451
|
+
GET_OBSERVATION_CONTEXT: () => GET_OBSERVATION_CONTEXT,
|
|
14452
|
+
GET_ONTOLOGY: () => GET_ONTOLOGY,
|
|
14453
|
+
GET_QUESTION: () => GET_QUESTION,
|
|
14454
|
+
GET_TOPIC: () => GET_TOPIC,
|
|
14455
|
+
GET_TOPIC_COVERAGE: () => GET_TOPIC_COVERAGE,
|
|
14456
|
+
GET_TOPIC_TREE: () => GET_TOPIC_TREE,
|
|
14457
|
+
GIT_SEMANTIC_REQUIRED_TOOLS: () => GIT_SEMANTIC_REQUIRED_TOOLS,
|
|
14458
|
+
GRAPH_ANALYSIS_ANALYSIS_FIELDS: () => GRAPH_ANALYSIS_ANALYSIS_FIELDS,
|
|
14459
|
+
GRAPH_ANALYSIS_COMPUTE_FIELDS: () => GRAPH_ANALYSIS_COMPUTE_FIELDS,
|
|
14460
|
+
GRAPH_ANALYSIS_SUGGESTION_FIELDS: () => GRAPH_ANALYSIS_SUGGESTION_FIELDS,
|
|
14461
|
+
GRAPH_INTELLIGENCE_MODE_TOOL_NAMES: () => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES,
|
|
14462
|
+
GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES: () => GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES,
|
|
14463
|
+
GRAPH_INTELLIGENCE_QUERIES: () => GRAPH_INTELLIGENCE_QUERIES,
|
|
14464
|
+
GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS: () => GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS,
|
|
14465
|
+
GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION: () => GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION,
|
|
14466
|
+
GRAPH_INTELLIGENCE_QUERY_CATEGORIES: () => GRAPH_INTELLIGENCE_QUERY_CATEGORIES,
|
|
14467
|
+
GRAPH_INTELLIGENCE_QUERY_MODES: () => GRAPH_INTELLIGENCE_QUERY_MODES,
|
|
14468
|
+
GRAPH_INTELLIGENCE_QUICK_QUERIES: () => GRAPH_INTELLIGENCE_QUICK_QUERIES,
|
|
14469
|
+
GRAPH_RECOMMENDATION_FIELDS: () => GRAPH_RECOMMENDATION_FIELDS,
|
|
14470
|
+
GRAPH_STATE_CLASSIFIER_FIELDS: () => GRAPH_STATE_CLASSIFIER_FIELDS,
|
|
14471
|
+
HEARTBEAT_SESSION: () => HEARTBEAT_SESSION,
|
|
14472
|
+
IDENTITY_WHOAMI: () => IDENTITY_WHOAMI,
|
|
14473
|
+
INGEST_OBSERVATION: () => INGEST_OBSERVATION,
|
|
14474
|
+
InfisicalRuntimeError: () => InfisicalRuntimeError,
|
|
14475
|
+
JOBS_FIELDS: () => JOBS_FIELDS,
|
|
14476
|
+
JUDGMENT_TYPES: () => JUDGMENT_TYPES,
|
|
14477
|
+
LENS_PERSPECTIVE_TYPES: () => LENS_PERSPECTIVE_TYPES2,
|
|
14478
|
+
LENS_STATUSES: () => LENS_STATUSES,
|
|
14479
|
+
LENS_TASK_TEMPLATE_PRIORITIES: () => LENS_TASK_TEMPLATE_PRIORITIES,
|
|
14480
|
+
LINK_EVIDENCE: () => LINK_EVIDENCE,
|
|
14481
|
+
LINK_EVIDENCE_TO_BELIEF: () => LINK_EVIDENCE_TO_BELIEF,
|
|
14482
|
+
LINK_EVIDENCE_TO_QUESTION: () => LINK_EVIDENCE_TO_QUESTION,
|
|
14483
|
+
LIST_ACTIVE_SESSIONS: () => LIST_ACTIVE_SESSIONS,
|
|
14484
|
+
LIST_ALL_WORKTREES: () => LIST_ALL_WORKTREES,
|
|
14485
|
+
LIST_BELIEFS: () => LIST_BELIEFS,
|
|
14486
|
+
LIST_CAMPAIGNS: () => LIST_CAMPAIGNS,
|
|
14487
|
+
LIST_EVIDENCE: () => LIST_EVIDENCE,
|
|
14488
|
+
LIST_GRAPH_INTELLIGENCE_QUERIES: () => LIST_GRAPH_INTELLIGENCE_QUERIES,
|
|
14489
|
+
LIST_LENSES: () => LIST_LENSES,
|
|
14490
|
+
LIST_ONTOLOGIES: () => LIST_ONTOLOGIES,
|
|
14491
|
+
LIST_QUESTIONS: () => LIST_QUESTIONS,
|
|
14492
|
+
LIST_TASKS: () => LIST_TASKS,
|
|
14493
|
+
LIST_TOPICS: () => LIST_TOPICS,
|
|
14494
|
+
LIST_WORKTREES: () => LIST_WORKTREES,
|
|
14495
|
+
LUCERN_SDK_VERSION: () => LUCERN_SDK_VERSION,
|
|
14496
|
+
LucernApiError: () => LucernApiError,
|
|
14497
|
+
LucernSdkAuthContextError: () => LucernSdkAuthContextError,
|
|
14498
|
+
MANAGE_WRITE_POLICY: () => MANAGE_WRITE_POLICY,
|
|
14499
|
+
MATCH_ENTITY_TYPE: () => MATCH_ENTITY_TYPE,
|
|
14500
|
+
MAX_ENTITY_LIMIT: () => MAX_ENTITY_LIMIT,
|
|
14501
|
+
MCP_ALWAYS_ALLOWED_TOOL_NAMES: () => MCP_ALWAYS_ALLOWED_TOOL_NAMES,
|
|
14502
|
+
MCP_TOOL_CONTRACTS: () => MCP_TOOL_CONTRACTS,
|
|
14503
|
+
MERGE: () => MERGE,
|
|
14504
|
+
MERGE_OUTCOMES: () => MERGE_OUTCOMES,
|
|
14505
|
+
MODEL_RUNTIME_FIELDS: () => MODEL_RUNTIME_FIELDS,
|
|
14506
|
+
MODULATE_CONFIDENCE: () => MODULATE_CONFIDENCE,
|
|
14507
|
+
MORNING_BRIEF_WORKFLOW_ID: () => MORNING_BRIEF_WORKFLOW_ID,
|
|
14508
|
+
NIGHTLY_RECONCILIATION_WORKFLOW_ID: () => NIGHTLY_RECONCILIATION_WORKFLOW_ID,
|
|
14509
|
+
ONTOLOGY_LINK_FIELDS: () => ONTOLOGY_LINK_FIELDS,
|
|
14510
|
+
OPEN_PULL_REQUEST: () => OPEN_PULL_REQUEST,
|
|
14511
|
+
ORG_GRAPH_SEARCH_FIELDS: () => ORG_GRAPH_SEARCH_FIELDS,
|
|
14512
|
+
PIPELINE_SNAPSHOT: () => PIPELINE_SNAPSHOT,
|
|
14513
|
+
PUBLISH_ONTOLOGY_VERSION: () => PUBLISH_ONTOLOGY_VERSION,
|
|
14514
|
+
PUSH: () => PUSH,
|
|
14515
|
+
QUERY_LINEAGE: () => QUERY_LINEAGE,
|
|
14516
|
+
REASONING_METHODS: () => REASONING_METHODS,
|
|
14517
|
+
RECORD_ATTEMPT: () => RECORD_ATTEMPT,
|
|
14518
|
+
RECORD_JUDGMENT: () => RECORD_JUDGMENT,
|
|
14519
|
+
RECORD_SCOPE_LEARNING: () => RECORD_SCOPE_LEARNING,
|
|
14520
|
+
REFINE_BELIEF: () => REFINE_BELIEF,
|
|
14521
|
+
REFINE_QUESTION: () => REFINE_QUESTION,
|
|
14522
|
+
REGISTER_SESSION: () => REGISTER_SESSION,
|
|
14523
|
+
REMOVE_LENS_FROM_TOPIC: () => REMOVE_LENS_FROM_TOPIC,
|
|
14524
|
+
RESOLVE_EFFECTIVE_ONTOLOGY: () => RESOLVE_EFFECTIVE_ONTOLOGY,
|
|
14525
|
+
RUN_GRAPH_INTELLIGENCE_QUERY: () => RUN_GRAPH_INTELLIGENCE_QUERY,
|
|
14526
|
+
SEARCH_BELIEFS: () => SEARCH_BELIEFS,
|
|
14527
|
+
SEARCH_EVIDENCE: () => SEARCH_EVIDENCE,
|
|
14528
|
+
SEED_BELIEF_LATTICE: () => SEED_BELIEF_LATTICE,
|
|
14529
|
+
SEND_AGENT_MESSAGE: () => SEND_AGENT_MESSAGE,
|
|
14530
|
+
SESSION_AUTH_MODES: () => SESSION_AUTH_MODES,
|
|
14531
|
+
SESSION_LIFECYCLE_STATUSES: () => SESSION_LIFECYCLE_STATUSES,
|
|
14532
|
+
SESSION_PRINCIPAL_TYPES: () => SESSION_PRINCIPAL_TYPES,
|
|
14533
|
+
STRUCTURAL_EDGE_TYPES: () => STRUCTURAL_EDGE_TYPES,
|
|
14534
|
+
TELEMETRY_FIELDS: () => TELEMETRY_FIELDS,
|
|
14535
|
+
TENANT_IDENTITY_FIELDS: () => TENANT_IDENTITY_FIELDS,
|
|
14536
|
+
TOOL_REGISTRY_FIELDS: () => TOOL_REGISTRY_FIELDS,
|
|
14537
|
+
TRACE_ENTITY_IMPACT: () => TRACE_ENTITY_IMPACT,
|
|
14538
|
+
TRAVERSE_GRAPH: () => TRAVERSE_GRAPH,
|
|
14539
|
+
TRIGGER_BELIEF_REVIEW: () => TRIGGER_BELIEF_REVIEW,
|
|
14540
|
+
UPDATE_ONTOLOGY: () => UPDATE_ONTOLOGY,
|
|
14541
|
+
UPDATE_QUESTION_STATUS: () => UPDATE_QUESTION_STATUS,
|
|
14542
|
+
UPDATE_TASK: () => UPDATE_TASK,
|
|
14543
|
+
UPDATE_TOPIC: () => UPDATE_TOPIC,
|
|
14544
|
+
UPDATE_WORKTREE_METADATA: () => UPDATE_WORKTREE_METADATA,
|
|
14545
|
+
UPDATE_WORKTREE_TARGETS: () => UPDATE_WORKTREE_TARGETS,
|
|
14546
|
+
WEBHOOK_MAX_ATTEMPTS: () => WEBHOOK_MAX_ATTEMPTS,
|
|
14547
|
+
WEBHOOK_RETRY_DELAYS_MS: () => WEBHOOK_RETRY_DELAYS_MS,
|
|
14548
|
+
WORKFLOW_ACTION_KINDS: () => WORKFLOW_ACTION_KINDS,
|
|
14549
|
+
WORKFLOW_APPROVAL_MODES: () => WORKFLOW_APPROVAL_MODES,
|
|
14550
|
+
WORKFLOW_AUTO_FIX_MODES: () => WORKFLOW_AUTO_FIX_MODES,
|
|
14551
|
+
WORKFLOW_HOOK_EVENTS: () => WORKFLOW_HOOK_EVENTS,
|
|
14552
|
+
WORKFLOW_INTEGRITY_CHECKS: () => WORKFLOW_INTEGRITY_CHECKS,
|
|
14553
|
+
WORKFLOW_MUTATION_TIERS: () => WORKFLOW_MUTATION_TIERS,
|
|
14554
|
+
WORKFLOW_OUTPUT_KINDS: () => WORKFLOW_OUTPUT_KINDS,
|
|
14555
|
+
WORKFLOW_PROOF_ARTIFACT_KINDS: () => WORKFLOW_PROOF_ARTIFACT_KINDS,
|
|
14556
|
+
WORKFLOW_RUNTIME_SCHEMA_VERSION: () => WORKFLOW_RUNTIME_SCHEMA_VERSION,
|
|
14557
|
+
WORKFLOW_RUN_STATUSES: () => WORKFLOW_RUN_STATUSES,
|
|
14558
|
+
WORKFLOW_STAFFING_HINTS: () => WORKFLOW_STAFFING_HINTS,
|
|
14559
|
+
WORKFLOW_TRIGGER_KINDS: () => WORKFLOW_TRIGGER_KINDS,
|
|
14560
|
+
WORKTREE_PHASES: () => WORKTREE_PHASES,
|
|
14561
|
+
applyInfisicalRuntimeEnv: () => applyInfisicalRuntimeEnv,
|
|
14562
|
+
asListItems: () => asListItems,
|
|
14563
|
+
assertValidWebhookSecret: () => assertValidWebhookSecret,
|
|
14564
|
+
assertValidWebhookUrl: () => assertValidWebhookUrl,
|
|
14565
|
+
buildDeprecatedBranchMetadata: () => buildDeprecatedBranchMetadata,
|
|
14566
|
+
buildDomainEvent: () => buildDomainEvent,
|
|
14567
|
+
buildMcpToolContracts: () => buildMcpToolContracts,
|
|
14568
|
+
buildMcpToolManifest: () => buildMcpToolManifest,
|
|
14569
|
+
clearRegisteredCustomTools: () => clearRegisteredCustomTools,
|
|
14570
|
+
compareEventCursor: () => compareEventCursor,
|
|
14571
|
+
compileContextPackFromSnapshot: () => compileContextPackFromSnapshot,
|
|
14572
|
+
computeWebhookSignature: () => computeWebhookSignature,
|
|
14573
|
+
createAdminClient: () => createAdminClient,
|
|
14574
|
+
createAnswersClient: () => createAnswersClient,
|
|
14575
|
+
createAudiencesClient: () => createAudiencesClient,
|
|
14576
|
+
createAuditClient: () => createAuditClient,
|
|
14577
|
+
createAuthDeviceClient: () => createAuthDeviceClient,
|
|
14578
|
+
createBeliefsClient: () => createBeliefsClient,
|
|
14579
|
+
createCanonicalAuthHeaders: () => createCanonicalAuthHeaders,
|
|
14580
|
+
createContextClient: () => createContextClient,
|
|
14581
|
+
createContextFacade: () => createContextFacade,
|
|
14582
|
+
createDecisionsClient: () => createDecisionsClient,
|
|
14583
|
+
createEmbeddingsClient: () => createEmbeddingsClient,
|
|
14584
|
+
createEventId: () => createEventId,
|
|
14585
|
+
createEventingClient: () => createEventingClient,
|
|
14586
|
+
createEventsClientCore: () => createEventsClientCore,
|
|
14587
|
+
createEvidenceClient: () => createEvidenceClient,
|
|
14588
|
+
createFunctionSurfaceClient: () => createFunctionSurfaceClient,
|
|
14589
|
+
createGatewayRequestClient: () => createGatewayRequestClient,
|
|
14590
|
+
createGraphAnalysisClient: () => createGraphAnalysisClient,
|
|
14591
|
+
createGraphClient: () => createGraphClient,
|
|
14592
|
+
createGraphRecommendationsClient: () => createGraphRecommendationsClient,
|
|
14593
|
+
createGraphStateClassifierClient: () => createGraphStateClassifierClient,
|
|
14594
|
+
createHarnessClient: () => createHarnessClient,
|
|
14595
|
+
createIdentityClient: () => createIdentityClient,
|
|
14596
|
+
createJobsClient: () => createJobsClient,
|
|
14597
|
+
createLearningClient: () => createLearningClient,
|
|
14598
|
+
createListResult: () => createListResult,
|
|
14599
|
+
createLucernClient: () => createLucernClient,
|
|
14600
|
+
createModelRuntimeClient: () => createModelRuntimeClient,
|
|
14601
|
+
createOntologyClient: () => createOntologyClient,
|
|
14602
|
+
createOntologyLinksClient: () => createOntologyLinksClient,
|
|
14603
|
+
createOrgGraphSearchClient: () => createOrgGraphSearchClient,
|
|
14604
|
+
createPacksClient: () => createPacksClient,
|
|
14605
|
+
createPolicyClient: () => createPolicyClient,
|
|
14606
|
+
createReportsClient: () => createReportsClient,
|
|
14607
|
+
createSchemaClient: () => createSchemaClient,
|
|
14608
|
+
createSourcesClient: () => createSourcesClient,
|
|
14609
|
+
createTelemetryClient: () => createTelemetryClient,
|
|
14610
|
+
createToolRegistryClient: () => createToolRegistryClient,
|
|
14611
|
+
createTopicsClient: () => createTopicsClient,
|
|
14612
|
+
createWebhooksClientCore: () => createWebhooksClientCore,
|
|
14613
|
+
createWorkflowClient: () => createWorkflowClient,
|
|
14614
|
+
decodeEventCursor: () => decodeEventCursor,
|
|
14615
|
+
emitDomainEvent: () => emitDomainEvent,
|
|
14616
|
+
encodeEventCursor: () => encodeEventCursor,
|
|
14617
|
+
eventPatternToRegExp: () => eventPatternToRegExp,
|
|
14618
|
+
fillGraphIntelligencePromptTemplate: () => fillGraphIntelligencePromptTemplate,
|
|
14619
|
+
getControlObjectOwnershipCase: () => getControlObjectOwnershipCase,
|
|
14620
|
+
getGraphIntelligenceQuery: () => getGraphIntelligenceQuery,
|
|
14621
|
+
getMcpToolExposure: () => getMcpToolExposure,
|
|
14622
|
+
getRegisteredCustomTool: () => getRegisteredCustomTool,
|
|
14623
|
+
hydrateInfisicalRuntimeEnv: () => hydrateInfisicalRuntimeEnv,
|
|
14624
|
+
inferActorType: () => inferActorType,
|
|
14625
|
+
inferLensPerspectiveTypeFromBranchSchema: () => inferLensPerspectiveTypeFromBranchSchema,
|
|
14626
|
+
inferSessionPrincipalType: () => inferSessionPrincipalType,
|
|
14627
|
+
invokeRegisteredCustomTool: () => invokeRegisteredCustomTool,
|
|
14628
|
+
isAfterCursor: () => isAfterCursor,
|
|
14629
|
+
isGraphIntelligenceQueryMode: () => isGraphIntelligenceQueryMode,
|
|
14630
|
+
isInfisicalRuntimeDisabled: () => isInfisicalRuntimeDisabled,
|
|
14631
|
+
isLensFilterCriteria: () => isLensFilterCriteria2,
|
|
14632
|
+
isLucernPrompt: () => isLucernPrompt,
|
|
14633
|
+
isMcpToolAllowed: () => isMcpToolAllowed,
|
|
14634
|
+
isTaxonomyFilterCriteriaV1: () => isTaxonomyFilterCriteriaV12,
|
|
14635
|
+
lastDelegator: () => lastDelegator,
|
|
14636
|
+
listControlObjectOwnershipCases: () => listControlObjectOwnershipCases,
|
|
14637
|
+
listGraphIntelligenceQueries: () => listGraphIntelligenceQueries,
|
|
14638
|
+
listRegisteredCustomTools: () => listRegisteredCustomTools,
|
|
14639
|
+
mapAliasedList: () => mapAliasedList,
|
|
14640
|
+
mapGatewayData: () => mapGatewayData,
|
|
14641
|
+
mapOpinionHistoryEntriesFromGatewayData: () => mapOpinionHistoryEntriesFromGatewayData,
|
|
14642
|
+
matchesAnyEventPattern: () => matchesAnyEventPattern,
|
|
14643
|
+
matchesEventPattern: () => matchesEventPattern,
|
|
14644
|
+
mcpContractToInputSchema: () => mcpContractToInputSchema,
|
|
14645
|
+
mcpContractToManifestEntry: () => mcpContractToManifestEntry,
|
|
14646
|
+
migrateBranchToLens: () => migrateBranchToLens,
|
|
14647
|
+
nextDeliveryAttemptAt: () => nextDeliveryAttemptAt,
|
|
14648
|
+
normalizeCanonicalLucernAuthContext: () => normalizeCanonicalLucernAuthContext,
|
|
14649
|
+
normalizeDelegationChain: () => normalizeDelegationChain,
|
|
14650
|
+
normalizeNodeVerificationStatus: () => normalizeNodeVerificationStatus,
|
|
14651
|
+
normalizeNodeWriteInput: () => normalizeNodeWriteInput,
|
|
14652
|
+
normalizeRetentionDays: () => normalizeRetentionDays,
|
|
14653
|
+
normalizeTopicQuery: () => normalizeTopicQuery,
|
|
14654
|
+
normalizeWebhookPatterns: () => normalizeWebhookPatterns,
|
|
14655
|
+
opinionFromBaseRate: () => opinionFromBaseRate,
|
|
14656
|
+
opinionFromDogmatic: () => opinionFromDogmatic,
|
|
14657
|
+
opinionFromProjected: () => opinionFromProjected,
|
|
14658
|
+
planContextPackCompilation: () => planContextPackCompilation,
|
|
14659
|
+
randomIdempotencyKey: () => randomIdempotencyKey,
|
|
14660
|
+
readInfisicalRuntimeBootstrap: () => readInfisicalRuntimeBootstrap,
|
|
14661
|
+
registerCustomTool: () => registerCustomTool,
|
|
14662
|
+
resolveDeliveryFailureStatus: () => resolveDeliveryFailureStatus,
|
|
14663
|
+
resolveText: () => resolveText,
|
|
14664
|
+
resolveTopicId: () => resolveTopicId,
|
|
14665
|
+
sanitizeWebhookRecord: () => sanitizeWebhookRecord,
|
|
14666
|
+
sortEventsByCursor: () => sortEventsByCursor,
|
|
14667
|
+
toQueryString: () => toQueryString,
|
|
14668
|
+
truncateWebhookResponseBody: () => truncateWebhookResponseBody,
|
|
14669
|
+
unregisterCustomTool: () => unregisterCustomTool,
|
|
14670
|
+
validateFilterCriteria: () => validateFilterCriteria2,
|
|
14671
|
+
validateGitSemantics: () => validateGitSemantics,
|
|
14672
|
+
withSdkAliases: () => withSdkAliases,
|
|
14673
|
+
withTextAlias: () => withTextAlias,
|
|
14674
|
+
withTopicAlias: () => withTopicAlias
|
|
14675
|
+
});
|
|
14676
|
+
|
|
14677
|
+
// ../sdk/src/opinion.ts
|
|
14678
|
+
function clamp01(value) {
|
|
14679
|
+
if (!Number.isFinite(value)) {
|
|
14680
|
+
return 0;
|
|
14681
|
+
}
|
|
14682
|
+
return Math.max(0, Math.min(1, value));
|
|
14683
|
+
}
|
|
14684
|
+
function vacuous(baseRate) {
|
|
14685
|
+
return { b: 0, d: 0, u: 1, a: clamp01(baseRate) };
|
|
14686
|
+
}
|
|
14687
|
+
function dogmatic(probability, baseRate) {
|
|
14688
|
+
const p = clamp01(probability);
|
|
14689
|
+
return { b: p, d: 1 - p, u: 0, a: clamp01(baseRate) };
|
|
14690
|
+
}
|
|
14691
|
+
function opinionFromBaseRate(probability) {
|
|
14692
|
+
return vacuous(clamp01(probability));
|
|
14693
|
+
}
|
|
14694
|
+
function opinionFromDogmatic(probability, baseRate) {
|
|
14695
|
+
return dogmatic(clamp01(probability), clamp01(baseRate));
|
|
14696
|
+
}
|
|
14697
|
+
function opinionFromProjected(probability, uncertainty, baseRate) {
|
|
14698
|
+
const p = clamp01(probability);
|
|
14699
|
+
const u = clamp01(uncertainty);
|
|
14700
|
+
const remainingMass = 1 - u;
|
|
14701
|
+
return {
|
|
14702
|
+
b: p * remainingMass,
|
|
14703
|
+
d: (1 - p) * remainingMass,
|
|
14704
|
+
u,
|
|
14705
|
+
a: clamp01(baseRate)
|
|
14706
|
+
};
|
|
14707
|
+
}
|
|
14708
|
+
|
|
13489
14709
|
// ../sdk/src/authContext.ts
|
|
13490
14710
|
var LucernSdkAuthContextError = class extends Error {
|
|
13491
14711
|
reason;
|
|
@@ -14794,7 +16014,7 @@ function readString2(value) {
|
|
|
14794
16014
|
function readNumber(value) {
|
|
14795
16015
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
14796
16016
|
}
|
|
14797
|
-
function
|
|
16017
|
+
function clamp012(value) {
|
|
14798
16018
|
return Math.max(0, Math.min(1, value));
|
|
14799
16019
|
}
|
|
14800
16020
|
function normalizeOpinionTuple(record) {
|
|
@@ -14809,10 +16029,10 @@ function normalizeOpinionTuple(record) {
|
|
|
14809
16029
|
);
|
|
14810
16030
|
}
|
|
14811
16031
|
return {
|
|
14812
|
-
b:
|
|
14813
|
-
d:
|
|
14814
|
-
u:
|
|
14815
|
-
a:
|
|
16032
|
+
b: clamp012(rawBelief),
|
|
16033
|
+
d: clamp012(rawDisbelief),
|
|
16034
|
+
u: clamp012(rawUncertainty),
|
|
16035
|
+
a: clamp012(rawBaseRate)
|
|
14816
16036
|
};
|
|
14817
16037
|
}
|
|
14818
16038
|
function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
@@ -14820,7 +16040,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
14820
16040
|
return entries2.map((value) => {
|
|
14821
16041
|
const record = asRecord2(value);
|
|
14822
16042
|
const tuple = normalizeOpinionTuple(record);
|
|
14823
|
-
const projected = readNumber(record.confidence) ??
|
|
16043
|
+
const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
|
|
14824
16044
|
const triggeringEvidenceId = readString2(record.triggeringEvidenceId);
|
|
14825
16045
|
const triggeringQuestionId = readString2(record.triggeringQuestionId);
|
|
14826
16046
|
const triggeringAnswerId = readString2(record.triggeringAnswerId);
|
|
@@ -14839,7 +16059,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
14839
16059
|
d: tuple.d,
|
|
14840
16060
|
u: tuple.u,
|
|
14841
16061
|
a: tuple.a,
|
|
14842
|
-
P:
|
|
16062
|
+
P: clamp012(projected),
|
|
14843
16063
|
trigger,
|
|
14844
16064
|
...triggeringRef ? { triggeringRef } : {},
|
|
14845
16065
|
...readString2(record.rationale) ? { rationale: readString2(record.rationale) } : {},
|
|
@@ -17601,9 +18821,33 @@ function graphAnalysisQuery(input) {
|
|
|
17601
18821
|
cursor: input.cursor
|
|
17602
18822
|
};
|
|
17603
18823
|
}
|
|
18824
|
+
function normalizeRunQueryPayload(input) {
|
|
18825
|
+
return {
|
|
18826
|
+
...input,
|
|
18827
|
+
topicId: requireTopicId2(input),
|
|
18828
|
+
projectId: void 0
|
|
18829
|
+
};
|
|
18830
|
+
}
|
|
17604
18831
|
function createGraphAnalysisClient(config = {}) {
|
|
17605
18832
|
const gateway = createGatewayRequestClient(config);
|
|
17606
18833
|
return {
|
|
18834
|
+
listGraphIntelligenceQueries(input = {}) {
|
|
18835
|
+
return gateway.request({
|
|
18836
|
+
path: "/api/platform/v1/graph-intelligence/queries",
|
|
18837
|
+
method: "POST",
|
|
18838
|
+
body: {
|
|
18839
|
+
categoryId: input.categoryId,
|
|
18840
|
+
mode: input.mode
|
|
18841
|
+
}
|
|
18842
|
+
});
|
|
18843
|
+
},
|
|
18844
|
+
runGraphIntelligenceQuery(input) {
|
|
18845
|
+
return gateway.request({
|
|
18846
|
+
path: "/api/platform/v1/graph-intelligence/run",
|
|
18847
|
+
method: "POST",
|
|
18848
|
+
body: normalizeRunQueryPayload(input)
|
|
18849
|
+
});
|
|
18850
|
+
},
|
|
17607
18851
|
saveAnalysis(input, idempotencyKey) {
|
|
17608
18852
|
return gateway.request({
|
|
17609
18853
|
path: "/api/platform/v1/graph-analysis/analyses",
|
|
@@ -18440,6 +19684,120 @@ function createMcpClient(config = {}) {
|
|
|
18440
19684
|
}
|
|
18441
19685
|
|
|
18442
19686
|
// ../sdk/src/generated/functionSurface.ts
|
|
19687
|
+
var FUNCTION_SURFACE_METHOD_PATHS = [
|
|
19688
|
+
"answers.answerQuestion",
|
|
19689
|
+
"answers.createAnswer",
|
|
19690
|
+
"answers.getAnswer",
|
|
19691
|
+
"beliefs.archiveBelief",
|
|
19692
|
+
"beliefs.bisectConfidence",
|
|
19693
|
+
"beliefs.createBelief",
|
|
19694
|
+
"beliefs.forkBelief",
|
|
19695
|
+
"beliefs.getBelief",
|
|
19696
|
+
"beliefs.getConfidenceHistory",
|
|
19697
|
+
"beliefs.listBeliefs",
|
|
19698
|
+
"beliefs.modulateConfidence",
|
|
19699
|
+
"beliefs.refineBelief",
|
|
19700
|
+
"beliefs.searchBeliefs",
|
|
19701
|
+
"bootstrap.generateSessionHandoff",
|
|
19702
|
+
"coding.getChangeHistory",
|
|
19703
|
+
"coding.getCodeContext",
|
|
19704
|
+
"coding.getFailureLog",
|
|
19705
|
+
"coding.recordAttempt",
|
|
19706
|
+
"context.analyzeTopicDensity",
|
|
19707
|
+
"context.applyAutoBranching",
|
|
19708
|
+
"context.compileContext",
|
|
19709
|
+
"context.discover",
|
|
19710
|
+
"context.discoverEntityConnections",
|
|
19711
|
+
"context.getLatticeCoverage",
|
|
19712
|
+
"context.recordScopeLearning",
|
|
19713
|
+
"context.seedBeliefLattice",
|
|
19714
|
+
"context.triggerBeliefReview",
|
|
19715
|
+
"contracts.createEpistemicContract",
|
|
19716
|
+
"contracts.evaluateContract",
|
|
19717
|
+
"contracts.getContractStatus",
|
|
19718
|
+
"contradictions.flagContradiction",
|
|
19719
|
+
"coordination.broadcastMessage",
|
|
19720
|
+
"coordination.claimFiles",
|
|
19721
|
+
"coordination.endSession",
|
|
19722
|
+
"coordination.getAgentInbox",
|
|
19723
|
+
"coordination.heartbeatSession",
|
|
19724
|
+
"coordination.listActiveSessions",
|
|
19725
|
+
"coordination.registerSession",
|
|
19726
|
+
"coordination.sendAgentMessage",
|
|
19727
|
+
"edges.createEdge",
|
|
19728
|
+
"edges.queryLineage",
|
|
19729
|
+
"evidence.addEvidence",
|
|
19730
|
+
"evidence.createEvidence",
|
|
19731
|
+
"evidence.getEvidence",
|
|
19732
|
+
"evidence.linkEvidence",
|
|
19733
|
+
"evidence.linkEvidenceToBelief",
|
|
19734
|
+
"evidence.linkEvidenceToQuestion",
|
|
19735
|
+
"evidence.listEvidence",
|
|
19736
|
+
"evidence.searchEvidence",
|
|
19737
|
+
"graph.detectConfirmationBias",
|
|
19738
|
+
"graph.findContradictions",
|
|
19739
|
+
"graph.getGraphGaps",
|
|
19740
|
+
"graph.getGraphNeighborhood",
|
|
19741
|
+
"graph.getGraphStructureAnalysis",
|
|
19742
|
+
"graph.getTopicCoverage",
|
|
19743
|
+
"graph.traceEntityImpact",
|
|
19744
|
+
"graph.traverseGraph",
|
|
19745
|
+
"graphAnalysis.listGraphIntelligenceQueries",
|
|
19746
|
+
"graphAnalysis.runGraphIntelligenceQuery",
|
|
19747
|
+
"identity.checkPermission",
|
|
19748
|
+
"identity.filterByPermission",
|
|
19749
|
+
"identity.whoami",
|
|
19750
|
+
"judgments.getAuditTrail",
|
|
19751
|
+
"judgments.recordJudgment",
|
|
19752
|
+
"lenses.applyLensToTopic",
|
|
19753
|
+
"lenses.createLens",
|
|
19754
|
+
"lenses.listLenses",
|
|
19755
|
+
"lenses.removeLensFromTopic",
|
|
19756
|
+
"observations.getObservationContext",
|
|
19757
|
+
"observations.ingestObservation",
|
|
19758
|
+
"ontologies.applyOntology",
|
|
19759
|
+
"ontologies.archiveOntology",
|
|
19760
|
+
"ontologies.createOntology",
|
|
19761
|
+
"ontologies.createOntologyVersion",
|
|
19762
|
+
"ontologies.deprecateOntologyVersion",
|
|
19763
|
+
"ontologies.getOntology",
|
|
19764
|
+
"ontologies.listOntologies",
|
|
19765
|
+
"ontologies.matchEntityType",
|
|
19766
|
+
"ontologies.publishOntologyVersion",
|
|
19767
|
+
"ontologies.resolveEffectiveOntology",
|
|
19768
|
+
"ontologies.updateOntology",
|
|
19769
|
+
"policy.manageWritePolicy",
|
|
19770
|
+
"questions.archiveQuestion",
|
|
19771
|
+
"questions.createQuestion",
|
|
19772
|
+
"questions.findMissingQuestions",
|
|
19773
|
+
"questions.getFalsificationQuestions",
|
|
19774
|
+
"questions.getHighPriorityQuestions",
|
|
19775
|
+
"questions.getQuestion",
|
|
19776
|
+
"questions.listQuestions",
|
|
19777
|
+
"questions.refineQuestion",
|
|
19778
|
+
"questions.updateQuestionStatus",
|
|
19779
|
+
"tasks.completeTask",
|
|
19780
|
+
"tasks.createTask",
|
|
19781
|
+
"tasks.listTasks",
|
|
19782
|
+
"tasks.updateTask",
|
|
19783
|
+
"topics.createTopic",
|
|
19784
|
+
"topics.getTopic",
|
|
19785
|
+
"topics.getTopicTree",
|
|
19786
|
+
"topics.listTopics",
|
|
19787
|
+
"topics.updateTopic",
|
|
19788
|
+
"worktrees.activateWorktree",
|
|
19789
|
+
"worktrees.addWorktree",
|
|
19790
|
+
"worktrees.beginBuildSession",
|
|
19791
|
+
"worktrees.listAllWorktrees",
|
|
19792
|
+
"worktrees.listCampaigns",
|
|
19793
|
+
"worktrees.listWorktrees",
|
|
19794
|
+
"worktrees.merge",
|
|
19795
|
+
"worktrees.openPullRequest",
|
|
19796
|
+
"worktrees.pipelineSnapshot",
|
|
19797
|
+
"worktrees.push",
|
|
19798
|
+
"worktrees.updateWorktreeMetadata",
|
|
19799
|
+
"worktrees.updateWorktreeTargets"
|
|
19800
|
+
];
|
|
18443
19801
|
var CONTRACTS = {
|
|
18444
19802
|
"activate_worktree": { method: "POST", path: "/worktrees/activate", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
|
|
18445
19803
|
"add_evidence": { method: "POST", path: "/evidence/add", kind: "mutation", idempotent: true, surfaceIntent: "compatibility" },
|
|
@@ -18515,6 +19873,7 @@ var CONTRACTS = {
|
|
|
18515
19873
|
"list_beliefs": { method: "GET", path: "/beliefs", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
18516
19874
|
"list_campaigns": { method: "GET", path: "/worktrees/campaigns", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
18517
19875
|
"list_evidence": { method: "GET", path: "/evidence", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
19876
|
+
"list_graph_intelligence_queries": { method: "POST", path: "/graph-intelligence/queries", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
|
|
18518
19877
|
"list_lenses": { method: "GET", path: "/lenses", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
18519
19878
|
"list_ontologies": { method: "GET", path: "/ontologies", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
18520
19879
|
"list_questions": { method: "GET", path: "/questions", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
@@ -18538,6 +19897,7 @@ var CONTRACTS = {
|
|
|
18538
19897
|
"register_session": { method: "POST", path: "/coordination/register-session", kind: "mutation", idempotent: true, surfaceIntent: "system" },
|
|
18539
19898
|
"remove_lens_from_topic": { method: "DELETE", path: "/lenses/apply", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
|
|
18540
19899
|
"resolve_effective_ontology": { method: "POST", path: "/ontologies/effective", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
|
|
19900
|
+
"run_graph_intelligence_query": { method: "POST", path: "/graph-intelligence/run", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
|
|
18541
19901
|
"search_beliefs": { method: "POST", path: "/beliefs/search", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
18542
19902
|
"search_evidence": { method: "POST", path: "/evidence/search", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
|
|
18543
19903
|
"seed_belief_lattice": { method: "POST", path: "/scope/belief-lattice/seed", kind: "mutation", idempotent: true, surfaceIntent: "system" },
|
|
@@ -18813,6 +20173,9 @@ function createFunctionSurfaceClient(config = {}) {
|
|
|
18813
20173
|
listEvidence(input = {}, idempotencyKey) {
|
|
18814
20174
|
return execute("list_evidence", input, idempotencyKey);
|
|
18815
20175
|
},
|
|
20176
|
+
listGraphIntelligenceQueries(input = {}, idempotencyKey) {
|
|
20177
|
+
return execute("list_graph_intelligence_queries", input, idempotencyKey);
|
|
20178
|
+
},
|
|
18816
20179
|
listLenses(input = {}, idempotencyKey) {
|
|
18817
20180
|
return execute("list_lenses", input, idempotencyKey);
|
|
18818
20181
|
},
|
|
@@ -18882,6 +20245,9 @@ function createFunctionSurfaceClient(config = {}) {
|
|
|
18882
20245
|
resolveEffectiveOntology(input = {}, idempotencyKey) {
|
|
18883
20246
|
return execute("resolve_effective_ontology", input, idempotencyKey);
|
|
18884
20247
|
},
|
|
20248
|
+
runGraphIntelligenceQuery(input = {}, idempotencyKey) {
|
|
20249
|
+
return execute("run_graph_intelligence_query", input, idempotencyKey);
|
|
20250
|
+
},
|
|
18885
20251
|
searchBeliefs(input = {}, idempotencyKey) {
|
|
18886
20252
|
return execute("search_beliefs", input, idempotencyKey);
|
|
18887
20253
|
},
|
|
@@ -22483,105 +23849,1289 @@ function createLucernClient(config = {}) {
|
|
|
22483
23849
|
};
|
|
22484
23850
|
}
|
|
22485
23851
|
|
|
22486
|
-
// ../sdk/src/
|
|
22487
|
-
|
|
22488
|
-
"
|
|
22489
|
-
"workspace",
|
|
22490
|
-
"principal",
|
|
22491
|
-
"tool",
|
|
22492
|
-
"pack",
|
|
22493
|
-
"ontology",
|
|
22494
|
-
"belief",
|
|
22495
|
-
"policy_rule"
|
|
22496
|
-
];
|
|
22497
|
-
function defineCases(cases) {
|
|
22498
|
-
return cases;
|
|
23852
|
+
// ../sdk/src/facade/context.ts
|
|
23853
|
+
function cleanString6(value) {
|
|
23854
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
22499
23855
|
}
|
|
22500
|
-
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
23856
|
+
function cleanNumber2(value) {
|
|
23857
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
23858
|
+
}
|
|
23859
|
+
function cleanBoolean2(value) {
|
|
23860
|
+
return typeof value === "boolean" ? value : void 0;
|
|
23861
|
+
}
|
|
23862
|
+
function buildCompileContextRequest2(topicId, input = {}) {
|
|
23863
|
+
const payload = { topicId };
|
|
23864
|
+
const query5 = cleanString6(input.query);
|
|
23865
|
+
if (query5) {
|
|
23866
|
+
payload.query = query5;
|
|
23867
|
+
}
|
|
23868
|
+
const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
|
|
23869
|
+
if (budget !== void 0) {
|
|
23870
|
+
payload.budget = budget;
|
|
23871
|
+
}
|
|
23872
|
+
const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
|
|
23873
|
+
if (ranking) {
|
|
23874
|
+
payload.ranking = ranking;
|
|
23875
|
+
}
|
|
23876
|
+
const limit = cleanNumber2(input.limit);
|
|
23877
|
+
if (limit !== void 0) {
|
|
23878
|
+
payload.limit = limit;
|
|
23879
|
+
}
|
|
23880
|
+
const maxDepth = cleanNumber2(input.maxDepth);
|
|
23881
|
+
if (maxDepth !== void 0) {
|
|
23882
|
+
payload.maxDepth = maxDepth;
|
|
23883
|
+
}
|
|
23884
|
+
const includeEntities = cleanBoolean2(input.includeEntities);
|
|
23885
|
+
if (includeEntities !== void 0) {
|
|
23886
|
+
payload.includeEntities = includeEntities;
|
|
23887
|
+
}
|
|
23888
|
+
const mode = cleanString6(input.mode);
|
|
23889
|
+
if (mode) {
|
|
23890
|
+
payload.mode = mode;
|
|
23891
|
+
}
|
|
23892
|
+
const includeFailures = cleanBoolean2(input.includeFailures);
|
|
23893
|
+
if (includeFailures !== void 0) {
|
|
23894
|
+
payload.includeFailures = includeFailures;
|
|
23895
|
+
}
|
|
23896
|
+
const worktreeId = cleanString6(input.worktreeId);
|
|
23897
|
+
if (worktreeId) {
|
|
23898
|
+
payload.worktreeId = worktreeId;
|
|
23899
|
+
}
|
|
23900
|
+
const sessionId = cleanString6(input.sessionId);
|
|
23901
|
+
if (sessionId) {
|
|
23902
|
+
payload.sessionId = sessionId;
|
|
23903
|
+
}
|
|
23904
|
+
if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
|
|
23905
|
+
payload.packWeightOverrides = input.packWeightOverrides;
|
|
23906
|
+
}
|
|
23907
|
+
return {
|
|
23908
|
+
path: "/api/platform/v1/context/compile",
|
|
23909
|
+
method: "POST",
|
|
23910
|
+
body: payload
|
|
23911
|
+
};
|
|
23912
|
+
}
|
|
23913
|
+
function createContextFacade(config) {
|
|
23914
|
+
return {
|
|
23915
|
+
compile(topicId, input = {}) {
|
|
23916
|
+
const request = buildCompileContextRequest2(topicId, input);
|
|
23917
|
+
return config.transport.request(request);
|
|
22510
23918
|
}
|
|
22511
|
-
|
|
22512
|
-
|
|
22513
|
-
|
|
22514
|
-
|
|
22515
|
-
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
23919
|
+
};
|
|
23920
|
+
}
|
|
23921
|
+
|
|
23922
|
+
// ../sdk/src/contracts/context-pack.contract.ts
|
|
23923
|
+
var CONTEXT_PACK_SCHEMA_VERSION = "1.0.0";
|
|
23924
|
+
var DEFAULT_COMPILATION_MODE = "standard";
|
|
23925
|
+
var SECTION_BUDGET_RATIOS = {
|
|
23926
|
+
invariants: 0.28,
|
|
23927
|
+
activeBeliefs: 0.3,
|
|
23928
|
+
openQuestions: 0.17,
|
|
23929
|
+
recentEvidence: 0.17,
|
|
23930
|
+
contradictions: 0.08
|
|
23931
|
+
};
|
|
23932
|
+
var MIN_TOKEN_BUDGET = 400;
|
|
23933
|
+
var MAX_TOKEN_BUDGET = 8e3;
|
|
23934
|
+
var DEFAULT_TOKEN_BUDGET = 1800;
|
|
23935
|
+
var MIN_CONTRADICTION_BUDGET = 40;
|
|
23936
|
+
var RANKING_WEIGHTS = {
|
|
23937
|
+
invariants: {
|
|
23938
|
+
query: 0.35,
|
|
23939
|
+
recency: 0.1,
|
|
23940
|
+
confidence: 0.4,
|
|
23941
|
+
beliefType: 0.15
|
|
23942
|
+
},
|
|
23943
|
+
activeBeliefs: {
|
|
23944
|
+
query: 0.5,
|
|
23945
|
+
recency: 0.2,
|
|
23946
|
+
confidence: 0.2,
|
|
23947
|
+
beliefType: 0.1
|
|
23948
|
+
},
|
|
23949
|
+
openQuestions: {
|
|
23950
|
+
query: 0.55,
|
|
23951
|
+
recency: 0.2,
|
|
23952
|
+
priority: 0.25
|
|
23953
|
+
},
|
|
23954
|
+
recentEvidence: {
|
|
23955
|
+
query: 0.6,
|
|
23956
|
+
recency: 0.4
|
|
23957
|
+
},
|
|
23958
|
+
contradictions: {
|
|
23959
|
+
query: 0.4,
|
|
23960
|
+
recency: 0.2,
|
|
23961
|
+
severity: 0.4
|
|
23962
|
+
}
|
|
23963
|
+
};
|
|
23964
|
+
var RECENCY_HALF_LIFE_DAYS = 30;
|
|
23965
|
+
var ENTITY_RANKING_WEIGHTS = {
|
|
23966
|
+
query: 0.4,
|
|
23967
|
+
connectivity: 0.6
|
|
23968
|
+
};
|
|
23969
|
+
var DEFAULT_ENTITY_LIMIT = 10;
|
|
23970
|
+
var MAX_ENTITY_LIMIT = 50;
|
|
23971
|
+
var BELIEF_TYPE_BONUS = {
|
|
23972
|
+
invariant: 1,
|
|
23973
|
+
tenet: 0.8,
|
|
23974
|
+
principle: 0.6
|
|
23975
|
+
};
|
|
23976
|
+
var DEFAULT_BELIEF_TYPE_BONUS = 0.4;
|
|
23977
|
+
var PRIORITY_SCORES = {
|
|
23978
|
+
critical: 1,
|
|
23979
|
+
high: 0.85,
|
|
23980
|
+
medium: 0.55,
|
|
23981
|
+
low: 0.35
|
|
23982
|
+
};
|
|
23983
|
+
var DEFAULT_PRIORITY_SCORE = 0.5;
|
|
23984
|
+
var SEVERITY_SCORES = {
|
|
23985
|
+
critical: 1,
|
|
23986
|
+
high: 0.85,
|
|
23987
|
+
medium: 0.6,
|
|
23988
|
+
low: 0.35
|
|
23989
|
+
};
|
|
23990
|
+
var DEFAULT_SEVERITY_SCORE = 0.5;
|
|
23991
|
+
var TOKENS_PER_WORD = 1.35;
|
|
23992
|
+
var MIN_TOKEN_ESTIMATE = 8;
|
|
23993
|
+
|
|
23994
|
+
// ../sdk/src/contextPackPolicy.ts
|
|
23995
|
+
function nowMs() {
|
|
23996
|
+
return Date.now();
|
|
23997
|
+
}
|
|
23998
|
+
function normalizeText(text) {
|
|
23999
|
+
return text.trim().toLowerCase();
|
|
24000
|
+
}
|
|
24001
|
+
function tokenHits(text, tokens) {
|
|
24002
|
+
if (tokens.length === 0) {
|
|
24003
|
+
return 1;
|
|
24004
|
+
}
|
|
24005
|
+
const haystack = normalizeText(text);
|
|
24006
|
+
let hits = 0;
|
|
24007
|
+
for (const token of tokens) {
|
|
24008
|
+
if (haystack.includes(token)) {
|
|
24009
|
+
hits += 1;
|
|
22521
24010
|
}
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
24011
|
+
}
|
|
24012
|
+
return hits;
|
|
24013
|
+
}
|
|
24014
|
+
function clamp013(value) {
|
|
24015
|
+
if (!Number.isFinite(value)) {
|
|
24016
|
+
return 0;
|
|
24017
|
+
}
|
|
24018
|
+
return Math.max(0, Math.min(1, value));
|
|
24019
|
+
}
|
|
24020
|
+
function recencyScore(updatedAt, referenceTimeMs = nowMs()) {
|
|
24021
|
+
if (!updatedAt || !Number.isFinite(updatedAt)) {
|
|
24022
|
+
return 0.25;
|
|
24023
|
+
}
|
|
24024
|
+
const ageMs = Math.max(0, referenceTimeMs - updatedAt);
|
|
24025
|
+
const ageDays = ageMs / (1e3 * 60 * 60 * 24);
|
|
24026
|
+
const decay = 0.5 ** (ageDays / RECENCY_HALF_LIFE_DAYS);
|
|
24027
|
+
return clamp013(decay);
|
|
24028
|
+
}
|
|
24029
|
+
function confidenceScore(confidence) {
|
|
24030
|
+
if (typeof confidence !== "number" || !Number.isFinite(confidence)) {
|
|
24031
|
+
return 0.5;
|
|
24032
|
+
}
|
|
24033
|
+
return clamp013(confidence);
|
|
24034
|
+
}
|
|
24035
|
+
function priorityScore(priority) {
|
|
24036
|
+
const value = normalizeText(priority || "");
|
|
24037
|
+
return PRIORITY_SCORES[value] ?? DEFAULT_PRIORITY_SCORE;
|
|
24038
|
+
}
|
|
24039
|
+
function severityScore(severity) {
|
|
24040
|
+
const value = normalizeText(severity || "");
|
|
24041
|
+
return SEVERITY_SCORES[value] ?? DEFAULT_SEVERITY_SCORE;
|
|
24042
|
+
}
|
|
24043
|
+
function beliefTypeBonus(beliefType) {
|
|
24044
|
+
const value = normalizeText(beliefType || "");
|
|
24045
|
+
return BELIEF_TYPE_BONUS[value] ?? DEFAULT_BELIEF_TYPE_BONUS;
|
|
24046
|
+
}
|
|
24047
|
+
function resolveEffectiveWeights(overrides) {
|
|
24048
|
+
if (!overrides || overrides.length === 0) {
|
|
24049
|
+
return RANKING_WEIGHTS;
|
|
24050
|
+
}
|
|
24051
|
+
const result = { ...RANKING_WEIGHTS };
|
|
24052
|
+
for (const override of overrides) {
|
|
24053
|
+
const base = RANKING_WEIGHTS[override.section];
|
|
24054
|
+
if (base) {
|
|
24055
|
+
result[override.section] = { ...base, ...override.weights };
|
|
22532
24056
|
}
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22539
|
-
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
|
|
22551
|
-
|
|
24057
|
+
}
|
|
24058
|
+
return result;
|
|
24059
|
+
}
|
|
24060
|
+
function generateJustification(_section, candidate, queryTokens, weights) {
|
|
24061
|
+
const parts = [];
|
|
24062
|
+
const hits = tokenHits(candidate.text, queryTokens);
|
|
24063
|
+
if (queryTokens.length > 0 && hits > 0) {
|
|
24064
|
+
parts.push(`${hits}/${queryTokens.length} query terms matched`);
|
|
24065
|
+
} else if (queryTokens.length === 0) {
|
|
24066
|
+
parts.push("no query filter");
|
|
24067
|
+
}
|
|
24068
|
+
const ts = candidate.updatedAt || candidate.createdAt || null;
|
|
24069
|
+
if (ts && Number.isFinite(ts)) {
|
|
24070
|
+
const ageDays = Math.max(0, nowMs() - ts) / (1e3 * 60 * 60 * 24);
|
|
24071
|
+
if (ageDays < 1) {
|
|
24072
|
+
parts.push("updated today");
|
|
24073
|
+
} else if (ageDays < 7) {
|
|
24074
|
+
parts.push(`updated ${Math.floor(ageDays)}d ago`);
|
|
24075
|
+
} else if (ageDays < 30) {
|
|
24076
|
+
parts.push(`updated ${Math.floor(ageDays / 7)}w ago`);
|
|
24077
|
+
} else {
|
|
24078
|
+
parts.push(`updated ${Math.floor(ageDays)}d ago (decayed)`);
|
|
22552
24079
|
}
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
{
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22562
|
-
|
|
22563
|
-
|
|
22564
|
-
{
|
|
22565
|
-
|
|
22566
|
-
|
|
22567
|
-
|
|
22568
|
-
|
|
22569
|
-
|
|
22570
|
-
|
|
22571
|
-
|
|
24080
|
+
}
|
|
24081
|
+
if (weights.confidence !== void 0 && candidate.confidence !== null && candidate.confidence !== void 0) {
|
|
24082
|
+
parts.push(`confidence=${candidate.confidence.toFixed(2)}`);
|
|
24083
|
+
}
|
|
24084
|
+
if (weights.beliefType !== void 0 && candidate.beliefType) {
|
|
24085
|
+
parts.push(`type=${candidate.beliefType}`);
|
|
24086
|
+
}
|
|
24087
|
+
if (weights.priority !== void 0 && candidate.priority) {
|
|
24088
|
+
parts.push(`priority=${candidate.priority}`);
|
|
24089
|
+
}
|
|
24090
|
+
if (weights.severity !== void 0 && candidate.severity) {
|
|
24091
|
+
parts.push(`severity=${candidate.severity}`);
|
|
24092
|
+
}
|
|
24093
|
+
return parts.join(", ");
|
|
24094
|
+
}
|
|
24095
|
+
function computeBaselineScore(candidate, queryTokens) {
|
|
24096
|
+
const hits = tokenHits(candidate.text, queryTokens);
|
|
24097
|
+
return queryTokens.length === 0 ? 1 : hits;
|
|
24098
|
+
}
|
|
24099
|
+
function computeWeightedScore(section, candidate, queryTokens, effectiveWeights, referenceTimeMs) {
|
|
24100
|
+
const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
|
|
24101
|
+
const queryComponent = queryTokens.length === 0 ? 0.4 : clamp013(tokenHits(candidate.text, queryTokens) / queryTokens.length);
|
|
24102
|
+
const recencyComponent = recencyScore(
|
|
24103
|
+
candidate.updatedAt || candidate.createdAt || null,
|
|
24104
|
+
referenceTimeMs
|
|
24105
|
+
);
|
|
24106
|
+
let score = queryComponent * weights.query + recencyComponent * weights.recency;
|
|
24107
|
+
if (weights.confidence !== void 0) {
|
|
24108
|
+
score += confidenceScore(candidate.confidence) * weights.confidence;
|
|
24109
|
+
}
|
|
24110
|
+
if (weights.beliefType !== void 0) {
|
|
24111
|
+
score += beliefTypeBonus(candidate.beliefType) * weights.beliefType;
|
|
24112
|
+
}
|
|
24113
|
+
if (weights.priority !== void 0) {
|
|
24114
|
+
score += priorityScore(candidate.priority) * weights.priority;
|
|
24115
|
+
}
|
|
24116
|
+
if (weights.severity !== void 0) {
|
|
24117
|
+
score += severityScore(candidate.severity) * weights.severity;
|
|
24118
|
+
}
|
|
24119
|
+
return score;
|
|
24120
|
+
}
|
|
24121
|
+
function rankContextSection(section, rows, queryTokens, limit, profile, options) {
|
|
24122
|
+
const effectiveWeights = options?.effectiveWeights;
|
|
24123
|
+
const includeJustifications = options?.includeJustifications ?? false;
|
|
24124
|
+
const referenceTimeMs = options?.referenceTimeMs;
|
|
24125
|
+
const scored = rows.map((row) => {
|
|
24126
|
+
const score = profile === "weighted_v1" ? computeWeightedScore(
|
|
24127
|
+
section,
|
|
24128
|
+
row,
|
|
24129
|
+
queryTokens,
|
|
24130
|
+
effectiveWeights,
|
|
24131
|
+
referenceTimeMs
|
|
24132
|
+
) : computeBaselineScore(row, queryTokens);
|
|
24133
|
+
const result = { ...row, score };
|
|
24134
|
+
if (includeJustifications && profile === "weighted_v1") {
|
|
24135
|
+
const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
|
|
24136
|
+
result.justification = generateJustification(section, row, queryTokens, weights);
|
|
24137
|
+
}
|
|
24138
|
+
return result;
|
|
24139
|
+
});
|
|
24140
|
+
const filtered = queryTokens.length === 0 ? scored : scored.filter((row) => row.score > 0);
|
|
24141
|
+
filtered.sort((left, right) => {
|
|
24142
|
+
if (right.score !== left.score) {
|
|
24143
|
+
return right.score - left.score;
|
|
24144
|
+
}
|
|
24145
|
+
const rightTs = right.updatedAt || right.createdAt || 0;
|
|
24146
|
+
const leftTs = left.updatedAt || left.createdAt || 0;
|
|
24147
|
+
return rightTs - leftTs;
|
|
24148
|
+
});
|
|
24149
|
+
return filtered.slice(0, limit);
|
|
24150
|
+
}
|
|
24151
|
+
function parseTokenBudget(value, fallback = DEFAULT_TOKEN_BUDGET) {
|
|
24152
|
+
const parsed = typeof value === "number" && Number.isFinite(value) ? Math.floor(value) : fallback;
|
|
24153
|
+
return Math.max(MIN_TOKEN_BUDGET, Math.min(MAX_TOKEN_BUDGET, parsed));
|
|
24154
|
+
}
|
|
24155
|
+
function estimateTokens(text) {
|
|
24156
|
+
const words = text.trim().split(/\s+/).filter(Boolean).length;
|
|
24157
|
+
return Math.max(MIN_TOKEN_ESTIMATE, Math.ceil(words * TOKENS_PER_WORD));
|
|
24158
|
+
}
|
|
24159
|
+
function buildInjectionPlan(args) {
|
|
24160
|
+
const tokenBudget = parseTokenBudget(args.tokenBudget);
|
|
24161
|
+
const trackExclusions = args.trackExclusions ?? false;
|
|
24162
|
+
const sectionBudgets = {
|
|
24163
|
+
invariants: Math.floor(tokenBudget * SECTION_BUDGET_RATIOS.invariants),
|
|
24164
|
+
activeBeliefs: Math.floor(
|
|
24165
|
+
tokenBudget * SECTION_BUDGET_RATIOS.activeBeliefs
|
|
24166
|
+
),
|
|
24167
|
+
openQuestions: Math.floor(
|
|
24168
|
+
tokenBudget * SECTION_BUDGET_RATIOS.openQuestions
|
|
24169
|
+
),
|
|
24170
|
+
recentEvidence: Math.floor(
|
|
24171
|
+
tokenBudget * SECTION_BUDGET_RATIOS.recentEvidence
|
|
24172
|
+
),
|
|
24173
|
+
contradictions: Math.max(
|
|
24174
|
+
MIN_CONTRADICTION_BUDGET,
|
|
24175
|
+
Math.floor(tokenBudget * SECTION_BUDGET_RATIOS.contradictions)
|
|
24176
|
+
)
|
|
24177
|
+
};
|
|
24178
|
+
const selected = {
|
|
24179
|
+
invariants: [],
|
|
24180
|
+
activeBeliefs: [],
|
|
24181
|
+
openQuestions: [],
|
|
24182
|
+
recentEvidence: [],
|
|
24183
|
+
contradictions: []
|
|
24184
|
+
};
|
|
24185
|
+
const sectionUsage = {
|
|
24186
|
+
invariants: 0,
|
|
24187
|
+
activeBeliefs: 0,
|
|
24188
|
+
openQuestions: 0,
|
|
24189
|
+
recentEvidence: 0,
|
|
24190
|
+
contradictions: 0
|
|
24191
|
+
};
|
|
24192
|
+
const excludedItems = [];
|
|
24193
|
+
const pushItem = (section, id, text, score) => {
|
|
24194
|
+
const itemTokens = estimateTokens(text);
|
|
24195
|
+
const nextUsage = sectionUsage[section] + itemTokens;
|
|
24196
|
+
if (nextUsage > sectionBudgets[section]) {
|
|
24197
|
+
if (trackExclusions) {
|
|
24198
|
+
excludedItems.push({
|
|
24199
|
+
id,
|
|
24200
|
+
section,
|
|
24201
|
+
reason: "budget_exceeded",
|
|
24202
|
+
score: score ?? 0
|
|
24203
|
+
});
|
|
24204
|
+
}
|
|
24205
|
+
return;
|
|
22572
24206
|
}
|
|
22573
|
-
|
|
22574
|
-
|
|
22575
|
-
|
|
22576
|
-
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22580
|
-
|
|
22581
|
-
|
|
22582
|
-
|
|
22583
|
-
|
|
22584
|
-
|
|
24207
|
+
selected[section].push(id);
|
|
24208
|
+
sectionUsage[section] = nextUsage;
|
|
24209
|
+
};
|
|
24210
|
+
for (const row of args.invariants) {
|
|
24211
|
+
pushItem("invariants", row.nodeId, row.canonicalText, row.score);
|
|
24212
|
+
}
|
|
24213
|
+
for (const row of args.activeBeliefs) {
|
|
24214
|
+
pushItem("activeBeliefs", row.nodeId, row.canonicalText, row.score);
|
|
24215
|
+
}
|
|
24216
|
+
for (const row of args.openQuestions) {
|
|
24217
|
+
pushItem("openQuestions", row.questionId, row.text, row.score);
|
|
24218
|
+
}
|
|
24219
|
+
for (const row of args.recentEvidence) {
|
|
24220
|
+
pushItem("recentEvidence", row.nodeId, row.canonicalText, row.score);
|
|
24221
|
+
}
|
|
24222
|
+
for (const row of args.contradictions) {
|
|
24223
|
+
pushItem("contradictions", row.contradictionId, row.description, row.score);
|
|
24224
|
+
}
|
|
24225
|
+
const estimatedTokens = sectionUsage.invariants + sectionUsage.activeBeliefs + sectionUsage.openQuestions + sectionUsage.recentEvidence + sectionUsage.contradictions;
|
|
24226
|
+
return {
|
|
24227
|
+
tokenBudget,
|
|
24228
|
+
estimatedTokens,
|
|
24229
|
+
sectionBudgets,
|
|
24230
|
+
sectionUsage,
|
|
24231
|
+
selected,
|
|
24232
|
+
...trackExclusions ? { excludedItems } : {}
|
|
24233
|
+
};
|
|
24234
|
+
}
|
|
24235
|
+
function rankEntities(candidates, queryTokens, limit) {
|
|
24236
|
+
if (candidates.length === 0) {
|
|
24237
|
+
return [];
|
|
24238
|
+
}
|
|
24239
|
+
const effectiveLimit = Math.max(
|
|
24240
|
+
1,
|
|
24241
|
+
Math.min(limit ?? DEFAULT_ENTITY_LIMIT, MAX_ENTITY_LIMIT)
|
|
24242
|
+
);
|
|
24243
|
+
const maxConnections = Math.max(
|
|
24244
|
+
1,
|
|
24245
|
+
...candidates.map(
|
|
24246
|
+
(candidate) => candidate.connectedBeliefCount + candidate.connectedEvidenceCount
|
|
24247
|
+
)
|
|
24248
|
+
);
|
|
24249
|
+
const scored = candidates.map((candidate) => {
|
|
24250
|
+
const searchText = `${candidate.title} ${candidate.entityType} ${candidate.canonicalText}`;
|
|
24251
|
+
const queryScore = queryTokens.length === 0 ? 0.4 : clamp013(tokenHits(searchText, queryTokens) / queryTokens.length);
|
|
24252
|
+
const totalConnections = candidate.connectedBeliefCount + candidate.connectedEvidenceCount;
|
|
24253
|
+
const connectivityScore = clamp013(totalConnections / maxConnections);
|
|
24254
|
+
const score = queryScore * ENTITY_RANKING_WEIGHTS.query + connectivityScore * ENTITY_RANKING_WEIGHTS.connectivity;
|
|
24255
|
+
return { ...candidate, score };
|
|
24256
|
+
});
|
|
24257
|
+
scored.sort((left, right) => {
|
|
24258
|
+
if (right.score !== left.score) {
|
|
24259
|
+
return right.score - left.score;
|
|
24260
|
+
}
|
|
24261
|
+
const rightConn = right.connectedBeliefCount + right.connectedEvidenceCount;
|
|
24262
|
+
const leftConn = left.connectedBeliefCount + left.connectedEvidenceCount;
|
|
24263
|
+
return rightConn - leftConn;
|
|
24264
|
+
});
|
|
24265
|
+
return scored.slice(0, effectiveLimit);
|
|
24266
|
+
}
|
|
24267
|
+
|
|
24268
|
+
// ../sdk/src/contextPackSchema.ts
|
|
24269
|
+
var CONTEXT_PACK_SCHEMA_VERSION2 = "1.0.0";
|
|
24270
|
+
function isObject(value) {
|
|
24271
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24272
|
+
}
|
|
24273
|
+
function isString(value) {
|
|
24274
|
+
return typeof value === "string";
|
|
24275
|
+
}
|
|
24276
|
+
function isNumber(value) {
|
|
24277
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
24278
|
+
}
|
|
24279
|
+
function isNullableNumber(value) {
|
|
24280
|
+
return value === null || isNumber(value);
|
|
24281
|
+
}
|
|
24282
|
+
function isStringArray(value) {
|
|
24283
|
+
return Array.isArray(value) && value.every((entry) => isString(entry));
|
|
24284
|
+
}
|
|
24285
|
+
function requireObject(parent, key, errors) {
|
|
24286
|
+
const value = parent[key];
|
|
24287
|
+
if (!isObject(value)) {
|
|
24288
|
+
errors.push(`Expected '${key}' to be an object`);
|
|
24289
|
+
return null;
|
|
24290
|
+
}
|
|
24291
|
+
return value;
|
|
24292
|
+
}
|
|
24293
|
+
function validateBeliefArray(key, value, errors) {
|
|
24294
|
+
if (!Array.isArray(value)) {
|
|
24295
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24296
|
+
return;
|
|
24297
|
+
}
|
|
24298
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24299
|
+
const row = value[index];
|
|
24300
|
+
if (!isObject(row)) {
|
|
24301
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24302
|
+
continue;
|
|
24303
|
+
}
|
|
24304
|
+
if (!isString(row.nodeId)) {
|
|
24305
|
+
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
24306
|
+
}
|
|
24307
|
+
if (!isString(row.canonicalText)) {
|
|
24308
|
+
errors.push(`Expected '${key}[${index}].canonicalText' to be a string`);
|
|
24309
|
+
}
|
|
24310
|
+
if (!isNullableNumber(row.confidence)) {
|
|
24311
|
+
errors.push(`Expected '${key}[${index}].confidence' to be number|null`);
|
|
24312
|
+
}
|
|
24313
|
+
}
|
|
24314
|
+
}
|
|
24315
|
+
function validateQuestionArray(key, value, errors) {
|
|
24316
|
+
if (!Array.isArray(value)) {
|
|
24317
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24318
|
+
return;
|
|
24319
|
+
}
|
|
24320
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24321
|
+
const row = value[index];
|
|
24322
|
+
if (!isObject(row)) {
|
|
24323
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24324
|
+
continue;
|
|
24325
|
+
}
|
|
24326
|
+
if (!isString(row.questionId)) {
|
|
24327
|
+
errors.push(`Expected '${key}[${index}].questionId' to be a string`);
|
|
24328
|
+
}
|
|
24329
|
+
if (!isString(row.text)) {
|
|
24330
|
+
errors.push(`Expected '${key}[${index}].text' to be a string`);
|
|
24331
|
+
}
|
|
24332
|
+
if (!isString(row.status)) {
|
|
24333
|
+
errors.push(`Expected '${key}[${index}].status' to be a string`);
|
|
24334
|
+
}
|
|
24335
|
+
}
|
|
24336
|
+
}
|
|
24337
|
+
function validateEvidenceArray(key, value, errors) {
|
|
24338
|
+
if (!Array.isArray(value)) {
|
|
24339
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24340
|
+
return;
|
|
24341
|
+
}
|
|
24342
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24343
|
+
const row = value[index];
|
|
24344
|
+
if (!isObject(row)) {
|
|
24345
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24346
|
+
continue;
|
|
24347
|
+
}
|
|
24348
|
+
if (!isString(row.nodeId)) {
|
|
24349
|
+
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
24350
|
+
}
|
|
24351
|
+
if (!isString(row.canonicalText)) {
|
|
24352
|
+
errors.push(`Expected '${key}[${index}].canonicalText' to be a string`);
|
|
24353
|
+
}
|
|
24354
|
+
}
|
|
24355
|
+
}
|
|
24356
|
+
function validateEntityArray(key, value, errors) {
|
|
24357
|
+
if (!Array.isArray(value)) {
|
|
24358
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24359
|
+
return;
|
|
24360
|
+
}
|
|
24361
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24362
|
+
const row = value[index];
|
|
24363
|
+
if (!isObject(row)) {
|
|
24364
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24365
|
+
continue;
|
|
24366
|
+
}
|
|
24367
|
+
if (!isString(row.nodeId)) {
|
|
24368
|
+
errors.push(`Expected '${key}[${index}].nodeId' to be a string`);
|
|
24369
|
+
}
|
|
24370
|
+
if (!isString(row.entityType)) {
|
|
24371
|
+
errors.push(`Expected '${key}[${index}].entityType' to be a string`);
|
|
24372
|
+
}
|
|
24373
|
+
if (!isString(row.title)) {
|
|
24374
|
+
errors.push(`Expected '${key}[${index}].title' to be a string`);
|
|
24375
|
+
}
|
|
24376
|
+
if (!isNumber(row.connectedBeliefCount)) {
|
|
24377
|
+
errors.push(`Expected '${key}[${index}].connectedBeliefCount' to be a number`);
|
|
24378
|
+
}
|
|
24379
|
+
if (!isNumber(row.connectedEvidenceCount)) {
|
|
24380
|
+
errors.push(`Expected '${key}[${index}].connectedEvidenceCount' to be a number`);
|
|
24381
|
+
}
|
|
24382
|
+
if (!isNumber(row.score)) {
|
|
24383
|
+
errors.push(`Expected '${key}[${index}].score' to be a number`);
|
|
24384
|
+
}
|
|
24385
|
+
}
|
|
24386
|
+
}
|
|
24387
|
+
function validateContradictionArray(key, value, errors) {
|
|
24388
|
+
if (!Array.isArray(value)) {
|
|
24389
|
+
errors.push(`Expected '${key}' to be an array`);
|
|
24390
|
+
return;
|
|
24391
|
+
}
|
|
24392
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24393
|
+
const row = value[index];
|
|
24394
|
+
if (!isObject(row)) {
|
|
24395
|
+
errors.push(`Expected '${key}[${index}]' to be an object`);
|
|
24396
|
+
continue;
|
|
24397
|
+
}
|
|
24398
|
+
if (!isString(row.contradictionId)) {
|
|
24399
|
+
errors.push(`Expected '${key}[${index}].contradictionId' to be a string`);
|
|
24400
|
+
}
|
|
24401
|
+
if (!isString(row.status)) {
|
|
24402
|
+
errors.push(`Expected '${key}[${index}].status' to be a string`);
|
|
24403
|
+
}
|
|
24404
|
+
}
|
|
24405
|
+
}
|
|
24406
|
+
function validateContextPackSchema(payload) {
|
|
24407
|
+
const errors = [];
|
|
24408
|
+
if (!isObject(payload)) {
|
|
24409
|
+
return {
|
|
24410
|
+
valid: false,
|
|
24411
|
+
errors: ["Expected context pack payload to be an object"]
|
|
24412
|
+
};
|
|
24413
|
+
}
|
|
24414
|
+
if (payload.schemaVersion !== CONTEXT_PACK_SCHEMA_VERSION2) {
|
|
24415
|
+
errors.push(
|
|
24416
|
+
`Expected schemaVersion='${CONTEXT_PACK_SCHEMA_VERSION2}', received '${String(
|
|
24417
|
+
payload.schemaVersion
|
|
24418
|
+
)}'`
|
|
24419
|
+
);
|
|
24420
|
+
}
|
|
24421
|
+
if (!isString(payload.topicId)) {
|
|
24422
|
+
errors.push("Expected 'topicId' to be a string");
|
|
24423
|
+
}
|
|
24424
|
+
if (!isString(payload.topicName)) {
|
|
24425
|
+
errors.push("Expected 'topicName' to be a string");
|
|
24426
|
+
}
|
|
24427
|
+
if (!isStringArray(payload.scopedTopicIds)) {
|
|
24428
|
+
errors.push("Expected 'scopedTopicIds' to be string[]");
|
|
24429
|
+
}
|
|
24430
|
+
if (!isNumber(payload.generatedAt)) {
|
|
24431
|
+
errors.push("Expected 'generatedAt' to be a number");
|
|
24432
|
+
}
|
|
24433
|
+
if (!isString(payload.ranking)) {
|
|
24434
|
+
errors.push("Expected 'ranking' to be a string");
|
|
24435
|
+
}
|
|
24436
|
+
validateBeliefArray("invariants", payload.invariants, errors);
|
|
24437
|
+
validateBeliefArray("activeBeliefs", payload.activeBeliefs, errors);
|
|
24438
|
+
validateQuestionArray("openQuestions", payload.openQuestions, errors);
|
|
24439
|
+
validateEvidenceArray("recentEvidence", payload.recentEvidence, errors);
|
|
24440
|
+
validateContradictionArray("contradictions", payload.contradictions, errors);
|
|
24441
|
+
if (payload.relatedEntities !== void 0 && payload.relatedEntities !== null) {
|
|
24442
|
+
validateEntityArray("relatedEntities", payload.relatedEntities, errors);
|
|
24443
|
+
}
|
|
24444
|
+
if (!Array.isArray(payload.contextNarrative)) {
|
|
24445
|
+
errors.push("Expected 'contextNarrative' to be an array");
|
|
24446
|
+
}
|
|
24447
|
+
const injectionPolicy = requireObject(payload, "injectionPolicy", errors);
|
|
24448
|
+
if (injectionPolicy) {
|
|
24449
|
+
if (!isNumber(injectionPolicy.tokenBudget)) {
|
|
24450
|
+
errors.push("Expected 'injectionPolicy.tokenBudget' to be a number");
|
|
24451
|
+
}
|
|
24452
|
+
if (!isNumber(injectionPolicy.estimatedTokens)) {
|
|
24453
|
+
errors.push("Expected 'injectionPolicy.estimatedTokens' to be a number");
|
|
24454
|
+
}
|
|
24455
|
+
}
|
|
24456
|
+
if (!isObject(payload.summary)) {
|
|
24457
|
+
errors.push("Expected 'summary' to be an object");
|
|
24458
|
+
}
|
|
24459
|
+
if (!isObject(payload.diagnostics)) {
|
|
24460
|
+
errors.push("Expected 'diagnostics' to be an object");
|
|
24461
|
+
}
|
|
24462
|
+
return {
|
|
24463
|
+
valid: errors.length === 0,
|
|
24464
|
+
errors
|
|
24465
|
+
};
|
|
24466
|
+
}
|
|
24467
|
+
|
|
24468
|
+
// ../sdk/src/contextPackCompiler.ts
|
|
24469
|
+
function assertContextPackSchema(payload) {
|
|
24470
|
+
const result = validateContextPackSchema(payload);
|
|
24471
|
+
if (!result.valid) {
|
|
24472
|
+
throw new Error(
|
|
24473
|
+
`Invalid context pack payload: ${result.errors.join("; ")}`
|
|
24474
|
+
);
|
|
24475
|
+
}
|
|
24476
|
+
}
|
|
24477
|
+
function asStringArray(value) {
|
|
24478
|
+
if (!Array.isArray(value)) {
|
|
24479
|
+
return [];
|
|
24480
|
+
}
|
|
24481
|
+
return value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
24482
|
+
}
|
|
24483
|
+
function toPositiveInt(value, fallback, max) {
|
|
24484
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
24485
|
+
return fallback;
|
|
24486
|
+
}
|
|
24487
|
+
const floored = Math.floor(value);
|
|
24488
|
+
return Math.max(1, Math.min(floored, max));
|
|
24489
|
+
}
|
|
24490
|
+
function normalizeQueryTokens(query5) {
|
|
24491
|
+
if (!query5) {
|
|
24492
|
+
return [];
|
|
24493
|
+
}
|
|
24494
|
+
return query5.toLowerCase().split(/[^a-z0-9]+/).map((token) => token.trim()).filter((token) => token.length >= 2);
|
|
24495
|
+
}
|
|
24496
|
+
function parseRankingProfile(value) {
|
|
24497
|
+
return value === "baseline_v1" ? "baseline_v1" : "weighted_v1";
|
|
24498
|
+
}
|
|
24499
|
+
function beliefTypeOf(node) {
|
|
24500
|
+
if (typeof node.beliefType === "string") {
|
|
24501
|
+
return node.beliefType;
|
|
24502
|
+
}
|
|
24503
|
+
const metadata = node.metadata || {};
|
|
24504
|
+
if (typeof metadata.beliefType === "string") {
|
|
24505
|
+
return metadata.beliefType;
|
|
24506
|
+
}
|
|
24507
|
+
return "";
|
|
24508
|
+
}
|
|
24509
|
+
function questionStatusOf(node) {
|
|
24510
|
+
const metadata = node.metadata || {};
|
|
24511
|
+
const direct = typeof node.status === "string" ? node.status : "";
|
|
24512
|
+
const questionStatus = typeof metadata.questionStatus === "string" ? metadata.questionStatus : "";
|
|
24513
|
+
return (questionStatus || direct || "open").toLowerCase();
|
|
24514
|
+
}
|
|
24515
|
+
function isOpenQuestion(status) {
|
|
24516
|
+
return ![
|
|
24517
|
+
"answered",
|
|
24518
|
+
"archived",
|
|
24519
|
+
"closed",
|
|
24520
|
+
"resolved",
|
|
24521
|
+
"resolved_support",
|
|
24522
|
+
"resolved_contra",
|
|
24523
|
+
"belief_forked"
|
|
24524
|
+
].includes(status);
|
|
24525
|
+
}
|
|
24526
|
+
function metadataText(payload) {
|
|
24527
|
+
return JSON.stringify(payload).toLowerCase();
|
|
24528
|
+
}
|
|
24529
|
+
function collectTopicNeighborhood(topics2, rootTopicId, maxDescendantDepth = 2) {
|
|
24530
|
+
const byId = /* @__PURE__ */ new Map();
|
|
24531
|
+
const children = /* @__PURE__ */ new Map();
|
|
24532
|
+
for (const topic of topics2) {
|
|
24533
|
+
const id = String(topic._id);
|
|
24534
|
+
byId.set(id, topic);
|
|
24535
|
+
if (!children.has(id)) {
|
|
24536
|
+
children.set(id, []);
|
|
24537
|
+
}
|
|
24538
|
+
}
|
|
24539
|
+
for (const topic of topics2) {
|
|
24540
|
+
if (!topic.parentTopicId) {
|
|
24541
|
+
continue;
|
|
24542
|
+
}
|
|
24543
|
+
const parent = String(topic.parentTopicId);
|
|
24544
|
+
const id = String(topic._id);
|
|
24545
|
+
const list = children.get(parent) || [];
|
|
24546
|
+
list.push(id);
|
|
24547
|
+
children.set(parent, list);
|
|
24548
|
+
}
|
|
24549
|
+
const selected = /* @__PURE__ */ new Set([rootTopicId]);
|
|
24550
|
+
let cursor = byId.get(rootTopicId);
|
|
24551
|
+
while (cursor?.parentTopicId) {
|
|
24552
|
+
const parentId = String(cursor.parentTopicId);
|
|
24553
|
+
if (selected.has(parentId)) {
|
|
24554
|
+
break;
|
|
24555
|
+
}
|
|
24556
|
+
selected.add(parentId);
|
|
24557
|
+
cursor = byId.get(parentId);
|
|
24558
|
+
}
|
|
24559
|
+
const queue = [
|
|
24560
|
+
{ id: rootTopicId, depth: 0 }
|
|
24561
|
+
];
|
|
24562
|
+
while (queue.length > 0) {
|
|
24563
|
+
const current = queue.shift();
|
|
24564
|
+
if (!current || current.depth >= maxDescendantDepth) {
|
|
24565
|
+
continue;
|
|
24566
|
+
}
|
|
24567
|
+
for (const childId of children.get(current.id) || []) {
|
|
24568
|
+
if (!selected.has(childId)) {
|
|
24569
|
+
selected.add(childId);
|
|
24570
|
+
}
|
|
24571
|
+
queue.push({ id: childId, depth: current.depth + 1 });
|
|
24572
|
+
}
|
|
24573
|
+
}
|
|
24574
|
+
return Array.from(selected);
|
|
24575
|
+
}
|
|
24576
|
+
function dedupeById(rows) {
|
|
24577
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24578
|
+
const output = [];
|
|
24579
|
+
for (const row of rows) {
|
|
24580
|
+
const id = row?._id ? String(row._id) : "";
|
|
24581
|
+
if (!id || seen.has(id)) {
|
|
24582
|
+
continue;
|
|
24583
|
+
}
|
|
24584
|
+
seen.add(id);
|
|
24585
|
+
output.push(row);
|
|
24586
|
+
}
|
|
24587
|
+
return output;
|
|
24588
|
+
}
|
|
24589
|
+
function candidateTimestamp(candidate) {
|
|
24590
|
+
if (!candidate || typeof candidate !== "object") {
|
|
24591
|
+
return 0;
|
|
24592
|
+
}
|
|
24593
|
+
const record = candidate;
|
|
24594
|
+
const timestamps = [record.updatedAt, record.createdAt, record.generatedAt].filter(
|
|
24595
|
+
(value) => typeof value === "number" && Number.isFinite(value)
|
|
24596
|
+
);
|
|
24597
|
+
return timestamps.length > 0 ? Math.max(...timestamps) : 0;
|
|
24598
|
+
}
|
|
24599
|
+
function resolveReferenceTimeMs(...collections) {
|
|
24600
|
+
let maxTimestamp = 0;
|
|
24601
|
+
for (const collection of collections) {
|
|
24602
|
+
for (const item of collection) {
|
|
24603
|
+
const timestamp = candidateTimestamp(item);
|
|
24604
|
+
if (timestamp > maxTimestamp) {
|
|
24605
|
+
maxTimestamp = timestamp;
|
|
24606
|
+
}
|
|
24607
|
+
}
|
|
24608
|
+
}
|
|
24609
|
+
return maxTimestamp;
|
|
24610
|
+
}
|
|
24611
|
+
function planContextPackCompilation(input) {
|
|
24612
|
+
const args = input.args ?? {};
|
|
24613
|
+
const topicId = String(input.topic._id);
|
|
24614
|
+
const queryText = typeof args.query === "string" && args.query.trim().length > 0 ? args.query.trim() : void 0;
|
|
24615
|
+
const tokens = normalizeQueryTokens(queryText);
|
|
24616
|
+
const limit = toPositiveInt(args.limit, 8, 25);
|
|
24617
|
+
const rankingProfile = parseRankingProfile(
|
|
24618
|
+
typeof args.ranking === "string" ? args.ranking : args.rankingProfile
|
|
24619
|
+
);
|
|
24620
|
+
const tokenBudget = parseTokenBudget(
|
|
24621
|
+
typeof args.budget === "number" ? args.budget : args.tokenBudget,
|
|
24622
|
+
1800
|
|
24623
|
+
);
|
|
24624
|
+
const topicDepth = typeof input.topic.depth === "number" && Number.isFinite(input.topic.depth) ? input.topic.depth : 0;
|
|
24625
|
+
const requestedMaxDepth = typeof args.maxDepth === "number" && Number.isFinite(args.maxDepth) ? Math.max(1, Math.min(Math.floor(args.maxDepth), 6)) : void 0;
|
|
24626
|
+
const descendantDepth = requestedMaxDepth ?? (topicDepth <= 1 ? 4 : 2);
|
|
24627
|
+
const includeEntities = args.includeEntities !== false;
|
|
24628
|
+
const compilationMode = args.mode === "delta" ? "delta" : DEFAULT_COMPILATION_MODE;
|
|
24629
|
+
const includeFailures = compilationMode === "delta" || args.includeFailures === true;
|
|
24630
|
+
const worktreeId = typeof args.worktreeId === "string" && args.worktreeId.trim().length > 0 ? args.worktreeId.trim() : void 0;
|
|
24631
|
+
const sessionId = typeof args.sessionId === "string" && args.sessionId.trim().length > 0 ? args.sessionId.trim() : void 0;
|
|
24632
|
+
const packWeightOverrides = Array.isArray(args.packWeightOverrides) ? args.packWeightOverrides : void 0;
|
|
24633
|
+
const effectiveWeights = resolveEffectiveWeights(packWeightOverrides);
|
|
24634
|
+
let scopedTopicIds = collectTopicNeighborhood(
|
|
24635
|
+
input.allTopics,
|
|
24636
|
+
topicId,
|
|
24637
|
+
descendantDepth
|
|
24638
|
+
);
|
|
24639
|
+
const allowedTopicIds = asStringArray(args.allowedTopicIds);
|
|
24640
|
+
if (allowedTopicIds.length > 0) {
|
|
24641
|
+
const allowedSet = new Set(allowedTopicIds);
|
|
24642
|
+
if (!allowedSet.has(topicId)) {
|
|
24643
|
+
throw new Error(`Access denied to compile context for topic ${topicId}.`);
|
|
24644
|
+
}
|
|
24645
|
+
scopedTopicIds = scopedTopicIds.filter((id) => allowedSet.has(id));
|
|
24646
|
+
}
|
|
24647
|
+
return {
|
|
24648
|
+
topicId,
|
|
24649
|
+
...queryText ? { queryText } : {},
|
|
24650
|
+
tokens,
|
|
24651
|
+
limit,
|
|
24652
|
+
rankingProfile,
|
|
24653
|
+
tokenBudget,
|
|
24654
|
+
descendantDepth,
|
|
24655
|
+
includeEntities,
|
|
24656
|
+
compilationMode,
|
|
24657
|
+
includeFailures,
|
|
24658
|
+
...worktreeId ? { worktreeId } : {},
|
|
24659
|
+
...sessionId ? { sessionId } : {},
|
|
24660
|
+
...packWeightOverrides ? { packWeightOverrides } : {},
|
|
24661
|
+
effectiveWeights,
|
|
24662
|
+
scopedTopicIds
|
|
24663
|
+
};
|
|
24664
|
+
}
|
|
24665
|
+
function compileContextPackFromSnapshot(snapshot) {
|
|
24666
|
+
const uniqueBeliefs = dedupeById(snapshot.beliefs);
|
|
24667
|
+
const uniqueQuestions = dedupeById(snapshot.questions);
|
|
24668
|
+
const uniqueEvidence = dedupeById(snapshot.evidence);
|
|
24669
|
+
const uniqueContradictions = dedupeById(snapshot.contradictions);
|
|
24670
|
+
const referenceTimeMs = resolveReferenceTimeMs(
|
|
24671
|
+
[snapshot.topic],
|
|
24672
|
+
uniqueBeliefs,
|
|
24673
|
+
uniqueQuestions,
|
|
24674
|
+
uniqueEvidence,
|
|
24675
|
+
uniqueContradictions,
|
|
24676
|
+
snapshot.entities
|
|
24677
|
+
) || 0;
|
|
24678
|
+
const rankOptions = {
|
|
24679
|
+
effectiveWeights: snapshot.plan.effectiveWeights,
|
|
24680
|
+
includeJustifications: snapshot.plan.compilationMode === "delta",
|
|
24681
|
+
referenceTimeMs
|
|
24682
|
+
};
|
|
24683
|
+
const invariantCandidates = uniqueBeliefs.filter((belief) => beliefTypeOf(belief).toLowerCase() === "invariant").map((belief) => ({
|
|
24684
|
+
nodeId: String(belief._id),
|
|
24685
|
+
canonicalText: String(belief.canonicalText || ""),
|
|
24686
|
+
confidence: typeof belief.confidence === "number" ? belief.confidence : null,
|
|
24687
|
+
beliefType: beliefTypeOf(belief) || "invariant",
|
|
24688
|
+
updatedAt: belief.updatedAt || belief.createdAt || null
|
|
24689
|
+
}));
|
|
24690
|
+
const invariants = rankContextSection(
|
|
24691
|
+
"invariants",
|
|
24692
|
+
invariantCandidates.map((candidate) => ({
|
|
24693
|
+
...candidate,
|
|
24694
|
+
id: candidate.nodeId,
|
|
24695
|
+
text: `${candidate.canonicalText} ${candidate.beliefType}`
|
|
24696
|
+
})),
|
|
24697
|
+
snapshot.plan.tokens,
|
|
24698
|
+
snapshot.plan.limit,
|
|
24699
|
+
snapshot.plan.rankingProfile,
|
|
24700
|
+
rankOptions
|
|
24701
|
+
).map((row) => ({
|
|
24702
|
+
nodeId: row.nodeId,
|
|
24703
|
+
canonicalText: row.canonicalText,
|
|
24704
|
+
confidence: row.confidence,
|
|
24705
|
+
beliefType: row.beliefType,
|
|
24706
|
+
score: row.score,
|
|
24707
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24708
|
+
}));
|
|
24709
|
+
const activeBeliefCandidates = uniqueBeliefs.filter((belief) => (belief.status || "active") !== "archived").map((belief) => ({
|
|
24710
|
+
nodeId: String(belief._id),
|
|
24711
|
+
canonicalText: String(belief.canonicalText || ""),
|
|
24712
|
+
confidence: typeof belief.confidence === "number" ? belief.confidence : null,
|
|
24713
|
+
beliefType: beliefTypeOf(belief) || null,
|
|
24714
|
+
status: belief.status || "active",
|
|
24715
|
+
updatedAt: belief.updatedAt || belief.createdAt || null,
|
|
24716
|
+
metadataText: belief.metadata && typeof belief.metadata === "object" ? metadataText(belief.metadata) : ""
|
|
24717
|
+
}));
|
|
24718
|
+
const activeBeliefs = rankContextSection(
|
|
24719
|
+
"activeBeliefs",
|
|
24720
|
+
activeBeliefCandidates.map((candidate) => ({
|
|
24721
|
+
...candidate,
|
|
24722
|
+
id: candidate.nodeId,
|
|
24723
|
+
text: `${candidate.canonicalText} ${candidate.metadataText}`
|
|
24724
|
+
})),
|
|
24725
|
+
snapshot.plan.tokens,
|
|
24726
|
+
snapshot.plan.limit,
|
|
24727
|
+
snapshot.plan.rankingProfile,
|
|
24728
|
+
rankOptions
|
|
24729
|
+
).map((row) => ({
|
|
24730
|
+
nodeId: row.nodeId,
|
|
24731
|
+
canonicalText: row.canonicalText,
|
|
24732
|
+
confidence: row.confidence,
|
|
24733
|
+
beliefType: row.beliefType,
|
|
24734
|
+
status: row.status,
|
|
24735
|
+
updatedAt: row.updatedAt,
|
|
24736
|
+
score: row.score,
|
|
24737
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24738
|
+
}));
|
|
24739
|
+
const openQuestionCandidates = uniqueQuestions.map((question) => {
|
|
24740
|
+
const status = questionStatusOf(question);
|
|
24741
|
+
const metadata = question.metadata && typeof question.metadata === "object" ? question.metadata : {};
|
|
24742
|
+
return {
|
|
24743
|
+
questionId: String(question._id),
|
|
24744
|
+
text: String(question.canonicalText || ""),
|
|
24745
|
+
status,
|
|
24746
|
+
priority: typeof metadata.priority === "string" ? metadata.priority : "medium",
|
|
24747
|
+
updatedAt: question.updatedAt || question.createdAt || null,
|
|
24748
|
+
metadataText: metadataText(metadata)
|
|
24749
|
+
};
|
|
24750
|
+
}).filter((row) => isOpenQuestion(row.status));
|
|
24751
|
+
const openQuestions = rankContextSection(
|
|
24752
|
+
"openQuestions",
|
|
24753
|
+
openQuestionCandidates.map((candidate) => ({
|
|
24754
|
+
...candidate,
|
|
24755
|
+
id: candidate.questionId,
|
|
24756
|
+
text: `${candidate.text} ${candidate.metadataText}`
|
|
24757
|
+
})),
|
|
24758
|
+
snapshot.plan.tokens,
|
|
24759
|
+
snapshot.plan.limit,
|
|
24760
|
+
snapshot.plan.rankingProfile,
|
|
24761
|
+
rankOptions
|
|
24762
|
+
).map((row) => ({
|
|
24763
|
+
questionId: row.questionId,
|
|
24764
|
+
text: row.text,
|
|
24765
|
+
status: row.status,
|
|
24766
|
+
priority: row.priority,
|
|
24767
|
+
updatedAt: row.updatedAt,
|
|
24768
|
+
score: row.score,
|
|
24769
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24770
|
+
}));
|
|
24771
|
+
const evidenceCandidates = uniqueEvidence.map((item) => {
|
|
24772
|
+
const metadata = item.metadata && typeof item.metadata === "object" ? item.metadata : {};
|
|
24773
|
+
return {
|
|
24774
|
+
nodeId: String(item._id),
|
|
24775
|
+
canonicalText: String(item.canonicalText || ""),
|
|
24776
|
+
sourceUrl: typeof metadata.sourceUrl === "string" && metadata.sourceUrl || typeof item.sourceUrl === "string" && item.sourceUrl || null,
|
|
24777
|
+
kind: typeof metadata.kind === "string" && metadata.kind || "observation",
|
|
24778
|
+
createdAt: item.createdAt || null,
|
|
24779
|
+
updatedAt: item.updatedAt || item.createdAt || null,
|
|
24780
|
+
metadataText: metadataText(metadata)
|
|
24781
|
+
};
|
|
24782
|
+
});
|
|
24783
|
+
const recentEvidence = rankContextSection(
|
|
24784
|
+
"recentEvidence",
|
|
24785
|
+
evidenceCandidates.map((candidate) => ({
|
|
24786
|
+
...candidate,
|
|
24787
|
+
id: candidate.nodeId,
|
|
24788
|
+
text: `${candidate.canonicalText} ${candidate.metadataText}`
|
|
24789
|
+
})),
|
|
24790
|
+
snapshot.plan.tokens,
|
|
24791
|
+
snapshot.plan.limit,
|
|
24792
|
+
snapshot.plan.rankingProfile,
|
|
24793
|
+
rankOptions
|
|
24794
|
+
).map((row) => ({
|
|
24795
|
+
nodeId: row.nodeId,
|
|
24796
|
+
canonicalText: row.canonicalText,
|
|
24797
|
+
sourceUrl: row.sourceUrl,
|
|
24798
|
+
kind: row.kind,
|
|
24799
|
+
createdAt: row.createdAt,
|
|
24800
|
+
score: row.score,
|
|
24801
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24802
|
+
}));
|
|
24803
|
+
const contradictionCandidates = uniqueContradictions.map((row) => {
|
|
24804
|
+
const weight = typeof row.weight === "number" ? row.weight : 0;
|
|
24805
|
+
const severity = weight <= -0.9 ? "critical" : weight <= -0.7 ? "high" : weight <= -0.5 ? "medium" : "low";
|
|
24806
|
+
return {
|
|
24807
|
+
contradictionId: String(row._id || row.globalId || ""),
|
|
24808
|
+
severity,
|
|
24809
|
+
status: "active",
|
|
24810
|
+
description: row.context || row.description || row.summary || "",
|
|
24811
|
+
updatedAt: row.updatedAt || row.createdAt || null
|
|
24812
|
+
};
|
|
24813
|
+
});
|
|
24814
|
+
const contradictions2 = rankContextSection(
|
|
24815
|
+
"contradictions",
|
|
24816
|
+
contradictionCandidates.map((candidate) => ({
|
|
24817
|
+
...candidate,
|
|
24818
|
+
id: candidate.contradictionId,
|
|
24819
|
+
text: `${candidate.description} ${candidate.severity}`
|
|
24820
|
+
})),
|
|
24821
|
+
snapshot.plan.tokens,
|
|
24822
|
+
snapshot.plan.limit,
|
|
24823
|
+
snapshot.plan.rankingProfile,
|
|
24824
|
+
rankOptions
|
|
24825
|
+
).map((row) => ({
|
|
24826
|
+
contradictionId: row.contradictionId,
|
|
24827
|
+
severity: row.severity,
|
|
24828
|
+
status: row.status,
|
|
24829
|
+
description: row.description,
|
|
24830
|
+
score: row.score,
|
|
24831
|
+
...row.justification ? { justification: row.justification } : {}
|
|
24832
|
+
}));
|
|
24833
|
+
const entityCandidates = snapshot.entities.map((row) => ({
|
|
24834
|
+
nodeId: String(row._id),
|
|
24835
|
+
entityType: String(row.nodeType || ""),
|
|
24836
|
+
title: String(row.title || ""),
|
|
24837
|
+
canonicalText: String(row.canonicalText || ""),
|
|
24838
|
+
connectedBeliefCount: typeof row.connectedBeliefCount === "number" ? row.connectedBeliefCount : 0,
|
|
24839
|
+
connectedEvidenceCount: typeof row.connectedEvidenceCount === "number" ? row.connectedEvidenceCount : 0,
|
|
24840
|
+
metadata: row.metadata && typeof row.metadata === "object" ? row.metadata : {},
|
|
24841
|
+
updatedAt: row.updatedAt || null
|
|
24842
|
+
}));
|
|
24843
|
+
const entityLimit = toPositiveInt(
|
|
24844
|
+
snapshot.plan.limit,
|
|
24845
|
+
DEFAULT_ENTITY_LIMIT,
|
|
24846
|
+
MAX_ENTITY_LIMIT
|
|
24847
|
+
);
|
|
24848
|
+
const rankedEntities = snapshot.plan.includeEntities ? rankEntities(entityCandidates, snapshot.plan.tokens, entityLimit).map(
|
|
24849
|
+
(row) => ({
|
|
24850
|
+
nodeId: row.nodeId,
|
|
24851
|
+
entityType: row.entityType,
|
|
24852
|
+
title: row.title,
|
|
24853
|
+
connectedBeliefCount: row.connectedBeliefCount,
|
|
24854
|
+
connectedEvidenceCount: row.connectedEvidenceCount,
|
|
24855
|
+
score: row.score,
|
|
24856
|
+
...Object.keys(row.metadata).length > 0 ? { metadata: row.metadata } : {}
|
|
24857
|
+
})
|
|
24858
|
+
) : void 0;
|
|
24859
|
+
let failureContext;
|
|
24860
|
+
if (snapshot.plan.includeFailures && snapshot.failures) {
|
|
24861
|
+
const allFailures = snapshot.failures.filter((node) => {
|
|
24862
|
+
const metadata = node.metadata || {};
|
|
24863
|
+
return metadata.failedApproach === true || metadata.isFailedAttempt === true;
|
|
24864
|
+
});
|
|
24865
|
+
const rankedFailures = rankContextSection(
|
|
24866
|
+
"recentEvidence",
|
|
24867
|
+
allFailures.map((node) => ({
|
|
24868
|
+
id: String(node._id),
|
|
24869
|
+
text: String(node.canonicalText || ""),
|
|
24870
|
+
createdAt: node.createdAt || null,
|
|
24871
|
+
updatedAt: node.updatedAt || node.createdAt || null
|
|
24872
|
+
})),
|
|
24873
|
+
snapshot.plan.tokens,
|
|
24874
|
+
10,
|
|
24875
|
+
snapshot.plan.rankingProfile,
|
|
24876
|
+
rankOptions
|
|
24877
|
+
);
|
|
24878
|
+
const failures = rankedFailures.map((row) => {
|
|
24879
|
+
const original = allFailures.find((node) => String(node._id) === row.id);
|
|
24880
|
+
const metadata = original?.metadata || {};
|
|
24881
|
+
return {
|
|
24882
|
+
attemptId: row.id,
|
|
24883
|
+
approach: String(row.text || ""),
|
|
24884
|
+
outcome: String(metadata.errorMessage || "Failed"),
|
|
24885
|
+
recordedAt: row.createdAt || referenceTimeMs || 0,
|
|
24886
|
+
score: row.score
|
|
24887
|
+
};
|
|
24888
|
+
});
|
|
24889
|
+
const failureTexts = new Set(
|
|
24890
|
+
failures.map((failure) => failure.approach.toLowerCase().slice(0, 100))
|
|
24891
|
+
);
|
|
24892
|
+
const suppressionIds = /* @__PURE__ */ new Set();
|
|
24893
|
+
if (snapshot.plan.sessionId && failureTexts.size > 0) {
|
|
24894
|
+
for (const evidenceRow of recentEvidence) {
|
|
24895
|
+
const evidenceText = evidenceRow.canonicalText.toLowerCase().slice(0, 100);
|
|
24896
|
+
for (const failureText of failureTexts) {
|
|
24897
|
+
if (evidenceText.includes(failureText) || failureText.includes(evidenceText)) {
|
|
24898
|
+
suppressionIds.add(evidenceRow.nodeId);
|
|
24899
|
+
break;
|
|
24900
|
+
}
|
|
24901
|
+
}
|
|
24902
|
+
}
|
|
24903
|
+
}
|
|
24904
|
+
if (failures.length > 0) {
|
|
24905
|
+
failureContext = {
|
|
24906
|
+
failures,
|
|
24907
|
+
suppressedIds: Array.from(suppressionIds)
|
|
24908
|
+
};
|
|
24909
|
+
}
|
|
24910
|
+
}
|
|
24911
|
+
const suppressionSet = new Set(failureContext?.suppressedIds || []);
|
|
24912
|
+
const effectiveEvidence = suppressionSet.size > 0 ? recentEvidence.filter((row) => !suppressionSet.has(row.nodeId)) : recentEvidence;
|
|
24913
|
+
const suppressedEvidenceIds = suppressionSet.size > 0 ? recentEvidence.filter((row) => suppressionSet.has(row.nodeId)).map((row) => row.nodeId) : [];
|
|
24914
|
+
const summary = {
|
|
24915
|
+
totalBeliefs: uniqueBeliefs.length,
|
|
24916
|
+
invariants: invariants.length,
|
|
24917
|
+
openQuestions: openQuestions.length,
|
|
24918
|
+
evidenceItems: uniqueEvidence.length,
|
|
24919
|
+
contradictions: contradictions2.length,
|
|
24920
|
+
...rankedEntities ? { relatedEntities: rankedEntities.length } : {},
|
|
24921
|
+
scopedTopics: snapshot.plan.scopedTopicIds.length,
|
|
24922
|
+
descendantDepth: snapshot.plan.descendantDepth,
|
|
24923
|
+
query: snapshot.plan.queryText || null
|
|
24924
|
+
};
|
|
24925
|
+
const injectionPolicy = buildInjectionPlan({
|
|
24926
|
+
tokenBudget: snapshot.plan.tokenBudget,
|
|
24927
|
+
invariants: invariants.map((row) => ({
|
|
24928
|
+
nodeId: row.nodeId,
|
|
24929
|
+
canonicalText: row.canonicalText,
|
|
24930
|
+
score: row.score
|
|
24931
|
+
})),
|
|
24932
|
+
activeBeliefs: activeBeliefs.map((row) => ({
|
|
24933
|
+
nodeId: row.nodeId,
|
|
24934
|
+
canonicalText: row.canonicalText,
|
|
24935
|
+
score: row.score
|
|
24936
|
+
})),
|
|
24937
|
+
openQuestions: openQuestions.map((row) => ({
|
|
24938
|
+
questionId: row.questionId,
|
|
24939
|
+
text: row.text,
|
|
24940
|
+
score: row.score
|
|
24941
|
+
})),
|
|
24942
|
+
recentEvidence: effectiveEvidence.map((row) => ({
|
|
24943
|
+
nodeId: row.nodeId,
|
|
24944
|
+
canonicalText: row.canonicalText,
|
|
24945
|
+
score: row.score
|
|
24946
|
+
})),
|
|
24947
|
+
contradictions: contradictions2.map((row) => ({
|
|
24948
|
+
contradictionId: row.contradictionId,
|
|
24949
|
+
description: row.description,
|
|
24950
|
+
score: row.score
|
|
24951
|
+
})),
|
|
24952
|
+
trackExclusions: snapshot.plan.compilationMode === "delta"
|
|
24953
|
+
});
|
|
24954
|
+
const contextNarrative = [
|
|
24955
|
+
"Prefer invariant beliefs as hard constraints while reasoning over this scope.",
|
|
24956
|
+
"Treat open questions as unresolved work items and avoid claiming closure without evidence.",
|
|
24957
|
+
"Use recent evidence for implementation context before creating new beliefs.",
|
|
24958
|
+
"When contradictions exist, resolve explicitly (fork, lower confidence, or gather counter-evidence).",
|
|
24959
|
+
`Apply injection token budget of ${injectionPolicy.tokenBudget} with section quotas before prompt assembly.`
|
|
24960
|
+
];
|
|
24961
|
+
const deltaReport = snapshot.plan.compilationMode === "delta" && snapshot.plan.worktreeId ? {
|
|
24962
|
+
changedItems: [],
|
|
24963
|
+
verificationObligations: [],
|
|
24964
|
+
referencePoint: snapshot.plan.worktreeId
|
|
24965
|
+
} : void 0;
|
|
24966
|
+
const excludedItems = [
|
|
24967
|
+
...injectionPolicy.excludedItems || [],
|
|
24968
|
+
...suppressedEvidenceIds.map((id) => ({
|
|
24969
|
+
id,
|
|
24970
|
+
section: "recentEvidence",
|
|
24971
|
+
reason: "anti_repetition",
|
|
24972
|
+
score: recentEvidence.find((row) => row.nodeId === id)?.score ?? 0
|
|
24973
|
+
}))
|
|
24974
|
+
];
|
|
24975
|
+
const result = {
|
|
24976
|
+
schemaVersion: CONTEXT_PACK_SCHEMA_VERSION,
|
|
24977
|
+
topicId: snapshot.plan.topicId,
|
|
24978
|
+
topicName: snapshot.topic.name || "Untitled Topic",
|
|
24979
|
+
scopedTopicIds: snapshot.plan.scopedTopicIds,
|
|
24980
|
+
generatedAt: referenceTimeMs,
|
|
24981
|
+
rankingProfile: snapshot.plan.rankingProfile,
|
|
24982
|
+
summary,
|
|
24983
|
+
invariants,
|
|
24984
|
+
activeBeliefs,
|
|
24985
|
+
openQuestions,
|
|
24986
|
+
recentEvidence: effectiveEvidence,
|
|
24987
|
+
contradictions: contradictions2,
|
|
24988
|
+
...rankedEntities ? { relatedEntities: rankedEntities } : {},
|
|
24989
|
+
contextNarrative,
|
|
24990
|
+
injectionPolicy: {
|
|
24991
|
+
...injectionPolicy,
|
|
24992
|
+
...excludedItems.length > 0 ? { excludedItems } : {}
|
|
24993
|
+
},
|
|
24994
|
+
diagnostics: {
|
|
24995
|
+
itemsScored: invariantCandidates.length + activeBeliefCandidates.length + openQuestionCandidates.length + evidenceCandidates.length + contradictionCandidates.length + entityCandidates.length,
|
|
24996
|
+
tokenBudgetUtilization: injectionPolicy.tokenBudget === 0 ? 0 : Number(
|
|
24997
|
+
(injectionPolicy.estimatedTokens / injectionPolicy.tokenBudget).toFixed(4)
|
|
24998
|
+
),
|
|
24999
|
+
referenceTimeMs
|
|
25000
|
+
},
|
|
25001
|
+
...snapshot.plan.compilationMode !== "standard" ? { compilationMode: snapshot.plan.compilationMode } : {},
|
|
25002
|
+
...failureContext ? { failureContext } : {},
|
|
25003
|
+
...deltaReport ? { deltaReport } : {},
|
|
25004
|
+
...snapshot.plan.packWeightOverrides && snapshot.plan.packWeightOverrides.length > 0 ? { appliedWeightOverrides: snapshot.plan.packWeightOverrides } : {}
|
|
25005
|
+
};
|
|
25006
|
+
assertContextPackSchema(result);
|
|
25007
|
+
return result;
|
|
25008
|
+
}
|
|
25009
|
+
|
|
25010
|
+
// ../sdk/src/controlObjectOwnership.ts
|
|
25011
|
+
var CONTROL_OBJECT_KINDS = [
|
|
25012
|
+
"tenant",
|
|
25013
|
+
"workspace",
|
|
25014
|
+
"principal",
|
|
25015
|
+
"tool",
|
|
25016
|
+
"pack",
|
|
25017
|
+
"ontology",
|
|
25018
|
+
"belief",
|
|
25019
|
+
"policy_rule"
|
|
25020
|
+
];
|
|
25021
|
+
var CONTROL_OBJECT_OWNER_SCOPES = [
|
|
25022
|
+
"platform",
|
|
25023
|
+
"tenant",
|
|
25024
|
+
"workspace",
|
|
25025
|
+
"resource"
|
|
25026
|
+
];
|
|
25027
|
+
var CONTROL_OBJECT_EDIT_SURFACES = [
|
|
25028
|
+
"platform_admin",
|
|
25029
|
+
"tenant_admin",
|
|
25030
|
+
"workspace_admin",
|
|
25031
|
+
"graph_worktree"
|
|
25032
|
+
];
|
|
25033
|
+
var CONTROL_OBJECT_INHERITANCE_RULES = [
|
|
25034
|
+
"none",
|
|
25035
|
+
"platform_seed_to_tenant",
|
|
25036
|
+
"tenant_default_to_workspace",
|
|
25037
|
+
"workspace_narrowing_only",
|
|
25038
|
+
"pack_overlay_to_tenant",
|
|
25039
|
+
"topic_lineage_to_resource"
|
|
25040
|
+
];
|
|
25041
|
+
var CONTROL_OBJECT_BLAST_RADII = [
|
|
25042
|
+
"platform",
|
|
25043
|
+
"tenant",
|
|
25044
|
+
"workspace",
|
|
25045
|
+
"resource"
|
|
25046
|
+
];
|
|
25047
|
+
function defineCases(cases) {
|
|
25048
|
+
return cases;
|
|
25049
|
+
}
|
|
25050
|
+
var CONTROL_OBJECT_OWNERSHIP_MATRIX = {
|
|
25051
|
+
tenant: defineCases([
|
|
25052
|
+
{
|
|
25053
|
+
caseKey: "platform-record",
|
|
25054
|
+
caseLabel: "Platform Record",
|
|
25055
|
+
kind: "tenant",
|
|
25056
|
+
canonicalOwnerScope: "platform",
|
|
25057
|
+
editSurface: "platform_admin",
|
|
25058
|
+
inheritanceRule: "none",
|
|
25059
|
+
blastRadius: "tenant"
|
|
25060
|
+
}
|
|
25061
|
+
]),
|
|
25062
|
+
workspace: defineCases([
|
|
25063
|
+
{
|
|
25064
|
+
caseKey: "tenant-workspace",
|
|
25065
|
+
caseLabel: "Tenant Workspace",
|
|
25066
|
+
kind: "workspace",
|
|
25067
|
+
canonicalOwnerScope: "tenant",
|
|
25068
|
+
editSurface: "tenant_admin",
|
|
25069
|
+
inheritanceRule: "tenant_default_to_workspace",
|
|
25070
|
+
blastRadius: "workspace"
|
|
25071
|
+
}
|
|
25072
|
+
]),
|
|
25073
|
+
principal: defineCases([
|
|
25074
|
+
{
|
|
25075
|
+
caseKey: "tenant-principal",
|
|
25076
|
+
caseLabel: "Tenant Principal",
|
|
25077
|
+
kind: "principal",
|
|
25078
|
+
canonicalOwnerScope: "tenant",
|
|
25079
|
+
editSurface: "tenant_admin",
|
|
25080
|
+
inheritanceRule: "workspace_narrowing_only",
|
|
25081
|
+
blastRadius: "resource"
|
|
25082
|
+
}
|
|
25083
|
+
]),
|
|
25084
|
+
tool: defineCases([
|
|
25085
|
+
{
|
|
25086
|
+
caseKey: "platform-core",
|
|
25087
|
+
caseLabel: "Platform Core",
|
|
25088
|
+
kind: "tool",
|
|
25089
|
+
canonicalOwnerScope: "platform",
|
|
25090
|
+
editSurface: "platform_admin",
|
|
25091
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25092
|
+
blastRadius: "platform"
|
|
25093
|
+
},
|
|
25094
|
+
{
|
|
25095
|
+
caseKey: "tenant-custom",
|
|
25096
|
+
caseLabel: "Tenant Custom",
|
|
25097
|
+
kind: "tool",
|
|
25098
|
+
canonicalOwnerScope: "tenant",
|
|
25099
|
+
editSurface: "tenant_admin",
|
|
25100
|
+
inheritanceRule: "tenant_default_to_workspace",
|
|
25101
|
+
blastRadius: "tenant"
|
|
25102
|
+
}
|
|
25103
|
+
]),
|
|
25104
|
+
pack: defineCases([
|
|
25105
|
+
{
|
|
25106
|
+
caseKey: "platform-definition",
|
|
25107
|
+
caseLabel: "Platform Definition",
|
|
25108
|
+
kind: "pack",
|
|
25109
|
+
canonicalOwnerScope: "platform",
|
|
25110
|
+
editSurface: "platform_admin",
|
|
25111
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25112
|
+
blastRadius: "platform"
|
|
25113
|
+
},
|
|
25114
|
+
{
|
|
25115
|
+
caseKey: "tenant-installation",
|
|
25116
|
+
caseLabel: "Tenant Installation",
|
|
25117
|
+
kind: "pack",
|
|
25118
|
+
canonicalOwnerScope: "tenant",
|
|
25119
|
+
editSurface: "tenant_admin",
|
|
25120
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25121
|
+
blastRadius: "tenant"
|
|
25122
|
+
}
|
|
25123
|
+
]),
|
|
25124
|
+
ontology: defineCases([
|
|
25125
|
+
{
|
|
25126
|
+
caseKey: "platform-base",
|
|
25127
|
+
caseLabel: "Platform Base",
|
|
25128
|
+
kind: "ontology",
|
|
25129
|
+
canonicalOwnerScope: "platform",
|
|
25130
|
+
editSurface: "platform_admin",
|
|
25131
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25132
|
+
blastRadius: "platform"
|
|
25133
|
+
},
|
|
25134
|
+
{
|
|
22585
25135
|
caseKey: "pack-overlay",
|
|
22586
25136
|
caseLabel: "Pack Overlay",
|
|
22587
25137
|
kind: "ontology",
|
|
@@ -22590,64 +25140,1049 @@ var CONTROL_OBJECT_OWNERSHIP_MATRIX = {
|
|
|
22590
25140
|
inheritanceRule: "pack_overlay_to_tenant",
|
|
22591
25141
|
blastRadius: "platform"
|
|
22592
25142
|
},
|
|
22593
|
-
{
|
|
22594
|
-
caseKey: "tenant-extension",
|
|
22595
|
-
caseLabel: "Tenant Extension",
|
|
22596
|
-
kind: "ontology",
|
|
22597
|
-
canonicalOwnerScope: "tenant",
|
|
22598
|
-
editSurface: "tenant_admin",
|
|
22599
|
-
inheritanceRule: "topic_lineage_to_resource",
|
|
22600
|
-
blastRadius: "tenant"
|
|
25143
|
+
{
|
|
25144
|
+
caseKey: "tenant-extension",
|
|
25145
|
+
caseLabel: "Tenant Extension",
|
|
25146
|
+
kind: "ontology",
|
|
25147
|
+
canonicalOwnerScope: "tenant",
|
|
25148
|
+
editSurface: "tenant_admin",
|
|
25149
|
+
inheritanceRule: "topic_lineage_to_resource",
|
|
25150
|
+
blastRadius: "tenant"
|
|
25151
|
+
}
|
|
25152
|
+
]),
|
|
25153
|
+
belief: defineCases([
|
|
25154
|
+
{
|
|
25155
|
+
caseKey: "topic-resource",
|
|
25156
|
+
caseLabel: "Topic Resource",
|
|
25157
|
+
kind: "belief",
|
|
25158
|
+
canonicalOwnerScope: "resource",
|
|
25159
|
+
editSurface: "graph_worktree",
|
|
25160
|
+
inheritanceRule: "topic_lineage_to_resource",
|
|
25161
|
+
blastRadius: "resource"
|
|
25162
|
+
}
|
|
25163
|
+
]),
|
|
25164
|
+
policy_rule: defineCases([
|
|
25165
|
+
{
|
|
25166
|
+
caseKey: "platform-baseline",
|
|
25167
|
+
caseLabel: "Platform Baseline",
|
|
25168
|
+
kind: "policy_rule",
|
|
25169
|
+
canonicalOwnerScope: "platform",
|
|
25170
|
+
editSurface: "platform_admin",
|
|
25171
|
+
inheritanceRule: "platform_seed_to_tenant",
|
|
25172
|
+
blastRadius: "platform"
|
|
25173
|
+
},
|
|
25174
|
+
{
|
|
25175
|
+
caseKey: "tenant-bundle",
|
|
25176
|
+
caseLabel: "Tenant Bundle",
|
|
25177
|
+
kind: "policy_rule",
|
|
25178
|
+
canonicalOwnerScope: "tenant",
|
|
25179
|
+
editSurface: "tenant_admin",
|
|
25180
|
+
inheritanceRule: "tenant_default_to_workspace",
|
|
25181
|
+
blastRadius: "tenant"
|
|
25182
|
+
},
|
|
25183
|
+
{
|
|
25184
|
+
caseKey: "workspace-override",
|
|
25185
|
+
caseLabel: "Workspace Override",
|
|
25186
|
+
kind: "policy_rule",
|
|
25187
|
+
canonicalOwnerScope: "workspace",
|
|
25188
|
+
editSurface: "workspace_admin",
|
|
25189
|
+
inheritanceRule: "none",
|
|
25190
|
+
blastRadius: "workspace"
|
|
25191
|
+
}
|
|
25192
|
+
])
|
|
25193
|
+
};
|
|
25194
|
+
function flattenOwnershipMatrix(matrix) {
|
|
25195
|
+
return CONTROL_OBJECT_KINDS.flatMap((kind) => [...matrix[kind]]);
|
|
25196
|
+
}
|
|
25197
|
+
var CONTROL_OBJECT_OWNERSHIP_ROWS = Object.freeze(
|
|
25198
|
+
flattenOwnershipMatrix(CONTROL_OBJECT_OWNERSHIP_MATRIX)
|
|
25199
|
+
);
|
|
25200
|
+
var CONTROL_OBJECT_OWNERSHIP_CONTRACT = {
|
|
25201
|
+
version: "1.0.0",
|
|
25202
|
+
kinds: CONTROL_OBJECT_KINDS,
|
|
25203
|
+
ownerScopes: CONTROL_OBJECT_OWNER_SCOPES,
|
|
25204
|
+
editSurfaces: CONTROL_OBJECT_EDIT_SURFACES,
|
|
25205
|
+
inheritanceRules: CONTROL_OBJECT_INHERITANCE_RULES,
|
|
25206
|
+
blastRadii: CONTROL_OBJECT_BLAST_RADII,
|
|
25207
|
+
matrix: CONTROL_OBJECT_OWNERSHIP_MATRIX,
|
|
25208
|
+
rows: CONTROL_OBJECT_OWNERSHIP_ROWS
|
|
25209
|
+
};
|
|
25210
|
+
function listControlObjectOwnershipCases(kind) {
|
|
25211
|
+
if (!kind) {
|
|
25212
|
+
return CONTROL_OBJECT_OWNERSHIP_ROWS;
|
|
25213
|
+
}
|
|
25214
|
+
return CONTROL_OBJECT_OWNERSHIP_MATRIX[kind];
|
|
25215
|
+
}
|
|
25216
|
+
function getControlObjectOwnershipCase(kind, caseKey) {
|
|
25217
|
+
return CONTROL_OBJECT_OWNERSHIP_MATRIX[kind].find(
|
|
25218
|
+
(ownershipCase) => ownershipCase.caseKey === caseKey
|
|
25219
|
+
);
|
|
25220
|
+
}
|
|
25221
|
+
|
|
25222
|
+
// ../sdk/src/contracts/api-enums.contract.ts
|
|
25223
|
+
var BELIEF_STATUSES = [
|
|
25224
|
+
"assumption",
|
|
25225
|
+
"hypothesis",
|
|
25226
|
+
"belief",
|
|
25227
|
+
"fact"
|
|
25228
|
+
];
|
|
25229
|
+
var FORK_REASONS = [
|
|
25230
|
+
"refinement",
|
|
25231
|
+
"contradiction_response",
|
|
25232
|
+
"scope_change",
|
|
25233
|
+
"confidence_collapse",
|
|
25234
|
+
"manual"
|
|
25235
|
+
];
|
|
25236
|
+
var CONFIDENCE_TRIGGERS = [
|
|
25237
|
+
"evidence_added",
|
|
25238
|
+
"evidence_removed",
|
|
25239
|
+
"contradiction_detected",
|
|
25240
|
+
"contradiction_resolved",
|
|
25241
|
+
"agent_assessment",
|
|
25242
|
+
"worktree_outcome",
|
|
25243
|
+
"worktree_completed",
|
|
25244
|
+
"manual",
|
|
25245
|
+
"decay",
|
|
25246
|
+
"fusion",
|
|
25247
|
+
"discount",
|
|
25248
|
+
"deduction"
|
|
25249
|
+
];
|
|
25250
|
+
var EPISTEMIC_EDGE_TYPES = [
|
|
25251
|
+
"supports",
|
|
25252
|
+
"informs",
|
|
25253
|
+
"depends_on",
|
|
25254
|
+
"derived_from",
|
|
25255
|
+
"contains",
|
|
25256
|
+
"tests"
|
|
25257
|
+
];
|
|
25258
|
+
var STRUCTURAL_EDGE_TYPES = [
|
|
25259
|
+
"supersedes",
|
|
25260
|
+
"responds_to",
|
|
25261
|
+
"belongs_to",
|
|
25262
|
+
"relates_to_thesis"
|
|
25263
|
+
];
|
|
25264
|
+
var EDGE_TYPES = [
|
|
25265
|
+
...EPISTEMIC_EDGE_TYPES,
|
|
25266
|
+
...STRUCTURAL_EDGE_TYPES
|
|
25267
|
+
];
|
|
25268
|
+
var REASONING_METHODS = [
|
|
25269
|
+
"deductive",
|
|
25270
|
+
"inductive",
|
|
25271
|
+
"abductive",
|
|
25272
|
+
"analogical",
|
|
25273
|
+
"empirical"
|
|
25274
|
+
];
|
|
25275
|
+
var DEFEAT_TYPES = [
|
|
25276
|
+
"rebuts",
|
|
25277
|
+
"undercuts",
|
|
25278
|
+
"undermines"
|
|
25279
|
+
];
|
|
25280
|
+
var CONTRADICTION_SEVERITIES = [
|
|
25281
|
+
"low",
|
|
25282
|
+
"medium",
|
|
25283
|
+
"high",
|
|
25284
|
+
"critical"
|
|
25285
|
+
];
|
|
25286
|
+
var CONTRADICTION_STATUSES = [
|
|
25287
|
+
"unresolved",
|
|
25288
|
+
"resolved",
|
|
25289
|
+
"accepted"
|
|
25290
|
+
];
|
|
25291
|
+
var MERGE_OUTCOMES = [
|
|
25292
|
+
"validated",
|
|
25293
|
+
"invalidated",
|
|
25294
|
+
"forked",
|
|
25295
|
+
"inconclusive"
|
|
25296
|
+
];
|
|
25297
|
+
var WORKTREE_PHASES = [
|
|
25298
|
+
"hypothesis",
|
|
25299
|
+
"investigation",
|
|
25300
|
+
"evaluation",
|
|
25301
|
+
"resolution"
|
|
25302
|
+
];
|
|
25303
|
+
var EPISTEMIC_LAYERS = [
|
|
25304
|
+
"L1",
|
|
25305
|
+
"L2",
|
|
25306
|
+
"L3",
|
|
25307
|
+
"L4"
|
|
25308
|
+
];
|
|
25309
|
+
var JUDGMENT_TYPES = [
|
|
25310
|
+
"thesis",
|
|
25311
|
+
"thesis_maturity",
|
|
25312
|
+
"contradiction_ruling",
|
|
25313
|
+
"scope_determination",
|
|
25314
|
+
"confidence_ruling"
|
|
25315
|
+
];
|
|
25316
|
+
|
|
25317
|
+
// ../sdk/src/contracts/auth-session.contract.ts
|
|
25318
|
+
var SESSION_AUTH_MODES = [
|
|
25319
|
+
"interactive_user",
|
|
25320
|
+
"service_principal",
|
|
25321
|
+
"tenant_api_key",
|
|
25322
|
+
"session_token"
|
|
25323
|
+
];
|
|
25324
|
+
var SESSION_PRINCIPAL_TYPES = ["human", "service", "agent"];
|
|
25325
|
+
var SESSION_LIFECYCLE_STATUSES = [
|
|
25326
|
+
"active",
|
|
25327
|
+
"expired",
|
|
25328
|
+
"revoked"
|
|
25329
|
+
];
|
|
25330
|
+
function inferSessionPrincipalType(principalId) {
|
|
25331
|
+
if (principalId.startsWith("user:")) {
|
|
25332
|
+
return "human";
|
|
25333
|
+
}
|
|
25334
|
+
if (principalId.startsWith("agent:")) {
|
|
25335
|
+
return "agent";
|
|
25336
|
+
}
|
|
25337
|
+
return "service";
|
|
25338
|
+
}
|
|
25339
|
+
function normalizeDelegationChain(args) {
|
|
25340
|
+
if (args.delegationChain && args.delegationChain.length > 0) {
|
|
25341
|
+
return [...args.delegationChain];
|
|
25342
|
+
}
|
|
25343
|
+
if (!args.delegatedBy) {
|
|
25344
|
+
return;
|
|
25345
|
+
}
|
|
25346
|
+
return [
|
|
25347
|
+
{
|
|
25348
|
+
principalId: args.delegatedBy,
|
|
25349
|
+
principalType: args.delegatedByType ?? inferSessionPrincipalType(args.delegatedBy),
|
|
25350
|
+
delegatedAt: args.delegatedAt,
|
|
25351
|
+
reason: args.reason
|
|
25352
|
+
}
|
|
25353
|
+
];
|
|
25354
|
+
}
|
|
25355
|
+
function lastDelegator(delegationChain) {
|
|
25356
|
+
if (!delegationChain || delegationChain.length === 0) {
|
|
25357
|
+
return;
|
|
25358
|
+
}
|
|
25359
|
+
return delegationChain[delegationChain.length - 1]?.principalId;
|
|
25360
|
+
}
|
|
25361
|
+
|
|
25362
|
+
// ../sdk/src/contracts/lens-filter.contract.ts
|
|
25363
|
+
function isLensFilterCriteria2(value) {
|
|
25364
|
+
if (!value || typeof value !== "object") return false;
|
|
25365
|
+
const obj = value;
|
|
25366
|
+
return typeof obj.version === "number" && typeof obj.kind === "string";
|
|
25367
|
+
}
|
|
25368
|
+
function isTaxonomyFilterCriteriaV12(value) {
|
|
25369
|
+
if (!isLensFilterCriteria2(value)) return false;
|
|
25370
|
+
return value.version === 1 && value.kind === "taxonomy";
|
|
25371
|
+
}
|
|
25372
|
+
function validateFilterCriteria2(value) {
|
|
25373
|
+
if (value === void 0 || value === null) {
|
|
25374
|
+
return { valid: true };
|
|
25375
|
+
}
|
|
25376
|
+
if (!isLensFilterCriteria2(value)) {
|
|
25377
|
+
return {
|
|
25378
|
+
valid: false,
|
|
25379
|
+
errors: [
|
|
25380
|
+
'filterCriteria must have numeric "version" and string "kind" fields'
|
|
25381
|
+
]
|
|
25382
|
+
};
|
|
25383
|
+
}
|
|
25384
|
+
if (isTaxonomyFilterCriteriaV12(value)) {
|
|
25385
|
+
return validateTaxonomyFilterV1(value);
|
|
25386
|
+
}
|
|
25387
|
+
const raw = value;
|
|
25388
|
+
return {
|
|
25389
|
+
valid: false,
|
|
25390
|
+
errors: [
|
|
25391
|
+
`Unsupported filter criteria: version=${raw.version}, kind=${raw.kind}`
|
|
25392
|
+
]
|
|
25393
|
+
};
|
|
25394
|
+
}
|
|
25395
|
+
function validateTaxonomyFilterV1(criteria) {
|
|
25396
|
+
const errors = [];
|
|
25397
|
+
if (!Array.isArray(criteria.entityTypeFilters)) {
|
|
25398
|
+
errors.push("entityTypeFilters must be an array");
|
|
25399
|
+
return { valid: false, errors };
|
|
25400
|
+
}
|
|
25401
|
+
if (criteria.entityTypeFilters.length === 0) {
|
|
25402
|
+
errors.push("entityTypeFilters must contain at least one entry");
|
|
25403
|
+
return { valid: false, errors };
|
|
25404
|
+
}
|
|
25405
|
+
for (let i = 0; i < criteria.entityTypeFilters.length; i++) {
|
|
25406
|
+
const filter = criteria.entityTypeFilters[i];
|
|
25407
|
+
if (!filter || typeof filter.entityTypeValue !== "string") {
|
|
25408
|
+
errors.push(
|
|
25409
|
+
`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
|
|
25410
|
+
);
|
|
25411
|
+
continue;
|
|
25412
|
+
}
|
|
25413
|
+
if (filter.entityTypeValue.trim().length === 0) {
|
|
25414
|
+
errors.push(
|
|
25415
|
+
`entityTypeFilters[${i}].entityTypeValue must be a non-empty string`
|
|
25416
|
+
);
|
|
25417
|
+
}
|
|
25418
|
+
if (filter.subtypeValues !== void 0 && !Array.isArray(filter.subtypeValues)) {
|
|
25419
|
+
errors.push(`entityTypeFilters[${i}].subtypeValues must be an array`);
|
|
25420
|
+
}
|
|
25421
|
+
}
|
|
25422
|
+
if (criteria.ontologyScope !== void 0) {
|
|
25423
|
+
if (typeof criteria.ontologyScope !== "object" || criteria.ontologyScope === null) {
|
|
25424
|
+
errors.push("ontologyScope must be an object");
|
|
25425
|
+
}
|
|
25426
|
+
}
|
|
25427
|
+
return errors.length === 0 ? { valid: true } : { valid: false, errors };
|
|
25428
|
+
}
|
|
25429
|
+
|
|
25430
|
+
// ../sdk/src/contracts/lens-workflow.contract.ts
|
|
25431
|
+
var LENS_PERSPECTIVE_TYPES2 = [
|
|
25432
|
+
"investigation",
|
|
25433
|
+
"monitoring",
|
|
25434
|
+
"analysis",
|
|
25435
|
+
"comparison",
|
|
25436
|
+
"taxonomy"
|
|
25437
|
+
];
|
|
25438
|
+
var LENS_STATUSES = ["draft", "active", "archived"];
|
|
25439
|
+
var LENS_TASK_TEMPLATE_PRIORITIES = [
|
|
25440
|
+
"critical",
|
|
25441
|
+
"high",
|
|
25442
|
+
"medium",
|
|
25443
|
+
"low"
|
|
25444
|
+
];
|
|
25445
|
+
var BRANCH_DEPRECATION_MESSAGE = "Branches are deprecated for operational framing. Create a workspace-scoped lens instead.";
|
|
25446
|
+
function inferLensPerspectiveTypeFromBranchSchema(schema) {
|
|
25447
|
+
const normalized = schema?.trim().toLowerCase();
|
|
25448
|
+
if (normalized === "phase") {
|
|
25449
|
+
return "monitoring";
|
|
25450
|
+
}
|
|
25451
|
+
if (normalized === "axis" || normalized === "dimension") {
|
|
25452
|
+
return "comparison";
|
|
25453
|
+
}
|
|
25454
|
+
if (normalized === "track") {
|
|
25455
|
+
return "investigation";
|
|
25456
|
+
}
|
|
25457
|
+
return "analysis";
|
|
25458
|
+
}
|
|
25459
|
+
function migrateBranchToLens(args) {
|
|
25460
|
+
const perspectiveType = inferLensPerspectiveTypeFromBranchSchema(args.schema);
|
|
25461
|
+
return {
|
|
25462
|
+
recommendedTool: "create_lens",
|
|
25463
|
+
perspectiveType,
|
|
25464
|
+
message: "Branches are deprecated for operational framing. Create a workspace-scoped lens with the suggested payload instead.",
|
|
25465
|
+
suggestedPayload: {
|
|
25466
|
+
name: args.name,
|
|
25467
|
+
description: args.description,
|
|
25468
|
+
topicId: args.topicId,
|
|
25469
|
+
workspaceId: args.workspaceId,
|
|
25470
|
+
perspectiveType
|
|
25471
|
+
}
|
|
25472
|
+
};
|
|
25473
|
+
}
|
|
25474
|
+
function buildDeprecatedBranchMetadata(args) {
|
|
25475
|
+
return {
|
|
25476
|
+
deprecated: true,
|
|
25477
|
+
deprecationMessage: BRANCH_DEPRECATION_MESSAGE,
|
|
25478
|
+
lensSuggestion: migrateBranchToLens(args)
|
|
25479
|
+
};
|
|
25480
|
+
}
|
|
25481
|
+
|
|
25482
|
+
// ../sdk/src/contracts/mcpTools.ts
|
|
25483
|
+
var OPERATION_MANIFEST = LUCERN_OPERATION_MANIFEST;
|
|
25484
|
+
var MCP_ALWAYS_ALLOWED_TOOL_NAMES = ["identity_whoami"];
|
|
25485
|
+
function getMcpToolExposure(toolName) {
|
|
25486
|
+
return OPERATION_MANIFEST[toolName]?.surfaces.mcp ?? "none";
|
|
25487
|
+
}
|
|
25488
|
+
function decorateMcpToolContract(toolName, contract) {
|
|
25489
|
+
const exposure = getMcpToolExposure(toolName);
|
|
25490
|
+
if (exposure === "none") {
|
|
25491
|
+
return null;
|
|
25492
|
+
}
|
|
25493
|
+
return exposure === "internal" || contract.internal ? { ...contract, internal: true } : contract;
|
|
25494
|
+
}
|
|
25495
|
+
function buildMcpToolContracts(options = {}) {
|
|
25496
|
+
const merged = {
|
|
25497
|
+
...MCP_TOOL_CONTRACTS,
|
|
25498
|
+
...options.extensions ?? {}
|
|
25499
|
+
};
|
|
25500
|
+
return Object.fromEntries(
|
|
25501
|
+
Object.entries(merged).flatMap(([toolName, contract]) => {
|
|
25502
|
+
const decorated = decorateMcpToolContract(toolName, contract);
|
|
25503
|
+
return decorated ? [[toolName, decorated]] : [];
|
|
25504
|
+
})
|
|
25505
|
+
);
|
|
25506
|
+
}
|
|
25507
|
+
function mcpContractToInputSchema(contract) {
|
|
25508
|
+
const properties = {};
|
|
25509
|
+
for (const [paramName, paramDef] of Object.entries(contract.parameters)) {
|
|
25510
|
+
const prop = {
|
|
25511
|
+
type: paramDef.type,
|
|
25512
|
+
description: paramDef.description
|
|
25513
|
+
};
|
|
25514
|
+
if (paramDef.enum) {
|
|
25515
|
+
prop.enum = paramDef.enum;
|
|
25516
|
+
}
|
|
25517
|
+
properties[paramName] = prop;
|
|
25518
|
+
}
|
|
25519
|
+
return {
|
|
25520
|
+
type: "object",
|
|
25521
|
+
properties,
|
|
25522
|
+
required: contract.required
|
|
25523
|
+
};
|
|
25524
|
+
}
|
|
25525
|
+
function mcpContractToManifestEntry(name, contract) {
|
|
25526
|
+
return {
|
|
25527
|
+
name,
|
|
25528
|
+
description: contract.description,
|
|
25529
|
+
inputSchema: mcpContractToInputSchema(contract),
|
|
25530
|
+
internal: Boolean(contract.internal),
|
|
25531
|
+
ownerModule: contract.ownerModule,
|
|
25532
|
+
ontologyPrimitive: contract.ontologyPrimitive,
|
|
25533
|
+
tier: contract.tier
|
|
25534
|
+
};
|
|
25535
|
+
}
|
|
25536
|
+
function isMcpToolAllowed(toolName, options = {}) {
|
|
25537
|
+
const contracts = options.contracts ?? buildMcpToolContracts();
|
|
25538
|
+
const contract = contracts[toolName];
|
|
25539
|
+
const alwaysAllowed = /* @__PURE__ */ new Set([
|
|
25540
|
+
...MCP_ALWAYS_ALLOWED_TOOL_NAMES,
|
|
25541
|
+
...options.alwaysAllowedTools ?? []
|
|
25542
|
+
]);
|
|
25543
|
+
if (alwaysAllowed.has(toolName)) {
|
|
25544
|
+
return true;
|
|
25545
|
+
}
|
|
25546
|
+
if (options.sessionType === "user" && contract?.internal) {
|
|
25547
|
+
return false;
|
|
25548
|
+
}
|
|
25549
|
+
if (options.permittedTools !== void 0 && options.permittedTools !== null) {
|
|
25550
|
+
return options.permittedTools.some((tool) => tool.toolName === toolName);
|
|
25551
|
+
}
|
|
25552
|
+
if (options.allowedTools === null || options.allowedTools === void 0) {
|
|
25553
|
+
return true;
|
|
25554
|
+
}
|
|
25555
|
+
return options.allowedTools.includes(toolName);
|
|
25556
|
+
}
|
|
25557
|
+
function buildMcpToolManifest(args = {}) {
|
|
25558
|
+
const contracts = args.contracts ?? buildMcpToolContracts();
|
|
25559
|
+
return Object.entries(contracts).filter(([name, contract]) => {
|
|
25560
|
+
if (args.visibility?.sessionType === "user" && contract.internal) {
|
|
25561
|
+
return false;
|
|
25562
|
+
}
|
|
25563
|
+
return isMcpToolAllowed(name, {
|
|
25564
|
+
...args.visibility,
|
|
25565
|
+
contracts
|
|
25566
|
+
});
|
|
25567
|
+
}).map(([name, contract]) => mcpContractToManifestEntry(name, contract));
|
|
25568
|
+
}
|
|
25569
|
+
|
|
25570
|
+
// ../sdk/src/contracts/prompt.contract.ts
|
|
25571
|
+
function isLucernPrompt(value) {
|
|
25572
|
+
if (!value || typeof value !== "object") {
|
|
25573
|
+
return false;
|
|
25574
|
+
}
|
|
25575
|
+
const prompt = value;
|
|
25576
|
+
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");
|
|
25577
|
+
}
|
|
25578
|
+
|
|
25579
|
+
// ../sdk/src/contracts/workflow-runtime.contract.ts
|
|
25580
|
+
var WORKFLOW_RUNTIME_SCHEMA_VERSION = "1.0.0";
|
|
25581
|
+
var WORKFLOW_MUTATION_TIERS = [
|
|
25582
|
+
"read_only",
|
|
25583
|
+
"low_risk_write",
|
|
25584
|
+
"high_risk_write"
|
|
25585
|
+
];
|
|
25586
|
+
var WORKFLOW_APPROVAL_MODES = [
|
|
25587
|
+
"none",
|
|
25588
|
+
"audit_only",
|
|
25589
|
+
"human_required",
|
|
25590
|
+
"auto_approve"
|
|
25591
|
+
];
|
|
25592
|
+
var DEFAULT_TIER_APPROVAL_MODE = {
|
|
25593
|
+
read_only: "none",
|
|
25594
|
+
low_risk_write: "audit_only",
|
|
25595
|
+
high_risk_write: "human_required"
|
|
25596
|
+
};
|
|
25597
|
+
var WORKFLOW_ACTION_KINDS = [
|
|
25598
|
+
"context_pack",
|
|
25599
|
+
"integrity_check",
|
|
25600
|
+
"lucern_tool",
|
|
25601
|
+
"report_compile",
|
|
25602
|
+
"brief_publish",
|
|
25603
|
+
"notification",
|
|
25604
|
+
"custom"
|
|
25605
|
+
];
|
|
25606
|
+
var WORKFLOW_HOOK_EVENTS = [
|
|
25607
|
+
"schedule.tick",
|
|
25608
|
+
"worktree.activated",
|
|
25609
|
+
"worktree.completed",
|
|
25610
|
+
"question.created",
|
|
25611
|
+
"question.answered",
|
|
25612
|
+
"evidence.appended",
|
|
25613
|
+
"inbox.item_created"
|
|
25614
|
+
];
|
|
25615
|
+
var WORKFLOW_OUTPUT_KINDS = [
|
|
25616
|
+
"engineering_brief",
|
|
25617
|
+
"research_memo",
|
|
25618
|
+
"strategy_artifact",
|
|
25619
|
+
"inbox_summary",
|
|
25620
|
+
"pipeline_brief",
|
|
25621
|
+
"structured_payload"
|
|
25622
|
+
];
|
|
25623
|
+
var WORKFLOW_RUN_STATUSES = [
|
|
25624
|
+
"queued",
|
|
25625
|
+
"running",
|
|
25626
|
+
"awaiting_approval",
|
|
25627
|
+
"completed",
|
|
25628
|
+
"failed",
|
|
25629
|
+
"cancelled"
|
|
25630
|
+
];
|
|
25631
|
+
var WORKFLOW_TRIGGER_KINDS = [
|
|
25632
|
+
"manual",
|
|
25633
|
+
"schedule",
|
|
25634
|
+
"hook"
|
|
25635
|
+
];
|
|
25636
|
+
var WORKFLOW_PROOF_ARTIFACT_KINDS = [
|
|
25637
|
+
"report",
|
|
25638
|
+
"brief",
|
|
25639
|
+
"artifact",
|
|
25640
|
+
"dashboard",
|
|
25641
|
+
"test_evidence"
|
|
25642
|
+
];
|
|
25643
|
+
var WORKFLOW_STAFFING_HINTS = [
|
|
25644
|
+
"solo",
|
|
25645
|
+
"backend+tests",
|
|
25646
|
+
"fullstack",
|
|
25647
|
+
"mcp+tests"
|
|
25648
|
+
];
|
|
25649
|
+
var WORKFLOW_AUTO_FIX_MODES = [
|
|
25650
|
+
"disabled",
|
|
25651
|
+
"dry_run",
|
|
25652
|
+
"safe",
|
|
25653
|
+
"aggressive"
|
|
25654
|
+
];
|
|
25655
|
+
var WORKFLOW_INTEGRITY_CHECKS = [
|
|
25656
|
+
"null_dependency_refs",
|
|
25657
|
+
"superseded_blockers",
|
|
25658
|
+
"band_order_inconsistency",
|
|
25659
|
+
"sparse_shaping",
|
|
25660
|
+
"failed_completed_gate"
|
|
25661
|
+
];
|
|
25662
|
+
var DEFAULT_WORKFLOW_AUTO_FIX_POLICY = {
|
|
25663
|
+
mode: "disabled",
|
|
25664
|
+
permittedMutationTiers: ["read_only"],
|
|
25665
|
+
requireAuditTrail: true
|
|
25666
|
+
};
|
|
25667
|
+
var NIGHTLY_RECONCILIATION_WORKFLOW_ID = "workflow.pipeline_reconciliation.v1";
|
|
25668
|
+
var MORNING_BRIEF_WORKFLOW_ID = "workflow.morning_brief.v1";
|
|
25669
|
+
var CANONICAL_WORKFLOW_DEFINITIONS = [
|
|
25670
|
+
{
|
|
25671
|
+
workflowId: NIGHTLY_RECONCILIATION_WORKFLOW_ID,
|
|
25672
|
+
version: WORKFLOW_RUNTIME_SCHEMA_VERSION,
|
|
25673
|
+
title: "Nightly Pipeline Reconciliation",
|
|
25674
|
+
description: "Runs deterministic integrity checks, compiles pipeline state, and emits an operator-facing reconciliation brief.",
|
|
25675
|
+
trigger: {
|
|
25676
|
+
kind: "schedule",
|
|
25677
|
+
cadence: "daily",
|
|
25678
|
+
timezone: "America/New_York"
|
|
25679
|
+
},
|
|
25680
|
+
staffingHint: "backend+tests",
|
|
25681
|
+
proofArtifacts: [
|
|
25682
|
+
{
|
|
25683
|
+
kind: "report",
|
|
25684
|
+
label: "Pipeline reconciliation report",
|
|
25685
|
+
required: true
|
|
25686
|
+
},
|
|
25687
|
+
{
|
|
25688
|
+
kind: "test_evidence",
|
|
25689
|
+
label: "Integrity check receipt",
|
|
25690
|
+
required: true
|
|
25691
|
+
}
|
|
25692
|
+
],
|
|
25693
|
+
autoFixPolicy: {
|
|
25694
|
+
mode: "safe",
|
|
25695
|
+
maxActionsPerRun: 5,
|
|
25696
|
+
permittedMutationTiers: ["read_only", "low_risk_write"],
|
|
25697
|
+
requireAuditTrail: true,
|
|
25698
|
+
escalationGate: "gate:workflow-runtime-contract-live"
|
|
25699
|
+
},
|
|
25700
|
+
actions: [
|
|
25701
|
+
{
|
|
25702
|
+
actionId: "compile_context_pack",
|
|
25703
|
+
kind: "context_pack",
|
|
25704
|
+
title: "Compile pipeline context",
|
|
25705
|
+
description: "Build the ranked context needed for deterministic checks.",
|
|
25706
|
+
mutationTier: "read_only",
|
|
25707
|
+
produces: ["structured_payload"],
|
|
25708
|
+
idempotent: true,
|
|
25709
|
+
approval: { mode: "none" }
|
|
25710
|
+
},
|
|
25711
|
+
{
|
|
25712
|
+
actionId: "run_integrity_checks",
|
|
25713
|
+
kind: "integrity_check",
|
|
25714
|
+
title: "Run integrity checks",
|
|
25715
|
+
description: "Evaluate dependency references, blockers, campaign/lane placement, shaping coverage, and completed gates.",
|
|
25716
|
+
mutationTier: "read_only",
|
|
25717
|
+
produces: ["structured_payload"],
|
|
25718
|
+
idempotent: true,
|
|
25719
|
+
approval: { mode: "none" }
|
|
25720
|
+
},
|
|
25721
|
+
{
|
|
25722
|
+
actionId: "record_followup_questions",
|
|
25723
|
+
kind: "lucern_tool",
|
|
25724
|
+
title: "Record follow-up questions",
|
|
25725
|
+
description: "Create or reopen operator-facing questions for integrity failures that require human review.",
|
|
25726
|
+
mutationTier: "low_risk_write",
|
|
25727
|
+
toolName: "create_question",
|
|
25728
|
+
produces: ["pipeline_brief"],
|
|
25729
|
+
approval: { mode: "audit_only", rationaleRequired: true }
|
|
25730
|
+
},
|
|
25731
|
+
{
|
|
25732
|
+
actionId: "publish_reconciliation_brief",
|
|
25733
|
+
kind: "brief_publish",
|
|
25734
|
+
title: "Publish reconciliation brief",
|
|
25735
|
+
description: "Emit an inbox-routed brief summarizing the nightly pipeline state and grouped blockers.",
|
|
25736
|
+
mutationTier: "low_risk_write",
|
|
25737
|
+
produces: ["pipeline_brief", "inbox_summary"],
|
|
25738
|
+
approval: { mode: "audit_only" }
|
|
25739
|
+
}
|
|
25740
|
+
],
|
|
25741
|
+
hooks: [
|
|
25742
|
+
{
|
|
25743
|
+
hookId: "nightly-schedule",
|
|
25744
|
+
event: "schedule.tick",
|
|
25745
|
+
description: "Run once per nightly cadence.",
|
|
25746
|
+
actionIds: [
|
|
25747
|
+
"compile_context_pack",
|
|
25748
|
+
"run_integrity_checks",
|
|
25749
|
+
"record_followup_questions",
|
|
25750
|
+
"publish_reconciliation_brief"
|
|
25751
|
+
]
|
|
25752
|
+
}
|
|
25753
|
+
],
|
|
25754
|
+
outputs: ["pipeline_brief", "inbox_summary", "structured_payload"],
|
|
25755
|
+
integrityChecks: WORKFLOW_INTEGRITY_CHECKS
|
|
25756
|
+
},
|
|
25757
|
+
{
|
|
25758
|
+
workflowId: MORNING_BRIEF_WORKFLOW_ID,
|
|
25759
|
+
version: WORKFLOW_RUNTIME_SCHEMA_VERSION,
|
|
25760
|
+
title: "Morning Brief",
|
|
25761
|
+
description: "Compiles a developer-facing morning brief from graph state, overnight workflow outputs, and inbox routing preferences.",
|
|
25762
|
+
trigger: {
|
|
25763
|
+
kind: "schedule",
|
|
25764
|
+
cadence: "daily",
|
|
25765
|
+
timezone: "America/New_York"
|
|
25766
|
+
},
|
|
25767
|
+
staffingHint: "solo",
|
|
25768
|
+
proofArtifacts: [
|
|
25769
|
+
{
|
|
25770
|
+
kind: "brief",
|
|
25771
|
+
label: "Morning brief",
|
|
25772
|
+
required: true
|
|
25773
|
+
}
|
|
25774
|
+
],
|
|
25775
|
+
autoFixPolicy: {
|
|
25776
|
+
mode: "dry_run",
|
|
25777
|
+
maxActionsPerRun: 1,
|
|
25778
|
+
permittedMutationTiers: ["read_only", "low_risk_write"],
|
|
25779
|
+
requireAuditTrail: true
|
|
25780
|
+
},
|
|
25781
|
+
actions: [
|
|
25782
|
+
{
|
|
25783
|
+
actionId: "compile_brief_inputs",
|
|
25784
|
+
kind: "context_pack",
|
|
25785
|
+
title: "Compile brief inputs",
|
|
25786
|
+
description: "Read graph state, worktree state, and overnight workflow receipts.",
|
|
25787
|
+
mutationTier: "read_only",
|
|
25788
|
+
produces: ["structured_payload"],
|
|
25789
|
+
idempotent: true,
|
|
25790
|
+
approval: { mode: "none" }
|
|
25791
|
+
},
|
|
25792
|
+
{
|
|
25793
|
+
actionId: "publish_morning_brief",
|
|
25794
|
+
kind: "brief_publish",
|
|
25795
|
+
title: "Publish morning brief",
|
|
25796
|
+
description: "Publish a typed inbox summary with prioritized worktree and question context.",
|
|
25797
|
+
mutationTier: "low_risk_write",
|
|
25798
|
+
produces: ["engineering_brief", "inbox_summary"],
|
|
25799
|
+
approval: { mode: "audit_only" }
|
|
25800
|
+
}
|
|
25801
|
+
],
|
|
25802
|
+
hooks: [
|
|
25803
|
+
{
|
|
25804
|
+
hookId: "morning-schedule",
|
|
25805
|
+
event: "schedule.tick",
|
|
25806
|
+
description: "Run once per morning cadence.",
|
|
25807
|
+
actionIds: ["compile_brief_inputs", "publish_morning_brief"]
|
|
25808
|
+
},
|
|
25809
|
+
{
|
|
25810
|
+
hookId: "worktree-complete-refresh",
|
|
25811
|
+
event: "worktree.completed",
|
|
25812
|
+
description: "Refresh the queued morning brief inputs when worktree outcomes land overnight.",
|
|
25813
|
+
actionIds: ["compile_brief_inputs"]
|
|
25814
|
+
}
|
|
25815
|
+
],
|
|
25816
|
+
outputs: ["engineering_brief", "inbox_summary", "structured_payload"],
|
|
25817
|
+
integrityChecks: ["sparse_shaping"]
|
|
25818
|
+
}
|
|
25819
|
+
];
|
|
25820
|
+
|
|
25821
|
+
// ../sdk/src/events.ts
|
|
25822
|
+
var DOMAIN_EVENT_VERSION = "1.0";
|
|
25823
|
+
var EVENT_RETENTION_DEFAULT_DAYS = 30;
|
|
25824
|
+
var WEBHOOK_MAX_ATTEMPTS = 5;
|
|
25825
|
+
var WEBHOOK_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 3e5];
|
|
25826
|
+
var DOMAIN_EVENT_TYPES = [
|
|
25827
|
+
"belief.created",
|
|
25828
|
+
"belief.forked",
|
|
25829
|
+
"belief.confidence_updated",
|
|
25830
|
+
"belief.archived",
|
|
25831
|
+
"belief.refined",
|
|
25832
|
+
"belief.contract_created",
|
|
25833
|
+
"belief.contract_evaluated",
|
|
25834
|
+
"belief.lineage_queried",
|
|
25835
|
+
"evidence.created",
|
|
25836
|
+
"evidence.linked",
|
|
25837
|
+
"evidence.search_executed",
|
|
25838
|
+
"question.created",
|
|
25839
|
+
"question.answered",
|
|
25840
|
+
"question.refined",
|
|
25841
|
+
"question.status_updated",
|
|
25842
|
+
"question.archived",
|
|
25843
|
+
"edge.created",
|
|
25844
|
+
"contradiction.flagged",
|
|
25845
|
+
"worktree.created",
|
|
25846
|
+
"worktree.activated",
|
|
25847
|
+
"worktree.merged",
|
|
25848
|
+
"worktree.targets_updated",
|
|
25849
|
+
"worktree.metadata_updated",
|
|
25850
|
+
"topic.created",
|
|
25851
|
+
"topic.updated",
|
|
25852
|
+
"topic.archived",
|
|
25853
|
+
"task.created",
|
|
25854
|
+
"task.completed",
|
|
25855
|
+
"task.updated",
|
|
25856
|
+
"ontology.bound",
|
|
25857
|
+
"context.compiled",
|
|
25858
|
+
"identity.key_created",
|
|
25859
|
+
"identity.key_rotated",
|
|
25860
|
+
"identity.key_revoked",
|
|
25861
|
+
"webhook.test"
|
|
25862
|
+
];
|
|
25863
|
+
var RUNTIME_BUFFER2 = globalThis.Buffer;
|
|
25864
|
+
var RUNTIME_ENV = globalThis.process?.env;
|
|
25865
|
+
function escapeRegex(value) {
|
|
25866
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25867
|
+
}
|
|
25868
|
+
function eventPatternToRegExp(pattern) {
|
|
25869
|
+
const normalized = pattern.trim();
|
|
25870
|
+
if (!normalized) {
|
|
25871
|
+
return /^$/;
|
|
25872
|
+
}
|
|
25873
|
+
if (normalized === "*") {
|
|
25874
|
+
return /^.*$/;
|
|
25875
|
+
}
|
|
25876
|
+
const source = escapeRegex(normalized).replace(/\\\*/g, ".*");
|
|
25877
|
+
return new RegExp(`^${source}$`);
|
|
25878
|
+
}
|
|
25879
|
+
function matchesEventPattern(eventType, pattern) {
|
|
25880
|
+
return eventPatternToRegExp(pattern).test(eventType.trim());
|
|
25881
|
+
}
|
|
25882
|
+
function matchesAnyEventPattern(eventType, patterns) {
|
|
25883
|
+
if (patterns.length === 0) {
|
|
25884
|
+
return true;
|
|
25885
|
+
}
|
|
25886
|
+
return patterns.some((pattern) => matchesEventPattern(eventType, pattern));
|
|
25887
|
+
}
|
|
25888
|
+
function toBase64(value) {
|
|
25889
|
+
if (RUNTIME_BUFFER2) {
|
|
25890
|
+
return RUNTIME_BUFFER2.from(value, "utf8").toString("base64url");
|
|
25891
|
+
}
|
|
25892
|
+
return btoa(unescape(encodeURIComponent(value))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
25893
|
+
}
|
|
25894
|
+
function fromBase64(value) {
|
|
25895
|
+
if (RUNTIME_BUFFER2) {
|
|
25896
|
+
return RUNTIME_BUFFER2.from(value, "base64url").toString("utf8");
|
|
25897
|
+
}
|
|
25898
|
+
const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
25899
|
+
return decodeURIComponent(escape(atob(normalized)));
|
|
25900
|
+
}
|
|
25901
|
+
function createEventId() {
|
|
25902
|
+
const random = typeof globalThis.crypto?.randomUUID === "function" ? globalThis.crypto.randomUUID().replace(/-/g, "") : Array.from(
|
|
25903
|
+
typeof globalThis.crypto?.getRandomValues === "function" ? globalThis.crypto.getRandomValues(new Uint8Array(16)) : Array.from({ length: 16 }, () => Math.floor(Math.random() * 256)),
|
|
25904
|
+
(value) => value.toString(16).padStart(2, "0")
|
|
25905
|
+
).join("");
|
|
25906
|
+
return `evt_${random}`;
|
|
25907
|
+
}
|
|
25908
|
+
function normalizeRetentionDays(value) {
|
|
25909
|
+
if (!Number.isFinite(value) || typeof value !== "number" || value <= 0) {
|
|
25910
|
+
return EVENT_RETENTION_DEFAULT_DAYS;
|
|
25911
|
+
}
|
|
25912
|
+
return Math.max(1, Math.trunc(value));
|
|
25913
|
+
}
|
|
25914
|
+
function buildDomainEvent(input) {
|
|
25915
|
+
const timestamp = input.timestamp ?? Date.now();
|
|
25916
|
+
const retentionDays = normalizeRetentionDays(input.retentionDays);
|
|
25917
|
+
return {
|
|
25918
|
+
eventId: input.eventId?.trim() || createEventId(),
|
|
25919
|
+
type: input.type.trim(),
|
|
25920
|
+
version: DOMAIN_EVENT_VERSION,
|
|
25921
|
+
timestamp,
|
|
25922
|
+
tenantId: input.tenantId?.trim() || void 0,
|
|
25923
|
+
workspaceId: input.workspaceId?.trim() || void 0,
|
|
25924
|
+
topicId: input.topicId.trim(),
|
|
25925
|
+
resourceId: input.resourceId.trim(),
|
|
25926
|
+
resourceType: input.resourceType.trim(),
|
|
25927
|
+
actorId: input.actorId.trim(),
|
|
25928
|
+
actorType: input.actorType,
|
|
25929
|
+
data: input.data ?? {},
|
|
25930
|
+
correlationId: input.correlationId?.trim() || void 0,
|
|
25931
|
+
expiresAt: timestamp + retentionDays * 24 * 60 * 60 * 1e3
|
|
25932
|
+
};
|
|
25933
|
+
}
|
|
25934
|
+
function compareEventCursor(left, right) {
|
|
25935
|
+
if (left.timestamp !== right.timestamp) {
|
|
25936
|
+
return left.timestamp - right.timestamp;
|
|
25937
|
+
}
|
|
25938
|
+
return left.eventId.localeCompare(right.eventId);
|
|
25939
|
+
}
|
|
25940
|
+
function encodeEventCursor(cursor) {
|
|
25941
|
+
return toBase64(JSON.stringify(cursor));
|
|
25942
|
+
}
|
|
25943
|
+
function decodeEventCursor(cursor) {
|
|
25944
|
+
if (!cursor || cursor.trim().length === 0) {
|
|
25945
|
+
return null;
|
|
25946
|
+
}
|
|
25947
|
+
try {
|
|
25948
|
+
const parsed = JSON.parse(fromBase64(cursor.trim()));
|
|
25949
|
+
if (typeof parsed.timestamp !== "number" || !Number.isFinite(parsed.timestamp) || typeof parsed.eventId !== "string" || parsed.eventId.trim().length === 0) {
|
|
25950
|
+
return null;
|
|
22601
25951
|
}
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
|
|
25952
|
+
return {
|
|
25953
|
+
timestamp: parsed.timestamp,
|
|
25954
|
+
eventId: parsed.eventId.trim()
|
|
25955
|
+
};
|
|
25956
|
+
} catch {
|
|
25957
|
+
return null;
|
|
25958
|
+
}
|
|
25959
|
+
}
|
|
25960
|
+
function isAfterCursor(event, cursor) {
|
|
25961
|
+
if (!cursor) {
|
|
25962
|
+
return true;
|
|
25963
|
+
}
|
|
25964
|
+
return compareEventCursor(event, cursor) > 0;
|
|
25965
|
+
}
|
|
25966
|
+
function sortEventsByCursor(events) {
|
|
25967
|
+
return [...events].sort((left, right) => compareEventCursor(left, right));
|
|
25968
|
+
}
|
|
25969
|
+
function inferActorType(args) {
|
|
25970
|
+
if (args.sessionType === "agent") {
|
|
25971
|
+
return "agent";
|
|
25972
|
+
}
|
|
25973
|
+
if (args.authMode === "service_principal" || args.authMode === "tenant_api_key" || args.principalType === "service") {
|
|
25974
|
+
return "service";
|
|
25975
|
+
}
|
|
25976
|
+
return "human";
|
|
25977
|
+
}
|
|
25978
|
+
async function emitDomainEvent(invokeMutation, input) {
|
|
25979
|
+
return await invokeMutation("events:recordEvent", input);
|
|
25980
|
+
}
|
|
25981
|
+
var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
|
|
25982
|
+
function normalizeUrl(url) {
|
|
25983
|
+
try {
|
|
25984
|
+
return new URL(url.trim());
|
|
25985
|
+
} catch {
|
|
25986
|
+
throw new Error("Webhook URL must be a valid absolute URL.");
|
|
25987
|
+
}
|
|
25988
|
+
}
|
|
25989
|
+
function assertValidWebhookUrl(url) {
|
|
25990
|
+
const parsed = normalizeUrl(url);
|
|
25991
|
+
const hostname = parsed.hostname.trim().toLowerCase();
|
|
25992
|
+
const nodeEnv = RUNTIME_ENV?.NODE_ENV;
|
|
25993
|
+
const allowLocalHttp = nodeEnv === "test" || LOCALHOST_HOSTS.has(hostname);
|
|
25994
|
+
if (parsed.protocol !== "https:" && !(allowLocalHttp && parsed.protocol === "http:")) {
|
|
25995
|
+
throw new Error("Webhook URL must use HTTPS.");
|
|
25996
|
+
}
|
|
25997
|
+
return parsed.toString();
|
|
25998
|
+
}
|
|
25999
|
+
function normalizeWebhookPatterns(patterns) {
|
|
26000
|
+
const normalized = Array.from(
|
|
26001
|
+
new Set(
|
|
26002
|
+
patterns.map((pattern) => pattern.trim()).filter((pattern) => pattern.length > 0)
|
|
26003
|
+
)
|
|
26004
|
+
);
|
|
26005
|
+
if (normalized.length === 0) {
|
|
26006
|
+
throw new Error("At least one webhook event pattern is required.");
|
|
26007
|
+
}
|
|
26008
|
+
return normalized;
|
|
26009
|
+
}
|
|
26010
|
+
function assertValidWebhookSecret(secret) {
|
|
26011
|
+
const normalized = secret.trim();
|
|
26012
|
+
if (normalized.length < 8) {
|
|
26013
|
+
throw new Error("Webhook secret must be at least 8 characters.");
|
|
26014
|
+
}
|
|
26015
|
+
return normalized;
|
|
26016
|
+
}
|
|
26017
|
+
async function computeWebhookSignature(payload, secret) {
|
|
26018
|
+
const encoder = new TextEncoder();
|
|
26019
|
+
const key = await crypto.subtle.importKey(
|
|
26020
|
+
"raw",
|
|
26021
|
+
encoder.encode(secret),
|
|
26022
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
26023
|
+
false,
|
|
26024
|
+
["sign"]
|
|
26025
|
+
);
|
|
26026
|
+
const signature = await crypto.subtle.sign("HMAC", key, encoder.encode(payload));
|
|
26027
|
+
return Array.from(new Uint8Array(signature)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
26028
|
+
}
|
|
26029
|
+
function nextDeliveryAttemptAt(currentAttemptCount, now = Date.now()) {
|
|
26030
|
+
if (currentAttemptCount >= WEBHOOK_MAX_ATTEMPTS) {
|
|
26031
|
+
return void 0;
|
|
26032
|
+
}
|
|
26033
|
+
const retryIndex = currentAttemptCount - 1;
|
|
26034
|
+
const delay2 = WEBHOOK_RETRY_DELAYS_MS[retryIndex];
|
|
26035
|
+
return typeof delay2 === "number" ? now + delay2 : void 0;
|
|
26036
|
+
}
|
|
26037
|
+
function resolveDeliveryFailureStatus(attemptCount) {
|
|
26038
|
+
return attemptCount >= WEBHOOK_MAX_ATTEMPTS ? "dead_letter" : "failed";
|
|
26039
|
+
}
|
|
26040
|
+
function sanitizeWebhookRecord(value) {
|
|
26041
|
+
return {
|
|
26042
|
+
id: String(value.id ?? value.webhookId ?? value._id ?? ""),
|
|
26043
|
+
webhookId: String(value.webhookId ?? value.id ?? value._id ?? ""),
|
|
26044
|
+
tenantId: typeof value.tenantId === "string" && value.tenantId.trim().length > 0 ? value.tenantId : void 0,
|
|
26045
|
+
workspaceId: typeof value.workspaceId === "string" && value.workspaceId.trim().length > 0 ? value.workspaceId : void 0,
|
|
26046
|
+
topicId: typeof value.topicId === "string" && value.topicId.trim().length > 0 ? value.topicId : void 0,
|
|
26047
|
+
url: String(value.url ?? ""),
|
|
26048
|
+
events: Array.isArray(value.events) ? value.events.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean) : [],
|
|
26049
|
+
active: value.active !== false,
|
|
26050
|
+
secretConfigured: true,
|
|
26051
|
+
createdAt: Number(value.createdAt ?? Date.now()),
|
|
26052
|
+
updatedAt: Number(value.updatedAt ?? value.createdAt ?? Date.now()),
|
|
26053
|
+
createdBy: String(value.createdBy ?? ""),
|
|
26054
|
+
updatedBy: String(value.updatedBy ?? value.createdBy ?? ""),
|
|
26055
|
+
lastDeliveryAt: typeof value.lastDeliveryAt === "number" ? value.lastDeliveryAt : void 0,
|
|
26056
|
+
lastSuccessfulDeliveryAt: typeof value.lastSuccessfulDeliveryAt === "number" ? value.lastSuccessfulDeliveryAt : void 0
|
|
26057
|
+
};
|
|
26058
|
+
}
|
|
26059
|
+
function truncateWebhookResponseBody(responseBody, maxLength = 2e3) {
|
|
26060
|
+
if (!responseBody) {
|
|
26061
|
+
return void 0;
|
|
26062
|
+
}
|
|
26063
|
+
if (responseBody.length <= maxLength) {
|
|
26064
|
+
return responseBody;
|
|
26065
|
+
}
|
|
26066
|
+
return `${responseBody.slice(0, maxLength - 3)}...`;
|
|
26067
|
+
}
|
|
26068
|
+
|
|
26069
|
+
// ../sdk/src/eventsCore.ts
|
|
26070
|
+
function serializeTypes2(types) {
|
|
26071
|
+
return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
|
|
26072
|
+
}
|
|
26073
|
+
function createEventsClientCore(config = {}) {
|
|
26074
|
+
const gateway = createGatewayRequestClient(config);
|
|
26075
|
+
return {
|
|
26076
|
+
async list(query5 = {}) {
|
|
26077
|
+
return gateway.request({
|
|
26078
|
+
path: `/v1/events${toQueryString({
|
|
26079
|
+
topicId: query5.topicId,
|
|
26080
|
+
after: query5.after,
|
|
26081
|
+
types: serializeTypes2(query5.types),
|
|
26082
|
+
startTime: query5.startTime,
|
|
26083
|
+
endTime: query5.endTime,
|
|
26084
|
+
limit: query5.limit
|
|
26085
|
+
})}`
|
|
26086
|
+
});
|
|
26087
|
+
},
|
|
26088
|
+
async replay(input, idempotencyKey = randomIdempotencyKey()) {
|
|
26089
|
+
return gateway.request({
|
|
26090
|
+
path: "/v1/events/replay",
|
|
26091
|
+
method: "POST",
|
|
26092
|
+
body: input,
|
|
26093
|
+
idempotencyKey
|
|
26094
|
+
});
|
|
22612
26095
|
}
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
|
|
26096
|
+
};
|
|
26097
|
+
}
|
|
26098
|
+
function createWebhooksClientCore(config = {}) {
|
|
26099
|
+
const gateway = createGatewayRequestClient(config);
|
|
26100
|
+
return {
|
|
26101
|
+
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
26102
|
+
return gateway.request({
|
|
26103
|
+
path: "/v1/webhooks",
|
|
26104
|
+
method: "POST",
|
|
26105
|
+
body: input,
|
|
26106
|
+
idempotencyKey
|
|
26107
|
+
});
|
|
22623
26108
|
},
|
|
22624
|
-
{
|
|
22625
|
-
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22630
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
22631
|
-
blastRadius: "tenant"
|
|
26109
|
+
async list(query5 = {}) {
|
|
26110
|
+
return gateway.request({
|
|
26111
|
+
path: `/v1/webhooks${toQueryString({
|
|
26112
|
+
topicId: query5.topicId
|
|
26113
|
+
})}`
|
|
26114
|
+
});
|
|
22632
26115
|
},
|
|
22633
|
-
{
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22638
|
-
|
|
22639
|
-
|
|
22640
|
-
|
|
26116
|
+
async get(id) {
|
|
26117
|
+
return gateway.request({
|
|
26118
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}`
|
|
26119
|
+
});
|
|
26120
|
+
},
|
|
26121
|
+
async update(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
26122
|
+
return gateway.request({
|
|
26123
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}`,
|
|
26124
|
+
method: "PATCH",
|
|
26125
|
+
body: input,
|
|
26126
|
+
idempotencyKey
|
|
26127
|
+
});
|
|
26128
|
+
},
|
|
26129
|
+
async delete(id, idempotencyKey = randomIdempotencyKey()) {
|
|
26130
|
+
return gateway.request({
|
|
26131
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}`,
|
|
26132
|
+
method: "DELETE",
|
|
26133
|
+
idempotencyKey
|
|
26134
|
+
});
|
|
26135
|
+
},
|
|
26136
|
+
async test(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
|
|
26137
|
+
return gateway.request({
|
|
26138
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}/test`,
|
|
26139
|
+
method: "POST",
|
|
26140
|
+
body: input,
|
|
26141
|
+
idempotencyKey
|
|
26142
|
+
});
|
|
26143
|
+
},
|
|
26144
|
+
async deliveries(id, query5 = {}) {
|
|
26145
|
+
return gateway.request({
|
|
26146
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
|
|
26147
|
+
limit: query5.limit
|
|
26148
|
+
})}`
|
|
26149
|
+
});
|
|
26150
|
+
},
|
|
26151
|
+
async health(id) {
|
|
26152
|
+
return gateway.request({
|
|
26153
|
+
path: `/v1/webhooks/${encodeURIComponent(id)}/health`
|
|
26154
|
+
});
|
|
22641
26155
|
}
|
|
22642
|
-
|
|
22643
|
-
};
|
|
22644
|
-
function flattenOwnershipMatrix(matrix) {
|
|
22645
|
-
return CONTROL_OBJECT_KINDS.flatMap((kind) => [...matrix[kind]]);
|
|
26156
|
+
};
|
|
22646
26157
|
}
|
|
22647
|
-
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
|
|
26158
|
+
|
|
26159
|
+
// ../sdk/src/graphIntel.ts
|
|
26160
|
+
var graphIntel_exports = {};
|
|
26161
|
+
__reExport(graphIntel_exports, graphIntel_star);
|
|
26162
|
+
|
|
26163
|
+
// ../sdk/src/index.ts
|
|
26164
|
+
__reExport(src_exports, graphIntel_exports);
|
|
26165
|
+
|
|
26166
|
+
// ../sdk/src/graphIntelligence.ts
|
|
26167
|
+
var graphIntelligence_exports = {};
|
|
26168
|
+
__export(graphIntelligence_exports, {
|
|
26169
|
+
GRAPH_INTELLIGENCE_MODE_TOOL_NAMES: () => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES,
|
|
26170
|
+
GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES: () => GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES,
|
|
26171
|
+
GRAPH_INTELLIGENCE_QUERIES: () => GRAPH_INTELLIGENCE_QUERIES,
|
|
26172
|
+
GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS: () => GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS,
|
|
26173
|
+
GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION: () => GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION,
|
|
26174
|
+
GRAPH_INTELLIGENCE_QUERY_CATEGORIES: () => GRAPH_INTELLIGENCE_QUERY_CATEGORIES,
|
|
26175
|
+
GRAPH_INTELLIGENCE_QUERY_MODES: () => GRAPH_INTELLIGENCE_QUERY_MODES,
|
|
26176
|
+
GRAPH_INTELLIGENCE_QUICK_QUERIES: () => GRAPH_INTELLIGENCE_QUICK_QUERIES,
|
|
26177
|
+
fillGraphIntelligencePromptTemplate: () => fillGraphIntelligencePromptTemplate,
|
|
26178
|
+
getGraphIntelligenceQuery: () => getGraphIntelligenceQuery,
|
|
26179
|
+
isGraphIntelligenceQueryMode: () => isGraphIntelligenceQueryMode,
|
|
26180
|
+
listGraphIntelligenceQueries: () => listGraphIntelligenceQueries
|
|
26181
|
+
});
|
|
26182
|
+
__reExport(graphIntelligence_exports, graphIntel_exports);
|
|
26183
|
+
|
|
26184
|
+
// ../sdk/src/index.ts
|
|
26185
|
+
__reExport(src_exports, graphIntelligence_exports);
|
|
22651
26186
|
|
|
22652
26187
|
// src/execution.ts
|
|
22653
26188
|
var SCOPE_ALIAS_GROUPS = [];
|
|
@@ -24395,9 +27930,9 @@ var MCP_RATE_LIMIT_SIGNALS = [
|
|
|
24395
27930
|
"RATE_LIMIT_EXCEEDED",
|
|
24396
27931
|
"Retry-After"
|
|
24397
27932
|
];
|
|
24398
|
-
var
|
|
27933
|
+
var OPERATION_MANIFEST2 = LUCERN_OPERATION_MANIFEST;
|
|
24399
27934
|
function mcpExposureFor(toolName) {
|
|
24400
|
-
return
|
|
27935
|
+
return OPERATION_MANIFEST2[toolName]?.surfaces.mcp ?? "none";
|
|
24401
27936
|
}
|
|
24402
27937
|
function withManifestVisibility(toolName, contract) {
|
|
24403
27938
|
return mcpExposureFor(toolName) === "internal" || contract.internal ? { ...contract, internal: true } : contract;
|