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

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.
@@ -4425,50 +4425,55 @@ function cleanNumber(value) {
4425
4425
  function cleanBoolean(value) {
4426
4426
  return typeof value === "boolean" ? value : void 0;
4427
4427
  }
4428
- function buildCompileContextRequest(topicId, input = {}) {
4429
- const payload = { topicId };
4430
- const query5 = cleanString4(input.query);
4428
+ function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
4429
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
4430
+ const payload = {};
4431
+ const topicId = typeof topicIdOrInput === "string" ? cleanString4(topicIdOrInput) : cleanString4(effectiveInput.topicId);
4432
+ if (topicId) {
4433
+ payload.topicId = topicId;
4434
+ }
4435
+ const query5 = cleanString4(effectiveInput.query);
4431
4436
  if (query5) {
4432
4437
  payload.query = query5;
4433
4438
  }
4434
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
4439
+ const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
4435
4440
  if (budget !== void 0) {
4436
4441
  payload.budget = budget;
4437
4442
  }
4438
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
4443
+ const ranking = cleanString4(effectiveInput.ranking) ?? cleanString4(effectiveInput.rankingProfile);
4439
4444
  if (ranking) {
4440
4445
  payload.ranking = ranking;
4441
4446
  }
4442
- const limit = cleanNumber(input.limit);
4447
+ const limit = cleanNumber(effectiveInput.limit);
4443
4448
  if (limit !== void 0) {
4444
4449
  payload.limit = limit;
4445
4450
  }
4446
- const maxDepth = cleanNumber(input.maxDepth);
4451
+ const maxDepth = cleanNumber(effectiveInput.maxDepth);
4447
4452
  if (maxDepth !== void 0) {
4448
4453
  payload.maxDepth = maxDepth;
4449
4454
  }
4450
- const includeEntities = cleanBoolean(input.includeEntities);
4455
+ const includeEntities = cleanBoolean(effectiveInput.includeEntities);
4451
4456
  if (includeEntities !== void 0) {
4452
4457
  payload.includeEntities = includeEntities;
4453
4458
  }
4454
- const mode = cleanString4(input.mode);
4459
+ const mode = cleanString4(effectiveInput.mode);
4455
4460
  if (mode) {
4456
4461
  payload.mode = mode;
4457
4462
  }
4458
- const includeFailures = cleanBoolean(input.includeFailures);
4463
+ const includeFailures = cleanBoolean(effectiveInput.includeFailures);
4459
4464
  if (includeFailures !== void 0) {
4460
4465
  payload.includeFailures = includeFailures;
4461
4466
  }
4462
- const worktreeId = cleanString4(input.worktreeId);
4467
+ const worktreeId = cleanString4(effectiveInput.worktreeId);
4463
4468
  if (worktreeId) {
4464
4469
  payload.worktreeId = worktreeId;
4465
4470
  }
4466
- const sessionId = cleanString4(input.sessionId);
4471
+ const sessionId = cleanString4(effectiveInput.sessionId);
4467
4472
  if (sessionId) {
4468
4473
  payload.sessionId = sessionId;
4469
4474
  }
4470
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
4471
- payload.packWeightOverrides = input.packWeightOverrides;
4475
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
4476
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
4472
4477
  }
4473
4478
  return {
4474
4479
  path: "/api/platform/v1/context/compile",
@@ -4480,13 +4485,20 @@ function createContextClient(config = {}) {
4480
4485
  const gateway = createGatewayRequestClient(config);
4481
4486
  return {
4482
4487
  /**
4483
- * Compile a focused reasoning context pack for a topic scope.
4484
- * @param topicId - The topic to compile context for.
4488
+ * Compile a focused reasoning context pack.
4489
+ * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
4485
4490
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
4486
4491
  * @returns The compiled context payload with beliefs, questions, and evidence.
4487
4492
  */
4488
- async compile(topicId, input = {}) {
4489
- const request = buildCompileContextRequest(topicId, input);
4493
+ async compile(topicIdOrInput = {}, input = {}) {
4494
+ const request = buildCompileContextRequest(topicIdOrInput, input);
4495
+ return gateway.request({
4496
+ ...request,
4497
+ body: request.body
4498
+ });
4499
+ },
4500
+ async compileByQuery(input = {}) {
4501
+ const request = buildCompileContextRequest(input);
4490
4502
  return gateway.request({
4491
4503
  ...request,
4492
4504
  body: request.body
@@ -7261,7 +7273,7 @@ function createToolRegistryClient(config = {}) {
7261
7273
  }
7262
7274
 
7263
7275
  // ../sdk/src/version.ts
7264
- var LUCERN_SDK_VERSION = "0.3.0-alpha.7";
7276
+ var LUCERN_SDK_VERSION = "0.3.0-alpha.8";
7265
7277
 
7266
7278
  // ../sdk/src/workflowClient.ts
7267
7279
  function normalizeLensQuery(value) {
@@ -9426,50 +9438,55 @@ function cleanNumber2(value) {
9426
9438
  function cleanBoolean2(value) {
9427
9439
  return typeof value === "boolean" ? value : void 0;
9428
9440
  }
9429
- function buildCompileContextRequest2(topicId, input = {}) {
9430
- const payload = { topicId };
9431
- const query5 = cleanString6(input.query);
9441
+ function buildCompileContextRequest2(topicIdOrInput = {}, input = {}) {
9442
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
9443
+ const payload = {};
9444
+ const topicId = typeof topicIdOrInput === "string" ? cleanString6(topicIdOrInput) : cleanString6(effectiveInput.topicId);
9445
+ if (topicId) {
9446
+ payload.topicId = topicId;
9447
+ }
9448
+ const query5 = cleanString6(effectiveInput.query);
9432
9449
  if (query5) {
9433
9450
  payload.query = query5;
9434
9451
  }
9435
- const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
9452
+ const budget = cleanNumber2(effectiveInput.budget) ?? cleanNumber2(effectiveInput.tokenBudget);
9436
9453
  if (budget !== void 0) {
9437
9454
  payload.budget = budget;
9438
9455
  }
9439
- const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
9456
+ const ranking = cleanString6(effectiveInput.ranking) ?? cleanString6(effectiveInput.rankingProfile);
9440
9457
  if (ranking) {
9441
9458
  payload.ranking = ranking;
9442
9459
  }
9443
- const limit = cleanNumber2(input.limit);
9460
+ const limit = cleanNumber2(effectiveInput.limit);
9444
9461
  if (limit !== void 0) {
9445
9462
  payload.limit = limit;
9446
9463
  }
9447
- const maxDepth = cleanNumber2(input.maxDepth);
9464
+ const maxDepth = cleanNumber2(effectiveInput.maxDepth);
9448
9465
  if (maxDepth !== void 0) {
9449
9466
  payload.maxDepth = maxDepth;
9450
9467
  }
9451
- const includeEntities = cleanBoolean2(input.includeEntities);
9468
+ const includeEntities = cleanBoolean2(effectiveInput.includeEntities);
9452
9469
  if (includeEntities !== void 0) {
9453
9470
  payload.includeEntities = includeEntities;
9454
9471
  }
9455
- const mode = cleanString6(input.mode);
9472
+ const mode = cleanString6(effectiveInput.mode);
9456
9473
  if (mode) {
9457
9474
  payload.mode = mode;
9458
9475
  }
9459
- const includeFailures = cleanBoolean2(input.includeFailures);
9476
+ const includeFailures = cleanBoolean2(effectiveInput.includeFailures);
9460
9477
  if (includeFailures !== void 0) {
9461
9478
  payload.includeFailures = includeFailures;
9462
9479
  }
9463
- const worktreeId = cleanString6(input.worktreeId);
9480
+ const worktreeId = cleanString6(effectiveInput.worktreeId);
9464
9481
  if (worktreeId) {
9465
9482
  payload.worktreeId = worktreeId;
9466
9483
  }
9467
- const sessionId = cleanString6(input.sessionId);
9484
+ const sessionId = cleanString6(effectiveInput.sessionId);
9468
9485
  if (sessionId) {
9469
9486
  payload.sessionId = sessionId;
9470
9487
  }
9471
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
9472
- payload.packWeightOverrides = input.packWeightOverrides;
9488
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
9489
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
9473
9490
  }
9474
9491
  return {
9475
9492
  path: "/api/platform/v1/context/compile",
@@ -9479,8 +9496,12 @@ function buildCompileContextRequest2(topicId, input = {}) {
9479
9496
  }
9480
9497
  function createContextFacade(config) {
9481
9498
  return {
9482
- compile(topicId, input = {}) {
9483
- const request = buildCompileContextRequest2(topicId, input);
9499
+ compile(topicIdOrInput = {}, input = {}) {
9500
+ const request = buildCompileContextRequest2(topicIdOrInput, input);
9501
+ return config.transport.request(request);
9502
+ },
9503
+ compileByQuery(input = {}) {
9504
+ const request = buildCompileContextRequest2(input);
9484
9505
  return config.transport.request(request);
9485
9506
  }
9486
9507
  };
@@ -13119,15 +13140,15 @@ var IDENTITY_WHOAMI = {
13119
13140
  };
13120
13141
  var COMPILE_CONTEXT = {
13121
13142
  name: "compile_context",
13122
- 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.",
13143
+ 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.",
13123
13144
  parameters: {
13124
13145
  topicId: {
13125
13146
  type: "string",
13126
- description: "Topic scope ID to compile"
13147
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
13127
13148
  },
13128
13149
  query: {
13129
13150
  type: "string",
13130
- description: "Optional focus query used to rank context items"
13151
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
13131
13152
  },
13132
13153
  budget: {
13133
13154
  type: "number",
@@ -13151,7 +13172,7 @@ var COMPILE_CONTEXT = {
13151
13172
  description: "Include related ontological entities in the compiled result"
13152
13173
  }
13153
13174
  },
13154
- required: ["topicId"],
13175
+ required: [],
13155
13176
  response: {
13156
13177
  description: "Compiled context pack for the requested topic",
13157
13178
  fields: {
@@ -21876,7 +21897,7 @@ var contextContracts = [
21876
21897
  path: "/context/compile",
21877
21898
  sdkNamespace: "context",
21878
21899
  sdkMethod: "compileContext",
21879
- summary: "Compile a focused reasoning context for a topic.",
21900
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
21880
21901
  convex: {
21881
21902
  module: "contextCompiler",
21882
21903
  functionName: "compile",
@@ -26343,24 +26364,27 @@ function readResultString(value, key) {
26343
26364
  }
26344
26365
  function createContextHandlers(context) {
26345
26366
  const compiler = createContextClient(context.sdkConfig);
26367
+ const functionSurface = createFunctionSurfaceClient(context.sdkConfig);
26346
26368
  return {
26347
26369
  compile_context: contractToHandler(
26348
26370
  MCP_TOOL_CONTRACTS.compile_context,
26349
26371
  async (params) => {
26350
- const topicId = readTopicId4(params, { required: true });
26351
- const response = await compiler.compile(
26352
- topicId,
26353
- {
26354
- ...readString3(params, "query") ? { query: readString3(params, "query") } : {},
26355
- ...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
26356
- ...readString3(params, "ranking") ? {
26357
- ranking: readString3(params, "ranking")
26358
- } : {},
26359
- ...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
26360
- ...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
26361
- ...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
26362
- }
26363
- );
26372
+ const topicId = readTopicId4(params);
26373
+ const query5 = readString3(params, "query");
26374
+ const input = {
26375
+ ...query5 ? { query: query5 } : {},
26376
+ ...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
26377
+ ...readString3(params, "ranking") ? {
26378
+ ranking: readString3(params, "ranking")
26379
+ } : {},
26380
+ ...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
26381
+ ...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
26382
+ ...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
26383
+ };
26384
+ if (!topicId && !query5) {
26385
+ throw new Error("[compile_context] query is required when topicId is omitted.");
26386
+ }
26387
+ const response = topicId ? await compiler.compile(topicId, input) : await functionSurface.compileContext(input);
26364
26388
  writeLocalLucernContext({
26365
26389
  topicId: readResultString(response.data, "topicId") ?? topicId,
26366
26390
  topicName: readResultString(response.data, "topicName"),
@@ -28199,7 +28223,7 @@ function createLucernStandaloneMcpServer(options) {
28199
28223
  });
28200
28224
  const server = new McpServer({
28201
28225
  name: "lucern-mcp",
28202
- version: "0.3.0-alpha.7"
28226
+ version: "0.3.0-alpha.8"
28203
28227
  });
28204
28228
  registerTools(server, runtime);
28205
28229
  const resources = registerResources(server, runtime, observationStore);