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