@lucern/sdk 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.
Files changed (56) hide show
  1. package/README.md +4 -4
  2. package/dist/beliefs/index.d.ts +1 -0
  3. package/dist/beliefs/index.js +51 -27
  4. package/dist/beliefs/index.js.map +1 -1
  5. package/dist/client.d.ts +6 -3
  6. package/dist/client.js +51 -27
  7. package/dist/client.js.map +1 -1
  8. package/dist/clientHelpers.d.ts +21 -2
  9. package/dist/clientHelpers.js +16 -1
  10. package/dist/clientHelpers.js.map +1 -1
  11. package/dist/contextClient.d.ts +4 -3
  12. package/dist/contextClient.js +30 -18
  13. package/dist/contextClient.js.map +1 -1
  14. package/dist/contextFacade.js +25 -16
  15. package/dist/contextFacade.js.map +1 -1
  16. package/dist/contextTypes.d.ts +2 -0
  17. package/dist/contradictions/index.d.ts +1 -0
  18. package/dist/contradictions/index.js +51 -27
  19. package/dist/contradictions/index.js.map +1 -1
  20. package/dist/decisions/index.d.ts +1 -0
  21. package/dist/decisions/index.js +51 -27
  22. package/dist/decisions/index.js.map +1 -1
  23. package/dist/edges/index.d.ts +1 -0
  24. package/dist/edges/index.js +51 -27
  25. package/dist/edges/index.js.map +1 -1
  26. package/dist/evidence/index.d.ts +1 -0
  27. package/dist/evidence/index.js +51 -27
  28. package/dist/evidence/index.js.map +1 -1
  29. package/dist/facade/context.d.ts +2 -1
  30. package/dist/facade/context.js +25 -16
  31. package/dist/facade/context.js.map +1 -1
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +76 -43
  34. package/dist/index.js.map +1 -1
  35. package/dist/lenses/index.d.ts +1 -0
  36. package/dist/lenses/index.js +51 -27
  37. package/dist/lenses/index.js.map +1 -1
  38. package/dist/nodes/index.d.ts +1 -0
  39. package/dist/nodes/index.js +51 -27
  40. package/dist/nodes/index.js.map +1 -1
  41. package/dist/ontologies/index.d.ts +1 -0
  42. package/dist/ontologies/index.js +51 -27
  43. package/dist/ontologies/index.js.map +1 -1
  44. package/dist/questions/index.d.ts +1 -0
  45. package/dist/questions/index.js +51 -27
  46. package/dist/questions/index.js.map +1 -1
  47. package/dist/topics/index.d.ts +1 -0
  48. package/dist/topics/index.js +51 -27
  49. package/dist/topics/index.js.map +1 -1
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/dist/version.js.map +1 -1
  53. package/dist/worktrees/index.d.ts +1 -0
  54. package/dist/worktrees/index.js +51 -27
  55. package/dist/worktrees/index.js.map +1 -1
  56. package/package.json +4 -4
@@ -54,6 +54,7 @@ import '../learningClient.js';
54
54
  import '../reportsClient.js';
55
55
  import '../sourcesClient.js';
56
56
  import '../workflowClient.js';
57
+ import '../clientHelpers.js';
57
58
 
58
59
  type EdgesClientConfig = LucernClientConfig;
59
60
  type EdgesClient = ReturnType<typeof createEdgesClient>;
@@ -3914,50 +3914,55 @@ function cleanNumber(value) {
3914
3914
  function cleanBoolean(value) {
3915
3915
  return typeof value === "boolean" ? value : void 0;
3916
3916
  }
3917
- function buildCompileContextRequest(topicId, input = {}) {
3918
- const payload = { topicId };
3919
- const query5 = cleanString4(input.query);
3917
+ function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
3918
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
3919
+ const payload = {};
3920
+ const topicId = typeof topicIdOrInput === "string" ? cleanString4(topicIdOrInput) : cleanString4(effectiveInput.topicId);
3921
+ if (topicId) {
3922
+ payload.topicId = topicId;
3923
+ }
3924
+ const query5 = cleanString4(effectiveInput.query);
3920
3925
  if (query5) {
3921
3926
  payload.query = query5;
3922
3927
  }
3923
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3928
+ const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
3924
3929
  if (budget !== void 0) {
3925
3930
  payload.budget = budget;
3926
3931
  }
3927
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
3932
+ const ranking = cleanString4(effectiveInput.ranking) ?? cleanString4(effectiveInput.rankingProfile);
3928
3933
  if (ranking) {
3929
3934
  payload.ranking = ranking;
3930
3935
  }
3931
- const limit = cleanNumber(input.limit);
3936
+ const limit = cleanNumber(effectiveInput.limit);
3932
3937
  if (limit !== void 0) {
3933
3938
  payload.limit = limit;
3934
3939
  }
3935
- const maxDepth = cleanNumber(input.maxDepth);
3940
+ const maxDepth = cleanNumber(effectiveInput.maxDepth);
3936
3941
  if (maxDepth !== void 0) {
3937
3942
  payload.maxDepth = maxDepth;
3938
3943
  }
3939
- const includeEntities = cleanBoolean(input.includeEntities);
3944
+ const includeEntities = cleanBoolean(effectiveInput.includeEntities);
3940
3945
  if (includeEntities !== void 0) {
3941
3946
  payload.includeEntities = includeEntities;
3942
3947
  }
3943
- const mode = cleanString4(input.mode);
3948
+ const mode = cleanString4(effectiveInput.mode);
3944
3949
  if (mode) {
3945
3950
  payload.mode = mode;
3946
3951
  }
3947
- const includeFailures = cleanBoolean(input.includeFailures);
3952
+ const includeFailures = cleanBoolean(effectiveInput.includeFailures);
3948
3953
  if (includeFailures !== void 0) {
3949
3954
  payload.includeFailures = includeFailures;
3950
3955
  }
3951
- const worktreeId = cleanString4(input.worktreeId);
3956
+ const worktreeId = cleanString4(effectiveInput.worktreeId);
3952
3957
  if (worktreeId) {
3953
3958
  payload.worktreeId = worktreeId;
3954
3959
  }
3955
- const sessionId = cleanString4(input.sessionId);
3960
+ const sessionId = cleanString4(effectiveInput.sessionId);
3956
3961
  if (sessionId) {
3957
3962
  payload.sessionId = sessionId;
3958
3963
  }
3959
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
3960
- payload.packWeightOverrides = input.packWeightOverrides;
3964
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
3965
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
3961
3966
  }
3962
3967
  return {
3963
3968
  path: "/api/platform/v1/context/compile",
@@ -3969,13 +3974,20 @@ function createContextClient(config = {}) {
3969
3974
  const gateway = createGatewayRequestClient(config);
3970
3975
  return {
3971
3976
  /**
3972
- * Compile a focused reasoning context pack for a topic scope.
3973
- * @param topicId - The topic to compile context for.
3977
+ * Compile a focused reasoning context pack.
3978
+ * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
3974
3979
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
3975
3980
  * @returns The compiled context payload with beliefs, questions, and evidence.
3976
3981
  */
3977
- async compile(topicId, input = {}) {
3978
- const request = buildCompileContextRequest(topicId, input);
3982
+ async compile(topicIdOrInput = {}, input = {}) {
3983
+ const request = buildCompileContextRequest(topicIdOrInput, input);
3984
+ return gateway.request({
3985
+ ...request,
3986
+ body: request.body
3987
+ });
3988
+ },
3989
+ async compileByQuery(input = {}) {
3990
+ const request = buildCompileContextRequest(input);
3979
3991
  return gateway.request({
3980
3992
  ...request,
3981
3993
  body: request.body
@@ -6250,6 +6262,21 @@ function createSchemaClient(config = {}) {
6250
6262
  }
6251
6263
 
6252
6264
  // src/clientHelpers.ts
6265
+ function normalizeCustomNamespace(namespace) {
6266
+ return namespace.trim() || "custom";
6267
+ }
6268
+ function normalizeCustomToolPayload(input) {
6269
+ return input && typeof input === "object" && !Array.isArray(input) ? input : {};
6270
+ }
6271
+ function resolveCustomToolFullName(name) {
6272
+ return name.includes(".") ? name : `custom.${name}`;
6273
+ }
6274
+ function buildBeliefsRefinePayload(textOrInput, rationale) {
6275
+ return typeof textOrInput === "string" ? { text: textOrInput, rationale } : { text: textOrInput.text, rationale: textOrInput.rationale };
6276
+ }
6277
+ function buildBeliefsArchivePayload(input) {
6278
+ return typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
6279
+ }
6253
6280
  function asNodeArray(data) {
6254
6281
  const rows = asListItems(data, "nodes");
6255
6282
  if (rows.length > 0) {
@@ -6627,7 +6654,7 @@ function createToolRegistryClient(config = {}) {
6627
6654
  }
6628
6655
 
6629
6656
  // src/version.ts
6630
- var LUCERN_SDK_VERSION = "0.3.0-alpha.7";
6657
+ var LUCERN_SDK_VERSION = "0.3.0-alpha.9";
6631
6658
 
6632
6659
  // src/workflowClient.ts
6633
6660
  function normalizeLensQuery(value) {
@@ -7148,11 +7175,11 @@ function createLucernClient(config = {}) {
7148
7175
  }
7149
7176
  }
7150
7177
  const invokeCustomTool = async (fullName, input = {}) => {
7151
- const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
7178
+ const payload = normalizeCustomToolPayload(input);
7152
7179
  return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
7153
7180
  };
7154
7181
  const getCustomNamespace = (namespace) => {
7155
- const normalized = namespace.trim() || "custom";
7182
+ const normalized = normalizeCustomNamespace(namespace);
7156
7183
  const cached = customNamespaceCache.get(normalized);
7157
7184
  if (cached) {
7158
7185
  return cached;
@@ -7612,10 +7639,7 @@ function createLucernClient(config = {}) {
7612
7639
  return beliefsFacade.get(nodeId).then(exposeGatewayData);
7613
7640
  },
7614
7641
  refine(nodeId, textOrInput, rationale) {
7615
- const payload = typeof textOrInput === "string" ? { text: textOrInput, rationale } : {
7616
- text: textOrInput.text,
7617
- rationale: textOrInput.rationale
7618
- };
7642
+ const payload = buildBeliefsRefinePayload(textOrInput, rationale);
7619
7643
  return beliefsFacade.refine(nodeId, payload).then(exposeGatewayData);
7620
7644
  },
7621
7645
  updateConfidence(nodeId, input) {
@@ -7653,7 +7677,7 @@ function createLucernClient(config = {}) {
7653
7677
  }).then(exposeGatewayData);
7654
7678
  },
7655
7679
  archive(nodeId, input) {
7656
- const payload = typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
7680
+ const payload = buildBeliefsArchivePayload(input);
7657
7681
  return beliefsFacade.archive(nodeId, payload).then(exposeGatewayData);
7658
7682
  },
7659
7683
  list(args) {
@@ -8693,7 +8717,7 @@ function createLucernClient(config = {}) {
8693
8717
  list: listRegisteredCustomTools,
8694
8718
  clear: clearRegisteredCustomTools,
8695
8719
  invoke(name, input = {}) {
8696
- const fullName = name.includes(".") ? name : `custom.${name}`;
8720
+ const fullName = resolveCustomToolFullName(name);
8697
8721
  return invokeCustomTool(fullName, input);
8698
8722
  },
8699
8723
  namespace: getCustomNamespace