@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
@@ -36,14 +36,14 @@ function requireString(value, reason, label) {
36
36
  }
37
37
  return normalized;
38
38
  }
39
- function requirePrincipalType(principalType2) {
40
- if (!principalType2) {
39
+ function requirePrincipalType(principalType) {
40
+ if (!principalType) {
41
41
  throw new LucernSdkAuthContextError(
42
42
  "principal_missing",
43
43
  "Canonical Lucern SDK auth context is missing principalType."
44
44
  );
45
45
  }
46
- return principalType2;
46
+ return principalType;
47
47
  }
48
48
  function requireAuthMode(authMode) {
49
49
  if (!authMode) {
@@ -89,15 +89,14 @@ function normalizeCanonicalLucernAuthContext(input) {
89
89
  );
90
90
  const roles = cleanStringList(input.roles);
91
91
  const scopes = cleanStringList(input.scopes);
92
- const principalType2 = requirePrincipalType(input.principalType);
93
- const authMode = requireAuthMode(input.authMode);
94
- const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
95
- if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
92
+ if (roles.length === 0 || scopes.length === 0) {
96
93
  throw new LucernSdkAuthContextError(
97
94
  "membership_missing",
98
95
  "Canonical Lucern SDK auth context requires non-empty roles and scopes."
99
96
  );
100
97
  }
98
+ const principalType = requirePrincipalType(input.principalType);
99
+ const authMode = requireAuthMode(input.authMode);
101
100
  const subject = cleanString(input.permit?.subject) ?? principalId;
102
101
  const tenant = cleanString(input.permit?.tenant) ?? tenantId;
103
102
  const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
@@ -118,7 +117,7 @@ function normalizeCanonicalLucernAuthContext(input) {
118
117
  principalId,
119
118
  tenantId,
120
119
  workspaceId,
121
- principalType: principalType2,
120
+ principalType,
122
121
  authMode,
123
122
  roles,
124
123
  scopes,
@@ -239,7 +238,9 @@ function generatePortableRequestId() {
239
238
  8
240
239
  ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
241
240
  }
242
- var randomIdempotencyKey = generatePortableRequestId;
241
+ function randomIdempotencyKey() {
242
+ return generatePortableRequestId();
243
+ }
243
244
  function isRetryableStatus(status) {
244
245
  return status >= 500 || status === 408 || status === 429;
245
246
  }
@@ -304,11 +305,8 @@ function timeoutError(timeoutMs) {
304
305
  error.name = "AbortError";
305
306
  return error;
306
307
  }
307
- function isRecord(value) {
308
- return value !== null && typeof value === "object" && !Array.isArray(value);
309
- }
310
308
  function readPolicySummaryFromDetails(details) {
311
- if (!isRecord(details)) {
309
+ if (!details || typeof details !== "object" || Array.isArray(details)) {
312
310
  return null;
313
311
  }
314
312
  const directSummary = details.summary;
@@ -316,11 +314,11 @@ function readPolicySummaryFromDetails(details) {
316
314
  return directSummary.trim();
317
315
  }
318
316
  const policy = details.policy;
319
- if (!isRecord(policy)) {
317
+ if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
320
318
  return null;
321
319
  }
322
320
  const explanation = policy.explanation;
323
- if (!isRecord(explanation)) {
321
+ if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
324
322
  return null;
325
323
  }
326
324
  const nestedSummary = explanation.summary;
@@ -349,31 +347,13 @@ function mergeHeaderRecord(base, addition) {
349
347
  }
350
348
  return Object.fromEntries(headers.entries());
351
349
  }
352
- function cleanHeaderValue(value) {
353
- const normalized = value?.trim();
354
- return normalized ? normalized : void 0;
355
- }
356
350
  function createGatewayRequestClient(config = {}) {
357
351
  const fetchImpl = config.fetchImpl ?? fetch;
358
352
  const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
359
353
  const maxRetries = config.maxRetries ?? 2;
360
354
  const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
361
355
  async function resolveAuthHeaders() {
362
- const provided = config.getAuthHeaders ? await config.getAuthHeaders() : {};
363
- const headers = new Headers(provided);
364
- const setIfAbsent = (name, value) => {
365
- const normalized = cleanHeaderValue(value);
366
- if (normalized && !headers.has(name)) {
367
- headers.set(name, normalized);
368
- }
369
- };
370
- setIfAbsent("x-lucern-key", config.apiKey);
371
- setIfAbsent("x-lucern-session-token", config.userToken);
372
- setIfAbsent("x-lucern-environment", config.environment);
373
- setIfAbsent("x-lucern-clerk-id", config.clerkId);
374
- setIfAbsent("x-lucern-user-id", config.userId ?? config.clerkId);
375
- setIfAbsent("x-lucern-deployment-host", config.deploymentHost);
376
- const base = Object.fromEntries(headers.entries());
356
+ const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
377
357
  const authContextInput = await resolveConfiguredAuthContext(
378
358
  config.authContext
379
359
  );
@@ -402,11 +382,11 @@ function createGatewayRequestClient(config = {}) {
402
382
  if (!text) {
403
383
  return null;
404
384
  }
405
- const parsed = tryParseGatewayEnvelopeJson(text);
406
- if (!parsed.ok) {
385
+ try {
386
+ return JSON.parse(text);
387
+ } catch {
407
388
  return null;
408
389
  }
409
- return isRecord(parsed.value) ? parsed.value : null;
410
390
  }
411
391
  function resolveTimeoutMs(method, requestTimeoutMs) {
412
392
  if (typeof requestTimeoutMs === "number") {
@@ -418,31 +398,16 @@ function createGatewayRequestClient(config = {}) {
418
398
  }
419
399
  return config.timeoutMs ?? 15e3;
420
400
  }
421
- function tryParseGatewayEnvelopeJson(text) {
422
- const trimmed = text.trim();
423
- if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
424
- return { ok: false, reason: "non-json" };
425
- }
426
- try {
427
- return { ok: true, value: JSON.parse(trimmed) };
428
- } catch (error) {
429
- if (error instanceof SyntaxError) {
430
- return { ok: false, reason: "invalid-json", error };
431
- }
432
- throw error;
433
- }
434
- }
435
401
  function buildApiError(args) {
436
402
  const failure = args.failure;
437
- const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
403
+ const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
438
404
  const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
439
405
  const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
440
406
  const details = failure?.details ?? legacyError?.details;
441
407
  const policySummary = readPolicySummaryFromDetails(details);
442
- const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
443
408
  return new LucernApiError({
444
409
  code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
445
- message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
410
+ message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
446
411
  status: args.response.status,
447
412
  invariant: failure?.invariant,
448
413
  suggestion: failure?.suggestion,
@@ -568,11 +533,8 @@ function createGatewayRequestClient(config = {}) {
568
533
  }
569
534
 
570
535
  // src/sdkSurface.ts
571
- function isRecord2(value) {
572
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
573
- }
574
536
  function asRecord(value) {
575
- return isRecord2(value) ? value : {};
537
+ return value && typeof value === "object" ? value : {};
576
538
  }
577
539
  function cleanString2(value) {
578
540
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
@@ -633,7 +595,9 @@ function normalizeNodeWriteInput(value) {
633
595
  }
634
596
  return next;
635
597
  }
636
- var normalizeNodeVerificationStatus = normalizeVerificationStatus;
598
+ function normalizeNodeVerificationStatus(value) {
599
+ return normalizeVerificationStatus(value);
600
+ }
637
601
  function normalizeTopicQuery(value) {
638
602
  const topicId = cleanString2(value.topicId);
639
603
  if (!topicId) {
@@ -660,10 +624,7 @@ function createListResult(items, legacyKey) {
660
624
  total: items.length
661
625
  };
662
626
  if (legacyKey) {
663
- return {
664
- ...result,
665
- [legacyKey]: items
666
- };
627
+ result[legacyKey] = items;
667
628
  }
668
629
  return result;
669
630
  }
@@ -707,17 +668,6 @@ function asTenantVaultSecretArray(data) {
707
668
  }
708
669
  function createAdminClient(config = {}) {
709
670
  const gateway = createGatewayRequestClient(config);
710
- const getControlObjectOwnership = async () => gateway.request({
711
- path: "/api/platform/v1/admin/control-ownership"
712
- });
713
- const createMembership = async (input, idempotencyKey) => gateway.request({
714
- path: "/api/platform/v1/memberships",
715
- method: "POST",
716
- body: input,
717
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
718
- });
719
- const updateMembership = createMembership;
720
- const upsertMembership = createMembership;
721
671
  return {
722
672
  /**
723
673
  * List tenants visible to the current principal.
@@ -749,11 +699,19 @@ function createAdminClient(config = {}) {
749
699
  /**
750
700
  * Get the control-object ownership contract.
751
701
  */
752
- getControlObjectOwnership,
702
+ async getControlObjectOwnership() {
703
+ return gateway.request({
704
+ path: "/api/platform/v1/admin/control-ownership"
705
+ });
706
+ },
753
707
  /**
754
708
  * @deprecated Use getControlObjectOwnership.
755
709
  */
756
- getControlObjectOwnershipContract: getControlObjectOwnership,
710
+ async getControlObjectOwnershipContract() {
711
+ return gateway.request({
712
+ path: "/api/platform/v1/admin/control-ownership"
713
+ });
714
+ },
757
715
  /**
758
716
  * List workspaces for the current admin scope.
759
717
  */
@@ -800,15 +758,26 @@ function createAdminClient(config = {}) {
800
758
  /**
801
759
  * Create a membership.
802
760
  */
803
- createMembership,
761
+ async createMembership(input, idempotencyKey) {
762
+ return gateway.request({
763
+ path: "/api/platform/v1/memberships",
764
+ method: "POST",
765
+ body: input,
766
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
767
+ });
768
+ },
804
769
  /**
805
770
  * Update a membership.
806
771
  */
807
- updateMembership,
772
+ async updateMembership(input, idempotencyKey) {
773
+ return this.createMembership(input, idempotencyKey);
774
+ },
808
775
  /**
809
776
  * @deprecated Use createMembership or updateMembership.
810
777
  */
811
- upsertMembership,
778
+ async upsertMembership(input, idempotencyKey) {
779
+ return this.createMembership(input, idempotencyKey);
780
+ },
812
781
  /**
813
782
  * List tenant API keys in the current admin scope.
814
783
  */
@@ -1070,852 +1039,135 @@ function createAdminClient(config = {}) {
1070
1039
  };
1071
1040
  }
1072
1041
 
1073
- // src/boundaryClientSurface.ts
1074
- function cleanOptionalString(value) {
1075
- const normalized = value?.trim();
1076
- return normalized ? normalized : void 0;
1077
- }
1078
- function isRecord3(value) {
1079
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1080
- }
1081
- function cleanRequiredString(value, label) {
1082
- const normalized = cleanOptionalString(value);
1083
- if (!normalized) {
1084
- throw new Error(`${label} is required`);
1085
- }
1086
- return normalized;
1087
- }
1088
- function readTopicId(input) {
1089
- return cleanOptionalString(input.topicId) ?? cleanOptionalString(input.projectId);
1090
- }
1091
- function requireTopicId(input) {
1092
- const topicId = readTopicId(input);
1093
- if (!topicId) {
1094
- throw new Error("topicId is required");
1095
- }
1096
- return topicId;
1097
- }
1098
- function assertKnownKeys(input, allowed, operation) {
1099
- const allowedSet = new Set(allowed);
1100
- const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
1101
- if (unknownKeys.length > 0) {
1102
- throw new Error(
1103
- `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
1104
- );
1105
- }
1106
- }
1107
- function knownPayload(input, allowed, operation) {
1108
- assertKnownKeys(input, allowed, operation);
1109
- return { ...input };
1110
- }
1111
- function topicPayload(input, allowed, operation) {
1112
- assertKnownKeys(input, allowed, operation);
1113
- return {
1114
- ...input,
1115
- topicId: requireTopicId(input),
1116
- projectId: void 0
1117
- };
1118
- }
1119
- function listResultFromEnvelope(data, legacyKey) {
1120
- const record = isRecord3(data) ? data : {};
1121
- const legacyItems = record[legacyKey];
1122
- return createListResult(
1123
- Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
1124
- legacyKey
1125
- );
1126
- }
1127
-
1128
- // src/control-plane.ts
1129
- var LucernControlPlaneIdentityError = class extends Error {
1130
- reason;
1131
- principalStatus;
1132
- tenantStatus;
1133
- workspaceStatus;
1134
- details;
1135
- constructor(failure) {
1136
- super(failure.message);
1137
- this.name = "LucernControlPlaneIdentityError";
1138
- this.reason = failure.reason;
1139
- this.principalStatus = failure.principalStatus;
1140
- this.tenantStatus = failure.tenantStatus;
1141
- this.workspaceStatus = failure.workspaceStatus;
1142
- this.details = failure.details;
1143
- }
1144
- };
1145
- function cleanString3(value) {
1146
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
1147
- }
1148
- function stringList(value) {
1149
- if (!Array.isArray(value)) {
1150
- return [];
1151
- }
1152
- return [
1153
- ...new Set(
1154
- value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean)
1155
- )
1156
- ];
1157
- }
1158
- function principalType(value) {
1159
- switch (value) {
1160
- case "service":
1161
- case "service_principal":
1162
- return "service";
1163
- case "agent":
1164
- return "agent";
1165
- case "group":
1166
- return "group";
1167
- case "external_viewer":
1168
- case "external_stakeholder":
1169
- return "external_viewer";
1170
- default:
1171
- return "human";
1172
- }
1173
- }
1174
- function adminFlags(roles) {
1175
- const normalized = roles.map((role) => role.toLowerCase());
1176
- const isPlatformAdmin = normalized.includes("platform_admin");
1177
- const isTenantAdmin = isPlatformAdmin || normalized.includes("tenant_admin");
1178
- const isWorkspaceAdmin = isTenantAdmin || normalized.includes("workspace_admin") || normalized.includes("workspace_owner");
1179
- return { isPlatformAdmin, isTenantAdmin, isWorkspaceAdmin };
1180
- }
1181
- function normalizeResolvedInteractivePrincipal(payload) {
1182
- if ("ok" in payload && payload.ok === false) {
1183
- throw new LucernControlPlaneIdentityError(payload);
1184
- }
1185
- const principalId = cleanString3(payload.principalId);
1186
- const clerkId = cleanString3(payload.clerkId);
1187
- const tenantId = cleanString3(payload.tenantId);
1188
- if (!principalId || !clerkId || !tenantId) {
1189
- throw new LucernControlPlaneIdentityError({
1190
- ok: false,
1191
- reason: "resolver_unavailable",
1192
- message: "Control-plane principal resolver returned an incomplete principal context.",
1193
- principalStatus: payload.principalStatus ?? "missing",
1194
- tenantStatus: payload.tenantStatus,
1195
- workspaceStatus: payload.workspaceStatus
1196
- });
1197
- }
1198
- const roles = stringList(payload.roles);
1199
- const scopes = stringList(payload.scopes);
1200
- const workspaceId = cleanString3(payload.workspaceId) ?? null;
1201
- const flags = adminFlags(roles);
1202
- return {
1203
- principalId,
1204
- principalType: principalType(payload.principalType),
1205
- clerkId,
1206
- tenantId,
1207
- workspaceId,
1208
- roles,
1209
- scopes,
1210
- groupIds: stringList(payload.groupIds),
1211
- permittedToolNames: stringList(payload.permittedToolNames),
1212
- permittedPackKeys: stringList(payload.permittedPackKeys),
1213
- principalStatus: cleanString3(payload.principalStatus) ?? "active",
1214
- tenantStatus: cleanString3(payload.tenantStatus) ?? "active",
1215
- workspaceStatus: cleanString3(payload.workspaceStatus) ?? (workspaceId ? "active" : "none"),
1216
- isPlatformAdmin: typeof payload.isPlatformAdmin === "boolean" ? payload.isPlatformAdmin : flags.isPlatformAdmin,
1217
- isTenantAdmin: typeof payload.isTenantAdmin === "boolean" ? payload.isTenantAdmin : flags.isTenantAdmin,
1218
- isWorkspaceAdmin: typeof payload.isWorkspaceAdmin === "boolean" ? payload.isWorkspaceAdmin : flags.isWorkspaceAdmin,
1219
- permit: {
1220
- subject: cleanString3(payload.permit?.subject) ?? principalId,
1221
- tenant: cleanString3(payload.permit?.tenant) ?? tenantId,
1222
- ...workspaceId ? { workspace: cleanString3(payload.permit?.workspace) ?? workspaceId } : {}
1223
- },
1224
- authMode: "interactive_user",
1225
- sessionId: payload.sessionId,
1226
- delegatedBy: payload.delegatedBy,
1227
- expiresAt: payload.expiresAt
1228
- };
1229
- }
1230
- function createControlPlaneIdentityClient(config = {}) {
1231
- const gateway = createGatewayRequestClient(config);
1232
- return {
1233
- async resolveInteractivePrincipal(input) {
1234
- return gateway.request({
1235
- path: "/api/platform/v1/control-plane/identity/resolve-interactive-principal",
1236
- method: "POST",
1237
- body: input
1238
- }).then(
1239
- (response) => mapGatewayData(response, normalizeResolvedInteractivePrincipal)
1240
- );
1241
- }
1242
- };
1243
- }
1244
- function createControlPlaneClient(config = {}) {
1245
- return {
1246
- identity: createControlPlaneIdentityClient(config)
1247
- };
1248
- }
1249
-
1250
- // src/identityClient.ts
1251
- function createIdentityWhoamiClient(config = {}) {
1042
+ // src/answersClient.ts
1043
+ function createAnswersClient(config = {}) {
1252
1044
  const gateway = createGatewayRequestClient(config);
1253
1045
  return {
1254
- async whoami() {
1046
+ /**
1047
+ * Get the current answer for a question.
1048
+ * @param questionId - The question node identifier.
1049
+ * @returns The answer record for the given question.
1050
+ */
1051
+ async get(questionId) {
1255
1052
  return gateway.request({
1256
- path: "/api/platform/v1/identity/whoami"
1053
+ path: `/api/platform/v1/questions/${encodeURIComponent(questionId)}/answer`
1257
1054
  });
1258
1055
  }
1259
1056
  };
1260
1057
  }
1261
- var TENANT_IDENTITY_FIELDS = [
1262
- "tenantId",
1263
- "workspaceId",
1264
- "principalId",
1265
- "integrationKey",
1266
- "secretRef",
1267
- "policySubject",
1268
- "policyAction",
1269
- "policyResource",
1270
- "decision",
1271
- "config",
1272
- "configKey",
1273
- "configValue",
1274
- "provider",
1275
- "status",
1276
- "metadata",
1277
- "limit",
1278
- "cursor"
1279
- ];
1280
- function tenantIdentityQuery(input) {
1281
- return {
1282
- tenantId: cleanRequiredString(input.tenantId, "tenantId"),
1283
- workspaceId: input.workspaceId,
1284
- principalId: input.principalId,
1285
- limit: input.limit,
1286
- cursor: input.cursor
1287
- };
1288
- }
1289
- function tenantIdentityBody(input, operation) {
1290
- return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
1291
- }
1292
- function createIdentityClient(config = {}) {
1058
+
1059
+ // src/audiencesClient.ts
1060
+ function createAudiencesClient(config = {}) {
1293
1061
  const gateway = createGatewayRequestClient(config);
1294
- const whoamiClient = createIdentityWhoamiClient(config);
1295
- const requestPrincipalWrite = (method, input, idempotencyKey) => gateway.request({
1296
- path: "/api/platform/v1/identity/principals",
1297
- method,
1298
- body: input,
1299
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1300
- });
1301
- const updatePrincipal = (input, idempotencyKey) => requestPrincipalWrite("PATCH", input, idempotencyKey);
1302
- const deleteKey = (keyId, input = {}, idempotencyKey) => gateway.request({
1303
- path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
1304
- method: "POST",
1305
- body: input,
1306
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1307
- });
1308
1062
  return {
1309
1063
  /**
1310
- * Resolve the current authenticated identity summary.
1311
- */
1312
- async whoami() {
1313
- return whoamiClient.whoami().then(
1314
- (response) => mapGatewayData(response, (data) => ({
1315
- principalId: data.principalId,
1316
- principalType: data.principalType,
1317
- clerkId: data.clerkId,
1318
- tenantId: data.tenantId ?? null,
1319
- workspaceId: data.workspaceId ?? null,
1320
- scopes: Array.isArray(data.scopes) ? data.scopes : [],
1321
- roles: Array.isArray(data.roles) ? data.roles : [],
1322
- groupIds: Array.isArray(data.groupIds) ? data.groupIds : [],
1323
- permittedToolNames: Array.isArray(data.permittedToolNames) ? data.permittedToolNames : [],
1324
- permittedPackKeys: Array.isArray(data.permittedPackKeys) ? data.permittedPackKeys : [],
1325
- principalStatus: data.principalStatus,
1326
- tenantStatus: data.tenantStatus,
1327
- workspaceStatus: data.workspaceStatus,
1328
- isPlatformAdmin: data.isPlatformAdmin === true,
1329
- isTenantAdmin: data.isTenantAdmin === true,
1330
- isWorkspaceAdmin: data.isWorkspaceAdmin === true,
1331
- permit: data.permit ?? (data.tenantId ? {
1332
- subject: data.principalId,
1333
- tenant: data.tenantId,
1334
- ...data.workspaceId ? { workspace: data.workspaceId } : {}
1335
- } : void 0),
1336
- authMode: data.authMode,
1337
- sessionId: data.sessionId,
1338
- delegatedBy: data.delegatedBy,
1339
- expiresAt: data.expiresAt
1340
- }))
1341
- );
1342
- },
1343
- /**
1344
- * Resolve a Clerk subject through the tenant control-plane Permit projection.
1345
- * @deprecated Prefer lucern.controlPlane.identity.resolveInteractivePrincipal().
1346
- */
1347
- async resolveInteractivePrincipal(input) {
1348
- return gateway.request({
1349
- path: "/api/platform/v1/control-plane/identity/resolve-interactive-principal",
1350
- method: "POST",
1351
- body: input
1352
- }).then(
1353
- (response) => mapGatewayData(response, normalizeResolvedInteractivePrincipal)
1354
- );
1355
- },
1356
- /**
1357
- * List principals in the current identity scope.
1064
+ * List audience registry entries.
1358
1065
  */
1359
- async listPrincipals(query5 = {}) {
1066
+ async listRegistry(query5 = {}) {
1360
1067
  return gateway.request({
1361
- path: `/api/platform/v1/identity/principals${toQueryString(query5)}`
1068
+ path: `/api/platform/v1/audiences/registry${toQueryString({
1069
+ ...query5,
1070
+ effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1071
+ status: query5.status
1072
+ })}`
1362
1073
  }).then(
1363
1074
  (response) => mapGatewayData(
1364
1075
  response,
1365
1076
  (data) => createListResult(
1366
1077
  Array.isArray(data) ? data : [],
1367
- "principals"
1078
+ "registryEntries"
1368
1079
  )
1369
1080
  )
1370
1081
  );
1371
1082
  },
1372
1083
  /**
1373
- * Create a principal.
1084
+ * @deprecated Use listRegistry.
1374
1085
  */
1375
- async createPrincipal(input, idempotencyKey) {
1376
- return requestPrincipalWrite("POST", input, idempotencyKey);
1086
+ async getRegistry(query5 = {}) {
1087
+ return this.listRegistry(query5);
1377
1088
  },
1378
1089
  /**
1379
- * Update a principal.
1090
+ * Create an audience registry entry.
1380
1091
  */
1381
- updatePrincipal,
1092
+ async createRegistryEntry(input, idempotencyKey) {
1093
+ return gateway.request({
1094
+ path: "/api/platform/v1/audiences/registry",
1095
+ method: "POST",
1096
+ body: input,
1097
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1098
+ });
1099
+ },
1382
1100
  /**
1383
- * @deprecated Use createPrincipal or updatePrincipal.
1101
+ * Update an audience registry entry.
1384
1102
  */
1385
- upsertPrincipal: updatePrincipal,
1103
+ async updateRegistryEntry(input, idempotencyKey) {
1104
+ return this.createRegistryEntry(input, idempotencyKey);
1105
+ },
1386
1106
  /**
1387
- * List keys in the current identity scope.
1107
+ * @deprecated Use createRegistryEntry or updateRegistryEntry.
1388
1108
  */
1389
- async listKeys(query5 = {}) {
1109
+ async upsertRegistry(input, idempotencyKey) {
1110
+ return this.createRegistryEntry(input, idempotencyKey);
1111
+ },
1112
+ /**
1113
+ * List audience grants.
1114
+ */
1115
+ async listGrants(query5 = {}) {
1390
1116
  return gateway.request({
1391
- path: `/api/platform/v1/identity/keys${toQueryString(query5)}`
1117
+ path: `/api/platform/v1/audiences/grants${toQueryString({
1118
+ ...query5,
1119
+ audienceKey: query5.audienceKey,
1120
+ principalId: query5.principalId,
1121
+ groupId: query5.groupId,
1122
+ status: query5.status
1123
+ })}`
1392
1124
  }).then(
1393
1125
  (response) => mapGatewayData(
1394
1126
  response,
1395
- (data) => createListResult(Array.isArray(data) ? data : [], "keys")
1127
+ (data) => createListResult(Array.isArray(data) ? data : [], "grants")
1396
1128
  )
1397
1129
  );
1398
1130
  },
1399
1131
  /**
1400
- * Create an API key.
1132
+ * @deprecated Use listGrants.
1401
1133
  */
1402
- async createKey(input, idempotencyKey) {
1134
+ async getGrants(query5 = {}) {
1135
+ return this.listGrants(query5);
1136
+ },
1137
+ /**
1138
+ * Create an audience grant.
1139
+ */
1140
+ async createGrant(input, idempotencyKey) {
1403
1141
  return gateway.request({
1404
- path: "/api/platform/v1/identity/keys",
1142
+ path: "/api/platform/v1/audiences/grants",
1405
1143
  method: "POST",
1406
1144
  body: input,
1407
1145
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1408
1146
  });
1409
1147
  },
1410
1148
  /**
1411
- * Rotate an API key.
1149
+ * @deprecated Use createGrant.
1412
1150
  */
1413
- async rotateKey(keyId, input = {}, idempotencyKey) {
1414
- return gateway.request({
1415
- path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/rotate`,
1416
- method: "POST",
1417
- body: input,
1418
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1419
- });
1151
+ async grant(input, idempotencyKey) {
1152
+ return this.createGrant(input, idempotencyKey);
1420
1153
  },
1421
1154
  /**
1422
- * Delete an API key by revoking it.
1423
- */
1424
- deleteKey,
1425
- /**
1426
- * @deprecated Use deleteKey.
1427
- */
1428
- revokeKey: deleteKey,
1429
- /**
1430
- * Search Clerk users by email or display attributes.
1155
+ * Delete an audience grant by revoking it.
1431
1156
  */
1432
- async searchClerkUsers(q) {
1433
- return gateway.request({
1434
- path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
1435
- });
1436
- },
1437
- async getTenantConfig(input) {
1438
- return gateway.request({
1439
- path: `/api/platform/v1/identity/tenant-config${toQueryString(
1440
- tenantIdentityQuery(input)
1441
- )}`
1442
- });
1443
- },
1444
- async updateTenantConfig(input, idempotencyKey) {
1445
- cleanRequiredString(input.tenantId, "tenantId");
1446
- return gateway.request({
1447
- path: "/api/platform/v1/identity/tenant-config",
1448
- method: "PATCH",
1449
- body: tenantIdentityBody(
1450
- input,
1451
- "identity.updateTenantConfig"
1452
- ),
1453
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1454
- });
1455
- },
1456
- async listIntegrations(input) {
1457
- return gateway.request({
1458
- path: `/api/platform/v1/identity/integrations${toQueryString(
1459
- tenantIdentityQuery(input)
1460
- )}`
1461
- }).then(
1462
- (response) => mapGatewayData(
1463
- response,
1464
- (data) => listResultFromEnvelope(
1465
- data,
1466
- "integrations"
1467
- )
1468
- )
1469
- );
1470
- },
1471
- async upsertIntegration(input, idempotencyKey) {
1472
- cleanRequiredString(input.tenantId, "tenantId");
1473
- cleanRequiredString(input.integrationKey, "integrationKey");
1157
+ async deleteGrant(input, idempotencyKey) {
1474
1158
  return gateway.request({
1475
- path: "/api/platform/v1/identity/integrations",
1476
- method: "PUT",
1477
- body: tenantIdentityBody(
1478
- input,
1479
- "identity.upsertIntegration"
1480
- ),
1481
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1482
- });
1483
- },
1484
- async listSecrets(input) {
1485
- return gateway.request({
1486
- path: `/api/platform/v1/identity/secrets${toQueryString(
1487
- tenantIdentityQuery(input)
1488
- )}`
1489
- }).then(
1490
- (response) => mapGatewayData(
1491
- response,
1492
- (data) => listResultFromEnvelope(
1493
- data,
1494
- "secrets"
1495
- )
1496
- )
1497
- );
1498
- },
1499
- async putSecretReference(input, idempotencyKey) {
1500
- cleanRequiredString(input.tenantId, "tenantId");
1501
- cleanRequiredString(input.secretRef, "secretRef");
1502
- return gateway.request({
1503
- path: "/api/platform/v1/identity/secrets",
1504
- method: "PUT",
1505
- body: tenantIdentityBody(
1506
- input,
1507
- "identity.putSecretReference"
1508
- ),
1509
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1510
- });
1511
- },
1512
- async evaluatePolicy(input, idempotencyKey) {
1513
- cleanRequiredString(input.tenantId, "tenantId");
1514
- cleanRequiredString(input.policySubject, "policySubject");
1515
- cleanRequiredString(input.policyAction, "policyAction");
1516
- cleanRequiredString(input.policyResource, "policyResource");
1517
- return gateway.request({
1518
- path: "/api/platform/v1/identity/policy/evaluate",
1159
+ path: "/api/platform/v1/audiences/grants/revoke",
1519
1160
  method: "POST",
1520
- body: tenantIdentityBody(
1521
- input,
1522
- "identity.evaluatePolicy"
1523
- ),
1161
+ body: input,
1524
1162
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1525
1163
  });
1526
1164
  },
1527
- async recordPolicyDecision(input, idempotencyKey) {
1528
- cleanRequiredString(input.tenantId, "tenantId");
1529
- cleanRequiredString(input.decision, "decision");
1530
- return gateway.request({
1531
- path: "/api/platform/v1/identity/policy/decisions",
1532
- method: "POST",
1533
- body: tenantIdentityBody(
1534
- input,
1535
- "identity.recordPolicyDecision"
1536
- ),
1537
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1538
- });
1539
- }
1540
- };
1541
- }
1542
-
1543
- // src/accessControl.ts
1544
- var LucernAccessControlError = class extends LucernSdkAuthContextError {
1545
- policyDecision;
1546
- constructor(reason, message, policyDecision) {
1547
- super(reason, message);
1548
- this.name = "LucernAccessControlError";
1549
- this.policyDecision = policyDecision;
1550
- }
1551
- };
1552
- function cleanString4(value) {
1553
- const normalized = value?.trim();
1554
- return normalized ? normalized : void 0;
1555
- }
1556
- function cleanStringList2(values) {
1557
- if (!values) {
1558
- return [];
1559
- }
1560
- return [
1561
- ...new Set(
1562
- values.map((value) => value.trim()).filter((value) => value.length > 0)
1563
- )
1564
- ];
1565
- }
1566
- function requireString2(value, reason, label) {
1567
- const normalized = cleanString4(value);
1568
- if (!normalized) {
1569
- throw new LucernAccessControlError(
1570
- reason,
1571
- `Lucern SDK access control requires ${label}.`
1572
- );
1573
- }
1574
- return normalized;
1575
- }
1576
- function normalizePrincipalType(principalType2) {
1577
- if (principalType2 === "agent") {
1578
- return "agent";
1579
- }
1580
- if (principalType2 === "service") {
1581
- return "service";
1582
- }
1583
- if (principalType2 === "group") {
1584
- return "group";
1585
- }
1586
- if (principalType2 === "external_viewer") {
1587
- return "external_viewer";
1588
- }
1589
- return "human";
1590
- }
1591
- function aliasKey(alias) {
1592
- return `${alias.provider}:${alias.providerProjectId ?? ""}:${alias.externalSubjectId}`;
1593
- }
1594
- function normalizeAliases(input, canonicalClerkUserId) {
1595
- const aliases = /* @__PURE__ */ new Map();
1596
- for (const alias of input ?? []) {
1597
- const externalSubjectId = cleanString4(alias.externalSubjectId);
1598
- if (!externalSubjectId) {
1599
- continue;
1600
- }
1601
- const normalized = {
1602
- provider: cleanString4(alias.provider) ?? "clerk",
1603
- providerProjectId: cleanString4(alias.providerProjectId),
1604
- externalSubjectId,
1605
- status: cleanString4(alias.status)
1606
- };
1607
- aliases.set(aliasKey(normalized), normalized);
1608
- }
1609
- if (canonicalClerkUserId) {
1610
- const canonicalAlias = {
1611
- provider: "clerk",
1612
- externalSubjectId: canonicalClerkUserId,
1613
- status: "active"
1614
- };
1615
- aliases.set(aliasKey(canonicalAlias), canonicalAlias);
1616
- }
1617
- return [...aliases.values()];
1618
- }
1619
- function isKnownClerkSubject(args) {
1620
- if (args.clerkId === args.canonicalClerkUserId) {
1621
- return true;
1622
- }
1623
- return args.aliases.some(
1624
- (alias) => alias.provider === "clerk" && alias.externalSubjectId === args.clerkId
1625
- );
1626
- }
1627
- function authContextToPrincipalInput(input) {
1628
- const normalized = normalizeCanonicalLucernAuthContext(input);
1629
- return {
1630
- principalId: normalized.principalId,
1631
- principalType: normalized.principalType,
1632
- canonicalClerkUserId: normalized.clerkId,
1633
- clerkId: normalized.clerkId,
1634
- tenantId: normalized.tenantId,
1635
- workspaceId: normalized.workspaceId,
1636
- roles: normalized.roles,
1637
- scopes: normalized.scopes
1638
- };
1639
- }
1640
- function isAuthContextInput(input) {
1641
- return "authMode" in input || "permit" in input || "delegationChain" in input;
1642
- }
1643
- function normalizeCanonicalPrincipalIdentity(input, options = {}) {
1644
- const principalInput = isAuthContextInput(input) ? authContextToPrincipalInput(input) : input;
1645
- const principalId = requireString2(
1646
- principalInput.principalId,
1647
- "principal_missing",
1648
- "principalId"
1649
- );
1650
- const principalType2 = normalizePrincipalType(principalInput.principalType);
1651
- const observedClerkId = cleanString4(options.observedClerkId);
1652
- const canonicalClerkUserId = cleanString4(principalInput.canonicalClerkUserId) ?? cleanString4(principalInput.clerkId);
1653
- if (principalType2 === "human" && !canonicalClerkUserId) {
1654
- throw new LucernAccessControlError(
1655
- "clerk_alias_missing",
1656
- "Human principals require one canonical Clerk user id."
1657
- );
1658
- }
1659
- const aliases = normalizeAliases(
1660
- principalInput.clerkIdentityAliases,
1661
- canonicalClerkUserId
1662
- );
1663
- if (observedClerkId && !isKnownClerkSubject({
1664
- clerkId: observedClerkId,
1665
- canonicalClerkUserId,
1666
- aliases
1667
- })) {
1668
- throw new LucernAccessControlError(
1669
- "clerk_alias_unrecognized",
1670
- "Observed Clerk user id does not match the canonical human principal id."
1671
- );
1672
- }
1673
- return {
1674
- principalId,
1675
- principalType: principalType2,
1676
- canonicalClerkUserId,
1677
- clerkIdentityAliases: aliases,
1678
- tenantId: cleanString4(principalInput.tenantId),
1679
- workspaceId: cleanString4(principalInput.workspaceId),
1680
- roles: cleanStringList2(principalInput.roles),
1681
- scopes: cleanStringList2(principalInput.scopes)
1682
- };
1683
- }
1684
- function formatPermitResource(resource) {
1685
- if (typeof resource === "string") {
1686
- return requireString2(resource, "policy_denied", "policyResource");
1687
- }
1688
- const type = requireString2(resource.type, "policy_denied", "resource.type");
1689
- const key = requireString2(resource.key, "policy_denied", "resource.key");
1690
- return key.startsWith(`${type}:`) ? key : `${type}:${key}`;
1691
- }
1692
- function resourceRequiresWorkspace(resource) {
1693
- if (typeof resource === "string") {
1694
- return !resource.startsWith("tenant:");
1695
- }
1696
- return resource.type !== "tenant";
1697
- }
1698
- function buildPolicyInput(identity, input) {
1699
- const tenantId = requireString2(
1700
- input.tenantId ?? identity.tenantId,
1701
- "tenant_missing",
1702
- "tenantId"
1703
- );
1704
- const workspaceId = cleanString4(input.workspaceId ?? identity.workspaceId);
1705
- if (resourceRequiresWorkspace(input.resource) && !workspaceId) {
1706
- throw new LucernAccessControlError(
1707
- "workspace_missing",
1708
- "Workspace-scoped Permit checks require workspaceId."
1709
- );
1710
- }
1711
- return {
1712
- tenantId,
1713
- workspaceId,
1714
- principalId: identity.principalId,
1715
- policySubject: identity.principalId,
1716
- policyAction: requireString2(input.action, "policy_denied", "policyAction"),
1717
- policyResource: formatPermitResource(input.resource),
1718
- metadata: input.context
1719
- };
1720
- }
1721
- async function resolveConfiguredPrincipalInput(authContext) {
1722
- if (typeof authContext === "function") {
1723
- return await authContext();
1724
- }
1725
- return authContext;
1726
- }
1727
- function assertPermitAllowed(decision) {
1728
- if (decision.decision !== "allow") {
1729
- throw new LucernAccessControlError(
1730
- decision.decision === "deny" ? "policy_denied" : "policy_unknown",
1731
- `Permit denied ${decision.policyAction} on ${decision.policyResource}.`,
1732
- decision
1733
- );
1734
- }
1735
- }
1736
- function createAccessControlClient(config = {}) {
1737
- const identityClient = createIdentityClient(config);
1738
- async function resolveIdentity(input, observedClerkId) {
1739
- const identityInput = input ?? await resolveConfiguredPrincipalInput(config.authContext);
1740
- if (!identityInput) {
1741
- throw new LucernAccessControlError(
1742
- "principal_missing",
1743
- "Lucern SDK access control requires a canonical principal identity."
1744
- );
1745
- }
1746
- return normalizeCanonicalPrincipalIdentity(identityInput, {
1747
- observedClerkId
1748
- });
1749
- }
1750
- async function checkAccess(input, idempotencyKey) {
1751
- const identity = await resolveIdentity(input.identity, input.observedClerkId);
1752
- const policyInput = buildPolicyInput(identity, input);
1753
- try {
1754
- const response = await identityClient.evaluatePolicy(
1755
- policyInput,
1756
- idempotencyKey
1757
- );
1758
- return {
1759
- identity,
1760
- policyInput,
1761
- decision: response.data
1762
- };
1763
- } catch (error) {
1764
- if (error instanceof LucernSdkAuthContextError) {
1765
- throw error;
1766
- }
1767
- throw new LucernAccessControlError(
1768
- "policy_unavailable",
1769
- "Permit policy check failed closed before an allow decision was returned."
1770
- );
1771
- }
1772
- }
1773
- async function requireAccess(input, idempotencyKey) {
1774
- const result = await checkAccess(input, idempotencyKey);
1775
- assertPermitAllowed(result.decision);
1776
- return result;
1777
- }
1778
- async function canAccess(input, idempotencyKey) {
1779
- try {
1780
- await requireAccess(input, idempotencyKey);
1781
- return true;
1782
- } catch {
1783
- return false;
1784
- }
1785
- }
1786
- return {
1787
- normalizePrincipal: normalizeCanonicalPrincipalIdentity,
1788
- checkAccess,
1789
- requireAccess,
1790
- canAccess
1791
- };
1792
- }
1793
-
1794
- // src/answersClient.ts
1795
- function createAnswersClient(config = {}) {
1796
- const gateway = createGatewayRequestClient(config);
1797
- return {
1798
- /**
1799
- * Get the current answer for a question.
1800
- * @param questionId - The question node identifier.
1801
- * @returns The answer record for the given question.
1802
- */
1803
- async get(questionId) {
1804
- return gateway.request({
1805
- path: `/api/platform/v1/questions/${encodeURIComponent(questionId)}/answer`
1806
- });
1807
- }
1808
- };
1809
- }
1810
-
1811
- // src/audiencesClient.ts
1812
- function createAudiencesClient(config = {}) {
1813
- const gateway = createGatewayRequestClient(config);
1814
- const listRegistry = async (query5 = {}) => {
1815
- return gateway.request({
1816
- path: `/api/platform/v1/audiences/registry${toQueryString({
1817
- ...query5,
1818
- effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1819
- status: query5.status
1820
- })}`
1821
- }).then(
1822
- (response) => mapGatewayData(
1823
- response,
1824
- (data) => createListResult(Array.isArray(data) ? data : [], "registryEntries")
1825
- )
1826
- );
1827
- };
1828
- const createRegistryEntry = async (input, idempotencyKey) => {
1829
- return gateway.request({
1830
- path: "/api/platform/v1/audiences/registry",
1831
- method: "POST",
1832
- body: input,
1833
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1834
- });
1835
- };
1836
- const updateRegistryEntry = createRegistryEntry;
1837
- const upsertRegistry = createRegistryEntry;
1838
- const getRegistry = listRegistry;
1839
- const listGrants = async (query5 = {}) => {
1840
- return gateway.request({
1841
- path: `/api/platform/v1/audiences/grants${toQueryString({
1842
- ...query5,
1843
- audienceKey: query5.audienceKey,
1844
- principalId: query5.principalId,
1845
- groupId: query5.groupId,
1846
- status: query5.status
1847
- })}`
1848
- }).then(
1849
- (response) => mapGatewayData(
1850
- response,
1851
- (data) => createListResult(Array.isArray(data) ? data : [], "grants")
1852
- )
1853
- );
1854
- };
1855
- const createGrant = async (input, idempotencyKey) => {
1856
- return gateway.request({
1857
- path: "/api/platform/v1/audiences/grants",
1858
- method: "POST",
1859
- body: input,
1860
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1861
- });
1862
- };
1863
- const getGrants = listGrants;
1864
- const grant = createGrant;
1865
- const deleteGrant = async (input, idempotencyKey) => {
1866
- return gateway.request({
1867
- path: "/api/platform/v1/audiences/grants/revoke",
1868
- method: "POST",
1869
- body: input,
1870
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1871
- });
1872
- };
1873
- const revokeGrant = deleteGrant;
1874
- return {
1875
- /**
1876
- * List audience registry entries.
1877
- */
1878
- listRegistry,
1879
- /**
1880
- * @deprecated Use listRegistry.
1881
- */
1882
- getRegistry,
1883
- /**
1884
- * Create an audience registry entry.
1885
- */
1886
- createRegistryEntry,
1887
- /**
1888
- * Update an audience registry entry.
1889
- */
1890
- updateRegistryEntry,
1891
- /**
1892
- * @deprecated Use createRegistryEntry or updateRegistryEntry.
1893
- */
1894
- upsertRegistry,
1895
- /**
1896
- * List audience grants.
1897
- */
1898
- listGrants,
1899
- /**
1900
- * @deprecated Use listGrants.
1901
- */
1902
- getGrants,
1903
- /**
1904
- * Create an audience grant.
1905
- */
1906
- createGrant,
1907
- /**
1908
- * @deprecated Use createGrant.
1909
- */
1910
- grant,
1911
- /**
1912
- * Delete an audience grant by revoking it.
1913
- */
1914
- deleteGrant,
1915
1165
  /**
1916
1166
  * @deprecated Use deleteGrant.
1917
1167
  */
1918
- revokeGrant
1168
+ async revokeGrant(input, idempotencyKey) {
1169
+ return this.deleteGrant(input, idempotencyKey);
1170
+ }
1919
1171
  };
1920
1172
  }
1921
1173
 
@@ -1956,18 +1208,8 @@ function authBaseUrl(config) {
1956
1208
  return config.baseUrl?.replace(/\/+$/, "") ?? "";
1957
1209
  }
1958
1210
  async function readJson(response) {
1959
- try {
1960
- const payload = await response.json();
1961
- return isRecord4(payload) ? payload : {};
1962
- } catch (error) {
1963
- return unreadableJsonBodyFallback();
1964
- }
1965
- }
1966
- function unreadableJsonBodyFallback(_error) {
1967
- return {};
1968
- }
1969
- function isRecord4(value) {
1970
- return value !== null && typeof value === "object" && !Array.isArray(value);
1211
+ const payload = await response.json().catch(() => ({}));
1212
+ return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
1971
1213
  }
1972
1214
  function readString(value) {
1973
1215
  const normalized = typeof value === "string" ? value.trim() : "";
@@ -2009,10 +1251,7 @@ function assertDeviceTokenResponse(payload) {
2009
1251
  tenant_id: tenantId,
2010
1252
  workspace_id: readString(payload.workspace_id),
2011
1253
  principal_id: principalId,
2012
- user: isRecord4(payload.user) && typeof payload.user.id === "string" && typeof payload.user.principalId === "string" ? {
2013
- id: payload.user.id,
2014
- principalId: payload.user.principalId
2015
- } : void 0
1254
+ user: payload.user && typeof payload.user === "object" && !Array.isArray(payload.user) ? payload.user : void 0
2016
1255
  };
2017
1256
  }
2018
1257
  function maybeThrowDeviceError(payload) {
@@ -2160,12 +1399,12 @@ function createBeliefsClient(config = {}) {
2160
1399
  body: normalizeModulateConfidenceInput(input),
2161
1400
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2162
1401
  });
2163
- const getOpinionHistory = async (beliefId) => {
1402
+ async function getOpinionHistory(beliefId) {
2164
1403
  const response = await gateway.request({
2165
1404
  path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence-history`
2166
1405
  });
2167
1406
  return mapOpinionHistoryEntriesFromGatewayData(response.data);
2168
- };
1407
+ }
2169
1408
  return {
2170
1409
  /**
2171
1410
  * Create a belief within a topic scope.
@@ -2210,9 +1449,13 @@ function createBeliefsClient(config = {}) {
2210
1449
  * trigger = cause of the score change
2211
1450
  * triggeringRef = optional pointer to the evidence or worktree that drove the change
2212
1451
  */
2213
- getOpinionHistory,
1452
+ async getOpinionHistory(beliefId) {
1453
+ return getOpinionHistory(beliefId);
1454
+ },
2214
1455
  /** @deprecated Use getOpinionHistory(). */
2215
- getConfidenceHistory: getOpinionHistory,
1456
+ async getConfidenceHistory(beliefId) {
1457
+ return getOpinionHistory(beliefId);
1458
+ },
2216
1459
  /**
2217
1460
  * Fork a scored belief into a new formulation.
2218
1461
  */
@@ -2355,6 +1598,57 @@ function createEvidenceClient(config = {}) {
2355
1598
  };
2356
1599
  }
2357
1600
 
1601
+ // src/boundaryClientSurface.ts
1602
+ function cleanOptionalString(value) {
1603
+ const normalized = value?.trim();
1604
+ return normalized ? normalized : void 0;
1605
+ }
1606
+ function cleanRequiredString(value, label) {
1607
+ const normalized = cleanOptionalString(value);
1608
+ if (!normalized) {
1609
+ throw new Error(`${label} is required`);
1610
+ }
1611
+ return normalized;
1612
+ }
1613
+ function readTopicId(input) {
1614
+ return cleanOptionalString(input.topicId) ?? cleanOptionalString(input.projectId);
1615
+ }
1616
+ function requireTopicId(input) {
1617
+ const topicId = readTopicId(input);
1618
+ if (!topicId) {
1619
+ throw new Error("topicId is required");
1620
+ }
1621
+ return topicId;
1622
+ }
1623
+ function assertKnownKeys(input, allowed, operation) {
1624
+ const allowedSet = new Set(allowed);
1625
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
1626
+ if (unknownKeys.length > 0) {
1627
+ throw new Error(
1628
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
1629
+ );
1630
+ }
1631
+ }
1632
+ function knownPayload(input, allowed, operation) {
1633
+ assertKnownKeys(input, allowed, operation);
1634
+ return { ...input };
1635
+ }
1636
+ function topicPayload(input, allowed, operation) {
1637
+ assertKnownKeys(input, allowed, operation);
1638
+ return {
1639
+ ...input,
1640
+ topicId: requireTopicId(input),
1641
+ projectId: void 0
1642
+ };
1643
+ }
1644
+ function listResultFromEnvelope(data, legacyKey) {
1645
+ const record = data && typeof data === "object" ? data : {};
1646
+ return createListResult(
1647
+ Array.isArray(record[legacyKey]) ? record[legacyKey] : Array.isArray(data) ? data : [],
1648
+ legacyKey
1649
+ );
1650
+ }
1651
+
2358
1652
  // src/eventingClient.ts
2359
1653
  var EVENTING_FIELDS = [
2360
1654
  "tenantId",
@@ -2722,391 +2016,693 @@ async function invokeRegisteredCustomTool(fullName, params, context) {
2722
2016
  // src/ontologyClient.ts
2723
2017
  function createOntologyClient(config = {}) {
2724
2018
  const gateway = createGatewayRequestClient(config);
2725
- const client = {
2019
+ return {
2020
+ /**
2021
+ * List ontology definitions matching optional filters.
2022
+ */
2023
+ async list(filters = {}) {
2024
+ return gateway.request({
2025
+ path: `/api/platform/v1/ontologies${toQueryString(filters)}`
2026
+ }).then(
2027
+ (response) => mapGatewayData(response, (data) => {
2028
+ const record = data && typeof data === "object" && !Array.isArray(data) ? data : {};
2029
+ const ontologies = Array.isArray(record.ontologies) ? record.ontologies : Array.isArray(record.definitions) ? record.definitions : Array.isArray(data) ? data : [];
2030
+ const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : ontologies.length;
2031
+ return {
2032
+ ...record,
2033
+ ...createListResult(ontologies, "definitions"),
2034
+ ontologies,
2035
+ total
2036
+ };
2037
+ })
2038
+ );
2039
+ },
2040
+ /**
2041
+ * Get an ontology definition by identifier.
2042
+ */
2043
+ async get(id) {
2044
+ return gateway.request({
2045
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2046
+ });
2047
+ },
2048
+ /**
2049
+ * Bind an ontology definition to a topic.
2050
+ */
2051
+ async bind(input, idempotencyKey) {
2052
+ return gateway.request({
2053
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
2054
+ method: "POST",
2055
+ body: {
2056
+ topicId: input.topicId
2057
+ },
2058
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2059
+ });
2060
+ },
2061
+ /**
2062
+ * List ontology definitions.
2063
+ */
2064
+ async listDefinitions(filters = {}) {
2065
+ return this.list(filters);
2066
+ },
2067
+ /**
2068
+ * Get an ontology definition.
2069
+ */
2070
+ async getDefinition(id) {
2071
+ return this.get(id);
2072
+ },
2073
+ /**
2074
+ * Create an ontology definition.
2075
+ */
2076
+ async createDefinition(input, idempotencyKey) {
2077
+ return gateway.request({
2078
+ path: "/api/platform/v1/ontologies",
2079
+ method: "POST",
2080
+ body: input,
2081
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2082
+ });
2083
+ },
2084
+ /**
2085
+ * Update an ontology definition.
2086
+ */
2087
+ async updateDefinition(id, input, idempotencyKey) {
2088
+ return gateway.request({
2089
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
2090
+ method: "PATCH",
2091
+ body: input,
2092
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2093
+ });
2094
+ },
2095
+ /**
2096
+ * Archive an ontology definition.
2097
+ */
2098
+ async archiveDefinition(id, idempotencyKey) {
2099
+ return gateway.request({
2100
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
2101
+ method: "DELETE",
2102
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2103
+ });
2104
+ },
2105
+ /**
2106
+ * List versions for an ontology definition.
2107
+ */
2108
+ async listVersions(ontologyId, filters = {}) {
2109
+ return gateway.request({
2110
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions${toQueryString(filters)}`
2111
+ }).then(
2112
+ (response) => mapGatewayData(
2113
+ response,
2114
+ (data) => createListResult(Array.isArray(data) ? data : [], "versions")
2115
+ )
2116
+ );
2117
+ },
2118
+ /**
2119
+ * Create an ontology version.
2120
+ */
2121
+ async createVersion(ontologyId, input, idempotencyKey) {
2122
+ return gateway.request({
2123
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions`,
2124
+ method: "POST",
2125
+ body: input,
2126
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2127
+ });
2128
+ },
2129
+ /**
2130
+ * Publish an ontology version.
2131
+ */
2132
+ async publishVersion(ontologyId, versionId, idempotencyKey) {
2133
+ return gateway.request({
2134
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/publish`,
2135
+ method: "POST",
2136
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2137
+ });
2138
+ },
2139
+ /**
2140
+ * Deprecate an ontology version.
2141
+ */
2142
+ async deprecateVersion(ontologyId, versionId, idempotencyKey) {
2143
+ return gateway.request({
2144
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/deprecate`,
2145
+ method: "POST",
2146
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2147
+ });
2148
+ },
2149
+ /**
2150
+ * List topics directly bound to a specific ontology definition.
2151
+ * Uses the topics gateway with ontologyId filter.
2152
+ */
2153
+ async listTopics(ontologyId) {
2154
+ return gateway.request({
2155
+ path: `/api/platform/v1/topics?ontologyId=${encodeURIComponent(ontologyId)}`
2156
+ }).then(
2157
+ (response) => mapGatewayData(
2158
+ response,
2159
+ (data) => createListResult(Array.isArray(data) ? data : [], "topics")
2160
+ )
2161
+ );
2162
+ },
2163
+ /**
2164
+ * @deprecated Use listTopics.
2165
+ */
2166
+ async listTopicsByOntology(ontologyId) {
2167
+ return this.listTopics(ontologyId);
2168
+ }
2169
+ };
2170
+ }
2171
+
2172
+ // src/graphClient.ts
2173
+ function createGraphClient(config = {}) {
2174
+ const gateway = createGatewayRequestClient(config);
2175
+ return {
2176
+ /**
2177
+ * List graph nodes matching the provided filters.
2178
+ */
2179
+ async listNodes(query5) {
2180
+ return gateway.request({
2181
+ path: `/api/platform/v1/graph/nodes${toQueryString(
2182
+ normalizeTopicQuery(query5)
2183
+ )}`
2184
+ }).then(
2185
+ (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
2186
+ );
2187
+ },
2188
+ /**
2189
+ * @deprecated Use listNodes.
2190
+ */
2191
+ async queryNodes(query5) {
2192
+ return this.listNodes(query5);
2193
+ },
2194
+ /**
2195
+ * Retrieve a single graph node by nodeId or globalId.
2196
+ */
2197
+ async getNode(query5) {
2198
+ return gateway.request({
2199
+ path: `/api/platform/v1/graph/nodes${toQueryString(query5)}`
2200
+ }).then(
2201
+ (response) => mapGatewayData(
2202
+ response,
2203
+ (data) => withSdkAliases(data)
2204
+ )
2205
+ );
2206
+ },
2207
+ /**
2208
+ * Create a graph node.
2209
+ */
2210
+ async createNode(input, idempotencyKey) {
2211
+ return gateway.request({
2212
+ path: "/api/platform/v1/graph/nodes",
2213
+ method: "POST",
2214
+ body: normalizeNodeWriteInput(input),
2215
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2216
+ }).then(
2217
+ (response) => mapGatewayData(
2218
+ response,
2219
+ (data) => withSdkAliases(data)
2220
+ )
2221
+ );
2222
+ },
2223
+ /**
2224
+ * Update a graph node.
2225
+ */
2226
+ async updateNode(input, idempotencyKey) {
2227
+ return gateway.request({
2228
+ path: "/api/platform/v1/graph/nodes",
2229
+ method: "PUT",
2230
+ body: normalizeNodeWriteInput(input),
2231
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2232
+ }).then(
2233
+ (response) => mapGatewayData(
2234
+ response,
2235
+ (data) => withSdkAliases(data)
2236
+ )
2237
+ );
2238
+ },
2239
+ /**
2240
+ * Batch create graph nodes through the admin route surface.
2241
+ */
2242
+ async batchCreateNodes(input, idempotencyKey) {
2243
+ return gateway.request({
2244
+ path: "/api/platform/v1/graph/nodes/batch",
2245
+ method: "POST",
2246
+ body: {
2247
+ nodes: input.nodes.map((node) => normalizeNodeWriteInput(node))
2248
+ },
2249
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2250
+ });
2251
+ },
2252
+ /**
2253
+ * Supersede an existing graph node with a new canonical version.
2254
+ */
2255
+ async supersedeNode(input, idempotencyKey) {
2256
+ return gateway.request({
2257
+ path: "/api/platform/v1/graph/nodes/supersede",
2258
+ method: "POST",
2259
+ body: input,
2260
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2261
+ });
2262
+ },
2263
+ /**
2264
+ * Update a node's verification status.
2265
+ */
2266
+ async verifyNode(input, idempotencyKey) {
2267
+ const verificationStatus = normalizeNodeVerificationStatus(input.verificationStatus) ?? input.verificationStatus;
2268
+ return gateway.request({
2269
+ path: "/api/platform/v1/graph/nodes/verify",
2270
+ method: "POST",
2271
+ body: {
2272
+ ...input,
2273
+ verificationStatus
2274
+ },
2275
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2276
+ });
2277
+ },
2278
+ /**
2279
+ * Permanently delete a node via the admin-only hard-delete route.
2280
+ */
2281
+ async hardDeleteNode(input, idempotencyKey) {
2282
+ return gateway.request({
2283
+ path: "/api/platform/v1/graph/nodes/hard-delete",
2284
+ method: "POST",
2285
+ body: input,
2286
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2287
+ });
2288
+ },
2726
2289
  /**
2727
- * List ontology definitions matching optional filters.
2290
+ * List graph edges matching the provided filters.
2728
2291
  */
2729
- async list(filters = {}) {
2292
+ async listEdges(query5) {
2730
2293
  return gateway.request({
2731
- path: `/api/platform/v1/ontologies${toQueryString(filters)}`
2294
+ path: `/api/platform/v1/graph/edges${toQueryString(
2295
+ normalizeTopicQuery(query5)
2296
+ )}`
2732
2297
  }).then(
2733
- (response) => mapGatewayData(response, (data) => {
2734
- const record = asRecord(data);
2735
- const ontologies = asListItems(data, "ontologies");
2736
- const definitions = ontologies.length > 0 ? ontologies : asListItems(data, "definitions");
2737
- const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : definitions.length;
2738
- return {
2739
- ...record,
2740
- ...createListResult(definitions, "definitions"),
2741
- ontologies: definitions,
2742
- total
2743
- };
2744
- })
2298
+ (response) => mapGatewayData(
2299
+ response,
2300
+ (data) => mapAliasedList(data, "edges")
2301
+ )
2745
2302
  );
2746
2303
  },
2747
2304
  /**
2748
- * Get an ontology definition by identifier.
2305
+ * @deprecated Use listEdges.
2749
2306
  */
2750
- async get(id) {
2751
- return gateway.request({
2752
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2753
- });
2307
+ async queryEdges(query5) {
2308
+ return this.listEdges(query5);
2754
2309
  },
2755
2310
  /**
2756
- * Bind an ontology definition to a topic.
2311
+ * Create a graph edge.
2757
2312
  */
2758
- async bind(input, idempotencyKey) {
2313
+ async createEdge(input, idempotencyKey) {
2759
2314
  return gateway.request({
2760
- path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
2315
+ path: "/api/platform/v1/graph/edges",
2761
2316
  method: "POST",
2762
- body: {
2763
- topicId: input.topicId
2764
- },
2317
+ body: normalizeTopicQuery(input),
2765
2318
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2766
2319
  });
2767
2320
  },
2768
2321
  /**
2769
- * Create an ontology definition.
2322
+ * Delete one or more edges matching the provided filter.
2770
2323
  */
2771
- async createDefinition(input, idempotencyKey) {
2324
+ async deleteEdge(query5, idempotencyKey) {
2772
2325
  return gateway.request({
2773
- path: "/api/platform/v1/ontologies",
2774
- method: "POST",
2775
- body: input,
2326
+ path: `/api/platform/v1/graph/edges${toQueryString(query5)}`,
2327
+ method: "DELETE",
2776
2328
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2777
2329
  });
2778
2330
  },
2779
2331
  /**
2780
- * Update an ontology definition.
2332
+ * Retrieve a graph neighborhood around a root node.
2781
2333
  */
2782
- async updateDefinition(id, input, idempotencyKey) {
2334
+ async neighborhood(query5) {
2783
2335
  return gateway.request({
2784
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
2785
- method: "PATCH",
2786
- body: input,
2787
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2336
+ path: `/api/platform/v1/graph/neighborhood${toQueryString(query5)}`
2788
2337
  });
2789
2338
  },
2790
2339
  /**
2791
- * Archive an ontology definition.
2340
+ * Traverse the graph from a starting node.
2792
2341
  */
2793
- async archiveDefinition(id, idempotencyKey) {
2342
+ async traverse(query5) {
2794
2343
  return gateway.request({
2795
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
2796
- method: "DELETE",
2797
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2344
+ path: "/api/platform/v1/graph/traverse",
2345
+ method: "POST",
2346
+ body: normalizeTopicQuery(query5)
2798
2347
  });
2799
2348
  },
2800
2349
  /**
2801
- * List versions for an ontology definition.
2350
+ * Analyze graph structure for a topic.
2802
2351
  */
2803
- async listVersions(ontologyId, filters = {}) {
2352
+ async analyze(query5 = {}) {
2353
+ const normalized = normalizeTopicQuery(query5);
2804
2354
  return gateway.request({
2805
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions${toQueryString(filters)}`
2806
- }).then(
2807
- (response) => mapGatewayData(
2808
- response,
2809
- (data) => createListResult(asListItems(data, "versions"), "versions")
2810
- )
2811
- );
2355
+ path: `/api/platform/v1/graph/analyze${toQueryString({
2356
+ topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
2357
+ metric: typeof normalized.metric === "string" ? normalized.metric : void 0,
2358
+ limit: typeof normalized.limit === "number" ? normalized.limit : void 0
2359
+ })}`
2360
+ });
2812
2361
  },
2813
2362
  /**
2814
- * Create an ontology version.
2363
+ * Detect confirmation-bias patterns for a topic graph.
2815
2364
  */
2816
- async createVersion(ontologyId, input, idempotencyKey) {
2365
+ async bias(query5 = {}) {
2366
+ const normalized = normalizeTopicQuery(query5);
2817
2367
  return gateway.request({
2818
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions`,
2819
- method: "POST",
2820
- body: input,
2821
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2368
+ path: `/api/platform/v1/graph/bias${toQueryString({
2369
+ topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
2370
+ threshold: typeof normalized.threshold === "number" ? normalized.threshold : void 0,
2371
+ limit: typeof normalized.limit === "number" ? normalized.limit : void 0
2372
+ })}`
2822
2373
  });
2823
2374
  },
2824
2375
  /**
2825
- * Publish an ontology version.
2376
+ * Find graph gaps for beliefs that still need testing.
2826
2377
  */
2827
- async publishVersion(ontologyId, versionId, idempotencyKey) {
2378
+ async gaps(query5) {
2379
+ const normalized = normalizeTopicQuery(query5);
2828
2380
  return gateway.request({
2829
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/publish`,
2830
- method: "POST",
2831
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2381
+ path: `/api/platform/v1/graph/gaps${toQueryString({
2382
+ topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
2383
+ minConfidence: typeof normalized.minConfidence === "number" ? normalized.minConfidence : void 0
2384
+ })}`
2832
2385
  });
2833
2386
  },
2834
2387
  /**
2835
- * Deprecate an ontology version.
2388
+ * Search across graph resources within a topic.
2836
2389
  */
2837
- async deprecateVersion(ontologyId, versionId, idempotencyKey) {
2390
+ async search(query5) {
2838
2391
  return gateway.request({
2839
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/deprecate`,
2392
+ path: "/api/platform/v1/search",
2840
2393
  method: "POST",
2841
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2394
+ body: normalizeTopicQuery(query5)
2842
2395
  });
2843
2396
  },
2844
2397
  /**
2845
- * List topics directly bound to a specific ontology definition.
2846
- * Uses the topics gateway with ontologyId filter.
2398
+ * Retrieve a graph neighborhood around a root node.
2847
2399
  */
2848
- async listTopics(ontologyId) {
2400
+ async getNeighborhood(query5) {
2401
+ return this.neighborhood(query5);
2402
+ },
2403
+ /**
2404
+ * Retrieve the shortest known path between two graph nodes.
2405
+ */
2406
+ async getPath(query5) {
2849
2407
  return gateway.request({
2850
- path: `/api/platform/v1/topics?ontologyId=${encodeURIComponent(ontologyId)}`
2851
- }).then(
2852
- (response) => mapGatewayData(
2853
- response,
2854
- (data) => createListResult(Array.isArray(data) ? data : [], "topics")
2855
- )
2856
- );
2408
+ path: `/api/platform/v1/graph/path${toQueryString(query5)}`
2409
+ });
2410
+ },
2411
+ /**
2412
+ * Retrieve graph analytics for the requested metric.
2413
+ */
2414
+ async getAnalytics(query5 = {}) {
2415
+ return gateway.request({
2416
+ path: `/api/platform/v1/graph/analytics${toQueryString(query5)}`
2417
+ });
2857
2418
  }
2858
2419
  };
2859
- return Object.assign(client, {
2860
- listDefinitions: client.list,
2861
- getDefinition: client.get,
2862
- listTopicsByOntology: client.listTopics
2863
- });
2864
2420
  }
2865
2421
 
2866
- // src/graphClient.ts
2867
- function createGraphClient(config = {}) {
2422
+ // src/identityClient.ts
2423
+ function createIdentityWhoamiClient(config = {}) {
2868
2424
  const gateway = createGatewayRequestClient(config);
2869
- const client = {
2425
+ return {
2426
+ async whoami() {
2427
+ return gateway.request({
2428
+ path: "/api/platform/v1/identity/whoami"
2429
+ });
2430
+ }
2431
+ };
2432
+ }
2433
+ var TENANT_IDENTITY_FIELDS = [
2434
+ "tenantId",
2435
+ "workspaceId",
2436
+ "principalId",
2437
+ "integrationKey",
2438
+ "secretRef",
2439
+ "policySubject",
2440
+ "policyAction",
2441
+ "policyResource",
2442
+ "decision",
2443
+ "config",
2444
+ "configKey",
2445
+ "configValue",
2446
+ "provider",
2447
+ "status",
2448
+ "metadata",
2449
+ "limit",
2450
+ "cursor"
2451
+ ];
2452
+ function tenantIdentityQuery(input) {
2453
+ return {
2454
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
2455
+ workspaceId: input.workspaceId,
2456
+ principalId: input.principalId,
2457
+ limit: input.limit,
2458
+ cursor: input.cursor
2459
+ };
2460
+ }
2461
+ function tenantIdentityBody(input, operation) {
2462
+ return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
2463
+ }
2464
+ function createIdentityClient(config = {}) {
2465
+ const gateway = createGatewayRequestClient(config);
2466
+ const whoamiClient = createIdentityWhoamiClient(config);
2467
+ const requestPrincipalWrite = (method, input, idempotencyKey) => gateway.request({
2468
+ path: "/api/platform/v1/identity/principals",
2469
+ method,
2470
+ body: input,
2471
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2472
+ });
2473
+ return {
2870
2474
  /**
2871
- * List graph nodes matching the provided filters.
2475
+ * Resolve the current authenticated identity summary.
2872
2476
  */
2873
- async listNodes(query5) {
2874
- return gateway.request({
2875
- path: `/api/platform/v1/graph/nodes${toQueryString(
2876
- normalizeTopicQuery(query5)
2877
- )}`
2878
- }).then(
2879
- (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
2477
+ async whoami() {
2478
+ return whoamiClient.whoami().then(
2479
+ (response) => mapGatewayData(response, (data) => ({
2480
+ principalId: data.principalId,
2481
+ principalType: data.principalType,
2482
+ tenantId: data.tenantId ?? null,
2483
+ workspaceId: data.workspaceId ?? null,
2484
+ scopes: Array.isArray(data.scopes) ? data.scopes : [],
2485
+ roles: Array.isArray(data.roles) ? data.roles : [],
2486
+ isPlatformAdmin: data.isPlatformAdmin === true,
2487
+ isTenantAdmin: data.isTenantAdmin === true,
2488
+ isWorkspaceAdmin: data.isWorkspaceAdmin === true,
2489
+ authMode: data.authMode,
2490
+ sessionId: data.sessionId,
2491
+ delegatedBy: data.delegatedBy,
2492
+ expiresAt: data.expiresAt
2493
+ }))
2880
2494
  );
2881
2495
  },
2882
2496
  /**
2883
- * Retrieve a single graph node by nodeId or globalId.
2497
+ * List principals in the current identity scope.
2884
2498
  */
2885
- async getNode(query5) {
2499
+ async listPrincipals(query5 = {}) {
2886
2500
  return gateway.request({
2887
- path: `/api/platform/v1/graph/nodes${toQueryString(query5)}`
2501
+ path: `/api/platform/v1/identity/principals${toQueryString(query5)}`
2888
2502
  }).then(
2889
2503
  (response) => mapGatewayData(
2890
2504
  response,
2891
- (data) => withSdkAliases(data)
2505
+ (data) => createListResult(
2506
+ Array.isArray(data) ? data : [],
2507
+ "principals"
2508
+ )
2892
2509
  )
2893
2510
  );
2894
2511
  },
2895
2512
  /**
2896
- * Create a graph node.
2513
+ * Create a principal.
2897
2514
  */
2898
- async createNode(input, idempotencyKey) {
2899
- return gateway.request({
2900
- path: "/api/platform/v1/graph/nodes",
2901
- method: "POST",
2902
- body: normalizeNodeWriteInput(input),
2903
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2904
- }).then(
2905
- (response) => mapGatewayData(
2906
- response,
2907
- (data) => withSdkAliases(data)
2908
- )
2909
- );
2515
+ async createPrincipal(input, idempotencyKey) {
2516
+ return requestPrincipalWrite("POST", input, idempotencyKey);
2517
+ },
2518
+ /**
2519
+ * Update a principal.
2520
+ */
2521
+ async updatePrincipal(input, idempotencyKey) {
2522
+ return requestPrincipalWrite("PATCH", input, idempotencyKey);
2523
+ },
2524
+ /**
2525
+ * @deprecated Use createPrincipal or updatePrincipal.
2526
+ */
2527
+ async upsertPrincipal(input, idempotencyKey) {
2528
+ return requestPrincipalWrite("PATCH", input, idempotencyKey);
2910
2529
  },
2911
2530
  /**
2912
- * Update a graph node.
2531
+ * List keys in the current identity scope.
2913
2532
  */
2914
- async updateNode(input, idempotencyKey) {
2533
+ async listKeys(query5 = {}) {
2915
2534
  return gateway.request({
2916
- path: "/api/platform/v1/graph/nodes",
2917
- method: "PUT",
2918
- body: normalizeNodeWriteInput(input),
2919
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2535
+ path: `/api/platform/v1/identity/keys${toQueryString(query5)}`
2920
2536
  }).then(
2921
2537
  (response) => mapGatewayData(
2922
2538
  response,
2923
- (data) => withSdkAliases(data)
2539
+ (data) => createListResult(Array.isArray(data) ? data : [], "keys")
2924
2540
  )
2925
2541
  );
2926
2542
  },
2927
2543
  /**
2928
- * Batch create graph nodes through the admin route surface.
2929
- */
2930
- async batchCreateNodes(input, idempotencyKey) {
2931
- return gateway.request({
2932
- path: "/api/platform/v1/graph/nodes/batch",
2933
- method: "POST",
2934
- body: {
2935
- nodes: input.nodes.map((node) => normalizeNodeWriteInput(node))
2936
- },
2937
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2938
- });
2939
- },
2940
- /**
2941
- * Supersede an existing graph node with a new canonical version.
2544
+ * Create an API key.
2942
2545
  */
2943
- async supersedeNode(input, idempotencyKey) {
2546
+ async createKey(input, idempotencyKey) {
2944
2547
  return gateway.request({
2945
- path: "/api/platform/v1/graph/nodes/supersede",
2548
+ path: "/api/platform/v1/identity/keys",
2946
2549
  method: "POST",
2947
2550
  body: input,
2948
2551
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2949
2552
  });
2950
2553
  },
2951
2554
  /**
2952
- * Update a node's verification status.
2555
+ * Rotate an API key.
2953
2556
  */
2954
- async verifyNode(input, idempotencyKey) {
2955
- const verificationStatus = normalizeNodeVerificationStatus(input.verificationStatus) ?? input.verificationStatus;
2557
+ async rotateKey(keyId, input = {}, idempotencyKey) {
2956
2558
  return gateway.request({
2957
- path: "/api/platform/v1/graph/nodes/verify",
2559
+ path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/rotate`,
2958
2560
  method: "POST",
2959
- body: {
2960
- ...input,
2961
- verificationStatus
2962
- },
2561
+ body: input,
2963
2562
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2964
2563
  });
2965
2564
  },
2966
2565
  /**
2967
- * Permanently delete a node via the admin-only hard-delete route.
2566
+ * Delete an API key by revoking it.
2968
2567
  */
2969
- async hardDeleteNode(input, idempotencyKey) {
2568
+ async deleteKey(keyId, input = {}, idempotencyKey) {
2970
2569
  return gateway.request({
2971
- path: "/api/platform/v1/graph/nodes/hard-delete",
2570
+ path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
2972
2571
  method: "POST",
2973
2572
  body: input,
2974
2573
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2975
2574
  });
2976
2575
  },
2977
2576
  /**
2978
- * List graph edges matching the provided filters.
2577
+ * @deprecated Use deleteKey.
2979
2578
  */
2980
- async listEdges(query5) {
2981
- return gateway.request({
2982
- path: `/api/platform/v1/graph/edges${toQueryString(
2983
- normalizeTopicQuery(query5)
2984
- )}`
2985
- }).then(
2986
- (response) => mapGatewayData(
2987
- response,
2988
- (data) => mapAliasedList(data, "edges")
2989
- )
2990
- );
2579
+ async revokeKey(keyId, input = {}, idempotencyKey) {
2580
+ return this.deleteKey(keyId, input, idempotencyKey);
2991
2581
  },
2992
2582
  /**
2993
- * Create a graph edge.
2583
+ * Search Clerk users by email or display attributes.
2994
2584
  */
2995
- async createEdge(input, idempotencyKey) {
2585
+ async searchClerkUsers(q) {
2996
2586
  return gateway.request({
2997
- path: "/api/platform/v1/graph/edges",
2998
- method: "POST",
2999
- body: normalizeTopicQuery(input),
3000
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2587
+ path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
3001
2588
  });
3002
2589
  },
3003
- /**
3004
- * Delete one or more edges matching the provided filter.
3005
- */
3006
- async deleteEdge(query5, idempotencyKey) {
2590
+ async getTenantConfig(input) {
3007
2591
  return gateway.request({
3008
- path: `/api/platform/v1/graph/edges${toQueryString(query5)}`,
3009
- method: "DELETE",
3010
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2592
+ path: `/api/platform/v1/identity/tenant-config${toQueryString(
2593
+ tenantIdentityQuery(input)
2594
+ )}`
3011
2595
  });
3012
2596
  },
3013
- /**
3014
- * Retrieve a graph neighborhood around a root node.
3015
- */
3016
- async neighborhood(query5) {
2597
+ async updateTenantConfig(input, idempotencyKey) {
2598
+ cleanRequiredString(input.tenantId, "tenantId");
3017
2599
  return gateway.request({
3018
- path: `/api/platform/v1/graph/neighborhood${toQueryString(query5)}`
2600
+ path: "/api/platform/v1/identity/tenant-config",
2601
+ method: "PATCH",
2602
+ body: tenantIdentityBody(
2603
+ input,
2604
+ "identity.updateTenantConfig"
2605
+ ),
2606
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3019
2607
  });
3020
2608
  },
3021
- /**
3022
- * Traverse the graph from a starting node.
3023
- */
3024
- async traverse(query5) {
2609
+ async listIntegrations(input) {
3025
2610
  return gateway.request({
3026
- path: "/api/platform/v1/graph/traverse",
3027
- method: "POST",
3028
- body: normalizeTopicQuery(query5)
3029
- });
2611
+ path: `/api/platform/v1/identity/integrations${toQueryString(
2612
+ tenantIdentityQuery(input)
2613
+ )}`
2614
+ }).then(
2615
+ (response) => mapGatewayData(
2616
+ response,
2617
+ (data) => listResultFromEnvelope(
2618
+ data,
2619
+ "integrations"
2620
+ )
2621
+ )
2622
+ );
3030
2623
  },
3031
- /**
3032
- * Analyze graph structure for a topic.
3033
- */
3034
- async analyze(query5 = {}) {
3035
- const normalized = normalizeTopicQuery(query5);
2624
+ async upsertIntegration(input, idempotencyKey) {
2625
+ cleanRequiredString(input.tenantId, "tenantId");
2626
+ cleanRequiredString(input.integrationKey, "integrationKey");
3036
2627
  return gateway.request({
3037
- path: `/api/platform/v1/graph/analyze${toQueryString({
3038
- topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
3039
- metric: typeof normalized.metric === "string" ? normalized.metric : void 0,
3040
- limit: typeof normalized.limit === "number" ? normalized.limit : void 0
3041
- })}`
2628
+ path: "/api/platform/v1/identity/integrations",
2629
+ method: "PUT",
2630
+ body: tenantIdentityBody(
2631
+ input,
2632
+ "identity.upsertIntegration"
2633
+ ),
2634
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3042
2635
  });
3043
2636
  },
3044
- /**
3045
- * Detect confirmation-bias patterns for a topic graph.
3046
- */
3047
- async bias(query5 = {}) {
3048
- const normalized = normalizeTopicQuery(query5);
2637
+ async listSecrets(input) {
3049
2638
  return gateway.request({
3050
- path: `/api/platform/v1/graph/bias${toQueryString({
3051
- topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
3052
- threshold: typeof normalized.threshold === "number" ? normalized.threshold : void 0,
3053
- limit: typeof normalized.limit === "number" ? normalized.limit : void 0
3054
- })}`
3055
- });
2639
+ path: `/api/platform/v1/identity/secrets${toQueryString(
2640
+ tenantIdentityQuery(input)
2641
+ )}`
2642
+ }).then(
2643
+ (response) => mapGatewayData(
2644
+ response,
2645
+ (data) => listResultFromEnvelope(
2646
+ data,
2647
+ "secrets"
2648
+ )
2649
+ )
2650
+ );
3056
2651
  },
3057
- /**
3058
- * Find graph gaps for beliefs that still need testing.
3059
- */
3060
- async gaps(query5) {
3061
- const normalized = normalizeTopicQuery(query5);
2652
+ async putSecretReference(input, idempotencyKey) {
2653
+ cleanRequiredString(input.tenantId, "tenantId");
2654
+ cleanRequiredString(input.secretRef, "secretRef");
3062
2655
  return gateway.request({
3063
- path: `/api/platform/v1/graph/gaps${toQueryString({
3064
- topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
3065
- minConfidence: typeof normalized.minConfidence === "number" ? normalized.minConfidence : void 0
3066
- })}`
2656
+ path: "/api/platform/v1/identity/secrets",
2657
+ method: "PUT",
2658
+ body: tenantIdentityBody(
2659
+ input,
2660
+ "identity.putSecretReference"
2661
+ ),
2662
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3067
2663
  });
3068
2664
  },
3069
- /**
3070
- * Search across graph resources within a topic.
3071
- */
3072
- async search(query5) {
2665
+ async evaluatePolicy(input, idempotencyKey) {
2666
+ cleanRequiredString(input.tenantId, "tenantId");
2667
+ cleanRequiredString(input.policySubject, "policySubject");
2668
+ cleanRequiredString(input.policyAction, "policyAction");
2669
+ cleanRequiredString(input.policyResource, "policyResource");
3073
2670
  return gateway.request({
3074
- path: "/api/platform/v1/search",
2671
+ path: "/api/platform/v1/identity/policy/evaluate",
3075
2672
  method: "POST",
3076
- body: normalizeTopicQuery(query5)
3077
- });
3078
- },
3079
- /**
3080
- * Retrieve the shortest known path between two graph nodes.
3081
- */
3082
- async getPath(query5) {
3083
- return gateway.request({
3084
- path: `/api/platform/v1/graph/path${toQueryString(query5)}`
2673
+ body: tenantIdentityBody(
2674
+ input,
2675
+ "identity.evaluatePolicy"
2676
+ ),
2677
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3085
2678
  });
3086
2679
  },
3087
- /**
3088
- * Retrieve graph analytics for the requested metric.
3089
- */
3090
- async getAnalytics(query5 = {}) {
2680
+ async recordPolicyDecision(input, idempotencyKey) {
2681
+ cleanRequiredString(input.tenantId, "tenantId");
2682
+ cleanRequiredString(input.decision, "decision");
3091
2683
  return gateway.request({
3092
- path: `/api/platform/v1/graph/analytics${toQueryString(query5)}`
2684
+ path: "/api/platform/v1/identity/policy/decisions",
2685
+ method: "POST",
2686
+ body: tenantIdentityBody(
2687
+ input,
2688
+ "identity.recordPolicyDecision"
2689
+ ),
2690
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3093
2691
  });
3094
2692
  }
3095
2693
  };
3096
- return Object.assign(client, {
3097
- queryNodes: client.listNodes,
3098
- queryEdges: client.listEdges,
3099
- getNeighborhood: client.neighborhood
3100
- });
3101
2694
  }
3102
2695
 
3103
2696
  // src/topicsClient.ts
3104
- function cleanString5(value) {
2697
+ function asRecord3(value) {
2698
+ return value && typeof value === "object" ? value : {};
2699
+ }
2700
+ function cleanString3(value) {
3105
2701
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
3106
2702
  }
3107
2703
  function normalizeTopicRecord(value) {
3108
- const record = asRecord(value);
3109
- const topicId = cleanString5(record.topicId) ?? cleanString5(record.id) ?? cleanString5(record._id);
2704
+ const record = asRecord3(value);
2705
+ const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
3110
2706
  return withTopicAlias({
3111
2707
  ...record,
3112
2708
  ...topicId ? { topicId } : {}
@@ -3130,7 +2726,7 @@ function createTopicsClient(config = {}) {
3130
2726
  })}`
3131
2727
  }).then(
3132
2728
  (response) => mapGatewayData(response, (data) => {
3133
- const record = asRecord(data);
2729
+ const record = asRecord3(data);
3134
2730
  const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
3135
2731
  return {
3136
2732
  ...createListResult(items, "topics"),
@@ -3147,7 +2743,7 @@ function createTopicsClient(config = {}) {
3147
2743
  }).then(
3148
2744
  (response) => mapGatewayData(
3149
2745
  response,
3150
- (data) => normalizeTopicRecord(asRecord(data).topic ?? data)
2746
+ (data) => normalizeTopicRecord(asRecord3(data).topic ?? data)
3151
2747
  )
3152
2748
  );
3153
2749
  },
@@ -3183,7 +2779,7 @@ function createTopicsClient(config = {}) {
3183
2779
  )}`
3184
2780
  }).then(
3185
2781
  (response) => mapGatewayData(response, (data) => {
3186
- const record = asRecord(data);
2782
+ const record = asRecord3(data);
3187
2783
  return {
3188
2784
  tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
3189
2785
  };
@@ -3602,7 +3198,7 @@ function createEventsFacade(config = {}) {
3602
3198
  function createGraphFacade(config = {}) {
3603
3199
  const graphClient = createGraphClient(config);
3604
3200
  const gateway = createGatewayRequestClient(config);
3605
- const graphFacade = {
3201
+ return {
3606
3202
  async neighborhood(input) {
3607
3203
  return graphClient.neighborhood({
3608
3204
  globalId: input.globalId,
@@ -3610,6 +3206,18 @@ function createGraphFacade(config = {}) {
3610
3206
  maxDepth: input.maxDepth
3611
3207
  });
3612
3208
  },
3209
+ async traverse(input) {
3210
+ return graphClient.traverse(input);
3211
+ },
3212
+ async analyze(input = {}) {
3213
+ return graphClient.analyze(input);
3214
+ },
3215
+ async bias(input = {}) {
3216
+ return graphClient.bias(input);
3217
+ },
3218
+ async gaps(input) {
3219
+ return graphClient.gaps(input);
3220
+ },
3613
3221
  async falsify(input, idempotencyKey = randomIdempotencyKey()) {
3614
3222
  return gateway.request({
3615
3223
  path: "/api/platform/v1/graph/falsify",
@@ -3619,12 +3227,6 @@ function createGraphFacade(config = {}) {
3619
3227
  });
3620
3228
  }
3621
3229
  };
3622
- return Object.assign(graphFacade, {
3623
- traverse: graphClient.traverse,
3624
- analyze: graphClient.analyze,
3625
- bias: graphClient.bias,
3626
- gaps: graphClient.gaps
3627
- });
3628
3230
  }
3629
3231
  function createIdentityFacade(config = {}) {
3630
3232
  const identityClient = createIdentityClient(config);
@@ -3638,12 +3240,15 @@ function createIdentityFacade(config = {}) {
3638
3240
  function createOntologiesFacade(config = {}) {
3639
3241
  const ontologyClient = createOntologyClient(config);
3640
3242
  const gateway = createGatewayRequestClient(config);
3641
- const ontologyFacade = {
3243
+ return {
3642
3244
  async get(id) {
3643
3245
  return gateway.request({
3644
3246
  path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
3645
3247
  });
3646
3248
  },
3249
+ async list(query5 = {}) {
3250
+ return ontologyClient.list(query5);
3251
+ },
3647
3252
  async bind(input, idempotencyKey) {
3648
3253
  return gateway.request({
3649
3254
  path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
@@ -3663,9 +3268,6 @@ function createOntologiesFacade(config = {}) {
3663
3268
  });
3664
3269
  }
3665
3270
  };
3666
- return Object.assign(ontologyFacade, {
3667
- list: ontologyClient.list
3668
- });
3669
3271
  }
3670
3272
  function createQuestionsFacade(config = {}) {
3671
3273
  const gateway = createGatewayRequestClient(config);
@@ -3825,8 +3427,6 @@ function createTasksFacade(config = {}) {
3825
3427
  description: input.description,
3826
3428
  priority: input.priority,
3827
3429
  status: input.status,
3828
- assigneeId: input.assigneeId,
3829
- blockedReason: input.blockedReason,
3830
3430
  linkedBeliefId: input.linkedBeliefId,
3831
3431
  linkedQuestionId: input.linkedQuestionId,
3832
3432
  linkedWorktreeId: input.linkedWorktreeId,
@@ -3860,9 +3460,15 @@ function createTasksFacade(config = {}) {
3860
3460
  function createTopicsFacade(config = {}) {
3861
3461
  const topicsClient = createTopicsClient(config);
3862
3462
  return {
3863
- create: topicsClient.create,
3864
- get: topicsClient.get,
3865
- list: topicsClient.list,
3463
+ async create(input, idempotencyKey) {
3464
+ return topicsClient.create(input, idempotencyKey);
3465
+ },
3466
+ async get(id) {
3467
+ return topicsClient.get(id);
3468
+ },
3469
+ async list(query5 = {}) {
3470
+ return topicsClient.list(query5);
3471
+ },
3866
3472
  async update(input, idempotencyKey) {
3867
3473
  const { id, ...rest } = input;
3868
3474
  return topicsClient.update(id, rest, idempotencyKey);
@@ -3878,8 +3484,12 @@ function createTopicsFacade(config = {}) {
3878
3484
  maxDepth: input.maxDepth
3879
3485
  });
3880
3486
  },
3881
- remove: topicsClient.remove,
3882
- bulkCreate: topicsClient.bulkCreate
3487
+ async remove(id, idempotencyKey = randomIdempotencyKey()) {
3488
+ return topicsClient.remove(id, idempotencyKey);
3489
+ },
3490
+ async bulkCreate(input, idempotencyKey = randomIdempotencyKey()) {
3491
+ return topicsClient.bulkCreate(input, idempotencyKey);
3492
+ }
3883
3493
  };
3884
3494
  }
3885
3495
  function createWebhooksFacade(config = {}) {
@@ -4079,7 +3689,7 @@ function createWorktreesFacade(config = {}) {
4079
3689
  // src/decisionsClient.ts
4080
3690
  function createDecisionsClient(config = {}) {
4081
3691
  const gateway = createGatewayRequestClient(config);
4082
- const client = {
3692
+ return {
4083
3693
  /**
4084
3694
  * List judgments for a topic scope.
4085
3695
  */
@@ -4157,6 +3767,12 @@ function createDecisionsClient(config = {}) {
4157
3767
  })
4158
3768
  );
4159
3769
  },
3770
+ /**
3771
+ * @deprecated Use listPendingOutcomeReviews.
3772
+ */
3773
+ async listPendingJudgmentOutcomeReview(query5) {
3774
+ return this.listPendingOutcomeReviews(query5);
3775
+ },
4160
3776
  /**
4161
3777
  * Get audit integrity checks for judgment transitions.
4162
3778
  */
@@ -4189,6 +3805,12 @@ function createDecisionsClient(config = {}) {
4189
3805
  )
4190
3806
  );
4191
3807
  },
3808
+ /**
3809
+ * @deprecated Use createJudgment.
3810
+ */
3811
+ async recordJudgment(input, idempotencyKey) {
3812
+ return this.createJudgment(input, idempotencyKey);
3813
+ },
4192
3814
  /**
4193
3815
  * Update the outcome for an existing judgment.
4194
3816
  */
@@ -4199,13 +3821,14 @@ function createDecisionsClient(config = {}) {
4199
3821
  body: input,
4200
3822
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4201
3823
  });
3824
+ },
3825
+ /**
3826
+ * @deprecated Use updateJudgmentOutcome.
3827
+ */
3828
+ async recordJudgmentOutcome(judgmentId, input, idempotencyKey) {
3829
+ return this.updateJudgmentOutcome(judgmentId, input, idempotencyKey);
4202
3830
  }
4203
3831
  };
4204
- return Object.assign(client, {
4205
- listPendingJudgmentOutcomeReview: client.listPendingOutcomeReviews,
4206
- recordJudgment: client.createJudgment,
4207
- recordJudgmentOutcome: client.updateJudgmentOutcome
4208
- });
4209
3832
  }
4210
3833
 
4211
3834
  // src/embeddingsClient.ts
@@ -4321,7 +3944,7 @@ function createEmbeddingsClient(config = {}) {
4321
3944
  }
4322
3945
 
4323
3946
  // src/contextClient.ts
4324
- function cleanString6(value) {
3947
+ function cleanString4(value) {
4325
3948
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
4326
3949
  }
4327
3950
  function cleanNumber(value) {
@@ -4330,55 +3953,50 @@ function cleanNumber(value) {
4330
3953
  function cleanBoolean(value) {
4331
3954
  return typeof value === "boolean" ? value : void 0;
4332
3955
  }
4333
- function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
4334
- const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
4335
- const payload = {};
4336
- const topicId = typeof topicIdOrInput === "string" ? cleanString6(topicIdOrInput) : cleanString6(effectiveInput.topicId);
4337
- if (topicId) {
4338
- payload.topicId = topicId;
4339
- }
4340
- const query5 = cleanString6(effectiveInput.query);
3956
+ function buildCompileContextRequest(topicId, input = {}) {
3957
+ const payload = { topicId };
3958
+ const query5 = cleanString4(input.query);
4341
3959
  if (query5) {
4342
3960
  payload.query = query5;
4343
3961
  }
4344
- const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
3962
+ const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
4345
3963
  if (budget !== void 0) {
4346
3964
  payload.budget = budget;
4347
3965
  }
4348
- const ranking = cleanString6(effectiveInput.ranking) ?? cleanString6(effectiveInput.rankingProfile);
3966
+ const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
4349
3967
  if (ranking) {
4350
3968
  payload.ranking = ranking;
4351
3969
  }
4352
- const limit = cleanNumber(effectiveInput.limit);
3970
+ const limit = cleanNumber(input.limit);
4353
3971
  if (limit !== void 0) {
4354
3972
  payload.limit = limit;
4355
3973
  }
4356
- const maxDepth = cleanNumber(effectiveInput.maxDepth);
3974
+ const maxDepth = cleanNumber(input.maxDepth);
4357
3975
  if (maxDepth !== void 0) {
4358
3976
  payload.maxDepth = maxDepth;
4359
3977
  }
4360
- const includeEntities = cleanBoolean(effectiveInput.includeEntities);
3978
+ const includeEntities = cleanBoolean(input.includeEntities);
4361
3979
  if (includeEntities !== void 0) {
4362
3980
  payload.includeEntities = includeEntities;
4363
3981
  }
4364
- const mode = cleanString6(effectiveInput.mode);
3982
+ const mode = cleanString4(input.mode);
4365
3983
  if (mode) {
4366
3984
  payload.mode = mode;
4367
3985
  }
4368
- const includeFailures = cleanBoolean(effectiveInput.includeFailures);
3986
+ const includeFailures = cleanBoolean(input.includeFailures);
4369
3987
  if (includeFailures !== void 0) {
4370
3988
  payload.includeFailures = includeFailures;
4371
3989
  }
4372
- const worktreeId = cleanString6(effectiveInput.worktreeId);
3990
+ const worktreeId = cleanString4(input.worktreeId);
4373
3991
  if (worktreeId) {
4374
3992
  payload.worktreeId = worktreeId;
4375
3993
  }
4376
- const sessionId = cleanString6(effectiveInput.sessionId);
3994
+ const sessionId = cleanString4(input.sessionId);
4377
3995
  if (sessionId) {
4378
3996
  payload.sessionId = sessionId;
4379
3997
  }
4380
- if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
4381
- payload.packWeightOverrides = effectiveInput.packWeightOverrides;
3998
+ if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
3999
+ payload.packWeightOverrides = input.packWeightOverrides;
4382
4000
  }
4383
4001
  return {
4384
4002
  path: "/api/platform/v1/context/compile",
@@ -4390,20 +4008,13 @@ function createContextClient(config = {}) {
4390
4008
  const gateway = createGatewayRequestClient(config);
4391
4009
  return {
4392
4010
  /**
4393
- * Compile a focused reasoning context pack.
4394
- * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
4011
+ * Compile a focused reasoning context pack for a topic scope.
4012
+ * @param topicId - The topic to compile context for.
4395
4013
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
4396
4014
  * @returns The compiled context payload with beliefs, questions, and evidence.
4397
4015
  */
4398
- async compile(topicIdOrInput = {}, input = {}) {
4399
- const request = buildCompileContextRequest(topicIdOrInput, input);
4400
- return gateway.request({
4401
- ...request,
4402
- body: request.body
4403
- });
4404
- },
4405
- async compileByQuery(input = {}) {
4406
- const request = buildCompileContextRequest(input);
4016
+ async compile(topicId, input = {}) {
4017
+ const request = buildCompileContextRequest(topicId, input);
4407
4018
  return gateway.request({
4408
4019
  ...request,
4409
4020
  body: request.body
@@ -4508,33 +4119,9 @@ function graphAnalysisQuery(input) {
4508
4119
  cursor: input.cursor
4509
4120
  };
4510
4121
  }
4511
- function normalizeRunQueryPayload(input) {
4512
- return {
4513
- ...input,
4514
- topicId: requireTopicId2(input),
4515
- projectId: void 0
4516
- };
4517
- }
4518
4122
  function createGraphAnalysisClient(config = {}) {
4519
4123
  const gateway = createGatewayRequestClient(config);
4520
4124
  return {
4521
- listGraphIntelligenceQueries(input = {}) {
4522
- return gateway.request({
4523
- path: "/api/platform/v1/graph-intelligence/queries",
4524
- method: "POST",
4525
- body: {
4526
- categoryId: input.categoryId,
4527
- mode: input.mode
4528
- }
4529
- });
4530
- },
4531
- runGraphIntelligenceQuery(input) {
4532
- return gateway.request({
4533
- path: "/api/platform/v1/graph-intelligence/run",
4534
- method: "POST",
4535
- body: normalizeRunQueryPayload(input)
4536
- });
4537
- },
4538
4125
  saveAnalysis(input, idempotencyKey) {
4539
4126
  return gateway.request({
4540
4127
  path: "/api/platform/v1/graph-analysis/analyses",
@@ -4616,9 +4203,7 @@ function createGraphAnalysisClient(config = {}) {
4616
4203
  topicId: requireTopicId2(input),
4617
4204
  workspaceId: input.workspaceId,
4618
4205
  analysisId: input.analysisId,
4619
- minimumCreatedAt: input.minimumCreatedAt ?? input.since ?? input.createdAt ?? input.analysisCreatedAt,
4620
- sourceNodeIds: input.sourceNodeIds?.join(",") ?? (input.nodeId ? input.nodeId : void 0),
4621
- sourceEdgeIds: input.sourceEdgeIds?.join(",") ?? (input.edgeId ? input.edgeId : void 0),
4206
+ since: input.since,
4622
4207
  limit: input.limit,
4623
4208
  cursor: input.cursor
4624
4209
  })}`
@@ -4841,7 +4426,7 @@ function createGraphStateClassifierClient(config = {}) {
4841
4426
  // src/harnessClient.ts
4842
4427
  function createHarnessClient(config = {}) {
4843
4428
  const gateway = createGatewayRequestClient(config);
4844
- const client = {
4429
+ return {
4845
4430
  /**
4846
4431
  * List agent definitions.
4847
4432
  */
@@ -4874,6 +4459,12 @@ function createHarnessClient(config = {}) {
4874
4459
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4875
4460
  });
4876
4461
  },
4462
+ /**
4463
+ * @deprecated Use createAgentDefinition.
4464
+ */
4465
+ async registerAgentDefinition(input, idempotencyKey) {
4466
+ return this.createAgentDefinition(input, idempotencyKey);
4467
+ },
4877
4468
  /**
4878
4469
  * Update an agent definition.
4879
4470
  */
@@ -4912,6 +4503,12 @@ function createHarnessClient(config = {}) {
4912
4503
  )
4913
4504
  );
4914
4505
  },
4506
+ /**
4507
+ * @deprecated Use listAgentRuns.
4508
+ */
4509
+ async listRunsForAgent(agentId, scope = {}) {
4510
+ return this.listAgentRuns(agentId, scope);
4511
+ },
4915
4512
  /**
4916
4513
  * List tool definitions.
4917
4514
  */
@@ -4944,6 +4541,12 @@ function createHarnessClient(config = {}) {
4944
4541
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4945
4542
  });
4946
4543
  },
4544
+ /**
4545
+ * @deprecated Use createToolDefinition.
4546
+ */
4547
+ async registerToolDefinition(input, idempotencyKey) {
4548
+ return this.createToolDefinition(input, idempotencyKey);
4549
+ },
4947
4550
  /**
4948
4551
  * Update a tool definition.
4949
4552
  */
@@ -4978,6 +4581,12 @@ function createHarnessClient(config = {}) {
4978
4581
  )
4979
4582
  );
4980
4583
  },
4584
+ /**
4585
+ * @deprecated Use listRunEntries.
4586
+ */
4587
+ async listRunLedgerEntries(scope = {}) {
4588
+ return this.listRunEntries(scope);
4589
+ },
4981
4590
  /**
4982
4591
  * Create a harness run.
4983
4592
  */
@@ -5052,12 +4661,6 @@ function createHarnessClient(config = {}) {
5052
4661
  });
5053
4662
  }
5054
4663
  };
5055
- return Object.assign(client, {
5056
- registerAgentDefinition: client.createAgentDefinition,
5057
- listRunsForAgent: client.listAgentRuns,
5058
- registerToolDefinition: client.createToolDefinition,
5059
- listRunLedgerEntries: client.listRunEntries
5060
- });
5061
4664
  }
5062
4665
 
5063
4666
  // src/jobsClient.ts
@@ -5185,41 +4788,45 @@ function createJobsClient(config = {}) {
5185
4788
  // src/learningClient.ts
5186
4789
  function createLearningClient(config = {}) {
5187
4790
  const gateway = createGatewayRequestClient(config);
5188
- const listRecentExecutions = async (args = {}) => gateway.request({
5189
- path: `/api/platform/v1/learning/executions/recent${toQueryString({
5190
- ...normalizeTopicQuery(args),
5191
- namespace: args.namespace,
5192
- audienceMode: args.audienceMode,
5193
- success: typeof args.success === "boolean" ? args.success ? "true" : "false" : void 0,
5194
- limit: typeof args.limit === "number" && Number.isFinite(args.limit) ? String(args.limit) : void 0
5195
- })}`
5196
- }).then(
5197
- (response) => mapGatewayData(
5198
- response,
5199
- (data) => createListResult(Array.isArray(data) ? data : [], "executions")
5200
- )
5201
- );
5202
- const getExecutionStats = async (args = {}) => gateway.request({
5203
- path: `/api/platform/v1/learning/executions/stats${toQueryString({
5204
- ...normalizeTopicQuery(args),
5205
- namespace: args.namespace,
5206
- audienceMode: args.audienceMode,
5207
- hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
5208
- })}`
5209
- });
5210
4791
  return {
5211
4792
  /**
5212
4793
  * List recent execution records.
5213
4794
  */
5214
- listRecentExecutions,
4795
+ async listRecentExecutions(args = {}) {
4796
+ return gateway.request({
4797
+ path: `/api/platform/v1/learning/executions/recent${toQueryString({
4798
+ ...normalizeTopicQuery(args),
4799
+ namespace: args.namespace,
4800
+ audienceMode: args.audienceMode,
4801
+ success: typeof args.success === "boolean" ? args.success ? "true" : "false" : void 0,
4802
+ limit: typeof args.limit === "number" && Number.isFinite(args.limit) ? String(args.limit) : void 0
4803
+ })}`
4804
+ }).then(
4805
+ (response) => mapGatewayData(
4806
+ response,
4807
+ (data) => createListResult(Array.isArray(data) ? data : [], "executions")
4808
+ )
4809
+ );
4810
+ },
5215
4811
  /**
5216
4812
  * @deprecated Use listRecentExecutions.
5217
4813
  */
5218
- getRecentExecutions: listRecentExecutions,
4814
+ async getRecentExecutions(args = {}) {
4815
+ return this.listRecentExecutions(args);
4816
+ },
5219
4817
  /**
5220
4818
  * Get aggregate execution statistics.
5221
4819
  */
5222
- getExecutionStats
4820
+ async getExecutionStats(args = {}) {
4821
+ return gateway.request({
4822
+ path: `/api/platform/v1/learning/executions/stats${toQueryString({
4823
+ ...normalizeTopicQuery(args),
4824
+ namespace: args.namespace,
4825
+ audienceMode: args.audienceMode,
4826
+ hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
4827
+ })}`
4828
+ });
4829
+ }
5223
4830
  };
5224
4831
  }
5225
4832
  function toJsonValue(value) {
@@ -5259,8 +4866,7 @@ function createMcpClient(config = {}) {
5259
4866
  transportKind: input.transportKind,
5260
4867
  sessionId: input.sessionId,
5261
4868
  agentIdentity: input.agentIdentity,
5262
- workspaceId: input.workspaceId,
5263
- worktreeId: input.worktreeId
4869
+ workspaceId: input.workspaceId
5264
4870
  };
5265
4871
  return gateway.request({
5266
4872
  path: `${MCP_GATEWAY_BOOTSTRAP_ENDPOINT}${toQueryString(scope)}`,
@@ -5351,12 +4957,8 @@ var CONTRACTS = {
5351
4957
  "apply_lens_to_topic": { method: "POST", path: "/lenses/apply", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5352
4958
  "apply_ontology": { method: "POST", path: "/ontologies/apply", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5353
4959
  "archive_belief": { method: "DELETE", path: "/beliefs", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5354
- "archive_epistemic_node": { method: "POST", path: "/nodes/archive", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5355
4960
  "archive_ontology": { method: "DELETE", path: "/ontologies", kind: "mutation", idempotent: true, surfaceIntent: "mcp_governance" },
5356
4961
  "archive_question": { method: "DELETE", path: "/questions", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5357
- "batch_create_edges": { method: "POST", path: "/edges/batch", kind: "mutation", idempotent: true, surfaceIntent: "mcp_analysis" },
5358
- "batch_create_epistemic_nodes": { method: "POST", path: "/nodes/batch", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5359
- "begin_build_session": { method: "POST", path: "/mcp/build-session/begin", kind: "mutation", idempotent: true, surfaceIntent: "system" },
5360
4962
  "bisect_confidence": { method: "POST", path: "/beliefs/confidence/bisect", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5361
4963
  "broadcast_message": { method: "POST", path: "/coordination/messages/broadcast", kind: "mutation", idempotent: true, surfaceIntent: "system" },
5362
4964
  "check_permission": { method: "POST", path: "/identity/check-permission", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
@@ -5367,7 +4969,6 @@ var CONTRACTS = {
5367
4969
  "create_belief": { method: "POST", path: "/beliefs", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5368
4970
  "create_edge": { method: "POST", path: "/edges", kind: "mutation", idempotent: true, surfaceIntent: "mcp_analysis" },
5369
4971
  "create_epistemic_contract": { method: "POST", path: "/contracts", kind: "mutation", idempotent: true, surfaceIntent: "mcp_governance" },
5370
- "create_epistemic_node": { method: "POST", path: "/nodes", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5371
4972
  "create_evidence": { method: "POST", path: "/evidence", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5372
4973
  "create_lens": { method: "POST", path: "/lenses", kind: "mutation", idempotent: true, surfaceIntent: "mcp_governance" },
5373
4974
  "create_ontology": { method: "POST", path: "/ontologies", kind: "mutation", idempotent: true, surfaceIntent: "mcp_governance" },
@@ -5395,7 +4996,6 @@ var CONTRACTS = {
5395
4996
  "get_code_context": { method: "POST", path: "/coding/context", kind: "query", idempotent: false, surfaceIntent: "system" },
5396
4997
  "get_confidence_history": { method: "POST", path: "/beliefs/confidence-history", kind: "query", idempotent: false, surfaceIntent: "compatibility" },
5397
4998
  "get_contract_status": { method: "POST", path: "/contracts/status", kind: "query", idempotent: false, surfaceIntent: "mcp_governance" },
5398
- "get_epistemic_node": { method: "GET", path: "/nodes/get", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5399
4999
  "get_evidence": { method: "GET", path: "/evidence/get", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5400
5000
  "get_failure_log": { method: "POST", path: "/coding/failure-log", kind: "query", idempotent: false, surfaceIntent: "system" },
5401
5001
  "get_falsification_questions": { method: "POST", path: "/questions/falsification", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
@@ -5409,7 +5009,6 @@ var CONTRACTS = {
5409
5009
  "get_question": { method: "GET", path: "/questions/get", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5410
5010
  "get_topic": { method: "GET", path: "/topics/get", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5411
5011
  "get_topic_coverage": { method: "POST", path: "/graph/topic-coverage", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
5412
- "get_topic_graph_spine": { method: "GET", path: "/topics/graph-spine", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5413
5012
  "get_topic_tree": { method: "GET", path: "/topics/tree", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5414
5013
  "heartbeat_session": { method: "POST", path: "/coordination/heartbeat-session", kind: "mutation", idempotent: true, surfaceIntent: "system" },
5415
5014
  "identity_whoami": { method: "GET", path: "/identity/whoami", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
@@ -5421,9 +5020,7 @@ var CONTRACTS = {
5421
5020
  "list_all_worktrees": { method: "GET", path: "/worktrees/all", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5422
5021
  "list_beliefs": { method: "GET", path: "/beliefs", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5423
5022
  "list_campaigns": { method: "GET", path: "/worktrees/campaigns", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5424
- "list_epistemic_nodes": { method: "GET", path: "/nodes", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5425
5023
  "list_evidence": { method: "GET", path: "/evidence", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5426
- "list_graph_intelligence_queries": { method: "POST", path: "/graph-intelligence/queries", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
5427
5024
  "list_lenses": { method: "GET", path: "/lenses", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5428
5025
  "list_ontologies": { method: "GET", path: "/ontologies", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5429
5026
  "list_questions": { method: "GET", path: "/questions", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
@@ -5432,7 +5029,6 @@ var CONTRACTS = {
5432
5029
  "list_worktrees": { method: "GET", path: "/worktrees", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5433
5030
  "manage_write_policy": { method: "POST", path: "/policy/write-policy/manage", kind: "mutation", idempotent: true, surfaceIntent: "mcp_governance" },
5434
5031
  "match_entity_type": { method: "POST", path: "/ontologies/match-entity-type", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5435
- "materialize_topic_graph": { method: "POST", path: "/topics/materialize-graph", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5436
5032
  "merge": { method: "POST", path: "/worktrees/merge", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5437
5033
  "modulate_confidence": { method: "POST", path: "/beliefs/confidence", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5438
5034
  "open_pull_request": { method: "POST", path: "/worktrees/open-pull-request", kind: "mutation", idempotent: true, surfaceIntent: "system" },
@@ -5446,29 +5042,21 @@ var CONTRACTS = {
5446
5042
  "refine_belief": { method: "PATCH", path: "/beliefs/refine", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5447
5043
  "refine_question": { method: "PATCH", path: "/questions/refine", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5448
5044
  "register_session": { method: "POST", path: "/coordination/register-session", kind: "mutation", idempotent: true, surfaceIntent: "system" },
5449
- "remove_edge": { method: "DELETE", path: "/edges", kind: "mutation", idempotent: true, surfaceIntent: "mcp_analysis" },
5450
- "remove_edges_between": { method: "DELETE", path: "/edges/between", kind: "mutation", idempotent: true, surfaceIntent: "mcp_analysis" },
5451
5045
  "remove_lens_from_topic": { method: "DELETE", path: "/lenses/apply", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5452
5046
  "resolve_effective_ontology": { method: "POST", path: "/ontologies/effective", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
5453
- "resolve_interactive_principal": { method: "POST", path: "/control-plane/identity/resolve-interactive-principal", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5454
- "run_graph_intelligence_query": { method: "POST", path: "/graph-intelligence/run", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
5455
5047
  "search_beliefs": { method: "POST", path: "/beliefs/search", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5456
5048
  "search_evidence": { method: "POST", path: "/evidence/search", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
5457
5049
  "seed_belief_lattice": { method: "POST", path: "/scope/belief-lattice/seed", kind: "mutation", idempotent: true, surfaceIntent: "system" },
5458
5050
  "send_agent_message": { method: "POST", path: "/coordination/messages/send", kind: "mutation", idempotent: true, surfaceIntent: "system" },
5459
- "supersede_epistemic_node": { method: "POST", path: "/nodes/supersede", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5460
5051
  "trace_entity_impact": { method: "POST", path: "/graph/trace-entity-impact", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
5461
5052
  "traverse_graph": { method: "POST", path: "/graph/traverse", kind: "query", idempotent: false, surfaceIntent: "mcp_analysis" },
5462
5053
  "trigger_belief_review": { method: "POST", path: "/context/belief-review", kind: "mutation", idempotent: true, surfaceIntent: "mcp_analysis" },
5463
- "update_edge": { method: "PATCH", path: "/edges", kind: "mutation", idempotent: true, surfaceIntent: "mcp_analysis" },
5464
- "update_epistemic_node": { method: "PATCH", path: "/nodes", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5465
5054
  "update_ontology": { method: "PATCH", path: "/ontologies", kind: "mutation", idempotent: true, surfaceIntent: "mcp_governance" },
5466
5055
  "update_question_status": { method: "PATCH", path: "/questions/status", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5467
5056
  "update_task": { method: "PATCH", path: "/tasks", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5468
5057
  "update_topic": { method: "PATCH", path: "/topics", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" },
5469
5058
  "update_worktree_metadata": { method: "PATCH", path: "/worktrees/metadata", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5470
- "update_worktree_targets": { method: "PATCH", path: "/worktrees/targets", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" },
5471
- "verify_epistemic_node": { method: "POST", path: "/nodes/verify", kind: "mutation", idempotent: true, surfaceIntent: "mcp_core" }
5059
+ "update_worktree_targets": { method: "PATCH", path: "/worktrees/targets", kind: "mutation", idempotent: true, surfaceIntent: "mcp_workflow" }
5472
5060
  };
5473
5061
  function createSessionId() {
5474
5062
  return typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : randomIdempotencyKey();
@@ -5536,24 +5124,12 @@ function createFunctionSurfaceClient(config = {}) {
5536
5124
  archiveBelief(input = {}, idempotencyKey) {
5537
5125
  return execute("archive_belief", input, idempotencyKey);
5538
5126
  },
5539
- archiveEpistemicNode(input = {}, idempotencyKey) {
5540
- return execute("archive_epistemic_node", input, idempotencyKey);
5541
- },
5542
5127
  archiveOntology(input = {}, idempotencyKey) {
5543
5128
  return execute("archive_ontology", input, idempotencyKey);
5544
5129
  },
5545
5130
  archiveQuestion(input = {}, idempotencyKey) {
5546
5131
  return execute("archive_question", input, idempotencyKey);
5547
5132
  },
5548
- batchCreateEdges(input = {}, idempotencyKey) {
5549
- return execute("batch_create_edges", input, idempotencyKey);
5550
- },
5551
- batchCreateEpistemicNodes(input = {}, idempotencyKey) {
5552
- return execute("batch_create_epistemic_nodes", input, idempotencyKey);
5553
- },
5554
- beginBuildSession(input = {}, idempotencyKey) {
5555
- return execute("begin_build_session", input, idempotencyKey);
5556
- },
5557
5133
  bisectConfidence(input = {}, idempotencyKey) {
5558
5134
  return execute("bisect_confidence", input, idempotencyKey);
5559
5135
  },
@@ -5584,9 +5160,6 @@ function createFunctionSurfaceClient(config = {}) {
5584
5160
  createEpistemicContract(input = {}, idempotencyKey) {
5585
5161
  return execute("create_epistemic_contract", input, idempotencyKey);
5586
5162
  },
5587
- createEpistemicNode(input = {}, idempotencyKey) {
5588
- return execute("create_epistemic_node", input, idempotencyKey);
5589
- },
5590
5163
  createEvidence(input = {}, idempotencyKey) {
5591
5164
  return execute("create_evidence", input, idempotencyKey);
5592
5165
  },
@@ -5668,9 +5241,6 @@ function createFunctionSurfaceClient(config = {}) {
5668
5241
  getContractStatus(input = {}, idempotencyKey) {
5669
5242
  return execute("get_contract_status", input, idempotencyKey);
5670
5243
  },
5671
- getEpistemicNode(input = {}, idempotencyKey) {
5672
- return execute("get_epistemic_node", input, idempotencyKey);
5673
- },
5674
5244
  getEvidence(input = {}, idempotencyKey) {
5675
5245
  return execute("get_evidence", input, idempotencyKey);
5676
5246
  },
@@ -5710,9 +5280,6 @@ function createFunctionSurfaceClient(config = {}) {
5710
5280
  getTopicCoverage(input = {}, idempotencyKey) {
5711
5281
  return execute("get_topic_coverage", input, idempotencyKey);
5712
5282
  },
5713
- getTopicGraphSpine(input = {}, idempotencyKey) {
5714
- return execute("get_topic_graph_spine", input, idempotencyKey);
5715
- },
5716
5283
  getTopicTree(input = {}, idempotencyKey) {
5717
5284
  return execute("get_topic_tree", input, idempotencyKey);
5718
5285
  },
@@ -5746,15 +5313,9 @@ function createFunctionSurfaceClient(config = {}) {
5746
5313
  listCampaigns(input = {}, idempotencyKey) {
5747
5314
  return execute("list_campaigns", input, idempotencyKey);
5748
5315
  },
5749
- listEpistemicNodes(input = {}, idempotencyKey) {
5750
- return execute("list_epistemic_nodes", input, idempotencyKey);
5751
- },
5752
5316
  listEvidence(input = {}, idempotencyKey) {
5753
5317
  return execute("list_evidence", input, idempotencyKey);
5754
5318
  },
5755
- listGraphIntelligenceQueries(input = {}, idempotencyKey) {
5756
- return execute("list_graph_intelligence_queries", input, idempotencyKey);
5757
- },
5758
5319
  listLenses(input = {}, idempotencyKey) {
5759
5320
  return execute("list_lenses", input, idempotencyKey);
5760
5321
  },
@@ -5779,9 +5340,6 @@ function createFunctionSurfaceClient(config = {}) {
5779
5340
  matchEntityType(input = {}, idempotencyKey) {
5780
5341
  return execute("match_entity_type", input, idempotencyKey);
5781
5342
  },
5782
- materializeTopicGraph(input = {}, idempotencyKey) {
5783
- return execute("materialize_topic_graph", input, idempotencyKey);
5784
- },
5785
5343
  merge(input = {}, idempotencyKey) {
5786
5344
  return execute("merge", input, idempotencyKey);
5787
5345
  },
@@ -5821,24 +5379,12 @@ function createFunctionSurfaceClient(config = {}) {
5821
5379
  registerSession(input = {}, idempotencyKey) {
5822
5380
  return execute("register_session", input, idempotencyKey);
5823
5381
  },
5824
- removeEdge(input = {}, idempotencyKey) {
5825
- return execute("remove_edge", input, idempotencyKey);
5826
- },
5827
- removeEdgesBetween(input = {}, idempotencyKey) {
5828
- return execute("remove_edges_between", input, idempotencyKey);
5829
- },
5830
5382
  removeLensFromTopic(input = {}, idempotencyKey) {
5831
5383
  return execute("remove_lens_from_topic", input, idempotencyKey);
5832
5384
  },
5833
5385
  resolveEffectiveOntology(input = {}, idempotencyKey) {
5834
5386
  return execute("resolve_effective_ontology", input, idempotencyKey);
5835
5387
  },
5836
- resolveInteractivePrincipal(input = {}, idempotencyKey) {
5837
- return execute("resolve_interactive_principal", input, idempotencyKey);
5838
- },
5839
- runGraphIntelligenceQuery(input = {}, idempotencyKey) {
5840
- return execute("run_graph_intelligence_query", input, idempotencyKey);
5841
- },
5842
5388
  searchBeliefs(input = {}, idempotencyKey) {
5843
5389
  return execute("search_beliefs", input, idempotencyKey);
5844
5390
  },
@@ -5851,9 +5397,6 @@ function createFunctionSurfaceClient(config = {}) {
5851
5397
  sendAgentMessage(input = {}, idempotencyKey) {
5852
5398
  return execute("send_agent_message", input, idempotencyKey);
5853
5399
  },
5854
- supersedeEpistemicNode(input = {}, idempotencyKey) {
5855
- return execute("supersede_epistemic_node", input, idempotencyKey);
5856
- },
5857
5400
  traceEntityImpact(input = {}, idempotencyKey) {
5858
5401
  return execute("trace_entity_impact", input, idempotencyKey);
5859
5402
  },
@@ -5863,12 +5406,6 @@ function createFunctionSurfaceClient(config = {}) {
5863
5406
  triggerBeliefReview(input = {}, idempotencyKey) {
5864
5407
  return execute("trigger_belief_review", input, idempotencyKey);
5865
5408
  },
5866
- updateEdge(input = {}, idempotencyKey) {
5867
- return execute("update_edge", input, idempotencyKey);
5868
- },
5869
- updateEpistemicNode(input = {}, idempotencyKey) {
5870
- return execute("update_epistemic_node", input, idempotencyKey);
5871
- },
5872
5409
  updateOntology(input = {}, idempotencyKey) {
5873
5410
  return execute("update_ontology", input, idempotencyKey);
5874
5411
  },
@@ -5886,9 +5423,6 @@ function createFunctionSurfaceClient(config = {}) {
5886
5423
  },
5887
5424
  updateWorktreeTargets(input = {}, idempotencyKey) {
5888
5425
  return execute("update_worktree_targets", input, idempotencyKey);
5889
- },
5890
- verifyEpistemicNode(input = {}, idempotencyKey) {
5891
- return execute("verify_epistemic_node", input, idempotencyKey);
5892
5426
  }
5893
5427
  };
5894
5428
  }
@@ -6096,7 +5630,7 @@ var ORG_GRAPH_SEARCH_FIELDS = [
6096
5630
  "cursor",
6097
5631
  "provenanceScope"
6098
5632
  ];
6099
- function cleanString7(value, label) {
5633
+ function cleanString5(value, label) {
6100
5634
  const normalized = value?.trim();
6101
5635
  if (!normalized) {
6102
5636
  throw new Error(`${label} is required`);
@@ -6118,9 +5652,9 @@ function searchBody(input) {
6118
5652
  "orgGraphSearch.search"
6119
5653
  );
6120
5654
  return {
6121
- tenantId: cleanString7(input.tenantId, "tenantId"),
6122
- workspaceId: cleanString7(input.workspaceId, "workspaceId"),
6123
- query: cleanString7(input.query, "query"),
5655
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5656
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5657
+ query: cleanString5(input.query, "query"),
6124
5658
  nodeTypes: input.nodeTypes,
6125
5659
  minConfidence: input.minConfidence,
6126
5660
  limit: input.limit,
@@ -6130,8 +5664,8 @@ function searchBody(input) {
6130
5664
  }
6131
5665
  function listQuery2(input) {
6132
5666
  return {
6133
- tenantId: cleanString7(input.tenantId, "tenantId"),
6134
- workspaceId: cleanString7(input.workspaceId, "workspaceId"),
5667
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5668
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
6135
5669
  nodeTypes: input.nodeTypes?.join(","),
6136
5670
  minConfidence: input.minConfidence,
6137
5671
  limit: input.limit,
@@ -6165,8 +5699,8 @@ function createOrgGraphSearchClient(config = {}) {
6165
5699
  return gateway.request({
6166
5700
  path: `/api/platform/v1/org-graph-search/nodes/${nodePath}${toQueryString(
6167
5701
  {
6168
- tenantId: cleanString7(input.tenantId, "tenantId"),
6169
- workspaceId: cleanString7(input.workspaceId, "workspaceId"),
5702
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5703
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
6170
5704
  globalId: nodeId ? void 0 : globalId
6171
5705
  }
6172
5706
  )}`
@@ -6194,7 +5728,7 @@ function createOrgGraphSearchClient(config = {}) {
6194
5728
  // src/packsClient.ts
6195
5729
  function createPacksClient(config = {}) {
6196
5730
  const gateway = createGatewayRequestClient(config);
6197
- const client = {
5731
+ return {
6198
5732
  /**
6199
5733
  * List catalog entries for available packs.
6200
5734
  */
@@ -6208,6 +5742,12 @@ function createPacksClient(config = {}) {
6208
5742
  )
6209
5743
  );
6210
5744
  },
5745
+ /**
5746
+ * @deprecated Use listCatalog.
5747
+ */
5748
+ async getCatalog() {
5749
+ return this.listCatalog();
5750
+ },
6211
5751
  /**
6212
5752
  * Get the discovery catalog for packs.
6213
5753
  */
@@ -6237,6 +5777,12 @@ function createPacksClient(config = {}) {
6237
5777
  )
6238
5778
  );
6239
5779
  },
5780
+ /**
5781
+ * @deprecated Use listStates.
5782
+ */
5783
+ async getStates(query5 = {}) {
5784
+ return this.listStates(query5);
5785
+ },
6240
5786
  /**
6241
5787
  * Get health details for a pack.
6242
5788
  */
@@ -6260,6 +5806,12 @@ function createPacksClient(config = {}) {
6260
5806
  )
6261
5807
  );
6262
5808
  },
5809
+ /**
5810
+ * @deprecated Use listTelemetry.
5811
+ */
5812
+ async getTelemetry(query5 = {}) {
5813
+ return this.listTelemetry(query5);
5814
+ },
6263
5815
  /**
6264
5816
  * Create a pack entitlement.
6265
5817
  */
@@ -6271,6 +5823,18 @@ function createPacksClient(config = {}) {
6271
5823
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6272
5824
  });
6273
5825
  },
5826
+ /**
5827
+ * Update a pack entitlement.
5828
+ */
5829
+ async updateEntitlement(input, idempotencyKey) {
5830
+ return this.createEntitlement(input, idempotencyKey);
5831
+ },
5832
+ /**
5833
+ * @deprecated Use createEntitlement or updateEntitlement.
5834
+ */
5835
+ async upsertEntitlement(input, idempotencyKey) {
5836
+ return this.createEntitlement(input, idempotencyKey);
5837
+ },
6274
5838
  /**
6275
5839
  * Install a pack.
6276
5840
  */
@@ -6327,13 +5891,6 @@ function createPacksClient(config = {}) {
6327
5891
  });
6328
5892
  }
6329
5893
  };
6330
- return Object.assign(client, {
6331
- getCatalog: client.listCatalog,
6332
- getStates: client.listStates,
6333
- getTelemetry: client.listTelemetry,
6334
- updateEntitlement: client.createEntitlement,
6335
- upsertEntitlement: client.createEntitlement
6336
- });
6337
5894
  }
6338
5895
 
6339
5896
  // src/policyClient.ts
@@ -6369,14 +5926,6 @@ function asRolePolicyArray(data) {
6369
5926
  }
6370
5927
  return data.map(asRolePolicyRecord).filter((row) => Boolean(row));
6371
5928
  }
6372
- function buildFilterByPermissionResponse(permission, allowedTopicIds, deniedTopics, count) {
6373
- const result = {};
6374
- result.permission = permission;
6375
- result.allowedTopicIds = allowedTopicIds;
6376
- result.deniedTopics = deniedTopics;
6377
- result.count = count;
6378
- return result;
6379
- }
6380
5929
  function createPolicyClient(config = {}) {
6381
5930
  const gateway = createGatewayRequestClient(config);
6382
5931
  return {
@@ -6599,15 +6148,15 @@ function createPolicyClient(config = {}) {
6599
6148
  });
6600
6149
  const allowedTopicIds = Array.isArray(response.data?.allowedTopicIds) ? response.data.allowedTopicIds : [];
6601
6150
  const deniedTopics = Array.isArray(response.data?.deniedTopics) ? response.data.deniedTopics : [];
6602
- const result = {};
6603
- result.success = true;
6604
- result.data = buildFilterByPermissionResponse(
6605
- permission,
6606
- allowedTopicIds,
6607
- deniedTopics,
6608
- typeof response.data?.count === "number" ? response.data.count : allowedTopicIds.length
6609
- );
6610
- return result;
6151
+ return {
6152
+ success: true,
6153
+ data: {
6154
+ permission,
6155
+ allowedTopicIds,
6156
+ deniedTopics,
6157
+ count: typeof response.data?.count === "number" ? response.data.count : allowedTopicIds.length
6158
+ }
6159
+ };
6611
6160
  }
6612
6161
  };
6613
6162
  }
@@ -6615,66 +6164,64 @@ function createPolicyClient(config = {}) {
6615
6164
  // src/reportsClient.ts
6616
6165
  function createReportsClient(config = {}) {
6617
6166
  const gateway = createGatewayRequestClient(config);
6618
- const listTemplates = async (args = {}) => gateway.request({
6619
- path: `/api/platform/v1/reports/templates${toQueryString({
6620
- slug: args.slug
6621
- })}`
6622
- }).then(
6623
- (response) => mapGatewayData(response, (data) => {
6624
- const rows = asListItems(data, "templates");
6625
- return createListResult(rows, "templates");
6626
- })
6627
- );
6628
- const listReports = async (input, args = {}) => {
6629
- const topicId = resolveTopicId(input);
6630
- if (!topicId) {
6631
- throw new Error("topicId is required");
6632
- }
6633
- return gateway.request({
6634
- path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString(
6635
- {
6636
- summary: typeof args.summary === "boolean" ? args.summary ? "true" : "false" : void 0
6637
- }
6638
- )}`
6639
- }).then(
6640
- (response) => mapGatewayData(
6641
- response,
6642
- (data) => createListResult(Array.isArray(data) ? data : [], "reports")
6643
- )
6644
- );
6645
- };
6646
- const getReport = async (reportId) => gateway.request({
6647
- path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`
6648
- });
6649
6167
  return {
6650
6168
  /**
6651
6169
  * List report templates.
6652
6170
  */
6653
- listTemplates,
6171
+ async listTemplates(args = {}) {
6172
+ return gateway.request({
6173
+ path: `/api/platform/v1/reports/templates${toQueryString({
6174
+ slug: args.slug
6175
+ })}`
6176
+ }).then(
6177
+ (response) => mapGatewayData(response, (data) => {
6178
+ const record = data && typeof data === "object" ? data : {};
6179
+ const rows = Array.isArray(data) ? data : Array.isArray(record.templates) ? record.templates : [];
6180
+ return createListResult(rows, "templates");
6181
+ })
6182
+ );
6183
+ },
6654
6184
  /**
6655
6185
  * @deprecated Use listTemplates.
6656
6186
  */
6657
- getTemplates: listTemplates,
6187
+ async getTemplates(args = {}) {
6188
+ return this.listTemplates(args);
6189
+ },
6658
6190
  /**
6659
6191
  * List reports for a topic scope.
6660
6192
  */
6661
- listReports,
6193
+ async listReports(input, args = {}) {
6194
+ const topicId = resolveTopicId(input);
6195
+ if (!topicId) {
6196
+ throw new Error("topicId is required");
6197
+ }
6198
+ return gateway.request({
6199
+ path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString(
6200
+ {
6201
+ summary: typeof args.summary === "boolean" ? args.summary ? "true" : "false" : void 0
6202
+ }
6203
+ )}`
6204
+ }).then(
6205
+ (response) => mapGatewayData(
6206
+ response,
6207
+ (data) => createListResult(Array.isArray(data) ? data : [], "reports")
6208
+ )
6209
+ );
6210
+ },
6662
6211
  /**
6663
6212
  * Get a generated report.
6664
6213
  */
6665
- getReport
6214
+ async getReport(reportId) {
6215
+ return gateway.request({
6216
+ path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`
6217
+ });
6218
+ }
6666
6219
  };
6667
6220
  }
6668
6221
 
6669
6222
  // src/schemaClient.ts
6670
6223
  function createSchemaClient(config = {}) {
6671
6224
  const gateway = createGatewayRequestClient(config);
6672
- const createEntitlement = (input, idempotencyKey) => gateway.request({
6673
- path: "/api/platform/v1/schema/entitlements",
6674
- method: "POST",
6675
- body: input,
6676
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6677
- });
6678
6225
  return {
6679
6226
  /**
6680
6227
  * List schema packs.
@@ -6726,108 +6273,27 @@ function createSchemaClient(config = {}) {
6726
6273
  /**
6727
6274
  * Create a schema entitlement.
6728
6275
  */
6729
- createEntitlement,
6276
+ async createEntitlement(input, idempotencyKey) {
6277
+ return gateway.request({
6278
+ path: "/api/platform/v1/schema/entitlements",
6279
+ method: "POST",
6280
+ body: input,
6281
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6282
+ });
6283
+ },
6730
6284
  /**
6731
6285
  * Update a schema entitlement.
6732
6286
  */
6733
- updateEntitlement: createEntitlement,
6287
+ async updateEntitlement(input, idempotencyKey) {
6288
+ return this.createEntitlement(input, idempotencyKey);
6289
+ },
6734
6290
  /**
6735
6291
  * @deprecated Use createEntitlement or updateEntitlement.
6736
6292
  */
6737
- upsertEntitlement: createEntitlement
6738
- };
6739
- }
6740
-
6741
- // src/clientHelpers.ts
6742
- function normalizeCustomNamespace(namespace) {
6743
- return namespace.trim() || "custom";
6744
- }
6745
- function normalizeCustomToolPayload(input) {
6746
- return input && typeof input === "object" && !Array.isArray(input) ? input : {};
6747
- }
6748
- function resolveCustomToolFullName(name) {
6749
- return name.includes(".") ? name : `custom.${name}`;
6750
- }
6751
- function buildBeliefsRefinePayload(textOrInput, rationale) {
6752
- return typeof textOrInput === "string" ? { text: textOrInput, rationale } : { text: textOrInput.text, rationale: textOrInput.rationale };
6753
- }
6754
- function buildBeliefsArchivePayload(input) {
6755
- return typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
6756
- }
6757
- function asNodeArray(data) {
6758
- const rows = asListItems(data, "nodes");
6759
- if (rows.length > 0) {
6760
- return rows.filter(
6761
- (value) => Boolean(value) && typeof value === "object"
6762
- );
6763
- }
6764
- if (data && typeof data === "object") {
6765
- return [data];
6766
- }
6767
- return [];
6768
- }
6769
- function requireTopicId4(args) {
6770
- const topicId = resolveTopicId(args);
6771
- if (!topicId) {
6772
- throw new Error("topicId is required");
6773
- }
6774
- return topicId;
6775
- }
6776
- function requireTopicOrProjectId(args) {
6777
- const topicId = args.topicId?.trim() || args.projectId?.trim() || void 0;
6778
- if (!topicId) {
6779
- throw new Error("topicId is required");
6780
- }
6781
- return topicId;
6782
- }
6783
- var AUDIT_NODE_REFERENCE_KEY_PATTERN = /(^|_)(id|nodeid|beliefid|resourceid|targetid|sourceid|subjectid|globalid|entityid|recordid|fromnodeid|tonodeid|linkednodeid|linkedbeliefid|nodeids|beliefids|resourceids)$/i;
6784
- function matchesAuditNodeReference(value, nodeId) {
6785
- if (Array.isArray(value)) {
6786
- return value.some((entry) => matchesAuditNodeReference(entry, nodeId));
6787
- }
6788
- if (!value || typeof value !== "object") {
6789
- return false;
6790
- }
6791
- return Object.entries(value).some(([key, entry]) => {
6792
- if (typeof entry === "string" && entry === nodeId && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key)) {
6793
- return true;
6794
- }
6795
- if (Array.isArray(entry) && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key) && entry.some((item) => item === nodeId)) {
6796
- return true;
6797
- }
6798
- return matchesAuditNodeReference(entry, nodeId);
6799
- });
6800
- }
6801
- function requireText(args) {
6802
- const text = resolveText(args);
6803
- if (!text) {
6804
- throw new Error("text is required");
6805
- }
6806
- return text;
6807
- }
6808
- function requireBaseRate(args) {
6809
- const baseRate = typeof args.baseRate === "number" && Number.isFinite(args.baseRate) ? args.baseRate : 0.5;
6810
- if (baseRate < 0 || baseRate > 1) {
6811
- throw new Error("baseRate must be within [0, 1].");
6812
- }
6813
- return baseRate;
6814
- }
6815
- function sdkQueryString(input) {
6816
- const params = new URLSearchParams();
6817
- for (const [key, value] of Object.entries(input)) {
6818
- if (value === void 0 || value === null) {
6819
- continue;
6820
- }
6821
- if (Array.isArray(value)) {
6822
- if (value.length > 0) {
6823
- params.set(key, value.join(","));
6824
- }
6825
- continue;
6293
+ async upsertEntitlement(input, idempotencyKey) {
6294
+ return this.createEntitlement(input, idempotencyKey);
6826
6295
  }
6827
- params.set(key, String(value));
6828
- }
6829
- const serialized = params.toString();
6830
- return serialized ? `?${serialized}` : "";
6296
+ };
6831
6297
  }
6832
6298
 
6833
6299
  // src/telemetryClient.ts
@@ -7000,16 +6466,6 @@ function query4(input) {
7000
6466
  cursor: input.cursor
7001
6467
  };
7002
6468
  }
7003
- function effectiveToolsQuery(input) {
7004
- return {
7005
- ...query4(input),
7006
- callerRole: input.callerRole,
7007
- surface: input.surface,
7008
- sessionType: input.sessionType,
7009
- permittedToolNames: input.permittedToolNames ? JSON.stringify(input.permittedToolNames) : void 0,
7010
- executableOnly: input.executableOnly
7011
- };
7012
- }
7013
6469
  function writeBody(input, operation) {
7014
6470
  return knownPayload(input, TOOL_REGISTRY_FIELDS, operation);
7015
6471
  }
@@ -7038,9 +6494,7 @@ function createToolRegistryClient(config = {}) {
7038
6494
  },
7039
6495
  listEffectiveTools(input) {
7040
6496
  return gateway.request({
7041
- path: `/api/platform/v1/tools/effective${toQueryString(
7042
- effectiveToolsQuery(input)
7043
- )}`
6497
+ path: `/api/platform/v1/tools/effective${toQueryString(query4(input))}`
7044
6498
  }).then(
7045
6499
  (response) => mapGatewayData(
7046
6500
  response,
@@ -7131,7 +6585,7 @@ function createToolRegistryClient(config = {}) {
7131
6585
  }
7132
6586
 
7133
6587
  // src/version.ts
7134
- var LUCERN_SDK_VERSION = "0.3.0-alpha.17";
6588
+ var LUCERN_SDK_VERSION = "0.2.0-alpha.1";
7135
6589
 
7136
6590
  // src/workflowClient.ts
7137
6591
  function normalizeLensQuery(value) {
@@ -7325,6 +6779,12 @@ function createWorkflowClient(config = {}) {
7325
6779
  )
7326
6780
  );
7327
6781
  },
6782
+ /**
6783
+ * @deprecated Use createWorktree.
6784
+ */
6785
+ async addWorktree(input, idempotencyKey) {
6786
+ return client.createWorktree(input, idempotencyKey);
6787
+ },
7328
6788
  /**
7329
6789
  * Merge a worktree into the main belief line.
7330
6790
  */
@@ -7522,29 +6982,58 @@ function createWorkflowClient(config = {}) {
7522
6982
  body: input,
7523
6983
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
7524
6984
  });
6985
+ },
6986
+ /**
6987
+ * @deprecated Use createBranch.
6988
+ */
6989
+ async createPillar(input, idempotencyKey) {
6990
+ return client.createBranch(input, idempotencyKey);
6991
+ },
6992
+ /**
6993
+ * @deprecated Use addWorktree.
6994
+ */
6995
+ async createSprint(input, idempotencyKey) {
6996
+ return client.createWorktree(input, idempotencyKey);
6997
+ },
6998
+ /**
6999
+ * @deprecated Use merge.
7000
+ */
7001
+ async completeSprint(worktreeId, input, idempotencyKey) {
7002
+ return client.merge(worktreeId, input, idempotencyKey);
7003
+ },
7004
+ /**
7005
+ * @deprecated Use openPullRequest.
7006
+ */
7007
+ async requestReview(worktreeId, input, idempotencyKey) {
7008
+ return client.openPullRequest(worktreeId, input, idempotencyKey);
7009
+ },
7010
+ /**
7011
+ * @deprecated Use push.
7012
+ */
7013
+ async publishFindings(worktreeId, input, idempotencyKey) {
7014
+ return client.push(worktreeId, input, idempotencyKey);
7525
7015
  }
7526
7016
  };
7527
- return Object.assign(client, {
7528
- addWorktree: client.createWorktree,
7529
- createPillar: client.createBranch,
7530
- createSprint: client.createWorktree,
7531
- completeSprint: client.merge,
7532
- requestReview: client.openPullRequest,
7533
- publishFindings: client.push
7534
- });
7017
+ return client;
7018
+ }
7019
+
7020
+ // src/client.ts
7021
+ function asNodeArray(data) {
7022
+ const rows = asListItems(data, "nodes");
7023
+ if (rows.length > 0) {
7024
+ return rows.filter(
7025
+ (value) => Boolean(value) && typeof value === "object"
7026
+ );
7027
+ }
7028
+ if (data && typeof data === "object") {
7029
+ return [data];
7030
+ }
7031
+ return [];
7535
7032
  }
7536
-
7537
- // src/client.ts
7538
7033
  function toGatewayConfig(config) {
7539
7034
  return {
7540
7035
  baseUrl: config.baseUrl,
7541
7036
  fetchImpl: config.fetchImpl,
7542
- apiKey: config.apiKey,
7543
- userToken: config.userToken,
7544
- environment: config.environment,
7545
- clerkId: config.clerkId,
7546
- userId: config.userId,
7547
- deploymentHost: config.deploymentHost,
7548
7037
  maxRetries: config.maxRetries,
7549
7038
  timeoutMs: config.timeoutMs,
7550
7039
  timeoutMsByMethod: config.timeoutMsByMethod,
@@ -7553,15 +7042,62 @@ function toGatewayConfig(config) {
7553
7042
  onResponse: config.onResponse,
7554
7043
  authContext: config.authContext,
7555
7044
  requireCanonicalAuthContext: config.requireCanonicalAuthContext,
7556
- getAuthHeaders: config.getAuthHeaders
7045
+ getAuthHeaders: async () => {
7046
+ const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
7047
+ if (config.apiKey && !base["x-lucern-key"] && !base.Authorization) {
7048
+ base["x-lucern-key"] = config.apiKey;
7049
+ }
7050
+ if (config.userToken && !base["x-lucern-session-token"]) {
7051
+ base["x-lucern-session-token"] = config.userToken;
7052
+ }
7053
+ if (config.environment && !base["x-lucern-environment"]) {
7054
+ base["x-lucern-environment"] = config.environment;
7055
+ }
7056
+ return base;
7057
+ }
7557
7058
  };
7558
7059
  }
7559
- function exposeGatewayData(response) {
7560
- const data = response.data;
7561
- if (data !== null && typeof data === "object" && !Array.isArray(data)) {
7562
- return Object.assign({}, response, data);
7060
+ function requireTopicId4(args) {
7061
+ const topicId = resolveTopicId(args);
7062
+ if (!topicId) {
7063
+ throw new Error("topicId is required");
7064
+ }
7065
+ return topicId;
7066
+ }
7067
+ var AUDIT_NODE_REFERENCE_KEY_PATTERN = /(^|_)(id|nodeid|beliefid|resourceid|targetid|sourceid|subjectid|globalid|entityid|recordid|fromnodeid|tonodeid|linkednodeid|linkedbeliefid|nodeids|beliefids|resourceids)$/i;
7068
+ function matchesAuditNodeReference(value, nodeId) {
7069
+ if (Array.isArray(value)) {
7070
+ return value.some((entry) => matchesAuditNodeReference(entry, nodeId));
7071
+ }
7072
+ if (!value || typeof value !== "object") {
7073
+ return false;
7074
+ }
7075
+ return Object.entries(value).some(([key, entry]) => {
7076
+ if (typeof entry === "string" && entry === nodeId && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key)) {
7077
+ return true;
7078
+ }
7079
+ if (Array.isArray(entry) && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key) && entry.some((item) => item === nodeId)) {
7080
+ return true;
7081
+ }
7082
+ return matchesAuditNodeReference(entry, nodeId);
7083
+ });
7084
+ }
7085
+ function requireText(args) {
7086
+ const text = resolveText(args);
7087
+ if (!text) {
7088
+ throw new Error("text is required");
7089
+ }
7090
+ return text;
7091
+ }
7092
+ function requireBaseRate(args) {
7093
+ const baseRate = typeof args.baseRate === "number" && Number.isFinite(args.baseRate) ? args.baseRate : 0.5;
7094
+ if (baseRate < 0 || baseRate > 1) {
7095
+ throw new Error("baseRate must be within [0, 1].");
7563
7096
  }
7564
- return { ...response };
7097
+ return baseRate;
7098
+ }
7099
+ function exposeGatewayData(response) {
7100
+ return Object.assign({}, response, response.data);
7565
7101
  }
7566
7102
  function createLucernClient(config = {}) {
7567
7103
  const gatewayConfig = toGatewayConfig(config);
@@ -7582,7 +7118,6 @@ function createLucernClient(config = {}) {
7582
7118
  const auditClient = createAuditClient(gatewayConfig);
7583
7119
  const authDeviceClient = createAuthDeviceClient(gatewayConfig);
7584
7120
  const adminClient = createAdminClient(gatewayConfig);
7585
- const accessControlClient = createAccessControlClient(gatewayConfig);
7586
7121
  const answersClient = createAnswersClient(gatewayConfig);
7587
7122
  const contradictionsFacade = createContradictionsFacade(gatewayConfig);
7588
7123
  const edgesFacade = createEdgesFacade(gatewayConfig);
@@ -7602,7 +7137,6 @@ function createLucernClient(config = {}) {
7602
7137
  const ontologyLinksClient = createOntologyLinksClient(gatewayConfig);
7603
7138
  const orgGraphSearchClient = createOrgGraphSearchClient(gatewayConfig);
7604
7139
  const functionSurfaceClient = createFunctionSurfaceClient(gatewayConfig);
7605
- const controlPlaneClient = createControlPlaneClient(gatewayConfig);
7606
7140
  const toolRegistryClient = createToolRegistryClient(gatewayConfig);
7607
7141
  const modelRuntimeClient = createModelRuntimeClient(gatewayConfig);
7608
7142
  const packsClient = createPacksClient(gatewayConfig);
@@ -7652,11 +7186,11 @@ function createLucernClient(config = {}) {
7652
7186
  }
7653
7187
  }
7654
7188
  const invokeCustomTool = async (fullName, input = {}) => {
7655
- const payload = normalizeCustomToolPayload(input);
7189
+ const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
7656
7190
  return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
7657
7191
  };
7658
7192
  const getCustomNamespace = (namespace) => {
7659
- const normalized = normalizeCustomNamespace(namespace);
7193
+ const normalized = namespace.trim() || "custom";
7660
7194
  const cached = customNamespaceCache.get(normalized);
7661
7195
  if (cached) {
7662
7196
  return cached;
@@ -7788,7 +7322,7 @@ function createLucernClient(config = {}) {
7788
7322
  topicId,
7789
7323
  nodeType: "contradiction",
7790
7324
  limit: 500
7791
- }) : args.nodeId ? await graphClient.listNodes({ nodeId: args.nodeId }) : { data: [] };
7325
+ }) : args.nodeId ? await graphClient.queryNodes({ nodeId: args.nodeId }) : { data: [] };
7792
7326
  const contradictions = asNodeArray(response.data).filter((node) => {
7793
7327
  const status = typeof node.metadata?.status === "string" ? node.metadata.status : typeof node.status === "string" ? node.status : "unresolved";
7794
7328
  if (args.status && status !== args.status) {
@@ -7968,141 +7502,39 @@ function createLucernClient(config = {}) {
7968
7502
  }).then(exposeGatewayData);
7969
7503
  }
7970
7504
  const nodesNamespace = {
7971
- list: graphClient.listNodes,
7505
+ list(query5) {
7506
+ return graphClient.listNodes(query5);
7507
+ },
7972
7508
  get(input) {
7973
7509
  return graphClient.getNode(
7974
7510
  typeof input === "string" ? { nodeId: input } : input
7975
7511
  );
7976
7512
  },
7977
7513
  create(input, idempotencyKey) {
7978
- return functionSurfaceClient.createEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
7979
- },
7980
- createEpistemicNode(input, idempotencyKey) {
7981
- return functionSurfaceClient.createEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
7514
+ return graphClient.createNode(input, idempotencyKey);
7982
7515
  },
7983
7516
  update(input, idempotencyKey) {
7984
- return functionSurfaceClient.updateEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
7985
- },
7986
- updateEpistemicNode(input, idempotencyKey) {
7987
- return functionSurfaceClient.updateEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
7517
+ return graphClient.updateNode(input, idempotencyKey);
7988
7518
  },
7989
7519
  batchCreate(input, idempotencyKey) {
7990
- return functionSurfaceClient.batchCreateEpistemicNodes(input, idempotencyKey).then(exposeGatewayData);
7991
- },
7992
- batchCreateEpistemicNodes(input, idempotencyKey) {
7993
- return functionSurfaceClient.batchCreateEpistemicNodes(input, idempotencyKey).then(exposeGatewayData);
7994
- },
7995
- listByTopicAndType(input) {
7996
- return gateway.request({
7997
- path: `/api/platform/v1/nodes${sdkQueryString({
7998
- topicId: requireTopicOrProjectId(input),
7999
- nodeType: input.nodeType,
8000
- nodeTypes: input.nodeTypes,
8001
- query: input.query,
8002
- sourceText: input.sourceText,
8003
- limit: input.limit,
8004
- cursor: input.cursor
8005
- })}`
8006
- }).then(exposeGatewayData);
8007
- },
8008
- countByTopicAndType(input) {
8009
- return gateway.request({
8010
- path: `/api/platform/v1/nodes/count${sdkQueryString({
8011
- topicId: requireTopicOrProjectId(input),
8012
- nodeType: input.nodeType,
8013
- nodeTypes: input.nodeTypes,
8014
- query: input.query,
8015
- limit: input.limit
8016
- })}`
8017
- }).then(exposeGatewayData);
7520
+ return graphClient.batchCreateNodes(input, idempotencyKey);
8018
7521
  },
8019
7522
  supersede(input, idempotencyKey) {
8020
- return functionSurfaceClient.supersedeEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
7523
+ return graphClient.supersedeNode(input, idempotencyKey);
8021
7524
  },
8022
7525
  verify(input, idempotencyKey) {
8023
- return functionSurfaceClient.verifyEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
8024
- },
8025
- archive(input, idempotencyKey) {
8026
- return functionSurfaceClient.archiveEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
8027
- },
8028
- hardDelete: graphClient.hardDeleteNode
8029
- };
8030
- const publicationNamespace = {
8031
- create(input, idempotencyKey) {
8032
- return gateway.request({
8033
- path: "/api/platform/v1/publication",
8034
- method: "POST",
8035
- body: input,
8036
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8037
- }).then(exposeGatewayData);
8038
- },
8039
- update(publicationId, input, idempotencyKey) {
8040
- return gateway.request({
8041
- path: `/api/platform/v1/publication/${encodeURIComponent(
8042
- publicationId
8043
- )}`,
8044
- method: "PATCH",
8045
- body: input,
8046
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8047
- }).then(exposeGatewayData);
8048
- },
8049
- list(input = {}) {
8050
- return gateway.request({
8051
- path: `/api/platform/v1/publication${sdkQueryString(input)}`
8052
- }).then(exposeGatewayData);
8053
- },
8054
- getByTopic(input) {
8055
- const topicId = typeof input === "string" ? input : input.topicId;
8056
- const workspaceId = typeof input === "string" ? void 0 : input.workspaceId;
8057
- return gateway.request({
8058
- path: `/api/platform/v1/publication/by-topic/${encodeURIComponent(
8059
- topicId
8060
- )}${sdkQueryString({ workspaceId })}`
8061
- }).then(exposeGatewayData);
8062
- },
8063
- publish(publicationId, input = {}, idempotencyKey) {
8064
- return gateway.request({
8065
- path: `/api/platform/v1/publication/${encodeURIComponent(
8066
- publicationId
8067
- )}/publish`,
8068
- method: "POST",
8069
- body: input,
8070
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8071
- }).then(exposeGatewayData);
8072
- },
8073
- unpublish(publicationId, input = {}, idempotencyKey) {
8074
- return gateway.request({
8075
- path: `/api/platform/v1/publication/${encodeURIComponent(
8076
- publicationId
8077
- )}/unpublish`,
8078
- method: "POST",
8079
- body: input,
8080
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8081
- }).then(exposeGatewayData);
7526
+ return graphClient.verifyNode(input, idempotencyKey);
8082
7527
  },
8083
- remove(publicationId, input = {}) {
8084
- return gateway.request({
8085
- path: `/api/platform/v1/publication/${encodeURIComponent(
8086
- publicationId
8087
- )}${sdkQueryString(input)}`,
8088
- method: "DELETE"
8089
- }).then(exposeGatewayData);
8090
- }
8091
- };
8092
- const ontologyLinksNamespace = {
8093
- ...ontologyLinksClient,
8094
- resolveThemeSource(input) {
8095
- return gateway.request({
8096
- path: "/api/platform/v1/ontology-links/theme-source",
8097
- method: "POST",
8098
- body: input
8099
- }).then(exposeGatewayData);
7528
+ hardDelete(input, idempotencyKey) {
7529
+ return graphClient.hardDeleteNode(input, idempotencyKey);
8100
7530
  }
8101
7531
  };
8102
7532
  return {
8103
7533
  config,
8104
7534
  version: LUCERN_SDK_VERSION,
8105
- search: searchResources,
7535
+ search(query5, options) {
7536
+ return searchResources(query5, options);
7537
+ },
8106
7538
  events: {
8107
7539
  list(query5 = {}) {
8108
7540
  return eventsFacade.list(query5).then(exposeGatewayData);
@@ -8138,7 +7570,10 @@ function createLucernClient(config = {}) {
8138
7570
  return beliefsFacade.get(nodeId).then(exposeGatewayData);
8139
7571
  },
8140
7572
  refine(nodeId, textOrInput, rationale) {
8141
- const payload = buildBeliefsRefinePayload(textOrInput, rationale);
7573
+ const payload = typeof textOrInput === "string" ? { text: textOrInput, rationale } : {
7574
+ text: textOrInput.text,
7575
+ rationale: textOrInput.rationale
7576
+ };
8142
7577
  return beliefsFacade.refine(nodeId, payload).then(exposeGatewayData);
8143
7578
  },
8144
7579
  updateConfidence(nodeId, input) {
@@ -8176,7 +7611,7 @@ function createLucernClient(config = {}) {
8176
7611
  }).then(exposeGatewayData);
8177
7612
  },
8178
7613
  archive(nodeId, input) {
8179
- const payload = buildBeliefsArchivePayload(input);
7614
+ const payload = typeof input === "string" ? { reason: input } : input ? { reason: input.reason ?? input.rationale } : void 0;
8180
7615
  return beliefsFacade.archive(nodeId, payload).then(exposeGatewayData);
8181
7616
  },
8182
7617
  list(args) {
@@ -8196,7 +7631,9 @@ function createLucernClient(config = {}) {
8196
7631
  confidenceHistory(nodeId) {
8197
7632
  return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
8198
7633
  },
8199
- opinionHistory: getOpinionHistory,
7634
+ opinionHistory(nodeId) {
7635
+ return getOpinionHistory(nodeId);
7636
+ },
8200
7637
  createContract(nodeId, input) {
8201
7638
  return beliefsFacade.createContract(nodeId, input).then(exposeGatewayData);
8202
7639
  },
@@ -8231,13 +7668,7 @@ function createLucernClient(config = {}) {
8231
7668
  }
8232
7669
  },
8233
7670
  edges: {
8234
- create(args, idempotencyKey) {
8235
- if (args.from && args.to) {
8236
- return functionSurfaceClient.createEdge(args, idempotencyKey).then(exposeGatewayData);
8237
- }
8238
- if (!args.sourceId || !args.targetId) {
8239
- throw new Error("from/to graph refs or sourceId/targetId are required");
8240
- }
7671
+ create(args) {
8241
7672
  return edgesFacade.create({
8242
7673
  sourceId: args.sourceId,
8243
7674
  targetId: args.targetId,
@@ -8248,32 +7679,17 @@ function createLucernClient(config = {}) {
8248
7679
  context: args.context ?? args.reasoning
8249
7680
  }).then(exposeGatewayData);
8250
7681
  },
8251
- createEdge(input, idempotencyKey) {
8252
- return functionSurfaceClient.createEdge(input, idempotencyKey).then(exposeGatewayData);
8253
- },
8254
7682
  update(input, idempotencyKey) {
8255
- return functionSurfaceClient.updateEdge(input, idempotencyKey).then(exposeGatewayData);
8256
- },
8257
- updateEdge(input, idempotencyKey) {
8258
- return functionSurfaceClient.updateEdge(input, idempotencyKey).then(exposeGatewayData);
7683
+ return edgesFacade.update(input, idempotencyKey).then(exposeGatewayData);
8259
7684
  },
8260
7685
  remove(input, idempotencyKey) {
8261
- return functionSurfaceClient.removeEdge(input, idempotencyKey).then(exposeGatewayData);
8262
- },
8263
- removeEdge(input, idempotencyKey) {
8264
- return functionSurfaceClient.removeEdge(input, idempotencyKey).then(exposeGatewayData);
7686
+ return edgesFacade.remove(input, idempotencyKey).then(exposeGatewayData);
8265
7687
  },
8266
7688
  removeBetween(input, idempotencyKey) {
8267
- return functionSurfaceClient.removeEdgesBetween(input, idempotencyKey).then(exposeGatewayData);
8268
- },
8269
- removeEdgesBetween(input, idempotencyKey) {
8270
- return functionSurfaceClient.removeEdgesBetween(input, idempotencyKey).then(exposeGatewayData);
7689
+ return edgesFacade.removeBetween(input, idempotencyKey).then(exposeGatewayData);
8271
7690
  },
8272
7691
  batchCreate(input, idempotencyKey) {
8273
- return functionSurfaceClient.batchCreateEdges(input, idempotencyKey).then(exposeGatewayData);
8274
- },
8275
- batchCreateEdges(input, idempotencyKey) {
8276
- return functionSurfaceClient.batchCreateEdges(input, idempotencyKey).then(exposeGatewayData);
7692
+ return edgesFacade.batchCreate(input, idempotencyKey).then(exposeGatewayData);
8277
7693
  },
8278
7694
  delete(input, idempotencyKey) {
8279
7695
  return edgesFacade.delete(input, idempotencyKey).then(exposeGatewayData);
@@ -8471,10 +7887,10 @@ function createLucernClient(config = {}) {
8471
7887
  }));
8472
7888
  },
8473
7889
  getHighPriority(args) {
8474
- return questionsFacade.list({
7890
+ return this.list({
8475
7891
  topicId: requireTopicId4(args),
8476
7892
  status: args.includeAnswered ? void 0 : "open"
8477
- }).then(exposeGatewayData).then((data) => {
7893
+ }).then((data) => {
8478
7894
  const questions = Array.isArray(data.questions) ? data.questions : [];
8479
7895
  const rank = (priority) => {
8480
7896
  switch (priority) {
@@ -8504,7 +7920,9 @@ function createLucernClient(config = {}) {
8504
7920
  },
8505
7921
  graph: {
8506
7922
  nodes: nodesNamespace,
8507
- createEdge: graphClient.createEdge,
7923
+ createEdge(input) {
7924
+ return graphClient.createEdge(input);
7925
+ },
8508
7926
  neighborhood(args) {
8509
7927
  return graphFacade.neighborhood({
8510
7928
  globalId: args.globalId,
@@ -8563,7 +7981,7 @@ function createLucernClient(config = {}) {
8563
7981
  bisectConfidence,
8564
7982
  listBeliefs,
8565
7983
  detectConfirmationBias(topicId, threshold) {
8566
- return graphFacade.bias({
7984
+ return this.bias({
8567
7985
  topicId,
8568
7986
  threshold,
8569
7987
  limit: 200
@@ -8574,7 +7992,7 @@ function createLucernClient(config = {}) {
8574
7992
  }));
8575
7993
  },
8576
7994
  getStructureAnalysis(topicId) {
8577
- return graphFacade.analyze({
7995
+ return this.analyze({
8578
7996
  topicId,
8579
7997
  limit: 200
8580
7998
  }).then((response) => ({
@@ -8592,69 +8010,39 @@ function createLucernClient(config = {}) {
8592
8010
  }));
8593
8011
  }
8594
8012
  },
8595
- themes: {
8596
- listByTopic(input) {
8597
- return gateway.request({
8598
- path: `/api/platform/v1/themes${sdkQueryString({
8599
- topicId: requireTopicOrProjectId(input),
8600
- query: input.query,
8601
- limit: input.limit,
8602
- cursor: input.cursor
8603
- })}`
8604
- }).then(exposeGatewayData);
8605
- }
8606
- },
8607
- graphSearch: {
8608
- keywordSearchNodes(input) {
8609
- return gateway.request({
8610
- path: "/api/platform/v1/graph-search/keyword-nodes",
8611
- method: "POST",
8612
- body: {
8613
- ...input,
8614
- topicId: requireTopicOrProjectId(input),
8615
- projectId: void 0
8616
- }
8617
- }).then(exposeGatewayData);
8618
- }
8619
- },
8620
- classifiers: {
8621
- listBeliefCandidates(input) {
8622
- return gateway.request({
8623
- path: `/api/platform/v1/classifiers/belief-candidates${sdkQueryString({
8624
- topicId: requireTopicOrProjectId(input),
8625
- classifierKey: input.classifierKey,
8626
- query: input.query,
8627
- limit: input.limit,
8628
- cursor: input.cursor
8629
- })}`
8630
- }).then(exposeGatewayData);
8631
- }
8632
- },
8633
- archetypes: {
8634
- getJudgmentSignature(input) {
8635
- return gateway.request({
8636
- path: `/api/platform/v1/archetypes/judgment-signature${sdkQueryString({
8637
- topicId: requireTopicOrProjectId(input),
8638
- principalId: input.principalId
8639
- })}`
8640
- }).then(exposeGatewayData);
8641
- }
8642
- },
8643
8013
  judgments: {
8644
- create: decisionsClient.createJudgment,
8645
- record: decisionsClient.recordJudgment,
8646
- list: decisionsClient.listJudgments,
8647
- get: decisionsClient.getJudgment,
8648
- recordOutcome: decisionsClient.recordJudgmentOutcome,
8649
- updateOutcome: decisionsClient.updateJudgmentOutcome,
8014
+ create(input) {
8015
+ return decisionsClient.createJudgment(input);
8016
+ },
8017
+ record(input) {
8018
+ return decisionsClient.recordJudgment(input);
8019
+ },
8020
+ list(query5) {
8021
+ return decisionsClient.listJudgments(query5);
8022
+ },
8023
+ get(judgmentId) {
8024
+ return decisionsClient.getJudgment(judgmentId);
8025
+ },
8026
+ recordOutcome(judgmentId, input) {
8027
+ return decisionsClient.recordJudgmentOutcome(judgmentId, input);
8028
+ },
8029
+ updateOutcome(judgmentId, input) {
8030
+ return decisionsClient.updateJudgmentOutcome(judgmentId, input);
8031
+ },
8650
8032
  readiness(topicId) {
8651
- return decisionsClient.getJudgmentReadiness({ topicId });
8033
+ return decisionsClient.getJudgmentReadiness({
8034
+ topicId
8035
+ });
8652
8036
  },
8653
8037
  calibration(topicId) {
8654
- return decisionsClient.getJudgmentCalibration({ topicId });
8038
+ return decisionsClient.getJudgmentCalibration({
8039
+ topicId
8040
+ });
8655
8041
  },
8656
8042
  pendingOutcomeReview(topicId) {
8657
- return decisionsClient.listPendingJudgmentOutcomeReview({ topicId });
8043
+ return decisionsClient.listPendingJudgmentOutcomeReview({
8044
+ topicId
8045
+ });
8658
8046
  },
8659
8047
  transitionAuditIntegrity(args) {
8660
8048
  return decisionsClient.getJudgmentTransitionAuditIntegrity({
@@ -8663,69 +8051,29 @@ function createLucernClient(config = {}) {
8663
8051
  });
8664
8052
  }
8665
8053
  },
8666
- decisions: {
8667
- create: decisionsClient.createJudgment,
8668
- record: decisionsClient.recordJudgment,
8669
- list: decisionsClient.listJudgments,
8670
- get: decisionsClient.getJudgment,
8671
- recordOutcome: decisionsClient.recordJudgmentOutcome,
8672
- lessons(decisionId, input, idempotencyKey) {
8673
- return gateway.request({
8674
- path: `/api/platform/v1/decisions/${encodeURIComponent(
8675
- decisionId
8676
- )}/lessons`,
8677
- method: "POST",
8678
- body: input,
8679
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8680
- }).then(exposeGatewayData);
8054
+ worktrees: {
8055
+ createBranch(input) {
8056
+ return workflowClient.createBranch(input);
8681
8057
  },
8682
- archive(decisionId, input = {}, idempotencyKey) {
8683
- return gateway.request({
8684
- path: `/api/platform/v1/decisions/${encodeURIComponent(
8685
- decisionId
8686
- )}/archive`,
8687
- method: "POST",
8688
- body: input,
8689
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8690
- }).then(exposeGatewayData);
8058
+ createLens(input) {
8059
+ return workflowClient.createLens(input);
8691
8060
  },
8692
- readiness(topicId) {
8693
- return decisionsClient.getJudgmentReadiness({ topicId });
8061
+ listLenses(query5) {
8062
+ return workflowClient.listLenses(query5);
8694
8063
  },
8695
- calibration(topicId) {
8696
- return decisionsClient.getJudgmentCalibration({ topicId });
8064
+ applyLensToTopic(input) {
8065
+ return workflowClient.applyLensToTopic(input);
8066
+ },
8067
+ removeLensFromTopic(input) {
8068
+ return workflowClient.removeLensFromTopic(input);
8697
8069
  },
8698
- pendingOutcomeReview(topicId) {
8699
- return decisionsClient.listPendingJudgmentOutcomeReview({ topicId });
8700
- }
8701
- },
8702
- worktrees: {
8703
- createBranch: workflowClient.createBranch,
8704
- createLens: workflowClient.createLens,
8705
- listLenses: workflowClient.listLenses,
8706
- applyLensToTopic: workflowClient.applyLensToTopic,
8707
- removeLensFromTopic: workflowClient.removeLensFromTopic,
8708
8070
  create(input) {
8709
8071
  return worktreesFacade.create({
8710
8072
  title: input.title,
8711
8073
  topicId: requireTopicId4(input),
8712
8074
  objective: input.objective,
8713
8075
  hypothesis: input.hypothesis,
8714
- rationale: input.rationale,
8715
- worktreeType: input.worktreeType,
8716
- startDate: input.startDate,
8717
- endDate: input.endDate,
8718
- durationWeeks: input.durationWeeks,
8719
- confidenceImpact: input.confidenceImpact,
8720
- beliefFocus: input.beliefFocus,
8721
8076
  beliefIds: input.beliefIds,
8722
- targetBeliefIds: input.targetBeliefIds,
8723
- targetQuestionIds: input.targetQuestionIds,
8724
- keyQuestions: input.keyQuestions,
8725
- evidenceSignals: input.evidenceSignals,
8726
- decisionGate: input.decisionGate,
8727
- goCriteria: input.goCriteria,
8728
- noGoSignals: input.noGoSignals,
8729
8077
  autoShape: input.autoShape,
8730
8078
  domainPackId: input.domainPackId,
8731
8079
  campaign: input.campaign,
@@ -8738,8 +8086,7 @@ function createLucernClient(config = {}) {
8738
8086
  proofArtifacts: input.proofArtifacts,
8739
8087
  staffingHint: typeof input.staffingHint === "string" ? input.staffingHint : void 0,
8740
8088
  lastReconciledAt: input.lastReconciledAt,
8741
- autoFixPolicy: input.autoFixPolicy,
8742
- lensId: input.lensId
8089
+ autoFixPolicy: input.autoFixPolicy
8743
8090
  });
8744
8091
  },
8745
8092
  add(input) {
@@ -8748,21 +8095,7 @@ function createLucernClient(config = {}) {
8748
8095
  topicId: requireTopicId4(input),
8749
8096
  objective: input.objective,
8750
8097
  hypothesis: input.hypothesis,
8751
- rationale: input.rationale,
8752
- worktreeType: input.worktreeType,
8753
- startDate: input.startDate,
8754
- endDate: input.endDate,
8755
- durationWeeks: input.durationWeeks,
8756
- confidenceImpact: input.confidenceImpact,
8757
- beliefFocus: input.beliefFocus,
8758
8098
  beliefIds: input.beliefIds,
8759
- targetBeliefIds: input.targetBeliefIds,
8760
- targetQuestionIds: input.targetQuestionIds,
8761
- keyQuestions: input.keyQuestions,
8762
- evidenceSignals: input.evidenceSignals,
8763
- decisionGate: input.decisionGate,
8764
- goCriteria: input.goCriteria,
8765
- noGoSignals: input.noGoSignals,
8766
8099
  autoShape: input.autoShape,
8767
8100
  domainPackId: input.domainPackId,
8768
8101
  campaign: input.campaign,
@@ -8775,8 +8108,7 @@ function createLucernClient(config = {}) {
8775
8108
  proofArtifacts: input.proofArtifacts,
8776
8109
  staffingHint: typeof input.staffingHint === "string" ? input.staffingHint : void 0,
8777
8110
  lastReconciledAt: input.lastReconciledAt,
8778
- autoFixPolicy: input.autoFixPolicy,
8779
- lensId: input.lensId
8111
+ autoFixPolicy: input.autoFixPolicy
8780
8112
  });
8781
8113
  },
8782
8114
  list(query5) {
@@ -8786,22 +8118,6 @@ function createLucernClient(config = {}) {
8786
8118
  limit: query5.limit
8787
8119
  });
8788
8120
  },
8789
- listByTopic(query5) {
8790
- return worktreesFacade.list({
8791
- topicId: requireTopicId4(query5),
8792
- status: query5.status,
8793
- limit: query5.limit
8794
- });
8795
- },
8796
- findByPairedSprint(input) {
8797
- return gateway.request({
8798
- path: `/api/platform/v1/worktrees/paired-sprint${sdkQueryString({
8799
- sprintId: input.sprintId,
8800
- topicId: input.topicId ?? input.projectId,
8801
- limit: input.limit
8802
- })}`
8803
- }).then(exposeGatewayData);
8804
- },
8805
8121
  activate(worktreeId) {
8806
8122
  return worktreesFacade.activate({ id: worktreeId });
8807
8123
  },
@@ -8809,9 +8125,7 @@ function createLucernClient(config = {}) {
8809
8125
  const dependsOn = Array.isArray(input.dependsOn) ? input.dependsOn.filter(
8810
8126
  (value) => typeof value === "string"
8811
8127
  ) : void 0;
8812
- const blocks = Array.isArray(input.blocks) ? input.blocks.filter(
8813
- (value) => typeof value === "string"
8814
- ) : void 0;
8128
+ const blocks = Array.isArray(input.blocks) ? input.blocks.filter((value) => typeof value === "string") : void 0;
8815
8129
  return worktreesFacade.update({
8816
8130
  id: typeof input.worktreeId === "string" ? input.worktreeId : "",
8817
8131
  hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : void 0,
@@ -8825,23 +8139,7 @@ function createLucernClient(config = {}) {
8825
8139
  });
8826
8140
  },
8827
8141
  update(input) {
8828
- const dependsOn = Array.isArray(input.dependsOn) ? input.dependsOn.filter(
8829
- (value) => typeof value === "string"
8830
- ) : void 0;
8831
- const blocks = Array.isArray(input.blocks) ? input.blocks.filter(
8832
- (value) => typeof value === "string"
8833
- ) : void 0;
8834
- return worktreesFacade.update({
8835
- id: typeof input.worktreeId === "string" ? input.worktreeId : "",
8836
- hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : void 0,
8837
- campaign: typeof input.campaign === "number" ? input.campaign : void 0,
8838
- lane: typeof input.lane === "string" ? input.lane : void 0,
8839
- laneOrderInCampaign: typeof input.laneOrderInCampaign === "number" ? input.laneOrderInCampaign : void 0,
8840
- orderInLane: typeof input.orderInLane === "number" ? input.orderInLane : void 0,
8841
- dependsOn,
8842
- blocks,
8843
- gate: typeof input.gate === "string" ? input.gate : void 0
8844
- });
8142
+ return this.updateMetadata(input);
8845
8143
  },
8846
8144
  updateTargets(input) {
8847
8145
  return worktreesFacade.updateTargets({
@@ -8852,7 +8150,9 @@ function createLucernClient(config = {}) {
8852
8150
  removeQuestionIds: input.removeQuestionIds
8853
8151
  });
8854
8152
  },
8855
- listAll: workflowClient.listAllWorktrees,
8153
+ listAll(query5 = {}) {
8154
+ return workflowClient.listAllWorktrees(query5);
8155
+ },
8856
8156
  merge(worktreeId, input) {
8857
8157
  return worktreesFacade.merge({
8858
8158
  id: worktreeId,
@@ -8860,12 +8160,18 @@ function createLucernClient(config = {}) {
8860
8160
  summary: input.summary
8861
8161
  });
8862
8162
  },
8863
- push: workflowClient.push,
8864
- openPullRequest: workflowClient.openPullRequest,
8163
+ push(worktreeId, input) {
8164
+ return workflowClient.push(worktreeId, input);
8165
+ },
8166
+ openPullRequest(worktreeId, input) {
8167
+ return workflowClient.openPullRequest(worktreeId, input);
8168
+ },
8865
8169
  pipelineSnapshot(topicId) {
8866
8170
  return functionSurfaceClient.pipelineSnapshot({ topicId });
8867
8171
  },
8868
- complete: worktreesFacade.complete,
8172
+ complete(input, idempotencyKey) {
8173
+ return worktreesFacade.complete(input, idempotencyKey);
8174
+ },
8869
8175
  advancePhase(worktreeId, idempotencyKey) {
8870
8176
  return worktreesFacade.advancePhase(
8871
8177
  { worktreeId },
@@ -8878,8 +8184,12 @@ function createLucernClient(config = {}) {
8878
8184
  idempotencyKey
8879
8185
  );
8880
8186
  },
8881
- patchState: worktreesFacade.patchState,
8882
- bulkCreate: worktreesFacade.bulkCreate
8187
+ patchState(input, idempotencyKey) {
8188
+ return worktreesFacade.patchState(input, idempotencyKey);
8189
+ },
8190
+ bulkCreate(input, idempotencyKey) {
8191
+ return worktreesFacade.bulkCreate(input, idempotencyKey);
8192
+ }
8883
8193
  },
8884
8194
  context: {
8885
8195
  listTopics(query5 = {}) {
@@ -8890,15 +8200,27 @@ function createLucernClient(config = {}) {
8890
8200
  type: query5.type
8891
8201
  });
8892
8202
  },
8893
- compile: contextClient.compile,
8894
- recordScopeLearning: functionSurfaceClient.recordScopeLearning,
8203
+ compile(topicId, input = {}) {
8204
+ return contextClient.compile(topicId, input);
8205
+ },
8206
+ recordScopeLearning(input, idempotencyKey) {
8207
+ return functionSurfaceClient.recordScopeLearning(input, idempotencyKey);
8208
+ },
8895
8209
  discover(input) {
8896
8210
  return discoverTopics(input);
8897
8211
  },
8898
- analyzeTopicDensity: functionSurfaceClient.analyzeTopicDensity,
8899
- applyAutoBranching: functionSurfaceClient.applyAutoBranching,
8900
- seedBeliefLattice: functionSurfaceClient.seedBeliefLattice,
8901
- getLatticeCoverage: functionSurfaceClient.getLatticeCoverage,
8212
+ analyzeTopicDensity(input) {
8213
+ return functionSurfaceClient.analyzeTopicDensity(input);
8214
+ },
8215
+ applyAutoBranching(input, idempotencyKey) {
8216
+ return functionSurfaceClient.applyAutoBranching(input, idempotencyKey);
8217
+ },
8218
+ seedBeliefLattice(input = {}, idempotencyKey) {
8219
+ return functionSurfaceClient.seedBeliefLattice(input, idempotencyKey);
8220
+ },
8221
+ getLatticeCoverage(input = {}) {
8222
+ return functionSurfaceClient.getLatticeCoverage(input);
8223
+ },
8902
8224
  matchEntityType(input) {
8903
8225
  return ontologiesFacade.match(input).then(exposeGatewayData);
8904
8226
  },
@@ -8947,31 +8269,6 @@ function createLucernClient(config = {}) {
8947
8269
  status: typeof input.status === "string" ? input.status : void 0,
8948
8270
  limit: typeof input.limit === "number" ? input.limit : void 0
8949
8271
  });
8950
- },
8951
- listByTopic(input) {
8952
- return tasksFacade.list({
8953
- topicId: requireTopicId4(input),
8954
- status: typeof input.status === "string" ? input.status : void 0,
8955
- limit: typeof input.limit === "number" ? input.limit : void 0
8956
- });
8957
- },
8958
- listByWorktree(input) {
8959
- return tasksFacade.list({
8960
- topicId: typeof input.topicId === "string" ? input.topicId : void 0,
8961
- worktreeId: input.worktreeId,
8962
- status: typeof input.status === "string" ? input.status : void 0,
8963
- limit: typeof input.limit === "number" ? input.limit : void 0
8964
- });
8965
- },
8966
- linkChat(taskId, input, idempotencyKey) {
8967
- return gateway.request({
8968
- path: `/api/platform/v1/tasks/${encodeURIComponent(
8969
- taskId
8970
- )}/link-chat`,
8971
- method: "POST",
8972
- body: input,
8973
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
8974
- }).then(exposeGatewayData);
8975
8272
  }
8976
8273
  },
8977
8274
  topics: {
@@ -8983,9 +8280,21 @@ function createLucernClient(config = {}) {
8983
8280
  type: input.type
8984
8281
  });
8985
8282
  },
8986
- get: topicsFacade.get,
8283
+ get(topicId) {
8284
+ return topicsFacade.get(topicId);
8285
+ },
8987
8286
  create(input) {
8988
- return functionSurfaceClient.createTopic(input).then(exposeGatewayData);
8287
+ return topicsFacade.create({
8288
+ name: input.name,
8289
+ description: input.description,
8290
+ type: input.type,
8291
+ parentTopicId: input.parentTopicId,
8292
+ ontologyId: input.ontologyId,
8293
+ tenantId: input.tenantId,
8294
+ workspaceId: input.workspaceId,
8295
+ visibility: input.visibility,
8296
+ createdBy: input.createdBy
8297
+ });
8989
8298
  },
8990
8299
  update(topicId, input) {
8991
8300
  return topicsFacade.update({
@@ -9018,19 +8327,11 @@ function createLucernClient(config = {}) {
9018
8327
  maxDepth: query5.maxDepth
9019
8328
  });
9020
8329
  },
9021
- remove: topicsFacade.remove,
9022
- bulkCreate: topicsFacade.bulkCreate,
9023
- materializeGraph(input = {}, idempotencyKey) {
9024
- return functionSurfaceClient.materializeTopicGraph(input, idempotencyKey).then(exposeGatewayData);
9025
- },
9026
- materializeTopicGraph(input = {}, idempotencyKey) {
9027
- return functionSurfaceClient.materializeTopicGraph(input, idempotencyKey).then(exposeGatewayData);
9028
- },
9029
- graphSpine(input = {}) {
9030
- return functionSurfaceClient.getTopicGraphSpine(input).then(exposeGatewayData);
8330
+ remove(topicId, idempotencyKey) {
8331
+ return topicsFacade.remove(topicId, idempotencyKey);
9031
8332
  },
9032
- getTopicGraphSpine(input = {}) {
9033
- return functionSurfaceClient.getTopicGraphSpine(input).then(exposeGatewayData);
8333
+ bulkCreate(input, idempotencyKey) {
8334
+ return topicsFacade.bulkCreate(input, idempotencyKey);
9034
8335
  }
9035
8336
  },
9036
8337
  answers: {
@@ -9130,15 +8431,33 @@ function createLucernClient(config = {}) {
9130
8431
  raw: ontologyClient
9131
8432
  },
9132
8433
  coordination: {
9133
- registerSession: functionSurfaceClient.registerSession,
9134
- heartbeatSession: functionSurfaceClient.heartbeatSession,
9135
- endSession: functionSurfaceClient.endSession,
9136
- listActiveSessions: functionSurfaceClient.listActiveSessions,
9137
- sendAgentMessage: functionSurfaceClient.sendAgentMessage,
9138
- broadcastMessage: functionSurfaceClient.broadcastMessage,
9139
- getInbox: functionSurfaceClient.getAgentInbox,
9140
- getAgentInbox: functionSurfaceClient.getAgentInbox,
9141
- claimFiles: functionSurfaceClient.claimFiles
8434
+ registerSession(input = {}, idempotencyKey) {
8435
+ return functionSurfaceClient.registerSession(input, idempotencyKey);
8436
+ },
8437
+ heartbeatSession(input = {}, idempotencyKey) {
8438
+ return functionSurfaceClient.heartbeatSession(input, idempotencyKey);
8439
+ },
8440
+ endSession(input = {}, idempotencyKey) {
8441
+ return functionSurfaceClient.endSession(input, idempotencyKey);
8442
+ },
8443
+ listActiveSessions(input = {}) {
8444
+ return functionSurfaceClient.listActiveSessions(input);
8445
+ },
8446
+ sendAgentMessage(input, idempotencyKey) {
8447
+ return functionSurfaceClient.sendAgentMessage(input, idempotencyKey);
8448
+ },
8449
+ broadcastMessage(input, idempotencyKey) {
8450
+ return functionSurfaceClient.broadcastMessage(input, idempotencyKey);
8451
+ },
8452
+ getInbox(input = {}) {
8453
+ return functionSurfaceClient.getAgentInbox(input);
8454
+ },
8455
+ getAgentInbox(input = {}) {
8456
+ return functionSurfaceClient.getAgentInbox(input);
8457
+ },
8458
+ claimFiles(input, idempotencyKey) {
8459
+ return functionSurfaceClient.claimFiles(input, idempotencyKey);
8460
+ }
9142
8461
  },
9143
8462
  policy: {
9144
8463
  checkPermission(input) {
@@ -9169,24 +8488,38 @@ function createLucernClient(config = {}) {
9169
8488
  principalId: typeof input.principalId === "string" ? input.principalId : void 0
9170
8489
  });
9171
8490
  },
9172
- // Backward compatibility shim: keep the policy namespace exposing the
9173
- // historical manageWritePolicy entry point.
9174
8491
  manageWritePolicy(input, idempotencyKey) {
9175
8492
  return functionSurfaceClient.manageWritePolicy(input, idempotencyKey);
9176
8493
  },
9177
8494
  raw: policyClient
9178
8495
  },
9179
8496
  observations: {
9180
- ingest: functionSurfaceClient.ingestObservation,
9181
- ingestObservation: functionSurfaceClient.ingestObservation,
9182
- getContext: functionSurfaceClient.getObservationContext,
9183
- getObservationContext: functionSurfaceClient.getObservationContext
8497
+ ingest(input, idempotencyKey) {
8498
+ return functionSurfaceClient.ingestObservation(input, idempotencyKey);
8499
+ },
8500
+ ingestObservation(input, idempotencyKey) {
8501
+ return functionSurfaceClient.ingestObservation(input, idempotencyKey);
8502
+ },
8503
+ getContext(input) {
8504
+ return functionSurfaceClient.getObservationContext(input);
8505
+ },
8506
+ getObservationContext(input) {
8507
+ return functionSurfaceClient.getObservationContext(input);
8508
+ }
9184
8509
  },
9185
8510
  coding: {
9186
- getCodeContext: functionSurfaceClient.getCodeContext,
9187
- getChangeHistory: functionSurfaceClient.getChangeHistory,
9188
- recordAttempt: functionSurfaceClient.recordAttempt,
9189
- getFailureLog: functionSurfaceClient.getFailureLog
8511
+ getCodeContext(input) {
8512
+ return functionSurfaceClient.getCodeContext(input);
8513
+ },
8514
+ getChangeHistory(input) {
8515
+ return functionSurfaceClient.getChangeHistory(input);
8516
+ },
8517
+ recordAttempt(input, idempotencyKey) {
8518
+ return functionSurfaceClient.recordAttempt(input, idempotencyKey);
8519
+ },
8520
+ getFailureLog(input) {
8521
+ return functionSurfaceClient.getFailureLog(input);
8522
+ }
9190
8523
  },
9191
8524
  contracts: {
9192
8525
  create(input) {
@@ -9212,19 +8545,19 @@ function createLucernClient(config = {}) {
9212
8545
  }
9213
8546
  },
9214
8547
  bootstrap: {
9215
- generateSessionHandoff: functionSurfaceClient.generateSessionHandoff
8548
+ generateSessionHandoff(input) {
8549
+ return functionSurfaceClient.generateSessionHandoff(input);
8550
+ }
9216
8551
  },
9217
8552
  embeddings: embeddingsClient,
9218
8553
  graphAnalysis: graphAnalysisClient,
9219
8554
  graphRecommendations: graphRecommendationsClient,
9220
8555
  orgGraphSearch: orgGraphSearchClient,
9221
- ontologyLinks: ontologyLinksNamespace,
8556
+ ontologyLinks: ontologyLinksClient,
9222
8557
  graphStateClassifier: graphStateClassifierClient,
9223
8558
  modelRuntime: modelRuntimeClient,
9224
8559
  jobs: jobsClient,
9225
8560
  telemetry: telemetryClient,
9226
- publication: publicationNamespace,
9227
- contentPublication: publicationNamespace,
9228
8561
  tools: {
9229
8562
  listCatalog: toolRegistryClient.listCatalog,
9230
8563
  listExecutable: toolRegistryClient.listExecutable,
@@ -9234,15 +8567,25 @@ function createLucernClient(config = {}) {
9234
8567
  createAcl: toolRegistryClient.createAcl,
9235
8568
  deleteAcl: toolRegistryClient.deleteAcl,
9236
8569
  registerCustomTool: toolRegistryClient.registerCustomTool,
9237
- register: registerCustomTool,
9238
- unregister: unregisterCustomTool,
9239
- list: listRegisteredCustomTools,
9240
- clear: clearRegisteredCustomTools,
8570
+ register(registration) {
8571
+ return registerCustomTool(registration);
8572
+ },
8573
+ unregister(fullName) {
8574
+ return unregisterCustomTool(fullName);
8575
+ },
8576
+ list() {
8577
+ return listRegisteredCustomTools();
8578
+ },
8579
+ clear() {
8580
+ clearRegisteredCustomTools();
8581
+ },
9241
8582
  invoke(name, input = {}) {
9242
- const fullName = resolveCustomToolFullName(name);
8583
+ const fullName = name.includes(".") ? name : `custom.${name}`;
9243
8584
  return invokeCustomTool(fullName, input);
9244
8585
  },
9245
- namespace: getCustomNamespace
8586
+ namespace(namespace) {
8587
+ return getCustomNamespace(namespace);
8588
+ }
9246
8589
  },
9247
8590
  packs: {
9248
8591
  /**
@@ -9257,25 +8600,31 @@ function createLucernClient(config = {}) {
9257
8600
  get isInstalled() {
9258
8601
  return _packInstalled;
9259
8602
  },
9260
- listCatalog: packsClient.listCatalog,
9261
- catalog: packsClient.listCatalog,
9262
- listStates: packsClient.listStates,
9263
- states: packsClient.getStates,
9264
- install: packsClient.install,
9265
- enable: packsClient.enable,
9266
- disable: packsClient.disable
9267
- },
9268
- nodes: nodesNamespace,
9269
- controlPlane: {
9270
- identity: {
9271
- resolveInteractivePrincipal: controlPlaneClient.identity.resolveInteractivePrincipal
8603
+ listCatalog() {
8604
+ return packsClient.listCatalog();
8605
+ },
8606
+ catalog() {
8607
+ return packsClient.getCatalog();
8608
+ },
8609
+ listStates(scope) {
8610
+ return packsClient.listStates(scope);
9272
8611
  },
9273
- raw: controlPlaneClient
8612
+ states(scope) {
8613
+ return packsClient.getStates(scope);
8614
+ },
8615
+ install(input) {
8616
+ return packsClient.install(input);
8617
+ },
8618
+ enable(input) {
8619
+ return packsClient.enable(input);
8620
+ },
8621
+ disable(input) {
8622
+ return packsClient.disable(input);
8623
+ }
9274
8624
  },
8625
+ nodes: nodesNamespace,
9275
8626
  identity: {
9276
8627
  ...identityFacade,
9277
- access: accessControlClient,
9278
- resolveInteractivePrincipal: identityClient.resolveInteractivePrincipal,
9279
8628
  evaluatePolicy: identityClient.evaluatePolicy,
9280
8629
  recordPolicyDecision: identityClient.recordPolicyDecision,
9281
8630
  putSecretReference: identityClient.putSecretReference,
@@ -9284,16 +8633,30 @@ function createLucernClient(config = {}) {
9284
8633
  raw: identityClient
9285
8634
  },
9286
8635
  mcp: {
9287
- bootstrapSession: mcpClient.bootstrapSession,
9288
- checkWritePolicy: mcpClient.checkWritePolicy,
9289
- beginBuildSession: mcpClient.beginBuildSession,
9290
- evaluateEngineeringContract: mcpClient.evaluateEngineeringContract,
9291
- evaluateResearchContract: mcpClient.evaluateResearchContract
8636
+ bootstrapSession(input) {
8637
+ return mcpClient.bootstrapSession(input);
8638
+ },
8639
+ checkWritePolicy(input) {
8640
+ return mcpClient.checkWritePolicy(input);
8641
+ },
8642
+ beginBuildSession(input) {
8643
+ return mcpClient.beginBuildSession(input);
8644
+ },
8645
+ evaluateEngineeringContract(input) {
8646
+ return mcpClient.evaluateEngineeringContract(input);
8647
+ },
8648
+ evaluateResearchContract(input) {
8649
+ return mcpClient.evaluateResearchContract(input);
8650
+ }
9292
8651
  },
9293
8652
  auth: {
9294
8653
  device: {
9295
- createCode: authDeviceClient.createDeviceCode,
9296
- pollToken: authDeviceClient.pollDeviceToken
8654
+ createCode(input) {
8655
+ return authDeviceClient.createDeviceCode(input);
8656
+ },
8657
+ pollToken(deviceCode) {
8658
+ return authDeviceClient.pollDeviceToken(deviceCode);
8659
+ }
9297
8660
  }
9298
8661
  },
9299
8662
  custom: getCustomNamespace("custom"),
@@ -9320,7 +8683,6 @@ function createLucernClient(config = {}) {
9320
8683
  ontologyLinks: ontologyLinksClient,
9321
8684
  orgGraphSearch: orgGraphSearchClient,
9322
8685
  functionSurface: functionSurfaceClient,
9323
- controlPlane: controlPlaneClient,
9324
8686
  toolRegistry: toolRegistryClient,
9325
8687
  modelRuntime: modelRuntimeClient,
9326
8688
  packs: packsClient,
@@ -9345,8 +8707,6 @@ function createTopicsClient2(config = {}) {
9345
8707
  updateTopic: topics.update,
9346
8708
  getTopicTree: topics.getTree,
9347
8709
  getTopicCoverage: topics.coverage,
9348
- materializeTopicGraph: topics.materializeTopicGraph,
9349
- getTopicGraphSpine: topics.getTopicGraphSpine,
9350
8710
  removeTopic: topics.remove,
9351
8711
  raw: topics
9352
8712
  };