@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/index.js CHANGED
@@ -300,9 +300,14 @@ function loadProfile(options) {
300
300
  const profiles = readProfilesFile(profilesPath());
301
301
  const localEnv = options.readLocalEnv === false ? {} : readLocalEnvFiles(options.cwd);
302
302
  const mergedEnv = { ...localEnv, ...options.env };
303
- const selected = options.profileName ?? mergedEnv.LUCERN_PROFILE ?? profiles.activeProfile ?? credentials.LUCERN_PROFILE ?? "default";
304
- const savedProfile = profiles.profiles?.[selected] ?? {};
305
303
  const envProfile = profileFromEnvironment(mergedEnv);
304
+ const hasEnvCredentials = Boolean(
305
+ envProfile.apiKey || envProfile.userToken || envProfile.packKey
306
+ );
307
+ const explicitProfileSelected = options.profileName !== void 0 || mergedEnv.LUCERN_PROFILE !== void 0;
308
+ const selectedProfile = options.profileName ?? mergedEnv.LUCERN_PROFILE ?? profiles.activeProfile ?? credentials.LUCERN_PROFILE ?? "default";
309
+ const selected = hasEnvCredentials && !explicitProfileSelected ? "env" : selectedProfile;
310
+ const savedProfile = hasEnvCredentials && !explicitProfileSelected ? {} : profiles.profiles?.[selectedProfile] ?? {};
306
311
  const credentialsProfile = {
307
312
  apiKey: credentials.LUCERN_API_KEY,
308
313
  userToken: readFirst(credentials, ["LUCERN_SESSION_TOKEN", "LUCERN_USER_TOKEN"]),
@@ -5273,17 +5278,44 @@ z.object({
5273
5278
  message: "SL invariant b+d+u=1 violated at API boundary"
5274
5279
  }
5275
5280
  );
5276
- var EpistemicNodeTypeSchema = z.enum([
5281
+
5282
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
5283
+ var NODE_TYPES = [
5284
+ "decision",
5277
5285
  "belief",
5278
- "evidence",
5279
5286
  "question",
5280
- "answer",
5287
+ "theme",
5288
+ "deal",
5281
5289
  "topic",
5290
+ "claim",
5291
+ "evidence",
5292
+ "synthesis",
5293
+ "answer",
5294
+ "atomic_fact",
5295
+ "excerpt",
5296
+ "source",
5297
+ "company",
5298
+ "person",
5299
+ "investor",
5300
+ "function",
5301
+ "value_chain"
5302
+ ];
5303
+ new Set(NODE_TYPES);
5304
+
5305
+ // ../contracts/src/types/graph-ref.ts
5306
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
5282
5307
  "edge",
5283
5308
  "ontology",
5284
5309
  "lens",
5285
5310
  "contradiction"
5286
- ]);
5311
+ ];
5312
+ var GRAPH_REF_NODE_TYPES = [
5313
+ ...NODE_TYPES,
5314
+ ...GRAPH_REF_EXTRA_NODE_TYPES
5315
+ ];
5316
+ var EpistemicNodeTypeSchema = z.enum(
5317
+ GRAPH_REF_NODE_TYPES
5318
+ );
5287
5319
  var GraphRefSchema = z.discriminatedUnion("kind", [
5288
5320
  z.object({
5289
5321
  kind: z.literal("epistemic_node"),
@@ -5331,33 +5363,14 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
5331
5363
  }
5332
5364
 
5333
5365
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
5366
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
5367
+ edgeType,
5368
+ fromKinds: ["epistemic_node"],
5369
+ toKinds: ["epistemic_node"],
5370
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
5371
+ });
5334
5372
  var edgePolicyManifest = {
5335
- policies: [
5336
- {
5337
- edgeType: "evidence_derived_from_evidence",
5338
- fromKinds: ["epistemic_node"],
5339
- fromNodeTypes: ["evidence"],
5340
- toKinds: ["epistemic_node"],
5341
- toNodeTypes: ["evidence"],
5342
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
5343
- },
5344
- {
5345
- edgeType: "evidence_supports_belief",
5346
- fromKinds: ["epistemic_node"],
5347
- fromNodeTypes: ["evidence"],
5348
- toKinds: ["epistemic_node"],
5349
- toNodeTypes: ["belief"],
5350
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
5351
- },
5352
- {
5353
- edgeType: "evidence_supports_question",
5354
- fromKinds: ["epistemic_node"],
5355
- fromNodeTypes: ["evidence"],
5356
- toKinds: ["epistemic_node"],
5357
- toNodeTypes: ["question"],
5358
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
5359
- }
5360
- ]
5373
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
5361
5374
  };
5362
5375
 
5363
5376
  // ../contracts/src/tenant-client.contract.ts
@@ -8083,15 +8096,15 @@ var IDENTITY_WHOAMI = {
8083
8096
  };
8084
8097
  var COMPILE_CONTEXT = {
8085
8098
  name: "compile_context",
8086
- 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.",
8099
+ 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.",
8087
8100
  parameters: {
8088
8101
  topicId: {
8089
8102
  type: "string",
8090
- description: "Topic scope ID to compile"
8103
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
8091
8104
  },
8092
8105
  query: {
8093
8106
  type: "string",
8094
- description: "Optional focus query used to rank context items"
8107
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
8095
8108
  },
8096
8109
  budget: {
8097
8110
  type: "number",
@@ -8115,7 +8128,7 @@ var COMPILE_CONTEXT = {
8115
8128
  description: "Include related ontological entities in the compiled result"
8116
8129
  }
8117
8130
  },
8118
- required: ["topicId"],
8131
+ required: [],
8119
8132
  response: {
8120
8133
  description: "Compiled context pack for the requested topic",
8121
8134
  fields: {
@@ -10626,7 +10639,7 @@ var contextContracts = [
10626
10639
  path: "/context/compile",
10627
10640
  sdkNamespace: "context",
10628
10641
  sdkMethod: "compileContext",
10629
- summary: "Compile a focused reasoning context for a topic.",
10642
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
10630
10643
  convex: {
10631
10644
  module: "contextCompiler",
10632
10645
  functionName: "compile",
@@ -11092,12 +11105,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
11092
11105
  compactRecord4({
11093
11106
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
11094
11107
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
11095
- edgeType: "evidence_supports_belief",
11108
+ edgeType: "informs",
11096
11109
  globalId: input.globalId ?? `edge:${String(
11097
11110
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
11098
11111
  )}:${String(
11099
11112
  input.beliefNodeId ?? input.beliefId ?? input.targetId
11100
- )}:evidence_supports_belief`,
11113
+ )}:informs`,
11101
11114
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
11102
11115
  context: input.rationale ?? input.context,
11103
11116
  skipLayerValidation: true,
@@ -11110,12 +11123,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
11110
11123
  compactRecord4({
11111
11124
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
11112
11125
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
11113
- edgeType: "evidence_supports_question",
11126
+ edgeType: "responds_to",
11114
11127
  globalId: input.globalId ?? `edge:${String(
11115
11128
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
11116
11129
  )}:${String(
11117
11130
  input.questionId ?? input.questionNodeId ?? input.targetId
11118
- )}:evidence_supports_question`,
11131
+ )}:responds_to`,
11119
11132
  weight: input.impactScore ?? input.weight,
11120
11133
  context: input.rationale ?? input.context,
11121
11134
  skipLayerValidation: true,
@@ -12620,10 +12633,13 @@ var tasksContracts = [
12620
12633
  }
12621
12634
  })
12622
12635
  ];
12636
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12637
+ (policy) => policy.edgeType
12638
+ );
12623
12639
  var createEdgeArgs = z.object({
12624
12640
  from: GraphRefSchema,
12625
12641
  to: GraphRefSchema,
12626
- edgeType: z.string(),
12642
+ edgeType: z.enum(CREATE_EDGE_TYPES),
12627
12643
  globalId: z.string().optional(),
12628
12644
  weight: z.number().optional(),
12629
12645
  confidence: z.number().optional(),
@@ -18961,50 +18977,55 @@ function cleanNumber(value) {
18961
18977
  function cleanBoolean(value) {
18962
18978
  return typeof value === "boolean" ? value : void 0;
18963
18979
  }
18964
- function buildCompileContextRequest(topicId, input = {}) {
18965
- const payload = { topicId };
18966
- const query5 = cleanString4(input.query);
18980
+ function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
18981
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
18982
+ const payload = {};
18983
+ const topicId = typeof topicIdOrInput === "string" ? cleanString4(topicIdOrInput) : cleanString4(effectiveInput.topicId);
18984
+ if (topicId) {
18985
+ payload.topicId = topicId;
18986
+ }
18987
+ const query5 = cleanString4(effectiveInput.query);
18967
18988
  if (query5) {
18968
18989
  payload.query = query5;
18969
18990
  }
18970
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
18991
+ const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
18971
18992
  if (budget !== void 0) {
18972
18993
  payload.budget = budget;
18973
18994
  }
18974
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
18995
+ const ranking = cleanString4(effectiveInput.ranking) ?? cleanString4(effectiveInput.rankingProfile);
18975
18996
  if (ranking) {
18976
18997
  payload.ranking = ranking;
18977
18998
  }
18978
- const limit = cleanNumber(input.limit);
18999
+ const limit = cleanNumber(effectiveInput.limit);
18979
19000
  if (limit !== void 0) {
18980
19001
  payload.limit = limit;
18981
19002
  }
18982
- const maxDepth = cleanNumber(input.maxDepth);
19003
+ const maxDepth = cleanNumber(effectiveInput.maxDepth);
18983
19004
  if (maxDepth !== void 0) {
18984
19005
  payload.maxDepth = maxDepth;
18985
19006
  }
18986
- const includeEntities = cleanBoolean(input.includeEntities);
19007
+ const includeEntities = cleanBoolean(effectiveInput.includeEntities);
18987
19008
  if (includeEntities !== void 0) {
18988
19009
  payload.includeEntities = includeEntities;
18989
19010
  }
18990
- const mode = cleanString4(input.mode);
19011
+ const mode = cleanString4(effectiveInput.mode);
18991
19012
  if (mode) {
18992
19013
  payload.mode = mode;
18993
19014
  }
18994
- const includeFailures = cleanBoolean(input.includeFailures);
19015
+ const includeFailures = cleanBoolean(effectiveInput.includeFailures);
18995
19016
  if (includeFailures !== void 0) {
18996
19017
  payload.includeFailures = includeFailures;
18997
19018
  }
18998
- const worktreeId = cleanString4(input.worktreeId);
19019
+ const worktreeId = cleanString4(effectiveInput.worktreeId);
18999
19020
  if (worktreeId) {
19000
19021
  payload.worktreeId = worktreeId;
19001
19022
  }
19002
- const sessionId = cleanString4(input.sessionId);
19023
+ const sessionId = cleanString4(effectiveInput.sessionId);
19003
19024
  if (sessionId) {
19004
19025
  payload.sessionId = sessionId;
19005
19026
  }
19006
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
19007
- payload.packWeightOverrides = input.packWeightOverrides;
19027
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
19028
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
19008
19029
  }
19009
19030
  return {
19010
19031
  path: "/api/platform/v1/context/compile",
@@ -19016,13 +19037,20 @@ function createContextClient(config = {}) {
19016
19037
  const gateway = createGatewayRequestClient(config);
19017
19038
  return {
19018
19039
  /**
19019
- * Compile a focused reasoning context pack for a topic scope.
19020
- * @param topicId - The topic to compile context for.
19040
+ * Compile a focused reasoning context pack.
19041
+ * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
19021
19042
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
19022
19043
  * @returns The compiled context payload with beliefs, questions, and evidence.
19023
19044
  */
19024
- async compile(topicId, input = {}) {
19025
- const request = buildCompileContextRequest(topicId, input);
19045
+ async compile(topicIdOrInput = {}, input = {}) {
19046
+ const request = buildCompileContextRequest(topicIdOrInput, input);
19047
+ return gateway.request({
19048
+ ...request,
19049
+ body: request.body
19050
+ });
19051
+ },
19052
+ async compileByQuery(input = {}) {
19053
+ const request = buildCompileContextRequest(input);
19026
19054
  return gateway.request({
19027
19055
  ...request,
19028
19056
  body: request.body
@@ -21420,6 +21448,21 @@ function createSchemaClient(config = {}) {
21420
21448
  }
21421
21449
 
21422
21450
  // ../sdk/src/clientHelpers.ts
21451
+ function normalizeCustomNamespace(namespace) {
21452
+ return namespace.trim() || "custom";
21453
+ }
21454
+ function normalizeCustomToolPayload(input) {
21455
+ return input && typeof input === "object" && !Array.isArray(input) ? input : {};
21456
+ }
21457
+ function resolveCustomToolFullName(name) {
21458
+ return name.includes(".") ? name : `custom.${name}`;
21459
+ }
21460
+ function buildBeliefsRefinePayload(textOrInput, rationale) {
21461
+ return typeof textOrInput === "string" ? { text: textOrInput, rationale } : { text: textOrInput.text, rationale: textOrInput.rationale };
21462
+ }
21463
+ function buildBeliefsArchivePayload(input) {
21464
+ return typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
21465
+ }
21423
21466
  function asNodeArray(data) {
21424
21467
  const rows = asListItems(data, "nodes");
21425
21468
  if (rows.length > 0) {
@@ -21797,7 +21840,7 @@ function createToolRegistryClient(config = {}) {
21797
21840
  }
21798
21841
 
21799
21842
  // ../sdk/src/version.ts
21800
- var LUCERN_SDK_VERSION = "0.3.0-alpha.7";
21843
+ var LUCERN_SDK_VERSION = "0.3.0-alpha.9";
21801
21844
 
21802
21845
  // ../sdk/src/workflowClient.ts
21803
21846
  function normalizeLensQuery(value) {
@@ -22318,11 +22361,11 @@ function createLucernClient(config = {}) {
22318
22361
  }
22319
22362
  }
22320
22363
  const invokeCustomTool = async (fullName, input = {}) => {
22321
- const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
22364
+ const payload = normalizeCustomToolPayload(input);
22322
22365
  return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
22323
22366
  };
22324
22367
  const getCustomNamespace = (namespace) => {
22325
- const normalized = namespace.trim() || "custom";
22368
+ const normalized = normalizeCustomNamespace(namespace);
22326
22369
  const cached = customNamespaceCache.get(normalized);
22327
22370
  if (cached) {
22328
22371
  return cached;
@@ -22782,10 +22825,7 @@ function createLucernClient(config = {}) {
22782
22825
  return beliefsFacade.get(nodeId).then(exposeGatewayData);
22783
22826
  },
22784
22827
  refine(nodeId, textOrInput, rationale) {
22785
- const payload = typeof textOrInput === "string" ? { text: textOrInput, rationale } : {
22786
- text: textOrInput.text,
22787
- rationale: textOrInput.rationale
22788
- };
22828
+ const payload = buildBeliefsRefinePayload(textOrInput, rationale);
22789
22829
  return beliefsFacade.refine(nodeId, payload).then(exposeGatewayData);
22790
22830
  },
22791
22831
  updateConfidence(nodeId, input) {
@@ -22823,7 +22863,7 @@ function createLucernClient(config = {}) {
22823
22863
  }).then(exposeGatewayData);
22824
22864
  },
22825
22865
  archive(nodeId, input) {
22826
- const payload = typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
22866
+ const payload = buildBeliefsArchivePayload(input);
22827
22867
  return beliefsFacade.archive(nodeId, payload).then(exposeGatewayData);
22828
22868
  },
22829
22869
  list(args) {
@@ -23863,7 +23903,7 @@ function createLucernClient(config = {}) {
23863
23903
  list: listRegisteredCustomTools,
23864
23904
  clear: clearRegisteredCustomTools,
23865
23905
  invoke(name, input = {}) {
23866
- const fullName = name.includes(".") ? name : `custom.${name}`;
23906
+ const fullName = resolveCustomToolFullName(name);
23867
23907
  return invokeCustomTool(fullName, input);
23868
23908
  },
23869
23909
  namespace: getCustomNamespace
@@ -23962,50 +24002,55 @@ function cleanNumber2(value) {
23962
24002
  function cleanBoolean2(value) {
23963
24003
  return typeof value === "boolean" ? value : void 0;
23964
24004
  }
23965
- function buildCompileContextRequest2(topicId, input = {}) {
23966
- const payload = { topicId };
23967
- const query5 = cleanString6(input.query);
24005
+ function buildCompileContextRequest2(topicIdOrInput = {}, input = {}) {
24006
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
24007
+ const payload = {};
24008
+ const topicId = typeof topicIdOrInput === "string" ? cleanString6(topicIdOrInput) : cleanString6(effectiveInput.topicId);
24009
+ if (topicId) {
24010
+ payload.topicId = topicId;
24011
+ }
24012
+ const query5 = cleanString6(effectiveInput.query);
23968
24013
  if (query5) {
23969
24014
  payload.query = query5;
23970
24015
  }
23971
- const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
24016
+ const budget = cleanNumber2(effectiveInput.budget) ?? cleanNumber2(effectiveInput.tokenBudget);
23972
24017
  if (budget !== void 0) {
23973
24018
  payload.budget = budget;
23974
24019
  }
23975
- const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
24020
+ const ranking = cleanString6(effectiveInput.ranking) ?? cleanString6(effectiveInput.rankingProfile);
23976
24021
  if (ranking) {
23977
24022
  payload.ranking = ranking;
23978
24023
  }
23979
- const limit = cleanNumber2(input.limit);
24024
+ const limit = cleanNumber2(effectiveInput.limit);
23980
24025
  if (limit !== void 0) {
23981
24026
  payload.limit = limit;
23982
24027
  }
23983
- const maxDepth = cleanNumber2(input.maxDepth);
24028
+ const maxDepth = cleanNumber2(effectiveInput.maxDepth);
23984
24029
  if (maxDepth !== void 0) {
23985
24030
  payload.maxDepth = maxDepth;
23986
24031
  }
23987
- const includeEntities = cleanBoolean2(input.includeEntities);
24032
+ const includeEntities = cleanBoolean2(effectiveInput.includeEntities);
23988
24033
  if (includeEntities !== void 0) {
23989
24034
  payload.includeEntities = includeEntities;
23990
24035
  }
23991
- const mode = cleanString6(input.mode);
24036
+ const mode = cleanString6(effectiveInput.mode);
23992
24037
  if (mode) {
23993
24038
  payload.mode = mode;
23994
24039
  }
23995
- const includeFailures = cleanBoolean2(input.includeFailures);
24040
+ const includeFailures = cleanBoolean2(effectiveInput.includeFailures);
23996
24041
  if (includeFailures !== void 0) {
23997
24042
  payload.includeFailures = includeFailures;
23998
24043
  }
23999
- const worktreeId = cleanString6(input.worktreeId);
24044
+ const worktreeId = cleanString6(effectiveInput.worktreeId);
24000
24045
  if (worktreeId) {
24001
24046
  payload.worktreeId = worktreeId;
24002
24047
  }
24003
- const sessionId = cleanString6(input.sessionId);
24048
+ const sessionId = cleanString6(effectiveInput.sessionId);
24004
24049
  if (sessionId) {
24005
24050
  payload.sessionId = sessionId;
24006
24051
  }
24007
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
24008
- payload.packWeightOverrides = input.packWeightOverrides;
24052
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
24053
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
24009
24054
  }
24010
24055
  return {
24011
24056
  path: "/api/platform/v1/context/compile",
@@ -24015,8 +24060,12 @@ function buildCompileContextRequest2(topicId, input = {}) {
24015
24060
  }
24016
24061
  function createContextFacade(config) {
24017
24062
  return {
24018
- compile(topicId, input = {}) {
24019
- const request = buildCompileContextRequest2(topicId, input);
24063
+ compile(topicIdOrInput = {}, input = {}) {
24064
+ const request = buildCompileContextRequest2(topicIdOrInput, input);
24065
+ return config.transport.request(request);
24066
+ },
24067
+ compileByQuery(input = {}) {
24068
+ const request = buildCompileContextRequest2(input);
24020
24069
  return config.transport.request(request);
24021
24070
  }
24022
24071
  };
@@ -26665,24 +26714,27 @@ function readResultString(value, key) {
26665
26714
  }
26666
26715
  function createContextHandlers(context) {
26667
26716
  const compiler = createContextClient(context.sdkConfig);
26717
+ const functionSurface = createFunctionSurfaceClient(context.sdkConfig);
26668
26718
  return {
26669
26719
  compile_context: contractToHandler(
26670
26720
  MCP_TOOL_CONTRACTS.compile_context,
26671
26721
  async (params) => {
26672
- const topicId = readTopicId4(params, { required: true });
26673
- const response = await compiler.compile(
26674
- topicId,
26675
- {
26676
- ...readString3(params, "query") ? { query: readString3(params, "query") } : {},
26677
- ...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
26678
- ...readString3(params, "ranking") ? {
26679
- ranking: readString3(params, "ranking")
26680
- } : {},
26681
- ...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
26682
- ...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
26683
- ...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
26684
- }
26685
- );
26722
+ const topicId = readTopicId4(params);
26723
+ const query5 = readString3(params, "query");
26724
+ const input = {
26725
+ ...query5 ? { query: query5 } : {},
26726
+ ...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
26727
+ ...readString3(params, "ranking") ? {
26728
+ ranking: readString3(params, "ranking")
26729
+ } : {},
26730
+ ...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
26731
+ ...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
26732
+ ...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
26733
+ };
26734
+ if (!topicId && !query5) {
26735
+ throw new Error("[compile_context] query is required when topicId is omitted.");
26736
+ }
26737
+ const response = topicId ? await compiler.compile(topicId, input) : await functionSurface.compileContext(input);
26686
26738
  writeLocalLucernContext({
26687
26739
  topicId: readResultString(response.data, "topicId") ?? topicId,
26688
26740
  topicName: readResultString(response.data, "topicName"),
@@ -28530,7 +28582,7 @@ function createLucernStandaloneMcpServer(options) {
28530
28582
  });
28531
28583
  const server = new McpServer({
28532
28584
  name: "lucern-mcp",
28533
- version: "0.3.0-alpha.7"
28585
+ version: "0.3.0-alpha.9"
28534
28586
  });
28535
28587
  registerTools(server, runtime);
28536
28588
  const resources = registerResources(server, runtime, observationStore);