@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
package/dist/client.d.ts CHANGED
@@ -38,6 +38,7 @@ import { LearningClientConfig } from './learningClient.js';
38
38
  import { ReportsClientConfig } from './reportsClient.js';
39
39
  import { SourcesClientConfig, UpsertSourceSpec } from './sourcesClient.js';
40
40
  import { WorkflowClientConfig, WorkflowLensPerspectiveType, WorkflowLensStatus, AddWorktreeInput, WorkflowWorktreeStatus, UpdateWorktreeTargetsInput, MergeInput, CreateTaskInput, CompleteTaskInput, UpdateTaskInput, WorkflowBranchStatus, CompleteWorktreeInput, AdvanceWorktreePhaseInput, SetWorktreePhaseInput, PatchWorktreeStateInput, BulkCreateWorktreesInput, ListTopicsInput, SwitchTopicContextInput } from './workflowClient.js';
41
+ import { CustomToolInput as CustomToolInput$1 } from './clientHelpers.js';
41
42
  import './authContext.js';
42
43
  import './contracts/auth-session.contract.js';
43
44
  import './contracts/workflow-runtime.contract.js';
@@ -50,7 +51,7 @@ import 'zod';
50
51
  import '@lucern/contracts/tool-contracts';
51
52
 
52
53
  type ClientConfig = BeliefsClientConfig | SourcesClientConfig | GraphClientConfig | DecisionsClientConfig | AnswersClientConfig | ContextClientConfig | WorkflowClientConfig | AuditClientConfig | AdminClientConfig | EvidenceClientConfig | EmbeddingsClientConfig | EventingClientConfig | GraphAnalysisClientConfig | GraphRecommendationsClientConfig | GraphStateClassifierClientConfig | IdentityClientConfig | JobsClientConfig | ModelRuntimeClientConfig | OntologyLinksClientConfig | OrgGraphSearchClientConfig | PolicyClientConfig | PacksClientConfig | ReportsClientConfig | LearningClientConfig | TelemetryClientConfig | ToolRegistryClientConfig | FunctionSurfaceClientConfig | OntologyClientConfig | HarnessClientConfig | SchemaClientConfig | AudiencesClientConfig | TopicsClientConfig;
53
- type CustomToolInput = JsonObject;
54
+ type CustomToolInput = CustomToolInput$1;
54
55
  type CustomToolInvoker = (input?: CustomToolInput) => Promise<unknown>;
55
56
  type CustomToolNamespace = Record<string, CustomToolInvoker>;
56
57
  type GatewayDataEnvelope<T extends Record<string, unknown>> = PlatformGatewaySuccess<T> & T;
@@ -1124,7 +1125,7 @@ declare function createLucernClient(config?: LucernClientConfig): {
1124
1125
  };
1125
1126
  context: {
1126
1127
  listTopics(query?: Parameters<(query?: TopicListInput) => Promise<PlatformGatewaySuccess<TopicListResponse>>>[0]): Promise<PlatformGatewaySuccess<TopicListResponse>>;
1127
- compile: (topicId: string, input?: CompileContextInput) => Promise<PlatformGatewaySuccess<PublicCompiledContext>>;
1128
+ compile: (topicIdOrInput?: string | CompileContextInput, input?: CompileContextInput) => Promise<PlatformGatewaySuccess<PublicCompiledContext>>;
1128
1129
  recordScopeLearning: (input?: FunctionSurfaceInput, idempotencyKey?: string) => FunctionSurfaceResult<unknown>;
1129
1130
  discover(input: FunctionSurfaceInput): Promise<GatewayDataEnvelope<Record<string, unknown>>>;
1130
1131
  analyzeTopicDensity: (input?: FunctionSurfaceInput, idempotencyKey?: string) => FunctionSurfaceResult<unknown>;
@@ -2169,7 +2170,9 @@ declare function createLucernClient(config?: LucernClientConfig): {
2169
2170
  name?: string;
2170
2171
  status?: "active" | "archived";
2171
2172
  defaultProjectVisibility?: "private" | "team" | "firm" | "external" | "public";
2172
- restore?: boolean;
2173
+ restore
2174
+ /** Target environment. Defaults to production if not specified. */
2175
+ ? /** Target environment. Defaults to production if not specified. */: boolean;
2173
2176
  metadata?: JsonObject;
2174
2177
  }, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
2175
2178
  listMemberships(query?: GatewayScope & {
package/dist/client.js CHANGED
@@ -3908,50 +3908,55 @@ function cleanNumber(value) {
3908
3908
  function cleanBoolean(value) {
3909
3909
  return typeof value === "boolean" ? value : void 0;
3910
3910
  }
3911
- function buildCompileContextRequest(topicId, input = {}) {
3912
- const payload = { topicId };
3913
- const query5 = cleanString4(input.query);
3911
+ function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
3912
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
3913
+ const payload = {};
3914
+ const topicId = typeof topicIdOrInput === "string" ? cleanString4(topicIdOrInput) : cleanString4(effectiveInput.topicId);
3915
+ if (topicId) {
3916
+ payload.topicId = topicId;
3917
+ }
3918
+ const query5 = cleanString4(effectiveInput.query);
3914
3919
  if (query5) {
3915
3920
  payload.query = query5;
3916
3921
  }
3917
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3922
+ const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
3918
3923
  if (budget !== void 0) {
3919
3924
  payload.budget = budget;
3920
3925
  }
3921
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
3926
+ const ranking = cleanString4(effectiveInput.ranking) ?? cleanString4(effectiveInput.rankingProfile);
3922
3927
  if (ranking) {
3923
3928
  payload.ranking = ranking;
3924
3929
  }
3925
- const limit = cleanNumber(input.limit);
3930
+ const limit = cleanNumber(effectiveInput.limit);
3926
3931
  if (limit !== void 0) {
3927
3932
  payload.limit = limit;
3928
3933
  }
3929
- const maxDepth = cleanNumber(input.maxDepth);
3934
+ const maxDepth = cleanNumber(effectiveInput.maxDepth);
3930
3935
  if (maxDepth !== void 0) {
3931
3936
  payload.maxDepth = maxDepth;
3932
3937
  }
3933
- const includeEntities = cleanBoolean(input.includeEntities);
3938
+ const includeEntities = cleanBoolean(effectiveInput.includeEntities);
3934
3939
  if (includeEntities !== void 0) {
3935
3940
  payload.includeEntities = includeEntities;
3936
3941
  }
3937
- const mode = cleanString4(input.mode);
3942
+ const mode = cleanString4(effectiveInput.mode);
3938
3943
  if (mode) {
3939
3944
  payload.mode = mode;
3940
3945
  }
3941
- const includeFailures = cleanBoolean(input.includeFailures);
3946
+ const includeFailures = cleanBoolean(effectiveInput.includeFailures);
3942
3947
  if (includeFailures !== void 0) {
3943
3948
  payload.includeFailures = includeFailures;
3944
3949
  }
3945
- const worktreeId = cleanString4(input.worktreeId);
3950
+ const worktreeId = cleanString4(effectiveInput.worktreeId);
3946
3951
  if (worktreeId) {
3947
3952
  payload.worktreeId = worktreeId;
3948
3953
  }
3949
- const sessionId = cleanString4(input.sessionId);
3954
+ const sessionId = cleanString4(effectiveInput.sessionId);
3950
3955
  if (sessionId) {
3951
3956
  payload.sessionId = sessionId;
3952
3957
  }
3953
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
3954
- payload.packWeightOverrides = input.packWeightOverrides;
3958
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
3959
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
3955
3960
  }
3956
3961
  return {
3957
3962
  path: "/api/platform/v1/context/compile",
@@ -3963,13 +3968,20 @@ function createContextClient(config = {}) {
3963
3968
  const gateway = createGatewayRequestClient(config);
3964
3969
  return {
3965
3970
  /**
3966
- * Compile a focused reasoning context pack for a topic scope.
3967
- * @param topicId - The topic to compile context for.
3971
+ * Compile a focused reasoning context pack.
3972
+ * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
3968
3973
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
3969
3974
  * @returns The compiled context payload with beliefs, questions, and evidence.
3970
3975
  */
3971
- async compile(topicId, input = {}) {
3972
- const request = buildCompileContextRequest(topicId, input);
3976
+ async compile(topicIdOrInput = {}, input = {}) {
3977
+ const request = buildCompileContextRequest(topicIdOrInput, input);
3978
+ return gateway.request({
3979
+ ...request,
3980
+ body: request.body
3981
+ });
3982
+ },
3983
+ async compileByQuery(input = {}) {
3984
+ const request = buildCompileContextRequest(input);
3973
3985
  return gateway.request({
3974
3986
  ...request,
3975
3987
  body: request.body
@@ -6244,6 +6256,21 @@ function createSchemaClient(config = {}) {
6244
6256
  }
6245
6257
 
6246
6258
  // src/clientHelpers.ts
6259
+ function normalizeCustomNamespace(namespace) {
6260
+ return namespace.trim() || "custom";
6261
+ }
6262
+ function normalizeCustomToolPayload(input) {
6263
+ return input && typeof input === "object" && !Array.isArray(input) ? input : {};
6264
+ }
6265
+ function resolveCustomToolFullName(name) {
6266
+ return name.includes(".") ? name : `custom.${name}`;
6267
+ }
6268
+ function buildBeliefsRefinePayload(textOrInput, rationale) {
6269
+ return typeof textOrInput === "string" ? { text: textOrInput, rationale } : { text: textOrInput.text, rationale: textOrInput.rationale };
6270
+ }
6271
+ function buildBeliefsArchivePayload(input) {
6272
+ return typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
6273
+ }
6247
6274
  function asNodeArray(data) {
6248
6275
  const rows = asListItems(data, "nodes");
6249
6276
  if (rows.length > 0) {
@@ -6621,7 +6648,7 @@ function createToolRegistryClient(config = {}) {
6621
6648
  }
6622
6649
 
6623
6650
  // src/version.ts
6624
- var LUCERN_SDK_VERSION = "0.3.0-alpha.7";
6651
+ var LUCERN_SDK_VERSION = "0.3.0-alpha.9";
6625
6652
 
6626
6653
  // src/workflowClient.ts
6627
6654
  function normalizeLensQuery(value) {
@@ -7142,11 +7169,11 @@ function createLucernClient(config = {}) {
7142
7169
  }
7143
7170
  }
7144
7171
  const invokeCustomTool = async (fullName, input = {}) => {
7145
- const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
7172
+ const payload = normalizeCustomToolPayload(input);
7146
7173
  return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
7147
7174
  };
7148
7175
  const getCustomNamespace = (namespace) => {
7149
- const normalized = namespace.trim() || "custom";
7176
+ const normalized = normalizeCustomNamespace(namespace);
7150
7177
  const cached = customNamespaceCache.get(normalized);
7151
7178
  if (cached) {
7152
7179
  return cached;
@@ -7606,10 +7633,7 @@ function createLucernClient(config = {}) {
7606
7633
  return beliefsFacade.get(nodeId).then(exposeGatewayData);
7607
7634
  },
7608
7635
  refine(nodeId, textOrInput, rationale) {
7609
- const payload = typeof textOrInput === "string" ? { text: textOrInput, rationale } : {
7610
- text: textOrInput.text,
7611
- rationale: textOrInput.rationale
7612
- };
7636
+ const payload = buildBeliefsRefinePayload(textOrInput, rationale);
7613
7637
  return beliefsFacade.refine(nodeId, payload).then(exposeGatewayData);
7614
7638
  },
7615
7639
  updateConfidence(nodeId, input) {
@@ -7647,7 +7671,7 @@ function createLucernClient(config = {}) {
7647
7671
  }).then(exposeGatewayData);
7648
7672
  },
7649
7673
  archive(nodeId, input) {
7650
- const payload = typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
7674
+ const payload = buildBeliefsArchivePayload(input);
7651
7675
  return beliefsFacade.archive(nodeId, payload).then(exposeGatewayData);
7652
7676
  },
7653
7677
  list(args) {
@@ -8687,7 +8711,7 @@ function createLucernClient(config = {}) {
8687
8711
  list: listRegisteredCustomTools,
8688
8712
  clear: clearRegisteredCustomTools,
8689
8713
  invoke(name, input = {}) {
8690
- const fullName = name.includes(".") ? name : `custom.${name}`;
8714
+ const fullName = resolveCustomToolFullName(name);
8691
8715
  return invokeCustomTool(fullName, input);
8692
8716
  },
8693
8717
  namespace: getCustomNamespace