@lucern/sdk 1.0.11 → 1.0.13

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 +10 -0
  2. package/README.md +24 -27
  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 +16 -67
  21. package/dist/beliefs/index.js +20 -10181
  22. package/dist/beliefs/lifecycle.d.ts +10 -11
  23. package/dist/beliefs/lifecycle.js +78 -80
  24. package/dist/beliefsClient.d.ts +30 -35
  25. package/dist/beliefsClient.js +238 -994
  26. package/dist/boundaryClientSurface.d.ts +11 -16
  27. package/dist/boundaryClientSurface.js +49 -68
  28. package/dist/client.d.ts +82 -113
  29. package/dist/client.js +232 -10155
  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 +24 -14
  35. package/dist/clientEvidenceCompat.js +56 -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 +24 -54
  41. package/dist/clientKnowledgeNamespaces.js +506 -506
  42. package/dist/clientLocalHelpers.d.ts +11 -56
  43. package/dist/clientLocalHelpers.js +503 -732
  44. package/dist/clientPlatformNamespaces.d.ts +5 -53
  45. package/dist/clientPlatformNamespaces.js +229 -323
  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 -10175
  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 -10177
  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 -10176
  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 +42 -61
  123. package/dist/evidence/index.js +13 -10176
  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 +93 -296
  133. package/dist/gatewayFacades.factories.d.ts +209 -14
  134. package/dist/gatewayFacades.factories.js +545 -2228
  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 -13313
  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 -10175
  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 -10177
  170. package/dist/ontologies/index.d.ts +21 -73
  171. package/dist/ontologies/index.js +14 -10178
  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 -10178
  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 -10178
  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 -10178
  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,747 +1,518 @@
1
- import '@lucern/transport-core';
2
- import '@lucern/transport-core/redaction';
3
- import '@lucern/transport-core/transport';
4
- import 'effect';
5
- import 'zod';
6
-
7
- // src/coreClient.ts
8
- function toQueryString(scope) {
9
- const params = new URLSearchParams();
10
- if (scope.tenantId) {
11
- params.set("tenantId", scope.tenantId);
12
- }
13
- if (scope.workspaceId) {
14
- params.set("workspaceId", scope.workspaceId);
15
- }
16
- for (const [key, value] of Object.entries(scope)) {
17
- if (key === "tenantId" || key === "workspaceId") {
18
- continue;
1
+ import { mapOpinionHistoryEntriesFromGatewayData } from "./beliefsClient.js";
2
+ import { addEvidenceCompat, createEvidenceCompat, } from "./clientEvidenceCompat.js";
3
+ import { asNodeArray, matchesAuditNodeReference, normalizeCustomNamespace, normalizeCustomToolPayload, requireTopicId, requireTopicOrProjectId, sdkQueryString, } from "./clientHelpers.js";
4
+ import { randomIdempotencyKey, toQueryString, } from "./coreClient.js";
5
+ import { invokeRegisteredCustomTool, } from "./customTools.js";
6
+ import { asListItems, resolveTopicId } from "./sdkSurface.js";
7
+ export function createClientLocalHelpers(ctx) {
8
+ const { auditClient, beliefsFacade, customNamespaceCache, evidenceFacade, exposeGatewayData, graphClient, graphFacade, gateway, functionSurfaceClient, ontologyClient, ontologyLinksClient, searchFacade, } = ctx;
9
+ const invokeCustomTool = async (fullName, input = {}) => {
10
+ const payload = normalizeCustomToolPayload(input);
11
+ return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
12
+ };
13
+ const getCustomNamespace = (namespace) => {
14
+ const normalized = normalizeCustomNamespace(namespace);
15
+ const cached = customNamespaceCache.get(normalized);
16
+ if (cached) {
17
+ return cached;
18
+ }
19
+ const proxy = new Proxy({}, {
20
+ get(_target, property) {
21
+ if (typeof property !== "string" || property === "then") {
22
+ return;
23
+ }
24
+ return async (input = {}) => invokeCustomTool(`${normalized}.${property}`, input);
25
+ },
26
+ });
27
+ customNamespaceCache.set(normalized, proxy);
28
+ return proxy;
29
+ };
30
+ const extensionNamespaces = new Proxy({}, {
31
+ get(_target, namespace) {
32
+ if (typeof namespace !== "string" || namespace === "then") {
33
+ return;
34
+ }
35
+ return getCustomNamespace(namespace);
36
+ },
37
+ });
38
+ const createEvidence = (args) => createEvidenceCompat(evidenceFacade, args);
39
+ const addEvidence = (args) => addEvidenceCompat(evidenceFacade, args);
40
+ async function listBeliefs(args) {
41
+ const response = await beliefsFacade.list({
42
+ topicId: requireTopicId(args),
43
+ status: args.status,
44
+ worktreeId: args.worktreeId,
45
+ minConfidence: args.minConfidence,
46
+ limit: args.limit,
47
+ cursor: args.cursor,
48
+ });
49
+ return Array.isArray(response.data.beliefs) ? response.data.beliefs : [];
19
50
  }
20
- if (value === void 0) {
21
- continue;
51
+ async function searchBeliefs(args) {
52
+ const topicId = resolveTopicId(args);
53
+ if (!topicId) {
54
+ return { results: [] };
55
+ }
56
+ const response = await searchFacade.query({
57
+ q: args.query,
58
+ topicId,
59
+ types: ["belief"],
60
+ status: args.status,
61
+ minConfidence: args.minConfidence,
62
+ limit: args.limit,
63
+ });
64
+ const data = exposeGatewayData(response);
65
+ const groupedBeliefs = Array.isArray(data.beliefs)
66
+ ? data.beliefs
67
+ : [];
68
+ const mergedResults = Array.isArray(data.results)
69
+ ? data.results
70
+ : [];
71
+ const results = groupedBeliefs.length > 0
72
+ ? groupedBeliefs
73
+ : mergedResults.filter((result) => result.type === "belief");
74
+ return { results };
22
75
  }
23
- params.set(key, String(value));
24
- }
25
- const serialized = params.toString();
26
- return serialized.length > 0 ? `?${serialized}` : "";
27
- }
28
- function fillRandomBytes(length) {
29
- const bytes = new Uint8Array(length);
30
- if (typeof globalThis.crypto?.getRandomValues === "function") {
31
- globalThis.crypto.getRandomValues(bytes);
32
- return bytes;
33
- }
34
- for (let index = 0; index < length; index += 1) {
35
- bytes[index] = Math.floor(Math.random() * 256);
36
- }
37
- return bytes;
38
- }
39
- function generatePortableRequestId() {
40
- if (typeof globalThis.crypto?.randomUUID === "function") {
41
- return globalThis.crypto.randomUUID();
42
- }
43
- const bytes = fillRandomBytes(16);
44
- bytes[6] = bytes[6] & 15 | 64;
45
- bytes[8] = bytes[8] & 63 | 128;
46
- const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
47
- return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
48
- 6,
49
- 8
50
- ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
51
- }
52
- var randomIdempotencyKey = generatePortableRequestId;
53
-
54
- // src/sdkSurface.ts
55
- function isRecord(value) {
56
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
57
- }
58
- function asRecord(value) {
59
- return isRecord(value) ? value : {};
60
- }
61
- function cleanString(value) {
62
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
63
- }
64
- function resolveTopicId(value) {
65
- return cleanString(value.topicId);
66
- }
67
- function resolveText(value) {
68
- return cleanString(value.text) ?? cleanString(value.canonicalText);
69
- }
70
- function asListItems(data, legacyKey) {
71
- if (Array.isArray(data)) {
72
- return data;
73
- }
74
- const record = asRecord(data);
75
- if (Array.isArray(record.items)) {
76
- return record.items;
77
- }
78
- if (legacyKey && Array.isArray(record[legacyKey])) {
79
- return record[legacyKey];
80
- }
81
- return [];
82
- }
83
-
84
- // src/beliefsClient.ts
85
- function asRecord2(value) {
86
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
87
- }
88
- function readString(value) {
89
- if (typeof value !== "string") {
90
- return void 0;
91
- }
92
- const normalized = value.trim();
93
- return normalized.length > 0 ? normalized : void 0;
94
- }
95
- function readNumber(value) {
96
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
97
- }
98
- function clamp01(value) {
99
- return Math.max(0, Math.min(1, value));
100
- }
101
- function normalizeOpinionTuple(record) {
102
- const opinion = asRecord2(record.opinion);
103
- const rawBelief = readNumber(opinion.b) ?? readNumber(record.belief);
104
- const rawDisbelief = readNumber(opinion.d) ?? readNumber(record.disbelief);
105
- const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
106
- const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
107
- if (rawBelief === void 0 || rawDisbelief === void 0 || rawUncertainty === void 0 || rawBaseRate === void 0) {
108
- throw new Error(
109
- "Gateway opinion history entries must include belief, disbelief, uncertainty, and baseRate."
110
- );
111
- }
112
- return {
113
- b: clamp01(rawBelief),
114
- d: clamp01(rawDisbelief),
115
- u: clamp01(rawUncertainty),
116
- a: clamp01(rawBaseRate)
117
- };
118
- }
119
- function mapOpinionHistoryEntriesFromGatewayData(payload) {
120
- const entries = Array.isArray(payload.entries) ? payload.entries : [];
121
- return entries.map((value) => {
122
- const record = asRecord2(value);
123
- const tuple = normalizeOpinionTuple(record);
124
- const projected = readNumber(record.confidence) ?? clamp01(tuple.b + tuple.a * tuple.u);
125
- const triggeringEvidenceId = readString(record.triggeringEvidenceId);
126
- const triggeringQuestionId = readString(record.triggeringQuestionId);
127
- const triggeringAnswerId = readString(record.triggeringAnswerId);
128
- const triggeringContradictionId = readString(
129
- record.triggeringContradictionId
130
- );
131
- const triggeringWorktreeId = readString(record.triggeringWorktreeId);
132
- const triggeringRef = triggeringEvidenceId ? { kind: "evidence", id: triggeringEvidenceId } : triggeringQuestionId ? { kind: "question", id: triggeringQuestionId } : triggeringAnswerId ? { kind: "answer", id: triggeringAnswerId } : triggeringContradictionId ? { kind: "contradiction", id: triggeringContradictionId } : triggeringWorktreeId ? { kind: "worktree", id: triggeringWorktreeId } : void 0;
133
- const trigger = readString(record.trigger);
134
- if (!trigger) {
135
- throw new Error("Gateway opinion history entries must include trigger.");
76
+ async function searchResources(query, options = {}) {
77
+ const topicId = resolveTopicId(options);
78
+ if (!topicId) {
79
+ throw new Error("topicId is required");
80
+ }
81
+ return searchFacade
82
+ .query({
83
+ q: query,
84
+ topicId,
85
+ types: options.types,
86
+ status: options.status,
87
+ minConfidence: options.minConfidence,
88
+ limit: options.limit,
89
+ cursor: options.cursor,
90
+ })
91
+ .then(exposeGatewayData);
136
92
  }
137
- return {
138
- t: readNumber(record.timestamp) ?? readNumber(record.assessedAt) ?? 0,
139
- b: tuple.b,
140
- d: tuple.d,
141
- u: tuple.u,
142
- a: tuple.a,
143
- P: clamp01(projected),
144
- trigger,
145
- ...triggeringRef ? { triggeringRef } : {},
146
- ...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
147
- ...readString(record.userId) ? { userId: readString(record.userId) } : {},
148
- ...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
149
- };
150
- }).sort((left, right) => left.t - right.t);
151
- }
152
-
153
- // src/clientEvidenceCompat.ts
154
- async function createEvidenceCompat(evidenceFacade, args) {
155
- const text = resolveText(args);
156
- if (!text) {
157
- throw new Error("text is required");
158
- }
159
- const rationale = args.rationale ?? args.supports?.reasoning;
160
- if (!rationale) {
161
- throw new Error("rationale is required");
162
- }
163
- const metadata = {
164
- ...args.metadata ?? {},
165
- rationale
166
- };
167
- return evidenceFacade.create({
168
- topicId: resolveTopicId(args),
169
- text,
170
- source: args.source ?? args.sourceUrl,
171
- targetId: args.targetId ?? args.supports?.nodeId,
172
- weight: args.weight ?? args.supports?.weight,
173
- rationale,
174
- metadata: Object.keys(metadata).length > 0 ? metadata : void 0,
175
- title: args.title,
176
- content: args.content,
177
- contentType: args.contentType,
178
- kind: args.kind
179
- });
180
- }
181
- async function addEvidenceCompat(evidenceFacade, args) {
182
- const created = await createEvidenceCompat(evidenceFacade, {
183
- ...args,
184
- targetId: args.supports ? void 0 : args.targetId,
185
- weight: args.supports ? void 0 : args.weight
186
- });
187
- if (!args.supports) {
188
- return created.data;
189
- }
190
- const evidenceId = created.data.id;
191
- if (typeof evidenceId !== "string" || evidenceId.length === 0) {
192
- throw new Error("evidence create did not return an id");
193
- }
194
- const linked = await evidenceFacade.link({
195
- evidenceId,
196
- targetId: args.supports.nodeId,
197
- weight: args.supports.weight,
198
- rationale: args.supports.reasoning
199
- });
200
- return {
201
- ...created.data,
202
- edgeId: linked.data.edgeId
203
- };
204
- }
205
-
206
- // src/clientHelpers.ts
207
- function normalizeCustomNamespace(namespace) {
208
- return namespace.trim() || "custom";
209
- }
210
- function normalizeCustomToolPayload(input) {
211
- return input && typeof input === "object" && !Array.isArray(input) ? input : {};
212
- }
213
- function asNodeArray(data) {
214
- const rows = asListItems(data, "nodes");
215
- if (rows.length > 0) {
216
- return rows.filter(
217
- (value) => Boolean(value) && typeof value === "object"
218
- );
219
- }
220
- if (data && typeof data === "object") {
221
- return [data];
222
- }
223
- return [];
224
- }
225
- function requireTopicId(args) {
226
- const topicId = resolveTopicId(args);
227
- if (!topicId) {
228
- throw new Error("topicId is required");
229
- }
230
- return topicId;
231
- }
232
- function requireTopicOrProjectId(args) {
233
- const topicId = args.topicId?.trim() || args.projectId?.trim() || void 0;
234
- if (!topicId) {
235
- throw new Error("topicId is required");
236
- }
237
- return topicId;
238
- }
239
- var AUDIT_NODE_REFERENCE_KEY_PATTERN = /(^|_)(id|nodeid|beliefid|resourceid|targetid|sourceid|subjectid|globalid|entityid|recordid|fromnodeid|tonodeid|linkednodeid|linkedbeliefid|nodeids|beliefids|resourceids)$/i;
240
- function matchesAuditNodeReference(value, nodeId) {
241
- if (Array.isArray(value)) {
242
- return value.some((entry) => matchesAuditNodeReference(entry, nodeId));
243
- }
244
- if (!value || typeof value !== "object") {
245
- return false;
246
- }
247
- return Object.entries(value).some(([key, entry]) => {
248
- if (typeof entry === "string" && entry === nodeId && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key)) {
249
- return true;
93
+ async function findContradictions(args) {
94
+ const topicId = resolveTopicId(args);
95
+ const response = topicId
96
+ ? await graphClient.listNodes({
97
+ topicId,
98
+ nodeType: "contradiction",
99
+ limit: 500,
100
+ })
101
+ : args.nodeId
102
+ ? await graphClient.listNodes({ nodeId: args.nodeId })
103
+ : { data: [] };
104
+ const contradictions = asNodeArray(response.data)
105
+ .filter((node) => {
106
+ const status = typeof node.metadata?.status === "string"
107
+ ? node.metadata.status
108
+ : typeof node.status === "string"
109
+ ? node.status
110
+ : "unresolved";
111
+ if (args.status && status !== args.status) {
112
+ return false;
113
+ }
114
+ return true;
115
+ })
116
+ .map((node) => ({
117
+ beliefA: typeof node.metadata?.beliefA === "string"
118
+ ? node.metadata.beliefA
119
+ : "",
120
+ beliefB: typeof node.metadata?.beliefB === "string"
121
+ ? node.metadata.beliefB
122
+ : "",
123
+ description: node.canonicalText ?? "",
124
+ severity: typeof node.metadata?.severity === "string"
125
+ ? node.metadata.severity
126
+ : "medium",
127
+ status: typeof node.metadata?.status === "string"
128
+ ? node.metadata.status
129
+ : "unresolved",
130
+ defeatType: typeof node.metadata?.defeatType === "string"
131
+ ? node.metadata.defeatType
132
+ : "rebuts",
133
+ }));
134
+ return { contradictions };
250
135
  }
251
- if (Array.isArray(entry) && AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key) && entry.some((item) => item === nodeId)) {
252
- return true;
136
+ async function queryLineage(nodeId, depth = 5) {
137
+ const response = await beliefsFacade.lineage(nodeId);
138
+ const lineage = Array.isArray(response.data.lineage)
139
+ ? response.data.lineage
140
+ : [];
141
+ const chain = lineage.length > 0
142
+ ? lineage
143
+ .slice(0, depth + 1)
144
+ .map((entry, index) => ({
145
+ nodeId: entry.nodeId ?? entry.beliefId ?? "",
146
+ relation: index === 0 ? "self" : "ancestor",
147
+ }))
148
+ : [{ nodeId, relation: "self" }];
149
+ return {
150
+ chain,
151
+ forkTree: {
152
+ nodeId,
153
+ parentCount: Math.max(0, lineage.length - 1),
154
+ childCount: 0,
155
+ children: [],
156
+ },
157
+ depth,
158
+ beliefId: response.data.beliefId,
159
+ lineage,
160
+ };
253
161
  }
254
- return matchesAuditNodeReference(entry, nodeId);
255
- });
256
- }
257
- function sdkQueryString(input) {
258
- const params = new URLSearchParams();
259
- for (const [key, value] of Object.entries(input)) {
260
- if (value === void 0 || value === null) {
261
- continue;
162
+ async function getConfidenceHistory(nodeId) {
163
+ return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
262
164
  }
263
- if (Array.isArray(value)) {
264
- if (value.length > 0) {
265
- params.set(key, value.join(","));
266
- }
267
- continue;
165
+ async function getOpinionHistory(nodeId) {
166
+ const response = await beliefsFacade.opinionHistory(nodeId);
167
+ return mapOpinionHistoryEntriesFromGatewayData(response.data);
268
168
  }
269
- params.set(key, String(value));
270
- }
271
- const serialized = params.toString();
272
- return serialized ? `?${serialized}` : "";
273
- }
274
- var CustomToolRegistryError = class extends Error {
275
- constructor(message) {
276
- super(message);
277
- this.name = "CustomToolRegistryError";
278
- }
279
- };
280
- var customToolRegistry = /* @__PURE__ */ new Map();
281
- function getRegisteredCustomTool(fullName) {
282
- return customToolRegistry.get(fullName.trim());
283
- }
284
- async function invokeRegisteredCustomTool(fullName, params, context) {
285
- const registered = getRegisteredCustomTool(fullName);
286
- if (!registered) {
287
- throw new CustomToolRegistryError(
288
- `Custom tool "${fullName}" is not registered.`
289
- );
290
- }
291
- return registered.invoke(params, context);
292
- }
293
-
294
- // src/clientLocalHelpers.ts
295
- function createClientLocalHelpers(ctx) {
296
- const {
297
- auditClient,
298
- beliefsFacade,
299
- customNamespaceCache,
300
- evidenceFacade,
301
- exposeGatewayData,
302
- graphClient,
303
- graphFacade,
304
- gateway,
305
- functionSurfaceClient,
306
- ontologyClient,
307
- ontologyLinksClient,
308
- searchFacade
309
- } = ctx;
310
- const invokeCustomTool = async (fullName, input = {}) => {
311
- const payload = normalizeCustomToolPayload(input);
312
- return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
313
- };
314
- const getCustomNamespace = (namespace) => {
315
- const normalized = normalizeCustomNamespace(namespace);
316
- const cached = customNamespaceCache.get(normalized);
317
- if (cached) {
318
- return cached;
169
+ async function getAuditTrail(nodeId, limit = 50) {
170
+ const events = await auditClient.listEvents({ limit });
171
+ const entries = asListItems(events.data, "events")
172
+ .filter((event) => matchesAuditNodeReference(event, nodeId))
173
+ .slice(0, limit)
174
+ .map((event) => {
175
+ const row = event;
176
+ return {
177
+ action: typeof row.action === "string" ? row.action : "unknown",
178
+ actor: typeof row.actor === "string" ? row.actor : "unknown",
179
+ timestamp: typeof row.timestamp === "number" ? row.timestamp : Date.now(),
180
+ rationale: typeof row.rationale === "string"
181
+ ? row.rationale
182
+ : "No rationale recorded.",
183
+ before: row.before ?? null,
184
+ after: row.after ?? null,
185
+ };
186
+ });
187
+ return { entries };
319
188
  }
320
- const proxy = new Proxy(
321
- {},
322
- {
323
- get(_target, property) {
324
- if (typeof property !== "string" || property === "then") {
325
- return;
326
- }
327
- return async (input = {}) => invokeCustomTool(`${normalized}.${property}`, input);
328
- }
329
- }
330
- );
331
- customNamespaceCache.set(normalized, proxy);
332
- return proxy;
333
- };
334
- const extensionNamespaces = new Proxy(
335
- {},
336
- {
337
- get(_target, namespace) {
338
- if (typeof namespace !== "string" || namespace === "then") {
339
- return;
340
- }
341
- return getCustomNamespace(namespace);
342
- }
189
+ async function bisectConfidence(nodeId, args) {
190
+ return beliefsFacade.bisect(nodeId, args).then(exposeGatewayData);
343
191
  }
344
- );
345
- const createEvidence = (args) => createEvidenceCompat(evidenceFacade, args);
346
- const addEvidence = (args) => addEvidenceCompat(evidenceFacade, args);
347
- async function listBeliefs(args) {
348
- const response = await beliefsFacade.list({
349
- topicId: requireTopicId(args),
350
- status: args.status,
351
- worktreeId: args.worktreeId,
352
- minConfidence: args.minConfidence,
353
- limit: args.limit,
354
- cursor: args.cursor
355
- });
356
- return Array.isArray(response.data.beliefs) ? response.data.beliefs : [];
357
- }
358
- async function searchBeliefs(args) {
359
- const topicId = resolveTopicId(args);
360
- if (!topicId) {
361
- return { results: [] };
192
+ async function discoverTopics(input = {}) {
193
+ return gateway
194
+ .request({
195
+ path: "/api/platform/v1/context/discover",
196
+ method: "POST",
197
+ body: input,
198
+ })
199
+ .then(exposeGatewayData);
362
200
  }
363
- const response = await searchFacade.query({
364
- q: args.query,
365
- topicId,
366
- types: ["belief"],
367
- status: args.status,
368
- minConfidence: args.minConfidence,
369
- limit: args.limit
370
- });
371
- const data = exposeGatewayData(response);
372
- const groupedBeliefs = Array.isArray(data.beliefs) ? data.beliefs : [];
373
- const mergedResults = Array.isArray(data.results) ? data.results : [];
374
- const results = groupedBeliefs.length > 0 ? groupedBeliefs : mergedResults.filter((result) => result.type === "belief");
375
- return { results };
376
- }
377
- async function searchResources(query, options = {}) {
378
- const topicId = resolveTopicId(options);
379
- if (!topicId) {
380
- throw new Error("topicId is required");
201
+ async function discoverEntityConnections(input = {}) {
202
+ return gateway
203
+ .request({
204
+ path: "/api/platform/v1/context/entity-connections",
205
+ method: "POST",
206
+ body: input,
207
+ })
208
+ .then(exposeGatewayData);
381
209
  }
382
- return searchFacade.query({
383
- q: query,
384
- topicId,
385
- types: options.types,
386
- status: options.status,
387
- minConfidence: options.minConfidence,
388
- limit: options.limit,
389
- cursor: options.cursor
390
- }).then(exposeGatewayData);
391
- }
392
- async function findContradictions(args) {
393
- const topicId = resolveTopicId(args);
394
- const response = topicId ? await graphClient.listNodes({
395
- topicId,
396
- nodeType: "contradiction",
397
- limit: 500
398
- }) : args.nodeId ? await graphClient.listNodes({ nodeId: args.nodeId }) : { data: [] };
399
- const contradictions = asNodeArray(response.data).filter((node) => {
400
- const status = typeof node.metadata?.status === "string" ? node.metadata.status : typeof node.status === "string" ? node.status : "unresolved";
401
- if (args.status && status !== args.status) {
402
- return false;
403
- }
404
- return true;
405
- }).map((node) => ({
406
- beliefA: typeof node.metadata?.beliefA === "string" ? node.metadata.beliefA : "",
407
- beliefB: typeof node.metadata?.beliefB === "string" ? node.metadata.beliefB : "",
408
- description: node.canonicalText ?? "",
409
- severity: typeof node.metadata?.severity === "string" ? node.metadata.severity : "medium",
410
- status: typeof node.metadata?.status === "string" ? node.metadata.status : "unresolved",
411
- defeatType: typeof node.metadata?.defeatType === "string" ? node.metadata.defeatType : "rebuts"
412
- }));
413
- return { contradictions };
414
- }
415
- async function queryLineage(nodeId, depth = 5) {
416
- const response = await beliefsFacade.lineage(nodeId);
417
- const lineage = Array.isArray(response.data.lineage) ? response.data.lineage : [];
418
- const chain = lineage.length > 0 ? lineage.slice(0, depth + 1).map((entry, index) => ({
419
- nodeId: entry.nodeId ?? entry.beliefId ?? "",
420
- relation: index === 0 ? "self" : "ancestor"
421
- })) : [{ nodeId, relation: "self" }];
422
- return {
423
- chain,
424
- forkTree: {
425
- nodeId,
426
- parentCount: Math.max(0, lineage.length - 1),
427
- childCount: 0,
428
- children: []
429
- },
430
- depth,
431
- beliefId: response.data.beliefId,
432
- lineage
433
- };
434
- }
435
- async function getConfidenceHistory(nodeId) {
436
- return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
437
- }
438
- async function getOpinionHistory(nodeId) {
439
- const response = await beliefsFacade.opinionHistory(nodeId);
440
- return mapOpinionHistoryEntriesFromGatewayData(response.data);
441
- }
442
- async function getAuditTrail(nodeId, limit = 50) {
443
- const events = await auditClient.listEvents({ limit });
444
- const entries = asListItems(events.data, "events").filter((event) => matchesAuditNodeReference(event, nodeId)).slice(0, limit).map((event) => {
445
- const row = event;
446
- return {
447
- action: typeof row.action === "string" ? row.action : "unknown",
448
- actor: typeof row.actor === "string" ? row.actor : "unknown",
449
- timestamp: typeof row.timestamp === "number" ? row.timestamp : Date.now(),
450
- rationale: typeof row.rationale === "string" ? row.rationale : "No rationale recorded.",
451
- before: row.before ?? null,
452
- after: row.after ?? null
453
- };
454
- });
455
- return { entries };
456
- }
457
- async function bisectConfidence(nodeId, args) {
458
- return beliefsFacade.bisect(nodeId, args).then(exposeGatewayData);
459
- }
460
- async function discoverTopics(input = {}) {
461
- return gateway.request({
462
- path: "/api/platform/v1/context/discover",
463
- method: "POST",
464
- body: input
465
- }).then(exposeGatewayData);
466
- }
467
- async function discoverEntityConnections(input = {}) {
468
- return gateway.request({
469
- path: "/api/platform/v1/context/entity-connections",
470
- method: "POST",
471
- body: input
472
- }).then(exposeGatewayData);
473
- }
474
- async function triggerBeliefReview(input = {}) {
475
- return gateway.request({
476
- path: "/api/platform/v1/context/belief-review",
477
- method: "POST",
478
- body: input,
479
- idempotencyKey: randomIdempotencyKey()
480
- }).then(exposeGatewayData);
481
- }
482
- async function createContractCompat(input = {}) {
483
- return gateway.request({
484
- path: "/api/platform/v1/contracts",
485
- method: "POST",
486
- body: input,
487
- idempotencyKey: randomIdempotencyKey()
488
- }).then(exposeGatewayData);
489
- }
490
- async function evaluateContractCompat(input = {}) {
491
- return gateway.request({
492
- path: "/api/platform/v1/contracts/evaluate",
493
- method: "POST",
494
- body: input,
495
- idempotencyKey: randomIdempotencyKey()
496
- }).then(exposeGatewayData);
497
- }
498
- async function getContractStatusCompat(input = {}) {
499
- return gateway.request({
500
- path: "/api/platform/v1/contracts/status",
501
- method: "POST",
502
- body: input
503
- }).then(exposeGatewayData);
504
- }
505
- async function listContractsCompat(input = {}) {
506
- return gateway.request({
507
- path: `/api/platform/v1/contracts${toQueryString({
508
- beliefNodeId: typeof input.beliefNodeId === "string" ? input.beliefNodeId : void 0,
509
- contractId: typeof input.contractId === "string" ? input.contractId : void 0,
510
- status: typeof input.status === "string" ? input.status : void 0
511
- })}`
512
- }).then(exposeGatewayData);
513
- }
514
- async function createOntologyCompat(input = {}) {
515
- const response = await ontologyClient.createDefinition(
516
- input
517
- );
518
- const envelope = response;
519
- return Object.assign({}, envelope, envelope.data);
520
- }
521
- async function updateOntologyCompat(input = {}) {
522
- const id = typeof input.id === "string" ? input.id : "";
523
- const { id: _id, ...rest } = input;
524
- const response = await ontologyClient.updateDefinition(
525
- id,
526
- rest
527
- );
528
- const envelope = response;
529
- return Object.assign({}, envelope, envelope.data);
530
- }
531
- async function archiveOntologyCompat(input = {}) {
532
- const id = typeof input.id === "string" ? input.id : "";
533
- const response = await ontologyClient.archiveDefinition(id);
534
- const envelope = response;
535
- return Object.assign({}, envelope, envelope.data);
536
- }
537
- async function createOntologyVersionCompat(input = {}) {
538
- const ontologyId = typeof input.ontologyId === "string" ? input.ontologyId : "";
539
- const { ontologyId: _ontologyId, ...rest } = input;
540
- const response = await ontologyClient.createVersion(
541
- ontologyId,
542
- rest
543
- );
544
- const envelope = response;
545
- return Object.assign({}, envelope, envelope.data);
546
- }
547
- async function publishOntologyVersionCompat(input = {}) {
548
- return gateway.request({
549
- path: "/api/platform/v1/ontologies/versions/publish",
550
- method: "POST",
551
- body: input,
552
- idempotencyKey: randomIdempotencyKey()
553
- }).then(exposeGatewayData);
554
- }
555
- async function deprecateOntologyVersionCompat(input = {}) {
556
- return gateway.request({
557
- path: "/api/platform/v1/ontologies/versions/deprecate",
558
- method: "POST",
559
- body: input,
560
- idempotencyKey: randomIdempotencyKey()
561
- }).then(exposeGatewayData);
562
- }
563
- async function resolveEffectiveOntologyCompat(input = {}) {
564
- return gateway.request({
565
- path: "/api/platform/v1/ontologies/effective",
566
- method: "POST",
567
- body: input
568
- }).then(exposeGatewayData);
569
- }
570
- async function traceEntityImpactCompat(input = {}) {
571
- return gateway.request({
572
- path: "/api/platform/v1/graph/trace-entity-impact",
573
- method: "POST",
574
- body: input
575
- }).then(exposeGatewayData);
576
- }
577
- const nodesNamespace = {
578
- list: graphClient.listNodes,
579
- get(input) {
580
- return graphClient.getNode(
581
- typeof input === "string" ? { nodeId: input } : input
582
- );
583
- },
584
- create(input, idempotencyKey) {
585
- return functionSurfaceClient.createEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
586
- },
587
- createEpistemicNode(input, idempotencyKey) {
588
- return functionSurfaceClient.createEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
589
- },
590
- update(input, idempotencyKey) {
591
- return functionSurfaceClient.updateEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
592
- },
593
- updateEpistemicNode(input, idempotencyKey) {
594
- return functionSurfaceClient.updateEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
595
- },
596
- batchCreate(input, idempotencyKey) {
597
- return functionSurfaceClient.batchCreateEpistemicNodes(input, idempotencyKey).then(exposeGatewayData);
598
- },
599
- batchCreateEpistemicNodes(input, idempotencyKey) {
600
- return functionSurfaceClient.batchCreateEpistemicNodes(input, idempotencyKey).then(exposeGatewayData);
601
- },
602
- listByTopicAndType(input) {
603
- return gateway.request({
604
- path: `/api/platform/v1/nodes${sdkQueryString({
605
- topicId: requireTopicOrProjectId(input),
606
- nodeType: input.nodeType,
607
- nodeTypes: input.nodeTypes,
608
- query: input.query,
609
- sourceText: input.sourceText,
610
- limit: input.limit,
611
- cursor: input.cursor
612
- })}`
613
- }).then(exposeGatewayData);
614
- },
615
- countByTopicAndType(input) {
616
- return gateway.request({
617
- path: `/api/platform/v1/nodes/count${sdkQueryString({
618
- topicId: requireTopicOrProjectId(input),
619
- nodeType: input.nodeType,
620
- nodeTypes: input.nodeTypes,
621
- query: input.query,
622
- limit: input.limit
623
- })}`
624
- }).then(exposeGatewayData);
625
- },
626
- supersede(input, idempotencyKey) {
627
- return functionSurfaceClient.supersedeEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
628
- },
629
- verify(input, idempotencyKey) {
630
- return functionSurfaceClient.verifyEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
631
- },
632
- archive(input, idempotencyKey) {
633
- return functionSurfaceClient.archiveEpistemicNode(input, idempotencyKey).then(exposeGatewayData);
634
- },
635
- hardDelete: graphClient.hardDeleteNode
636
- };
637
- const publicationNamespace = {
638
- create(input, idempotencyKey) {
639
- return gateway.request({
640
- path: "/api/platform/v1/publication",
641
- method: "POST",
642
- body: input,
643
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
644
- }).then(exposeGatewayData);
645
- },
646
- update(publicationId, input, idempotencyKey) {
647
- return gateway.request({
648
- path: `/api/platform/v1/publication/${encodeURIComponent(
649
- publicationId
650
- )}`,
651
- method: "PATCH",
652
- body: input,
653
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
654
- }).then(exposeGatewayData);
655
- },
656
- list(input = {}) {
657
- return gateway.request({
658
- path: `/api/platform/v1/publication${sdkQueryString(input)}`
659
- }).then(exposeGatewayData);
660
- },
661
- getByTopic(input) {
662
- const topicId = typeof input === "string" ? input : input.topicId;
663
- const workspaceId = typeof input === "string" ? void 0 : input.workspaceId;
664
- return gateway.request({
665
- path: `/api/platform/v1/publication/by-topic/${encodeURIComponent(
666
- topicId
667
- )}${sdkQueryString({ workspaceId })}`
668
- }).then(exposeGatewayData);
669
- },
670
- publish(publicationId, input = {}, idempotencyKey) {
671
- return gateway.request({
672
- path: `/api/platform/v1/publication/${encodeURIComponent(
673
- publicationId
674
- )}/publish`,
675
- method: "POST",
676
- body: input,
677
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
678
- }).then(exposeGatewayData);
679
- },
680
- unpublish(publicationId, input = {}, idempotencyKey) {
681
- return gateway.request({
682
- path: `/api/platform/v1/publication/${encodeURIComponent(
683
- publicationId
684
- )}/unpublish`,
685
- method: "POST",
686
- body: input,
687
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
688
- }).then(exposeGatewayData);
689
- },
690
- remove(publicationId, input = {}) {
691
- return gateway.request({
692
- path: `/api/platform/v1/publication/${encodeURIComponent(
693
- publicationId
694
- )}${sdkQueryString(input)}`,
695
- method: "DELETE"
696
- }).then(exposeGatewayData);
210
+ async function triggerBeliefReview(input = {}) {
211
+ return gateway
212
+ .request({
213
+ path: "/api/platform/v1/context/belief-review",
214
+ method: "POST",
215
+ body: input,
216
+ idempotencyKey: randomIdempotencyKey(),
217
+ })
218
+ .then(exposeGatewayData);
219
+ }
220
+ async function createContractCompat(input = {}) {
221
+ return gateway
222
+ .request({
223
+ path: "/api/platform/v1/contracts",
224
+ method: "POST",
225
+ body: input,
226
+ idempotencyKey: randomIdempotencyKey(),
227
+ })
228
+ .then(exposeGatewayData);
229
+ }
230
+ async function evaluateContractCompat(input = {}) {
231
+ return gateway
232
+ .request({
233
+ path: "/api/platform/v1/contracts/evaluate",
234
+ method: "POST",
235
+ body: input,
236
+ idempotencyKey: randomIdempotencyKey(),
237
+ })
238
+ .then(exposeGatewayData);
697
239
  }
698
- };
699
- const ontologyLinksNamespace = {
700
- ...ontologyLinksClient,
701
- resolveThemeSource(input) {
702
- return gateway.request({
703
- path: "/api/platform/v1/ontology-links/theme-source",
704
- method: "POST",
705
- body: input
706
- }).then(exposeGatewayData);
240
+ async function getContractStatusCompat(input = {}) {
241
+ return gateway
242
+ .request({
243
+ path: "/api/platform/v1/contracts/status",
244
+ method: "POST",
245
+ body: input,
246
+ })
247
+ .then(exposeGatewayData);
707
248
  }
708
- };
709
- return {
710
- addEvidence,
711
- archiveOntologyCompat,
712
- bisectConfidence,
713
- createContractCompat,
714
- createEvidence,
715
- createOntologyCompat,
716
- createOntologyVersionCompat,
717
- deprecateOntologyVersionCompat,
718
- discoverEntityConnections,
719
- discoverTopics,
720
- evaluateContractCompat,
721
- extensionNamespaces,
722
- findContradictions,
723
- getAuditTrail,
724
- getConfidenceHistory,
725
- getContractStatusCompat,
726
- getCustomNamespace,
727
- getOpinionHistory,
728
- invokeCustomTool,
729
- listBeliefs,
730
- listContractsCompat,
731
- nodesNamespace,
732
- ontologyLinksNamespace,
733
- publicationNamespace,
734
- publishOntologyVersionCompat,
735
- queryLineage,
736
- resolveEffectiveOntologyCompat,
737
- searchBeliefs,
738
- searchResources,
739
- traceEntityImpactCompat,
740
- triggerBeliefReview,
741
- updateOntologyCompat
742
- };
249
+ async function listContractsCompat(input = {}) {
250
+ return gateway
251
+ .request({
252
+ path: `/api/platform/v1/contracts${toQueryString({
253
+ beliefNodeId: typeof input.beliefNodeId === "string"
254
+ ? input.beliefNodeId
255
+ : undefined,
256
+ contractId: typeof input.contractId === "string" ? input.contractId : undefined,
257
+ status: typeof input.status === "string" ? input.status : undefined,
258
+ })}`,
259
+ })
260
+ .then(exposeGatewayData);
261
+ }
262
+ async function createOntologyCompat(input = {}) {
263
+ const response = await ontologyClient.createDefinition(input);
264
+ const envelope = response;
265
+ return Object.assign({}, envelope, envelope.data);
266
+ }
267
+ async function updateOntologyCompat(input = {}) {
268
+ const id = typeof input.id === "string" ? input.id : "";
269
+ const { id: _id, ...rest } = input;
270
+ const response = await ontologyClient.updateDefinition(id, rest);
271
+ const envelope = response;
272
+ return Object.assign({}, envelope, envelope.data);
273
+ }
274
+ async function archiveOntologyCompat(input = {}) {
275
+ const id = typeof input.id === "string" ? input.id : "";
276
+ const response = await ontologyClient.archiveDefinition(id);
277
+ const envelope = response;
278
+ return Object.assign({}, envelope, envelope.data);
279
+ }
280
+ async function createOntologyVersionCompat(input = {}) {
281
+ const ontologyId = typeof input.ontologyId === "string" ? input.ontologyId : "";
282
+ const { ontologyId: _ontologyId, ...rest } = input;
283
+ const response = await ontologyClient.createVersion(ontologyId, rest);
284
+ const envelope = response;
285
+ return Object.assign({}, envelope, envelope.data);
286
+ }
287
+ async function publishOntologyVersionCompat(input = {}) {
288
+ return gateway
289
+ .request({
290
+ path: "/api/platform/v1/ontologies/versions/publish",
291
+ method: "POST",
292
+ body: input,
293
+ idempotencyKey: randomIdempotencyKey(),
294
+ })
295
+ .then(exposeGatewayData);
296
+ }
297
+ async function deprecateOntologyVersionCompat(input = {}) {
298
+ return gateway
299
+ .request({
300
+ path: "/api/platform/v1/ontologies/versions/deprecate",
301
+ method: "POST",
302
+ body: input,
303
+ idempotencyKey: randomIdempotencyKey(),
304
+ })
305
+ .then(exposeGatewayData);
306
+ }
307
+ async function resolveEffectiveOntologyCompat(input = {}) {
308
+ return gateway
309
+ .request({
310
+ path: "/api/platform/v1/ontologies/effective",
311
+ method: "POST",
312
+ body: input,
313
+ })
314
+ .then(exposeGatewayData);
315
+ }
316
+ async function traceEntityImpactCompat(input = {}) {
317
+ return gateway
318
+ .request({
319
+ path: "/api/platform/v1/graph/trace-entity-impact",
320
+ method: "POST",
321
+ body: input,
322
+ })
323
+ .then(exposeGatewayData);
324
+ }
325
+ const nodesNamespace = {
326
+ list: graphClient.listNodes,
327
+ get(input) {
328
+ return graphClient.getNode(typeof input === "string" ? { nodeId: input } : input);
329
+ },
330
+ create(input, idempotencyKey) {
331
+ return functionSurfaceClient
332
+ .createEpistemicNode(input, idempotencyKey)
333
+ .then(exposeGatewayData);
334
+ },
335
+ createEpistemicNode(input, idempotencyKey) {
336
+ return functionSurfaceClient
337
+ .createEpistemicNode(input, idempotencyKey)
338
+ .then(exposeGatewayData);
339
+ },
340
+ update(input, idempotencyKey) {
341
+ return functionSurfaceClient
342
+ .updateEpistemicNode(input, idempotencyKey)
343
+ .then(exposeGatewayData);
344
+ },
345
+ updateEpistemicNode(input, idempotencyKey) {
346
+ return functionSurfaceClient
347
+ .updateEpistemicNode(input, idempotencyKey)
348
+ .then(exposeGatewayData);
349
+ },
350
+ batchCreate(input, idempotencyKey) {
351
+ return functionSurfaceClient
352
+ .batchCreateEpistemicNodes(input, idempotencyKey)
353
+ .then(exposeGatewayData);
354
+ },
355
+ batchCreateEpistemicNodes(input, idempotencyKey) {
356
+ return functionSurfaceClient
357
+ .batchCreateEpistemicNodes(input, idempotencyKey)
358
+ .then(exposeGatewayData);
359
+ },
360
+ listByTopicAndType(input) {
361
+ return gateway
362
+ .request({
363
+ path: `/api/platform/v1/nodes${sdkQueryString({
364
+ topicId: requireTopicOrProjectId(input),
365
+ nodeType: input.nodeType,
366
+ nodeTypes: input.nodeTypes,
367
+ query: input.query,
368
+ sourceText: input.sourceText,
369
+ limit: input.limit,
370
+ cursor: input.cursor,
371
+ })}`,
372
+ })
373
+ .then(exposeGatewayData);
374
+ },
375
+ countByTopicAndType(input) {
376
+ return gateway
377
+ .request({
378
+ path: `/api/platform/v1/nodes/count${sdkQueryString({
379
+ topicId: requireTopicOrProjectId(input),
380
+ nodeType: input.nodeType,
381
+ nodeTypes: input.nodeTypes,
382
+ query: input.query,
383
+ limit: input.limit,
384
+ })}`,
385
+ })
386
+ .then(exposeGatewayData);
387
+ },
388
+ supersede(input, idempotencyKey) {
389
+ return functionSurfaceClient
390
+ .supersedeEpistemicNode(input, idempotencyKey)
391
+ .then(exposeGatewayData);
392
+ },
393
+ verify(input, idempotencyKey) {
394
+ return functionSurfaceClient
395
+ .verifyEpistemicNode(input, idempotencyKey)
396
+ .then(exposeGatewayData);
397
+ },
398
+ archive(input, idempotencyKey) {
399
+ return functionSurfaceClient
400
+ .archiveEpistemicNode(input, idempotencyKey)
401
+ .then(exposeGatewayData);
402
+ },
403
+ hardDelete: graphClient.hardDeleteNode,
404
+ };
405
+ const publicationNamespace = {
406
+ create(input, idempotencyKey) {
407
+ return gateway
408
+ .request({
409
+ path: "/api/platform/v1/publication",
410
+ method: "POST",
411
+ body: input,
412
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
413
+ })
414
+ .then(exposeGatewayData);
415
+ },
416
+ update(publicationId, input, idempotencyKey) {
417
+ return gateway
418
+ .request({
419
+ path: `/api/platform/v1/publication/${encodeURIComponent(publicationId)}`,
420
+ method: "PATCH",
421
+ body: input,
422
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
423
+ })
424
+ .then(exposeGatewayData);
425
+ },
426
+ list(input = {}) {
427
+ return gateway
428
+ .request({
429
+ path: `/api/platform/v1/publication${sdkQueryString(input)}`,
430
+ })
431
+ .then(exposeGatewayData);
432
+ },
433
+ getByTopic(input) {
434
+ const topicId = typeof input === "string" ? input : input.topicId;
435
+ const workspaceId = typeof input === "string" ? undefined : input.workspaceId;
436
+ return gateway
437
+ .request({
438
+ path: `/api/platform/v1/publication/by-topic/${encodeURIComponent(topicId)}${sdkQueryString({ workspaceId })}`,
439
+ })
440
+ .then(exposeGatewayData);
441
+ },
442
+ publish(publicationId, input = {}, idempotencyKey) {
443
+ return gateway
444
+ .request({
445
+ path: `/api/platform/v1/publication/${encodeURIComponent(publicationId)}/publish`,
446
+ method: "POST",
447
+ body: input,
448
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
449
+ })
450
+ .then(exposeGatewayData);
451
+ },
452
+ unpublish(publicationId, input = {}, idempotencyKey) {
453
+ return gateway
454
+ .request({
455
+ path: `/api/platform/v1/publication/${encodeURIComponent(publicationId)}/unpublish`,
456
+ method: "POST",
457
+ body: input,
458
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
459
+ })
460
+ .then(exposeGatewayData);
461
+ },
462
+ remove(publicationId, input = {}) {
463
+ return gateway
464
+ .request({
465
+ path: `/api/platform/v1/publication/${encodeURIComponent(publicationId)}${sdkQueryString(input)}`,
466
+ method: "DELETE",
467
+ })
468
+ .then(exposeGatewayData);
469
+ },
470
+ };
471
+ const ontologyLinksNamespace = {
472
+ ...ontologyLinksClient,
473
+ resolveThemeSource(input) {
474
+ return gateway
475
+ .request({
476
+ path: "/api/platform/v1/ontology-links/theme-source",
477
+ method: "POST",
478
+ body: input,
479
+ })
480
+ .then(exposeGatewayData);
481
+ },
482
+ };
483
+ return {
484
+ addEvidence,
485
+ archiveOntologyCompat,
486
+ bisectConfidence,
487
+ createContractCompat,
488
+ createEvidence,
489
+ createOntologyCompat,
490
+ createOntologyVersionCompat,
491
+ deprecateOntologyVersionCompat,
492
+ discoverEntityConnections,
493
+ discoverTopics,
494
+ evaluateContractCompat,
495
+ extensionNamespaces,
496
+ findContradictions,
497
+ getAuditTrail,
498
+ getConfidenceHistory,
499
+ getContractStatusCompat,
500
+ getCustomNamespace,
501
+ getOpinionHistory,
502
+ invokeCustomTool,
503
+ listBeliefs,
504
+ listContractsCompat,
505
+ nodesNamespace,
506
+ ontologyLinksNamespace,
507
+ publicationNamespace,
508
+ publishOntologyVersionCompat,
509
+ queryLineage,
510
+ resolveEffectiveOntologyCompat,
511
+ searchBeliefs,
512
+ searchResources,
513
+ traceEntityImpactCompat,
514
+ triggerBeliefReview,
515
+ updateOntologyCompat,
516
+ };
743
517
  }
744
-
745
- export { createClientLocalHelpers };
746
- //# sourceMappingURL=clientLocalHelpers.js.map
747
518
  //# sourceMappingURL=clientLocalHelpers.js.map