@lucern/sdk 0.3.0-alpha.17 → 0.3.0-alpha.3

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 (210) hide show
  1. package/CHANGELOG.md +0 -12
  2. package/README.md +4 -110
  3. package/dist/adminClient.d.ts +8 -8
  4. package/dist/adminClient.js +40 -70
  5. package/dist/adminClient.js.map +1 -1
  6. package/dist/answersClient.js +12 -49
  7. package/dist/answersClient.js.map +1 -1
  8. package/dist/audience/index.d.ts +1 -2
  9. package/dist/audience/index.js +3 -1
  10. package/dist/audience/index.js.map +1 -1
  11. package/dist/audiencesClient.d.ts +16 -16
  12. package/dist/audiencesClient.js +91 -125
  13. package/dist/audiencesClient.js.map +1 -1
  14. package/dist/auditClient.js +14 -53
  15. package/dist/auditClient.js.map +1 -1
  16. package/dist/authContext.d.ts +2 -2
  17. package/dist/authContext.js +3 -4
  18. package/dist/authContext.js.map +1 -1
  19. package/dist/authDeviceClient.js +3 -16
  20. package/dist/authDeviceClient.js.map +1 -1
  21. package/dist/beliefs/index.d.ts +4 -9
  22. package/dist/beliefs/index.js +1305 -1943
  23. package/dist/beliefs/index.js.map +1 -1
  24. package/dist/beliefsClient.d.ts +2 -2
  25. package/dist/beliefsClient.js +23 -54
  26. package/dist/beliefsClient.js.map +1 -1
  27. package/dist/boundaryClientSurface.js +3 -10
  28. package/dist/boundaryClientSurface.js.map +1 -1
  29. package/dist/client-EiG9nJOY.d.ts +2911 -0
  30. package/dist/client.d.ts +41 -3038
  31. package/dist/client.js +1305 -1943
  32. package/dist/client.js.map +1 -1
  33. package/dist/contextClient.d.ts +3 -4
  34. package/dist/contextClient.js +30 -79
  35. package/dist/contextClient.js.map +1 -1
  36. package/dist/contextFacade.js +16 -25
  37. package/dist/contextFacade.js.map +1 -1
  38. package/dist/contextPackCompiler.js +30 -19
  39. package/dist/contextPackCompiler.js.map +1 -1
  40. package/dist/contextPackPolicy.js +17 -7
  41. package/dist/contextPackPolicy.js.map +1 -1
  42. package/dist/contextTypes.d.ts +0 -2
  43. package/dist/contracts/api-enums.contract.d.ts +2 -2
  44. package/dist/contracts/api-enums.contract.js +1 -6
  45. package/dist/contracts/api-enums.contract.js.map +1 -1
  46. package/dist/contracts/auth-session.contract.d.ts +1 -1
  47. package/dist/contracts/auth-session.contract.js +2 -14
  48. package/dist/contracts/auth-session.contract.js.map +1 -1
  49. package/dist/contracts/index.js +6 -30
  50. package/dist/contracts/index.js.map +1 -1
  51. package/dist/contracts/lens-filter.contract.js +3 -4
  52. package/dist/contracts/lens-filter.contract.js.map +1 -1
  53. package/dist/contracts/lens-workflow.contract.js +3 -4
  54. package/dist/contracts/lens-workflow.contract.js.map +1 -1
  55. package/dist/contracts/lensFilter.js +3 -4
  56. package/dist/contracts/lensFilter.js.map +1 -1
  57. package/dist/contracts/lensWorkflow.js +3 -4
  58. package/dist/contracts/lensWorkflow.js.map +1 -1
  59. package/dist/contracts/mcpTools.js +0 -6
  60. package/dist/contracts/mcpTools.js.map +1 -1
  61. package/dist/contradictions/index.d.ts +3 -8
  62. package/dist/contradictions/index.js +1305 -1943
  63. package/dist/contradictions/index.js.map +1 -1
  64. package/dist/coreClient.d.ts +2 -19
  65. package/dist/coreClient.js +15 -50
  66. package/dist/coreClient.js.map +1 -1
  67. package/dist/decisions/index.d.ts +13 -18
  68. package/dist/decisions/index.js +1305 -1943
  69. package/dist/decisions/index.js.map +1 -1
  70. package/dist/decisionsClient.d.ts +12 -4
  71. package/dist/decisionsClient.js +35 -60
  72. package/dist/decisionsClient.js.map +1 -1
  73. package/dist/edges/index.d.ts +86 -31
  74. package/dist/edges/index.js +1305 -1943
  75. package/dist/edges/index.js.map +1 -1
  76. package/dist/embeddingsClient.js +18 -60
  77. package/dist/embeddingsClient.js.map +1 -1
  78. package/dist/eventingClient.js +18 -60
  79. package/dist/eventingClient.js.map +1 -1
  80. package/dist/events.js +3 -6
  81. package/dist/events.js.map +1 -1
  82. package/dist/eventsCore.d.ts +1 -1
  83. package/dist/eventsCore.js +15 -50
  84. package/dist/eventsCore.js.map +1 -1
  85. package/dist/evidence/index.d.ts +3 -8
  86. package/dist/evidence/index.js +1305 -1943
  87. package/dist/evidence/index.js.map +1 -1
  88. package/dist/evidenceClient.js +15 -50
  89. package/dist/evidenceClient.js.map +1 -1
  90. package/dist/facade/context.d.ts +1 -2
  91. package/dist/facade/context.js +16 -25
  92. package/dist/facade/context.js.map +1 -1
  93. package/dist/gatewayFacades.d.ts +48 -90
  94. package/dist/gatewayFacades.js +128 -251
  95. package/dist/gatewayFacades.js.map +1 -1
  96. package/dist/graphAnalysisClient.d.ts +1 -53
  97. package/dist/graphAnalysisClient.js +17 -81
  98. package/dist/graphAnalysisClient.js.map +1 -1
  99. package/dist/graphClient.d.ts +13 -6
  100. package/dist/graphClient.js +39 -65
  101. package/dist/graphClient.js.map +1 -1
  102. package/dist/graphRecommendationsClient.js +17 -54
  103. package/dist/graphRecommendationsClient.js.map +1 -1
  104. package/dist/graphStateClassifierClient.js +19 -60
  105. package/dist/graphStateClassifierClient.js.map +1 -1
  106. package/dist/harnessClient.d.ts +24 -13
  107. package/dist/harnessClient.js +41 -61
  108. package/dist/harnessClient.js.map +1 -1
  109. package/dist/identityClient.d.ts +9 -27
  110. package/dist/identityClient.js +39 -203
  111. package/dist/identityClient.js.map +1 -1
  112. package/dist/index.d.ts +6 -15
  113. package/dist/index.js +1171 -2256
  114. package/dist/index.js.map +1 -1
  115. package/dist/jobsClient.js +19 -60
  116. package/dist/jobsClient.js.map +1 -1
  117. package/dist/learningClient.d.ts +6 -6
  118. package/dist/learningClient.js +43 -78
  119. package/dist/learningClient.js.map +1 -1
  120. package/dist/lenses/index.d.ts +37 -60
  121. package/dist/lenses/index.js +1305 -1943
  122. package/dist/lenses/index.js.map +1 -1
  123. package/dist/mcpClient.js +13 -51
  124. package/dist/mcpClient.js.map +1 -1
  125. package/dist/modelRuntimeClient.js +18 -60
  126. package/dist/modelRuntimeClient.js.map +1 -1
  127. package/dist/nodes/index.d.ts +22 -49
  128. package/dist/nodes/index.js +1305 -1943
  129. package/dist/nodes/index.js.map +1 -1
  130. package/dist/ontologies/index.d.ts +31 -37
  131. package/dist/ontologies/index.js +1305 -1943
  132. package/dist/ontologies/index.js.map +1 -1
  133. package/dist/ontologyClient.d.ts +25 -17
  134. package/dist/ontologyClient.js +41 -86
  135. package/dist/ontologyClient.js.map +1 -1
  136. package/dist/ontologyLinksClient.js +19 -60
  137. package/dist/ontologyLinksClient.js.map +1 -1
  138. package/dist/orgGraphSearchClient.js +14 -53
  139. package/dist/orgGraphSearchClient.js.map +1 -1
  140. package/dist/packRuntime.d.ts +1 -2
  141. package/dist/packsClient.d.ts +23 -9
  142. package/dist/packsClient.js +47 -62
  143. package/dist/packsClient.js.map +1 -1
  144. package/dist/policyClient.d.ts +10 -11
  145. package/dist/policyClient.js +26 -71
  146. package/dist/policyClient.js.map +1 -1
  147. package/dist/questions/index.d.ts +3 -8
  148. package/dist/questions/index.js +1305 -1943
  149. package/dist/questions/index.js.map +1 -1
  150. package/dist/realtime/index.d.ts +1 -1
  151. package/dist/reportsClient.d.ts +7 -7
  152. package/dist/reportsClient.js +52 -107
  153. package/dist/reportsClient.js.map +1 -1
  154. package/dist/schemaClient.d.ts +3 -3
  155. package/dist/schemaClient.js +30 -63
  156. package/dist/schemaClient.js.map +1 -1
  157. package/dist/sdkSurface.d.ts +3 -6
  158. package/dist/sdkSurface.js +6 -10
  159. package/dist/sdkSurface.js.map +1 -1
  160. package/dist/sourcesClient.js +15 -50
  161. package/dist/sourcesClient.js.map +1 -1
  162. package/dist/telemetryClient.js +19 -60
  163. package/dist/telemetryClient.js.map +1 -1
  164. package/dist/toolRegistryClient.d.ts +2 -10
  165. package/dist/toolRegistryClient.js +20 -73
  166. package/dist/toolRegistryClient.js.map +1 -1
  167. package/dist/topics/index.d.ts +8 -19
  168. package/dist/topics/index.js +1305 -1945
  169. package/dist/topics/index.js.map +1 -1
  170. package/dist/topicsClient.d.ts +0 -2
  171. package/dist/topicsClient.js +20 -60
  172. package/dist/topicsClient.js.map +1 -1
  173. package/dist/types.d.ts +0 -17
  174. package/dist/version.d.ts +1 -1
  175. package/dist/version.js +1 -1
  176. package/dist/version.js.map +1 -1
  177. package/dist/workflowClient.d.ts +40 -58
  178. package/dist/workflowClient.js +54 -66
  179. package/dist/workflowClient.js.map +1 -1
  180. package/dist/worktrees/index.d.ts +33 -54
  181. package/dist/worktrees/index.js +1305 -1943
  182. package/dist/worktrees/index.js.map +1 -1
  183. package/package.json +3 -17
  184. package/dist/accessControl.d.ts +0 -79
  185. package/dist/accessControl.js +0 -1270
  186. package/dist/accessControl.js.map +0 -1
  187. package/dist/clientHelpers.d.ts +0 -48
  188. package/dist/clientHelpers.js +0 -137
  189. package/dist/clientHelpers.js.map +0 -1
  190. package/dist/control-plane.d.ts +0 -69
  191. package/dist/control-plane.js +0 -674
  192. package/dist/control-plane.js.map +0 -1
  193. package/dist/functionSurface.d.ts +0 -144
  194. package/dist/functionSurface.js +0 -1227
  195. package/dist/functionSurface.js.map +0 -1
  196. package/dist/functionSurfaceClient.d.ts +0 -8
  197. package/dist/functionSurfaceClient.js +0 -1227
  198. package/dist/functionSurfaceClient.js.map +0 -1
  199. package/dist/graphIntel.d.ts +0 -4
  200. package/dist/graphIntel.js +0 -3
  201. package/dist/graphIntel.js.map +0 -1
  202. package/dist/graphIntelligence.d.ts +0 -2
  203. package/dist/graphIntelligence.js +0 -47
  204. package/dist/graphIntelligence.js.map +0 -1
  205. package/dist/infisicalRuntime.d.ts +0 -43
  206. package/dist/infisicalRuntime.js +0 -346
  207. package/dist/infisicalRuntime.js.map +0 -1
  208. package/dist/secrets.d.ts +0 -1
  209. package/dist/secrets.js +0 -3
  210. package/dist/secrets.js.map +0 -1
@@ -29,14 +29,14 @@ function requireString(value, reason, label) {
29
29
  }
30
30
  return normalized;
31
31
  }
32
- function requirePrincipalType(principalType2) {
33
- if (!principalType2) {
32
+ function requirePrincipalType(principalType) {
33
+ if (!principalType) {
34
34
  throw new LucernSdkAuthContextError(
35
35
  "principal_missing",
36
36
  "Canonical Lucern SDK auth context is missing principalType."
37
37
  );
38
38
  }
39
- return principalType2;
39
+ return principalType;
40
40
  }
41
41
  function requireAuthMode(authMode) {
42
42
  if (!authMode) {
@@ -82,15 +82,14 @@ function normalizeCanonicalLucernAuthContext(input) {
82
82
  );
83
83
  const roles = cleanStringList(input.roles);
84
84
  const scopes = cleanStringList(input.scopes);
85
- const principalType2 = requirePrincipalType(input.principalType);
86
- const authMode = requireAuthMode(input.authMode);
87
- const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
88
- if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
85
+ if (roles.length === 0 || scopes.length === 0) {
89
86
  throw new LucernSdkAuthContextError(
90
87
  "membership_missing",
91
88
  "Canonical Lucern SDK auth context requires non-empty roles and scopes."
92
89
  );
93
90
  }
91
+ const principalType = requirePrincipalType(input.principalType);
92
+ const authMode = requireAuthMode(input.authMode);
94
93
  const subject = cleanString(input.permit?.subject) ?? principalId;
95
94
  const tenant = cleanString(input.permit?.tenant) ?? tenantId;
96
95
  const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
@@ -111,7 +110,7 @@ function normalizeCanonicalLucernAuthContext(input) {
111
110
  principalId,
112
111
  tenantId,
113
112
  workspaceId,
114
- principalType: principalType2,
113
+ principalType,
115
114
  authMode,
116
115
  roles,
117
116
  scopes,
@@ -232,7 +231,9 @@ function generatePortableRequestId() {
232
231
  8
233
232
  ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
234
233
  }
235
- var randomIdempotencyKey = generatePortableRequestId;
234
+ function randomIdempotencyKey() {
235
+ return generatePortableRequestId();
236
+ }
236
237
  function isRetryableStatus(status) {
237
238
  return status >= 500 || status === 408 || status === 429;
238
239
  }
@@ -297,11 +298,8 @@ function timeoutError(timeoutMs) {
297
298
  error.name = "AbortError";
298
299
  return error;
299
300
  }
300
- function isRecord(value) {
301
- return value !== null && typeof value === "object" && !Array.isArray(value);
302
- }
303
301
  function readPolicySummaryFromDetails(details) {
304
- if (!isRecord(details)) {
302
+ if (!details || typeof details !== "object" || Array.isArray(details)) {
305
303
  return null;
306
304
  }
307
305
  const directSummary = details.summary;
@@ -309,11 +307,11 @@ function readPolicySummaryFromDetails(details) {
309
307
  return directSummary.trim();
310
308
  }
311
309
  const policy = details.policy;
312
- if (!isRecord(policy)) {
310
+ if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
313
311
  return null;
314
312
  }
315
313
  const explanation = policy.explanation;
316
- if (!isRecord(explanation)) {
314
+ if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
317
315
  return null;
318
316
  }
319
317
  const nestedSummary = explanation.summary;
@@ -342,31 +340,13 @@ function mergeHeaderRecord(base, addition) {
342
340
  }
343
341
  return Object.fromEntries(headers.entries());
344
342
  }
345
- function cleanHeaderValue(value) {
346
- const normalized = value?.trim();
347
- return normalized ? normalized : void 0;
348
- }
349
343
  function createGatewayRequestClient(config = {}) {
350
344
  const fetchImpl = config.fetchImpl ?? fetch;
351
345
  const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
352
346
  const maxRetries = config.maxRetries ?? 2;
353
347
  const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
354
348
  async function resolveAuthHeaders() {
355
- const provided = config.getAuthHeaders ? await config.getAuthHeaders() : {};
356
- const headers = new Headers(provided);
357
- const setIfAbsent = (name, value) => {
358
- const normalized = cleanHeaderValue(value);
359
- if (normalized && !headers.has(name)) {
360
- headers.set(name, normalized);
361
- }
362
- };
363
- setIfAbsent("x-lucern-key", config.apiKey);
364
- setIfAbsent("x-lucern-session-token", config.userToken);
365
- setIfAbsent("x-lucern-environment", config.environment);
366
- setIfAbsent("x-lucern-clerk-id", config.clerkId);
367
- setIfAbsent("x-lucern-user-id", config.userId ?? config.clerkId);
368
- setIfAbsent("x-lucern-deployment-host", config.deploymentHost);
369
- const base = Object.fromEntries(headers.entries());
349
+ const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
370
350
  const authContextInput = await resolveConfiguredAuthContext(
371
351
  config.authContext
372
352
  );
@@ -395,11 +375,11 @@ function createGatewayRequestClient(config = {}) {
395
375
  if (!text) {
396
376
  return null;
397
377
  }
398
- const parsed = tryParseGatewayEnvelopeJson(text);
399
- if (!parsed.ok) {
378
+ try {
379
+ return JSON.parse(text);
380
+ } catch {
400
381
  return null;
401
382
  }
402
- return isRecord(parsed.value) ? parsed.value : null;
403
383
  }
404
384
  function resolveTimeoutMs(method, requestTimeoutMs) {
405
385
  if (typeof requestTimeoutMs === "number") {
@@ -411,31 +391,16 @@ function createGatewayRequestClient(config = {}) {
411
391
  }
412
392
  return config.timeoutMs ?? 15e3;
413
393
  }
414
- function tryParseGatewayEnvelopeJson(text) {
415
- const trimmed = text.trim();
416
- if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
417
- return { ok: false, reason: "non-json" };
418
- }
419
- try {
420
- return { ok: true, value: JSON.parse(trimmed) };
421
- } catch (error) {
422
- if (error instanceof SyntaxError) {
423
- return { ok: false, reason: "invalid-json", error };
424
- }
425
- throw error;
426
- }
427
- }
428
394
  function buildApiError(args) {
429
395
  const failure = args.failure;
430
- const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
396
+ const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
431
397
  const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
432
398
  const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
433
399
  const details = failure?.details ?? legacyError?.details;
434
400
  const policySummary = readPolicySummaryFromDetails(details);
435
- const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
436
401
  return new LucernApiError({
437
402
  code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
438
- message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
403
+ message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
439
404
  status: args.response.status,
440
405
  invariant: failure?.invariant,
441
406
  suggestion: failure?.suggestion,
@@ -561,11 +526,8 @@ function createGatewayRequestClient(config = {}) {
561
526
  }
562
527
 
563
528
  // src/sdkSurface.ts
564
- function isRecord2(value) {
565
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
566
- }
567
529
  function asRecord(value) {
568
- return isRecord2(value) ? value : {};
530
+ return value && typeof value === "object" ? value : {};
569
531
  }
570
532
  function cleanString2(value) {
571
533
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
@@ -626,7 +588,9 @@ function normalizeNodeWriteInput(value) {
626
588
  }
627
589
  return next;
628
590
  }
629
- var normalizeNodeVerificationStatus = normalizeVerificationStatus;
591
+ function normalizeNodeVerificationStatus(value) {
592
+ return normalizeVerificationStatus(value);
593
+ }
630
594
  function normalizeTopicQuery(value) {
631
595
  const topicId = cleanString2(value.topicId);
632
596
  if (!topicId) {
@@ -653,10 +617,7 @@ function createListResult(items, legacyKey) {
653
617
  total: items.length
654
618
  };
655
619
  if (legacyKey) {
656
- return {
657
- ...result,
658
- [legacyKey]: items
659
- };
620
+ result[legacyKey] = items;
660
621
  }
661
622
  return result;
662
623
  }
@@ -676,7 +637,7 @@ function mapAliasedList(data, legacyKey) {
676
637
  // src/ontologyClient.ts
677
638
  function createOntologyClient(config = {}) {
678
639
  const gateway = createGatewayRequestClient(config);
679
- const client = {
640
+ return {
680
641
  /**
681
642
  * List ontology definitions matching optional filters.
682
643
  */
@@ -685,14 +646,13 @@ function createOntologyClient(config = {}) {
685
646
  path: `/api/platform/v1/ontologies${toQueryString(filters)}`
686
647
  }).then(
687
648
  (response) => mapGatewayData(response, (data) => {
688
- const record = asRecord(data);
689
- const ontologies = asListItems(data, "ontologies");
690
- const definitions = ontologies.length > 0 ? ontologies : asListItems(data, "definitions");
691
- const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : definitions.length;
649
+ const record = data && typeof data === "object" && !Array.isArray(data) ? data : {};
650
+ const ontologies = Array.isArray(record.ontologies) ? record.ontologies : Array.isArray(record.definitions) ? record.definitions : Array.isArray(data) ? data : [];
651
+ const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : ontologies.length;
692
652
  return {
693
653
  ...record,
694
- ...createListResult(definitions, "definitions"),
695
- ontologies: definitions,
654
+ ...createListResult(ontologies, "definitions"),
655
+ ontologies,
696
656
  total
697
657
  };
698
658
  })
@@ -719,6 +679,18 @@ function createOntologyClient(config = {}) {
719
679
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
720
680
  });
721
681
  },
682
+ /**
683
+ * List ontology definitions.
684
+ */
685
+ async listDefinitions(filters = {}) {
686
+ return this.list(filters);
687
+ },
688
+ /**
689
+ * Get an ontology definition.
690
+ */
691
+ async getDefinition(id) {
692
+ return this.get(id);
693
+ },
722
694
  /**
723
695
  * Create an ontology definition.
724
696
  */
@@ -760,7 +732,7 @@ function createOntologyClient(config = {}) {
760
732
  }).then(
761
733
  (response) => mapGatewayData(
762
734
  response,
763
- (data) => createListResult(asListItems(data, "versions"), "versions")
735
+ (data) => createListResult(Array.isArray(data) ? data : [], "versions")
764
736
  )
765
737
  );
766
738
  },
@@ -808,19 +780,20 @@ function createOntologyClient(config = {}) {
808
780
  (data) => createListResult(Array.isArray(data) ? data : [], "topics")
809
781
  )
810
782
  );
783
+ },
784
+ /**
785
+ * @deprecated Use listTopics.
786
+ */
787
+ async listTopicsByOntology(ontologyId) {
788
+ return this.listTopics(ontologyId);
811
789
  }
812
790
  };
813
- return Object.assign(client, {
814
- listDefinitions: client.list,
815
- getDefinition: client.get,
816
- listTopicsByOntology: client.listTopics
817
- });
818
791
  }
819
792
 
820
793
  // src/graphClient.ts
821
794
  function createGraphClient(config = {}) {
822
795
  const gateway = createGatewayRequestClient(config);
823
- const client = {
796
+ return {
824
797
  /**
825
798
  * List graph nodes matching the provided filters.
826
799
  */
@@ -833,6 +806,12 @@ function createGraphClient(config = {}) {
833
806
  (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
834
807
  );
835
808
  },
809
+ /**
810
+ * @deprecated Use listNodes.
811
+ */
812
+ async queryNodes(query) {
813
+ return this.listNodes(query);
814
+ },
836
815
  /**
837
816
  * Retrieve a single graph node by nodeId or globalId.
838
817
  */
@@ -943,6 +922,12 @@ function createGraphClient(config = {}) {
943
922
  )
944
923
  );
945
924
  },
925
+ /**
926
+ * @deprecated Use listEdges.
927
+ */
928
+ async queryEdges(query) {
929
+ return this.listEdges(query);
930
+ },
946
931
  /**
947
932
  * Create a graph edge.
948
933
  */
@@ -1030,6 +1015,12 @@ function createGraphClient(config = {}) {
1030
1015
  body: normalizeTopicQuery(query)
1031
1016
  });
1032
1017
  },
1018
+ /**
1019
+ * Retrieve a graph neighborhood around a root node.
1020
+ */
1021
+ async getNeighborhood(query) {
1022
+ return this.neighborhood(query);
1023
+ },
1033
1024
  /**
1034
1025
  * Retrieve the shortest known path between two graph nodes.
1035
1026
  */
@@ -1047,11 +1038,6 @@ function createGraphClient(config = {}) {
1047
1038
  });
1048
1039
  }
1049
1040
  };
1050
- return Object.assign(client, {
1051
- queryNodes: client.listNodes,
1052
- queryEdges: client.listEdges,
1053
- getNeighborhood: client.neighborhood
1054
- });
1055
1041
  }
1056
1042
 
1057
1043
  // src/boundaryClientSurface.ts
@@ -1059,9 +1045,6 @@ function cleanOptionalString(value) {
1059
1045
  const normalized = value?.trim();
1060
1046
  return normalized ? normalized : void 0;
1061
1047
  }
1062
- function isRecord3(value) {
1063
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1064
- }
1065
1048
  function cleanRequiredString(value, label) {
1066
1049
  const normalized = cleanOptionalString(value);
1067
1050
  if (!normalized) {
@@ -1083,117 +1066,13 @@ function knownPayload(input, allowed, operation) {
1083
1066
  return { ...input };
1084
1067
  }
1085
1068
  function listResultFromEnvelope(data, legacyKey) {
1086
- const record = isRecord3(data) ? data : {};
1087
- const legacyItems = record[legacyKey];
1069
+ const record = data && typeof data === "object" ? data : {};
1088
1070
  return createListResult(
1089
- Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
1071
+ Array.isArray(record[legacyKey]) ? record[legacyKey] : Array.isArray(data) ? data : [],
1090
1072
  legacyKey
1091
1073
  );
1092
1074
  }
1093
1075
 
1094
- // src/control-plane.ts
1095
- var LucernControlPlaneIdentityError = class extends Error {
1096
- reason;
1097
- principalStatus;
1098
- tenantStatus;
1099
- workspaceStatus;
1100
- details;
1101
- constructor(failure) {
1102
- super(failure.message);
1103
- this.name = "LucernControlPlaneIdentityError";
1104
- this.reason = failure.reason;
1105
- this.principalStatus = failure.principalStatus;
1106
- this.tenantStatus = failure.tenantStatus;
1107
- this.workspaceStatus = failure.workspaceStatus;
1108
- this.details = failure.details;
1109
- }
1110
- };
1111
- function cleanString3(value) {
1112
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
1113
- }
1114
- function stringList(value) {
1115
- if (!Array.isArray(value)) {
1116
- return [];
1117
- }
1118
- return [
1119
- ...new Set(
1120
- value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean)
1121
- )
1122
- ];
1123
- }
1124
- function principalType(value) {
1125
- switch (value) {
1126
- case "service":
1127
- case "service_principal":
1128
- return "service";
1129
- case "agent":
1130
- return "agent";
1131
- case "group":
1132
- return "group";
1133
- case "external_viewer":
1134
- case "external_stakeholder":
1135
- return "external_viewer";
1136
- default:
1137
- return "human";
1138
- }
1139
- }
1140
- function adminFlags(roles) {
1141
- const normalized = roles.map((role) => role.toLowerCase());
1142
- const isPlatformAdmin = normalized.includes("platform_admin");
1143
- const isTenantAdmin = isPlatformAdmin || normalized.includes("tenant_admin");
1144
- const isWorkspaceAdmin = isTenantAdmin || normalized.includes("workspace_admin") || normalized.includes("workspace_owner");
1145
- return { isPlatformAdmin, isTenantAdmin, isWorkspaceAdmin };
1146
- }
1147
- function normalizeResolvedInteractivePrincipal(payload) {
1148
- if ("ok" in payload && payload.ok === false) {
1149
- throw new LucernControlPlaneIdentityError(payload);
1150
- }
1151
- const principalId = cleanString3(payload.principalId);
1152
- const clerkId = cleanString3(payload.clerkId);
1153
- const tenantId = cleanString3(payload.tenantId);
1154
- if (!principalId || !clerkId || !tenantId) {
1155
- throw new LucernControlPlaneIdentityError({
1156
- ok: false,
1157
- reason: "resolver_unavailable",
1158
- message: "Control-plane principal resolver returned an incomplete principal context.",
1159
- principalStatus: payload.principalStatus ?? "missing",
1160
- tenantStatus: payload.tenantStatus,
1161
- workspaceStatus: payload.workspaceStatus
1162
- });
1163
- }
1164
- const roles = stringList(payload.roles);
1165
- const scopes = stringList(payload.scopes);
1166
- const workspaceId = cleanString3(payload.workspaceId) ?? null;
1167
- const flags = adminFlags(roles);
1168
- return {
1169
- principalId,
1170
- principalType: principalType(payload.principalType),
1171
- clerkId,
1172
- tenantId,
1173
- workspaceId,
1174
- roles,
1175
- scopes,
1176
- groupIds: stringList(payload.groupIds),
1177
- permittedToolNames: stringList(payload.permittedToolNames),
1178
- permittedPackKeys: stringList(payload.permittedPackKeys),
1179
- principalStatus: cleanString3(payload.principalStatus) ?? "active",
1180
- tenantStatus: cleanString3(payload.tenantStatus) ?? "active",
1181
- workspaceStatus: cleanString3(payload.workspaceStatus) ?? (workspaceId ? "active" : "none"),
1182
- isPlatformAdmin: typeof payload.isPlatformAdmin === "boolean" ? payload.isPlatformAdmin : flags.isPlatformAdmin,
1183
- isTenantAdmin: typeof payload.isTenantAdmin === "boolean" ? payload.isTenantAdmin : flags.isTenantAdmin,
1184
- isWorkspaceAdmin: typeof payload.isWorkspaceAdmin === "boolean" ? payload.isWorkspaceAdmin : flags.isWorkspaceAdmin,
1185
- permit: {
1186
- subject: cleanString3(payload.permit?.subject) ?? principalId,
1187
- tenant: cleanString3(payload.permit?.tenant) ?? tenantId,
1188
- ...workspaceId ? { workspace: cleanString3(payload.permit?.workspace) ?? workspaceId } : {}
1189
- },
1190
- authMode: "interactive_user",
1191
- sessionId: payload.sessionId,
1192
- delegatedBy: payload.delegatedBy,
1193
- expiresAt: payload.expiresAt
1194
- };
1195
- }
1196
-
1197
1076
  // src/identityClient.ts
1198
1077
  function createIdentityWhoamiClient(config = {}) {
1199
1078
  const gateway = createGatewayRequestClient(config);
@@ -1245,13 +1124,6 @@ function createIdentityClient(config = {}) {
1245
1124
  body: input,
1246
1125
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1247
1126
  });
1248
- const updatePrincipal = (input, idempotencyKey) => requestPrincipalWrite("PATCH", input, idempotencyKey);
1249
- const deleteKey = (keyId, input = {}, idempotencyKey) => gateway.request({
1250
- path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
1251
- method: "POST",
1252
- body: input,
1253
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1254
- });
1255
1127
  return {
1256
1128
  /**
1257
1129
  * Resolve the current authenticated identity summary.
@@ -1261,25 +1133,13 @@ function createIdentityClient(config = {}) {
1261
1133
  (response) => mapGatewayData(response, (data) => ({
1262
1134
  principalId: data.principalId,
1263
1135
  principalType: data.principalType,
1264
- clerkId: data.clerkId,
1265
1136
  tenantId: data.tenantId ?? null,
1266
1137
  workspaceId: data.workspaceId ?? null,
1267
1138
  scopes: Array.isArray(data.scopes) ? data.scopes : [],
1268
1139
  roles: Array.isArray(data.roles) ? data.roles : [],
1269
- groupIds: Array.isArray(data.groupIds) ? data.groupIds : [],
1270
- permittedToolNames: Array.isArray(data.permittedToolNames) ? data.permittedToolNames : [],
1271
- permittedPackKeys: Array.isArray(data.permittedPackKeys) ? data.permittedPackKeys : [],
1272
- principalStatus: data.principalStatus,
1273
- tenantStatus: data.tenantStatus,
1274
- workspaceStatus: data.workspaceStatus,
1275
1140
  isPlatformAdmin: data.isPlatformAdmin === true,
1276
1141
  isTenantAdmin: data.isTenantAdmin === true,
1277
1142
  isWorkspaceAdmin: data.isWorkspaceAdmin === true,
1278
- permit: data.permit ?? (data.tenantId ? {
1279
- subject: data.principalId,
1280
- tenant: data.tenantId,
1281
- ...data.workspaceId ? { workspace: data.workspaceId } : {}
1282
- } : void 0),
1283
1143
  authMode: data.authMode,
1284
1144
  sessionId: data.sessionId,
1285
1145
  delegatedBy: data.delegatedBy,
@@ -1287,19 +1147,6 @@ function createIdentityClient(config = {}) {
1287
1147
  }))
1288
1148
  );
1289
1149
  },
1290
- /**
1291
- * Resolve a Clerk subject through the tenant control-plane Permit projection.
1292
- * @deprecated Prefer lucern.controlPlane.identity.resolveInteractivePrincipal().
1293
- */
1294
- async resolveInteractivePrincipal(input) {
1295
- return gateway.request({
1296
- path: "/api/platform/v1/control-plane/identity/resolve-interactive-principal",
1297
- method: "POST",
1298
- body: input
1299
- }).then(
1300
- (response) => mapGatewayData(response, normalizeResolvedInteractivePrincipal)
1301
- );
1302
- },
1303
1150
  /**
1304
1151
  * List principals in the current identity scope.
1305
1152
  */
@@ -1325,11 +1172,15 @@ function createIdentityClient(config = {}) {
1325
1172
  /**
1326
1173
  * Update a principal.
1327
1174
  */
1328
- updatePrincipal,
1175
+ async updatePrincipal(input, idempotencyKey) {
1176
+ return requestPrincipalWrite("PATCH", input, idempotencyKey);
1177
+ },
1329
1178
  /**
1330
1179
  * @deprecated Use createPrincipal or updatePrincipal.
1331
1180
  */
1332
- upsertPrincipal: updatePrincipal,
1181
+ async upsertPrincipal(input, idempotencyKey) {
1182
+ return requestPrincipalWrite("PATCH", input, idempotencyKey);
1183
+ },
1333
1184
  /**
1334
1185
  * List keys in the current identity scope.
1335
1186
  */
@@ -1368,11 +1219,20 @@ function createIdentityClient(config = {}) {
1368
1219
  /**
1369
1220
  * Delete an API key by revoking it.
1370
1221
  */
1371
- deleteKey,
1222
+ async deleteKey(keyId, input = {}, idempotencyKey) {
1223
+ return gateway.request({
1224
+ path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
1225
+ method: "POST",
1226
+ body: input,
1227
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1228
+ });
1229
+ },
1372
1230
  /**
1373
1231
  * @deprecated Use deleteKey.
1374
1232
  */
1375
- revokeKey: deleteKey,
1233
+ async revokeKey(keyId, input = {}, idempotencyKey) {
1234
+ return this.deleteKey(keyId, input, idempotencyKey);
1235
+ },
1376
1236
  /**
1377
1237
  * Search Clerk users by email or display attributes.
1378
1238
  */
@@ -1488,12 +1348,15 @@ function createIdentityClient(config = {}) {
1488
1348
  }
1489
1349
 
1490
1350
  // src/topicsClient.ts
1491
- function cleanString4(value) {
1351
+ function asRecord2(value) {
1352
+ return value && typeof value === "object" ? value : {};
1353
+ }
1354
+ function cleanString3(value) {
1492
1355
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
1493
1356
  }
1494
1357
  function normalizeTopicRecord(value) {
1495
- const record = asRecord(value);
1496
- const topicId = cleanString4(record.topicId) ?? cleanString4(record.id) ?? cleanString4(record._id);
1358
+ const record = asRecord2(value);
1359
+ const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
1497
1360
  return withTopicAlias({
1498
1361
  ...record,
1499
1362
  ...topicId ? { topicId } : {}
@@ -1517,7 +1380,7 @@ function createTopicsClient(config = {}) {
1517
1380
  })}`
1518
1381
  }).then(
1519
1382
  (response) => mapGatewayData(response, (data) => {
1520
- const record = asRecord(data);
1383
+ const record = asRecord2(data);
1521
1384
  const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
1522
1385
  return {
1523
1386
  ...createListResult(items, "topics"),
@@ -1534,7 +1397,7 @@ function createTopicsClient(config = {}) {
1534
1397
  }).then(
1535
1398
  (response) => mapGatewayData(
1536
1399
  response,
1537
- (data) => normalizeTopicRecord(asRecord(data).topic ?? data)
1400
+ (data) => normalizeTopicRecord(asRecord2(data).topic ?? data)
1538
1401
  )
1539
1402
  );
1540
1403
  },
@@ -1570,7 +1433,7 @@ function createTopicsClient(config = {}) {
1570
1433
  )}`
1571
1434
  }).then(
1572
1435
  (response) => mapGatewayData(response, (data) => {
1573
- const record = asRecord(data);
1436
+ const record = asRecord2(data);
1574
1437
  return {
1575
1438
  tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
1576
1439
  };
@@ -1989,7 +1852,7 @@ function createEventsFacade(config = {}) {
1989
1852
  function createGraphFacade(config = {}) {
1990
1853
  const graphClient = createGraphClient(config);
1991
1854
  const gateway = createGatewayRequestClient(config);
1992
- const graphFacade = {
1855
+ return {
1993
1856
  async neighborhood(input) {
1994
1857
  return graphClient.neighborhood({
1995
1858
  globalId: input.globalId,
@@ -1997,6 +1860,18 @@ function createGraphFacade(config = {}) {
1997
1860
  maxDepth: input.maxDepth
1998
1861
  });
1999
1862
  },
1863
+ async traverse(input) {
1864
+ return graphClient.traverse(input);
1865
+ },
1866
+ async analyze(input = {}) {
1867
+ return graphClient.analyze(input);
1868
+ },
1869
+ async bias(input = {}) {
1870
+ return graphClient.bias(input);
1871
+ },
1872
+ async gaps(input) {
1873
+ return graphClient.gaps(input);
1874
+ },
2000
1875
  async falsify(input, idempotencyKey = randomIdempotencyKey()) {
2001
1876
  return gateway.request({
2002
1877
  path: "/api/platform/v1/graph/falsify",
@@ -2006,12 +1881,6 @@ function createGraphFacade(config = {}) {
2006
1881
  });
2007
1882
  }
2008
1883
  };
2009
- return Object.assign(graphFacade, {
2010
- traverse: graphClient.traverse,
2011
- analyze: graphClient.analyze,
2012
- bias: graphClient.bias,
2013
- gaps: graphClient.gaps
2014
- });
2015
1884
  }
2016
1885
  function createIdentityFacade(config = {}) {
2017
1886
  const identityClient = createIdentityClient(config);
@@ -2025,12 +1894,15 @@ function createIdentityFacade(config = {}) {
2025
1894
  function createOntologiesFacade(config = {}) {
2026
1895
  const ontologyClient = createOntologyClient(config);
2027
1896
  const gateway = createGatewayRequestClient(config);
2028
- const ontologyFacade = {
1897
+ return {
2029
1898
  async get(id) {
2030
1899
  return gateway.request({
2031
1900
  path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2032
1901
  });
2033
1902
  },
1903
+ async list(query = {}) {
1904
+ return ontologyClient.list(query);
1905
+ },
2034
1906
  async bind(input, idempotencyKey) {
2035
1907
  return gateway.request({
2036
1908
  path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
@@ -2050,9 +1922,6 @@ function createOntologiesFacade(config = {}) {
2050
1922
  });
2051
1923
  }
2052
1924
  };
2053
- return Object.assign(ontologyFacade, {
2054
- list: ontologyClient.list
2055
- });
2056
1925
  }
2057
1926
  function createQuestionsFacade(config = {}) {
2058
1927
  const gateway = createGatewayRequestClient(config);
@@ -2212,8 +2081,6 @@ function createTasksFacade(config = {}) {
2212
2081
  description: input.description,
2213
2082
  priority: input.priority,
2214
2083
  status: input.status,
2215
- assigneeId: input.assigneeId,
2216
- blockedReason: input.blockedReason,
2217
2084
  linkedBeliefId: input.linkedBeliefId,
2218
2085
  linkedQuestionId: input.linkedQuestionId,
2219
2086
  linkedWorktreeId: input.linkedWorktreeId,
@@ -2247,9 +2114,15 @@ function createTasksFacade(config = {}) {
2247
2114
  function createTopicsFacade(config = {}) {
2248
2115
  const topicsClient = createTopicsClient(config);
2249
2116
  return {
2250
- create: topicsClient.create,
2251
- get: topicsClient.get,
2252
- list: topicsClient.list,
2117
+ async create(input, idempotencyKey) {
2118
+ return topicsClient.create(input, idempotencyKey);
2119
+ },
2120
+ async get(id) {
2121
+ return topicsClient.get(id);
2122
+ },
2123
+ async list(query = {}) {
2124
+ return topicsClient.list(query);
2125
+ },
2253
2126
  async update(input, idempotencyKey) {
2254
2127
  const { id, ...rest } = input;
2255
2128
  return topicsClient.update(id, rest, idempotencyKey);
@@ -2265,8 +2138,12 @@ function createTopicsFacade(config = {}) {
2265
2138
  maxDepth: input.maxDepth
2266
2139
  });
2267
2140
  },
2268
- remove: topicsClient.remove,
2269
- bulkCreate: topicsClient.bulkCreate
2141
+ async remove(id, idempotencyKey = randomIdempotencyKey()) {
2142
+ return topicsClient.remove(id, idempotencyKey);
2143
+ },
2144
+ async bulkCreate(input, idempotencyKey = randomIdempotencyKey()) {
2145
+ return topicsClient.bulkCreate(input, idempotencyKey);
2146
+ }
2270
2147
  };
2271
2148
  }
2272
2149
  function createWebhooksFacade(config = {}) {