@lucern/sdk 0.3.0-alpha.6 → 0.3.0-alpha.8

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 (176) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +4 -4
  3. package/dist/adminClient.d.ts +8 -8
  4. package/dist/adminClient.js +47 -36
  5. package/dist/adminClient.js.map +1 -1
  6. package/dist/answersClient.js +26 -8
  7. package/dist/answersClient.js.map +1 -1
  8. package/dist/audience/index.d.ts +2 -1
  9. package/dist/audience/index.js +1 -3
  10. package/dist/audience/index.js.map +1 -1
  11. package/dist/audiencesClient.d.ts +16 -16
  12. package/dist/audiencesClient.js +102 -87
  13. package/dist/audiencesClient.js.map +1 -1
  14. package/dist/auditClient.js +30 -10
  15. package/dist/auditClient.js.map +1 -1
  16. package/dist/authDeviceClient.js +16 -3
  17. package/dist/authDeviceClient.js.map +1 -1
  18. package/dist/beliefs/index.d.ts +3 -3
  19. package/dist/beliefs/index.js +543 -776
  20. package/dist/beliefs/index.js.map +1 -1
  21. package/dist/beliefsClient.d.ts +2 -2
  22. package/dist/beliefsClient.js +31 -19
  23. package/dist/beliefsClient.js.map +1 -1
  24. package/dist/boundaryClientSurface.js +10 -3
  25. package/dist/boundaryClientSurface.js.map +1 -1
  26. package/dist/client.d.ts +247 -270
  27. package/dist/client.js +543 -776
  28. package/dist/client.js.map +1 -1
  29. package/dist/clientHelpers.d.ts +29 -0
  30. package/dist/clientHelpers.js +122 -0
  31. package/dist/clientHelpers.js.map +1 -0
  32. package/dist/contextClient.d.ts +4 -3
  33. package/dist/contextClient.js +56 -26
  34. package/dist/contextClient.js.map +1 -1
  35. package/dist/contextFacade.js +25 -16
  36. package/dist/contextFacade.js.map +1 -1
  37. package/dist/contextPackCompiler.js +19 -30
  38. package/dist/contextPackCompiler.js.map +1 -1
  39. package/dist/contextPackPolicy.js +7 -17
  40. package/dist/contextPackPolicy.js.map +1 -1
  41. package/dist/contextTypes.d.ts +2 -0
  42. package/dist/contracts/index.js +4 -3
  43. package/dist/contracts/index.js.map +1 -1
  44. package/dist/contracts/lens-filter.contract.js +4 -3
  45. package/dist/contracts/lens-filter.contract.js.map +1 -1
  46. package/dist/contracts/lens-workflow.contract.js +4 -3
  47. package/dist/contracts/lens-workflow.contract.js.map +1 -1
  48. package/dist/contracts/lensFilter.js +4 -3
  49. package/dist/contracts/lensFilter.js.map +1 -1
  50. package/dist/contracts/lensWorkflow.js +4 -3
  51. package/dist/contracts/lensWorkflow.js.map +1 -1
  52. package/dist/contradictions/index.d.ts +2 -2
  53. package/dist/contradictions/index.js +543 -776
  54. package/dist/contradictions/index.js.map +1 -1
  55. package/dist/coreClient.d.ts +2 -1
  56. package/dist/coreClient.js +27 -11
  57. package/dist/coreClient.js.map +1 -1
  58. package/dist/decisions/index.d.ts +12 -12
  59. package/dist/decisions/index.js +543 -776
  60. package/dist/decisions/index.js.map +1 -1
  61. package/dist/decisionsClient.d.ts +4 -12
  62. package/dist/decisionsClient.js +37 -31
  63. package/dist/decisionsClient.js.map +1 -1
  64. package/dist/edges/index.d.ts +2 -2
  65. package/dist/edges/index.js +543 -776
  66. package/dist/edges/index.js.map +1 -1
  67. package/dist/embeddingsClient.js +37 -14
  68. package/dist/embeddingsClient.js.map +1 -1
  69. package/dist/eventingClient.js +37 -14
  70. package/dist/eventingClient.js.map +1 -1
  71. package/dist/events.js +6 -3
  72. package/dist/events.js.map +1 -1
  73. package/dist/eventsCore.d.ts +1 -1
  74. package/dist/eventsCore.js +27 -11
  75. package/dist/eventsCore.js.map +1 -1
  76. package/dist/evidence/index.d.ts +2 -2
  77. package/dist/evidence/index.js +543 -776
  78. package/dist/evidence/index.js.map +1 -1
  79. package/dist/evidenceClient.js +27 -11
  80. package/dist/evidenceClient.js.map +1 -1
  81. package/dist/facade/context.d.ts +2 -1
  82. package/dist/facade/context.js +25 -16
  83. package/dist/facade/context.js.map +1 -1
  84. package/dist/functionSurface.js +27 -11
  85. package/dist/functionSurface.js.map +1 -1
  86. package/dist/functionSurfaceClient.js +27 -11
  87. package/dist/functionSurfaceClient.js.map +1 -1
  88. package/dist/gatewayFacades.d.ts +27 -45
  89. package/dist/gatewayFacades.js +92 -118
  90. package/dist/gatewayFacades.js.map +1 -1
  91. package/dist/graphAnalysisClient.js +31 -12
  92. package/dist/graphAnalysisClient.js.map +1 -1
  93. package/dist/graphClient.d.ts +5 -13
  94. package/dist/graphClient.js +42 -35
  95. package/dist/graphClient.js.map +1 -1
  96. package/dist/graphRecommendationsClient.js +31 -13
  97. package/dist/graphRecommendationsClient.js.map +1 -1
  98. package/dist/graphStateClassifierClient.js +37 -15
  99. package/dist/graphStateClassifierClient.js.map +1 -1
  100. package/dist/harnessClient.d.ts +13 -24
  101. package/dist/harnessClient.js +38 -37
  102. package/dist/harnessClient.js.map +1 -1
  103. package/dist/identityClient.d.ts +8 -8
  104. package/dist/identityClient.js +48 -31
  105. package/dist/identityClient.js.map +1 -1
  106. package/dist/index.d.ts +2 -2
  107. package/dist/index.js +647 -853
  108. package/dist/index.js.map +1 -1
  109. package/dist/infisicalRuntime.js +47 -24
  110. package/dist/infisicalRuntime.js.map +1 -1
  111. package/dist/jobsClient.js +37 -15
  112. package/dist/jobsClient.js.map +1 -1
  113. package/dist/learningClient.d.ts +6 -6
  114. package/dist/learningClient.js +55 -39
  115. package/dist/learningClient.js.map +1 -1
  116. package/dist/lenses/index.d.ts +29 -35
  117. package/dist/lenses/index.js +543 -776
  118. package/dist/lenses/index.js.map +1 -1
  119. package/dist/mcpClient.js +26 -8
  120. package/dist/mcpClient.js.map +1 -1
  121. package/dist/modelRuntimeClient.js +37 -14
  122. package/dist/modelRuntimeClient.js.map +1 -1
  123. package/dist/nodes/index.d.ts +17 -17
  124. package/dist/nodes/index.js +543 -776
  125. package/dist/nodes/index.js.map +1 -1
  126. package/dist/ontologies/index.d.ts +31 -30
  127. package/dist/ontologies/index.js +543 -776
  128. package/dist/ontologies/index.js.map +1 -1
  129. package/dist/ontologyClient.d.ts +17 -25
  130. package/dist/ontologyClient.js +63 -37
  131. package/dist/ontologyClient.js.map +1 -1
  132. package/dist/ontologyLinksClient.js +37 -15
  133. package/dist/ontologyLinksClient.js.map +1 -1
  134. package/dist/orgGraphSearchClient.js +30 -10
  135. package/dist/orgGraphSearchClient.js.map +1 -1
  136. package/dist/packsClient.d.ts +9 -23
  137. package/dist/packsClient.js +39 -43
  138. package/dist/packsClient.js.map +1 -1
  139. package/dist/policyClient.d.ts +11 -10
  140. package/dist/policyClient.js +48 -22
  141. package/dist/policyClient.js.map +1 -1
  142. package/dist/questions/index.d.ts +2 -2
  143. package/dist/questions/index.js +543 -776
  144. package/dist/questions/index.js.map +1 -1
  145. package/dist/realtime/index.d.ts +1 -1
  146. package/dist/reportsClient.d.ts +7 -7
  147. package/dist/reportsClient.js +84 -48
  148. package/dist/reportsClient.js.map +1 -1
  149. package/dist/schemaClient.d.ts +3 -3
  150. package/dist/schemaClient.js +40 -26
  151. package/dist/schemaClient.js.map +1 -1
  152. package/dist/sdkSurface.d.ts +6 -3
  153. package/dist/sdkSurface.js +10 -6
  154. package/dist/sdkSurface.js.map +1 -1
  155. package/dist/sourcesClient.js +27 -11
  156. package/dist/sourcesClient.js.map +1 -1
  157. package/dist/telemetryClient.js +37 -15
  158. package/dist/telemetryClient.js.map +1 -1
  159. package/dist/toolRegistryClient.d.ts +10 -2
  160. package/dist/toolRegistryClient.js +50 -16
  161. package/dist/toolRegistryClient.js.map +1 -1
  162. package/dist/topics/index.d.ts +5 -5
  163. package/dist/topics/index.js +543 -776
  164. package/dist/topics/index.js.map +1 -1
  165. package/dist/topicsClient.js +37 -16
  166. package/dist/topicsClient.js.map +1 -1
  167. package/dist/version.d.ts +1 -1
  168. package/dist/version.js +1 -1
  169. package/dist/version.js.map +1 -1
  170. package/dist/workflowClient.d.ts +15 -33
  171. package/dist/workflowClient.js +43 -50
  172. package/dist/workflowClient.js.map +1 -1
  173. package/dist/worktrees/index.d.ts +22 -30
  174. package/dist/worktrees/index.js +543 -776
  175. package/dist/worktrees/index.js.map +1 -1
  176. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -112,6 +112,7 @@ __export(src_exports, {
112
112
  WORKTREE_PHASES: () => WORKTREE_PHASES,
113
113
  applyInfisicalRuntimeEnv: () => applyInfisicalRuntimeEnv,
114
114
  asListItems: () => asListItems,
115
+ asRecord: () => asRecord,
115
116
  assertValidWebhookSecret: () => assertValidWebhookSecret,
116
117
  assertValidWebhookUrl: () => assertValidWebhookUrl,
117
118
  buildDeprecatedBranchMetadata: () => buildDeprecatedBranchMetadata,
@@ -183,6 +184,7 @@ __export(src_exports, {
183
184
  isLensFilterCriteria: () => isLensFilterCriteria,
184
185
  isLucernPrompt: () => isLucernPrompt,
185
186
  isMcpToolAllowed: () => isMcpToolAllowed,
187
+ isRecord: () => isRecord2,
186
188
  isTaxonomyFilterCriteriaV1: () => isTaxonomyFilterCriteriaV1,
187
189
  lastDelegator: () => lastDelegator,
188
190
  listControlObjectOwnershipCases: () => listControlObjectOwnershipCases,
@@ -491,9 +493,7 @@ function generatePortableRequestId() {
491
493
  8
492
494
  ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
493
495
  }
494
- function randomIdempotencyKey() {
495
- return generatePortableRequestId();
496
- }
496
+ var randomIdempotencyKey = generatePortableRequestId;
497
497
  function isRetryableStatus(status) {
498
498
  return status >= 500 || status === 408 || status === 429;
499
499
  }
@@ -558,8 +558,11 @@ function timeoutError(timeoutMs) {
558
558
  error.name = "AbortError";
559
559
  return error;
560
560
  }
561
+ function isRecord(value) {
562
+ return value !== null && typeof value === "object" && !Array.isArray(value);
563
+ }
561
564
  function readPolicySummaryFromDetails(details) {
562
- if (!details || typeof details !== "object" || Array.isArray(details)) {
565
+ if (!isRecord(details)) {
563
566
  return null;
564
567
  }
565
568
  const directSummary = details.summary;
@@ -567,11 +570,11 @@ function readPolicySummaryFromDetails(details) {
567
570
  return directSummary.trim();
568
571
  }
569
572
  const policy = details.policy;
570
- if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
573
+ if (!isRecord(policy)) {
571
574
  return null;
572
575
  }
573
576
  const explanation = policy.explanation;
574
- if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
577
+ if (!isRecord(explanation)) {
575
578
  return null;
576
579
  }
577
580
  const nestedSummary = explanation.summary;
@@ -635,11 +638,11 @@ function createGatewayRequestClient(config = {}) {
635
638
  if (!text) {
636
639
  return null;
637
640
  }
638
- try {
639
- return JSON.parse(text);
640
- } catch {
641
+ const parsed = tryParseGatewayEnvelopeJson(text);
642
+ if (!parsed.ok) {
641
643
  return null;
642
644
  }
645
+ return isRecord(parsed.value) ? parsed.value : null;
643
646
  }
644
647
  function resolveTimeoutMs(method, requestTimeoutMs) {
645
648
  if (typeof requestTimeoutMs === "number") {
@@ -651,16 +654,31 @@ function createGatewayRequestClient(config = {}) {
651
654
  }
652
655
  return config.timeoutMs ?? 15e3;
653
656
  }
657
+ function tryParseGatewayEnvelopeJson(text) {
658
+ const trimmed = text.trim();
659
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
660
+ return { ok: false, reason: "non-json" };
661
+ }
662
+ try {
663
+ return { ok: true, value: JSON.parse(trimmed) };
664
+ } catch (error) {
665
+ if (error instanceof SyntaxError) {
666
+ return { ok: false, reason: "invalid-json", error };
667
+ }
668
+ throw error;
669
+ }
670
+ }
654
671
  function buildApiError(args) {
655
672
  const failure = args.failure;
656
- const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
673
+ const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
657
674
  const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
658
675
  const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
659
676
  const details = failure?.details ?? legacyError?.details;
660
677
  const policySummary = readPolicySummaryFromDetails(details);
678
+ const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
661
679
  return new LucernApiError({
662
680
  code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
663
- message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
681
+ message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
664
682
  status: args.response.status,
665
683
  invariant: failure?.invariant,
666
684
  suggestion: failure?.suggestion,
@@ -786,8 +804,11 @@ function createGatewayRequestClient(config = {}) {
786
804
  }
787
805
 
788
806
  // src/sdkSurface.ts
807
+ function isRecord2(value) {
808
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
809
+ }
789
810
  function asRecord(value) {
790
- return value && typeof value === "object" ? value : {};
811
+ return isRecord2(value) ? value : {};
791
812
  }
792
813
  function cleanString2(value) {
793
814
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
@@ -848,9 +869,7 @@ function normalizeNodeWriteInput(value) {
848
869
  }
849
870
  return next;
850
871
  }
851
- function normalizeNodeVerificationStatus(value) {
852
- return normalizeVerificationStatus(value);
853
- }
872
+ var normalizeNodeVerificationStatus = normalizeVerificationStatus;
854
873
  function normalizeTopicQuery(value) {
855
874
  const topicId = cleanString2(value.topicId);
856
875
  if (!topicId) {
@@ -877,7 +896,10 @@ function createListResult(items, legacyKey) {
877
896
  total: items.length
878
897
  };
879
898
  if (legacyKey) {
880
- result[legacyKey] = items;
899
+ return {
900
+ ...result,
901
+ [legacyKey]: items
902
+ };
881
903
  }
882
904
  return result;
883
905
  }
@@ -921,6 +943,17 @@ function asTenantVaultSecretArray(data) {
921
943
  }
922
944
  function createAdminClient(config = {}) {
923
945
  const gateway = createGatewayRequestClient(config);
946
+ const getControlObjectOwnership = async () => gateway.request({
947
+ path: "/api/platform/v1/admin/control-ownership"
948
+ });
949
+ const createMembership = async (input, idempotencyKey) => gateway.request({
950
+ path: "/api/platform/v1/memberships",
951
+ method: "POST",
952
+ body: input,
953
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
954
+ });
955
+ const updateMembership = createMembership;
956
+ const upsertMembership = createMembership;
924
957
  return {
925
958
  /**
926
959
  * List tenants visible to the current principal.
@@ -952,19 +985,11 @@ function createAdminClient(config = {}) {
952
985
  /**
953
986
  * Get the control-object ownership contract.
954
987
  */
955
- async getControlObjectOwnership() {
956
- return gateway.request({
957
- path: "/api/platform/v1/admin/control-ownership"
958
- });
959
- },
988
+ getControlObjectOwnership,
960
989
  /**
961
990
  * @deprecated Use getControlObjectOwnership.
962
991
  */
963
- async getControlObjectOwnershipContract() {
964
- return gateway.request({
965
- path: "/api/platform/v1/admin/control-ownership"
966
- });
967
- },
992
+ getControlObjectOwnershipContract: getControlObjectOwnership,
968
993
  /**
969
994
  * List workspaces for the current admin scope.
970
995
  */
@@ -1011,26 +1036,15 @@ function createAdminClient(config = {}) {
1011
1036
  /**
1012
1037
  * Create a membership.
1013
1038
  */
1014
- async createMembership(input, idempotencyKey) {
1015
- return gateway.request({
1016
- path: "/api/platform/v1/memberships",
1017
- method: "POST",
1018
- body: input,
1019
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1020
- });
1021
- },
1039
+ createMembership,
1022
1040
  /**
1023
1041
  * Update a membership.
1024
1042
  */
1025
- async updateMembership(input, idempotencyKey) {
1026
- return this.createMembership(input, idempotencyKey);
1027
- },
1043
+ updateMembership,
1028
1044
  /**
1029
1045
  * @deprecated Use createMembership or updateMembership.
1030
1046
  */
1031
- async upsertMembership(input, idempotencyKey) {
1032
- return this.createMembership(input, idempotencyKey);
1033
- },
1047
+ upsertMembership,
1034
1048
  /**
1035
1049
  * List tenant API keys in the current admin scope.
1036
1050
  */
@@ -1312,115 +1326,111 @@ function createAnswersClient(config = {}) {
1312
1326
  // src/audiencesClient.ts
1313
1327
  function createAudiencesClient(config = {}) {
1314
1328
  const gateway = createGatewayRequestClient(config);
1329
+ const listRegistry = async (query5 = {}) => {
1330
+ return gateway.request({
1331
+ path: `/api/platform/v1/audiences/registry${toQueryString({
1332
+ ...query5,
1333
+ effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1334
+ status: query5.status
1335
+ })}`
1336
+ }).then(
1337
+ (response) => mapGatewayData(
1338
+ response,
1339
+ (data) => createListResult(Array.isArray(data) ? data : [], "registryEntries")
1340
+ )
1341
+ );
1342
+ };
1343
+ const createRegistryEntry = async (input, idempotencyKey) => {
1344
+ return gateway.request({
1345
+ path: "/api/platform/v1/audiences/registry",
1346
+ method: "POST",
1347
+ body: input,
1348
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1349
+ });
1350
+ };
1351
+ const updateRegistryEntry = createRegistryEntry;
1352
+ const upsertRegistry = createRegistryEntry;
1353
+ const getRegistry = listRegistry;
1354
+ const listGrants = async (query5 = {}) => {
1355
+ return gateway.request({
1356
+ path: `/api/platform/v1/audiences/grants${toQueryString({
1357
+ ...query5,
1358
+ audienceKey: query5.audienceKey,
1359
+ principalId: query5.principalId,
1360
+ groupId: query5.groupId,
1361
+ status: query5.status
1362
+ })}`
1363
+ }).then(
1364
+ (response) => mapGatewayData(
1365
+ response,
1366
+ (data) => createListResult(Array.isArray(data) ? data : [], "grants")
1367
+ )
1368
+ );
1369
+ };
1370
+ const createGrant = async (input, idempotencyKey) => {
1371
+ return gateway.request({
1372
+ path: "/api/platform/v1/audiences/grants",
1373
+ method: "POST",
1374
+ body: input,
1375
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1376
+ });
1377
+ };
1378
+ const getGrants = listGrants;
1379
+ const grant = createGrant;
1380
+ const deleteGrant = async (input, idempotencyKey) => {
1381
+ return gateway.request({
1382
+ path: "/api/platform/v1/audiences/grants/revoke",
1383
+ method: "POST",
1384
+ body: input,
1385
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1386
+ });
1387
+ };
1388
+ const revokeGrant = deleteGrant;
1315
1389
  return {
1316
1390
  /**
1317
1391
  * List audience registry entries.
1318
1392
  */
1319
- async listRegistry(query5 = {}) {
1320
- return gateway.request({
1321
- path: `/api/platform/v1/audiences/registry${toQueryString({
1322
- ...query5,
1323
- effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1324
- status: query5.status
1325
- })}`
1326
- }).then(
1327
- (response) => mapGatewayData(
1328
- response,
1329
- (data) => createListResult(
1330
- Array.isArray(data) ? data : [],
1331
- "registryEntries"
1332
- )
1333
- )
1334
- );
1335
- },
1393
+ listRegistry,
1336
1394
  /**
1337
1395
  * @deprecated Use listRegistry.
1338
1396
  */
1339
- async getRegistry(query5 = {}) {
1340
- return this.listRegistry(query5);
1341
- },
1397
+ getRegistry,
1342
1398
  /**
1343
1399
  * Create an audience registry entry.
1344
1400
  */
1345
- async createRegistryEntry(input, idempotencyKey) {
1346
- return gateway.request({
1347
- path: "/api/platform/v1/audiences/registry",
1348
- method: "POST",
1349
- body: input,
1350
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1351
- });
1352
- },
1401
+ createRegistryEntry,
1353
1402
  /**
1354
1403
  * Update an audience registry entry.
1355
1404
  */
1356
- async updateRegistryEntry(input, idempotencyKey) {
1357
- return this.createRegistryEntry(input, idempotencyKey);
1358
- },
1405
+ updateRegistryEntry,
1359
1406
  /**
1360
1407
  * @deprecated Use createRegistryEntry or updateRegistryEntry.
1361
1408
  */
1362
- async upsertRegistry(input, idempotencyKey) {
1363
- return this.createRegistryEntry(input, idempotencyKey);
1364
- },
1409
+ upsertRegistry,
1365
1410
  /**
1366
1411
  * List audience grants.
1367
1412
  */
1368
- async listGrants(query5 = {}) {
1369
- return gateway.request({
1370
- path: `/api/platform/v1/audiences/grants${toQueryString({
1371
- ...query5,
1372
- audienceKey: query5.audienceKey,
1373
- principalId: query5.principalId,
1374
- groupId: query5.groupId,
1375
- status: query5.status
1376
- })}`
1377
- }).then(
1378
- (response) => mapGatewayData(
1379
- response,
1380
- (data) => createListResult(Array.isArray(data) ? data : [], "grants")
1381
- )
1382
- );
1383
- },
1413
+ listGrants,
1384
1414
  /**
1385
1415
  * @deprecated Use listGrants.
1386
1416
  */
1387
- async getGrants(query5 = {}) {
1388
- return this.listGrants(query5);
1389
- },
1417
+ getGrants,
1390
1418
  /**
1391
1419
  * Create an audience grant.
1392
1420
  */
1393
- async createGrant(input, idempotencyKey) {
1394
- return gateway.request({
1395
- path: "/api/platform/v1/audiences/grants",
1396
- method: "POST",
1397
- body: input,
1398
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1399
- });
1400
- },
1421
+ createGrant,
1401
1422
  /**
1402
1423
  * @deprecated Use createGrant.
1403
1424
  */
1404
- async grant(input, idempotencyKey) {
1405
- return this.createGrant(input, idempotencyKey);
1406
- },
1425
+ grant,
1407
1426
  /**
1408
1427
  * Delete an audience grant by revoking it.
1409
1428
  */
1410
- async deleteGrant(input, idempotencyKey) {
1411
- return gateway.request({
1412
- path: "/api/platform/v1/audiences/grants/revoke",
1413
- method: "POST",
1414
- body: input,
1415
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1416
- });
1417
- },
1429
+ deleteGrant,
1418
1430
  /**
1419
1431
  * @deprecated Use deleteGrant.
1420
1432
  */
1421
- async revokeGrant(input, idempotencyKey) {
1422
- return this.deleteGrant(input, idempotencyKey);
1423
- }
1433
+ revokeGrant
1424
1434
  };
1425
1435
  }
1426
1436
 
@@ -1461,8 +1471,18 @@ function authBaseUrl(config) {
1461
1471
  return config.baseUrl?.replace(/\/+$/, "") ?? "";
1462
1472
  }
1463
1473
  async function readJson(response) {
1464
- const payload = await response.json().catch(() => ({}));
1465
- return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
1474
+ try {
1475
+ const payload = await response.json();
1476
+ return isRecord3(payload) ? payload : {};
1477
+ } catch (error) {
1478
+ return unreadableJsonBodyFallback();
1479
+ }
1480
+ }
1481
+ function unreadableJsonBodyFallback(_error) {
1482
+ return {};
1483
+ }
1484
+ function isRecord3(value) {
1485
+ return value !== null && typeof value === "object" && !Array.isArray(value);
1466
1486
  }
1467
1487
  function readString(value) {
1468
1488
  const normalized = typeof value === "string" ? value.trim() : "";
@@ -1504,7 +1524,10 @@ function assertDeviceTokenResponse(payload) {
1504
1524
  tenant_id: tenantId,
1505
1525
  workspace_id: readString(payload.workspace_id),
1506
1526
  principal_id: principalId,
1507
- user: payload.user && typeof payload.user === "object" && !Array.isArray(payload.user) ? payload.user : void 0
1527
+ user: isRecord3(payload.user) && typeof payload.user.id === "string" && typeof payload.user.principalId === "string" ? {
1528
+ id: payload.user.id,
1529
+ principalId: payload.user.principalId
1530
+ } : void 0
1508
1531
  };
1509
1532
  }
1510
1533
  function maybeThrowDeviceError(payload) {
@@ -1652,12 +1675,12 @@ function createBeliefsClient(config = {}) {
1652
1675
  body: normalizeModulateConfidenceInput(input),
1653
1676
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1654
1677
  });
1655
- async function getOpinionHistory(beliefId) {
1678
+ const getOpinionHistory = async (beliefId) => {
1656
1679
  const response = await gateway.request({
1657
1680
  path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence-history`
1658
1681
  });
1659
1682
  return mapOpinionHistoryEntriesFromGatewayData(response.data);
1660
- }
1683
+ };
1661
1684
  return {
1662
1685
  /**
1663
1686
  * Create a belief within a topic scope.
@@ -1702,13 +1725,9 @@ function createBeliefsClient(config = {}) {
1702
1725
  * trigger = cause of the score change
1703
1726
  * triggeringRef = optional pointer to the evidence or worktree that drove the change
1704
1727
  */
1705
- async getOpinionHistory(beliefId) {
1706
- return getOpinionHistory(beliefId);
1707
- },
1728
+ getOpinionHistory,
1708
1729
  /** @deprecated Use getOpinionHistory(). */
1709
- async getConfidenceHistory(beliefId) {
1710
- return getOpinionHistory(beliefId);
1711
- },
1730
+ getConfidenceHistory: getOpinionHistory,
1712
1731
  /**
1713
1732
  * Fork a scored belief into a new formulation.
1714
1733
  */
@@ -1856,6 +1875,9 @@ function cleanOptionalString(value) {
1856
1875
  const normalized = value?.trim();
1857
1876
  return normalized ? normalized : void 0;
1858
1877
  }
1878
+ function isRecord4(value) {
1879
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1880
+ }
1859
1881
  function cleanRequiredString(value, label) {
1860
1882
  const normalized = cleanOptionalString(value);
1861
1883
  if (!normalized) {
@@ -1895,9 +1917,10 @@ function topicPayload(input, allowed, operation) {
1895
1917
  };
1896
1918
  }
1897
1919
  function listResultFromEnvelope(data, legacyKey) {
1898
- const record = data && typeof data === "object" ? data : {};
1920
+ const record = isRecord4(data) ? data : {};
1921
+ const legacyItems = record[legacyKey];
1899
1922
  return createListResult(
1900
- Array.isArray(record[legacyKey]) ? record[legacyKey] : Array.isArray(data) ? data : [],
1923
+ Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
1901
1924
  legacyKey
1902
1925
  );
1903
1926
  }
@@ -2269,7 +2292,7 @@ async function invokeRegisteredCustomTool(fullName, params, context) {
2269
2292
  // src/ontologyClient.ts
2270
2293
  function createOntologyClient(config = {}) {
2271
2294
  const gateway = createGatewayRequestClient(config);
2272
- return {
2295
+ const client = {
2273
2296
  /**
2274
2297
  * List ontology definitions matching optional filters.
2275
2298
  */
@@ -2278,13 +2301,14 @@ function createOntologyClient(config = {}) {
2278
2301
  path: `/api/platform/v1/ontologies${toQueryString(filters)}`
2279
2302
  }).then(
2280
2303
  (response) => mapGatewayData(response, (data) => {
2281
- const record = data && typeof data === "object" && !Array.isArray(data) ? data : {};
2282
- const ontologies = Array.isArray(record.ontologies) ? record.ontologies : Array.isArray(record.definitions) ? record.definitions : Array.isArray(data) ? data : [];
2283
- const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : ontologies.length;
2304
+ const record = asRecord(data);
2305
+ const ontologies = asListItems(data, "ontologies");
2306
+ const definitions = ontologies.length > 0 ? ontologies : asListItems(data, "definitions");
2307
+ const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : definitions.length;
2284
2308
  return {
2285
2309
  ...record,
2286
- ...createListResult(ontologies, "definitions"),
2287
- ontologies,
2310
+ ...createListResult(definitions, "definitions"),
2311
+ ontologies: definitions,
2288
2312
  total
2289
2313
  };
2290
2314
  })
@@ -2311,18 +2335,6 @@ function createOntologyClient(config = {}) {
2311
2335
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2312
2336
  });
2313
2337
  },
2314
- /**
2315
- * List ontology definitions.
2316
- */
2317
- async listDefinitions(filters = {}) {
2318
- return this.list(filters);
2319
- },
2320
- /**
2321
- * Get an ontology definition.
2322
- */
2323
- async getDefinition(id) {
2324
- return this.get(id);
2325
- },
2326
2338
  /**
2327
2339
  * Create an ontology definition.
2328
2340
  */
@@ -2364,7 +2376,7 @@ function createOntologyClient(config = {}) {
2364
2376
  }).then(
2365
2377
  (response) => mapGatewayData(
2366
2378
  response,
2367
- (data) => createListResult(Array.isArray(data) ? data : [], "versions")
2379
+ (data) => createListResult(asListItems(data, "versions"), "versions")
2368
2380
  )
2369
2381
  );
2370
2382
  },
@@ -2412,20 +2424,19 @@ function createOntologyClient(config = {}) {
2412
2424
  (data) => createListResult(Array.isArray(data) ? data : [], "topics")
2413
2425
  )
2414
2426
  );
2415
- },
2416
- /**
2417
- * @deprecated Use listTopics.
2418
- */
2419
- async listTopicsByOntology(ontologyId) {
2420
- return this.listTopics(ontologyId);
2421
2427
  }
2422
2428
  };
2429
+ return Object.assign(client, {
2430
+ listDefinitions: client.list,
2431
+ getDefinition: client.get,
2432
+ listTopicsByOntology: client.listTopics
2433
+ });
2423
2434
  }
2424
2435
 
2425
2436
  // src/graphClient.ts
2426
2437
  function createGraphClient(config = {}) {
2427
2438
  const gateway = createGatewayRequestClient(config);
2428
- return {
2439
+ const client = {
2429
2440
  /**
2430
2441
  * List graph nodes matching the provided filters.
2431
2442
  */
@@ -2438,12 +2449,6 @@ function createGraphClient(config = {}) {
2438
2449
  (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
2439
2450
  );
2440
2451
  },
2441
- /**
2442
- * @deprecated Use listNodes.
2443
- */
2444
- async queryNodes(query5) {
2445
- return this.listNodes(query5);
2446
- },
2447
2452
  /**
2448
2453
  * Retrieve a single graph node by nodeId or globalId.
2449
2454
  */
@@ -2554,12 +2559,6 @@ function createGraphClient(config = {}) {
2554
2559
  )
2555
2560
  );
2556
2561
  },
2557
- /**
2558
- * @deprecated Use listEdges.
2559
- */
2560
- async queryEdges(query5) {
2561
- return this.listEdges(query5);
2562
- },
2563
2562
  /**
2564
2563
  * Create a graph edge.
2565
2564
  */
@@ -2647,12 +2646,6 @@ function createGraphClient(config = {}) {
2647
2646
  body: normalizeTopicQuery(query5)
2648
2647
  });
2649
2648
  },
2650
- /**
2651
- * Retrieve a graph neighborhood around a root node.
2652
- */
2653
- async getNeighborhood(query5) {
2654
- return this.neighborhood(query5);
2655
- },
2656
2649
  /**
2657
2650
  * Retrieve the shortest known path between two graph nodes.
2658
2651
  */
@@ -2670,6 +2663,11 @@ function createGraphClient(config = {}) {
2670
2663
  });
2671
2664
  }
2672
2665
  };
2666
+ return Object.assign(client, {
2667
+ queryNodes: client.listNodes,
2668
+ queryEdges: client.listEdges,
2669
+ getNeighborhood: client.neighborhood
2670
+ });
2673
2671
  }
2674
2672
 
2675
2673
  // src/identityClient.ts
@@ -2723,6 +2721,13 @@ function createIdentityClient(config = {}) {
2723
2721
  body: input,
2724
2722
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2725
2723
  });
2724
+ const updatePrincipal = (input, idempotencyKey) => requestPrincipalWrite("PATCH", input, idempotencyKey);
2725
+ const deleteKey = (keyId, input = {}, idempotencyKey) => gateway.request({
2726
+ path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
2727
+ method: "POST",
2728
+ body: input,
2729
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2730
+ });
2726
2731
  return {
2727
2732
  /**
2728
2733
  * Resolve the current authenticated identity summary.
@@ -2771,15 +2776,11 @@ function createIdentityClient(config = {}) {
2771
2776
  /**
2772
2777
  * Update a principal.
2773
2778
  */
2774
- async updatePrincipal(input, idempotencyKey) {
2775
- return requestPrincipalWrite("PATCH", input, idempotencyKey);
2776
- },
2779
+ updatePrincipal,
2777
2780
  /**
2778
2781
  * @deprecated Use createPrincipal or updatePrincipal.
2779
2782
  */
2780
- async upsertPrincipal(input, idempotencyKey) {
2781
- return requestPrincipalWrite("PATCH", input, idempotencyKey);
2782
- },
2783
+ upsertPrincipal: updatePrincipal,
2783
2784
  /**
2784
2785
  * List keys in the current identity scope.
2785
2786
  */
@@ -2818,20 +2819,11 @@ function createIdentityClient(config = {}) {
2818
2819
  /**
2819
2820
  * Delete an API key by revoking it.
2820
2821
  */
2821
- async deleteKey(keyId, input = {}, idempotencyKey) {
2822
- return gateway.request({
2823
- path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
2824
- method: "POST",
2825
- body: input,
2826
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2827
- });
2828
- },
2822
+ deleteKey,
2829
2823
  /**
2830
2824
  * @deprecated Use deleteKey.
2831
2825
  */
2832
- async revokeKey(keyId, input = {}, idempotencyKey) {
2833
- return this.deleteKey(keyId, input, idempotencyKey);
2834
- },
2826
+ revokeKey: deleteKey,
2835
2827
  /**
2836
2828
  * Search Clerk users by email or display attributes.
2837
2829
  */
@@ -2947,14 +2939,11 @@ function createIdentityClient(config = {}) {
2947
2939
  }
2948
2940
 
2949
2941
  // src/topicsClient.ts
2950
- function asRecord3(value) {
2951
- return value && typeof value === "object" ? value : {};
2952
- }
2953
2942
  function cleanString3(value) {
2954
2943
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
2955
2944
  }
2956
2945
  function normalizeTopicRecord(value) {
2957
- const record = asRecord3(value);
2946
+ const record = asRecord(value);
2958
2947
  const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
2959
2948
  return withTopicAlias({
2960
2949
  ...record,
@@ -2979,7 +2968,7 @@ function createTopicsClient(config = {}) {
2979
2968
  })}`
2980
2969
  }).then(
2981
2970
  (response) => mapGatewayData(response, (data) => {
2982
- const record = asRecord3(data);
2971
+ const record = asRecord(data);
2983
2972
  const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
2984
2973
  return {
2985
2974
  ...createListResult(items, "topics"),
@@ -2996,7 +2985,7 @@ function createTopicsClient(config = {}) {
2996
2985
  }).then(
2997
2986
  (response) => mapGatewayData(
2998
2987
  response,
2999
- (data) => normalizeTopicRecord(asRecord3(data).topic ?? data)
2988
+ (data) => normalizeTopicRecord(asRecord(data).topic ?? data)
3000
2989
  )
3001
2990
  );
3002
2991
  },
@@ -3032,7 +3021,7 @@ function createTopicsClient(config = {}) {
3032
3021
  )}`
3033
3022
  }).then(
3034
3023
  (response) => mapGatewayData(response, (data) => {
3035
- const record = asRecord3(data);
3024
+ const record = asRecord(data);
3036
3025
  return {
3037
3026
  tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
3038
3027
  };
@@ -3451,7 +3440,7 @@ function createEventsFacade(config = {}) {
3451
3440
  function createGraphFacade(config = {}) {
3452
3441
  const graphClient = createGraphClient(config);
3453
3442
  const gateway = createGatewayRequestClient(config);
3454
- return {
3443
+ const graphFacade = {
3455
3444
  async neighborhood(input) {
3456
3445
  return graphClient.neighborhood({
3457
3446
  globalId: input.globalId,
@@ -3459,18 +3448,6 @@ function createGraphFacade(config = {}) {
3459
3448
  maxDepth: input.maxDepth
3460
3449
  });
3461
3450
  },
3462
- async traverse(input) {
3463
- return graphClient.traverse(input);
3464
- },
3465
- async analyze(input = {}) {
3466
- return graphClient.analyze(input);
3467
- },
3468
- async bias(input = {}) {
3469
- return graphClient.bias(input);
3470
- },
3471
- async gaps(input) {
3472
- return graphClient.gaps(input);
3473
- },
3474
3451
  async falsify(input, idempotencyKey = randomIdempotencyKey()) {
3475
3452
  return gateway.request({
3476
3453
  path: "/api/platform/v1/graph/falsify",
@@ -3480,6 +3457,12 @@ function createGraphFacade(config = {}) {
3480
3457
  });
3481
3458
  }
3482
3459
  };
3460
+ return Object.assign(graphFacade, {
3461
+ traverse: graphClient.traverse,
3462
+ analyze: graphClient.analyze,
3463
+ bias: graphClient.bias,
3464
+ gaps: graphClient.gaps
3465
+ });
3483
3466
  }
3484
3467
  function createIdentityFacade(config = {}) {
3485
3468
  const identityClient = createIdentityClient(config);
@@ -3493,15 +3476,12 @@ function createIdentityFacade(config = {}) {
3493
3476
  function createOntologiesFacade(config = {}) {
3494
3477
  const ontologyClient = createOntologyClient(config);
3495
3478
  const gateway = createGatewayRequestClient(config);
3496
- return {
3479
+ const ontologyFacade = {
3497
3480
  async get(id) {
3498
3481
  return gateway.request({
3499
3482
  path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
3500
3483
  });
3501
3484
  },
3502
- async list(query5 = {}) {
3503
- return ontologyClient.list(query5);
3504
- },
3505
3485
  async bind(input, idempotencyKey) {
3506
3486
  return gateway.request({
3507
3487
  path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
@@ -3521,6 +3501,9 @@ function createOntologiesFacade(config = {}) {
3521
3501
  });
3522
3502
  }
3523
3503
  };
3504
+ return Object.assign(ontologyFacade, {
3505
+ list: ontologyClient.list
3506
+ });
3524
3507
  }
3525
3508
  function createQuestionsFacade(config = {}) {
3526
3509
  const gateway = createGatewayRequestClient(config);
@@ -3713,15 +3696,9 @@ function createTasksFacade(config = {}) {
3713
3696
  function createTopicsFacade(config = {}) {
3714
3697
  const topicsClient = createTopicsClient(config);
3715
3698
  return {
3716
- async create(input, idempotencyKey) {
3717
- return topicsClient.create(input, idempotencyKey);
3718
- },
3719
- async get(id) {
3720
- return topicsClient.get(id);
3721
- },
3722
- async list(query5 = {}) {
3723
- return topicsClient.list(query5);
3724
- },
3699
+ create: topicsClient.create,
3700
+ get: topicsClient.get,
3701
+ list: topicsClient.list,
3725
3702
  async update(input, idempotencyKey) {
3726
3703
  const { id, ...rest } = input;
3727
3704
  return topicsClient.update(id, rest, idempotencyKey);
@@ -3737,12 +3714,8 @@ function createTopicsFacade(config = {}) {
3737
3714
  maxDepth: input.maxDepth
3738
3715
  });
3739
3716
  },
3740
- async remove(id, idempotencyKey = randomIdempotencyKey()) {
3741
- return topicsClient.remove(id, idempotencyKey);
3742
- },
3743
- async bulkCreate(input, idempotencyKey = randomIdempotencyKey()) {
3744
- return topicsClient.bulkCreate(input, idempotencyKey);
3745
- }
3717
+ remove: topicsClient.remove,
3718
+ bulkCreate: topicsClient.bulkCreate
3746
3719
  };
3747
3720
  }
3748
3721
  function createWebhooksFacade(config = {}) {
@@ -3942,7 +3915,7 @@ function createWorktreesFacade(config = {}) {
3942
3915
  // src/decisionsClient.ts
3943
3916
  function createDecisionsClient(config = {}) {
3944
3917
  const gateway = createGatewayRequestClient(config);
3945
- return {
3918
+ const client = {
3946
3919
  /**
3947
3920
  * List judgments for a topic scope.
3948
3921
  */
@@ -4020,12 +3993,6 @@ function createDecisionsClient(config = {}) {
4020
3993
  })
4021
3994
  );
4022
3995
  },
4023
- /**
4024
- * @deprecated Use listPendingOutcomeReviews.
4025
- */
4026
- async listPendingJudgmentOutcomeReview(query5) {
4027
- return this.listPendingOutcomeReviews(query5);
4028
- },
4029
3996
  /**
4030
3997
  * Get audit integrity checks for judgment transitions.
4031
3998
  */
@@ -4058,12 +4025,6 @@ function createDecisionsClient(config = {}) {
4058
4025
  )
4059
4026
  );
4060
4027
  },
4061
- /**
4062
- * @deprecated Use createJudgment.
4063
- */
4064
- async recordJudgment(input, idempotencyKey) {
4065
- return this.createJudgment(input, idempotencyKey);
4066
- },
4067
4028
  /**
4068
4029
  * Update the outcome for an existing judgment.
4069
4030
  */
@@ -4074,14 +4035,13 @@ function createDecisionsClient(config = {}) {
4074
4035
  body: input,
4075
4036
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4076
4037
  });
4077
- },
4078
- /**
4079
- * @deprecated Use updateJudgmentOutcome.
4080
- */
4081
- async recordJudgmentOutcome(judgmentId, input, idempotencyKey) {
4082
- return this.updateJudgmentOutcome(judgmentId, input, idempotencyKey);
4083
4038
  }
4084
4039
  };
4040
+ return Object.assign(client, {
4041
+ listPendingJudgmentOutcomeReview: client.listPendingOutcomeReviews,
4042
+ recordJudgment: client.createJudgment,
4043
+ recordJudgmentOutcome: client.updateJudgmentOutcome
4044
+ });
4085
4045
  }
4086
4046
 
4087
4047
  // src/embeddingsClient.ts
@@ -4206,50 +4166,55 @@ function cleanNumber(value) {
4206
4166
  function cleanBoolean(value) {
4207
4167
  return typeof value === "boolean" ? value : void 0;
4208
4168
  }
4209
- function buildCompileContextRequest(topicId, input = {}) {
4210
- const payload = { topicId };
4211
- const query5 = cleanString4(input.query);
4169
+ function buildCompileContextRequest(topicIdOrInput = {}, input = {}) {
4170
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
4171
+ const payload = {};
4172
+ const topicId = typeof topicIdOrInput === "string" ? cleanString4(topicIdOrInput) : cleanString4(effectiveInput.topicId);
4173
+ if (topicId) {
4174
+ payload.topicId = topicId;
4175
+ }
4176
+ const query5 = cleanString4(effectiveInput.query);
4212
4177
  if (query5) {
4213
4178
  payload.query = query5;
4214
4179
  }
4215
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
4180
+ const budget = cleanNumber(effectiveInput.budget) ?? cleanNumber(effectiveInput.tokenBudget);
4216
4181
  if (budget !== void 0) {
4217
4182
  payload.budget = budget;
4218
4183
  }
4219
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
4184
+ const ranking = cleanString4(effectiveInput.ranking) ?? cleanString4(effectiveInput.rankingProfile);
4220
4185
  if (ranking) {
4221
4186
  payload.ranking = ranking;
4222
4187
  }
4223
- const limit = cleanNumber(input.limit);
4188
+ const limit = cleanNumber(effectiveInput.limit);
4224
4189
  if (limit !== void 0) {
4225
4190
  payload.limit = limit;
4226
4191
  }
4227
- const maxDepth = cleanNumber(input.maxDepth);
4192
+ const maxDepth = cleanNumber(effectiveInput.maxDepth);
4228
4193
  if (maxDepth !== void 0) {
4229
4194
  payload.maxDepth = maxDepth;
4230
4195
  }
4231
- const includeEntities = cleanBoolean(input.includeEntities);
4196
+ const includeEntities = cleanBoolean(effectiveInput.includeEntities);
4232
4197
  if (includeEntities !== void 0) {
4233
4198
  payload.includeEntities = includeEntities;
4234
4199
  }
4235
- const mode = cleanString4(input.mode);
4200
+ const mode = cleanString4(effectiveInput.mode);
4236
4201
  if (mode) {
4237
4202
  payload.mode = mode;
4238
4203
  }
4239
- const includeFailures = cleanBoolean(input.includeFailures);
4204
+ const includeFailures = cleanBoolean(effectiveInput.includeFailures);
4240
4205
  if (includeFailures !== void 0) {
4241
4206
  payload.includeFailures = includeFailures;
4242
4207
  }
4243
- const worktreeId = cleanString4(input.worktreeId);
4208
+ const worktreeId = cleanString4(effectiveInput.worktreeId);
4244
4209
  if (worktreeId) {
4245
4210
  payload.worktreeId = worktreeId;
4246
4211
  }
4247
- const sessionId = cleanString4(input.sessionId);
4212
+ const sessionId = cleanString4(effectiveInput.sessionId);
4248
4213
  if (sessionId) {
4249
4214
  payload.sessionId = sessionId;
4250
4215
  }
4251
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
4252
- payload.packWeightOverrides = input.packWeightOverrides;
4216
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
4217
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
4253
4218
  }
4254
4219
  return {
4255
4220
  path: "/api/platform/v1/context/compile",
@@ -4261,13 +4226,20 @@ function createContextClient(config = {}) {
4261
4226
  const gateway = createGatewayRequestClient(config);
4262
4227
  return {
4263
4228
  /**
4264
- * Compile a focused reasoning context pack for a topic scope.
4265
- * @param topicId - The topic to compile context for.
4229
+ * Compile a focused reasoning context pack.
4230
+ * @param topicIdOrInput - Optional topic ID, or compile input for query-first resolution.
4266
4231
  * @param input - Optional compile parameters (query, budget, ranking, etc.).
4267
4232
  * @returns The compiled context payload with beliefs, questions, and evidence.
4268
4233
  */
4269
- async compile(topicId, input = {}) {
4270
- const request = buildCompileContextRequest(topicId, input);
4234
+ async compile(topicIdOrInput = {}, input = {}) {
4235
+ const request = buildCompileContextRequest(topicIdOrInput, input);
4236
+ return gateway.request({
4237
+ ...request,
4238
+ body: request.body
4239
+ });
4240
+ },
4241
+ async compileByQuery(input = {}) {
4242
+ const request = buildCompileContextRequest(input);
4271
4243
  return gateway.request({
4272
4244
  ...request,
4273
4245
  body: request.body
@@ -4705,7 +4677,7 @@ function createGraphStateClassifierClient(config = {}) {
4705
4677
  // src/harnessClient.ts
4706
4678
  function createHarnessClient(config = {}) {
4707
4679
  const gateway = createGatewayRequestClient(config);
4708
- return {
4680
+ const client = {
4709
4681
  /**
4710
4682
  * List agent definitions.
4711
4683
  */
@@ -4738,12 +4710,6 @@ function createHarnessClient(config = {}) {
4738
4710
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4739
4711
  });
4740
4712
  },
4741
- /**
4742
- * @deprecated Use createAgentDefinition.
4743
- */
4744
- async registerAgentDefinition(input, idempotencyKey) {
4745
- return this.createAgentDefinition(input, idempotencyKey);
4746
- },
4747
4713
  /**
4748
4714
  * Update an agent definition.
4749
4715
  */
@@ -4782,12 +4748,6 @@ function createHarnessClient(config = {}) {
4782
4748
  )
4783
4749
  );
4784
4750
  },
4785
- /**
4786
- * @deprecated Use listAgentRuns.
4787
- */
4788
- async listRunsForAgent(agentId, scope = {}) {
4789
- return this.listAgentRuns(agentId, scope);
4790
- },
4791
4751
  /**
4792
4752
  * List tool definitions.
4793
4753
  */
@@ -4820,12 +4780,6 @@ function createHarnessClient(config = {}) {
4820
4780
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4821
4781
  });
4822
4782
  },
4823
- /**
4824
- * @deprecated Use createToolDefinition.
4825
- */
4826
- async registerToolDefinition(input, idempotencyKey) {
4827
- return this.createToolDefinition(input, idempotencyKey);
4828
- },
4829
4783
  /**
4830
4784
  * Update a tool definition.
4831
4785
  */
@@ -4860,12 +4814,6 @@ function createHarnessClient(config = {}) {
4860
4814
  )
4861
4815
  );
4862
4816
  },
4863
- /**
4864
- * @deprecated Use listRunEntries.
4865
- */
4866
- async listRunLedgerEntries(scope = {}) {
4867
- return this.listRunEntries(scope);
4868
- },
4869
4817
  /**
4870
4818
  * Create a harness run.
4871
4819
  */
@@ -4940,6 +4888,12 @@ function createHarnessClient(config = {}) {
4940
4888
  });
4941
4889
  }
4942
4890
  };
4891
+ return Object.assign(client, {
4892
+ registerAgentDefinition: client.createAgentDefinition,
4893
+ listRunsForAgent: client.listAgentRuns,
4894
+ registerToolDefinition: client.createToolDefinition,
4895
+ listRunLedgerEntries: client.listRunEntries
4896
+ });
4943
4897
  }
4944
4898
 
4945
4899
  // src/jobsClient.ts
@@ -5067,45 +5021,41 @@ function createJobsClient(config = {}) {
5067
5021
  // src/learningClient.ts
5068
5022
  function createLearningClient(config = {}) {
5069
5023
  const gateway = createGatewayRequestClient(config);
5024
+ const listRecentExecutions = async (args = {}) => gateway.request({
5025
+ path: `/api/platform/v1/learning/executions/recent${toQueryString({
5026
+ ...normalizeTopicQuery(args),
5027
+ namespace: args.namespace,
5028
+ audienceMode: args.audienceMode,
5029
+ success: typeof args.success === "boolean" ? args.success ? "true" : "false" : void 0,
5030
+ limit: typeof args.limit === "number" && Number.isFinite(args.limit) ? String(args.limit) : void 0
5031
+ })}`
5032
+ }).then(
5033
+ (response) => mapGatewayData(
5034
+ response,
5035
+ (data) => createListResult(Array.isArray(data) ? data : [], "executions")
5036
+ )
5037
+ );
5038
+ const getExecutionStats = async (args = {}) => gateway.request({
5039
+ path: `/api/platform/v1/learning/executions/stats${toQueryString({
5040
+ ...normalizeTopicQuery(args),
5041
+ namespace: args.namespace,
5042
+ audienceMode: args.audienceMode,
5043
+ hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
5044
+ })}`
5045
+ });
5070
5046
  return {
5071
5047
  /**
5072
5048
  * List recent execution records.
5073
5049
  */
5074
- async listRecentExecutions(args = {}) {
5075
- return gateway.request({
5076
- path: `/api/platform/v1/learning/executions/recent${toQueryString({
5077
- ...normalizeTopicQuery(args),
5078
- namespace: args.namespace,
5079
- audienceMode: args.audienceMode,
5080
- success: typeof args.success === "boolean" ? args.success ? "true" : "false" : void 0,
5081
- limit: typeof args.limit === "number" && Number.isFinite(args.limit) ? String(args.limit) : void 0
5082
- })}`
5083
- }).then(
5084
- (response) => mapGatewayData(
5085
- response,
5086
- (data) => createListResult(Array.isArray(data) ? data : [], "executions")
5087
- )
5088
- );
5089
- },
5050
+ listRecentExecutions,
5090
5051
  /**
5091
5052
  * @deprecated Use listRecentExecutions.
5092
5053
  */
5093
- async getRecentExecutions(args = {}) {
5094
- return this.listRecentExecutions(args);
5095
- },
5054
+ getRecentExecutions: listRecentExecutions,
5096
5055
  /**
5097
5056
  * Get aggregate execution statistics.
5098
5057
  */
5099
- async getExecutionStats(args = {}) {
5100
- return gateway.request({
5101
- path: `/api/platform/v1/learning/executions/stats${toQueryString({
5102
- ...normalizeTopicQuery(args),
5103
- namespace: args.namespace,
5104
- audienceMode: args.audienceMode,
5105
- hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
5106
- })}`
5107
- });
5108
- }
5058
+ getExecutionStats
5109
5059
  };
5110
5060
  }
5111
5061
  function toJsonValue(value) {
@@ -6133,7 +6083,7 @@ function createOrgGraphSearchClient(config = {}) {
6133
6083
  // src/packsClient.ts
6134
6084
  function createPacksClient(config = {}) {
6135
6085
  const gateway = createGatewayRequestClient(config);
6136
- return {
6086
+ const client = {
6137
6087
  /**
6138
6088
  * List catalog entries for available packs.
6139
6089
  */
@@ -6147,12 +6097,6 @@ function createPacksClient(config = {}) {
6147
6097
  )
6148
6098
  );
6149
6099
  },
6150
- /**
6151
- * @deprecated Use listCatalog.
6152
- */
6153
- async getCatalog() {
6154
- return this.listCatalog();
6155
- },
6156
6100
  /**
6157
6101
  * Get the discovery catalog for packs.
6158
6102
  */
@@ -6182,12 +6126,6 @@ function createPacksClient(config = {}) {
6182
6126
  )
6183
6127
  );
6184
6128
  },
6185
- /**
6186
- * @deprecated Use listStates.
6187
- */
6188
- async getStates(query5 = {}) {
6189
- return this.listStates(query5);
6190
- },
6191
6129
  /**
6192
6130
  * Get health details for a pack.
6193
6131
  */
@@ -6211,12 +6149,6 @@ function createPacksClient(config = {}) {
6211
6149
  )
6212
6150
  );
6213
6151
  },
6214
- /**
6215
- * @deprecated Use listTelemetry.
6216
- */
6217
- async getTelemetry(query5 = {}) {
6218
- return this.listTelemetry(query5);
6219
- },
6220
6152
  /**
6221
6153
  * Create a pack entitlement.
6222
6154
  */
@@ -6228,18 +6160,6 @@ function createPacksClient(config = {}) {
6228
6160
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6229
6161
  });
6230
6162
  },
6231
- /**
6232
- * Update a pack entitlement.
6233
- */
6234
- async updateEntitlement(input, idempotencyKey) {
6235
- return this.createEntitlement(input, idempotencyKey);
6236
- },
6237
- /**
6238
- * @deprecated Use createEntitlement or updateEntitlement.
6239
- */
6240
- async upsertEntitlement(input, idempotencyKey) {
6241
- return this.createEntitlement(input, idempotencyKey);
6242
- },
6243
6163
  /**
6244
6164
  * Install a pack.
6245
6165
  */
@@ -6296,6 +6216,13 @@ function createPacksClient(config = {}) {
6296
6216
  });
6297
6217
  }
6298
6218
  };
6219
+ return Object.assign(client, {
6220
+ getCatalog: client.listCatalog,
6221
+ getStates: client.listStates,
6222
+ getTelemetry: client.listTelemetry,
6223
+ updateEntitlement: client.createEntitlement,
6224
+ upsertEntitlement: client.createEntitlement
6225
+ });
6299
6226
  }
6300
6227
 
6301
6228
  // src/policyClient.ts
@@ -6331,6 +6258,14 @@ function asRolePolicyArray(data) {
6331
6258
  }
6332
6259
  return data.map(asRolePolicyRecord).filter((row) => Boolean(row));
6333
6260
  }
6261
+ function buildFilterByPermissionResponse(permission, allowedTopicIds, deniedTopics, count) {
6262
+ const result = {};
6263
+ result.permission = permission;
6264
+ result.allowedTopicIds = allowedTopicIds;
6265
+ result.deniedTopics = deniedTopics;
6266
+ result.count = count;
6267
+ return result;
6268
+ }
6334
6269
  function createPolicyClient(config = {}) {
6335
6270
  const gateway = createGatewayRequestClient(config);
6336
6271
  return {
@@ -6553,15 +6488,15 @@ function createPolicyClient(config = {}) {
6553
6488
  });
6554
6489
  const allowedTopicIds = Array.isArray(response.data?.allowedTopicIds) ? response.data.allowedTopicIds : [];
6555
6490
  const deniedTopics = Array.isArray(response.data?.deniedTopics) ? response.data.deniedTopics : [];
6556
- return {
6557
- success: true,
6558
- data: {
6559
- permission,
6560
- allowedTopicIds,
6561
- deniedTopics,
6562
- count: typeof response.data?.count === "number" ? response.data.count : allowedTopicIds.length
6563
- }
6564
- };
6491
+ const result = {};
6492
+ result.success = true;
6493
+ result.data = buildFilterByPermissionResponse(
6494
+ permission,
6495
+ allowedTopicIds,
6496
+ deniedTopics,
6497
+ typeof response.data?.count === "number" ? response.data.count : allowedTopicIds.length
6498
+ );
6499
+ return result;
6565
6500
  }
6566
6501
  };
6567
6502
  }
@@ -6569,64 +6504,66 @@ function createPolicyClient(config = {}) {
6569
6504
  // src/reportsClient.ts
6570
6505
  function createReportsClient(config = {}) {
6571
6506
  const gateway = createGatewayRequestClient(config);
6507
+ const listTemplates = async (args = {}) => gateway.request({
6508
+ path: `/api/platform/v1/reports/templates${toQueryString({
6509
+ slug: args.slug
6510
+ })}`
6511
+ }).then(
6512
+ (response) => mapGatewayData(response, (data) => {
6513
+ const rows = asListItems(data, "templates");
6514
+ return createListResult(rows, "templates");
6515
+ })
6516
+ );
6517
+ const listReports = async (input, args = {}) => {
6518
+ const topicId = resolveTopicId(input);
6519
+ if (!topicId) {
6520
+ throw new Error("topicId is required");
6521
+ }
6522
+ return gateway.request({
6523
+ path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString(
6524
+ {
6525
+ summary: typeof args.summary === "boolean" ? args.summary ? "true" : "false" : void 0
6526
+ }
6527
+ )}`
6528
+ }).then(
6529
+ (response) => mapGatewayData(
6530
+ response,
6531
+ (data) => createListResult(Array.isArray(data) ? data : [], "reports")
6532
+ )
6533
+ );
6534
+ };
6535
+ const getReport = async (reportId) => gateway.request({
6536
+ path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`
6537
+ });
6572
6538
  return {
6573
6539
  /**
6574
6540
  * List report templates.
6575
6541
  */
6576
- async listTemplates(args = {}) {
6577
- return gateway.request({
6578
- path: `/api/platform/v1/reports/templates${toQueryString({
6579
- slug: args.slug
6580
- })}`
6581
- }).then(
6582
- (response) => mapGatewayData(response, (data) => {
6583
- const record = data && typeof data === "object" ? data : {};
6584
- const rows = Array.isArray(data) ? data : Array.isArray(record.templates) ? record.templates : [];
6585
- return createListResult(rows, "templates");
6586
- })
6587
- );
6588
- },
6542
+ listTemplates,
6589
6543
  /**
6590
6544
  * @deprecated Use listTemplates.
6591
6545
  */
6592
- async getTemplates(args = {}) {
6593
- return this.listTemplates(args);
6594
- },
6546
+ getTemplates: listTemplates,
6595
6547
  /**
6596
6548
  * List reports for a topic scope.
6597
6549
  */
6598
- async listReports(input, args = {}) {
6599
- const topicId = resolveTopicId(input);
6600
- if (!topicId) {
6601
- throw new Error("topicId is required");
6602
- }
6603
- return gateway.request({
6604
- path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString(
6605
- {
6606
- summary: typeof args.summary === "boolean" ? args.summary ? "true" : "false" : void 0
6607
- }
6608
- )}`
6609
- }).then(
6610
- (response) => mapGatewayData(
6611
- response,
6612
- (data) => createListResult(Array.isArray(data) ? data : [], "reports")
6613
- )
6614
- );
6615
- },
6550
+ listReports,
6616
6551
  /**
6617
6552
  * Get a generated report.
6618
6553
  */
6619
- async getReport(reportId) {
6620
- return gateway.request({
6621
- path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`
6622
- });
6623
- }
6554
+ getReport
6624
6555
  };
6625
6556
  }
6626
6557
 
6627
6558
  // src/schemaClient.ts
6628
6559
  function createSchemaClient(config = {}) {
6629
6560
  const gateway = createGatewayRequestClient(config);
6561
+ const createEntitlement = (input, idempotencyKey) => gateway.request({
6562
+ path: "/api/platform/v1/schema/entitlements",
6563
+ method: "POST",
6564
+ body: input,
6565
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6566
+ });
6630
6567
  return {
6631
6568
  /**
6632
6569
  * List schema packs.
@@ -6678,29 +6615,95 @@ function createSchemaClient(config = {}) {
6678
6615
  /**
6679
6616
  * Create a schema entitlement.
6680
6617
  */
6681
- async createEntitlement(input, idempotencyKey) {
6682
- return gateway.request({
6683
- path: "/api/platform/v1/schema/entitlements",
6684
- method: "POST",
6685
- body: input,
6686
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6687
- });
6688
- },
6618
+ createEntitlement,
6689
6619
  /**
6690
6620
  * Update a schema entitlement.
6691
6621
  */
6692
- async updateEntitlement(input, idempotencyKey) {
6693
- return this.createEntitlement(input, idempotencyKey);
6694
- },
6622
+ updateEntitlement: createEntitlement,
6695
6623
  /**
6696
6624
  * @deprecated Use createEntitlement or updateEntitlement.
6697
6625
  */
6698
- async upsertEntitlement(input, idempotencyKey) {
6699
- return this.createEntitlement(input, idempotencyKey);
6700
- }
6626
+ upsertEntitlement: createEntitlement
6701
6627
  };
6702
6628
  }
6703
6629
 
6630
+ // src/clientHelpers.ts
6631
+ function asNodeArray(data) {
6632
+ const rows = asListItems(data, "nodes");
6633
+ if (rows.length > 0) {
6634
+ return rows.filter(
6635
+ (value) => Boolean(value) && typeof value === "object"
6636
+ );
6637
+ }
6638
+ if (data && typeof data === "object") {
6639
+ return [data];
6640
+ }
6641
+ return [];
6642
+ }
6643
+ function requireTopicId4(args) {
6644
+ const topicId = resolveTopicId(args);
6645
+ if (!topicId) {
6646
+ throw new Error("topicId is required");
6647
+ }
6648
+ return topicId;
6649
+ }
6650
+ function requireTopicOrProjectId(args) {
6651
+ const topicId = args.topicId?.trim() || args.projectId?.trim() || void 0;
6652
+ if (!topicId) {
6653
+ throw new Error("topicId is required");
6654
+ }
6655
+ return topicId;
6656
+ }
6657
+ var AUDIT_NODE_REFERENCE_KEY_PATTERN = /(^|_)(id|nodeid|beliefid|resourceid|targetid|sourceid|subjectid|globalid|entityid|recordid|fromnodeid|tonodeid|linkednodeid|linkedbeliefid|nodeids|beliefids|resourceids)$/i;
6658
+ function matchesAuditNodeReference(value, nodeId) {
6659
+ if (Array.isArray(value)) {
6660
+ return value.some((entry) => matchesAuditNodeReference(entry, nodeId));
6661
+ }
6662
+ if (!value || typeof value !== "object") {
6663
+ return false;
6664
+ }
6665
+ return Object.entries(value).some(([key, entry]) => {
6666
+ if (typeof entry === "string" && entry === nodeId && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key)) {
6667
+ return true;
6668
+ }
6669
+ if (Array.isArray(entry) && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key) && entry.some((item) => item === nodeId)) {
6670
+ return true;
6671
+ }
6672
+ return matchesAuditNodeReference(entry, nodeId);
6673
+ });
6674
+ }
6675
+ function requireText(args) {
6676
+ const text = resolveText(args);
6677
+ if (!text) {
6678
+ throw new Error("text is required");
6679
+ }
6680
+ return text;
6681
+ }
6682
+ function requireBaseRate(args) {
6683
+ const baseRate = typeof args.baseRate === "number" && Number.isFinite(args.baseRate) ? args.baseRate : 0.5;
6684
+ if (baseRate < 0 || baseRate > 1) {
6685
+ throw new Error("baseRate must be within [0, 1].");
6686
+ }
6687
+ return baseRate;
6688
+ }
6689
+ function sdkQueryString(input) {
6690
+ const params = new URLSearchParams();
6691
+ for (const [key, value] of Object.entries(input)) {
6692
+ if (value === void 0 || value === null) {
6693
+ continue;
6694
+ }
6695
+ if (Array.isArray(value)) {
6696
+ if (value.length > 0) {
6697
+ params.set(key, value.join(","));
6698
+ }
6699
+ continue;
6700
+ }
6701
+ params.set(key, String(value));
6702
+ }
6703
+ const serialized = params.toString();
6704
+ return serialized ? `?${serialized}` : "";
6705
+ }
6706
+
6704
6707
  // src/telemetryClient.ts
6705
6708
  var TELEMETRY_FIELDS = [
6706
6709
  "tenantId",
@@ -6871,6 +6874,16 @@ function query4(input) {
6871
6874
  cursor: input.cursor
6872
6875
  };
6873
6876
  }
6877
+ function effectiveToolsQuery(input) {
6878
+ return {
6879
+ ...query4(input),
6880
+ callerRole: input.callerRole,
6881
+ surface: input.surface,
6882
+ sessionType: input.sessionType,
6883
+ permittedToolNames: input.permittedToolNames ? JSON.stringify(input.permittedToolNames) : void 0,
6884
+ executableOnly: input.executableOnly
6885
+ };
6886
+ }
6874
6887
  function writeBody(input, operation) {
6875
6888
  return knownPayload(input, TOOL_REGISTRY_FIELDS, operation);
6876
6889
  }
@@ -6899,7 +6912,9 @@ function createToolRegistryClient(config = {}) {
6899
6912
  },
6900
6913
  listEffectiveTools(input) {
6901
6914
  return gateway.request({
6902
- path: `/api/platform/v1/tools/effective${toQueryString(query4(input))}`
6915
+ path: `/api/platform/v1/tools/effective${toQueryString(
6916
+ effectiveToolsQuery(input)
6917
+ )}`
6903
6918
  }).then(
6904
6919
  (response) => mapGatewayData(
6905
6920
  response,
@@ -6990,7 +7005,7 @@ function createToolRegistryClient(config = {}) {
6990
7005
  }
6991
7006
 
6992
7007
  // src/version.ts
6993
- var LUCERN_SDK_VERSION = "0.2.0-alpha.1";
7008
+ var LUCERN_SDK_VERSION = "0.3.0-alpha.8";
6994
7009
 
6995
7010
  // src/workflowClient.ts
6996
7011
  function normalizeLensQuery(value) {
@@ -7184,12 +7199,6 @@ function createWorkflowClient(config = {}) {
7184
7199
  )
7185
7200
  );
7186
7201
  },
7187
- /**
7188
- * @deprecated Use createWorktree.
7189
- */
7190
- async addWorktree(input, idempotencyKey) {
7191
- return client.createWorktree(input, idempotencyKey);
7192
- },
7193
7202
  /**
7194
7203
  * Merge a worktree into the main belief line.
7195
7204
  */
@@ -7387,54 +7396,19 @@ function createWorkflowClient(config = {}) {
7387
7396
  body: input,
7388
7397
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
7389
7398
  });
7390
- },
7391
- /**
7392
- * @deprecated Use createBranch.
7393
- */
7394
- async createPillar(input, idempotencyKey) {
7395
- return client.createBranch(input, idempotencyKey);
7396
- },
7397
- /**
7398
- * @deprecated Use addWorktree.
7399
- */
7400
- async createSprint(input, idempotencyKey) {
7401
- return client.createWorktree(input, idempotencyKey);
7402
- },
7403
- /**
7404
- * @deprecated Use merge.
7405
- */
7406
- async completeSprint(worktreeId, input, idempotencyKey) {
7407
- return client.merge(worktreeId, input, idempotencyKey);
7408
- },
7409
- /**
7410
- * @deprecated Use openPullRequest.
7411
- */
7412
- async requestReview(worktreeId, input, idempotencyKey) {
7413
- return client.openPullRequest(worktreeId, input, idempotencyKey);
7414
- },
7415
- /**
7416
- * @deprecated Use push.
7417
- */
7418
- async publishFindings(worktreeId, input, idempotencyKey) {
7419
- return client.push(worktreeId, input, idempotencyKey);
7420
7399
  }
7421
7400
  };
7422
- return client;
7401
+ return Object.assign(client, {
7402
+ addWorktree: client.createWorktree,
7403
+ createPillar: client.createBranch,
7404
+ createSprint: client.createWorktree,
7405
+ completeSprint: client.merge,
7406
+ requestReview: client.openPullRequest,
7407
+ publishFindings: client.push
7408
+ });
7423
7409
  }
7424
7410
 
7425
7411
  // src/client.ts
7426
- function asNodeArray(data) {
7427
- const rows = asListItems(data, "nodes");
7428
- if (rows.length > 0) {
7429
- return rows.filter(
7430
- (value) => Boolean(value) && typeof value === "object"
7431
- );
7432
- }
7433
- if (data && typeof data === "object") {
7434
- return [data];
7435
- }
7436
- return [];
7437
- }
7438
7412
  function toGatewayConfig(config) {
7439
7413
  return {
7440
7414
  baseUrl: config.baseUrl,
@@ -7462,72 +7436,9 @@ function toGatewayConfig(config) {
7462
7436
  }
7463
7437
  };
7464
7438
  }
7465
- function requireTopicId4(args) {
7466
- const topicId = resolveTopicId(args);
7467
- if (!topicId) {
7468
- throw new Error("topicId is required");
7469
- }
7470
- return topicId;
7471
- }
7472
- function requireTopicOrProjectId(args) {
7473
- const topicId = args.topicId?.trim() || args.projectId?.trim() || void 0;
7474
- if (!topicId) {
7475
- throw new Error("topicId is required");
7476
- }
7477
- return topicId;
7478
- }
7479
- var AUDIT_NODE_REFERENCE_KEY_PATTERN = /(^|_)(id|nodeid|beliefid|resourceid|targetid|sourceid|subjectid|globalid|entityid|recordid|fromnodeid|tonodeid|linkednodeid|linkedbeliefid|nodeids|beliefids|resourceids)$/i;
7480
- function matchesAuditNodeReference(value, nodeId) {
7481
- if (Array.isArray(value)) {
7482
- return value.some((entry) => matchesAuditNodeReference(entry, nodeId));
7483
- }
7484
- if (!value || typeof value !== "object") {
7485
- return false;
7486
- }
7487
- return Object.entries(value).some(([key, entry]) => {
7488
- if (typeof entry === "string" && entry === nodeId && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key)) {
7489
- return true;
7490
- }
7491
- if (Array.isArray(entry) && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key) && entry.some((item) => item === nodeId)) {
7492
- return true;
7493
- }
7494
- return matchesAuditNodeReference(entry, nodeId);
7495
- });
7496
- }
7497
- function requireText(args) {
7498
- const text = resolveText(args);
7499
- if (!text) {
7500
- throw new Error("text is required");
7501
- }
7502
- return text;
7503
- }
7504
- function requireBaseRate(args) {
7505
- const baseRate = typeof args.baseRate === "number" && Number.isFinite(args.baseRate) ? args.baseRate : 0.5;
7506
- if (baseRate < 0 || baseRate > 1) {
7507
- throw new Error("baseRate must be within [0, 1].");
7508
- }
7509
- return baseRate;
7510
- }
7511
7439
  function exposeGatewayData(response) {
7512
7440
  return Object.assign({}, response, response.data);
7513
7441
  }
7514
- function sdkQueryString(input) {
7515
- const params = new URLSearchParams();
7516
- for (const [key, value] of Object.entries(input)) {
7517
- if (value === void 0 || value === null) {
7518
- continue;
7519
- }
7520
- if (Array.isArray(value)) {
7521
- if (value.length > 0) {
7522
- params.set(key, value.join(","));
7523
- }
7524
- continue;
7525
- }
7526
- params.set(key, String(value));
7527
- }
7528
- const serialized = params.toString();
7529
- return serialized ? `?${serialized}` : "";
7530
- }
7531
7442
  function createLucernClient(config = {}) {
7532
7443
  const gatewayConfig = toGatewayConfig(config);
7533
7444
  const beliefsClient = createBeliefsClient(gatewayConfig);
@@ -7751,7 +7662,7 @@ function createLucernClient(config = {}) {
7751
7662
  topicId,
7752
7663
  nodeType: "contradiction",
7753
7664
  limit: 500
7754
- }) : args.nodeId ? await graphClient.queryNodes({ nodeId: args.nodeId }) : { data: [] };
7665
+ }) : args.nodeId ? await graphClient.listNodes({ nodeId: args.nodeId }) : { data: [] };
7755
7666
  const contradictions = asNodeArray(response.data).filter((node) => {
7756
7667
  const status = typeof node.metadata?.status === "string" ? node.metadata.status : typeof node.status === "string" ? node.status : "unresolved";
7757
7668
  if (args.status && status !== args.status) {
@@ -7931,23 +7842,15 @@ function createLucernClient(config = {}) {
7931
7842
  }).then(exposeGatewayData);
7932
7843
  }
7933
7844
  const nodesNamespace = {
7934
- list(query5) {
7935
- return graphClient.listNodes(query5);
7936
- },
7845
+ list: graphClient.listNodes,
7937
7846
  get(input) {
7938
7847
  return graphClient.getNode(
7939
7848
  typeof input === "string" ? { nodeId: input } : input
7940
7849
  );
7941
7850
  },
7942
- create(input, idempotencyKey) {
7943
- return graphClient.createNode(input, idempotencyKey);
7944
- },
7945
- update(input, idempotencyKey) {
7946
- return graphClient.updateNode(input, idempotencyKey);
7947
- },
7948
- batchCreate(input, idempotencyKey) {
7949
- return graphClient.batchCreateNodes(input, idempotencyKey);
7950
- },
7851
+ create: graphClient.createNode,
7852
+ update: graphClient.updateNode,
7853
+ batchCreate: graphClient.batchCreateNodes,
7951
7854
  listByTopicAndType(input) {
7952
7855
  return gateway.request({
7953
7856
  path: `/api/platform/v1/nodes${sdkQueryString({
@@ -7972,15 +7875,9 @@ function createLucernClient(config = {}) {
7972
7875
  })}`
7973
7876
  }).then(exposeGatewayData);
7974
7877
  },
7975
- supersede(input, idempotencyKey) {
7976
- return graphClient.supersedeNode(input, idempotencyKey);
7977
- },
7978
- verify(input, idempotencyKey) {
7979
- return graphClient.verifyNode(input, idempotencyKey);
7980
- },
7981
- hardDelete(input, idempotencyKey) {
7982
- return graphClient.hardDeleteNode(input, idempotencyKey);
7983
- }
7878
+ supersede: graphClient.supersedeNode,
7879
+ verify: graphClient.verifyNode,
7880
+ hardDelete: graphClient.hardDeleteNode
7984
7881
  };
7985
7882
  const publicationNamespace = {
7986
7883
  create(input, idempotencyKey) {
@@ -8057,9 +7954,7 @@ function createLucernClient(config = {}) {
8057
7954
  return {
8058
7955
  config,
8059
7956
  version: LUCERN_SDK_VERSION,
8060
- search(query5, options) {
8061
- return searchResources(query5, options);
8062
- },
7957
+ search: searchResources,
8063
7958
  events: {
8064
7959
  list(query5 = {}) {
8065
7960
  return eventsFacade.list(query5).then(exposeGatewayData);
@@ -8156,9 +8051,7 @@ function createLucernClient(config = {}) {
8156
8051
  confidenceHistory(nodeId) {
8157
8052
  return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
8158
8053
  },
8159
- opinionHistory(nodeId) {
8160
- return getOpinionHistory(nodeId);
8161
- },
8054
+ opinionHistory: getOpinionHistory,
8162
8055
  createContract(nodeId, input) {
8163
8056
  return beliefsFacade.createContract(nodeId, input).then(exposeGatewayData);
8164
8057
  },
@@ -8412,10 +8305,10 @@ function createLucernClient(config = {}) {
8412
8305
  }));
8413
8306
  },
8414
8307
  getHighPriority(args) {
8415
- return this.list({
8308
+ return questionsFacade.list({
8416
8309
  topicId: requireTopicId4(args),
8417
8310
  status: args.includeAnswered ? void 0 : "open"
8418
- }).then((data) => {
8311
+ }).then(exposeGatewayData).then((data) => {
8419
8312
  const questions = Array.isArray(data.questions) ? data.questions : [];
8420
8313
  const rank = (priority) => {
8421
8314
  switch (priority) {
@@ -8445,9 +8338,7 @@ function createLucernClient(config = {}) {
8445
8338
  },
8446
8339
  graph: {
8447
8340
  nodes: nodesNamespace,
8448
- createEdge(input) {
8449
- return graphClient.createEdge(input);
8450
- },
8341
+ createEdge: graphClient.createEdge,
8451
8342
  neighborhood(args) {
8452
8343
  return graphFacade.neighborhood({
8453
8344
  globalId: args.globalId,
@@ -8506,7 +8397,7 @@ function createLucernClient(config = {}) {
8506
8397
  bisectConfidence,
8507
8398
  listBeliefs,
8508
8399
  detectConfirmationBias(topicId, threshold) {
8509
- return this.bias({
8400
+ return graphFacade.bias({
8510
8401
  topicId,
8511
8402
  threshold,
8512
8403
  limit: 200
@@ -8517,7 +8408,7 @@ function createLucernClient(config = {}) {
8517
8408
  }));
8518
8409
  },
8519
8410
  getStructureAnalysis(topicId) {
8520
- return this.analyze({
8411
+ return graphFacade.analyze({
8521
8412
  topicId,
8522
8413
  limit: 200
8523
8414
  }).then((response) => ({
@@ -8584,38 +8475,20 @@ function createLucernClient(config = {}) {
8584
8475
  }
8585
8476
  },
8586
8477
  judgments: {
8587
- create(input) {
8588
- return decisionsClient.createJudgment(input);
8589
- },
8590
- record(input) {
8591
- return decisionsClient.recordJudgment(input);
8592
- },
8593
- list(query5) {
8594
- return decisionsClient.listJudgments(query5);
8595
- },
8596
- get(judgmentId) {
8597
- return decisionsClient.getJudgment(judgmentId);
8598
- },
8599
- recordOutcome(judgmentId, input) {
8600
- return decisionsClient.recordJudgmentOutcome(judgmentId, input);
8601
- },
8602
- updateOutcome(judgmentId, input) {
8603
- return decisionsClient.updateJudgmentOutcome(judgmentId, input);
8604
- },
8478
+ create: decisionsClient.createJudgment,
8479
+ record: decisionsClient.recordJudgment,
8480
+ list: decisionsClient.listJudgments,
8481
+ get: decisionsClient.getJudgment,
8482
+ recordOutcome: decisionsClient.recordJudgmentOutcome,
8483
+ updateOutcome: decisionsClient.updateJudgmentOutcome,
8605
8484
  readiness(topicId) {
8606
- return decisionsClient.getJudgmentReadiness({
8607
- topicId
8608
- });
8485
+ return decisionsClient.getJudgmentReadiness({ topicId });
8609
8486
  },
8610
8487
  calibration(topicId) {
8611
- return decisionsClient.getJudgmentCalibration({
8612
- topicId
8613
- });
8488
+ return decisionsClient.getJudgmentCalibration({ topicId });
8614
8489
  },
8615
8490
  pendingOutcomeReview(topicId) {
8616
- return decisionsClient.listPendingJudgmentOutcomeReview({
8617
- topicId
8618
- });
8491
+ return decisionsClient.listPendingJudgmentOutcomeReview({ topicId });
8619
8492
  },
8620
8493
  transitionAuditIntegrity(args) {
8621
8494
  return decisionsClient.getJudgmentTransitionAuditIntegrity({
@@ -8625,21 +8498,11 @@ function createLucernClient(config = {}) {
8625
8498
  }
8626
8499
  },
8627
8500
  decisions: {
8628
- create(input) {
8629
- return decisionsClient.createJudgment(input);
8630
- },
8631
- record(input) {
8632
- return decisionsClient.recordJudgment(input);
8633
- },
8634
- list(query5) {
8635
- return decisionsClient.listJudgments(query5);
8636
- },
8637
- get(decisionId) {
8638
- return decisionsClient.getJudgment(decisionId);
8639
- },
8640
- recordOutcome(decisionId, input) {
8641
- return decisionsClient.recordJudgmentOutcome(decisionId, input);
8642
- },
8501
+ create: decisionsClient.createJudgment,
8502
+ record: decisionsClient.recordJudgment,
8503
+ list: decisionsClient.listJudgments,
8504
+ get: decisionsClient.getJudgment,
8505
+ recordOutcome: decisionsClient.recordJudgmentOutcome,
8643
8506
  lessons(decisionId, input, idempotencyKey) {
8644
8507
  return gateway.request({
8645
8508
  path: `/api/platform/v1/decisions/${encodeURIComponent(
@@ -8671,21 +8534,11 @@ function createLucernClient(config = {}) {
8671
8534
  }
8672
8535
  },
8673
8536
  worktrees: {
8674
- createBranch(input) {
8675
- return workflowClient.createBranch(input);
8676
- },
8677
- createLens(input) {
8678
- return workflowClient.createLens(input);
8679
- },
8680
- listLenses(query5) {
8681
- return workflowClient.listLenses(query5);
8682
- },
8683
- applyLensToTopic(input) {
8684
- return workflowClient.applyLensToTopic(input);
8685
- },
8686
- removeLensFromTopic(input) {
8687
- return workflowClient.removeLensFromTopic(input);
8688
- },
8537
+ createBranch: workflowClient.createBranch,
8538
+ createLens: workflowClient.createLens,
8539
+ listLenses: workflowClient.listLenses,
8540
+ applyLensToTopic: workflowClient.applyLensToTopic,
8541
+ removeLensFromTopic: workflowClient.removeLensFromTopic,
8689
8542
  create(input) {
8690
8543
  return worktreesFacade.create({
8691
8544
  title: input.title,
@@ -8790,7 +8643,9 @@ function createLucernClient(config = {}) {
8790
8643
  const dependsOn = Array.isArray(input.dependsOn) ? input.dependsOn.filter(
8791
8644
  (value) => typeof value === "string"
8792
8645
  ) : void 0;
8793
- const blocks = Array.isArray(input.blocks) ? input.blocks.filter((value) => typeof value === "string") : void 0;
8646
+ const blocks = Array.isArray(input.blocks) ? input.blocks.filter(
8647
+ (value) => typeof value === "string"
8648
+ ) : void 0;
8794
8649
  return worktreesFacade.update({
8795
8650
  id: typeof input.worktreeId === "string" ? input.worktreeId : "",
8796
8651
  hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : void 0,
@@ -8804,7 +8659,23 @@ function createLucernClient(config = {}) {
8804
8659
  });
8805
8660
  },
8806
8661
  update(input) {
8807
- return this.updateMetadata(input);
8662
+ const dependsOn = Array.isArray(input.dependsOn) ? input.dependsOn.filter(
8663
+ (value) => typeof value === "string"
8664
+ ) : void 0;
8665
+ const blocks = Array.isArray(input.blocks) ? input.blocks.filter(
8666
+ (value) => typeof value === "string"
8667
+ ) : void 0;
8668
+ return worktreesFacade.update({
8669
+ id: typeof input.worktreeId === "string" ? input.worktreeId : "",
8670
+ hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : void 0,
8671
+ campaign: typeof input.campaign === "number" ? input.campaign : void 0,
8672
+ lane: typeof input.lane === "string" ? input.lane : void 0,
8673
+ laneOrderInCampaign: typeof input.laneOrderInCampaign === "number" ? input.laneOrderInCampaign : void 0,
8674
+ orderInLane: typeof input.orderInLane === "number" ? input.orderInLane : void 0,
8675
+ dependsOn,
8676
+ blocks,
8677
+ gate: typeof input.gate === "string" ? input.gate : void 0
8678
+ });
8808
8679
  },
8809
8680
  updateTargets(input) {
8810
8681
  return worktreesFacade.updateTargets({
@@ -8815,9 +8686,7 @@ function createLucernClient(config = {}) {
8815
8686
  removeQuestionIds: input.removeQuestionIds
8816
8687
  });
8817
8688
  },
8818
- listAll(query5 = {}) {
8819
- return workflowClient.listAllWorktrees(query5);
8820
- },
8689
+ listAll: workflowClient.listAllWorktrees,
8821
8690
  merge(worktreeId, input) {
8822
8691
  return worktreesFacade.merge({
8823
8692
  id: worktreeId,
@@ -8825,18 +8694,12 @@ function createLucernClient(config = {}) {
8825
8694
  summary: input.summary
8826
8695
  });
8827
8696
  },
8828
- push(worktreeId, input) {
8829
- return workflowClient.push(worktreeId, input);
8830
- },
8831
- openPullRequest(worktreeId, input) {
8832
- return workflowClient.openPullRequest(worktreeId, input);
8833
- },
8697
+ push: workflowClient.push,
8698
+ openPullRequest: workflowClient.openPullRequest,
8834
8699
  pipelineSnapshot(topicId) {
8835
8700
  return functionSurfaceClient.pipelineSnapshot({ topicId });
8836
8701
  },
8837
- complete(input, idempotencyKey) {
8838
- return worktreesFacade.complete(input, idempotencyKey);
8839
- },
8702
+ complete: worktreesFacade.complete,
8840
8703
  advancePhase(worktreeId, idempotencyKey) {
8841
8704
  return worktreesFacade.advancePhase(
8842
8705
  { worktreeId },
@@ -8849,12 +8712,8 @@ function createLucernClient(config = {}) {
8849
8712
  idempotencyKey
8850
8713
  );
8851
8714
  },
8852
- patchState(input, idempotencyKey) {
8853
- return worktreesFacade.patchState(input, idempotencyKey);
8854
- },
8855
- bulkCreate(input, idempotencyKey) {
8856
- return worktreesFacade.bulkCreate(input, idempotencyKey);
8857
- }
8715
+ patchState: worktreesFacade.patchState,
8716
+ bulkCreate: worktreesFacade.bulkCreate
8858
8717
  },
8859
8718
  context: {
8860
8719
  listTopics(query5 = {}) {
@@ -8865,27 +8724,15 @@ function createLucernClient(config = {}) {
8865
8724
  type: query5.type
8866
8725
  });
8867
8726
  },
8868
- compile(topicId, input = {}) {
8869
- return contextClient.compile(topicId, input);
8870
- },
8871
- recordScopeLearning(input, idempotencyKey) {
8872
- return functionSurfaceClient.recordScopeLearning(input, idempotencyKey);
8873
- },
8727
+ compile: contextClient.compile,
8728
+ recordScopeLearning: functionSurfaceClient.recordScopeLearning,
8874
8729
  discover(input) {
8875
8730
  return discoverTopics(input);
8876
8731
  },
8877
- analyzeTopicDensity(input) {
8878
- return functionSurfaceClient.analyzeTopicDensity(input);
8879
- },
8880
- applyAutoBranching(input, idempotencyKey) {
8881
- return functionSurfaceClient.applyAutoBranching(input, idempotencyKey);
8882
- },
8883
- seedBeliefLattice(input = {}, idempotencyKey) {
8884
- return functionSurfaceClient.seedBeliefLattice(input, idempotencyKey);
8885
- },
8886
- getLatticeCoverage(input = {}) {
8887
- return functionSurfaceClient.getLatticeCoverage(input);
8888
- },
8732
+ analyzeTopicDensity: functionSurfaceClient.analyzeTopicDensity,
8733
+ applyAutoBranching: functionSurfaceClient.applyAutoBranching,
8734
+ seedBeliefLattice: functionSurfaceClient.seedBeliefLattice,
8735
+ getLatticeCoverage: functionSurfaceClient.getLatticeCoverage,
8889
8736
  matchEntityType(input) {
8890
8737
  return ontologiesFacade.match(input).then(exposeGatewayData);
8891
8738
  },
@@ -8970,9 +8817,7 @@ function createLucernClient(config = {}) {
8970
8817
  type: input.type
8971
8818
  });
8972
8819
  },
8973
- get(topicId) {
8974
- return topicsFacade.get(topicId);
8975
- },
8820
+ get: topicsFacade.get,
8976
8821
  create(input) {
8977
8822
  return topicsFacade.create({
8978
8823
  name: input.name,
@@ -9017,12 +8862,8 @@ function createLucernClient(config = {}) {
9017
8862
  maxDepth: query5.maxDepth
9018
8863
  });
9019
8864
  },
9020
- remove(topicId, idempotencyKey) {
9021
- return topicsFacade.remove(topicId, idempotencyKey);
9022
- },
9023
- bulkCreate(input, idempotencyKey) {
9024
- return topicsFacade.bulkCreate(input, idempotencyKey);
9025
- }
8865
+ remove: topicsFacade.remove,
8866
+ bulkCreate: topicsFacade.bulkCreate
9026
8867
  },
9027
8868
  answers: {
9028
8869
  create(input) {
@@ -9121,33 +8962,15 @@ function createLucernClient(config = {}) {
9121
8962
  raw: ontologyClient
9122
8963
  },
9123
8964
  coordination: {
9124
- registerSession(input = {}, idempotencyKey) {
9125
- return functionSurfaceClient.registerSession(input, idempotencyKey);
9126
- },
9127
- heartbeatSession(input = {}, idempotencyKey) {
9128
- return functionSurfaceClient.heartbeatSession(input, idempotencyKey);
9129
- },
9130
- endSession(input = {}, idempotencyKey) {
9131
- return functionSurfaceClient.endSession(input, idempotencyKey);
9132
- },
9133
- listActiveSessions(input = {}) {
9134
- return functionSurfaceClient.listActiveSessions(input);
9135
- },
9136
- sendAgentMessage(input, idempotencyKey) {
9137
- return functionSurfaceClient.sendAgentMessage(input, idempotencyKey);
9138
- },
9139
- broadcastMessage(input, idempotencyKey) {
9140
- return functionSurfaceClient.broadcastMessage(input, idempotencyKey);
9141
- },
9142
- getInbox(input = {}) {
9143
- return functionSurfaceClient.getAgentInbox(input);
9144
- },
9145
- getAgentInbox(input = {}) {
9146
- return functionSurfaceClient.getAgentInbox(input);
9147
- },
9148
- claimFiles(input, idempotencyKey) {
9149
- return functionSurfaceClient.claimFiles(input, idempotencyKey);
9150
- }
8965
+ registerSession: functionSurfaceClient.registerSession,
8966
+ heartbeatSession: functionSurfaceClient.heartbeatSession,
8967
+ endSession: functionSurfaceClient.endSession,
8968
+ listActiveSessions: functionSurfaceClient.listActiveSessions,
8969
+ sendAgentMessage: functionSurfaceClient.sendAgentMessage,
8970
+ broadcastMessage: functionSurfaceClient.broadcastMessage,
8971
+ getInbox: functionSurfaceClient.getAgentInbox,
8972
+ getAgentInbox: functionSurfaceClient.getAgentInbox,
8973
+ claimFiles: functionSurfaceClient.claimFiles
9151
8974
  },
9152
8975
  policy: {
9153
8976
  checkPermission(input) {
@@ -9178,38 +9001,24 @@ function createLucernClient(config = {}) {
9178
9001
  principalId: typeof input.principalId === "string" ? input.principalId : void 0
9179
9002
  });
9180
9003
  },
9004
+ // Backward compatibility shim: keep the policy namespace exposing the
9005
+ // historical manageWritePolicy entry point.
9181
9006
  manageWritePolicy(input, idempotencyKey) {
9182
9007
  return functionSurfaceClient.manageWritePolicy(input, idempotencyKey);
9183
9008
  },
9184
9009
  raw: policyClient
9185
9010
  },
9186
9011
  observations: {
9187
- ingest(input, idempotencyKey) {
9188
- return functionSurfaceClient.ingestObservation(input, idempotencyKey);
9189
- },
9190
- ingestObservation(input, idempotencyKey) {
9191
- return functionSurfaceClient.ingestObservation(input, idempotencyKey);
9192
- },
9193
- getContext(input) {
9194
- return functionSurfaceClient.getObservationContext(input);
9195
- },
9196
- getObservationContext(input) {
9197
- return functionSurfaceClient.getObservationContext(input);
9198
- }
9012
+ ingest: functionSurfaceClient.ingestObservation,
9013
+ ingestObservation: functionSurfaceClient.ingestObservation,
9014
+ getContext: functionSurfaceClient.getObservationContext,
9015
+ getObservationContext: functionSurfaceClient.getObservationContext
9199
9016
  },
9200
9017
  coding: {
9201
- getCodeContext(input) {
9202
- return functionSurfaceClient.getCodeContext(input);
9203
- },
9204
- getChangeHistory(input) {
9205
- return functionSurfaceClient.getChangeHistory(input);
9206
- },
9207
- recordAttempt(input, idempotencyKey) {
9208
- return functionSurfaceClient.recordAttempt(input, idempotencyKey);
9209
- },
9210
- getFailureLog(input) {
9211
- return functionSurfaceClient.getFailureLog(input);
9212
- }
9018
+ getCodeContext: functionSurfaceClient.getCodeContext,
9019
+ getChangeHistory: functionSurfaceClient.getChangeHistory,
9020
+ recordAttempt: functionSurfaceClient.recordAttempt,
9021
+ getFailureLog: functionSurfaceClient.getFailureLog
9213
9022
  },
9214
9023
  contracts: {
9215
9024
  create(input) {
@@ -9235,9 +9044,7 @@ function createLucernClient(config = {}) {
9235
9044
  }
9236
9045
  },
9237
9046
  bootstrap: {
9238
- generateSessionHandoff(input) {
9239
- return functionSurfaceClient.generateSessionHandoff(input);
9240
- }
9047
+ generateSessionHandoff: functionSurfaceClient.generateSessionHandoff
9241
9048
  },
9242
9049
  embeddings: embeddingsClient,
9243
9050
  graphAnalysis: graphAnalysisClient,
@@ -9259,25 +9066,15 @@ function createLucernClient(config = {}) {
9259
9066
  createAcl: toolRegistryClient.createAcl,
9260
9067
  deleteAcl: toolRegistryClient.deleteAcl,
9261
9068
  registerCustomTool: toolRegistryClient.registerCustomTool,
9262
- register(registration) {
9263
- return registerCustomTool(registration);
9264
- },
9265
- unregister(fullName) {
9266
- return unregisterCustomTool(fullName);
9267
- },
9268
- list() {
9269
- return listRegisteredCustomTools();
9270
- },
9271
- clear() {
9272
- clearRegisteredCustomTools();
9273
- },
9069
+ register: registerCustomTool,
9070
+ unregister: unregisterCustomTool,
9071
+ list: listRegisteredCustomTools,
9072
+ clear: clearRegisteredCustomTools,
9274
9073
  invoke(name, input = {}) {
9275
9074
  const fullName = name.includes(".") ? name : `custom.${name}`;
9276
9075
  return invokeCustomTool(fullName, input);
9277
9076
  },
9278
- namespace(namespace) {
9279
- return getCustomNamespace(namespace);
9280
- }
9077
+ namespace: getCustomNamespace
9281
9078
  },
9282
9079
  packs: {
9283
9080
  /**
@@ -9292,27 +9089,13 @@ function createLucernClient(config = {}) {
9292
9089
  get isInstalled() {
9293
9090
  return _packInstalled;
9294
9091
  },
9295
- listCatalog() {
9296
- return packsClient.listCatalog();
9297
- },
9298
- catalog() {
9299
- return packsClient.getCatalog();
9300
- },
9301
- listStates(scope) {
9302
- return packsClient.listStates(scope);
9303
- },
9304
- states(scope) {
9305
- return packsClient.getStates(scope);
9306
- },
9307
- install(input) {
9308
- return packsClient.install(input);
9309
- },
9310
- enable(input) {
9311
- return packsClient.enable(input);
9312
- },
9313
- disable(input) {
9314
- return packsClient.disable(input);
9315
- }
9092
+ listCatalog: packsClient.listCatalog,
9093
+ catalog: packsClient.listCatalog,
9094
+ listStates: packsClient.listStates,
9095
+ states: packsClient.getStates,
9096
+ install: packsClient.install,
9097
+ enable: packsClient.enable,
9098
+ disable: packsClient.disable
9316
9099
  },
9317
9100
  nodes: nodesNamespace,
9318
9101
  identity: {
@@ -9325,30 +9108,16 @@ function createLucernClient(config = {}) {
9325
9108
  raw: identityClient
9326
9109
  },
9327
9110
  mcp: {
9328
- bootstrapSession(input) {
9329
- return mcpClient.bootstrapSession(input);
9330
- },
9331
- checkWritePolicy(input) {
9332
- return mcpClient.checkWritePolicy(input);
9333
- },
9334
- beginBuildSession(input) {
9335
- return mcpClient.beginBuildSession(input);
9336
- },
9337
- evaluateEngineeringContract(input) {
9338
- return mcpClient.evaluateEngineeringContract(input);
9339
- },
9340
- evaluateResearchContract(input) {
9341
- return mcpClient.evaluateResearchContract(input);
9342
- }
9111
+ bootstrapSession: mcpClient.bootstrapSession,
9112
+ checkWritePolicy: mcpClient.checkWritePolicy,
9113
+ beginBuildSession: mcpClient.beginBuildSession,
9114
+ evaluateEngineeringContract: mcpClient.evaluateEngineeringContract,
9115
+ evaluateResearchContract: mcpClient.evaluateResearchContract
9343
9116
  },
9344
9117
  auth: {
9345
9118
  device: {
9346
- createCode(input) {
9347
- return authDeviceClient.createDeviceCode(input);
9348
- },
9349
- pollToken(deviceCode) {
9350
- return authDeviceClient.pollDeviceToken(deviceCode);
9351
- }
9119
+ createCode: authDeviceClient.createDeviceCode,
9120
+ pollToken: authDeviceClient.pollDeviceToken
9352
9121
  }
9353
9122
  },
9354
9123
  custom: getCustomNamespace("custom"),
@@ -9401,50 +9170,55 @@ function cleanNumber2(value) {
9401
9170
  function cleanBoolean2(value) {
9402
9171
  return typeof value === "boolean" ? value : void 0;
9403
9172
  }
9404
- function buildCompileContextRequest2(topicId, input = {}) {
9405
- const payload = { topicId };
9406
- const query5 = cleanString6(input.query);
9173
+ function buildCompileContextRequest2(topicIdOrInput = {}, input = {}) {
9174
+ const effectiveInput = typeof topicIdOrInput === "string" ? input : topicIdOrInput;
9175
+ const payload = {};
9176
+ const topicId = typeof topicIdOrInput === "string" ? cleanString6(topicIdOrInput) : cleanString6(effectiveInput.topicId);
9177
+ if (topicId) {
9178
+ payload.topicId = topicId;
9179
+ }
9180
+ const query5 = cleanString6(effectiveInput.query);
9407
9181
  if (query5) {
9408
9182
  payload.query = query5;
9409
9183
  }
9410
- const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
9184
+ const budget = cleanNumber2(effectiveInput.budget) ?? cleanNumber2(effectiveInput.tokenBudget);
9411
9185
  if (budget !== void 0) {
9412
9186
  payload.budget = budget;
9413
9187
  }
9414
- const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
9188
+ const ranking = cleanString6(effectiveInput.ranking) ?? cleanString6(effectiveInput.rankingProfile);
9415
9189
  if (ranking) {
9416
9190
  payload.ranking = ranking;
9417
9191
  }
9418
- const limit = cleanNumber2(input.limit);
9192
+ const limit = cleanNumber2(effectiveInput.limit);
9419
9193
  if (limit !== void 0) {
9420
9194
  payload.limit = limit;
9421
9195
  }
9422
- const maxDepth = cleanNumber2(input.maxDepth);
9196
+ const maxDepth = cleanNumber2(effectiveInput.maxDepth);
9423
9197
  if (maxDepth !== void 0) {
9424
9198
  payload.maxDepth = maxDepth;
9425
9199
  }
9426
- const includeEntities = cleanBoolean2(input.includeEntities);
9200
+ const includeEntities = cleanBoolean2(effectiveInput.includeEntities);
9427
9201
  if (includeEntities !== void 0) {
9428
9202
  payload.includeEntities = includeEntities;
9429
9203
  }
9430
- const mode = cleanString6(input.mode);
9204
+ const mode = cleanString6(effectiveInput.mode);
9431
9205
  if (mode) {
9432
9206
  payload.mode = mode;
9433
9207
  }
9434
- const includeFailures = cleanBoolean2(input.includeFailures);
9208
+ const includeFailures = cleanBoolean2(effectiveInput.includeFailures);
9435
9209
  if (includeFailures !== void 0) {
9436
9210
  payload.includeFailures = includeFailures;
9437
9211
  }
9438
- const worktreeId = cleanString6(input.worktreeId);
9212
+ const worktreeId = cleanString6(effectiveInput.worktreeId);
9439
9213
  if (worktreeId) {
9440
9214
  payload.worktreeId = worktreeId;
9441
9215
  }
9442
- const sessionId = cleanString6(input.sessionId);
9216
+ const sessionId = cleanString6(effectiveInput.sessionId);
9443
9217
  if (sessionId) {
9444
9218
  payload.sessionId = sessionId;
9445
9219
  }
9446
- if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
9447
- payload.packWeightOverrides = input.packWeightOverrides;
9220
+ if (Array.isArray(effectiveInput.packWeightOverrides) && effectiveInput.packWeightOverrides.length > 0) {
9221
+ payload.packWeightOverrides = effectiveInput.packWeightOverrides;
9448
9222
  }
9449
9223
  return {
9450
9224
  path: "/api/platform/v1/context/compile",
@@ -9454,8 +9228,12 @@ function buildCompileContextRequest2(topicId, input = {}) {
9454
9228
  }
9455
9229
  function createContextFacade(config) {
9456
9230
  return {
9457
- compile(topicId, input = {}) {
9458
- const request = buildCompileContextRequest2(topicId, input);
9231
+ compile(topicIdOrInput = {}, input = {}) {
9232
+ const request = buildCompileContextRequest2(topicIdOrInput, input);
9233
+ return config.transport.request(request);
9234
+ },
9235
+ compileByQuery(input = {}) {
9236
+ const request = buildCompileContextRequest2(input);
9459
9237
  return config.transport.request(request);
9460
9238
  }
9461
9239
  };
@@ -9534,17 +9312,11 @@ var TOKENS_PER_WORD = 1.35;
9534
9312
  var MIN_TOKEN_ESTIMATE = 8;
9535
9313
 
9536
9314
  // src/contextPackPolicy.ts
9537
- function nowMs() {
9538
- return Date.now();
9539
- }
9540
- function normalizeText(text) {
9541
- return text.trim().toLowerCase();
9542
- }
9543
9315
  function tokenHits(text, tokens) {
9544
9316
  if (tokens.length === 0) {
9545
9317
  return 1;
9546
9318
  }
9547
- const haystack = normalizeText(text);
9319
+ const haystack = text.trim().toLowerCase();
9548
9320
  let hits = 0;
9549
9321
  for (const token of tokens) {
9550
9322
  if (haystack.includes(token)) {
@@ -9559,7 +9331,7 @@ function clamp013(value) {
9559
9331
  }
9560
9332
  return Math.max(0, Math.min(1, value));
9561
9333
  }
9562
- function recencyScore(updatedAt, referenceTimeMs = nowMs()) {
9334
+ function recencyScore(updatedAt, referenceTimeMs = Date.now()) {
9563
9335
  if (!updatedAt || !Number.isFinite(updatedAt)) {
9564
9336
  return 0.25;
9565
9337
  }
@@ -9575,15 +9347,15 @@ function confidenceScore(confidence) {
9575
9347
  return clamp013(confidence);
9576
9348
  }
9577
9349
  function priorityScore(priority) {
9578
- const value = normalizeText(priority || "");
9350
+ const value = (priority || "").trim().toLowerCase();
9579
9351
  return PRIORITY_SCORES[value] ?? DEFAULT_PRIORITY_SCORE;
9580
9352
  }
9581
9353
  function severityScore(severity) {
9582
- const value = normalizeText(severity || "");
9354
+ const value = (severity || "").trim().toLowerCase();
9583
9355
  return SEVERITY_SCORES[value] ?? DEFAULT_SEVERITY_SCORE;
9584
9356
  }
9585
9357
  function beliefTypeBonus(beliefType) {
9586
- const value = normalizeText(beliefType || "");
9358
+ const value = (beliefType || "").trim().toLowerCase();
9587
9359
  return BELIEF_TYPE_BONUS[value] ?? DEFAULT_BELIEF_TYPE_BONUS;
9588
9360
  }
9589
9361
  function resolveEffectiveWeights(overrides) {
@@ -9609,7 +9381,7 @@ function generateJustification(_section, candidate, queryTokens, weights) {
9609
9381
  }
9610
9382
  const ts = candidate.updatedAt || candidate.createdAt || null;
9611
9383
  if (ts && Number.isFinite(ts)) {
9612
- const ageDays = Math.max(0, nowMs() - ts) / (1e3 * 60 * 60 * 24);
9384
+ const ageDays = Math.max(0, Date.now() - ts) / (1e3 * 60 * 60 * 24);
9613
9385
  if (ageDays < 1) {
9614
9386
  parts.push("updated today");
9615
9387
  } else if (ageDays < 7) {
@@ -9634,10 +9406,6 @@ function generateJustification(_section, candidate, queryTokens, weights) {
9634
9406
  }
9635
9407
  return parts.join(", ");
9636
9408
  }
9637
- function computeBaselineScore(candidate, queryTokens) {
9638
- const hits = tokenHits(candidate.text, queryTokens);
9639
- return queryTokens.length === 0 ? 1 : hits;
9640
- }
9641
9409
  function computeWeightedScore(section, candidate, queryTokens, effectiveWeights, referenceTimeMs) {
9642
9410
  const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
9643
9411
  const queryComponent = queryTokens.length === 0 ? 0.4 : clamp013(tokenHits(candidate.text, queryTokens) / queryTokens.length);
@@ -9671,7 +9439,7 @@ function rankContextSection(section, rows, queryTokens, limit, profile, options)
9671
9439
  queryTokens,
9672
9440
  effectiveWeights,
9673
9441
  referenceTimeMs
9674
- ) : computeBaselineScore(row, queryTokens);
9442
+ ) : queryTokens.length === 0 ? 1 : tokenHits(row.text, queryTokens);
9675
9443
  const result = { ...row, score };
9676
9444
  if (includeJustifications && profile === "weighted_v1") {
9677
9445
  const weights = (effectiveWeights ?? RANKING_WEIGHTS)[section];
@@ -10038,18 +9806,21 @@ function normalizeQueryTokens(query5) {
10038
9806
  function parseRankingProfile(value) {
10039
9807
  return value === "baseline_v1" ? "baseline_v1" : "weighted_v1";
10040
9808
  }
9809
+ function isRecord5(value) {
9810
+ return value !== null && typeof value === "object" && !Array.isArray(value);
9811
+ }
10041
9812
  function beliefTypeOf(node) {
10042
9813
  if (typeof node.beliefType === "string") {
10043
9814
  return node.beliefType;
10044
9815
  }
10045
- const metadata = node.metadata || {};
9816
+ const metadata = isRecord5(node.metadata) ? node.metadata : {};
10046
9817
  if (typeof metadata.beliefType === "string") {
10047
9818
  return metadata.beliefType;
10048
9819
  }
10049
9820
  return "";
10050
9821
  }
10051
9822
  function questionStatusOf(node) {
10052
- const metadata = node.metadata || {};
9823
+ const metadata = isRecord5(node.metadata) ? node.metadata : {};
10053
9824
  const direct = typeof node.status === "string" ? node.status : "";
10054
9825
  const questionStatus = typeof metadata.questionStatus === "string" ? metadata.questionStatus : "";
10055
9826
  return (questionStatus || direct || "open").toLowerCase();
@@ -10065,9 +9836,6 @@ function isOpenQuestion(status) {
10065
9836
  "belief_forked"
10066
9837
  ].includes(status);
10067
9838
  }
10068
- function metadataText(payload) {
10069
- return JSON.stringify(payload).toLowerCase();
10070
- }
10071
9839
  function collectTopicNeighborhood(topics, rootTopicId, maxDescendantDepth = 2) {
10072
9840
  const byId = /* @__PURE__ */ new Map();
10073
9841
  const children = /* @__PURE__ */ new Map();
@@ -10129,11 +9897,10 @@ function dedupeById(rows) {
10129
9897
  return output;
10130
9898
  }
10131
9899
  function candidateTimestamp(candidate) {
10132
- if (!candidate || typeof candidate !== "object") {
9900
+ if (!isRecord5(candidate)) {
10133
9901
  return 0;
10134
9902
  }
10135
- const record = candidate;
10136
- const timestamps = [record.updatedAt, record.createdAt, record.generatedAt].filter(
9903
+ const timestamps = [candidate.updatedAt, candidate.createdAt, candidate.generatedAt].filter(
10137
9904
  (value) => typeof value === "number" && Number.isFinite(value)
10138
9905
  );
10139
9906
  return timestamps.length > 0 ? Math.max(...timestamps) : 0;
@@ -10255,7 +10022,7 @@ function compileContextPackFromSnapshot(snapshot) {
10255
10022
  beliefType: beliefTypeOf(belief) || null,
10256
10023
  status: belief.status || "active",
10257
10024
  updatedAt: belief.updatedAt || belief.createdAt || null,
10258
- metadataText: belief.metadata && typeof belief.metadata === "object" ? metadataText(belief.metadata) : ""
10025
+ metadataText: belief.metadata && typeof belief.metadata === "object" ? JSON.stringify(belief.metadata).toLowerCase() : ""
10259
10026
  }));
10260
10027
  const activeBeliefs = rankContextSection(
10261
10028
  "activeBeliefs",
@@ -10287,7 +10054,7 @@ function compileContextPackFromSnapshot(snapshot) {
10287
10054
  status,
10288
10055
  priority: typeof metadata.priority === "string" ? metadata.priority : "medium",
10289
10056
  updatedAt: question.updatedAt || question.createdAt || null,
10290
- metadataText: metadataText(metadata)
10057
+ metadataText: JSON.stringify(metadata).toLowerCase()
10291
10058
  };
10292
10059
  }).filter((row) => isOpenQuestion(row.status));
10293
10060
  const openQuestions = rankContextSection(
@@ -10319,7 +10086,7 @@ function compileContextPackFromSnapshot(snapshot) {
10319
10086
  kind: typeof metadata.kind === "string" && metadata.kind || "observation",
10320
10087
  createdAt: item.createdAt || null,
10321
10088
  updatedAt: item.updatedAt || item.createdAt || null,
10322
- metadataText: metadataText(metadata)
10089
+ metadataText: JSON.stringify(metadata).toLowerCase()
10323
10090
  };
10324
10091
  });
10325
10092
  const recentEvidence = rankContextSection(
@@ -10401,7 +10168,7 @@ function compileContextPackFromSnapshot(snapshot) {
10401
10168
  let failureContext;
10402
10169
  if (snapshot.plan.includeFailures && snapshot.failures) {
10403
10170
  const allFailures = snapshot.failures.filter((node) => {
10404
- const metadata = node.metadata || {};
10171
+ const metadata = isRecord5(node.metadata) ? node.metadata : {};
10405
10172
  return metadata.failedApproach === true || metadata.isFailedAttempt === true;
10406
10173
  });
10407
10174
  const rankedFailures = rankContextSection(
@@ -10419,7 +10186,7 @@ function compileContextPackFromSnapshot(snapshot) {
10419
10186
  );
10420
10187
  const failures = rankedFailures.map((row) => {
10421
10188
  const original = allFailures.find((node) => String(node._id) === row.id);
10422
- const metadata = original?.metadata || {};
10189
+ const metadata = isRecord5(original?.metadata) ? original?.metadata : {};
10423
10190
  return {
10424
10191
  attemptId: row.id,
10425
10192
  approach: String(row.text || ""),
@@ -10903,9 +10670,7 @@ function lastDelegator(delegationChain) {
10903
10670
 
10904
10671
  // src/contracts/lens-filter.contract.ts
10905
10672
  function isLensFilterCriteria(value) {
10906
- if (!value || typeof value !== "object") return false;
10907
- const obj = value;
10908
- return typeof obj.version === "number" && typeof obj.kind === "string";
10673
+ return isRecord6(value) && typeof value.version === "number" && typeof value.kind === "string";
10909
10674
  }
10910
10675
  function isTaxonomyFilterCriteriaV1(value) {
10911
10676
  if (!isLensFilterCriteria(value)) return false;
@@ -10934,6 +10699,9 @@ function validateFilterCriteria(value) {
10934
10699
  ]
10935
10700
  };
10936
10701
  }
10702
+ function isRecord6(value) {
10703
+ return value !== null && typeof value === "object" && !Array.isArray(value);
10704
+ }
10937
10705
  function validateTaxonomyFilterV1(criteria) {
10938
10706
  const errors = [];
10939
10707
  if (!Array.isArray(criteria.entityTypeFilters)) {
@@ -11460,6 +11228,9 @@ function fromBase64(value) {
11460
11228
  const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
11461
11229
  return decodeURIComponent(escape(atob(normalized)));
11462
11230
  }
11231
+ function isRecord7(value) {
11232
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
11233
+ }
11463
11234
  function createEventId() {
11464
11235
  const random = typeof globalThis.crypto?.randomUUID === "function" ? globalThis.crypto.randomUUID().replace(/-/g, "") : Array.from(
11465
11236
  typeof globalThis.crypto?.getRandomValues === "function" ? globalThis.crypto.getRandomValues(new Uint8Array(16)) : Array.from({ length: 16 }, () => Math.floor(Math.random() * 256)),
@@ -11508,14 +11279,14 @@ function decodeEventCursor(cursor) {
11508
11279
  }
11509
11280
  try {
11510
11281
  const parsed = JSON.parse(fromBase64(cursor.trim()));
11511
- if (typeof parsed.timestamp !== "number" || !Number.isFinite(parsed.timestamp) || typeof parsed.eventId !== "string" || parsed.eventId.trim().length === 0) {
11282
+ if (!isRecord7(parsed) || typeof parsed.timestamp !== "number" || !Number.isFinite(parsed.timestamp) || typeof parsed.eventId !== "string" || parsed.eventId.trim().length === 0) {
11512
11283
  return null;
11513
11284
  }
11514
11285
  return {
11515
11286
  timestamp: parsed.timestamp,
11516
11287
  eventId: parsed.eventId.trim()
11517
11288
  };
11518
- } catch {
11289
+ } catch (error) {
11519
11290
  return null;
11520
11291
  }
11521
11292
  }
@@ -11544,7 +11315,7 @@ var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"])
11544
11315
  function normalizeUrl(url) {
11545
11316
  try {
11546
11317
  return new URL(url.trim());
11547
- } catch {
11318
+ } catch (error) {
11548
11319
  throw new Error("Webhook URL must be a valid absolute URL.");
11549
11320
  }
11550
11321
  }
@@ -11790,10 +11561,18 @@ function isInfisicalRuntimeDisabled(env = {}) {
11790
11561
  }
11791
11562
  async function hydrateInfisicalRuntimeEnv(options) {
11792
11563
  const env = options.env ?? {};
11793
- const bootstrap = mergeBootstrap(
11794
- readInfisicalRuntimeBootstrap(env, options.bootstrap),
11795
- options.bootstrap
11796
- );
11564
+ const baseBootstrap = readInfisicalRuntimeBootstrap(env, options.bootstrap);
11565
+ const bootstrap = baseBootstrap ? {
11566
+ ...baseBootstrap,
11567
+ ...Object.fromEntries(
11568
+ Object.entries(options.bootstrap ?? {}).filter(
11569
+ ([, value]) => value !== void 0
11570
+ )
11571
+ ),
11572
+ apiUrl: trimTrailingSlash(
11573
+ options.bootstrap?.apiUrl ?? baseBootstrap.apiUrl
11574
+ )
11575
+ } : null;
11797
11576
  if (!bootstrap) {
11798
11577
  return {
11799
11578
  status: "disabled",
@@ -11889,16 +11668,6 @@ function normalizeInfisicalEnvironment(value) {
11889
11668
  }
11890
11669
  return "prod";
11891
11670
  }
11892
- function mergeBootstrap(base, overrides) {
11893
- if (!base) {
11894
- return null;
11895
- }
11896
- return {
11897
- ...base,
11898
- ...compact(overrides ?? {}),
11899
- apiUrl: trimTrailingSlash(overrides?.apiUrl ?? base.apiUrl)
11900
- };
11901
- }
11902
11671
  async function loginWithUniversalAuth(bootstrap, fetchImpl) {
11903
11672
  const response = await fetchImpl(
11904
11673
  `${trimTrailingSlash(bootstrap.apiUrl)}/api/v1/auth/universal-auth/login`,
@@ -11983,14 +11752,18 @@ async function readSecretValue(args) {
11983
11752
  async function readJson2(response) {
11984
11753
  try {
11985
11754
  return await response.json();
11986
- } catch {
11755
+ } catch (error) {
11756
+ debugInfisicalRuntimeFallback("response.json", error);
11987
11757
  return void 0;
11988
11758
  }
11989
11759
  }
11760
+ function isRecord8(value) {
11761
+ return value !== null && typeof value === "object" && !Array.isArray(value);
11762
+ }
11990
11763
  function readNestedString(value, path) {
11991
11764
  let current = value;
11992
11765
  for (const key of path) {
11993
- if (!current || typeof current !== "object" || !(key in current)) {
11766
+ if (!isRecord8(current) || !(key in current)) {
11994
11767
  return null;
11995
11768
  }
11996
11769
  current = current[key];
@@ -11998,13 +11771,12 @@ function readNestedString(value, path) {
11998
11771
  return typeof current === "string" && current.length > 0 ? current : null;
11999
11772
  }
12000
11773
  function messageFromBody(body4) {
12001
- if (!body4 || typeof body4 !== "object") {
11774
+ if (!isRecord8(body4)) {
12002
11775
  return "no response body";
12003
11776
  }
12004
- const record = body4;
12005
11777
  for (const key of ["message", "error", "errorMessage"]) {
12006
- if (typeof record[key] === "string") {
12007
- return record[key];
11778
+ if (typeof body4[key] === "string") {
11779
+ return body4[key];
12008
11780
  }
12009
11781
  }
12010
11782
  return JSON.stringify(body4);
@@ -12024,12 +11796,34 @@ function isTruthyEnv(value) {
12024
11796
  function trimTrailingSlash(value) {
12025
11797
  return value.replace(/\/+$/u, "");
12026
11798
  }
12027
- function compact(value) {
12028
- return Object.fromEntries(
12029
- Object.entries(value).filter(([, entry]) => entry !== void 0)
12030
- );
11799
+ function debugInfisicalRuntimeFallback(message, error) {
11800
+ const env = globalThis.process?.env;
11801
+ if (env?.LUCERN_COMPAT_FALLBACK_DEBUG !== "1" && env?.LUCERN_INFISICAL_RUNTIME_DEBUG !== "1") {
11802
+ return;
11803
+ }
11804
+ console.debug(`[infisical-runtime] ${message}`, {
11805
+ error: formatInfisicalRuntimeError(error)
11806
+ });
11807
+ }
11808
+ function formatInfisicalRuntimeError(error) {
11809
+ if (error instanceof Error) {
11810
+ return `${error.name}: ${error.message}`;
11811
+ }
11812
+ if (typeof error === "string") {
11813
+ return error;
11814
+ }
11815
+ if (typeof error === "number" || typeof error === "boolean") {
11816
+ return String(error);
11817
+ }
11818
+ if (error && typeof error === "object") {
11819
+ const keys = Object.keys(error).slice(0, 5);
11820
+ if (keys.length > 0) {
11821
+ return `Unknown Infisical runtime error object with keys: ${keys.join(", ")}`;
11822
+ }
11823
+ }
11824
+ return "Unknown Infisical runtime error shape";
12031
11825
  }
12032
11826
 
12033
- export { BELIEF_STATUSES, BRANCH_DEPRECATION_MESSAGE, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, CONTROL_OBJECT_BLAST_RADII, CONTROL_OBJECT_EDIT_SURFACES, CONTROL_OBJECT_INHERITANCE_RULES, CONTROL_OBJECT_KINDS, CONTROL_OBJECT_OWNERSHIP_CONTRACT, CONTROL_OBJECT_OWNERSHIP_MATRIX, CONTROL_OBJECT_OWNERSHIP_ROWS, CONTROL_OBJECT_OWNER_SCOPES, CustomToolRegistryError, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, DeviceAuthorizationError, EDGE_TYPES, EMBEDDINGS_FIELDS, EPISTEMIC_EDGE_TYPES, EPISTEMIC_LAYERS, EVENTING_FIELDS, EVENT_RETENTION_DEFAULT_DAYS, FORK_REASONS, FUNCTION_SURFACE_METHOD_PATHS, GRAPH_ANALYSIS_ANALYSIS_FIELDS, GRAPH_ANALYSIS_COMPUTE_FIELDS, GRAPH_ANALYSIS_SUGGESTION_FIELDS, GRAPH_RECOMMENDATION_FIELDS, GRAPH_STATE_CLASSIFIER_FIELDS, InfisicalRuntimeError, JOBS_FIELDS, JUDGMENT_TYPES, LENS_PERSPECTIVE_TYPES, LENS_STATUSES, LENS_TASK_TEMPLATE_PRIORITIES, LUCERN_SDK_VERSION, LucernApiError, LucernSdkAuthContextError, MAX_ENTITY_LIMIT, MCP_ALWAYS_ALLOWED_TOOL_NAMES, MERGE_OUTCOMES, MODEL_RUNTIME_FIELDS, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, ONTOLOGY_LINK_FIELDS, ORG_GRAPH_SEARCH_FIELDS, REASONING_METHODS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, STRUCTURAL_EDGE_TYPES, TELEMETRY_FIELDS, TENANT_IDENTITY_FIELDS, TOOL_REGISTRY_FIELDS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, applyInfisicalRuntimeEnv, asListItems, assertValidWebhookSecret, assertValidWebhookUrl, buildDeprecatedBranchMetadata, buildDomainEvent, buildMcpToolContracts, buildMcpToolManifest, clearRegisteredCustomTools, compareEventCursor, compileContextPackFromSnapshot, computeWebhookSignature, createAdminClient, createAnswersClient, createAudiencesClient, createAuditClient, createAuthDeviceClient, createBeliefsClient, createCanonicalAuthHeaders, createContextClient, createContextFacade, createDecisionsClient, createEmbeddingsClient, createEventId, createEventingClient, createEventsClientCore, createEvidenceClient, createFunctionSurfaceClient, createGatewayRequestClient, createGraphAnalysisClient, createGraphClient, createGraphRecommendationsClient, createGraphStateClassifierClient, createHarnessClient, createIdentityClient, createJobsClient, createLearningClient, createListResult, createLucernClient, createModelRuntimeClient, createOntologyClient, createOntologyLinksClient, createOrgGraphSearchClient, createPacksClient, createPolicyClient, createReportsClient, createSchemaClient, createSourcesClient, createTelemetryClient, createToolRegistryClient, createTopicsClient, createWebhooksClientCore, createWorkflowClient, decodeEventCursor, emitDomainEvent, encodeEventCursor, eventPatternToRegExp, getControlObjectOwnershipCase, getMcpToolExposure, getRegisteredCustomTool, hydrateInfisicalRuntimeEnv, inferActorType, inferLensPerspectiveTypeFromBranchSchema, inferSessionPrincipalType, invokeRegisteredCustomTool, isAfterCursor, isInfisicalRuntimeDisabled, isLensFilterCriteria, isLucernPrompt, isMcpToolAllowed, isTaxonomyFilterCriteriaV1, lastDelegator, listControlObjectOwnershipCases, listRegisteredCustomTools, mapAliasedList, mapGatewayData, mapOpinionHistoryEntriesFromGatewayData, matchesAnyEventPattern, matchesEventPattern, mcpContractToInputSchema, mcpContractToManifestEntry, migrateBranchToLens, nextDeliveryAttemptAt, normalizeCanonicalLucernAuthContext, normalizeDelegationChain, normalizeNodeVerificationStatus, normalizeNodeWriteInput, normalizeRetentionDays, normalizeTopicQuery, normalizeWebhookPatterns, opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected, planContextPackCompilation, randomIdempotencyKey, readInfisicalRuntimeBootstrap, registerCustomTool, resolveDeliveryFailureStatus, resolveText, resolveTopicId, sanitizeWebhookRecord, sortEventsByCursor, toQueryString, truncateWebhookResponseBody, unregisterCustomTool, validateFilterCriteria, withSdkAliases, withTextAlias, withTopicAlias };
11827
+ export { BELIEF_STATUSES, BRANCH_DEPRECATION_MESSAGE, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, CONTROL_OBJECT_BLAST_RADII, CONTROL_OBJECT_EDIT_SURFACES, CONTROL_OBJECT_INHERITANCE_RULES, CONTROL_OBJECT_KINDS, CONTROL_OBJECT_OWNERSHIP_CONTRACT, CONTROL_OBJECT_OWNERSHIP_MATRIX, CONTROL_OBJECT_OWNERSHIP_ROWS, CONTROL_OBJECT_OWNER_SCOPES, CustomToolRegistryError, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, DeviceAuthorizationError, EDGE_TYPES, EMBEDDINGS_FIELDS, EPISTEMIC_EDGE_TYPES, EPISTEMIC_LAYERS, EVENTING_FIELDS, EVENT_RETENTION_DEFAULT_DAYS, FORK_REASONS, FUNCTION_SURFACE_METHOD_PATHS, GRAPH_ANALYSIS_ANALYSIS_FIELDS, GRAPH_ANALYSIS_COMPUTE_FIELDS, GRAPH_ANALYSIS_SUGGESTION_FIELDS, GRAPH_RECOMMENDATION_FIELDS, GRAPH_STATE_CLASSIFIER_FIELDS, InfisicalRuntimeError, JOBS_FIELDS, JUDGMENT_TYPES, LENS_PERSPECTIVE_TYPES, LENS_STATUSES, LENS_TASK_TEMPLATE_PRIORITIES, LUCERN_SDK_VERSION, LucernApiError, LucernSdkAuthContextError, MAX_ENTITY_LIMIT, MCP_ALWAYS_ALLOWED_TOOL_NAMES, MERGE_OUTCOMES, MODEL_RUNTIME_FIELDS, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, ONTOLOGY_LINK_FIELDS, ORG_GRAPH_SEARCH_FIELDS, REASONING_METHODS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, STRUCTURAL_EDGE_TYPES, TELEMETRY_FIELDS, TENANT_IDENTITY_FIELDS, TOOL_REGISTRY_FIELDS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, applyInfisicalRuntimeEnv, asListItems, asRecord, assertValidWebhookSecret, assertValidWebhookUrl, buildDeprecatedBranchMetadata, buildDomainEvent, buildMcpToolContracts, buildMcpToolManifest, clearRegisteredCustomTools, compareEventCursor, compileContextPackFromSnapshot, computeWebhookSignature, createAdminClient, createAnswersClient, createAudiencesClient, createAuditClient, createAuthDeviceClient, createBeliefsClient, createCanonicalAuthHeaders, createContextClient, createContextFacade, createDecisionsClient, createEmbeddingsClient, createEventId, createEventingClient, createEventsClientCore, createEvidenceClient, createFunctionSurfaceClient, createGatewayRequestClient, createGraphAnalysisClient, createGraphClient, createGraphRecommendationsClient, createGraphStateClassifierClient, createHarnessClient, createIdentityClient, createJobsClient, createLearningClient, createListResult, createLucernClient, createModelRuntimeClient, createOntologyClient, createOntologyLinksClient, createOrgGraphSearchClient, createPacksClient, createPolicyClient, createReportsClient, createSchemaClient, createSourcesClient, createTelemetryClient, createToolRegistryClient, createTopicsClient, createWebhooksClientCore, createWorkflowClient, decodeEventCursor, emitDomainEvent, encodeEventCursor, eventPatternToRegExp, getControlObjectOwnershipCase, getMcpToolExposure, getRegisteredCustomTool, hydrateInfisicalRuntimeEnv, inferActorType, inferLensPerspectiveTypeFromBranchSchema, inferSessionPrincipalType, invokeRegisteredCustomTool, isAfterCursor, isInfisicalRuntimeDisabled, isLensFilterCriteria, isLucernPrompt, isMcpToolAllowed, isRecord2 as isRecord, isTaxonomyFilterCriteriaV1, lastDelegator, listControlObjectOwnershipCases, listRegisteredCustomTools, mapAliasedList, mapGatewayData, mapOpinionHistoryEntriesFromGatewayData, matchesAnyEventPattern, matchesEventPattern, mcpContractToInputSchema, mcpContractToManifestEntry, migrateBranchToLens, nextDeliveryAttemptAt, normalizeCanonicalLucernAuthContext, normalizeDelegationChain, normalizeNodeVerificationStatus, normalizeNodeWriteInput, normalizeRetentionDays, normalizeTopicQuery, normalizeWebhookPatterns, opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected, planContextPackCompilation, randomIdempotencyKey, readInfisicalRuntimeBootstrap, registerCustomTool, resolveDeliveryFailureStatus, resolveText, resolveTopicId, sanitizeWebhookRecord, sortEventsByCursor, toQueryString, truncateWebhookResponseBody, unregisterCustomTool, validateFilterCriteria, withSdkAliases, withTextAlias, withTopicAlias };
12034
11828
  //# sourceMappingURL=index.js.map
12035
11829
  //# sourceMappingURL=index.js.map