@lucern/mcp 0.3.0-alpha.7 → 0.3.0-alpha.9

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/runtime.js CHANGED
@@ -4924,17 +4924,44 @@ z.object({
4924
4924
  message: "SL invariant b+d+u=1 violated at API boundary"
4925
4925
  }
4926
4926
  );
4927
- var EpistemicNodeTypeSchema = z.enum([
4927
+
4928
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
4929
+ var NODE_TYPES = [
4930
+ "decision",
4928
4931
  "belief",
4929
- "evidence",
4930
4932
  "question",
4931
- "answer",
4933
+ "theme",
4934
+ "deal",
4932
4935
  "topic",
4936
+ "claim",
4937
+ "evidence",
4938
+ "synthesis",
4939
+ "answer",
4940
+ "atomic_fact",
4941
+ "excerpt",
4942
+ "source",
4943
+ "company",
4944
+ "person",
4945
+ "investor",
4946
+ "function",
4947
+ "value_chain"
4948
+ ];
4949
+ new Set(NODE_TYPES);
4950
+
4951
+ // ../contracts/src/types/graph-ref.ts
4952
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
4933
4953
  "edge",
4934
4954
  "ontology",
4935
4955
  "lens",
4936
4956
  "contradiction"
4937
- ]);
4957
+ ];
4958
+ var GRAPH_REF_NODE_TYPES = [
4959
+ ...NODE_TYPES,
4960
+ ...GRAPH_REF_EXTRA_NODE_TYPES
4961
+ ];
4962
+ var EpistemicNodeTypeSchema = z.enum(
4963
+ GRAPH_REF_NODE_TYPES
4964
+ );
4938
4965
  var GraphRefSchema = z.discriminatedUnion("kind", [
4939
4966
  z.object({
4940
4967
  kind: z.literal("epistemic_node"),
@@ -4982,33 +5009,14 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4982
5009
  }
4983
5010
 
4984
5011
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
5012
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
5013
+ edgeType,
5014
+ fromKinds: ["epistemic_node"],
5015
+ toKinds: ["epistemic_node"],
5016
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
5017
+ });
4985
5018
  var edgePolicyManifest = {
4986
- policies: [
4987
- {
4988
- edgeType: "evidence_derived_from_evidence",
4989
- fromKinds: ["epistemic_node"],
4990
- fromNodeTypes: ["evidence"],
4991
- toKinds: ["epistemic_node"],
4992
- toNodeTypes: ["evidence"],
4993
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4994
- },
4995
- {
4996
- edgeType: "evidence_supports_belief",
4997
- fromKinds: ["epistemic_node"],
4998
- fromNodeTypes: ["evidence"],
4999
- toKinds: ["epistemic_node"],
5000
- toNodeTypes: ["belief"],
5001
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
5002
- },
5003
- {
5004
- edgeType: "evidence_supports_question",
5005
- fromKinds: ["epistemic_node"],
5006
- fromNodeTypes: ["evidence"],
5007
- toKinds: ["epistemic_node"],
5008
- toNodeTypes: ["question"],
5009
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
5010
- }
5011
- ]
5019
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
5012
5020
  };
5013
5021
 
5014
5022
  // ../contracts/src/tenant-client.contract.ts
@@ -7633,15 +7641,15 @@ var IDENTITY_WHOAMI = {
7633
7641
  };
7634
7642
  var COMPILE_CONTEXT = {
7635
7643
  name: "compile_context",
7636
- description: "Compile a focused reasoning context for a topic. Like `git log --graph --decorate` for the reasoning substrate \u2014 returns the canonical Pillar 3 context pack through the public API shape.",
7644
+ description: "Compile a focused reasoning context. If topicId is omitted, Lucern resolves the best topic from the query. Like `git log --graph --decorate` for the reasoning substrate \u2014 returns the canonical Pillar 3 context pack through the public API shape.",
7637
7645
  parameters: {
7638
7646
  topicId: {
7639
7647
  type: "string",
7640
- description: "Topic scope ID to compile"
7648
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
7641
7649
  },
7642
7650
  query: {
7643
7651
  type: "string",
7644
- description: "Optional focus query used to rank context items"
7652
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
7645
7653
  },
7646
7654
  budget: {
7647
7655
  type: "number",
@@ -7665,7 +7673,7 @@ var COMPILE_CONTEXT = {
7665
7673
  description: "Include related ontological entities in the compiled result"
7666
7674
  }
7667
7675
  },
7668
- required: ["topicId"],
7676
+ required: [],
7669
7677
  response: {
7670
7678
  description: "Compiled context pack for the requested topic",
7671
7679
  fields: {
@@ -10164,7 +10172,7 @@ var contextContracts = [
10164
10172
  path: "/context/compile",
10165
10173
  sdkNamespace: "context",
10166
10174
  sdkMethod: "compileContext",
10167
- summary: "Compile a focused reasoning context for a topic.",
10175
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
10168
10176
  convex: {
10169
10177
  module: "contextCompiler",
10170
10178
  functionName: "compile",
@@ -10630,12 +10638,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
10630
10638
  compactRecord4({
10631
10639
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
10632
10640
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
10633
- edgeType: "evidence_supports_belief",
10641
+ edgeType: "informs",
10634
10642
  globalId: input.globalId ?? `edge:${String(
10635
10643
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
10636
10644
  )}:${String(
10637
10645
  input.beliefNodeId ?? input.beliefId ?? input.targetId
10638
- )}:evidence_supports_belief`,
10646
+ )}:informs`,
10639
10647
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
10640
10648
  context: input.rationale ?? input.context,
10641
10649
  skipLayerValidation: true,
@@ -10648,12 +10656,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
10648
10656
  compactRecord4({
10649
10657
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
10650
10658
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
10651
- edgeType: "evidence_supports_question",
10659
+ edgeType: "responds_to",
10652
10660
  globalId: input.globalId ?? `edge:${String(
10653
10661
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
10654
10662
  )}:${String(
10655
10663
  input.questionId ?? input.questionNodeId ?? input.targetId
10656
- )}:evidence_supports_question`,
10664
+ )}:responds_to`,
10657
10665
  weight: input.impactScore ?? input.weight,
10658
10666
  context: input.rationale ?? input.context,
10659
10667
  skipLayerValidation: true,
@@ -12158,10 +12166,13 @@ var tasksContracts = [
12158
12166
  }
12159
12167
  })
12160
12168
  ];
12169
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12170
+ (policy) => policy.edgeType
12171
+ );
12161
12172
  var createEdgeArgs = z.object({
12162
12173
  from: GraphRefSchema,
12163
12174
  to: GraphRefSchema,
12164
- edgeType: z.string(),
12175
+ edgeType: z.enum(CREATE_EDGE_TYPES),
12165
12176
  globalId: z.string().optional(),
12166
12177
  weight: z.number().optional(),
12167
12178
  confidence: z.number().optional(),
@@ -17032,10 +17043,20 @@ function toPublicCompiledContext(pack) {
17032
17043
  var scopeContextHandlers = {
17033
17044
  async compile_context(args, ctx) {
17034
17045
  const requestedScope = readTopicIdArg(args);
17035
- if (!requestedScope) {
17036
- throw new Error("[compile_context] topicId is required.");
17037
- }
17038
- const topicId = await resolveTopicScopeId(requestedScope, "compile_context");
17046
+ const query = readString(args.query);
17047
+ if (!requestedScope && !query) {
17048
+ throw new Error("[compile_context] query is required when topicId is omitted.");
17049
+ }
17050
+ const topicId = requestedScope ? await resolveTopicScopeId(requestedScope, "compile_context") : (await resolveTopicForWrite(ctx, {
17051
+ workspaceId: readString(args.workspaceId),
17052
+ topicHint: readString(args.topicHint),
17053
+ summary: query ?? "",
17054
+ tags: readStringArray(args.tags),
17055
+ touchedPaths: readStringArray(args.touchedPaths),
17056
+ sourceRef: readString(args.sourceRef),
17057
+ sourceKind: readString(args.sourceKind) ?? "compile_context",
17058
+ autoCreate: false
17059
+ })).topicId;
17039
17060
  if (ctx.sessionType === "user" && Array.isArray(ctx.allowedTopics) && (!ctx.allowedTopics.includes(topicId) || ctx.allowedTopics.length === 0)) {
17040
17061
  throw new Error(
17041
17062
  `[compile_context] Access denied to compile context for topic ${topicId}.`