@lucern/sdk 1.0.10 → 1.0.12

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 (331) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +35 -0
  3. package/dist/.generated +2 -0
  4. package/dist/accessControl.d.ts +19 -26
  5. package/dist/accessControl.js +195 -1423
  6. package/dist/adminClient.d.ts +52 -59
  7. package/dist/adminClient.js +364 -1142
  8. package/dist/answersClient.d.ts +5 -14
  9. package/dist/answersClient.js +19 -737
  10. package/dist/audience/index.d.ts +18 -18
  11. package/dist/audience/index.js +87 -90
  12. package/dist/audiencesClient.d.ts +19 -27
  13. package/dist/audiencesClient.js +107 -868
  14. package/dist/auditClient.d.ts +8 -15
  15. package/dist/auditClient.js +18 -791
  16. package/dist/authContext.d.ts +11 -16
  17. package/dist/authContext.js +122 -154
  18. package/dist/authDeviceClient.d.ts +8 -17
  19. package/dist/authDeviceClient.js +113 -102
  20. package/dist/beliefs/index.d.ts +15 -67
  21. package/dist/beliefs/index.js +17 -10172
  22. package/dist/beliefs/lifecycle.d.ts +10 -11
  23. package/dist/beliefs/lifecycle.js +78 -80
  24. package/dist/beliefsClient.d.ts +26 -32
  25. package/dist/beliefsClient.js +250 -990
  26. package/dist/boundaryClientSurface.d.ts +11 -16
  27. package/dist/boundaryClientSurface.js +49 -68
  28. package/dist/client.d.ts +73 -112
  29. package/dist/client.js +232 -10146
  30. package/dist/clientAssemblyTypes.d.ts +3 -3
  31. package/dist/clientAssemblyTypes.js +1 -2
  32. package/dist/clientConfig.d.ts +45 -59
  33. package/dist/clientConfig.js +1 -2
  34. package/dist/clientEvidenceCompat.d.ts +7 -14
  35. package/dist/clientEvidenceCompat.js +50 -64
  36. package/dist/clientGraphNamespaces.d.ts +3 -5
  37. package/dist/clientGraphNamespaces.js +170 -245
  38. package/dist/clientHelpers.d.ts +20 -25
  39. package/dist/clientHelpers.js +104 -127
  40. package/dist/clientKnowledgeNamespaces.d.ts +6 -53
  41. package/dist/clientKnowledgeNamespaces.js +502 -506
  42. package/dist/clientLocalHelpers.d.ts +11 -56
  43. package/dist/clientLocalHelpers.js +503 -732
  44. package/dist/clientPlatformNamespaces.d.ts +14 -53
  45. package/dist/clientPlatformNamespaces.js +229 -314
  46. package/dist/clientRuntime.d.ts +5 -53
  47. package/dist/clientRuntime.js +26 -30
  48. package/dist/clientWorkflowNamespaces.d.ts +6 -15
  49. package/dist/clientWorkflowNamespaces.js +529 -596
  50. package/dist/contextClient.d.ts +9 -17
  51. package/dist/contextClient.js +92 -805
  52. package/dist/contextFacade.d.ts +11 -2
  53. package/dist/contextFacade.js +10 -81
  54. package/dist/contextPackCompiler.d.ts +10 -11
  55. package/dist/contextPackCompiler.js +494 -1040
  56. package/dist/contextPackPolicy.d.ts +14 -15
  57. package/dist/contextPackPolicy.js +227 -305
  58. package/dist/contextPackSchema.d.ts +3 -3
  59. package/dist/contextPackSchema.js +169 -176
  60. package/dist/contextTypes.d.ts +14 -15
  61. package/dist/contextTypes.js +1 -2
  62. package/dist/contracts/api-enums.contract.d.ts +29 -30
  63. package/dist/contracts/api-enums.contract.js +162 -88
  64. package/dist/contracts/auth-session.contract.d.ts +13 -14
  65. package/dist/contracts/auth-session.contract.js +55 -52
  66. package/dist/contracts/context-pack.contract.d.ts +54 -55
  67. package/dist/contracts/context-pack.contract.js +160 -88
  68. package/dist/contracts/contextPack.d.ts +2 -1
  69. package/dist/contracts/contextPack.js +1 -97
  70. package/dist/contracts/index.d.ts +11 -12
  71. package/dist/contracts/index.js +10 -854
  72. package/dist/contracts/lens-filter.contract.d.ts +9 -10
  73. package/dist/contracts/lens-filter.contract.js +82 -58
  74. package/dist/contracts/lens-workflow.contract.d.ts +21 -23
  75. package/dist/contracts/lens-workflow.contract.js +48 -117
  76. package/dist/contracts/lensFilter.d.ts +2 -1
  77. package/dist/contracts/lensFilter.js +1 -71
  78. package/dist/contracts/lensWorkflow.d.ts +2 -2
  79. package/dist/contracts/lensWorkflow.js +1 -123
  80. package/dist/contracts/mcpTools.d.ts +16 -18
  81. package/dist/contracts/mcpTools.js +89 -123
  82. package/dist/contracts/prompt.contract.d.ts +4 -5
  83. package/dist/contracts/prompt.contract.js +23 -10
  84. package/dist/contracts/prompt.d.ts +2 -1
  85. package/dist/contracts/prompt.js +1 -11
  86. package/dist/contracts/sdk-tools.contract.d.ts +2 -1
  87. package/dist/contracts/sdk-tools.contract.js +1 -2
  88. package/dist/contracts/sdkTools.d.ts +2 -1
  89. package/dist/contracts/sdkTools.js +1 -26
  90. package/dist/contracts/tool-contracts.d.ts +2 -1
  91. package/dist/contracts/tool-contracts.js +1 -2
  92. package/dist/contracts/workflow-runtime.contract.d.ts +45 -46
  93. package/dist/contracts/workflow-runtime.contract.js +241 -228
  94. package/dist/contracts/workflowRuntime.d.ts +2 -1
  95. package/dist/contracts/workflowRuntime.js +1 -244
  96. package/dist/contradictions/index.d.ts +8 -60
  97. package/dist/contradictions/index.js +11 -10166
  98. package/dist/control-plane.d.ts +17 -24
  99. package/dist/control-plane.js +124 -840
  100. package/dist/controlObjectOwnership.d.ts +19 -20
  101. package/dist/controlObjectOwnership.js +207 -201
  102. package/dist/coreClient.d.ts +23 -28
  103. package/dist/coreClient.js +567 -692
  104. package/dist/customTools.d.ts +17 -21
  105. package/dist/customTools.js +221 -221
  106. package/dist/decisions/index.d.ts +7 -58
  107. package/dist/decisions/index.js +14 -10168
  108. package/dist/decisionsClient.d.ts +25 -32
  109. package/dist/decisionsClient.js +113 -913
  110. package/dist/domainContext.d.ts +2 -1
  111. package/dist/domainContext.js +1 -2
  112. package/dist/edges/index.d.ts +21 -73
  113. package/dist/edges/index.js +12 -10167
  114. package/dist/embeddingsClient.d.ts +22 -30
  115. package/dist/embeddingsClient.js +73 -922
  116. package/dist/eventingClient.d.ts +23 -31
  117. package/dist/eventingClient.js +89 -918
  118. package/dist/events.d.ts +48 -49
  119. package/dist/events.js +257 -241
  120. package/dist/eventsCore.d.ts +20 -29
  121. package/dist/eventsCore.js +86 -830
  122. package/dist/evidence/index.d.ts +9 -60
  123. package/dist/evidence/index.js +13 -10167
  124. package/dist/evidenceClient.d.ts +13 -22
  125. package/dist/evidenceClient.js +34 -751
  126. package/dist/facade/context.d.ts +7 -8
  127. package/dist/facade/context.js +73 -72
  128. package/dist/functionSurface.d.ts +2 -156
  129. package/dist/functionSurface.js +1 -1460
  130. package/dist/functionSurfaceClient.d.ts +2 -9
  131. package/dist/functionSurfaceClient.js +1 -1460
  132. package/dist/gatewayFacades.d.ts +79 -296
  133. package/dist/gatewayFacades.factories.d.ts +209 -14
  134. package/dist/gatewayFacades.factories.js +561 -2227
  135. package/dist/gatewayFacades.js +284 -2627
  136. package/dist/generated/functionSurface.d.ts +149 -0
  137. package/dist/generated/functionSurface.js +749 -0
  138. package/dist/graphAnalysisClient.d.ts +41 -49
  139. package/dist/graphAnalysisClient.js +185 -974
  140. package/dist/graphClient.d.ts +53 -60
  141. package/dist/graphClient.js +219 -1090
  142. package/dist/graphIntel.d.ts +2 -4
  143. package/dist/graphIntel.js +1 -2
  144. package/dist/graphIntelligence.d.ts +4 -2
  145. package/dist/graphIntelligence.js +2 -46
  146. package/dist/graphRecommendationsClient.d.ts +15 -23
  147. package/dist/graphRecommendationsClient.js +70 -849
  148. package/dist/graphStateClassifierClient.d.ts +17 -25
  149. package/dist/graphStateClassifierClient.js +67 -908
  150. package/dist/harnessClient.d.ts +40 -47
  151. package/dist/harnessClient.js +198 -993
  152. package/dist/identityClient.d.ts +25 -33
  153. package/dist/identityClient.js +245 -1186
  154. package/dist/index.d.ts +73 -69
  155. package/dist/index.js +72 -13304
  156. package/dist/infisicalRuntime.d.ts +12 -14
  157. package/dist/infisicalRuntime.js +290 -297
  158. package/dist/jobsClient.d.ts +24 -32
  159. package/dist/jobsClient.js +101 -916
  160. package/dist/learningClient.d.ts +8 -16
  161. package/dist/learningClient.js +45 -809
  162. package/dist/lenses/index.d.ts +13 -65
  163. package/dist/lenses/index.js +11 -10166
  164. package/dist/mcpClient.d.ts +14 -23
  165. package/dist/mcpClient.js +115 -856
  166. package/dist/modelRuntimeClient.d.ts +18 -26
  167. package/dist/modelRuntimeClient.js +74 -894
  168. package/dist/nodes/index.d.ts +7 -58
  169. package/dist/nodes/index.js +14 -10168
  170. package/dist/ontologies/index.d.ts +21 -73
  171. package/dist/ontologies/index.js +14 -10169
  172. package/dist/ontologyClient.d.ts +23 -31
  173. package/dist/ontologyClient.js +138 -924
  174. package/dist/ontologyLinksClient.d.ts +16 -24
  175. package/dist/ontologyLinksClient.js +76 -886
  176. package/dist/opinion.d.ts +5 -6
  177. package/dist/opinion.js +21 -25
  178. package/dist/orgGraphSearchClient.d.ts +19 -27
  179. package/dist/orgGraphSearchClient.js +89 -857
  180. package/dist/packRuntime.d.ts +2 -2
  181. package/dist/packRuntime.js +1 -2
  182. package/dist/packsClient.d.ts +30 -37
  183. package/dist/packsClient.js +131 -906
  184. package/dist/policyClient.d.ts +21 -29
  185. package/dist/policyClient.js +267 -1026
  186. package/dist/proof-attestation.json +1 -1
  187. package/dist/questions/index.d.ts +9 -60
  188. package/dist/questions/index.js +15 -10169
  189. package/dist/realtime/index.d.ts +20 -16
  190. package/dist/realtime/index.js +30 -19
  191. package/dist/realtime/refs.d.ts +4 -6
  192. package/dist/realtime/refs.js +12 -7
  193. package/dist/realtime-refs.d.ts +1 -0
  194. package/dist/realtime-refs.js +1 -0
  195. package/dist/realtime.d.ts +1 -0
  196. package/dist/realtime.js +1 -0
  197. package/dist/reportsClient.d.ts +10 -19
  198. package/dist/reportsClient.js +48 -836
  199. package/dist/schemaClient.d.ts +16 -23
  200. package/dist/schemaClient.js +62 -832
  201. package/dist/sdkSurface.d.ts +18 -25
  202. package/dist/sdkSurface.js +135 -106
  203. package/dist/secrets.d.ts +2 -1
  204. package/dist/secrets.js +1 -2
  205. package/dist/sourcesClient.d.ts +11 -18
  206. package/dist/sourcesClient.js +18 -741
  207. package/dist/telemetryClient.d.ts +22 -30
  208. package/dist/telemetryClient.js +107 -931
  209. package/dist/toolRegistryClient.d.ts +27 -35
  210. package/dist/toolRegistryClient.js +116 -954
  211. package/dist/topics/index.d.ts +13 -64
  212. package/dist/topics/index.js +15 -10169
  213. package/dist/topicsClient.d.ts +19 -27
  214. package/dist/topicsClient.js +106 -894
  215. package/dist/types.d.ts +84 -87
  216. package/dist/types.js +1 -2
  217. package/dist/version.d.ts +2 -3
  218. package/dist/version.js +2 -5
  219. package/dist/workflowClient.d.ts +60 -65
  220. package/dist/workflowClient.js +343 -1219
  221. package/dist/worktrees/index.d.ts +16 -68
  222. package/dist/worktrees/index.js +14 -10169
  223. package/package.json +6 -6
  224. package/dist/accessControl.js.map +0 -1
  225. package/dist/adminClient.js.map +0 -1
  226. package/dist/answersClient.js.map +0 -1
  227. package/dist/audience/index.js.map +0 -1
  228. package/dist/audiencesClient.js.map +0 -1
  229. package/dist/auditClient.js.map +0 -1
  230. package/dist/authContext.js.map +0 -1
  231. package/dist/authDeviceClient.js.map +0 -1
  232. package/dist/beliefs/index.js.map +0 -1
  233. package/dist/beliefs/lifecycle.js.map +0 -1
  234. package/dist/beliefsClient.js.map +0 -1
  235. package/dist/boundaryClientSurface.js.map +0 -1
  236. package/dist/client.js.map +0 -1
  237. package/dist/clientAssemblyTypes.js.map +0 -1
  238. package/dist/clientConfig.js.map +0 -1
  239. package/dist/clientEvidenceCompat.js.map +0 -1
  240. package/dist/clientGraphNamespaces.js.map +0 -1
  241. package/dist/clientHelpers.js.map +0 -1
  242. package/dist/clientKnowledgeNamespaces.js.map +0 -1
  243. package/dist/clientLocalHelpers.js.map +0 -1
  244. package/dist/clientPlatformNamespaces.js.map +0 -1
  245. package/dist/clientRuntime.js.map +0 -1
  246. package/dist/clientWorkflowNamespaces.js.map +0 -1
  247. package/dist/contextClient.js.map +0 -1
  248. package/dist/contextFacade.js.map +0 -1
  249. package/dist/contextPackCompiler.js.map +0 -1
  250. package/dist/contextPackPolicy.js.map +0 -1
  251. package/dist/contextPackSchema.js.map +0 -1
  252. package/dist/contextTypes.js.map +0 -1
  253. package/dist/contracts/api-enums.contract.js.map +0 -1
  254. package/dist/contracts/auth-session.contract.js.map +0 -1
  255. package/dist/contracts/context-pack.contract.js.map +0 -1
  256. package/dist/contracts/contextPack.js.map +0 -1
  257. package/dist/contracts/index.js.map +0 -1
  258. package/dist/contracts/lens-filter.contract.js.map +0 -1
  259. package/dist/contracts/lens-workflow.contract.js.map +0 -1
  260. package/dist/contracts/lensFilter.js.map +0 -1
  261. package/dist/contracts/lensWorkflow.js.map +0 -1
  262. package/dist/contracts/mcpTools.js.map +0 -1
  263. package/dist/contracts/prompt.contract.js.map +0 -1
  264. package/dist/contracts/prompt.js.map +0 -1
  265. package/dist/contracts/sdk-tools.contract.js.map +0 -1
  266. package/dist/contracts/sdkTools.js.map +0 -1
  267. package/dist/contracts/tool-contracts.js.map +0 -1
  268. package/dist/contracts/workflow-runtime.contract.js.map +0 -1
  269. package/dist/contracts/workflowRuntime.js.map +0 -1
  270. package/dist/contradictions/index.js.map +0 -1
  271. package/dist/control-plane.js.map +0 -1
  272. package/dist/controlObjectOwnership.js.map +0 -1
  273. package/dist/coreClient.js.map +0 -1
  274. package/dist/customTools.js.map +0 -1
  275. package/dist/decisions/index.js.map +0 -1
  276. package/dist/decisionsClient.js.map +0 -1
  277. package/dist/domainContext.js.map +0 -1
  278. package/dist/edges/index.js.map +0 -1
  279. package/dist/embeddingsClient.js.map +0 -1
  280. package/dist/eventingClient.js.map +0 -1
  281. package/dist/events.js.map +0 -1
  282. package/dist/eventsCore.js.map +0 -1
  283. package/dist/evidence/index.js.map +0 -1
  284. package/dist/evidenceClient.js.map +0 -1
  285. package/dist/facade/context.js.map +0 -1
  286. package/dist/functionSurface.js.map +0 -1
  287. package/dist/functionSurfaceClient.js.map +0 -1
  288. package/dist/gatewayFacades.factories.js.map +0 -1
  289. package/dist/gatewayFacades.js.map +0 -1
  290. package/dist/graphAnalysisClient.js.map +0 -1
  291. package/dist/graphClient.js.map +0 -1
  292. package/dist/graphIntel.js.map +0 -1
  293. package/dist/graphIntelligence.js.map +0 -1
  294. package/dist/graphRecommendationsClient.js.map +0 -1
  295. package/dist/graphStateClassifierClient.js.map +0 -1
  296. package/dist/harnessClient.js.map +0 -1
  297. package/dist/identityClient.js.map +0 -1
  298. package/dist/index.js.map +0 -1
  299. package/dist/infisicalRuntime.js.map +0 -1
  300. package/dist/jobsClient.js.map +0 -1
  301. package/dist/learningClient.js.map +0 -1
  302. package/dist/lenses/index.js.map +0 -1
  303. package/dist/mcpClient.js.map +0 -1
  304. package/dist/modelRuntimeClient.js.map +0 -1
  305. package/dist/nodes/index.js.map +0 -1
  306. package/dist/ontologies/index.js.map +0 -1
  307. package/dist/ontologyClient.js.map +0 -1
  308. package/dist/ontologyLinksClient.js.map +0 -1
  309. package/dist/opinion.js.map +0 -1
  310. package/dist/orgGraphSearchClient.js.map +0 -1
  311. package/dist/packRuntime.js.map +0 -1
  312. package/dist/packsClient.js.map +0 -1
  313. package/dist/policyClient.js.map +0 -1
  314. package/dist/questions/index.js.map +0 -1
  315. package/dist/realtime/index.js.map +0 -1
  316. package/dist/realtime/refs.js.map +0 -1
  317. package/dist/reportsClient.js.map +0 -1
  318. package/dist/schemaClient.js.map +0 -1
  319. package/dist/sdk-tools.contract-B4c1Zr1o.d.ts +0 -22
  320. package/dist/sdkSurface.js.map +0 -1
  321. package/dist/secrets.js.map +0 -1
  322. package/dist/sourcesClient.js.map +0 -1
  323. package/dist/telemetryClient.js.map +0 -1
  324. package/dist/tool-contracts-BUiL9P6z.d.ts +0 -22
  325. package/dist/toolRegistryClient.js.map +0 -1
  326. package/dist/topics/index.js.map +0 -1
  327. package/dist/topicsClient.js.map +0 -1
  328. package/dist/types.js.map +0 -1
  329. package/dist/version.js.map +0 -1
  330. package/dist/workflowClient.js.map +0 -1
  331. package/dist/worktrees/index.js.map +0 -1
@@ -1,2249 +1,583 @@
1
- import { createTelemetryExporterFromEnv, emitTelemetrySignal } from '@lucern/transport-core';
2
- import { redactDiagnosticValue } from '@lucern/transport-core/redaction';
3
- import { classifyRetry } from '@lucern/transport-core/transport';
4
- import { Effect, Exit, Cause } from 'effect';
5
-
6
- // src/coreClient.ts
7
-
8
- // src/authContext.ts
9
- var LucernSdkAuthContextError = class extends Error {
10
- reason;
11
- constructor(reason, message) {
12
- super(message);
13
- this.name = "LucernSdkAuthContextError";
14
- this.reason = reason;
15
- }
16
- };
17
- function cleanString(value) {
18
- const normalized = value?.trim();
19
- return normalized ? normalized : void 0;
20
- }
21
- function cleanStringList(values) {
22
- if (!values) {
23
- return [];
24
- }
25
- return values.map((value) => value.trim()).filter(
26
- (value, index, list) => value.length > 0 && list.indexOf(value) === index
27
- );
28
- }
29
- function requireString(value, reason, label) {
30
- const normalized = cleanString(value);
31
- if (!normalized) {
32
- throw new LucernSdkAuthContextError(
33
- reason,
34
- `Canonical Lucern SDK auth context is missing ${label}.`
35
- );
36
- }
37
- return normalized;
38
- }
39
- function requirePrincipalType(principalType2) {
40
- if (!principalType2) {
41
- throw new LucernSdkAuthContextError(
42
- "principal_missing",
43
- "Canonical Lucern SDK auth context is missing principalType."
44
- );
45
- }
46
- return principalType2;
47
- }
48
- function requireAuthMode(authMode) {
49
- if (!authMode) {
50
- throw new LucernSdkAuthContextError(
51
- "principal_missing",
52
- "Canonical Lucern SDK auth context is missing authMode."
53
- );
54
- }
55
- return authMode;
56
- }
57
- function ensurePermitMatch(args) {
58
- const actual = cleanString(args.actual);
59
- if (actual && actual !== args.expected) {
60
- throw new LucernSdkAuthContextError(
61
- "policy_denied",
62
- `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
63
- );
64
- }
65
- }
66
- function normalizeCanonicalLucernAuthContext(input) {
67
- if (!input) {
68
- throw new LucernSdkAuthContextError(
69
- "principal_missing",
70
- "Canonical Lucern SDK auth context is required."
71
- );
72
- }
73
- if (input.policyDecision === "deny") {
74
- throw new LucernSdkAuthContextError(
75
- "policy_denied",
76
- "Canonical Lucern SDK auth context carries a denied policy decision."
77
- );
78
- }
79
- const principalId = requireString(
80
- input.principalId,
81
- "principal_missing",
82
- "principalId"
83
- );
84
- const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
85
- const workspaceId = requireString(
86
- input.workspaceId,
87
- "workspace_missing",
88
- "workspaceId"
89
- );
90
- const roles = cleanStringList(input.roles);
91
- const scopes = cleanStringList(input.scopes);
92
- const principalType2 = requirePrincipalType(input.principalType);
93
- const authMode = requireAuthMode(input.authMode);
94
- const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
95
- if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
96
- throw new LucernSdkAuthContextError(
97
- "membership_missing",
98
- "Canonical Lucern SDK auth context requires non-empty roles and scopes."
99
- );
100
- }
101
- const subject = cleanString(input.permit?.subject) ?? principalId;
102
- const tenant = cleanString(input.permit?.tenant) ?? tenantId;
103
- const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
104
- ensurePermitMatch({
105
- field: "subject",
106
- expected: principalId,
107
- actual: subject
108
- });
109
- ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
110
- ensurePermitMatch({
111
- field: "workspace",
112
- expected: workspaceId,
113
- actual: workspace
114
- });
115
- const context = input.permit?.context ? { ...input.permit.context } : void 0;
116
- return {
117
- clerkId: cleanString(input.clerkId),
118
- principalId,
119
- tenantId,
120
- workspaceId,
121
- principalType: principalType2,
122
- authMode,
123
- roles,
124
- scopes,
125
- delegationChain: input.delegationChain ? [...input.delegationChain] : [],
126
- policyTraceId: cleanString(input.policyTraceId),
127
- correlationId: cleanString(input.correlationId),
128
- membershipId: cleanString(input.membershipId),
129
- permit: {
130
- subject,
131
- tenant,
132
- workspace,
133
- resource: cleanString(input.permit?.resource),
134
- action: cleanString(input.permit?.action),
135
- relation: cleanString(input.permit?.relation),
136
- context
137
- }
138
- };
139
- }
140
- function createCanonicalAuthHeaders(authContext) {
141
- const headers = {
142
- "x-lucern-principal-id": authContext.principalId,
143
- "x-lucern-principal-type": authContext.principalType,
144
- "x-lucern-tenant": authContext.tenantId,
145
- "x-lucern-tenant-id": authContext.tenantId,
146
- "x-lucern-workspace": authContext.workspaceId,
147
- "x-lucern-workspace-id": authContext.workspaceId,
148
- "x-lucern-auth-mode": authContext.authMode,
149
- "x-lucern-roles": authContext.roles.join(","),
150
- "x-lucern-scopes": authContext.scopes.join(","),
151
- "x-lucern-permit-context": JSON.stringify(authContext.permit)
152
- };
153
- if (authContext.clerkId) {
154
- headers["x-lucern-clerk-id"] = authContext.clerkId;
155
- headers["x-lucern-user-id"] = authContext.clerkId;
156
- }
157
- if (authContext.delegationChain.length > 0) {
158
- headers["x-lucern-delegation-chain"] = JSON.stringify(
159
- authContext.delegationChain
160
- );
161
- }
162
- if (authContext.policyTraceId) {
163
- headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
164
- }
165
- if (authContext.correlationId) {
166
- headers["x-correlation-id"] = authContext.correlationId;
167
- headers["x-lucern-correlation-id"] = authContext.correlationId;
168
- }
169
- if (authContext.membershipId) {
170
- headers["x-lucern-membership-id"] = authContext.membershipId;
171
- }
172
- return headers;
173
- }
174
-
175
- // src/coreClient.ts
176
- var DEFAULT_GATEWAY_TIMEOUT_MS = 15e3;
177
- var DEFAULT_GATEWAY_MAX_RETRIES = 2;
178
- var DEFAULT_ENV_TIMEOUT_MS = "LUCERN_REQUEST_TIMEOUT_MS";
179
- var DEFAULT_ENV_MAX_RETRIES = "LUCERN_GATEWAY_MAX_RETRIES";
180
- var ENV_TIMEOUT_BY_METHOD_PREFIX = "LUCERN_REQUEST_TIMEOUT_MS_";
181
- var GatewayTimeoutError = class extends Error {
182
- retryable = true;
183
- timeoutMs;
184
- constructor(timeoutMs) {
185
- super(`Request timed out after ${timeoutMs}ms`);
186
- this.name = "AbortError";
187
- this.timeoutMs = timeoutMs;
188
- }
189
- };
190
- var GatewayTransportError = class extends Error {
191
- retryable;
192
- cause;
193
- constructor(message, options) {
194
- super(message);
195
- this.name = "GatewayTransportError";
196
- this.retryable = options?.retryable ?? true;
197
- this.cause = options?.cause;
198
- }
199
- };
200
- function isGatewayRetryableError(error) {
201
- return error instanceof GatewayTimeoutError && error.retryable || error instanceof GatewayTransportError && error.retryable || false;
202
- }
203
- var LucernApiError = class extends Error {
204
- code;
205
- status;
206
- invariant;
207
- suggestion;
208
- details;
209
- requestId;
210
- correlationId;
211
- policyTraceId;
212
- constructor(args) {
213
- super(args.message);
214
- this.name = "LucernApiError";
215
- this.code = args.code;
216
- this.status = args.status;
217
- this.invariant = args.invariant;
218
- this.suggestion = args.suggestion;
219
- this.details = args.details;
220
- this.requestId = args.requestId;
221
- this.correlationId = args.correlationId;
222
- this.policyTraceId = args.policyTraceId;
223
- }
224
- };
225
- function toQueryString(scope) {
226
- const params = new URLSearchParams();
227
- if (scope.tenantId) {
228
- params.set("tenantId", scope.tenantId);
229
- }
230
- if (scope.workspaceId) {
231
- params.set("workspaceId", scope.workspaceId);
232
- }
233
- for (const [key, value] of Object.entries(scope)) {
234
- if (key === "tenantId" || key === "workspaceId") {
235
- continue;
236
- }
237
- if (value === void 0) {
238
- continue;
239
- }
240
- params.set(key, String(value));
241
- }
242
- const serialized = params.toString();
243
- return serialized.length > 0 ? `?${serialized}` : "";
244
- }
245
- function fillRandomBytes(length) {
246
- const bytes = new Uint8Array(length);
247
- if (typeof globalThis.crypto?.getRandomValues === "function") {
248
- globalThis.crypto.getRandomValues(bytes);
249
- return bytes;
250
- }
251
- for (let index = 0; index < length; index += 1) {
252
- bytes[index] = Math.floor(Math.random() * 256);
253
- }
254
- return bytes;
255
- }
256
- function generatePortableRequestId() {
257
- if (typeof globalThis.crypto?.randomUUID === "function") {
258
- return globalThis.crypto.randomUUID();
259
- }
260
- const bytes = fillRandomBytes(16);
261
- bytes[6] = bytes[6] & 15 | 64;
262
- bytes[8] = bytes[8] & 63 | 128;
263
- const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
264
- return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
265
- 6,
266
- 8
267
- ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
268
- }
269
- function resolveEnvironment() {
270
- const processEnv = typeof globalThis === "object" && globalThis !== null && "process" in globalThis ? globalThis.process : void 0;
271
- const env = processEnv !== void 0 && typeof processEnv === "object" && processEnv !== null && typeof processEnv.env === "object" ? processEnv.env : void 0;
272
- return {
273
- get: (name) => {
274
- const value = env?.[name];
275
- return typeof value === "string" && value.length > 0 ? value : void 0;
276
- }
277
- };
278
- }
279
- function telemetryEnvironmentRecord(environment) {
280
- const names = [
281
- "LUCERN_TELEMETRY_ENABLED",
282
- "AXIOM_TELEMETRY_ENABLED",
283
- "LUCERN_AXIOM_TOKEN",
284
- "AXIOM_TOKEN",
285
- "LUCERN_AXIOM_EVENTS_DATASET",
286
- "LUCERN_AXIOM_DATASET",
287
- "AXIOM_EVENTS_DATASET",
288
- "AXIOM_DATASET",
289
- "LUCERN_AXIOM_API_URL",
290
- "AXIOM_URL",
291
- "LUCERN_ENVIRONMENT",
292
- "NODE_ENV",
293
- "LUCERN_RELEASE",
294
- "SENTRY_RELEASE",
295
- "VERCEL_GIT_COMMIT_SHA"
296
- ];
297
- return Object.fromEntries(
298
- names.map((name) => [name, environment.get(name)])
299
- );
300
- }
301
- function resolveRequestProfile(config, environment) {
302
- const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
303
- const parsedMaxRetries = parseIntegerFromString(
304
- config.maxRetries,
305
- environment.get(DEFAULT_ENV_MAX_RETRIES)
306
- );
307
- const parsedTimeoutMs = parseIntegerFromString(
308
- config.timeoutMs,
309
- environment.get(DEFAULT_ENV_TIMEOUT_MS)
310
- );
311
- const methodTimeouts = {
312
- ...config.timeoutMsByMethod
313
- };
314
- for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE"]) {
315
- const envKey = `${ENV_TIMEOUT_BY_METHOD_PREFIX}${method}`;
316
- const raw = environment.get(envKey);
317
- if (!raw || methodTimeouts[method] !== void 0) {
318
- continue;
319
- }
320
- const parsed = parseIntegerFromString(void 0, raw);
321
- if (typeof parsed === "number") {
322
- methodTimeouts[method] = parsed;
323
- }
324
- }
325
- return {
326
- maxRetries: parsedMaxRetries ?? DEFAULT_GATEWAY_MAX_RETRIES,
327
- timeoutMs: parsedTimeoutMs ?? DEFAULT_GATEWAY_TIMEOUT_MS,
328
- timeoutMsByMethod: methodTimeouts,
329
- requestIdFactory
330
- };
331
- }
332
- function createGatewayRuntime(config, environment) {
333
- return {
334
- fetch: config.fetchImpl ?? fetch,
335
- now: () => Date.now(),
336
- sleep: (ms) => delay(ms),
337
- env: environment,
338
- redaction: resolveRequestRedactionValue,
339
- profile: resolveRequestProfile(config, environment)
340
- };
341
- }
342
- function parseIntegerFromString(value, rawValue) {
343
- if (typeof value === "number" && Number.isInteger(value) && value >= 0) {
344
- return value;
345
- }
346
- if (typeof rawValue !== "string" || !rawValue.trim()) {
347
- return void 0;
348
- }
349
- const parsed = Number.parseInt(rawValue, 10);
350
- return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
351
- }
352
- function resolveRequestRedactionValue(value) {
353
- return redactDiagnosticValue(value);
354
- }
355
- function resolveGatewayBaseUrl(configBaseUrl, environment) {
356
- const envBaseUrl = environment.get("LUCERN_API_URL") ?? environment.get("LUCERN_BASE_URL") ?? environment.get("LUCERN_GATEWAY_BASE_URL");
357
- return (configBaseUrl ?? envBaseUrl ?? "").replace(/\/+$/, "");
358
- }
359
- function normalizeGatewayEnvironment(value) {
360
- return value === "sandbox" || value === "production" ? value : void 0;
361
- }
362
- var randomIdempotencyKey = generatePortableRequestId;
363
- function fallbackErrorCode(status) {
364
- if (status === 401) {
365
- return "AUTHENTICATION_REQUIRED";
366
- }
367
- if (status === 403) {
368
- return "FORBIDDEN";
369
- }
370
- if (status === 404) {
371
- return "NOT_FOUND";
372
- }
373
- if (status === 408) {
374
- return "UPSTREAM_ERROR";
375
- }
376
- if (status === 409) {
377
- return "CONFLICT";
378
- }
379
- if (status === 429) {
380
- return "RATE_LIMIT_EXCEEDED";
381
- }
382
- if (status >= 500) {
383
- return "UPSTREAM_ERROR";
384
- }
385
- return "INTERNAL_ERROR";
386
- }
387
- function delay(ms) {
388
- return new Promise((resolve) => setTimeout(resolve, ms));
389
- }
390
- function computeRetryDelayMs(args) {
391
- const baseDelay = args.status === 429 ? Math.max(
392
- args.retryAfterMs ?? 0,
393
- Math.min(1e3 * 2 ** args.attempt, 1e4)
394
- ) : Math.min(1e3 * 2 ** args.attempt, 4e3);
395
- if (args.status !== 429) {
396
- return baseDelay;
397
- }
398
- const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
399
- return baseDelay + Math.round(Math.random() * jitterWindow);
400
- }
401
- function classifyGatewayErrorForRetry(error) {
402
- return isGatewayRetryableError(error) || classifyRetry({ error }).retryable;
403
- }
404
- function isRecord(value) {
405
- return value !== null && typeof value === "object" && !Array.isArray(value);
1
+ import { createGatewayRequestClient, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
2
+ import { createGraphClient } from "./graphClient.js";
3
+ import { createIdentityClient } from "./identityClient.js";
4
+ import { createOntologyClient } from "./ontologyClient.js";
5
+ function normalizeBeliefConfidenceInput(input) {
6
+ const opinion = input.opinion;
7
+ return {
8
+ belief: opinion.b,
9
+ disbelief: opinion.d,
10
+ uncertainty: opinion.u,
11
+ baseRate: opinion.a,
12
+ trigger: input.trigger,
13
+ rationale: input.rationale,
14
+ triggeringEvidenceId: input.triggeringEvidenceId,
15
+ triggeringQuestionId: input.triggeringQuestionId,
16
+ triggeringAnswerId: input.triggeringAnswerId,
17
+ triggeringContradictionId: input.triggeringContradictionId,
18
+ triggeringWorktreeId: input.triggeringWorktreeId,
19
+ maxInlinePropagationTargets: input.maxInlinePropagationTargets,
20
+ };
406
21
  }
407
- function readPolicySummaryFromDetails(details) {
408
- if (!isRecord(details)) {
409
- return null;
410
- }
411
- const directSummary = details.summary;
412
- if (typeof directSummary === "string" && directSummary.trim().length > 0) {
413
- return directSummary.trim();
414
- }
415
- const policy = details.policy;
416
- if (!isRecord(policy)) {
417
- return null;
418
- }
419
- const explanation = policy.explanation;
420
- if (!isRecord(explanation)) {
421
- return null;
422
- }
423
- const nestedSummary = explanation.summary;
424
- if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
425
- return nestedSummary.trim();
426
- }
427
- return null;
22
+ function serializeTypes(types) {
23
+ return Array.isArray(types) && types.length > 0 ? types.join(",") : undefined;
428
24
  }
429
- function redactJsonDiagnosticValue(value) {
430
- return value === void 0 ? void 0 : redactDiagnosticValue(value);
25
+ export function createBeliefsFacade(config = {}) {
26
+ const gateway = createGatewayRequestClient(config);
27
+ return {
28
+ async create(input, idempotencyKey = randomIdempotencyKey()) {
29
+ return gateway.request({
30
+ path: "/api/platform/v1/beliefs",
31
+ method: "POST",
32
+ body: input,
33
+ idempotencyKey,
34
+ });
35
+ },
36
+ async get(id) {
37
+ return gateway.request({
38
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
39
+ });
40
+ },
41
+ async list(query) {
42
+ return gateway.request({
43
+ path: `/api/platform/v1/beliefs${toQueryString({
44
+ topicId: query.topicId,
45
+ status: query.status,
46
+ worktreeId: query.worktreeId,
47
+ minConfidence: query.minConfidence,
48
+ limit: query.limit,
49
+ cursor: query.cursor,
50
+ })}`,
51
+ });
52
+ },
53
+ async refine(id, input, idempotencyKey = randomIdempotencyKey()) {
54
+ return gateway.request({
55
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
56
+ method: "PATCH",
57
+ body: input,
58
+ idempotencyKey,
59
+ });
60
+ },
61
+ async fork(id, input, idempotencyKey = randomIdempotencyKey()) {
62
+ return gateway.request({
63
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/fork`,
64
+ method: "POST",
65
+ body: input,
66
+ idempotencyKey,
67
+ });
68
+ },
69
+ async updateConfidence(id, input, idempotencyKey = randomIdempotencyKey()) {
70
+ return gateway.request({
71
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence`,
72
+ method: "POST",
73
+ body: normalizeBeliefConfidenceInput(input),
74
+ idempotencyKey,
75
+ });
76
+ },
77
+ async updateStatus(input, idempotencyKey = randomIdempotencyKey()) {
78
+ return gateway.request({
79
+ path: "/api/platform/v1/beliefs/update-status",
80
+ method: "POST",
81
+ body: input,
82
+ idempotencyKey,
83
+ });
84
+ },
85
+ async updateRationale(input, idempotencyKey = randomIdempotencyKey()) {
86
+ return gateway.request({
87
+ path: "/api/platform/v1/beliefs/update-rationale",
88
+ method: "POST",
89
+ body: input,
90
+ idempotencyKey,
91
+ });
92
+ },
93
+ async linkBeliefs(input, idempotencyKey = randomIdempotencyKey()) {
94
+ return gateway.request({
95
+ path: "/api/platform/v1/beliefs/link",
96
+ method: "POST",
97
+ body: input,
98
+ idempotencyKey,
99
+ });
100
+ },
101
+ async unlinkEvidence(input, idempotencyKey = randomIdempotencyKey()) {
102
+ return gateway.request({
103
+ path: "/api/platform/v1/beliefs/unlink-evidence",
104
+ method: "POST",
105
+ body: input,
106
+ idempotencyKey,
107
+ });
108
+ },
109
+ async updateCriticality(input, idempotencyKey = randomIdempotencyKey()) {
110
+ return gateway.request({
111
+ path: "/api/platform/v1/beliefs/update-criticality",
112
+ method: "POST",
113
+ body: input,
114
+ idempotencyKey,
115
+ });
116
+ },
117
+ async batchUpdateCriticality(input, idempotencyKey = randomIdempotencyKey()) {
118
+ return gateway.request({
119
+ path: "/api/platform/v1/beliefs/batch-update-criticality",
120
+ method: "POST",
121
+ body: input,
122
+ idempotencyKey,
123
+ });
124
+ },
125
+ async reassignTopic(input, idempotencyKey = randomIdempotencyKey()) {
126
+ return gateway.request({
127
+ path: "/api/platform/v1/beliefs/reassign-topic",
128
+ method: "POST",
129
+ body: input,
130
+ idempotencyKey,
131
+ });
132
+ },
133
+ async archive(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
134
+ return gateway.request({
135
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
136
+ method: "DELETE",
137
+ body: input,
138
+ idempotencyKey,
139
+ });
140
+ },
141
+ async lineage(id) {
142
+ return gateway.request({
143
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/lineage`,
144
+ });
145
+ },
146
+ async confidenceHistory(id) {
147
+ return gateway.request({
148
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`,
149
+ });
150
+ },
151
+ async opinionHistory(id) {
152
+ return gateway.request({
153
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`,
154
+ });
155
+ },
156
+ async createContract(id, input, idempotencyKey = randomIdempotencyKey()) {
157
+ return gateway.request({
158
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/contracts`,
159
+ method: "POST",
160
+ body: input,
161
+ idempotencyKey,
162
+ });
163
+ },
164
+ async bisect(id, input, idempotencyKey = randomIdempotencyKey()) {
165
+ return gateway.request({
166
+ path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/bisect`,
167
+ method: "POST",
168
+ body: input,
169
+ idempotencyKey,
170
+ });
171
+ },
172
+ };
431
173
  }
432
- async function resolveConfiguredAuthContext(authContext) {
433
- if (typeof authContext === "function") {
434
- return await authContext();
435
- }
436
- return authContext;
174
+ export function createContradictionsFacade(config = {}) {
175
+ const gateway = createGatewayRequestClient(config);
176
+ return {
177
+ async flag(input, idempotencyKey = randomIdempotencyKey()) {
178
+ return gateway.request({
179
+ path: "/api/platform/v1/contradictions",
180
+ method: "POST",
181
+ body: input,
182
+ idempotencyKey,
183
+ });
184
+ },
185
+ async list(query) {
186
+ return gateway.request({
187
+ path: `/api/platform/v1/contradictions${toQueryString({
188
+ topicId: query.topicId,
189
+ status: query.status,
190
+ limit: query.limit,
191
+ cursor: query.cursor,
192
+ })}`,
193
+ });
194
+ },
195
+ async get(id) {
196
+ return gateway.request({
197
+ path: `/api/platform/v1/contradictions/${encodeURIComponent(id)}`,
198
+ });
199
+ },
200
+ };
437
201
  }
438
- function mergeHeaderRecord(base, addition) {
439
- const headers = new Headers(base);
440
- for (const [key, value] of Object.entries(addition)) {
441
- const existing = headers.get(key);
442
- if (existing !== null && existing !== value) {
443
- throw new LucernSdkAuthContextError(
444
- "policy_denied",
445
- `Canonical Lucern SDK auth context conflicts with existing ${key} header.`
446
- );
447
- }
448
- headers.set(key, value);
449
- }
450
- return Object.fromEntries(headers.entries());
202
+ export function createEdgesFacade(config = {}) {
203
+ const gateway = createGatewayRequestClient(config);
204
+ return {
205
+ async create(input, idempotencyKey = randomIdempotencyKey()) {
206
+ return gateway.request({
207
+ path: "/api/platform/v1/edges",
208
+ method: "POST",
209
+ body: input,
210
+ idempotencyKey,
211
+ });
212
+ },
213
+ async list(query) {
214
+ return gateway.request({
215
+ path: `/api/platform/v1/edges${toQueryString({
216
+ sourceId: query.sourceId,
217
+ edgeType: query.edgeType,
218
+ limit: query.limit,
219
+ cursor: query.cursor,
220
+ })}`,
221
+ });
222
+ },
223
+ async traverse(input, idempotencyKey = randomIdempotencyKey()) {
224
+ return gateway.request({
225
+ path: "/api/platform/v1/edges/traverse",
226
+ method: "POST",
227
+ body: input,
228
+ idempotencyKey,
229
+ });
230
+ },
231
+ async update(input, idempotencyKey = randomIdempotencyKey()) {
232
+ return gateway.request({
233
+ path: "/api/platform/v1/edges/update",
234
+ method: "POST",
235
+ body: input,
236
+ idempotencyKey,
237
+ });
238
+ },
239
+ async remove(input, idempotencyKey = randomIdempotencyKey()) {
240
+ return gateway.request({
241
+ path: "/api/platform/v1/edges/remove",
242
+ method: "POST",
243
+ body: input,
244
+ idempotencyKey,
245
+ });
246
+ },
247
+ async removeBetween(input, idempotencyKey = randomIdempotencyKey()) {
248
+ return gateway.request({
249
+ path: "/api/platform/v1/edges/remove-between",
250
+ method: "POST",
251
+ body: input,
252
+ idempotencyKey,
253
+ });
254
+ },
255
+ async batchCreate(input, idempotencyKey = randomIdempotencyKey()) {
256
+ return gateway.request({
257
+ path: "/api/platform/v1/edges/batch",
258
+ method: "POST",
259
+ body: input,
260
+ idempotencyKey,
261
+ });
262
+ },
263
+ async delete(input, idempotencyKey = randomIdempotencyKey()) {
264
+ return gateway.request({
265
+ path: "/api/platform/v1/edges/delete",
266
+ method: "POST",
267
+ body: input,
268
+ idempotencyKey,
269
+ });
270
+ },
271
+ };
451
272
  }
452
- function cleanHeaderValue(value) {
453
- const normalized = value?.trim();
454
- return normalized ? normalized : void 0;
273
+ export function createEvidenceFacade(config = {}) {
274
+ const gateway = createGatewayRequestClient(config);
275
+ return {
276
+ async create(input, idempotencyKey = randomIdempotencyKey()) {
277
+ return gateway.request({
278
+ path: "/api/platform/v1/evidence",
279
+ method: "POST",
280
+ body: input,
281
+ idempotencyKey,
282
+ });
283
+ },
284
+ async get(id) {
285
+ return gateway.request({
286
+ path: `/api/platform/v1/evidence/${encodeURIComponent(id)}`,
287
+ });
288
+ },
289
+ async list(query) {
290
+ return gateway.request({
291
+ path: `/api/platform/v1/evidence${toQueryString({
292
+ topicId: query.topicId,
293
+ targetId: query.targetId,
294
+ limit: query.limit,
295
+ cursor: query.cursor,
296
+ })}`,
297
+ });
298
+ },
299
+ async link(input, idempotencyKey = randomIdempotencyKey()) {
300
+ return gateway.request({
301
+ path: `/api/platform/v1/evidence/${encodeURIComponent(input.evidenceId)}/link`,
302
+ method: "POST",
303
+ body: {
304
+ targetId: input.targetId,
305
+ targetType: input.targetType,
306
+ weight: input.weight,
307
+ rationale: input.rationale,
308
+ },
309
+ idempotencyKey,
310
+ });
311
+ },
312
+ async search(query, idempotencyKey = randomIdempotencyKey()) {
313
+ return gateway.request({
314
+ path: "/api/platform/v1/evidence/search",
315
+ method: "POST",
316
+ body: query,
317
+ idempotencyKey,
318
+ });
319
+ },
320
+ async updateStatus(input, idempotencyKey = randomIdempotencyKey()) {
321
+ return gateway.request({
322
+ path: "/api/platform/v1/evidence/update-status",
323
+ method: "POST",
324
+ body: input,
325
+ idempotencyKey,
326
+ });
327
+ },
328
+ async update(input, idempotencyKey = randomIdempotencyKey()) {
329
+ return gateway.request({
330
+ path: "/api/platform/v1/evidence/update",
331
+ method: "POST",
332
+ body: input,
333
+ idempotencyKey,
334
+ });
335
+ },
336
+ async flagIncorrect(input, idempotencyKey = randomIdempotencyKey()) {
337
+ return gateway.request({
338
+ path: "/api/platform/v1/evidence/flag-incorrect",
339
+ method: "POST",
340
+ body: input,
341
+ idempotencyKey,
342
+ });
343
+ },
344
+ async remove(input, idempotencyKey = randomIdempotencyKey()) {
345
+ return gateway.request({
346
+ path: "/api/platform/v1/evidence/remove",
347
+ method: "POST",
348
+ body: input,
349
+ idempotencyKey,
350
+ });
351
+ },
352
+ async updateVerificationStatus(input, idempotencyKey = randomIdempotencyKey()) {
353
+ return gateway.request({
354
+ path: "/api/platform/v1/evidence/update-verification-status",
355
+ method: "POST",
356
+ body: input,
357
+ idempotencyKey,
358
+ });
359
+ },
360
+ };
455
361
  }
456
- function createGatewayRequestClient(config = {}) {
457
- const env = resolveEnvironment();
458
- const runtime = createGatewayRuntime(config, env);
459
- const baseUrl = resolveGatewayBaseUrl(config.baseUrl, env);
460
- const maxRetries = runtime.profile.maxRetries;
461
- const requestIdFactory = runtime.profile.requestIdFactory;
462
- const requestTimeoutByMethod = runtime.profile.timeoutMsByMethod;
463
- const defaultRequestTimeoutMs = runtime.profile.timeoutMs;
464
- const normalizedEnvironment = normalizeGatewayEnvironment(config.environment);
465
- const telemetryExporter = config.telemetryEnabled === false ? null : config.telemetryExporter ?? createTelemetryExporterFromEnv(telemetryEnvironmentRecord(env), {
466
- service: "lucern-sdk",
467
- environment: normalizedEnvironment
468
- });
469
- async function resolveAuthHeaders() {
470
- const provided = config.getAuthHeaders ? await config.getAuthHeaders() : {};
471
- const headers = new Headers(provided);
472
- const setIfAbsent = (name, value) => {
473
- const normalized = cleanHeaderValue(value);
474
- if (normalized && !headers.has(name)) {
475
- headers.set(name, normalized);
476
- }
362
+ export function createEventsFacade(config = {}) {
363
+ const gateway = createGatewayRequestClient(config);
364
+ return {
365
+ async list(query = {}) {
366
+ return gateway.request({
367
+ path: `/api/platform/v1/events${toQueryString({
368
+ topicId: query.topicId,
369
+ after: query.after,
370
+ types: serializeTypes(query.types),
371
+ startTime: query.startTime,
372
+ endTime: query.endTime,
373
+ limit: query.limit,
374
+ })}`,
375
+ });
376
+ },
377
+ async replay(input, idempotencyKey = randomIdempotencyKey()) {
378
+ return gateway.request({
379
+ path: "/api/platform/v1/events/replay",
380
+ method: "POST",
381
+ body: input,
382
+ idempotencyKey,
383
+ });
384
+ },
477
385
  };
478
- setIfAbsent("x-lucern-key", config.apiKey);
479
- setIfAbsent("x-lucern-session-token", config.userToken);
480
- setIfAbsent("x-lucern-environment", normalizedEnvironment);
481
- setIfAbsent("x-lucern-clerk-id", config.clerkId);
482
- setIfAbsent("x-lucern-user-id", config.userId ?? config.clerkId);
483
- setIfAbsent("x-lucern-deployment-host", config.deploymentHost);
484
- const base = Object.fromEntries(headers.entries());
485
- const authContextInput = await resolveConfiguredAuthContext(
486
- config.authContext
487
- );
488
- if (!authContextInput && !config.requireCanonicalAuthContext) {
489
- return base;
490
- }
491
- const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
492
- return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
493
- }
494
- async function fetchWithTimeout(url, init, timeoutMs) {
495
- const normalizeTransportError = (error, isTimeout) => {
496
- if (isTimeout) {
497
- return new GatewayTimeoutError(timeoutMs);
498
- }
499
- return error instanceof GatewayTimeoutError || error instanceof GatewayTransportError ? error : new GatewayTransportError(
500
- error instanceof Error ? error.message : "Gateway transport error",
501
- {
502
- cause: error,
503
- retryable: classifyGatewayErrorForRetry(error)
504
- }
505
- );
386
+ }
387
+ export function createGraphFacade(config = {}) {
388
+ const graphClient = createGraphClient(config);
389
+ const gateway = createGatewayRequestClient(config);
390
+ const graphFacade = {
391
+ async neighborhood(input) {
392
+ return graphClient.neighborhood({
393
+ globalId: input.globalId,
394
+ globalIds: Array.isArray(input.globalIds)
395
+ ? input.globalIds.join(",")
396
+ : input.globalIds,
397
+ maxDepth: input.maxDepth,
398
+ });
399
+ },
400
+ async falsify(input, idempotencyKey = randomIdempotencyKey()) {
401
+ return gateway.request({
402
+ path: "/api/platform/v1/graph/falsify",
403
+ method: "POST",
404
+ body: input,
405
+ idempotencyKey,
406
+ });
407
+ },
506
408
  };
507
- const controller = new AbortController();
508
- const timer = setTimeout(() => controller.abort(), timeoutMs);
509
- const requestEffect = Effect.tryPromise({
510
- try: () => runtime.fetch(url, { ...init, signal: controller.signal }),
511
- catch: (error) => normalizeTransportError(error, controller.signal.aborted)
512
- });
513
- try {
514
- const exit = await Effect.runPromiseExit(requestEffect);
515
- if (Exit.isSuccess(exit)) {
516
- return exit.value;
517
- }
518
- const failure = Array.from(Cause.failures(exit.cause))[0];
519
- if (failure !== void 0) {
520
- throw failure;
521
- }
522
- throw Cause.squash(exit.cause);
523
- } finally {
524
- clearTimeout(timer);
525
- }
526
- }
527
- async function emitSdkResponseTelemetry(context) {
528
- const retry = classifyRetry({
529
- status: context.status,
530
- error: context.error,
531
- retryAfter: context.retryAfterMs !== null && context.retryAfterMs !== void 0 ? String(context.retryAfterMs / 1e3) : void 0
532
- });
533
- await emitTelemetrySignal(telemetryExporter, {
534
- signalType: "trace",
535
- surface: "sdk-retry",
536
- eventName: context.willRetry ? "sdk.retry" : context.error ? "sdk.request.error" : "sdk.request.complete",
537
- severity: context.error ? context.willRetry ? "warn" : "error" : "info",
538
- durationMs: context.durationMs,
539
- metricName: "sdk.request.duration_ms",
540
- metricValue: context.durationMs,
541
- correlationId: context.correlationId ?? context.requestId,
542
- policyTraceId: context.policyTraceId ?? null,
543
- tenantId: context.headers.get("x-lucern-tenant-id") ?? context.headers.get("x-lucern-tenant") ?? void 0,
544
- workspaceId: context.headers.get("x-lucern-workspace-id") ?? context.headers.get("x-lucern-workspace") ?? void 0,
545
- attributes: {
546
- service: "lucern-sdk",
547
- operation: "gateway.request",
548
- path: context.path,
549
- httpMethod: context.method,
550
- httpStatus: context.status,
551
- attempt: context.attempt,
552
- maxRetries: context.maxRetries,
553
- retryReason: retry.reason,
554
- retryAfterMs: context.retryAfterMs ?? retry.retryAfterMs,
555
- willRetry: context.willRetry,
556
- retryable: retry.retryable,
557
- errorName: context.error instanceof Error ? context.error.name : void 0,
558
- errorMessage: context.error instanceof Error ? context.error.message : void 0
559
- }
409
+ return Object.assign(graphFacade, {
410
+ traverse: graphClient.traverse,
411
+ analyze: graphClient.analyze,
412
+ bias: graphClient.bias,
413
+ gaps: graphClient.gaps,
560
414
  });
561
- }
562
- async function parsePayload(response) {
563
- const text = await response.text();
564
- if (!text) {
565
- return null;
566
- }
567
- const parsed = tryParseGatewayEnvelopeJson(text);
568
- if (!parsed.ok) {
569
- return null;
570
- }
571
- return isRecord(parsed.value) ? parsed.value : null;
572
- }
573
- function resolveTimeoutMs(method, requestTimeoutMs) {
574
- if (typeof requestTimeoutMs === "number") {
575
- return requestTimeoutMs;
576
- }
577
- const methodTimeoutMs = requestTimeoutByMethod?.[method];
578
- if (typeof methodTimeoutMs === "number") {
579
- return methodTimeoutMs;
580
- }
581
- return defaultRequestTimeoutMs;
582
- }
583
- function tryParseGatewayEnvelopeJson(text) {
584
- const trimmed = text.trim();
585
- if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
586
- return { ok: false, reason: "non-json" };
587
- }
588
- try {
589
- return { ok: true, value: JSON.parse(trimmed) };
590
- } catch (error) {
591
- if (error instanceof SyntaxError) {
592
- return { ok: false, reason: "invalid-json", error };
593
- }
594
- throw error;
595
- }
596
- }
597
- function buildApiError(args) {
598
- const failure = args.failure;
599
- const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
600
- const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
601
- const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
602
- const details = runtime.redaction(
603
- redactJsonDiagnosticValue(failure?.details ?? legacyError?.details)
604
- );
605
- const policySummary = readPolicySummaryFromDetails(details);
606
- const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
607
- return new LucernApiError({
608
- code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
609
- message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
610
- status: args.response.status,
611
- invariant: failure?.invariant,
612
- suggestion: failure?.suggestion,
613
- details,
614
- requestId: args.requestId,
615
- correlationId,
616
- policyTraceId
617
- });
618
- }
619
- async function request(args) {
620
- const authHeaders = await resolveAuthHeaders();
621
- const method = args.method ?? "GET";
622
- const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
623
- const headers = new Headers({
624
- "content-type": "application/json",
625
- ...authHeaders
626
- });
627
- if (args.idempotencyKey) {
628
- headers.set("idempotency-key", args.idempotencyKey);
629
- }
630
- const requestId = headers.get("x-correlation-id")?.trim() || headers.get("x-request-id")?.trim() || args.requestId || requestIdFactory();
631
- if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
632
- headers.set("x-correlation-id", requestId);
633
- }
634
- const url = `${baseUrl}${args.path}`;
635
- const serializedBody = args.body ? JSON.stringify(args.body) : void 0;
636
- const init = {
637
- method,
638
- headers,
639
- body: serializedBody
640
- };
641
- let lastError;
642
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
643
- const hookRequestContext = {
644
- requestId,
645
- attempt,
646
- maxRetries,
647
- method,
648
- path: args.path,
649
- url,
650
- headers: new Headers(headers),
651
- body: serializedBody,
652
- timeoutMs
653
- };
654
- await config.onRequest?.(hookRequestContext);
655
- const startedAt = Date.now();
656
- try {
657
- const response = await fetchWithTimeout(url, init, timeoutMs);
658
- const responseClone = response.clone();
659
- const payload = await parsePayload(response);
660
- const retry = classifyRetry({
661
- status: response.status,
662
- retryAfter: response.headers.get("Retry-After")
663
- });
664
- const retryAfterMs = retry.retryAfterMs ?? null;
665
- if (!response.ok || !payload?.success) {
666
- const failure = payload && !payload.success ? payload : null;
667
- const apiError = buildApiError({
668
- requestId,
669
- response,
670
- failure
671
- });
672
- const willRetry = attempt < maxRetries && retry.retryable;
673
- const responseContext2 = {
674
- ...hookRequestContext,
675
- durationMs: Date.now() - startedAt,
676
- status: response.status,
677
- response: responseClone,
678
- error: apiError,
679
- correlationId: apiError.correlationId ?? requestId,
680
- policyTraceId: apiError.policyTraceId ?? null,
681
- retryAfterMs,
682
- willRetry
683
- };
684
- await config.onResponse?.(responseContext2);
685
- await emitSdkResponseTelemetry(responseContext2);
686
- if (willRetry) {
687
- lastError = apiError;
688
- await delay(
689
- computeRetryDelayMs({
690
- attempt,
691
- status: response.status,
692
- retryAfterMs
693
- })
694
- );
695
- continue;
696
- }
697
- throw apiError;
698
- }
699
- const successPayload = payload;
700
- const responseContext = {
701
- ...hookRequestContext,
702
- durationMs: Date.now() - startedAt,
703
- status: response.status,
704
- response: responseClone,
705
- correlationId: successPayload.correlationId ?? response.headers.get("x-lucern-correlation-id")?.trim() ?? requestId,
706
- policyTraceId: successPayload.policyTraceId ?? response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null,
707
- idempotentReplay: successPayload.idempotentReplay,
708
- retryAfterMs,
709
- willRetry: false
710
- };
711
- await config.onResponse?.(responseContext);
712
- await emitSdkResponseTelemetry(responseContext);
713
- return successPayload;
714
- } catch (fetchError) {
715
- if (fetchError instanceof LucernApiError) {
716
- throw fetchError;
717
- }
718
- const willRetry = attempt < maxRetries && classifyGatewayErrorForRetry(fetchError);
719
- const responseContext = {
720
- ...hookRequestContext,
721
- durationMs: Date.now() - startedAt,
722
- error: fetchError,
723
- correlationId: requestId,
724
- policyTraceId: null,
725
- willRetry
726
- };
727
- await config.onResponse?.(responseContext);
728
- await emitSdkResponseTelemetry(responseContext);
729
- lastError = fetchError;
730
- if (willRetry) {
731
- await delay(computeRetryDelayMs({ attempt }));
732
- }
733
- }
734
- }
735
- throw lastError instanceof Error ? lastError : new Error("Platform API request failed after retries.");
736
- }
737
- return {
738
- request
739
- };
740
- }
741
-
742
- // src/sdkSurface.ts
743
- function isRecord2(value) {
744
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
745
- }
746
- function asRecord(value) {
747
- return isRecord2(value) ? value : {};
748
- }
749
- function cleanString2(value) {
750
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
751
- }
752
- function normalizeVerificationStatus(value) {
753
- const status = cleanString2(value);
754
- if (!status) {
755
- return void 0;
756
- }
757
- if (status === "verified") {
758
- return "human_verified";
759
- }
760
- if (status === "rejected") {
761
- return "contradicted";
762
- }
763
- return status;
764
- }
765
- function cloneWith(value, patch) {
766
- return { ...value, ...patch };
767
- }
768
- function resolveTopicId(value) {
769
- return cleanString2(value.topicId);
770
415
  }
771
- function resolveText(value) {
772
- return cleanString2(value.text) ?? cleanString2(value.canonicalText);
773
- }
774
- function withTopicAlias(value) {
775
- const topicId = cleanString2(value.topicId) ?? void 0;
776
- if (!topicId) {
777
- return value;
778
- }
779
- return cloneWith(value, { topicId });
780
- }
781
- function withTextAlias(value) {
782
- const text = cleanString2(value.text) ?? cleanString2(value.canonicalText) ?? void 0;
783
- if (!text) {
784
- return value;
785
- }
786
- return cloneWith(value, { text, canonicalText: text });
787
- }
788
- function withSdkAliases(value) {
789
- return withTopicAlias(withTextAlias(value));
790
- }
791
- function normalizeNodeWriteInput(value) {
792
- const topicId = resolveTopicId(value);
793
- const text = resolveText(value);
794
- const verificationStatus = normalizeVerificationStatus(value.verificationStatus);
795
- const next = { ...value };
796
- if (topicId) {
797
- next.topicId = topicId;
798
- }
799
- if (text) {
800
- next.text = text;
801
- next.canonicalText = text;
802
- }
803
- if (verificationStatus) {
804
- next.verificationStatus = verificationStatus;
805
- }
806
- return next;
807
- }
808
- var normalizeNodeVerificationStatus = normalizeVerificationStatus;
809
- function normalizeTopicQuery(value) {
810
- const topicId = cleanString2(value.topicId);
811
- if (!topicId) {
812
- return value;
813
- }
814
- return { ...value, topicId };
815
- }
816
- function asListItems(data, legacyKey) {
817
- if (Array.isArray(data)) {
818
- return data;
819
- }
820
- const record = asRecord(data);
821
- if (Array.isArray(record.items)) {
822
- return record.items;
823
- }
824
- if (legacyKey && Array.isArray(record[legacyKey])) {
825
- return record[legacyKey];
826
- }
827
- return [];
828
- }
829
- function createListResult(items, legacyKey) {
830
- const result = {
831
- items,
832
- total: items.length
833
- };
834
- if (legacyKey) {
416
+ export function createIdentityFacade(config = {}) {
417
+ const identityClient = createIdentityClient(config);
835
418
  return {
836
- ...result,
837
- [legacyKey]: items
419
+ async whoami() {
420
+ const response = await identityClient.whoami();
421
+ return Object.assign({}, response, response.data);
422
+ },
838
423
  };
839
- }
840
- return result;
841
- }
842
- function mapGatewayData(response, mapper) {
843
- return {
844
- ...response,
845
- data: mapper(response.data)
846
- };
847
424
  }
848
- function mapAliasedList(data, legacyKey) {
849
- const items = asListItems(data, legacyKey).map(
850
- (item) => withSdkAliases(item)
851
- );
852
- return createListResult(items, legacyKey);
853
- }
854
-
855
- // src/graphClient.ts
856
- function createGraphClient(config = {}) {
857
- const gateway = createGatewayRequestClient(config);
858
- const client = {
859
- /**
860
- * List graph nodes matching the provided filters.
861
- */
862
- async listNodes(query) {
863
- return gateway.request({
864
- path: `/api/platform/v1/graph/nodes${toQueryString(
865
- normalizeTopicQuery(query)
866
- )}`
867
- }).then(
868
- (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
869
- );
870
- },
871
- /**
872
- * Retrieve a single graph node by nodeId or globalId.
873
- */
874
- async getNode(query) {
875
- return gateway.request({
876
- path: `/api/platform/v1/graph/nodes${toQueryString(query)}`
877
- }).then(
878
- (response) => mapGatewayData(
879
- response,
880
- (data) => withSdkAliases(data)
881
- )
882
- );
883
- },
884
- /**
885
- * Create a graph node.
886
- */
887
- async createNode(input, idempotencyKey) {
888
- return gateway.request({
889
- path: "/api/platform/v1/graph/nodes",
890
- method: "POST",
891
- body: normalizeNodeWriteInput(input),
892
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
893
- }).then(
894
- (response) => mapGatewayData(
895
- response,
896
- (data) => withSdkAliases(data)
897
- )
898
- );
899
- },
900
- /**
901
- * Update a graph node.
902
- */
903
- async updateNode(input, idempotencyKey) {
904
- return gateway.request({
905
- path: "/api/platform/v1/graph/nodes",
906
- method: "PUT",
907
- body: normalizeNodeWriteInput(input),
908
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
909
- }).then(
910
- (response) => mapGatewayData(
911
- response,
912
- (data) => withSdkAliases(data)
913
- )
914
- );
915
- },
916
- /**
917
- * Batch create graph nodes through the admin route surface.
918
- */
919
- async batchCreateNodes(input, idempotencyKey) {
920
- return gateway.request({
921
- path: "/api/platform/v1/graph/nodes/batch",
922
- method: "POST",
923
- body: {
924
- nodes: input.nodes.map((node) => normalizeNodeWriteInput(node))
425
+ export function createOntologiesFacade(config = {}) {
426
+ const ontologyClient = createOntologyClient(config);
427
+ const gateway = createGatewayRequestClient(config);
428
+ const ontologyFacade = {
429
+ async get(id) {
430
+ return gateway.request({
431
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
432
+ });
925
433
  },
926
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
927
- });
928
- },
929
- /**
930
- * Supersede an existing graph node with a new canonical version.
931
- */
932
- async supersedeNode(input, idempotencyKey) {
933
- return gateway.request({
934
- path: "/api/platform/v1/graph/nodes/supersede",
935
- method: "POST",
936
- body: input,
937
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
938
- });
939
- },
940
- /**
941
- * Update a node's verification status.
942
- */
943
- async verifyNode(input, idempotencyKey) {
944
- const verificationStatus = normalizeNodeVerificationStatus(input.verificationStatus) ?? input.verificationStatus;
945
- return gateway.request({
946
- path: "/api/platform/v1/graph/nodes/verify",
947
- method: "POST",
948
- body: {
949
- ...input,
950
- verificationStatus
434
+ async bind(input, idempotencyKey) {
435
+ return gateway.request({
436
+ path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
437
+ method: "POST",
438
+ body: {
439
+ topicId: input.topicId,
440
+ },
441
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
442
+ });
951
443
  },
952
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
953
- });
954
- },
955
- /**
956
- * Permanently delete a node via the admin-only hard-delete route.
957
- */
958
- async hardDeleteNode(input, idempotencyKey) {
959
- return gateway.request({
960
- path: "/api/platform/v1/graph/nodes/hard-delete",
961
- method: "POST",
962
- body: input,
963
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
964
- });
965
- },
966
- /**
967
- * List graph edges matching the provided filters.
968
- */
969
- async listEdges(query) {
970
- return gateway.request({
971
- path: `/api/platform/v1/graph/edges${toQueryString(
972
- normalizeTopicQuery(query)
973
- )}`
974
- }).then(
975
- (response) => mapGatewayData(
976
- response,
977
- (data) => mapAliasedList(data, "edges")
978
- )
979
- );
980
- },
981
- /**
982
- * Create a graph edge.
983
- */
984
- async createEdge(input, idempotencyKey) {
985
- return gateway.request({
986
- path: "/api/platform/v1/graph/edges",
987
- method: "POST",
988
- body: normalizeTopicQuery(input),
989
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
990
- });
991
- },
992
- /**
993
- * Delete one or more edges matching the provided filter.
994
- */
995
- async deleteEdge(query, idempotencyKey) {
996
- return gateway.request({
997
- path: `/api/platform/v1/graph/edges${toQueryString(query)}`,
998
- method: "DELETE",
999
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1000
- });
1001
- },
1002
- /**
1003
- * Retrieve a graph neighborhood around a root node.
1004
- */
1005
- async neighborhood(query) {
1006
- return gateway.request({
1007
- path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`
1008
- });
1009
- },
1010
- /**
1011
- * Traverse the graph from a starting node.
1012
- */
1013
- async traverse(query) {
1014
- return gateway.request({
1015
- path: "/api/platform/v1/graph/traverse",
1016
- method: "POST",
1017
- body: normalizeTopicQuery(query)
1018
- });
1019
- },
1020
- /**
1021
- * Analyze graph structure for a topic.
1022
- */
1023
- async analyze(query = {}) {
1024
- const normalized = normalizeTopicQuery(query);
1025
- return gateway.request({
1026
- path: `/api/platform/v1/graph/analyze${toQueryString({
1027
- topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
1028
- metric: typeof normalized.metric === "string" ? normalized.metric : void 0,
1029
- limit: typeof normalized.limit === "number" ? normalized.limit : void 0
1030
- })}`
1031
- });
1032
- },
1033
- /**
1034
- * Detect confirmation-bias patterns for a topic graph.
1035
- */
1036
- async bias(query = {}) {
1037
- const normalized = normalizeTopicQuery(query);
1038
- return gateway.request({
1039
- path: `/api/platform/v1/graph/bias${toQueryString({
1040
- topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
1041
- threshold: typeof normalized.threshold === "number" ? normalized.threshold : void 0,
1042
- limit: typeof normalized.limit === "number" ? normalized.limit : void 0
1043
- })}`
1044
- });
1045
- },
1046
- /**
1047
- * Find graph gaps for beliefs that still need testing.
1048
- */
1049
- async gaps(query) {
1050
- const normalized = normalizeTopicQuery(query);
1051
- return gateway.request({
1052
- path: `/api/platform/v1/graph/gaps${toQueryString({
1053
- topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
1054
- minConfidence: typeof normalized.minConfidence === "number" ? normalized.minConfidence : void 0
1055
- })}`
1056
- });
1057
- },
1058
- /**
1059
- * Search across graph resources within a topic.
1060
- */
1061
- async search(query) {
1062
- return gateway.request({
1063
- path: "/api/platform/v1/search",
1064
- method: "POST",
1065
- body: normalizeTopicQuery(query)
1066
- });
1067
- },
1068
- /**
1069
- * Retrieve the shortest known path between two graph nodes.
1070
- */
1071
- async getPath(query) {
1072
- return gateway.request({
1073
- path: `/api/platform/v1/graph/path${toQueryString(query)}`
1074
- });
1075
- },
1076
- /**
1077
- * Retrieve graph analytics for the requested metric.
1078
- */
1079
- async getAnalytics(query = {}) {
1080
- return gateway.request({
1081
- path: `/api/platform/v1/graph/analytics${toQueryString(query)}`
1082
- });
1083
- }
1084
- };
1085
- return Object.assign(client, {
1086
- queryNodes: client.listNodes,
1087
- queryEdges: client.listEdges,
1088
- getNeighborhood: client.neighborhood
1089
- });
1090
- }
1091
-
1092
- // src/boundaryClientSurface.ts
1093
- function cleanOptionalString(value) {
1094
- const normalized = value?.trim();
1095
- return normalized ? normalized : void 0;
1096
- }
1097
- function isRecord3(value) {
1098
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1099
- }
1100
- function cleanRequiredString(value, label) {
1101
- const normalized = cleanOptionalString(value);
1102
- if (!normalized) {
1103
- throw new Error(`${label} is required`);
1104
- }
1105
- return normalized;
1106
- }
1107
- function assertKnownKeys(input, allowed, operation) {
1108
- const allowedSet = new Set(allowed);
1109
- const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
1110
- if (unknownKeys.length > 0) {
1111
- throw new Error(
1112
- `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
1113
- );
1114
- }
1115
- }
1116
- function knownPayload(input, allowed, operation) {
1117
- assertKnownKeys(input, allowed, operation);
1118
- return { ...input };
1119
- }
1120
- function listResultFromEnvelope(data, legacyKey) {
1121
- const record = isRecord3(data) ? data : {};
1122
- const legacyItems = record[legacyKey];
1123
- return createListResult(
1124
- Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
1125
- legacyKey
1126
- );
1127
- }
1128
-
1129
- // src/control-plane.ts
1130
- var LucernControlPlaneIdentityError = class extends Error {
1131
- reason;
1132
- principalStatus;
1133
- tenantStatus;
1134
- workspaceStatus;
1135
- details;
1136
- constructor(failure) {
1137
- super(failure.message);
1138
- this.name = "LucernControlPlaneIdentityError";
1139
- this.reason = failure.reason;
1140
- this.principalStatus = failure.principalStatus;
1141
- this.tenantStatus = failure.tenantStatus;
1142
- this.workspaceStatus = failure.workspaceStatus;
1143
- this.details = failure.details;
1144
- }
1145
- };
1146
- function cleanString3(value) {
1147
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
1148
- }
1149
- function stringList(value) {
1150
- if (!Array.isArray(value)) {
1151
- return [];
1152
- }
1153
- return [
1154
- ...new Set(
1155
- value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean)
1156
- )
1157
- ];
1158
- }
1159
- function principalType(value) {
1160
- switch (value) {
1161
- case "service":
1162
- case "service_principal":
1163
- return "service";
1164
- case "agent":
1165
- return "agent";
1166
- case "group":
1167
- return "group";
1168
- case "external_viewer":
1169
- case "external_stakeholder":
1170
- return "external_viewer";
1171
- default:
1172
- return "human";
1173
- }
1174
- }
1175
- function adminFlags(roles) {
1176
- const normalized = roles.map((role) => role.toLowerCase());
1177
- const isPlatformAdmin = normalized.includes("platform_admin");
1178
- const isTenantAdmin = isPlatformAdmin || normalized.includes("tenant_admin");
1179
- const isWorkspaceAdmin = isTenantAdmin || normalized.includes("workspace_admin") || normalized.includes("workspace_owner");
1180
- return { isPlatformAdmin, isTenantAdmin, isWorkspaceAdmin };
1181
- }
1182
- function normalizeResolvedInteractivePrincipal(payload) {
1183
- if ("ok" in payload && payload.ok === false) {
1184
- throw new LucernControlPlaneIdentityError(payload);
1185
- }
1186
- const principalId = cleanString3(payload.principalId);
1187
- const clerkId = cleanString3(payload.clerkId);
1188
- const tenantId = cleanString3(payload.tenantId);
1189
- if (!principalId || !clerkId || !tenantId) {
1190
- throw new LucernControlPlaneIdentityError({
1191
- ok: false,
1192
- reason: "resolver_unavailable",
1193
- message: "Control-plane principal resolver returned an incomplete principal context.",
1194
- principalStatus: payload.principalStatus ?? "missing",
1195
- tenantStatus: payload.tenantStatus,
1196
- workspaceStatus: payload.workspaceStatus
444
+ async match(input, idempotencyKey) {
445
+ return gateway.request({
446
+ path: "/api/platform/v1/ontologies/match",
447
+ method: "POST",
448
+ body: input,
449
+ idempotencyKey,
450
+ });
451
+ },
452
+ };
453
+ return Object.assign(ontologyFacade, {
454
+ list: ontologyClient.list,
1197
455
  });
1198
- }
1199
- const roles = stringList(payload.roles);
1200
- const scopes = stringList(payload.scopes);
1201
- const workspaceId = cleanString3(payload.workspaceId) ?? null;
1202
- const flags = adminFlags(roles);
1203
- return {
1204
- principalId,
1205
- principalType: principalType(payload.principalType),
1206
- clerkId,
1207
- tenantId,
1208
- workspaceId,
1209
- roles,
1210
- scopes,
1211
- groupIds: stringList(payload.groupIds),
1212
- permittedToolNames: stringList(payload.permittedToolNames),
1213
- permittedPackKeys: stringList(payload.permittedPackKeys),
1214
- principalStatus: cleanString3(payload.principalStatus) ?? "active",
1215
- tenantStatus: cleanString3(payload.tenantStatus) ?? "active",
1216
- workspaceStatus: cleanString3(payload.workspaceStatus) ?? (workspaceId ? "active" : "none"),
1217
- isPlatformAdmin: typeof payload.isPlatformAdmin === "boolean" ? payload.isPlatformAdmin : flags.isPlatformAdmin,
1218
- isTenantAdmin: typeof payload.isTenantAdmin === "boolean" ? payload.isTenantAdmin : flags.isTenantAdmin,
1219
- isWorkspaceAdmin: typeof payload.isWorkspaceAdmin === "boolean" ? payload.isWorkspaceAdmin : flags.isWorkspaceAdmin,
1220
- permit: {
1221
- subject: cleanString3(payload.permit?.subject) ?? principalId,
1222
- tenant: cleanString3(payload.permit?.tenant) ?? tenantId,
1223
- ...workspaceId ? { workspace: cleanString3(payload.permit?.workspace) ?? workspaceId } : {}
1224
- },
1225
- authMode: "interactive_user",
1226
- sessionId: payload.sessionId,
1227
- delegatedBy: payload.delegatedBy,
1228
- expiresAt: payload.expiresAt
1229
- };
1230
- }
1231
-
1232
- // src/identityClient.ts
1233
- function createIdentityWhoamiClient(config = {}) {
1234
- const gateway = createGatewayRequestClient(config);
1235
- return {
1236
- async whoami() {
1237
- return gateway.request({
1238
- path: "/api/platform/v1/identity/whoami"
1239
- });
1240
- }
1241
- };
1242
- }
1243
- var TENANT_IDENTITY_FIELDS = [
1244
- "tenantId",
1245
- "workspaceId",
1246
- "principalId",
1247
- "integrationKey",
1248
- "secretRef",
1249
- "policySubject",
1250
- "policyAction",
1251
- "policyResource",
1252
- "decision",
1253
- "config",
1254
- "configKey",
1255
- "configValue",
1256
- "provider",
1257
- "status",
1258
- "metadata",
1259
- "limit",
1260
- "cursor"
1261
- ];
1262
- function tenantIdentityQuery(input) {
1263
- return {
1264
- tenantId: cleanRequiredString(input.tenantId, "tenantId"),
1265
- workspaceId: input.workspaceId,
1266
- principalId: input.principalId,
1267
- limit: input.limit,
1268
- cursor: input.cursor
1269
- };
1270
- }
1271
- function tenantIdentityBody(input, operation) {
1272
- return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
1273
- }
1274
- function createIdentityClient(config = {}) {
1275
- const gateway = createGatewayRequestClient(config);
1276
- const whoamiClient = createIdentityWhoamiClient(config);
1277
- const requestPrincipalWrite = (method, input, idempotencyKey) => gateway.request({
1278
- path: "/api/platform/v1/identity/principals",
1279
- method,
1280
- body: input,
1281
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1282
- });
1283
- const updatePrincipal = (input, idempotencyKey) => requestPrincipalWrite("PATCH", input, idempotencyKey);
1284
- const deleteKey = (keyId, input = {}, idempotencyKey) => gateway.request({
1285
- path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
1286
- method: "POST",
1287
- body: input,
1288
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1289
- });
1290
- return {
1291
- /**
1292
- * Resolve the current authenticated identity summary.
1293
- */
1294
- async whoami() {
1295
- return whoamiClient.whoami().then(
1296
- (response) => mapGatewayData(response, (data) => ({
1297
- principalId: data.principalId,
1298
- principalType: data.principalType,
1299
- clerkId: data.clerkId,
1300
- tenantId: data.tenantId ?? null,
1301
- workspaceId: data.workspaceId ?? null,
1302
- scopes: Array.isArray(data.scopes) ? data.scopes : [],
1303
- roles: Array.isArray(data.roles) ? data.roles : [],
1304
- groupIds: Array.isArray(data.groupIds) ? data.groupIds : [],
1305
- permittedToolNames: Array.isArray(data.permittedToolNames) ? data.permittedToolNames : [],
1306
- permittedPackKeys: Array.isArray(data.permittedPackKeys) ? data.permittedPackKeys : [],
1307
- principalStatus: data.principalStatus,
1308
- tenantStatus: data.tenantStatus,
1309
- workspaceStatus: data.workspaceStatus,
1310
- isPlatformAdmin: data.isPlatformAdmin === true,
1311
- isTenantAdmin: data.isTenantAdmin === true,
1312
- isWorkspaceAdmin: data.isWorkspaceAdmin === true,
1313
- permit: data.permit ?? (data.tenantId ? {
1314
- subject: data.principalId,
1315
- tenant: data.tenantId,
1316
- ...data.workspaceId ? { workspace: data.workspaceId } : {}
1317
- } : void 0),
1318
- authMode: data.authMode,
1319
- sessionId: data.sessionId,
1320
- delegatedBy: data.delegatedBy,
1321
- expiresAt: data.expiresAt
1322
- }))
1323
- );
1324
- },
1325
- /**
1326
- * Resolve a Clerk subject through the tenant control-plane Permit projection.
1327
- * @deprecated Prefer lucern.controlPlane.identity.resolveInteractivePrincipal().
1328
- */
1329
- async resolveInteractivePrincipal(input) {
1330
- return gateway.request({
1331
- path: "/api/platform/v1/control-plane/identity/resolve-interactive-principal",
1332
- method: "POST",
1333
- body: input
1334
- }).then(
1335
- (response) => mapGatewayData(response, normalizeResolvedInteractivePrincipal)
1336
- );
1337
- },
1338
- /**
1339
- * List principals in the current identity scope.
1340
- */
1341
- async listPrincipals(query = {}) {
1342
- return gateway.request({
1343
- path: `/api/platform/v1/identity/principals${toQueryString(query)}`
1344
- }).then(
1345
- (response) => mapGatewayData(
1346
- response,
1347
- (data) => createListResult(
1348
- Array.isArray(data) ? data : [],
1349
- "principals"
1350
- )
1351
- )
1352
- );
1353
- },
1354
- /**
1355
- * Create a principal.
1356
- */
1357
- async createPrincipal(input, idempotencyKey) {
1358
- return requestPrincipalWrite("POST", input, idempotencyKey);
1359
- },
1360
- /**
1361
- * Update a principal.
1362
- */
1363
- updatePrincipal,
1364
- /**
1365
- * @deprecated Use createPrincipal or updatePrincipal.
1366
- */
1367
- upsertPrincipal: updatePrincipal,
1368
- /**
1369
- * List keys in the current identity scope.
1370
- */
1371
- async listKeys(query = {}) {
1372
- return gateway.request({
1373
- path: `/api/platform/v1/identity/keys${toQueryString(query)}`
1374
- }).then(
1375
- (response) => mapGatewayData(
1376
- response,
1377
- (data) => createListResult(Array.isArray(data) ? data : [], "keys")
1378
- )
1379
- );
1380
- },
1381
- /**
1382
- * Create an API key.
1383
- */
1384
- async createKey(input, idempotencyKey) {
1385
- return gateway.request({
1386
- path: "/api/platform/v1/identity/keys",
1387
- method: "POST",
1388
- body: input,
1389
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1390
- });
1391
- },
1392
- /**
1393
- * Rotate an API key.
1394
- */
1395
- async rotateKey(keyId, input = {}, idempotencyKey) {
1396
- return gateway.request({
1397
- path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/rotate`,
1398
- method: "POST",
1399
- body: input,
1400
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1401
- });
1402
- },
1403
- /**
1404
- * Delete an API key by revoking it.
1405
- */
1406
- deleteKey,
1407
- /**
1408
- * @deprecated Use deleteKey.
1409
- */
1410
- revokeKey: deleteKey,
1411
- /**
1412
- * Search Clerk users by email or display attributes.
1413
- */
1414
- async searchClerkUsers(q) {
1415
- return gateway.request({
1416
- path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
1417
- });
1418
- },
1419
- async getTenantConfig(input) {
1420
- return gateway.request({
1421
- path: `/api/platform/v1/identity/tenant-config${toQueryString(
1422
- tenantIdentityQuery(input)
1423
- )}`
1424
- });
1425
- },
1426
- async updateTenantConfig(input, idempotencyKey) {
1427
- cleanRequiredString(input.tenantId, "tenantId");
1428
- return gateway.request({
1429
- path: "/api/platform/v1/identity/tenant-config",
1430
- method: "PATCH",
1431
- body: tenantIdentityBody(
1432
- input,
1433
- "identity.updateTenantConfig"
1434
- ),
1435
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1436
- });
1437
- },
1438
- async listIntegrations(input) {
1439
- return gateway.request({
1440
- path: `/api/platform/v1/identity/integrations${toQueryString(
1441
- tenantIdentityQuery(input)
1442
- )}`
1443
- }).then(
1444
- (response) => mapGatewayData(
1445
- response,
1446
- (data) => listResultFromEnvelope(
1447
- data,
1448
- "integrations"
1449
- )
1450
- )
1451
- );
1452
- },
1453
- async upsertIntegration(input, idempotencyKey) {
1454
- cleanRequiredString(input.tenantId, "tenantId");
1455
- cleanRequiredString(input.integrationKey, "integrationKey");
1456
- return gateway.request({
1457
- path: "/api/platform/v1/identity/integrations",
1458
- method: "PUT",
1459
- body: tenantIdentityBody(
1460
- input,
1461
- "identity.upsertIntegration"
1462
- ),
1463
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1464
- });
1465
- },
1466
- async listSecrets(input) {
1467
- return gateway.request({
1468
- path: `/api/platform/v1/identity/secrets${toQueryString(
1469
- tenantIdentityQuery(input)
1470
- )}`
1471
- }).then(
1472
- (response) => mapGatewayData(
1473
- response,
1474
- (data) => listResultFromEnvelope(
1475
- data,
1476
- "secrets"
1477
- )
1478
- )
1479
- );
1480
- },
1481
- async putSecretReference(input, idempotencyKey) {
1482
- cleanRequiredString(input.tenantId, "tenantId");
1483
- cleanRequiredString(input.secretRef, "secretRef");
1484
- return gateway.request({
1485
- path: "/api/platform/v1/identity/secrets",
1486
- method: "PUT",
1487
- body: tenantIdentityBody(
1488
- input,
1489
- "identity.putSecretReference"
1490
- ),
1491
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1492
- });
1493
- },
1494
- async evaluatePolicy(input, idempotencyKey) {
1495
- cleanRequiredString(input.tenantId, "tenantId");
1496
- cleanRequiredString(input.policySubject, "policySubject");
1497
- cleanRequiredString(input.policyAction, "policyAction");
1498
- cleanRequiredString(input.policyResource, "policyResource");
1499
- return gateway.request({
1500
- path: "/api/platform/v1/identity/policy/evaluate",
1501
- method: "POST",
1502
- body: tenantIdentityBody(
1503
- input,
1504
- "identity.evaluatePolicy"
1505
- ),
1506
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1507
- });
1508
- },
1509
- async recordPolicyDecision(input, idempotencyKey) {
1510
- cleanRequiredString(input.tenantId, "tenantId");
1511
- cleanRequiredString(input.decision, "decision");
1512
- return gateway.request({
1513
- path: "/api/platform/v1/identity/policy/decisions",
1514
- method: "POST",
1515
- body: tenantIdentityBody(
1516
- input,
1517
- "identity.recordPolicyDecision"
1518
- ),
1519
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1520
- });
1521
- }
1522
- };
1523
456
  }
1524
-
1525
- // src/ontologyClient.ts
1526
- function createOntologyClient(config = {}) {
1527
- const gateway = createGatewayRequestClient(config);
1528
- const client = {
1529
- /**
1530
- * List ontology definitions matching optional filters.
1531
- */
1532
- async list(filters = {}) {
1533
- return gateway.request({
1534
- path: `/api/platform/v1/ontologies${toQueryString(filters)}`
1535
- }).then(
1536
- (response) => mapGatewayData(response, (data) => {
1537
- const record = asRecord(data);
1538
- const ontologies = asListItems(data, "ontologies");
1539
- const definitions = ontologies.length > 0 ? ontologies : asListItems(data, "definitions");
1540
- const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : definitions.length;
1541
- return {
1542
- ...record,
1543
- ...createListResult(definitions, "definitions"),
1544
- ontologies: definitions,
1545
- total
1546
- };
1547
- })
1548
- );
1549
- },
1550
- /**
1551
- * Get an ontology definition by identifier.
1552
- */
1553
- async get(id) {
1554
- return gateway.request({
1555
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
1556
- });
1557
- },
1558
- /**
1559
- * Bind an ontology definition to a topic.
1560
- */
1561
- async bind(input, idempotencyKey) {
1562
- return gateway.request({
1563
- path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
1564
- method: "POST",
1565
- body: {
1566
- topicId: input.topicId
457
+ export function createQuestionsFacade(config = {}) {
458
+ const gateway = createGatewayRequestClient(config);
459
+ return {
460
+ async create(input, idempotencyKey = randomIdempotencyKey()) {
461
+ return gateway.request({
462
+ path: "/api/platform/v1/questions",
463
+ method: "POST",
464
+ body: input,
465
+ idempotencyKey,
466
+ });
1567
467
  },
1568
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1569
- });
1570
- },
1571
- /**
1572
- * Create an ontology definition.
1573
- */
1574
- async createDefinition(input, idempotencyKey) {
1575
- return gateway.request({
1576
- path: "/api/platform/v1/ontologies",
1577
- method: "POST",
1578
- body: input,
1579
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1580
- });
1581
- },
1582
- /**
1583
- * Update an ontology definition.
1584
- */
1585
- async updateDefinition(id, input, idempotencyKey) {
1586
- return gateway.request({
1587
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
1588
- method: "PATCH",
1589
- body: input,
1590
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1591
- });
1592
- },
1593
- /**
1594
- * Archive an ontology definition.
1595
- */
1596
- async archiveDefinition(id, idempotencyKey) {
1597
- return gateway.request({
1598
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
1599
- method: "DELETE",
1600
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1601
- });
1602
- },
1603
- /**
1604
- * List versions for an ontology definition.
1605
- */
1606
- async listVersions(ontologyId, filters = {}) {
1607
- return gateway.request({
1608
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions${toQueryString(filters)}`
1609
- }).then(
1610
- (response) => mapGatewayData(
1611
- response,
1612
- (data) => createListResult(asListItems(data, "versions"), "versions")
1613
- )
1614
- );
1615
- },
1616
- /**
1617
- * Create an ontology version.
1618
- */
1619
- async createVersion(ontologyId, input, idempotencyKey) {
1620
- return gateway.request({
1621
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions`,
1622
- method: "POST",
1623
- body: input,
1624
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1625
- });
1626
- },
1627
- /**
1628
- * Publish an ontology version.
1629
- */
1630
- async publishVersion(ontologyId, versionId, idempotencyKey) {
1631
- return gateway.request({
1632
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/publish`,
1633
- method: "POST",
1634
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1635
- });
1636
- },
1637
- /**
1638
- * Deprecate an ontology version.
1639
- */
1640
- async deprecateVersion(ontologyId, versionId, idempotencyKey) {
1641
- return gateway.request({
1642
- path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/deprecate`,
1643
- method: "POST",
1644
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1645
- });
1646
- },
1647
- /**
1648
- * List topics directly bound to a specific ontology definition.
1649
- * Uses the topics gateway with ontologyId filter.
1650
- */
1651
- async listTopics(ontologyId) {
1652
- return gateway.request({
1653
- path: `/api/platform/v1/topics?ontologyId=${encodeURIComponent(ontologyId)}`
1654
- }).then(
1655
- (response) => mapGatewayData(
1656
- response,
1657
- (data) => createListResult(Array.isArray(data) ? data : [], "topics")
1658
- )
1659
- );
1660
- }
1661
- };
1662
- return Object.assign(client, {
1663
- listDefinitions: client.list,
1664
- getDefinition: client.get,
1665
- listTopicsByOntology: client.listTopics
1666
- });
1667
- }
1668
-
1669
- // src/gatewayFacades.factories.ts
1670
- function normalizeBeliefConfidenceInput(input) {
1671
- const opinion = input.opinion;
1672
- return {
1673
- belief: opinion.b,
1674
- disbelief: opinion.d,
1675
- uncertainty: opinion.u,
1676
- baseRate: opinion.a,
1677
- trigger: input.trigger,
1678
- rationale: input.rationale,
1679
- triggeringEvidenceId: input.triggeringEvidenceId,
1680
- triggeringQuestionId: input.triggeringQuestionId,
1681
- triggeringAnswerId: input.triggeringAnswerId,
1682
- triggeringContradictionId: input.triggeringContradictionId,
1683
- triggeringWorktreeId: input.triggeringWorktreeId,
1684
- maxInlinePropagationTargets: input.maxInlinePropagationTargets
1685
- };
1686
- }
1687
- function serializeTypes(types) {
1688
- return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
1689
- }
1690
- function createBeliefsFacade(config = {}) {
1691
- const gateway = createGatewayRequestClient(config);
1692
- return {
1693
- async create(input, idempotencyKey = randomIdempotencyKey()) {
1694
- return gateway.request({
1695
- path: "/api/platform/v1/beliefs",
1696
- method: "POST",
1697
- body: input,
1698
- idempotencyKey
1699
- });
1700
- },
1701
- async get(id) {
1702
- return gateway.request({
1703
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`
1704
- });
1705
- },
1706
- async list(query) {
1707
- return gateway.request({
1708
- path: `/api/platform/v1/beliefs${toQueryString({
1709
- topicId: query.topicId,
1710
- status: query.status,
1711
- worktreeId: query.worktreeId,
1712
- minConfidence: query.minConfidence,
1713
- limit: query.limit,
1714
- cursor: query.cursor
1715
- })}`
1716
- });
1717
- },
1718
- async refine(id, input, idempotencyKey = randomIdempotencyKey()) {
1719
- return gateway.request({
1720
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
1721
- method: "PATCH",
1722
- body: input,
1723
- idempotencyKey
1724
- });
1725
- },
1726
- async fork(id, input, idempotencyKey = randomIdempotencyKey()) {
1727
- return gateway.request({
1728
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/fork`,
1729
- method: "POST",
1730
- body: input,
1731
- idempotencyKey
1732
- });
1733
- },
1734
- async updateConfidence(id, input, idempotencyKey = randomIdempotencyKey()) {
1735
- return gateway.request({
1736
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence`,
1737
- method: "POST",
1738
- body: normalizeBeliefConfidenceInput(input),
1739
- idempotencyKey
1740
- });
1741
- },
1742
- async updateStatus(input, idempotencyKey = randomIdempotencyKey()) {
1743
- return gateway.request({
1744
- path: "/api/platform/v1/beliefs/update-status",
1745
- method: "POST",
1746
- body: input,
1747
- idempotencyKey
1748
- });
1749
- },
1750
- async updateRationale(input, idempotencyKey = randomIdempotencyKey()) {
1751
- return gateway.request({
1752
- path: "/api/platform/v1/beliefs/update-rationale",
1753
- method: "POST",
1754
- body: input,
1755
- idempotencyKey
1756
- });
1757
- },
1758
- async linkBeliefs(input, idempotencyKey = randomIdempotencyKey()) {
1759
- return gateway.request({
1760
- path: "/api/platform/v1/beliefs/link",
1761
- method: "POST",
1762
- body: input,
1763
- idempotencyKey
1764
- });
1765
- },
1766
- async unlinkEvidence(input, idempotencyKey = randomIdempotencyKey()) {
1767
- return gateway.request({
1768
- path: "/api/platform/v1/beliefs/unlink-evidence",
1769
- method: "POST",
1770
- body: input,
1771
- idempotencyKey
1772
- });
1773
- },
1774
- async updateCriticality(input, idempotencyKey = randomIdempotencyKey()) {
1775
- return gateway.request({
1776
- path: "/api/platform/v1/beliefs/update-criticality",
1777
- method: "POST",
1778
- body: input,
1779
- idempotencyKey
1780
- });
1781
- },
1782
- async batchUpdateCriticality(input, idempotencyKey = randomIdempotencyKey()) {
1783
- return gateway.request({
1784
- path: "/api/platform/v1/beliefs/batch-update-criticality",
1785
- method: "POST",
1786
- body: input,
1787
- idempotencyKey
1788
- });
1789
- },
1790
- async reassignTopic(input, idempotencyKey = randomIdempotencyKey()) {
1791
- return gateway.request({
1792
- path: "/api/platform/v1/beliefs/reassign-topic",
1793
- method: "POST",
1794
- body: input,
1795
- idempotencyKey
1796
- });
1797
- },
1798
- async archive(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
1799
- return gateway.request({
1800
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
1801
- method: "DELETE",
1802
- body: input,
1803
- idempotencyKey
1804
- });
1805
- },
1806
- async lineage(id) {
1807
- return gateway.request({
1808
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/lineage`
1809
- });
1810
- },
1811
- async confidenceHistory(id) {
1812
- return gateway.request({
1813
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
1814
- });
1815
- },
1816
- async opinionHistory(id) {
1817
- return gateway.request({
1818
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
1819
- });
1820
- },
1821
- async createContract(id, input, idempotencyKey = randomIdempotencyKey()) {
1822
- return gateway.request({
1823
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/contracts`,
1824
- method: "POST",
1825
- body: input,
1826
- idempotencyKey
1827
- });
1828
- },
1829
- async bisect(id, input, idempotencyKey = randomIdempotencyKey()) {
1830
- return gateway.request({
1831
- path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/bisect`,
1832
- method: "POST",
1833
- body: input,
1834
- idempotencyKey
1835
- });
1836
- }
1837
- };
1838
- }
1839
- function createContradictionsFacade(config = {}) {
1840
- const gateway = createGatewayRequestClient(config);
1841
- return {
1842
- async flag(input, idempotencyKey = randomIdempotencyKey()) {
1843
- return gateway.request({
1844
- path: "/api/platform/v1/contradictions",
1845
- method: "POST",
1846
- body: input,
1847
- idempotencyKey
1848
- });
1849
- },
1850
- async list(query) {
1851
- return gateway.request({
1852
- path: `/api/platform/v1/contradictions${toQueryString({
1853
- topicId: query.topicId,
1854
- status: query.status,
1855
- limit: query.limit,
1856
- cursor: query.cursor
1857
- })}`
1858
- });
1859
- },
1860
- async get(id) {
1861
- return gateway.request({
1862
- path: `/api/platform/v1/contradictions/${encodeURIComponent(id)}`
1863
- });
1864
- }
1865
- };
1866
- }
1867
- function createEdgesFacade(config = {}) {
1868
- const gateway = createGatewayRequestClient(config);
1869
- return {
1870
- async create(input, idempotencyKey = randomIdempotencyKey()) {
1871
- return gateway.request({
1872
- path: "/api/platform/v1/edges",
1873
- method: "POST",
1874
- body: input,
1875
- idempotencyKey
1876
- });
1877
- },
1878
- async list(query) {
1879
- return gateway.request({
1880
- path: `/api/platform/v1/edges${toQueryString({
1881
- sourceId: query.sourceId,
1882
- edgeType: query.edgeType,
1883
- limit: query.limit,
1884
- cursor: query.cursor
1885
- })}`
1886
- });
1887
- },
1888
- async traverse(input, idempotencyKey = randomIdempotencyKey()) {
1889
- return gateway.request({
1890
- path: "/api/platform/v1/edges/traverse",
1891
- method: "POST",
1892
- body: input,
1893
- idempotencyKey
1894
- });
1895
- },
1896
- async update(input, idempotencyKey = randomIdempotencyKey()) {
1897
- return gateway.request({
1898
- path: "/api/platform/v1/edges/update",
1899
- method: "POST",
1900
- body: input,
1901
- idempotencyKey
1902
- });
1903
- },
1904
- async remove(input, idempotencyKey = randomIdempotencyKey()) {
1905
- return gateway.request({
1906
- path: "/api/platform/v1/edges/remove",
1907
- method: "POST",
1908
- body: input,
1909
- idempotencyKey
1910
- });
1911
- },
1912
- async removeBetween(input, idempotencyKey = randomIdempotencyKey()) {
1913
- return gateway.request({
1914
- path: "/api/platform/v1/edges/remove-between",
1915
- method: "POST",
1916
- body: input,
1917
- idempotencyKey
1918
- });
1919
- },
1920
- async batchCreate(input, idempotencyKey = randomIdempotencyKey()) {
1921
- return gateway.request({
1922
- path: "/api/platform/v1/edges/batch",
1923
- method: "POST",
1924
- body: input,
1925
- idempotencyKey
1926
- });
1927
- },
1928
- async delete(input, idempotencyKey = randomIdempotencyKey()) {
1929
- return gateway.request({
1930
- path: "/api/platform/v1/edges/delete",
1931
- method: "POST",
1932
- body: input,
1933
- idempotencyKey
1934
- });
1935
- }
1936
- };
1937
- }
1938
- function createEvidenceFacade(config = {}) {
1939
- const gateway = createGatewayRequestClient(config);
1940
- return {
1941
- async create(input, idempotencyKey = randomIdempotencyKey()) {
1942
- return gateway.request({
1943
- path: "/api/platform/v1/evidence",
1944
- method: "POST",
1945
- body: input,
1946
- idempotencyKey
1947
- });
1948
- },
1949
- async get(id) {
1950
- return gateway.request({
1951
- path: `/api/platform/v1/evidence/${encodeURIComponent(id)}`
1952
- });
1953
- },
1954
- async list(query) {
1955
- return gateway.request({
1956
- path: `/api/platform/v1/evidence${toQueryString({
1957
- topicId: query.topicId,
1958
- targetId: query.targetId,
1959
- limit: query.limit,
1960
- cursor: query.cursor
1961
- })}`
1962
- });
1963
- },
1964
- async link(input, idempotencyKey = randomIdempotencyKey()) {
1965
- return gateway.request({
1966
- path: `/api/platform/v1/evidence/${encodeURIComponent(input.evidenceId)}/link`,
1967
- method: "POST",
1968
- body: {
1969
- targetId: input.targetId,
1970
- targetType: input.targetType,
1971
- weight: input.weight,
1972
- rationale: input.rationale
468
+ async get(id) {
469
+ return gateway.request({
470
+ path: `/api/platform/v1/questions/${encodeURIComponent(id)}`,
471
+ });
1973
472
  },
1974
- idempotencyKey
1975
- });
1976
- },
1977
- async search(query, idempotencyKey = randomIdempotencyKey()) {
1978
- return gateway.request({
1979
- path: "/api/platform/v1/evidence/search",
1980
- method: "POST",
1981
- body: query,
1982
- idempotencyKey
1983
- });
1984
- },
1985
- async updateStatus(input, idempotencyKey = randomIdempotencyKey()) {
1986
- return gateway.request({
1987
- path: "/api/platform/v1/evidence/update-status",
1988
- method: "POST",
1989
- body: input,
1990
- idempotencyKey
1991
- });
1992
- },
1993
- async update(input, idempotencyKey = randomIdempotencyKey()) {
1994
- return gateway.request({
1995
- path: "/api/platform/v1/evidence/update",
1996
- method: "POST",
1997
- body: input,
1998
- idempotencyKey
1999
- });
2000
- },
2001
- async flagIncorrect(input, idempotencyKey = randomIdempotencyKey()) {
2002
- return gateway.request({
2003
- path: "/api/platform/v1/evidence/flag-incorrect",
2004
- method: "POST",
2005
- body: input,
2006
- idempotencyKey
2007
- });
2008
- },
2009
- async remove(input, idempotencyKey = randomIdempotencyKey()) {
2010
- return gateway.request({
2011
- path: "/api/platform/v1/evidence/remove",
2012
- method: "POST",
2013
- body: input,
2014
- idempotencyKey
2015
- });
2016
- },
2017
- async updateVerificationStatus(input, idempotencyKey = randomIdempotencyKey()) {
2018
- return gateway.request({
2019
- path: "/api/platform/v1/evidence/update-verification-status",
2020
- method: "POST",
2021
- body: input,
2022
- idempotencyKey
2023
- });
2024
- }
2025
- };
2026
- }
2027
- function createEventsFacade(config = {}) {
2028
- const gateway = createGatewayRequestClient(config);
2029
- return {
2030
- async list(query = {}) {
2031
- return gateway.request({
2032
- path: `/api/platform/v1/events${toQueryString({
2033
- topicId: query.topicId,
2034
- after: query.after,
2035
- types: serializeTypes(query.types),
2036
- startTime: query.startTime,
2037
- endTime: query.endTime,
2038
- limit: query.limit
2039
- })}`
2040
- });
2041
- },
2042
- async replay(input, idempotencyKey = randomIdempotencyKey()) {
2043
- return gateway.request({
2044
- path: "/api/platform/v1/events/replay",
2045
- method: "POST",
2046
- body: input,
2047
- idempotencyKey
2048
- });
2049
- }
2050
- };
2051
- }
2052
- function createGraphFacade(config = {}) {
2053
- const graphClient = createGraphClient(config);
2054
- const gateway = createGatewayRequestClient(config);
2055
- const graphFacade = {
2056
- async neighborhood(input) {
2057
- return graphClient.neighborhood({
2058
- globalId: input.globalId,
2059
- globalIds: Array.isArray(input.globalIds) ? input.globalIds.join(",") : input.globalIds,
2060
- maxDepth: input.maxDepth
2061
- });
2062
- },
2063
- async falsify(input, idempotencyKey = randomIdempotencyKey()) {
2064
- return gateway.request({
2065
- path: "/api/platform/v1/graph/falsify",
2066
- method: "POST",
2067
- body: input,
2068
- idempotencyKey
2069
- });
2070
- }
2071
- };
2072
- return Object.assign(graphFacade, {
2073
- traverse: graphClient.traverse,
2074
- analyze: graphClient.analyze,
2075
- bias: graphClient.bias,
2076
- gaps: graphClient.gaps
2077
- });
2078
- }
2079
- function createIdentityFacade(config = {}) {
2080
- const identityClient = createIdentityClient(config);
2081
- return {
2082
- async whoami() {
2083
- const response = await identityClient.whoami();
2084
- return Object.assign({}, response, response.data);
2085
- }
2086
- };
2087
- }
2088
- function createOntologiesFacade(config = {}) {
2089
- const ontologyClient = createOntologyClient(config);
2090
- const gateway = createGatewayRequestClient(config);
2091
- const ontologyFacade = {
2092
- async get(id) {
2093
- return gateway.request({
2094
- path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2095
- });
2096
- },
2097
- async bind(input, idempotencyKey) {
2098
- return gateway.request({
2099
- path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
2100
- method: "POST",
2101
- body: {
2102
- topicId: input.topicId
473
+ async list(query) {
474
+ return gateway.request({
475
+ path: `/api/platform/v1/questions${toQueryString({
476
+ topicId: query.topicId,
477
+ status: query.status,
478
+ priority: query.priority,
479
+ worktreeId: query.worktreeId,
480
+ limit: query.limit,
481
+ cursor: query.cursor,
482
+ })}`,
483
+ });
2103
484
  },
2104
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2105
- });
2106
- },
2107
- async match(input, idempotencyKey) {
2108
- return gateway.request({
2109
- path: "/api/platform/v1/ontologies/match",
2110
- method: "POST",
2111
- body: input,
2112
- idempotencyKey
2113
- });
2114
- }
2115
- };
2116
- return Object.assign(ontologyFacade, {
2117
- list: ontologyClient.list
2118
- });
2119
- }
2120
- function createQuestionsFacade(config = {}) {
2121
- const gateway = createGatewayRequestClient(config);
2122
- return {
2123
- async create(input, idempotencyKey = randomIdempotencyKey()) {
2124
- return gateway.request({
2125
- path: "/api/platform/v1/questions",
2126
- method: "POST",
2127
- body: input,
2128
- idempotencyKey
2129
- });
2130
- },
2131
- async get(id) {
2132
- return gateway.request({
2133
- path: `/api/platform/v1/questions/${encodeURIComponent(id)}`
2134
- });
2135
- },
2136
- async list(query) {
2137
- return gateway.request({
2138
- path: `/api/platform/v1/questions${toQueryString({
2139
- topicId: query.topicId,
2140
- status: query.status,
2141
- priority: query.priority,
2142
- worktreeId: query.worktreeId,
2143
- limit: query.limit,
2144
- cursor: query.cursor
2145
- })}`
2146
- });
2147
- },
2148
- async answer(id, input, idempotencyKey = randomIdempotencyKey()) {
2149
- return gateway.request({
2150
- path: `/api/platform/v1/questions/${encodeURIComponent(id)}/answer`,
2151
- method: "POST",
2152
- body: input,
2153
- idempotencyKey
2154
- });
2155
- },
2156
- async refine(id, input, idempotencyKey = randomIdempotencyKey()) {
2157
- return gateway.request({
2158
- path: `/api/platform/v1/questions/${encodeURIComponent(id)}/refine`,
2159
- method: "POST",
2160
- body: input,
2161
- idempotencyKey
2162
- });
2163
- },
2164
- async archive(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
2165
- return gateway.request({
2166
- path: `/api/platform/v1/questions/${encodeURIComponent(id)}`,
2167
- method: "DELETE",
2168
- body: input,
2169
- idempotencyKey
2170
- });
2171
- },
2172
- async updateStatus(id, input, idempotencyKey = randomIdempotencyKey()) {
2173
- return gateway.request({
2174
- path: `/api/platform/v1/questions/${encodeURIComponent(id)}/status`,
2175
- method: "PATCH",
2176
- body: input,
2177
- idempotencyKey
2178
- });
2179
- },
2180
- async batchCreate(input, idempotencyKey = randomIdempotencyKey()) {
2181
- return gateway.request({
2182
- path: "/api/platform/v1/questions/batch",
2183
- method: "POST",
2184
- body: input,
2185
- idempotencyKey
2186
- });
2187
- },
2188
- async add(input, idempotencyKey = randomIdempotencyKey()) {
2189
- return gateway.request({
2190
- path: "/api/platform/v1/questions/add",
2191
- method: "POST",
2192
- body: input,
2193
- idempotencyKey
2194
- });
2195
- },
2196
- async updatePriority(input, idempotencyKey = randomIdempotencyKey()) {
2197
- return gateway.request({
2198
- path: "/api/platform/v1/questions/update-priority",
2199
- method: "POST",
2200
- body: input,
2201
- idempotencyKey
2202
- });
2203
- },
2204
- async advanceToConviction(input, idempotencyKey = randomIdempotencyKey()) {
2205
- return gateway.request({
2206
- path: "/api/platform/v1/questions/advance-to-conviction",
2207
- method: "POST",
2208
- body: input,
2209
- idempotencyKey
2210
- });
2211
- },
2212
- async updateConviction(input, idempotencyKey = randomIdempotencyKey()) {
2213
- return gateway.request({
2214
- path: "/api/platform/v1/questions/update-conviction",
2215
- method: "POST",
2216
- body: input,
2217
- idempotencyKey
2218
- });
2219
- },
2220
- async finalizeConviction(input, idempotencyKey = randomIdempotencyKey()) {
2221
- return gateway.request({
2222
- path: "/api/platform/v1/questions/finalize-conviction",
2223
- method: "POST",
2224
- body: input,
2225
- idempotencyKey
2226
- });
2227
- },
2228
- async update(input, idempotencyKey = randomIdempotencyKey()) {
2229
- return gateway.request({
2230
- path: "/api/platform/v1/questions/update",
2231
- method: "POST",
2232
- body: input,
2233
- idempotencyKey
2234
- });
2235
- },
2236
- async delete(input, idempotencyKey = randomIdempotencyKey()) {
2237
- return gateway.request({
2238
- path: "/api/platform/v1/questions/delete",
2239
- method: "POST",
2240
- body: input,
2241
- idempotencyKey
2242
- });
2243
- }
2244
- };
485
+ async answer(id, input, idempotencyKey = randomIdempotencyKey()) {
486
+ return gateway.request({
487
+ path: `/api/platform/v1/questions/${encodeURIComponent(id)}/answer`,
488
+ method: "POST",
489
+ body: input,
490
+ idempotencyKey,
491
+ });
492
+ },
493
+ async refine(id, input, idempotencyKey = randomIdempotencyKey()) {
494
+ return gateway.request({
495
+ path: `/api/platform/v1/questions/${encodeURIComponent(id)}/refine`,
496
+ method: "POST",
497
+ body: input,
498
+ idempotencyKey,
499
+ });
500
+ },
501
+ async archive(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
502
+ return gateway.request({
503
+ path: `/api/platform/v1/questions/${encodeURIComponent(id)}`,
504
+ method: "DELETE",
505
+ body: input,
506
+ idempotencyKey,
507
+ });
508
+ },
509
+ async updateStatus(id, input, idempotencyKey = randomIdempotencyKey()) {
510
+ return gateway.request({
511
+ path: `/api/platform/v1/questions/${encodeURIComponent(id)}/status`,
512
+ method: "PATCH",
513
+ body: input,
514
+ idempotencyKey,
515
+ });
516
+ },
517
+ async batchCreate(input, idempotencyKey = randomIdempotencyKey()) {
518
+ return gateway.request({
519
+ path: "/api/platform/v1/questions/batch",
520
+ method: "POST",
521
+ body: input,
522
+ idempotencyKey,
523
+ });
524
+ },
525
+ async add(input, idempotencyKey = randomIdempotencyKey()) {
526
+ return gateway.request({
527
+ path: "/api/platform/v1/questions/add",
528
+ method: "POST",
529
+ body: input,
530
+ idempotencyKey,
531
+ });
532
+ },
533
+ async updatePriority(input, idempotencyKey = randomIdempotencyKey()) {
534
+ return gateway.request({
535
+ path: "/api/platform/v1/questions/update-priority",
536
+ method: "POST",
537
+ body: input,
538
+ idempotencyKey,
539
+ });
540
+ },
541
+ async advanceToConviction(input, idempotencyKey = randomIdempotencyKey()) {
542
+ return gateway.request({
543
+ path: "/api/platform/v1/questions/advance-to-conviction",
544
+ method: "POST",
545
+ body: input,
546
+ idempotencyKey,
547
+ });
548
+ },
549
+ async updateConviction(input, idempotencyKey = randomIdempotencyKey()) {
550
+ return gateway.request({
551
+ path: "/api/platform/v1/questions/update-conviction",
552
+ method: "POST",
553
+ body: input,
554
+ idempotencyKey,
555
+ });
556
+ },
557
+ async finalizeConviction(input, idempotencyKey = randomIdempotencyKey()) {
558
+ return gateway.request({
559
+ path: "/api/platform/v1/questions/finalize-conviction",
560
+ method: "POST",
561
+ body: input,
562
+ idempotencyKey,
563
+ });
564
+ },
565
+ async update(input, idempotencyKey = randomIdempotencyKey()) {
566
+ return gateway.request({
567
+ path: "/api/platform/v1/questions/update",
568
+ method: "POST",
569
+ body: input,
570
+ idempotencyKey,
571
+ });
572
+ },
573
+ async delete(input, idempotencyKey = randomIdempotencyKey()) {
574
+ return gateway.request({
575
+ path: "/api/platform/v1/questions/delete",
576
+ method: "POST",
577
+ body: input,
578
+ idempotencyKey,
579
+ });
580
+ },
581
+ };
2245
582
  }
2246
-
2247
- export { createBeliefsFacade, createContradictionsFacade, createEdgesFacade, createEventsFacade, createEvidenceFacade, createGraphFacade, createIdentityFacade, createOntologiesFacade, createQuestionsFacade };
2248
- //# sourceMappingURL=gatewayFacades.factories.js.map
2249
583
  //# sourceMappingURL=gatewayFacades.factories.js.map