@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/cli.js CHANGED
@@ -128,9 +128,14 @@ function loadProfile(options) {
128
128
  const profiles = readProfilesFile(profilesPath());
129
129
  const localEnv = options.readLocalEnv === false ? {} : readLocalEnvFiles(options.cwd);
130
130
  const mergedEnv = { ...localEnv, ...options.env };
131
- const selected = options.profileName ?? mergedEnv.LUCERN_PROFILE ?? profiles.activeProfile ?? credentials.LUCERN_PROFILE ?? "default";
132
- const savedProfile = profiles.profiles?.[selected] ?? {};
133
131
  const envProfile = profileFromEnvironment(mergedEnv);
132
+ const hasEnvCredentials = Boolean(
133
+ envProfile.apiKey || envProfile.userToken || envProfile.packKey
134
+ );
135
+ const explicitProfileSelected = options.profileName !== void 0 || mergedEnv.LUCERN_PROFILE !== void 0;
136
+ const selectedProfile = options.profileName ?? mergedEnv.LUCERN_PROFILE ?? profiles.activeProfile ?? credentials.LUCERN_PROFILE ?? "default";
137
+ const selected = hasEnvCredentials && !explicitProfileSelected ? "env" : selectedProfile;
138
+ const savedProfile = hasEnvCredentials && !explicitProfileSelected ? {} : profiles.profiles?.[selectedProfile] ?? {};
134
139
  const credentialsProfile = {
135
140
  apiKey: credentials.LUCERN_API_KEY,
136
141
  userToken: readFirst(credentials, ["LUCERN_SESSION_TOKEN", "LUCERN_USER_TOKEN"]),
@@ -5101,17 +5106,44 @@ z.object({
5101
5106
  message: "SL invariant b+d+u=1 violated at API boundary"
5102
5107
  }
5103
5108
  );
5104
- var EpistemicNodeTypeSchema = z.enum([
5109
+
5110
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
5111
+ var NODE_TYPES = [
5112
+ "decision",
5105
5113
  "belief",
5106
- "evidence",
5107
5114
  "question",
5108
- "answer",
5115
+ "theme",
5116
+ "deal",
5109
5117
  "topic",
5118
+ "claim",
5119
+ "evidence",
5120
+ "synthesis",
5121
+ "answer",
5122
+ "atomic_fact",
5123
+ "excerpt",
5124
+ "source",
5125
+ "company",
5126
+ "person",
5127
+ "investor",
5128
+ "function",
5129
+ "value_chain"
5130
+ ];
5131
+ new Set(NODE_TYPES);
5132
+
5133
+ // ../contracts/src/types/graph-ref.ts
5134
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
5110
5135
  "edge",
5111
5136
  "ontology",
5112
5137
  "lens",
5113
5138
  "contradiction"
5114
- ]);
5139
+ ];
5140
+ var GRAPH_REF_NODE_TYPES = [
5141
+ ...NODE_TYPES,
5142
+ ...GRAPH_REF_EXTRA_NODE_TYPES
5143
+ ];
5144
+ var EpistemicNodeTypeSchema = z.enum(
5145
+ GRAPH_REF_NODE_TYPES
5146
+ );
5115
5147
  var GraphRefSchema = z.discriminatedUnion("kind", [
5116
5148
  z.object({
5117
5149
  kind: z.literal("epistemic_node"),
@@ -5159,33 +5191,14 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
5159
5191
  }
5160
5192
 
5161
5193
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
5194
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
5195
+ edgeType,
5196
+ fromKinds: ["epistemic_node"],
5197
+ toKinds: ["epistemic_node"],
5198
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
5199
+ });
5162
5200
  var edgePolicyManifest = {
5163
- policies: [
5164
- {
5165
- edgeType: "evidence_derived_from_evidence",
5166
- fromKinds: ["epistemic_node"],
5167
- fromNodeTypes: ["evidence"],
5168
- toKinds: ["epistemic_node"],
5169
- toNodeTypes: ["evidence"],
5170
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
5171
- },
5172
- {
5173
- edgeType: "evidence_supports_belief",
5174
- fromKinds: ["epistemic_node"],
5175
- fromNodeTypes: ["evidence"],
5176
- toKinds: ["epistemic_node"],
5177
- toNodeTypes: ["belief"],
5178
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
5179
- },
5180
- {
5181
- edgeType: "evidence_supports_question",
5182
- fromKinds: ["epistemic_node"],
5183
- fromNodeTypes: ["evidence"],
5184
- toKinds: ["epistemic_node"],
5185
- toNodeTypes: ["question"],
5186
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
5187
- }
5188
- ]
5201
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
5189
5202
  };
5190
5203
 
5191
5204
  // ../contracts/src/tenant-client.contract.ts
@@ -7911,15 +7924,15 @@ var IDENTITY_WHOAMI = {
7911
7924
  };
7912
7925
  var COMPILE_CONTEXT = {
7913
7926
  name: "compile_context",
7914
- 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.",
7927
+ 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.",
7915
7928
  parameters: {
7916
7929
  topicId: {
7917
7930
  type: "string",
7918
- description: "Topic scope ID to compile"
7931
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
7919
7932
  },
7920
7933
  query: {
7921
7934
  type: "string",
7922
- description: "Optional focus query used to rank context items"
7935
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
7923
7936
  },
7924
7937
  budget: {
7925
7938
  type: "number",
@@ -7943,7 +7956,7 @@ var COMPILE_CONTEXT = {
7943
7956
  description: "Include related ontological entities in the compiled result"
7944
7957
  }
7945
7958
  },
7946
- required: ["topicId"],
7959
+ required: [],
7947
7960
  response: {
7948
7961
  description: "Compiled context pack for the requested topic",
7949
7962
  fields: {
@@ -10454,7 +10467,7 @@ var contextContracts = [
10454
10467
  path: "/context/compile",
10455
10468
  sdkNamespace: "context",
10456
10469
  sdkMethod: "compileContext",
10457
- summary: "Compile a focused reasoning context for a topic.",
10470
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
10458
10471
  convex: {
10459
10472
  module: "contextCompiler",
10460
10473
  functionName: "compile",
@@ -10920,12 +10933,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
10920
10933
  compactRecord4({
10921
10934
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
10922
10935
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
10923
- edgeType: "evidence_supports_belief",
10936
+ edgeType: "informs",
10924
10937
  globalId: input.globalId ?? `edge:${String(
10925
10938
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
10926
10939
  )}:${String(
10927
10940
  input.beliefNodeId ?? input.beliefId ?? input.targetId
10928
- )}:evidence_supports_belief`,
10941
+ )}:informs`,
10929
10942
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
10930
10943
  context: input.rationale ?? input.context,
10931
10944
  skipLayerValidation: true,
@@ -10938,12 +10951,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
10938
10951
  compactRecord4({
10939
10952
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
10940
10953
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
10941
- edgeType: "evidence_supports_question",
10954
+ edgeType: "responds_to",
10942
10955
  globalId: input.globalId ?? `edge:${String(
10943
10956
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
10944
10957
  )}:${String(
10945
10958
  input.questionId ?? input.questionNodeId ?? input.targetId
10946
- )}:evidence_supports_question`,
10959
+ )}:responds_to`,
10947
10960
  weight: input.impactScore ?? input.weight,
10948
10961
  context: input.rationale ?? input.context,
10949
10962
  skipLayerValidation: true,
@@ -12448,10 +12461,13 @@ var tasksContracts = [
12448
12461
  }
12449
12462
  })
12450
12463
  ];
12464
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12465
+ (policy) => policy.edgeType
12466
+ );
12451
12467
  var createEdgeArgs = z.object({
12452
12468
  from: GraphRefSchema,
12453
12469
  to: GraphRefSchema,
12454
- edgeType: z.string(),
12470
+ edgeType: z.enum(CREATE_EDGE_TYPES),
12455
12471
  globalId: z.string().optional(),
12456
12472
  weight: z.number().optional(),
12457
12473
  confidence: z.number().optional(),
@@ -18836,50 +18852,55 @@ function cleanNumber(value) {
18836
18852
  function cleanBoolean(value) {
18837
18853
  return typeof value === "boolean" ? value : void 0;
18838
18854
  }
18839
- function buildCompileContextRequest(topicId, input = {}) {
18840
- const payload = { topicId };
18841
- const query5 = cleanString4(input.query);
18855
+ function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
18856
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
18857
+ const payload = {};
18858
+ const topicId = typeof topicIdOrInput === "string" ? cleanString4(topicIdOrInput) : cleanString4(effectiveInput.topicId);
18859
+ if (topicId) {
18860
+ payload.topicId = topicId;
18861
+ }
18862
+ const query5 = cleanString4(effectiveInput.query);
18842
18863
  if (query5) {
18843
18864
  payload.query = query5;
18844
18865
  }
18845
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
18866
+ const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
18846
18867
  if (budget !== void 0) {
18847
18868
  payload.budget = budget;
18848
18869
  }
18849
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
18870
+ const ranking = cleanString4(effectiveInput.ranking) ?? cleanString4(effectiveInput.rankingProfile);
18850
18871
  if (ranking) {
18851
18872
  payload.ranking = ranking;
18852
18873
  }
18853
- const limit = cleanNumber(input.limit);
18874
+ const limit = cleanNumber(effectiveInput.limit);
18854
18875
  if (limit !== void 0) {
18855
18876
  payload.limit = limit;
18856
18877
  }
18857
- const maxDepth = cleanNumber(input.maxDepth);
18878
+ const maxDepth = cleanNumber(effectiveInput.maxDepth);
18858
18879
  if (maxDepth !== void 0) {
18859
18880
  payload.maxDepth = maxDepth;
18860
18881
  }
18861
- const includeEntities = cleanBoolean(input.includeEntities);
18882
+ const includeEntities = cleanBoolean(effectiveInput.includeEntities);
18862
18883
  if (includeEntities !== void 0) {
18863
18884
  payload.includeEntities = includeEntities;
18864
18885
  }
18865
- const mode = cleanString4(input.mode);
18886
+ const mode = cleanString4(effectiveInput.mode);
18866
18887
  if (mode) {
18867
18888
  payload.mode = mode;
18868
18889
  }
18869
- const includeFailures = cleanBoolean(input.includeFailures);
18890
+ const includeFailures = cleanBoolean(effectiveInput.includeFailures);
18870
18891
  if (includeFailures !== void 0) {
18871
18892
  payload.includeFailures = includeFailures;
18872
18893
  }
18873
- const worktreeId = cleanString4(input.worktreeId);
18894
+ const worktreeId = cleanString4(effectiveInput.worktreeId);
18874
18895
  if (worktreeId) {
18875
18896
  payload.worktreeId = worktreeId;
18876
18897
  }
18877
- const sessionId = cleanString4(input.sessionId);
18898
+ const sessionId = cleanString4(effectiveInput.sessionId);
18878
18899
  if (sessionId) {
18879
18900
  payload.sessionId = sessionId;
18880
18901
  }
18881
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
18882
- payload.packWeightOverrides = input.packWeightOverrides;
18902
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
18903
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
18883
18904
  }
18884
18905
  return {
18885
18906
  path: "/api/platform/v1/context/compile",
@@ -18891,13 +18912,20 @@ function createContextClient(config = {}) {
18891
18912
  const gateway = createGatewayRequestClient(config);
18892
18913
  return {
18893
18914
  /**
18894
- * Compile a focused reasoning context pack for a topic scope.
18895
- * @param topicId - The topic to compile context for.
18915
+ * Compile a focused reasoning context pack.
18916
+ * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
18896
18917
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
18897
18918
  * @returns The compiled context payload with beliefs, questions, and evidence.
18898
18919
  */
18899
- async compile(topicId, input = {}) {
18900
- const request = buildCompileContextRequest(topicId, input);
18920
+ async compile(topicIdOrInput = {}, input = {}) {
18921
+ const request = buildCompileContextRequest(topicIdOrInput, input);
18922
+ return gateway.request({
18923
+ ...request,
18924
+ body: request.body
18925
+ });
18926
+ },
18927
+ async compileByQuery(input = {}) {
18928
+ const request = buildCompileContextRequest(input);
18901
18929
  return gateway.request({
18902
18930
  ...request,
18903
18931
  body: request.body
@@ -21295,6 +21323,21 @@ function createSchemaClient(config = {}) {
21295
21323
  }
21296
21324
 
21297
21325
  // ../sdk/src/clientHelpers.ts
21326
+ function normalizeCustomNamespace(namespace) {
21327
+ return namespace.trim() || "custom";
21328
+ }
21329
+ function normalizeCustomToolPayload(input) {
21330
+ return input && typeof input === "object" && !Array.isArray(input) ? input : {};
21331
+ }
21332
+ function resolveCustomToolFullName(name) {
21333
+ return name.includes(".") ? name : `custom.${name}`;
21334
+ }
21335
+ function buildBeliefsRefinePayload(textOrInput, rationale) {
21336
+ return typeof textOrInput === "string" ? { text: textOrInput, rationale } : { text: textOrInput.text, rationale: textOrInput.rationale };
21337
+ }
21338
+ function buildBeliefsArchivePayload(input) {
21339
+ return typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
21340
+ }
21298
21341
  function asNodeArray(data) {
21299
21342
  const rows = asListItems(data, "nodes");
21300
21343
  if (rows.length > 0) {
@@ -21672,7 +21715,7 @@ function createToolRegistryClient(config = {}) {
21672
21715
  }
21673
21716
 
21674
21717
  // ../sdk/src/version.ts
21675
- var LUCERN_SDK_VERSION = "0.3.0-alpha.7";
21718
+ var LUCERN_SDK_VERSION = "0.3.0-alpha.9";
21676
21719
 
21677
21720
  // ../sdk/src/workflowClient.ts
21678
21721
  function normalizeLensQuery(value) {
@@ -22193,11 +22236,11 @@ function createLucernClient(config = {}) {
22193
22236
  }
22194
22237
  }
22195
22238
  const invokeCustomTool = async (fullName, input = {}) => {
22196
- const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
22239
+ const payload = normalizeCustomToolPayload(input);
22197
22240
  return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
22198
22241
  };
22199
22242
  const getCustomNamespace = (namespace) => {
22200
- const normalized = namespace.trim() || "custom";
22243
+ const normalized = normalizeCustomNamespace(namespace);
22201
22244
  const cached = customNamespaceCache.get(normalized);
22202
22245
  if (cached) {
22203
22246
  return cached;
@@ -22657,10 +22700,7 @@ function createLucernClient(config = {}) {
22657
22700
  return beliefsFacade.get(nodeId).then(exposeGatewayData);
22658
22701
  },
22659
22702
  refine(nodeId, textOrInput, rationale) {
22660
- const payload = typeof textOrInput === "string" ? { text: textOrInput, rationale } : {
22661
- text: textOrInput.text,
22662
- rationale: textOrInput.rationale
22663
- };
22703
+ const payload = buildBeliefsRefinePayload(textOrInput, rationale);
22664
22704
  return beliefsFacade.refine(nodeId, payload).then(exposeGatewayData);
22665
22705
  },
22666
22706
  updateConfidence(nodeId, input) {
@@ -22698,7 +22738,7 @@ function createLucernClient(config = {}) {
22698
22738
  }).then(exposeGatewayData);
22699
22739
  },
22700
22740
  archive(nodeId, input) {
22701
- const payload = typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
22741
+ const payload = buildBeliefsArchivePayload(input);
22702
22742
  return beliefsFacade.archive(nodeId, payload).then(exposeGatewayData);
22703
22743
  },
22704
22744
  list(args) {
@@ -23738,7 +23778,7 @@ function createLucernClient(config = {}) {
23738
23778
  list: listRegisteredCustomTools,
23739
23779
  clear: clearRegisteredCustomTools,
23740
23780
  invoke(name, input = {}) {
23741
- const fullName = name.includes(".") ? name : `custom.${name}`;
23781
+ const fullName = resolveCustomToolFullName(name);
23742
23782
  return invokeCustomTool(fullName, input);
23743
23783
  },
23744
23784
  namespace: getCustomNamespace
@@ -23837,50 +23877,55 @@ function cleanNumber2(value) {
23837
23877
  function cleanBoolean2(value) {
23838
23878
  return typeof value === "boolean" ? value : void 0;
23839
23879
  }
23840
- function buildCompileContextRequest2(topicId, input = {}) {
23841
- const payload = { topicId };
23842
- const query5 = cleanString6(input.query);
23880
+ function buildCompileContextRequest2(topicIdOrInput = {}, input = {}) {
23881
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
23882
+ const payload = {};
23883
+ const topicId = typeof topicIdOrInput === "string" ? cleanString6(topicIdOrInput) : cleanString6(effectiveInput.topicId);
23884
+ if (topicId) {
23885
+ payload.topicId = topicId;
23886
+ }
23887
+ const query5 = cleanString6(effectiveInput.query);
23843
23888
  if (query5) {
23844
23889
  payload.query = query5;
23845
23890
  }
23846
- const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
23891
+ const budget = cleanNumber2(effectiveInput.budget) ?? cleanNumber2(effectiveInput.tokenBudget);
23847
23892
  if (budget !== void 0) {
23848
23893
  payload.budget = budget;
23849
23894
  }
23850
- const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
23895
+ const ranking = cleanString6(effectiveInput.ranking) ?? cleanString6(effectiveInput.rankingProfile);
23851
23896
  if (ranking) {
23852
23897
  payload.ranking = ranking;
23853
23898
  }
23854
- const limit = cleanNumber2(input.limit);
23899
+ const limit = cleanNumber2(effectiveInput.limit);
23855
23900
  if (limit !== void 0) {
23856
23901
  payload.limit = limit;
23857
23902
  }
23858
- const maxDepth = cleanNumber2(input.maxDepth);
23903
+ const maxDepth = cleanNumber2(effectiveInput.maxDepth);
23859
23904
  if (maxDepth !== void 0) {
23860
23905
  payload.maxDepth = maxDepth;
23861
23906
  }
23862
- const includeEntities = cleanBoolean2(input.includeEntities);
23907
+ const includeEntities = cleanBoolean2(effectiveInput.includeEntities);
23863
23908
  if (includeEntities !== void 0) {
23864
23909
  payload.includeEntities = includeEntities;
23865
23910
  }
23866
- const mode = cleanString6(input.mode);
23911
+ const mode = cleanString6(effectiveInput.mode);
23867
23912
  if (mode) {
23868
23913
  payload.mode = mode;
23869
23914
  }
23870
- const includeFailures = cleanBoolean2(input.includeFailures);
23915
+ const includeFailures = cleanBoolean2(effectiveInput.includeFailures);
23871
23916
  if (includeFailures !== void 0) {
23872
23917
  payload.includeFailures = includeFailures;
23873
23918
  }
23874
- const worktreeId = cleanString6(input.worktreeId);
23919
+ const worktreeId = cleanString6(effectiveInput.worktreeId);
23875
23920
  if (worktreeId) {
23876
23921
  payload.worktreeId = worktreeId;
23877
23922
  }
23878
- const sessionId = cleanString6(input.sessionId);
23923
+ const sessionId = cleanString6(effectiveInput.sessionId);
23879
23924
  if (sessionId) {
23880
23925
  payload.sessionId = sessionId;
23881
23926
  }
23882
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
23883
- payload.packWeightOverrides = input.packWeightOverrides;
23927
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
23928
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
23884
23929
  }
23885
23930
  return {
23886
23931
  path: "/api/platform/v1/context/compile",
@@ -23890,8 +23935,12 @@ function buildCompileContextRequest2(topicId, input = {}) {
23890
23935
  }
23891
23936
  function createContextFacade(config) {
23892
23937
  return {
23893
- compile(topicId, input = {}) {
23894
- const request = buildCompileContextRequest2(topicId, input);
23938
+ compile(topicIdOrInput = {}, input = {}) {
23939
+ const request = buildCompileContextRequest2(topicIdOrInput, input);
23940
+ return config.transport.request(request);
23941
+ },
23942
+ compileByQuery(input = {}) {
23943
+ const request = buildCompileContextRequest2(input);
23895
23944
  return config.transport.request(request);
23896
23945
  }
23897
23946
  };
@@ -26649,24 +26698,27 @@ function readResultString(value, key) {
26649
26698
  }
26650
26699
  function createContextHandlers(context) {
26651
26700
  const compiler = createContextClient(context.sdkConfig);
26701
+ const functionSurface = createFunctionSurfaceClient(context.sdkConfig);
26652
26702
  return {
26653
26703
  compile_context: contractToHandler(
26654
26704
  MCP_TOOL_CONTRACTS.compile_context,
26655
26705
  async (params) => {
26656
- const topicId = readTopicId4(params, { required: true });
26657
- const response = await compiler.compile(
26658
- topicId,
26659
- {
26660
- ...readString3(params, "query") ? { query: readString3(params, "query") } : {},
26661
- ...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
26662
- ...readString3(params, "ranking") ? {
26663
- ranking: readString3(params, "ranking")
26664
- } : {},
26665
- ...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
26666
- ...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
26667
- ...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
26668
- }
26669
- );
26706
+ const topicId = readTopicId4(params);
26707
+ const query5 = readString3(params, "query");
26708
+ const input = {
26709
+ ...query5 ? { query: query5 } : {},
26710
+ ...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
26711
+ ...readString3(params, "ranking") ? {
26712
+ ranking: readString3(params, "ranking")
26713
+ } : {},
26714
+ ...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
26715
+ ...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
26716
+ ...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
26717
+ };
26718
+ if (!topicId && !query5) {
26719
+ throw new Error("[compile_context] query is required when topicId is omitted.");
26720
+ }
26721
+ const response = topicId ? await compiler.compile(topicId, input) : await functionSurface.compileContext(input);
26670
26722
  writeLocalLucernContext({
26671
26723
  topicId: readResultString(response.data, "topicId") ?? topicId,
26672
26724
  topicName: readResultString(response.data, "topicName"),
@@ -28505,7 +28557,7 @@ function createLucernStandaloneMcpServer(options) {
28505
28557
  });
28506
28558
  const server = new McpServer({
28507
28559
  name: "lucern-mcp",
28508
- version: "0.3.0-alpha.7"
28560
+ version: "0.3.0-alpha.9"
28509
28561
  });
28510
28562
  registerTools(server, runtime);
28511
28563
  const resources = registerResources(server, runtime, observationStore);