@lucern/sdk 0.2.0-alpha.5 → 0.2.0-alpha.7

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 (166) hide show
  1. package/.turbo/turbo-build.log +7 -0
  2. package/.turbo/turbo-typecheck.log +4 -0
  3. package/CHANGELOG.md +13 -0
  4. package/examples/README.md +69 -0
  5. package/examples/contradiction.ts +94 -0
  6. package/examples/investigation-context.ts +118 -0
  7. package/examples/questions-and-tasks.ts +55 -0
  8. package/examples/quickstart.ts +97 -0
  9. package/examples/shared.ts +318 -0
  10. package/examples/strict-public-types.ts +143 -0
  11. package/examples/worktree-lifecycle.ts +79 -0
  12. package/package.json +16 -59
  13. package/src/README.md +6 -0
  14. package/src/adminClient.ts +789 -0
  15. package/{dist/lib/platform/sdk/answersClient.d.ts → src/answersClient.ts} +17 -4
  16. package/src/audiencesClient.ts +209 -0
  17. package/src/auditClient.ts +50 -0
  18. package/src/beliefsClient.ts +319 -0
  19. package/src/client.ts +2647 -0
  20. package/src/contextClient.ts +130 -0
  21. package/src/contextFacade.ts +15 -0
  22. package/src/contextPackCompiler.ts +828 -0
  23. package/src/contextPackSchema.ts +251 -0
  24. package/src/contextTypes.ts +153 -0
  25. package/src/contracts/api-enums.contract.ts +202 -0
  26. package/src/contracts/auth-session.contract.ts +109 -0
  27. package/src/contracts/context-pack.contract.ts +700 -0
  28. package/src/contracts/contextPack.ts +1 -0
  29. package/src/contracts/index.ts +10 -0
  30. package/src/contracts/lens-filter.contract.ts +183 -0
  31. package/src/contracts/lens-workflow.contract.ts +162 -0
  32. package/src/contracts/lensFilter.ts +1 -0
  33. package/src/contracts/lensWorkflow.ts +1 -0
  34. package/src/contracts/mcp-tools.contract.ts +3636 -0
  35. package/src/contracts/mcpTools.ts +1 -0
  36. package/src/contracts/prompt.contract.ts +50 -0
  37. package/src/contracts/prompt.ts +1 -0
  38. package/src/contracts/sdk-tools.contract.ts +1457 -0
  39. package/src/contracts/sdkTools.ts +1 -0
  40. package/src/contracts/workflow-runtime.contract.ts +440 -0
  41. package/src/contracts/workflowRuntime.ts +1 -0
  42. package/src/controlObjectOwnership.ts +286 -0
  43. package/src/coreClient.ts +570 -0
  44. package/src/customTools.ts +398 -0
  45. package/src/decisionsClient.ts +286 -0
  46. package/src/domainContext.ts +15 -0
  47. package/src/events.ts +531 -0
  48. package/src/eventsCore.ts +168 -0
  49. package/src/facade/beliefs.ts +83 -0
  50. package/src/facade/context.ts +110 -0
  51. package/src/facade/contradictions.ts +29 -0
  52. package/src/facade/edges.ts +30 -0
  53. package/src/facade/events.ts +23 -0
  54. package/src/facade/evidence.ts +41 -0
  55. package/src/facade/graph.ts +38 -0
  56. package/src/facade/identity.ts +16 -0
  57. package/src/facade/ontologies.ts +34 -0
  58. package/src/facade/questions.ts +59 -0
  59. package/src/facade/search.ts +16 -0
  60. package/src/facade/tasks.ts +37 -0
  61. package/src/facade/topics.ts +42 -0
  62. package/src/facade/webhooks.ts +58 -0
  63. package/src/facade/worktrees.ts +51 -0
  64. package/src/gatewayFacades.ts +1666 -0
  65. package/src/graphClient.ts +529 -0
  66. package/src/harnessClient.ts +585 -0
  67. package/src/identityClient.ts +278 -0
  68. package/{dist/lib/platform/sdk/index.d.ts → src/index.ts} +3 -0
  69. package/src/learningClient.ts +95 -0
  70. package/src/mcpParityClient.ts +240 -0
  71. package/src/mcpParitySurface.ts +70 -0
  72. package/src/ontologyClient.ts +275 -0
  73. package/src/packRuntime.ts +3 -0
  74. package/src/packsClient.ts +260 -0
  75. package/src/policyClient.ts +572 -0
  76. package/src/promptCatalog.ts +1 -0
  77. package/src/realtime/index.ts +51 -0
  78. package/src/realtime/refs.ts +17 -0
  79. package/src/reportsClient.ts +99 -0
  80. package/src/schemaClient.ts +129 -0
  81. package/src/sdkSurface.ts +190 -0
  82. package/src/topicsClient.ts +243 -0
  83. package/src/types.ts +807 -0
  84. package/src/workflowClient.ts +826 -0
  85. package/tsconfig.json +9 -0
  86. package/dist/.generated +0 -2
  87. package/dist/index.d.ts +0 -3
  88. package/dist/index.js +0 -3
  89. package/dist/lib/platform/auth/credentials.d.ts +0 -5
  90. package/dist/lib/platform/auth/credentials.js +0 -40
  91. package/dist/lib/platform/sdk/adminClient.d.ts +0 -404
  92. package/dist/lib/platform/sdk/adminClient.js +0 -384
  93. package/dist/lib/platform/sdk/answersClient.js +0 -21
  94. package/dist/lib/platform/sdk/audiencesClient.d.ts +0 -93
  95. package/dist/lib/platform/sdk/audiencesClient.js +0 -111
  96. package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
  97. package/dist/lib/platform/sdk/auditClient.js +0 -21
  98. package/dist/lib/platform/sdk/beliefsClient.d.ts +0 -157
  99. package/dist/lib/platform/sdk/beliefsClient.js +0 -124
  100. package/dist/lib/platform/sdk/client.d.ts +0 -2369
  101. package/dist/lib/platform/sdk/client.js +0 -1831
  102. package/dist/lib/platform/sdk/contextClient.d.ts +0 -21
  103. package/dist/lib/platform/sdk/contextClient.js +0 -86
  104. package/dist/lib/platform/sdk/contextPackCompiler.d.ts +0 -100
  105. package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
  106. package/dist/lib/platform/sdk/contextTypes.d.ts +0 -133
  107. package/dist/lib/platform/sdk/contextTypes.js +0 -1
  108. package/dist/lib/platform/sdk/controlObjectOwnership.d.ts +0 -308
  109. package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
  110. package/dist/lib/platform/sdk/coreClient.d.ts +0 -139
  111. package/dist/lib/platform/sdk/coreClient.js +0 -366
  112. package/dist/lib/platform/sdk/customTools.d.ts +0 -83
  113. package/dist/lib/platform/sdk/customTools.js +0 -247
  114. package/dist/lib/platform/sdk/decisionsClient.d.ts +0 -106
  115. package/dist/lib/platform/sdk/decisionsClient.js +0 -129
  116. package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
  117. package/dist/lib/platform/sdk/domainContext.js +0 -1
  118. package/dist/lib/platform/sdk/events.d.ts +0 -176
  119. package/dist/lib/platform/sdk/events.js +0 -261
  120. package/dist/lib/platform/sdk/gatewayFacades.d.ts +0 -586
  121. package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
  122. package/dist/lib/platform/sdk/graphClient.d.ts +0 -266
  123. package/dist/lib/platform/sdk/graphClient.js +0 -235
  124. package/dist/lib/platform/sdk/harnessClient.d.ts +0 -309
  125. package/dist/lib/platform/sdk/harnessClient.js +0 -219
  126. package/dist/lib/platform/sdk/identityClient.d.ts +0 -134
  127. package/dist/lib/platform/sdk/identityClient.js +0 -131
  128. package/dist/lib/platform/sdk/index.js +0 -46
  129. package/dist/lib/platform/sdk/learningClient.d.ts +0 -40
  130. package/dist/lib/platform/sdk/learningClient.js +0 -53
  131. package/dist/lib/platform/sdk/mcpParityClient.d.ts +0 -69
  132. package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
  133. package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
  134. package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
  135. package/dist/lib/platform/sdk/ontologyClient.d.ts +0 -131
  136. package/dist/lib/platform/sdk/ontologyClient.js +0 -161
  137. package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
  138. package/dist/lib/platform/sdk/packRuntime.js +0 -1
  139. package/dist/lib/platform/sdk/packsClient.d.ts +0 -126
  140. package/dist/lib/platform/sdk/packsClient.js +0 -157
  141. package/dist/lib/platform/sdk/policyClient.d.ts +0 -293
  142. package/dist/lib/platform/sdk/policyClient.js +0 -277
  143. package/dist/lib/platform/sdk/promptCatalog.d.ts +0 -1
  144. package/dist/lib/platform/sdk/promptCatalog.js +0 -1
  145. package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
  146. package/dist/lib/platform/sdk/reportsClient.js +0 -64
  147. package/dist/lib/platform/sdk/schemaClient.d.ts +0 -59
  148. package/dist/lib/platform/sdk/schemaClient.js +0 -71
  149. package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
  150. package/dist/lib/platform/sdk/sdkSurface.js +0 -140
  151. package/dist/lib/platform/sdk/topicsClient.d.ts +0 -78
  152. package/dist/lib/platform/sdk/topicsClient.js +0 -118
  153. package/dist/lib/platform/sdk/types.d.ts +0 -692
  154. package/dist/lib/platform/sdk/types.js +0 -1
  155. package/dist/lib/platform/sdk/version.d.ts +0 -2
  156. package/dist/lib/platform/sdk/workflowClient.d.ts +0 -313
  157. package/dist/lib/platform/sdk/workflowClient.js +0 -366
  158. package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
  159. package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
  160. package/dist/lucern/contracts/src/lens-filter.contract.d.ts +0 -70
  161. package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
  162. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
  163. package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
  164. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
  165. package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
  166. /package/{dist/lib/platform/sdk/version.js → src/version.ts} +0 -0
@@ -1,1831 +0,0 @@
1
- import { createAdminClient } from "./adminClient.js";
2
- import { createAnswersClient, } from "./answersClient.js";
3
- import { createAudiencesClient, } from "./audiencesClient.js";
4
- import { createAuditClient } from "./auditClient.js";
5
- import { createBeliefsClient, } from "./beliefsClient.js";
6
- import { createGatewayRequestClient, LucernApiError, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
7
- import { clearRegisteredCustomTools, invokeRegisteredCustomTool, listRegisteredCustomTools, registerCustomTool, unregisterCustomTool, } from "./customTools.js";
8
- import { createBeliefsFacade, createContradictionsFacade, createEdgesFacade, createEvidenceFacade, createEventsFacade, createGraphFacade, createIdentityFacade, createOntologiesFacade, createQuestionsFacade, createSearchFacade, createTasksFacade, createTopicsFacade, createWebhooksFacade, createWorktreesFacade, } from "./gatewayFacades.js";
9
- import { createDecisionsClient, } from "./decisionsClient.js";
10
- import { createContextClient, } from "./contextClient.js";
11
- import { createGraphClient } from "./graphClient.js";
12
- import { createHarnessClient } from "./harnessClient.js";
13
- import { createIdentityClient, } from "./identityClient.js";
14
- import { createLearningClient, } from "./learningClient.js";
15
- import { createMcpParityClient, } from "./mcpParityClient.js";
16
- import { createOntologyClient, } from "./ontologyClient.js";
17
- import { createPacksClient } from "./packsClient.js";
18
- import { createPolicyClient } from "./policyClient.js";
19
- import { createReportsClient } from "./reportsClient.js";
20
- import { createSchemaClient } from "./schemaClient.js";
21
- import { asListItems, resolveText, resolveTopicId } from "./sdkSurface.js";
22
- import { createTopicsClient } from "./topicsClient.js";
23
- import { LUCERN_SDK_VERSION } from "./version.js";
24
- import { createWorkflowClient, } from "./workflowClient.js";
25
- function asNodeArray(data) {
26
- const rows = asListItems(data, "nodes");
27
- if (rows.length > 0) {
28
- return rows.filter((value) => Boolean(value) && typeof value === "object");
29
- }
30
- if (data && typeof data === "object") {
31
- return [data];
32
- }
33
- return [];
34
- }
35
- function asEdgeArray(data) {
36
- const rows = asListItems(data, "edges");
37
- if (rows.length > 0) {
38
- return rows.filter((value) => Boolean(value) && typeof value === "object");
39
- }
40
- if (data && typeof data === "object") {
41
- return [data];
42
- }
43
- return [];
44
- }
45
- function normalizeBeliefStatus(status) {
46
- if (!status) {
47
- return "unscored";
48
- }
49
- if (status === "unscored" || status === "scored" || status === "archived") {
50
- return status;
51
- }
52
- if (status === "active" || status === "in_evaluation") {
53
- return "unscored";
54
- }
55
- if (status === "challenged" || status === "validated") {
56
- return "scored";
57
- }
58
- return "unscored";
59
- }
60
- function confidenceFromNode(node) {
61
- if (typeof node.confidence === "number") {
62
- return node.confidence;
63
- }
64
- if (typeof node.metadata?.confidence === "number") {
65
- return node.metadata.confidence;
66
- }
67
- return 0;
68
- }
69
- function toGatewayConfig(config) {
70
- return {
71
- baseUrl: config.baseUrl,
72
- fetchImpl: config.fetchImpl,
73
- maxRetries: config.maxRetries,
74
- timeoutMs: config.timeoutMs,
75
- timeoutMsByMethod: config.timeoutMsByMethod,
76
- requestIdFactory: config.requestIdFactory,
77
- onRequest: config.onRequest,
78
- onResponse: config.onResponse,
79
- getAuthHeaders: async () => {
80
- const base = (config.getAuthHeaders ? await config.getAuthHeaders() : {});
81
- if (config.apiKey && !base["x-lucern-key"] && !base.Authorization) {
82
- base["x-lucern-key"] = config.apiKey;
83
- }
84
- if (config.userToken && !base["x-lucern-user-token"]) {
85
- base["x-lucern-user-token"] = config.userToken;
86
- }
87
- if (config.environment && !base["x-lucern-environment"]) {
88
- base["x-lucern-environment"] = config.environment;
89
- }
90
- return base;
91
- },
92
- };
93
- }
94
- function requireTopicId(args) {
95
- const topicId = resolveTopicId(args);
96
- if (!topicId) {
97
- throw new Error("topicId is required");
98
- }
99
- return topicId;
100
- }
101
- const AUDIT_NODE_REFERENCE_KEY_PATTERN = /(^|_)(id|nodeid|beliefid|resourceid|targetid|sourceid|subjectid|globalid|entityid|recordid|fromnodeid|tonodeid|linkednodeid|linkedbeliefid|nodeids|beliefids|resourceids)$/i;
102
- function matchesAuditNodeReference(value, nodeId) {
103
- if (Array.isArray(value)) {
104
- return value.some((entry) => matchesAuditNodeReference(entry, nodeId));
105
- }
106
- if (!value || typeof value !== "object") {
107
- return false;
108
- }
109
- return Object.entries(value).some(([key, entry]) => {
110
- if (typeof entry === "string" &&
111
- entry === nodeId &&
112
- AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key)) {
113
- return true;
114
- }
115
- if (Array.isArray(entry) &&
116
- AUDIT_NODE_REFERENCE_KEY_PATTERN.test(key) &&
117
- entry.some((item) => item === nodeId)) {
118
- return true;
119
- }
120
- return matchesAuditNodeReference(entry, nodeId);
121
- });
122
- }
123
- function requireText(args) {
124
- const text = resolveText(args);
125
- if (!text) {
126
- throw new Error("text is required");
127
- }
128
- return text;
129
- }
130
- function exposeGatewayData(response) {
131
- return Object.assign({}, response, response.data);
132
- }
133
- /**
134
- * Create the high-level Lucern SDK client with all domain namespaces.
135
- *
136
- * @param config - Client configuration with API key, base URL, and optional settings.
137
- * @returns The Lucern client with namespaced methods for beliefs, topics, evidence, decisions, and more.
138
- */
139
- export function createLucernClient(config = {}) {
140
- const gatewayConfig = toGatewayConfig(config);
141
- const beliefsClient = createBeliefsClient(gatewayConfig);
142
- const beliefsFacade = createBeliefsFacade(gatewayConfig);
143
- const graphClient = createGraphClient(gatewayConfig);
144
- const graphFacade = createGraphFacade(gatewayConfig);
145
- const decisionsClient = createDecisionsClient(gatewayConfig);
146
- const contextClient = createContextClient(gatewayConfig);
147
- const workflowClient = createWorkflowClient(gatewayConfig);
148
- const auditClient = createAuditClient(gatewayConfig);
149
- const adminClient = createAdminClient(gatewayConfig);
150
- const answersClient = createAnswersClient(gatewayConfig);
151
- const contradictionsFacade = createContradictionsFacade(gatewayConfig);
152
- const edgesFacade = createEdgesFacade(gatewayConfig);
153
- const evidenceFacade = createEvidenceFacade(gatewayConfig);
154
- const eventsFacade = createEventsFacade(gatewayConfig);
155
- const identityClient = createIdentityClient(gatewayConfig);
156
- const identityFacade = createIdentityFacade(gatewayConfig);
157
- const ontologiesFacade = createOntologiesFacade(gatewayConfig);
158
- const questionsFacade = createQuestionsFacade(gatewayConfig);
159
- const searchFacade = createSearchFacade(gatewayConfig);
160
- const tasksFacade = createTasksFacade(gatewayConfig);
161
- const topicsFacade = createTopicsFacade(gatewayConfig);
162
- const webhooksFacade = createWebhooksFacade(gatewayConfig);
163
- const worktreesFacade = createWorktreesFacade(gatewayConfig);
164
- const policyClient = createPolicyClient(gatewayConfig);
165
- const ontologyClient = createOntologyClient(gatewayConfig);
166
- const mcpParityClient = createMcpParityClient(gatewayConfig);
167
- const packsClient = createPacksClient(gatewayConfig);
168
- const reportsClient = createReportsClient(gatewayConfig);
169
- const learningClient = createLearningClient(gatewayConfig);
170
- const harnessClient = createHarnessClient(gatewayConfig);
171
- const schemaClient = createSchemaClient(gatewayConfig);
172
- const audiencesClient = createAudiencesClient(gatewayConfig);
173
- const topicsClient = createTopicsClient(gatewayConfig);
174
- const gateway = createGatewayRequestClient(gatewayConfig);
175
- const customNamespaceCache = new Map();
176
- // Pack auto-install: tracks whether the configured packKey has been installed.
177
- // Install is lazy — triggered on first API call or explicit ensurePack().
178
- let _packInstalled = !config.packKey; // true if no packKey configured
179
- let _packInstallPromise = null;
180
- async function ensurePack() {
181
- if (_packInstalled) {
182
- return;
183
- }
184
- if (_packInstallPromise) {
185
- return _packInstallPromise;
186
- }
187
- const installPromise = (async () => {
188
- try {
189
- await packsClient.install({
190
- packKey: config.packKey,
191
- autoEnable: true,
192
- });
193
- _packInstalled = true;
194
- }
195
- catch (err) {
196
- // If the pack is already installed, treat as success
197
- if (err instanceof LucernApiError && err.code === "ALREADY_EXISTS") {
198
- _packInstalled = true;
199
- return;
200
- }
201
- // Re-throw — caller decides whether to proceed without the pack
202
- throw err;
203
- }
204
- })();
205
- _packInstallPromise = installPromise;
206
- try {
207
- await installPromise;
208
- }
209
- catch (error) {
210
- if (_packInstallPromise === installPromise) {
211
- _packInstallPromise = null;
212
- }
213
- throw error;
214
- }
215
- }
216
- const invokeCustomTool = async (fullName, input = {}) => {
217
- const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
218
- return invokeRegisteredCustomTool(fullName, payload, { source: "sdk" });
219
- };
220
- const getCustomNamespace = (namespace) => {
221
- const normalized = namespace.trim() || "custom";
222
- const cached = customNamespaceCache.get(normalized);
223
- if (cached) {
224
- return cached;
225
- }
226
- const proxy = new Proxy({}, {
227
- get(_target, property) {
228
- if (typeof property !== "string" || property === "then") {
229
- return;
230
- }
231
- return async (input = {}) => invokeCustomTool(`${normalized}.${property}`, input);
232
- },
233
- });
234
- customNamespaceCache.set(normalized, proxy);
235
- return proxy;
236
- };
237
- const extensionNamespaces = new Proxy({}, {
238
- get(_target, namespace) {
239
- if (typeof namespace !== "string" || namespace === "then") {
240
- return;
241
- }
242
- return getCustomNamespace(namespace);
243
- },
244
- });
245
- async function createEvidenceCompat(args) {
246
- const topicId = requireTopicId(args);
247
- const text = resolveText(args);
248
- if (!text) {
249
- throw new Error("text is required");
250
- }
251
- const metadata = {
252
- ...(args.metadata ?? {}),
253
- ...(args.supports?.reasoning
254
- ? { rationale: args.supports.reasoning }
255
- : {}),
256
- };
257
- return evidenceFacade.create({
258
- topicId,
259
- text,
260
- source: args.source ?? args.sourceUrl,
261
- targetId: args.targetId ?? args.supports?.nodeId,
262
- weight: args.weight ?? args.supports?.weight,
263
- metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
264
- title: args.title,
265
- content: args.content,
266
- contentType: args.contentType,
267
- kind: args.kind,
268
- });
269
- }
270
- async function addEvidence(args) {
271
- const created = await createEvidenceCompat({
272
- ...args,
273
- targetId: args.supports ? undefined : args.targetId,
274
- weight: args.supports ? undefined : args.weight,
275
- });
276
- if (!args.supports) {
277
- return created.data;
278
- }
279
- const evidenceId = created.data.id;
280
- if (typeof evidenceId !== "string" || evidenceId.length === 0) {
281
- throw new Error("evidence create did not return an id");
282
- }
283
- const linked = await evidenceFacade.link({
284
- evidenceId,
285
- targetId: args.supports.nodeId,
286
- weight: args.supports.weight,
287
- rationale: args.supports.reasoning,
288
- });
289
- return {
290
- ...created.data,
291
- edgeId: linked.data.edgeId,
292
- };
293
- }
294
- async function listBeliefs(args) {
295
- const response = await beliefsFacade.list({
296
- topicId: requireTopicId(args),
297
- status: args.status,
298
- worktreeId: args.worktreeId,
299
- minConfidence: args.minConfidence,
300
- limit: args.limit,
301
- cursor: args.cursor,
302
- });
303
- return Array.isArray(response.data.beliefs) ? response.data.beliefs : [];
304
- }
305
- async function searchBeliefs(args) {
306
- const topicId = resolveTopicId(args);
307
- if (!topicId) {
308
- return { results: [] };
309
- }
310
- const response = await searchFacade.query({
311
- q: args.query,
312
- topicId,
313
- types: ["belief"],
314
- status: args.status,
315
- minConfidence: args.minConfidence,
316
- limit: args.limit,
317
- });
318
- const data = exposeGatewayData(response);
319
- const groupedBeliefs = Array.isArray(data.beliefs)
320
- ? data.beliefs
321
- : [];
322
- const mergedResults = Array.isArray(data.results)
323
- ? data.results
324
- : [];
325
- const results = groupedBeliefs.length > 0
326
- ? groupedBeliefs
327
- : mergedResults.filter((result) => result.type === "belief");
328
- return { results };
329
- }
330
- async function searchResources(query, options = {}) {
331
- const topicId = resolveTopicId(options);
332
- if (!topicId) {
333
- throw new Error("topicId is required");
334
- }
335
- return searchFacade
336
- .query({
337
- q: query,
338
- topicId,
339
- types: options.types,
340
- status: options.status,
341
- minConfidence: options.minConfidence,
342
- limit: options.limit,
343
- cursor: options.cursor,
344
- })
345
- .then(exposeGatewayData);
346
- }
347
- async function findContradictions(args) {
348
- const topicId = resolveTopicId(args);
349
- const response = topicId
350
- ? await graphClient.listNodes({
351
- topicId,
352
- nodeType: "contradiction",
353
- limit: 500,
354
- })
355
- : args.nodeId
356
- ? await graphClient.queryNodes({ nodeId: args.nodeId })
357
- : { data: [] };
358
- const contradictions = asNodeArray(response.data)
359
- .filter((node) => {
360
- const status = typeof node.metadata?.status === "string"
361
- ? node.metadata.status
362
- : typeof node.status === "string"
363
- ? node.status
364
- : "unresolved";
365
- if (args.status && status !== args.status) {
366
- return false;
367
- }
368
- return true;
369
- })
370
- .map((node) => ({
371
- beliefA: typeof node.metadata?.beliefA === "string"
372
- ? node.metadata.beliefA
373
- : "",
374
- beliefB: typeof node.metadata?.beliefB === "string"
375
- ? node.metadata.beliefB
376
- : "",
377
- description: node.canonicalText ?? "",
378
- severity: typeof node.metadata?.severity === "string"
379
- ? node.metadata.severity
380
- : "medium",
381
- status: typeof node.metadata?.status === "string"
382
- ? node.metadata.status
383
- : "unresolved",
384
- defeatType: typeof node.metadata?.defeatType === "string"
385
- ? node.metadata.defeatType
386
- : "rebuts",
387
- }));
388
- return { contradictions };
389
- }
390
- async function queryLineage(nodeId, depth = 5) {
391
- const response = await beliefsFacade.lineage(nodeId);
392
- const lineage = Array.isArray(response.data.lineage)
393
- ? response.data.lineage
394
- : [];
395
- const chain = lineage.length > 0
396
- ? lineage
397
- .slice(0, depth + 1)
398
- .map((entry, index) => ({
399
- nodeId: entry.nodeId ?? entry.beliefId ?? "",
400
- relation: index === 0 ? "self" : "ancestor",
401
- }))
402
- : [{ nodeId, relation: "self" }];
403
- return {
404
- chain,
405
- forkTree: {
406
- nodeId,
407
- parentCount: Math.max(0, lineage.length - 1),
408
- childCount: 0,
409
- children: [],
410
- },
411
- depth,
412
- beliefId: response.data.beliefId,
413
- lineage,
414
- };
415
- }
416
- async function getConfidenceHistory(nodeId) {
417
- return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
418
- }
419
- async function getAuditTrail(nodeId, limit = 50) {
420
- const events = await auditClient.listEvents({ limit });
421
- const entries = asListItems(events.data, "events")
422
- .filter((event) => matchesAuditNodeReference(event, nodeId))
423
- .slice(0, limit)
424
- .map((event) => {
425
- const row = event;
426
- return {
427
- action: typeof row.action === "string" ? row.action : "unknown",
428
- actor: typeof row.actor === "string" ? row.actor : "unknown",
429
- timestamp: typeof row.timestamp === "number" ? row.timestamp : Date.now(),
430
- rationale: typeof row.rationale === "string"
431
- ? row.rationale
432
- : "No rationale recorded.",
433
- before: row.before ?? null,
434
- after: row.after ?? null,
435
- };
436
- });
437
- return { entries };
438
- }
439
- async function bisectConfidence(nodeId, args) {
440
- return beliefsFacade.bisect(nodeId, args).then(exposeGatewayData);
441
- }
442
- async function discoverTopics(input = {}) {
443
- return gateway
444
- .request({
445
- path: "/api/platform/v1/context/discover",
446
- method: "POST",
447
- body: input,
448
- })
449
- .then(exposeGatewayData);
450
- }
451
- async function discoverEntityConnections(input = {}) {
452
- return gateway
453
- .request({
454
- path: "/api/platform/v1/context/entity-connections",
455
- method: "POST",
456
- body: input,
457
- })
458
- .then(exposeGatewayData);
459
- }
460
- async function triggerBeliefReview(input = {}) {
461
- return gateway
462
- .request({
463
- path: "/api/platform/v1/context/belief-review",
464
- method: "POST",
465
- body: input,
466
- idempotencyKey: randomIdempotencyKey(),
467
- })
468
- .then(exposeGatewayData);
469
- }
470
- async function createContractCompat(input = {}) {
471
- return gateway
472
- .request({
473
- path: "/api/platform/v1/contracts",
474
- method: "POST",
475
- body: input,
476
- idempotencyKey: randomIdempotencyKey(),
477
- })
478
- .then(exposeGatewayData);
479
- }
480
- async function evaluateContractCompat(input = {}) {
481
- return gateway
482
- .request({
483
- path: "/api/platform/v1/contracts/evaluate",
484
- method: "POST",
485
- body: input,
486
- idempotencyKey: randomIdempotencyKey(),
487
- })
488
- .then(exposeGatewayData);
489
- }
490
- async function getContractStatusCompat(input = {}) {
491
- return gateway
492
- .request({
493
- path: "/api/platform/v1/contracts/status",
494
- method: "POST",
495
- body: input,
496
- })
497
- .then(exposeGatewayData);
498
- }
499
- async function listContractsCompat(input = {}) {
500
- return gateway
501
- .request({
502
- path: `/api/platform/v1/contracts${toQueryString({
503
- beliefNodeId: typeof input.beliefNodeId === "string"
504
- ? input.beliefNodeId
505
- : undefined,
506
- contractId: typeof input.contractId === "string" ? input.contractId : undefined,
507
- status: typeof input.status === "string" ? input.status : undefined,
508
- })}`,
509
- })
510
- .then(exposeGatewayData);
511
- }
512
- async function createOntologyCompat(input = {}) {
513
- const response = await ontologyClient.createDefinition(input);
514
- const envelope = response;
515
- return Object.assign({}, envelope, envelope.data);
516
- }
517
- async function updateOntologyCompat(input = {}) {
518
- const id = typeof input.id === "string" ? input.id : "";
519
- const { id: _id, ...rest } = input;
520
- const response = await ontologyClient.updateDefinition(id, rest);
521
- const envelope = response;
522
- return Object.assign({}, envelope, envelope.data);
523
- }
524
- async function archiveOntologyCompat(input = {}) {
525
- const id = typeof input.id === "string" ? input.id : "";
526
- const response = await ontologyClient.archiveDefinition(id);
527
- const envelope = response;
528
- return Object.assign({}, envelope, envelope.data);
529
- }
530
- async function createOntologyVersionCompat(input = {}) {
531
- const ontologyId = typeof input.ontologyId === "string" ? input.ontologyId : "";
532
- const { ontologyId: _ontologyId, ...rest } = input;
533
- const response = await ontologyClient.createVersion(ontologyId, rest);
534
- const envelope = response;
535
- return Object.assign({}, envelope, envelope.data);
536
- }
537
- async function publishOntologyVersionCompat(input = {}) {
538
- return gateway
539
- .request({
540
- path: "/api/platform/v1/ontologies/versions/publish",
541
- method: "POST",
542
- body: input,
543
- idempotencyKey: randomIdempotencyKey(),
544
- })
545
- .then(exposeGatewayData);
546
- }
547
- async function deprecateOntologyVersionCompat(input = {}) {
548
- return gateway
549
- .request({
550
- path: "/api/platform/v1/ontologies/versions/deprecate",
551
- method: "POST",
552
- body: input,
553
- idempotencyKey: randomIdempotencyKey(),
554
- })
555
- .then(exposeGatewayData);
556
- }
557
- async function resolveEffectiveOntologyCompat(input = {}) {
558
- return gateway
559
- .request({
560
- path: "/api/platform/v1/ontologies/effective",
561
- method: "POST",
562
- body: input,
563
- })
564
- .then(exposeGatewayData);
565
- }
566
- async function traceEntityImpactCompat(input = {}) {
567
- return gateway
568
- .request({
569
- path: "/api/platform/v1/graph/trace-entity-impact",
570
- method: "POST",
571
- body: input,
572
- })
573
- .then(exposeGatewayData);
574
- }
575
- const nodesNamespace = {
576
- list(query) {
577
- return graphClient.listNodes(query);
578
- },
579
- get(input) {
580
- return graphClient.getNode(typeof input === "string" ? { nodeId: input } : input);
581
- },
582
- create(input, idempotencyKey) {
583
- return graphClient.createNode(input, idempotencyKey);
584
- },
585
- update(input, idempotencyKey) {
586
- return graphClient.updateNode(input, idempotencyKey);
587
- },
588
- batchCreate(input, idempotencyKey) {
589
- return graphClient.batchCreateNodes(input, idempotencyKey);
590
- },
591
- supersede(input, idempotencyKey) {
592
- return graphClient.supersedeNode(input, idempotencyKey);
593
- },
594
- verify(input, idempotencyKey) {
595
- return graphClient.verifyNode(input, idempotencyKey);
596
- },
597
- hardDelete(input, idempotencyKey) {
598
- return graphClient.hardDeleteNode(input, idempotencyKey);
599
- },
600
- };
601
- return {
602
- config,
603
- version: LUCERN_SDK_VERSION,
604
- search(query, options) {
605
- return searchResources(query, options);
606
- },
607
- events: {
608
- list(query = {}) {
609
- return eventsFacade.list(query).then(exposeGatewayData);
610
- },
611
- replay(input) {
612
- return eventsFacade.replay(input).then(exposeGatewayData);
613
- },
614
- },
615
- beliefs: {
616
- create(input) {
617
- return beliefsFacade
618
- .create({
619
- topicId: requireTopicId(input),
620
- text: requireText(input),
621
- rationale: input.rationale,
622
- worktreeId: input.worktreeId,
623
- pillar: input.pillar,
624
- sourceBeliefIds: input.sourceBeliefIds,
625
- sourceType: input.sourceType,
626
- beliefType: input.beliefType,
627
- reversibility: input.reversibility,
628
- predictionMeta: input.predictionMeta,
629
- metadata: input.metadata,
630
- })
631
- .then(exposeGatewayData);
632
- },
633
- get(nodeId) {
634
- return beliefsFacade.get(nodeId).then(exposeGatewayData);
635
- },
636
- refine(nodeId, textOrInput, rationale) {
637
- const payload = typeof textOrInput === "string"
638
- ? { text: textOrInput, rationale }
639
- : {
640
- text: textOrInput.text,
641
- rationale: textOrInput.rationale,
642
- };
643
- return beliefsFacade.refine(nodeId, payload).then(exposeGatewayData);
644
- },
645
- updateConfidence(nodeId, input) {
646
- return beliefsFacade.updateConfidence(nodeId, input).then(exposeGatewayData);
647
- },
648
- modulateConfidence(nodeId, input) {
649
- return beliefsFacade.updateConfidence(nodeId, input).then(exposeGatewayData);
650
- },
651
- updateStatus(input, idempotencyKey) {
652
- return beliefsFacade
653
- .updateStatus(input, idempotencyKey)
654
- .then(exposeGatewayData);
655
- },
656
- updateRationale(input, idempotencyKey) {
657
- return beliefsFacade
658
- .updateRationale(input, idempotencyKey)
659
- .then(exposeGatewayData);
660
- },
661
- linkBeliefs(input, idempotencyKey) {
662
- return beliefsFacade
663
- .linkBeliefs(input, idempotencyKey)
664
- .then(exposeGatewayData);
665
- },
666
- unlinkEvidence(input, idempotencyKey) {
667
- return beliefsFacade
668
- .unlinkEvidence(input, idempotencyKey)
669
- .then(exposeGatewayData);
670
- },
671
- updateCriticality(input, idempotencyKey) {
672
- return beliefsFacade
673
- .updateCriticality(input, idempotencyKey)
674
- .then(exposeGatewayData);
675
- },
676
- batchUpdateCriticality(input, idempotencyKey) {
677
- return beliefsFacade
678
- .batchUpdateCriticality(input, idempotencyKey)
679
- .then(exposeGatewayData);
680
- },
681
- reassignTopic(input, idempotencyKey) {
682
- return beliefsFacade
683
- .reassignTopic(input, idempotencyKey)
684
- .then(exposeGatewayData);
685
- },
686
- fork(nodeId, input) {
687
- return beliefsFacade
688
- .fork(nodeId, {
689
- text: requireText(input),
690
- forkReason: input.forkReason,
691
- rationale: input.rationale,
692
- })
693
- .then(exposeGatewayData);
694
- },
695
- archive(nodeId, input) {
696
- const payload = typeof input === "string"
697
- ? { reason: input }
698
- : input
699
- ? { reason: input.reason ?? input.rationale }
700
- : undefined;
701
- return beliefsFacade.archive(nodeId, payload).then(exposeGatewayData);
702
- },
703
- list(args) {
704
- return beliefsFacade
705
- .list({
706
- topicId: requireTopicId(args),
707
- worktreeId: args.worktreeId,
708
- status: args.status,
709
- minConfidence: args.minConfidence,
710
- limit: args.limit,
711
- cursor: args.cursor,
712
- })
713
- .then(exposeGatewayData);
714
- },
715
- search: searchBeliefs,
716
- lineage(nodeId) {
717
- return beliefsFacade.lineage(nodeId).then(exposeGatewayData);
718
- },
719
- confidenceHistory(nodeId) {
720
- return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
721
- },
722
- createContract(nodeId, input) {
723
- return beliefsFacade
724
- .createContract(nodeId, input)
725
- .then(exposeGatewayData);
726
- },
727
- bisect(nodeId, input) {
728
- return beliefsFacade.bisect(nodeId, input).then(exposeGatewayData);
729
- },
730
- },
731
- webhooks: {
732
- create(input) {
733
- return webhooksFacade.create(input).then(exposeGatewayData);
734
- },
735
- list(query) {
736
- return webhooksFacade.list(query).then(exposeGatewayData);
737
- },
738
- get(id) {
739
- return webhooksFacade.get(id).then(exposeGatewayData);
740
- },
741
- update(id, input) {
742
- return webhooksFacade.update(id, input).then(exposeGatewayData);
743
- },
744
- delete(id) {
745
- return webhooksFacade.delete(id).then(exposeGatewayData);
746
- },
747
- test(id, input) {
748
- return webhooksFacade.test(id, input).then(exposeGatewayData);
749
- },
750
- deliveries(id, query) {
751
- return webhooksFacade.deliveries(id, query).then(exposeGatewayData);
752
- },
753
- health(id) {
754
- return webhooksFacade.health(id).then(exposeGatewayData);
755
- },
756
- },
757
- edges: {
758
- create(args) {
759
- return edgesFacade
760
- .create({
761
- sourceId: args.sourceId,
762
- targetId: args.targetId,
763
- edgeType: args.edgeType,
764
- topicId: args.topicId,
765
- confidence: args.confidence,
766
- weight: args.weight,
767
- context: args.context ?? args.reasoning,
768
- })
769
- .then(exposeGatewayData);
770
- },
771
- update(input, idempotencyKey) {
772
- return edgesFacade.update(input, idempotencyKey).then(exposeGatewayData);
773
- },
774
- remove(input, idempotencyKey) {
775
- return edgesFacade.remove(input, idempotencyKey).then(exposeGatewayData);
776
- },
777
- removeBetween(input, idempotencyKey) {
778
- return edgesFacade
779
- .removeBetween(input, idempotencyKey)
780
- .then(exposeGatewayData);
781
- },
782
- batchCreate(input, idempotencyKey) {
783
- return edgesFacade
784
- .batchCreate(input, idempotencyKey)
785
- .then(exposeGatewayData);
786
- },
787
- delete(input, idempotencyKey) {
788
- return edgesFacade.delete(input, idempotencyKey).then(exposeGatewayData);
789
- },
790
- list(args) {
791
- return edgesFacade
792
- .list({
793
- sourceId: args.sourceId,
794
- edgeType: args.edgeType,
795
- limit: args.limit,
796
- cursor: args.cursor,
797
- })
798
- .then(exposeGatewayData);
799
- },
800
- traverse(args) {
801
- return edgesFacade
802
- .traverse({
803
- startNode: args.startNode,
804
- direction: args.direction,
805
- maxDepth: args.maxDepth,
806
- topicId: args.topicId,
807
- })
808
- .then(exposeGatewayData);
809
- },
810
- },
811
- evidence: {
812
- create(args) {
813
- return createEvidenceCompat(args).then(exposeGatewayData);
814
- },
815
- add: addEvidence,
816
- get(evidenceId) {
817
- return evidenceFacade.get(evidenceId).then(exposeGatewayData);
818
- },
819
- list(args) {
820
- return evidenceFacade
821
- .list({
822
- topicId: args.topicId,
823
- targetId: args.targetId,
824
- limit: args.limit,
825
- cursor: args.cursor,
826
- })
827
- .then(exposeGatewayData);
828
- },
829
- search(args) {
830
- const q = args.q ?? args.query;
831
- if (!q) {
832
- throw new Error("q is required");
833
- }
834
- return evidenceFacade
835
- .search({
836
- q,
837
- topicId: args.topicId,
838
- targetId: args.targetId,
839
- limit: args.limit,
840
- cursor: args.cursor,
841
- })
842
- .then(exposeGatewayData);
843
- },
844
- link(args) {
845
- const targetId = args.targetId ?? args.questionId ?? args.beliefId;
846
- if (!targetId) {
847
- throw new Error("targetId is required");
848
- }
849
- const targetType = typeof args.targetType === "string"
850
- ? args.targetType
851
- : args.questionId
852
- ? "question"
853
- : args.beliefId
854
- ? "belief"
855
- : undefined;
856
- return evidenceFacade
857
- .link({
858
- evidenceId: args.evidenceId,
859
- targetId,
860
- targetType: targetType,
861
- weight: args.weight,
862
- rationale: args.rationale,
863
- })
864
- .then(exposeGatewayData);
865
- },
866
- linkToBelief(args) {
867
- return evidenceFacade
868
- .link({
869
- evidenceId: args.evidenceId,
870
- targetId: args.beliefId,
871
- weight: args.weight,
872
- rationale: args.rationale,
873
- })
874
- .then((response) => ({
875
- ...response.data,
876
- beliefId: args.beliefId,
877
- }));
878
- },
879
- updateStatus(input, idempotencyKey) {
880
- return evidenceFacade
881
- .updateStatus(input, idempotencyKey)
882
- .then(exposeGatewayData);
883
- },
884
- update(input, idempotencyKey) {
885
- return evidenceFacade.update(input, idempotencyKey).then(exposeGatewayData);
886
- },
887
- flagIncorrect(input, idempotencyKey) {
888
- return evidenceFacade
889
- .flagIncorrect(input, idempotencyKey)
890
- .then(exposeGatewayData);
891
- },
892
- remove(input, idempotencyKey) {
893
- return evidenceFacade.remove(input, idempotencyKey).then(exposeGatewayData);
894
- },
895
- updateVerificationStatus(input, idempotencyKey) {
896
- return evidenceFacade
897
- .updateVerificationStatus(input, idempotencyKey)
898
- .then(exposeGatewayData);
899
- },
900
- },
901
- questions: {
902
- create(args) {
903
- return questionsFacade
904
- .create({
905
- topicId: requireTopicId(args),
906
- text: args.text,
907
- priority: args.priority,
908
- linkedBeliefId: args.linkedBeliefId,
909
- metadata: args.metadata,
910
- })
911
- .then(exposeGatewayData);
912
- },
913
- get(questionId) {
914
- return questionsFacade.get(questionId).then(exposeGatewayData);
915
- },
916
- refine(questionId, text, refinementReason) {
917
- return questionsFacade
918
- .refine(questionId, {
919
- text,
920
- rationale: refinementReason,
921
- })
922
- .then(exposeGatewayData);
923
- },
924
- list(args) {
925
- return questionsFacade
926
- .list({
927
- topicId: requireTopicId(args),
928
- status: args.status,
929
- priority: args.priority,
930
- worktreeId: args.worktreeId,
931
- limit: args.limit,
932
- cursor: args.cursor,
933
- })
934
- .then(exposeGatewayData);
935
- },
936
- updateStatus(questionId, status, rationale) {
937
- return questionsFacade
938
- .updateStatus(questionId, {
939
- status,
940
- rationale,
941
- })
942
- .then(exposeGatewayData);
943
- },
944
- batchCreate(input, idempotencyKey) {
945
- return questionsFacade
946
- .batchCreate(input, idempotencyKey)
947
- .then(exposeGatewayData);
948
- },
949
- add(input, idempotencyKey) {
950
- return questionsFacade.add(input, idempotencyKey).then(exposeGatewayData);
951
- },
952
- updatePriority(input, idempotencyKey) {
953
- return questionsFacade
954
- .updatePriority(input, idempotencyKey)
955
- .then(exposeGatewayData);
956
- },
957
- advanceToConviction(input, idempotencyKey) {
958
- return questionsFacade
959
- .advanceToConviction(input, idempotencyKey)
960
- .then(exposeGatewayData);
961
- },
962
- updateConviction(input, idempotencyKey) {
963
- return questionsFacade
964
- .updateConviction(input, idempotencyKey)
965
- .then(exposeGatewayData);
966
- },
967
- finalizeConviction(input, idempotencyKey) {
968
- return questionsFacade
969
- .finalizeConviction(input, idempotencyKey)
970
- .then(exposeGatewayData);
971
- },
972
- update(input, idempotencyKey) {
973
- return questionsFacade.update(input, idempotencyKey).then(exposeGatewayData);
974
- },
975
- delete(input, idempotencyKey) {
976
- return questionsFacade.delete(input, idempotencyKey).then(exposeGatewayData);
977
- },
978
- answer(questionId, input) {
979
- return questionsFacade
980
- .answer(questionId, input)
981
- .then(exposeGatewayData);
982
- },
983
- archive(questionId, reason) {
984
- return questionsFacade
985
- .archive(questionId, { reason })
986
- .then(exposeGatewayData);
987
- },
988
- linkEvidence(args) {
989
- const weight = args.weight ?? args.relevance;
990
- return evidenceFacade
991
- .link({
992
- evidenceId: args.evidenceId,
993
- targetId: args.questionId,
994
- targetType: "question",
995
- weight,
996
- rationale: args.rationale,
997
- })
998
- .then((response) => ({
999
- ...response.data,
1000
- questionId: args.questionId,
1001
- relevance: weight,
1002
- }));
1003
- },
1004
- getHighPriority(args) {
1005
- return this.list({
1006
- topicId: requireTopicId(args),
1007
- status: args.includeAnswered ? undefined : "open",
1008
- }).then((data) => {
1009
- const questions = (Array.isArray(data.questions) ? data.questions : []);
1010
- const rank = (priority) => {
1011
- switch (priority) {
1012
- case "urgent":
1013
- return 4;
1014
- case "high":
1015
- return 3;
1016
- case "medium":
1017
- return 2;
1018
- case "low":
1019
- return 1;
1020
- default:
1021
- return 0;
1022
- }
1023
- };
1024
- return {
1025
- questions: [...questions]
1026
- .sort((a, b) => rank(b.priority) - rank(a.priority))
1027
- .slice(0, args.limit ?? 20),
1028
- };
1029
- });
1030
- },
1031
- async findMissing(args) {
1032
- return graphFacade
1033
- .gaps({
1034
- topicId: requireTopicId(args),
1035
- minConfidence: args.minConfidence,
1036
- })
1037
- .then(exposeGatewayData);
1038
- },
1039
- },
1040
- graph: {
1041
- nodes: nodesNamespace,
1042
- createEdge(input) {
1043
- return graphClient.createEdge(input);
1044
- },
1045
- neighborhood(args) {
1046
- return graphFacade
1047
- .neighborhood({
1048
- globalId: args.globalId,
1049
- globalIds: typeof args.globalIds === "string"
1050
- ? args.globalIds
1051
- .split(",")
1052
- .map((value) => value.trim())
1053
- .filter((value) => value.length > 0)
1054
- : undefined,
1055
- maxDepth: args.maxDepth,
1056
- })
1057
- .then(exposeGatewayData);
1058
- },
1059
- queryLineage,
1060
- getConfidenceHistory,
1061
- getAuditTrail,
1062
- traverse(args) {
1063
- return graphFacade
1064
- .traverse({
1065
- startNode: args.startNode,
1066
- direction: args.direction,
1067
- maxDepth: args.maxDepth ?? 3,
1068
- topicId: args.topicId,
1069
- })
1070
- .then(exposeGatewayData);
1071
- },
1072
- analyze(args) {
1073
- return graphFacade
1074
- .analyze({
1075
- topicId: requireTopicId(args),
1076
- limit: args.limit,
1077
- metric: args.metric,
1078
- })
1079
- .then(exposeGatewayData);
1080
- },
1081
- bias(args) {
1082
- return graphFacade
1083
- .bias({
1084
- topicId: requireTopicId(args),
1085
- threshold: args.threshold,
1086
- limit: args.limit,
1087
- })
1088
- .then(exposeGatewayData);
1089
- },
1090
- gaps(args) {
1091
- return graphFacade
1092
- .gaps({
1093
- topicId: requireTopicId(args),
1094
- minConfidence: args.minConfidence,
1095
- })
1096
- .then(exposeGatewayData);
1097
- },
1098
- falsify(args) {
1099
- return graphFacade
1100
- .falsify({
1101
- topicId: args.topicId,
1102
- beliefId: args.beliefId,
1103
- beliefIds: args.beliefIds,
1104
- minConfidence: args.minConfidence,
1105
- })
1106
- .then(exposeGatewayData);
1107
- },
1108
- traceEntityImpact(args) {
1109
- return traceEntityImpactCompat({
1110
- nodeId: args.nodeId,
1111
- topicId: args.topicId,
1112
- });
1113
- },
1114
- searchBeliefs,
1115
- findContradictions,
1116
- bisectConfidence,
1117
- listBeliefs,
1118
- detectConfirmationBias(topicId, threshold) {
1119
- return this.bias({
1120
- topicId,
1121
- threshold,
1122
- limit: 200,
1123
- }).then((response) => ({
1124
- ...response,
1125
- topicId,
1126
- threshold: threshold ?? 0.7,
1127
- }));
1128
- },
1129
- getStructureAnalysis(topicId) {
1130
- return this.analyze({
1131
- topicId,
1132
- limit: 200,
1133
- }).then((response) => ({
1134
- ...response,
1135
- topicId,
1136
- }));
1137
- },
1138
- getFalsificationQuestions(topicId, beliefIds) {
1139
- return graphFacade
1140
- .falsify({
1141
- topicId,
1142
- beliefIds,
1143
- })
1144
- .then(exposeGatewayData)
1145
- .then((response) => ({
1146
- topicId,
1147
- questions: response.questions,
1148
- }));
1149
- },
1150
- },
1151
- judgments: {
1152
- create(input) {
1153
- return decisionsClient.createJudgment(input);
1154
- },
1155
- record(input) {
1156
- return decisionsClient.recordJudgment(input);
1157
- },
1158
- list(query) {
1159
- return decisionsClient.listJudgments(query);
1160
- },
1161
- get(judgmentId) {
1162
- return decisionsClient.getJudgment(judgmentId);
1163
- },
1164
- recordOutcome(judgmentId, input) {
1165
- return decisionsClient.recordJudgmentOutcome(judgmentId, input);
1166
- },
1167
- updateOutcome(judgmentId, input) {
1168
- return decisionsClient.updateJudgmentOutcome(judgmentId, input);
1169
- },
1170
- readiness(topicId) {
1171
- return decisionsClient.getJudgmentReadiness({
1172
- topicId,
1173
- });
1174
- },
1175
- calibration(topicId) {
1176
- return decisionsClient.getJudgmentCalibration({
1177
- topicId,
1178
- });
1179
- },
1180
- pendingOutcomeReview(topicId) {
1181
- return decisionsClient.listPendingJudgmentOutcomeReview({
1182
- topicId,
1183
- });
1184
- },
1185
- transitionAuditIntegrity(args) {
1186
- return decisionsClient.getJudgmentTransitionAuditIntegrity({
1187
- ...args,
1188
- topicId: requireTopicId(args),
1189
- });
1190
- },
1191
- },
1192
- worktrees: {
1193
- createBranch(input) {
1194
- return workflowClient.createBranch(input);
1195
- },
1196
- createLens(input) {
1197
- return workflowClient.createLens(input);
1198
- },
1199
- listLenses(query) {
1200
- return workflowClient.listLenses(query);
1201
- },
1202
- applyLensToTopic(input) {
1203
- return workflowClient.applyLensToTopic(input);
1204
- },
1205
- removeLensFromTopic(input) {
1206
- return workflowClient.removeLensFromTopic(input);
1207
- },
1208
- create(input) {
1209
- return worktreesFacade.create({
1210
- title: input.title,
1211
- topicId: requireTopicId(input),
1212
- objective: input.objective,
1213
- hypothesis: input.hypothesis,
1214
- beliefIds: input.beliefIds,
1215
- autoShape: input.autoShape,
1216
- domainPackId: input.domainPackId,
1217
- executionOrder: input.executionOrder,
1218
- dependsOn: input.dependsOn,
1219
- blocks: input.blocks,
1220
- gate: input.gate,
1221
- proofArtifacts: input.proofArtifacts,
1222
- staffingHint: typeof input.staffingHint === "string"
1223
- ? input.staffingHint
1224
- : undefined,
1225
- lastReconciledAt: input.lastReconciledAt,
1226
- autoFixPolicy: input.autoFixPolicy,
1227
- });
1228
- },
1229
- add(input) {
1230
- return worktreesFacade.create({
1231
- title: input.title,
1232
- topicId: requireTopicId(input),
1233
- objective: input.objective,
1234
- hypothesis: input.hypothesis,
1235
- beliefIds: input.beliefIds,
1236
- autoShape: input.autoShape,
1237
- domainPackId: input.domainPackId,
1238
- executionOrder: input.executionOrder,
1239
- dependsOn: input.dependsOn,
1240
- blocks: input.blocks,
1241
- gate: input.gate,
1242
- proofArtifacts: input.proofArtifacts,
1243
- staffingHint: typeof input.staffingHint === "string"
1244
- ? input.staffingHint
1245
- : undefined,
1246
- lastReconciledAt: input.lastReconciledAt,
1247
- autoFixPolicy: input.autoFixPolicy,
1248
- });
1249
- },
1250
- list(query) {
1251
- return worktreesFacade.list({
1252
- topicId: requireTopicId(query),
1253
- status: query.status,
1254
- limit: query.limit,
1255
- });
1256
- },
1257
- activate(worktreeId) {
1258
- return worktreesFacade.activate({ id: worktreeId });
1259
- },
1260
- updateMetadata(input) {
1261
- const dependsOn = Array.isArray(input.dependsOn)
1262
- ? input.dependsOn.filter((value) => typeof value === "string")
1263
- : undefined;
1264
- const blocks = Array.isArray(input.blocks)
1265
- ? input.blocks.filter((value) => typeof value === "string")
1266
- : undefined;
1267
- return worktreesFacade.update({
1268
- id: typeof input.worktreeId === "string" ? input.worktreeId : "",
1269
- hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : undefined,
1270
- track: typeof input.track === "string" ? input.track : undefined,
1271
- trackPosition: typeof input.trackPosition === "number" ? input.trackPosition : undefined,
1272
- executionBand: typeof input.executionBand === "number" ? input.executionBand : undefined,
1273
- executionOrder: typeof input.executionOrder === "number" ? input.executionOrder : undefined,
1274
- dependsOn,
1275
- blocks,
1276
- gate: typeof input.gate === "string" ? input.gate : undefined,
1277
- });
1278
- },
1279
- update(input) {
1280
- return this.updateMetadata(input);
1281
- },
1282
- updateTargets(input) {
1283
- return worktreesFacade.updateTargets({
1284
- id: input.worktreeId,
1285
- addBeliefIds: input.addBeliefIds,
1286
- addQuestionIds: input.addQuestionIds,
1287
- removeBeliefIds: input.removeBeliefIds,
1288
- removeQuestionIds: input.removeQuestionIds,
1289
- });
1290
- },
1291
- listAll(query = {}) {
1292
- return workflowClient.listAllWorktrees(query);
1293
- },
1294
- merge(worktreeId, input) {
1295
- return worktreesFacade.merge({
1296
- id: worktreeId,
1297
- outcomes: input.outcomes,
1298
- summary: input.summary,
1299
- });
1300
- },
1301
- push(worktreeId, input) {
1302
- return workflowClient.push(worktreeId, input);
1303
- },
1304
- openPullRequest(worktreeId, input) {
1305
- return workflowClient.openPullRequest(worktreeId, input);
1306
- },
1307
- pipelineSnapshot(topicId) {
1308
- return mcpParityClient.pipelineSnapshot({ topicId });
1309
- },
1310
- complete(input, idempotencyKey) {
1311
- return worktreesFacade.complete(input, idempotencyKey);
1312
- },
1313
- advancePhase(worktreeId, idempotencyKey) {
1314
- return worktreesFacade.advancePhase({ worktreeId }, idempotencyKey);
1315
- },
1316
- setPhase(worktreeId, phase, idempotencyKey) {
1317
- return worktreesFacade.setPhase({ worktreeId, phase }, idempotencyKey);
1318
- },
1319
- patchState(input, idempotencyKey) {
1320
- return worktreesFacade.patchState(input, idempotencyKey);
1321
- },
1322
- bulkCreate(input, idempotencyKey) {
1323
- return worktreesFacade.bulkCreate(input, idempotencyKey);
1324
- },
1325
- },
1326
- context: {
1327
- listTopics(query = {}) {
1328
- return topicsFacade.list({
1329
- ontologyId: query.ontologyId,
1330
- parentTopicId: query.parentTopicId,
1331
- status: query.status,
1332
- type: query.type,
1333
- });
1334
- },
1335
- compile(topicId, input = {}) {
1336
- return contextClient.compile(topicId, input);
1337
- },
1338
- recordScopeLearning(input) {
1339
- return mcpParityClient.recordScopeLearning(input);
1340
- },
1341
- discover(input) {
1342
- return discoverTopics(input);
1343
- },
1344
- analyzeTopicDensity(input) {
1345
- return mcpParityClient.analyzeTopicDensity(input);
1346
- },
1347
- applyAutoBranching(input) {
1348
- return mcpParityClient.applyAutoBranching(input);
1349
- },
1350
- seedBeliefLattice(input = {}) {
1351
- return mcpParityClient.seedBeliefLattice(input);
1352
- },
1353
- getLatticeCoverage(input = {}) {
1354
- return mcpParityClient.getLatticeCoverage(input);
1355
- },
1356
- matchEntityType(input) {
1357
- return ontologiesFacade
1358
- .match(input)
1359
- .then(exposeGatewayData);
1360
- },
1361
- discoverEntityConnections(input) {
1362
- return discoverEntityConnections(input);
1363
- },
1364
- triggerBeliefReview(input) {
1365
- return triggerBeliefReview(input);
1366
- },
1367
- },
1368
- tasks: {
1369
- create(input) {
1370
- return tasksFacade.create({
1371
- topicId: requireTopicId(input),
1372
- title: input.title,
1373
- description: input.description,
1374
- taskType: input.taskType,
1375
- priority: input.priority,
1376
- linkedBeliefId: input.linkedBeliefId,
1377
- linkedQuestionId: input.linkedQuestionId,
1378
- linkedWorktreeId: input.linkedWorktreeId,
1379
- });
1380
- },
1381
- complete(taskId, input) {
1382
- return tasksFacade.complete({
1383
- id: taskId,
1384
- outputSummary: input.outputSummary,
1385
- });
1386
- },
1387
- update(taskId, input) {
1388
- return tasksFacade.update({
1389
- id: taskId,
1390
- title: input.title,
1391
- description: input.description,
1392
- priority: input.priority,
1393
- status: input.status,
1394
- linkedBeliefId: input.linkedBeliefId,
1395
- linkedQuestionId: input.linkedQuestionId,
1396
- linkedWorktreeId: input.linkedWorktreeId,
1397
- });
1398
- },
1399
- list(input) {
1400
- return tasksFacade.list({
1401
- topicId: resolveTopicId(input),
1402
- worktreeId: typeof input.worktreeId === "string"
1403
- ? input.worktreeId
1404
- : typeof input.linkedWorktreeId === "string"
1405
- ? input.linkedWorktreeId
1406
- : undefined,
1407
- status: typeof input.status === "string" ? input.status : undefined,
1408
- limit: typeof input.limit === "number" ? input.limit : undefined,
1409
- });
1410
- },
1411
- },
1412
- topics: {
1413
- list(input = {}) {
1414
- return topicsFacade.list({
1415
- ontologyId: input.ontologyId,
1416
- parentTopicId: input.parentTopicId,
1417
- status: input.status,
1418
- type: input.type,
1419
- });
1420
- },
1421
- get(topicId) {
1422
- return topicsFacade.get(topicId);
1423
- },
1424
- create(input) {
1425
- return topicsFacade.create({
1426
- name: input.name,
1427
- description: input.description,
1428
- type: input.type,
1429
- parentTopicId: input.parentTopicId,
1430
- ontologyId: input.ontologyId,
1431
- tenantId: input.tenantId,
1432
- workspaceId: input.workspaceId,
1433
- visibility: input.visibility,
1434
- createdBy: input.createdBy,
1435
- });
1436
- },
1437
- update(topicId, input) {
1438
- return topicsFacade.update({
1439
- id: topicId,
1440
- name: input.name,
1441
- description: input.description,
1442
- type: input.type,
1443
- ontologyId: input.ontologyId,
1444
- clearOntologyId: input.clearOntologyId,
1445
- status: input.status,
1446
- visibility: input.visibility,
1447
- });
1448
- },
1449
- tree(topicId, query = {}) {
1450
- return topicsFacade.tree({
1451
- id: topicId,
1452
- maxDepth: query.maxDepth,
1453
- });
1454
- },
1455
- getTree(input) {
1456
- return topicsFacade.tree({
1457
- id: input.rootId,
1458
- maxDepth: input.maxDepth,
1459
- });
1460
- },
1461
- coverage(topicId, query = {}) {
1462
- return topicsFacade.coverage({
1463
- id: topicId,
1464
- includeDescendants: query.includeDescendants,
1465
- maxDepth: query.maxDepth,
1466
- });
1467
- },
1468
- remove(topicId, idempotencyKey) {
1469
- return topicsFacade.remove(topicId, idempotencyKey);
1470
- },
1471
- bulkCreate(input, idempotencyKey) {
1472
- return topicsFacade.bulkCreate(input, idempotencyKey);
1473
- },
1474
- },
1475
- answers: {
1476
- create(input) {
1477
- const questionId = typeof input.questionNodeId === "string" ? input.questionNodeId : "";
1478
- if (!questionId) {
1479
- throw new Error("questionNodeId is required");
1480
- }
1481
- const text = typeof input.answerText === "string" ? input.answerText : "";
1482
- if (!text) {
1483
- throw new Error("answerText is required");
1484
- }
1485
- const confidence = input.confidence === "moderate" ? "medium" : input.confidence;
1486
- return questionsFacade.answer(questionId, {
1487
- text,
1488
- confidence: typeof confidence === "string" ? confidence : undefined,
1489
- evidenceIds: Array.isArray(input.evidenceNodeIds)
1490
- ? input.evidenceNodeIds.filter((value) => typeof value === "string")
1491
- : undefined,
1492
- });
1493
- },
1494
- get(input) {
1495
- const questionId = typeof input.questionNodeId === "string" ? input.questionNodeId : "";
1496
- if (!questionId) {
1497
- throw new Error("questionNodeId is required");
1498
- }
1499
- return answersClient.get(questionId);
1500
- },
1501
- },
1502
- contradictions: {
1503
- flag(args) {
1504
- return contradictionsFacade
1505
- .flag({
1506
- beliefA: args.beliefA,
1507
- beliefB: args.beliefB,
1508
- description: args.description,
1509
- topicId: requireTopicId(args),
1510
- severity: args.severity,
1511
- defeatType: args.defeatType,
1512
- })
1513
- .then(exposeGatewayData);
1514
- },
1515
- list(args) {
1516
- return contradictionsFacade
1517
- .list({
1518
- topicId: requireTopicId(args),
1519
- status: args.status,
1520
- limit: args.limit,
1521
- cursor: args.cursor,
1522
- })
1523
- .then(exposeGatewayData);
1524
- },
1525
- get(contradictionId) {
1526
- return contradictionsFacade.get(contradictionId).then(exposeGatewayData);
1527
- },
1528
- find: findContradictions,
1529
- },
1530
- ontologies: {
1531
- list(input = {}) {
1532
- return ontologiesFacade.list(input).then(exposeGatewayData);
1533
- },
1534
- get(ontologyId) {
1535
- return ontologiesFacade
1536
- .get(ontologyId)
1537
- .then((response) => exposeGatewayData(response));
1538
- },
1539
- bind(input, idempotencyKey) {
1540
- return ontologiesFacade
1541
- .bind(input, idempotencyKey)
1542
- .then((response) => exposeGatewayData(response));
1543
- },
1544
- match(input, idempotencyKey) {
1545
- return ontologiesFacade.match(input, idempotencyKey).then(exposeGatewayData);
1546
- },
1547
- create(input) {
1548
- return createOntologyCompat(input);
1549
- },
1550
- update(input) {
1551
- return updateOntologyCompat(input);
1552
- },
1553
- archive(input) {
1554
- return archiveOntologyCompat(input);
1555
- },
1556
- createVersion(input) {
1557
- return createOntologyVersionCompat(input);
1558
- },
1559
- publishVersion(input) {
1560
- return publishOntologyVersionCompat(input);
1561
- },
1562
- deprecateVersion(input) {
1563
- return deprecateOntologyVersionCompat(input);
1564
- },
1565
- resolveEffective(input) {
1566
- return resolveEffectiveOntologyCompat(input);
1567
- },
1568
- raw: ontologyClient,
1569
- },
1570
- coordination: {
1571
- registerSession(input = {}) {
1572
- return mcpParityClient.registerSession(input);
1573
- },
1574
- heartbeatSession(input = {}) {
1575
- return mcpParityClient.heartbeatSession(input);
1576
- },
1577
- endSession(input = {}) {
1578
- return mcpParityClient.endSession(input);
1579
- },
1580
- listActiveSessions(input = {}) {
1581
- return mcpParityClient.listActiveSessions(input);
1582
- },
1583
- sendAgentMessage(input) {
1584
- return mcpParityClient.sendAgentMessage(input);
1585
- },
1586
- broadcastMessage(input) {
1587
- return mcpParityClient.broadcastMessage(input);
1588
- },
1589
- getInbox(input = {}) {
1590
- return mcpParityClient.getAgentInbox(input);
1591
- },
1592
- claimFiles(input) {
1593
- return mcpParityClient.claimFiles(input);
1594
- },
1595
- },
1596
- policy: {
1597
- checkPermission(input) {
1598
- return policyClient.checkPermission({
1599
- topicId: typeof input.topicId === "string" ? input.topicId : undefined,
1600
- permission: typeof input.permission === "string"
1601
- ? input.permission
1602
- : undefined,
1603
- principal: typeof input.principal === "string" ? input.principal : undefined,
1604
- principalId: typeof input.principalId === "string" ? input.principalId : undefined,
1605
- beliefClusterId: typeof input.beliefClusterId === "string"
1606
- ? input.beliefClusterId
1607
- : undefined,
1608
- });
1609
- },
1610
- listAccessibleTopics(input = {}) {
1611
- return policyClient.listAccessibleTopics({
1612
- permission: typeof input.permission === "string"
1613
- ? input.permission
1614
- : undefined,
1615
- includeShared: typeof input.includeShared === "boolean"
1616
- ? input.includeShared
1617
- : undefined,
1618
- principal: typeof input.principal === "string" ? input.principal : undefined,
1619
- principalId: typeof input.principalId === "string" ? input.principalId : undefined,
1620
- limit: typeof input.limit === "number" ? input.limit : undefined,
1621
- });
1622
- },
1623
- filterByPermission(input) {
1624
- return policyClient.filterByPermission({
1625
- topicIds: Array.isArray(input.topicIds)
1626
- ? input.topicIds.filter((value) => typeof value === "string")
1627
- : undefined,
1628
- permission: typeof input.permission === "string"
1629
- ? input.permission
1630
- : undefined,
1631
- principal: typeof input.principal === "string" ? input.principal : undefined,
1632
- principalId: typeof input.principalId === "string" ? input.principalId : undefined,
1633
- });
1634
- },
1635
- manageWritePolicy(input) {
1636
- return mcpParityClient.manageWritePolicy(input);
1637
- },
1638
- raw: policyClient,
1639
- },
1640
- observations: {
1641
- ingest(input) {
1642
- return mcpParityClient.ingestObservation(input);
1643
- },
1644
- getContext(input) {
1645
- return mcpParityClient.getObservationContext(input);
1646
- },
1647
- },
1648
- coding: {
1649
- getCodeContext(input) {
1650
- return mcpParityClient.getCodeContext(input);
1651
- },
1652
- getChangeHistory(input) {
1653
- return mcpParityClient.getChangeHistory(input);
1654
- },
1655
- recordAttempt(input) {
1656
- return mcpParityClient.recordAttempt(input);
1657
- },
1658
- getFailureLog(input) {
1659
- return mcpParityClient.getFailureLog(input);
1660
- },
1661
- },
1662
- contracts: {
1663
- create(input) {
1664
- return createContractCompat(input);
1665
- },
1666
- list(input = {}) {
1667
- return listContractsCompat(input);
1668
- },
1669
- evaluate(input) {
1670
- return evaluateContractCompat(input);
1671
- },
1672
- getStatus(input) {
1673
- return getContractStatusCompat(input);
1674
- },
1675
- },
1676
- bootstrap: {
1677
- generateSessionHandoff(input) {
1678
- return mcpParityClient.generateSessionHandoff(input);
1679
- },
1680
- },
1681
- research: {
1682
- searchSources(args) {
1683
- const topicId = requireTopicId(args);
1684
- return graphClient
1685
- .listNodes({
1686
- topicId,
1687
- nodeType: "source",
1688
- limit: 100,
1689
- })
1690
- .then((response) => {
1691
- const query = args.query.toLowerCase();
1692
- const results = asNodeArray(response.data)
1693
- .filter((node) => {
1694
- const text = `${node.canonicalText ?? ""} ${typeof node.metadata?.title === "string"
1695
- ? node.metadata.title
1696
- : ""}`.toLowerCase();
1697
- if (!text.includes(query)) {
1698
- return false;
1699
- }
1700
- if (!args.sources || args.sources.length === 0) {
1701
- return true;
1702
- }
1703
- const sourceType = typeof node.metadata?.sourceType === "string"
1704
- ? node.metadata.sourceType.toLowerCase()
1705
- : "";
1706
- return args.sources.some((source) => sourceType.includes(source.toLowerCase()));
1707
- })
1708
- .map((node) => ({
1709
- title: typeof node.metadata?.title === "string"
1710
- ? node.metadata.title
1711
- : (node.canonicalText ?? "Untitled source"),
1712
- url: typeof node.metadata?.sourceUrl === "string"
1713
- ? node.metadata.sourceUrl
1714
- : "",
1715
- snippet: node.canonicalText ?? "",
1716
- relevanceScore: 1,
1717
- suggestedEvidence: node.canonicalText ?? "",
1718
- }));
1719
- return { results };
1720
- });
1721
- },
1722
- async executeDeepResearch(args) {
1723
- const sources = await this.searchSources({
1724
- query: args.query,
1725
- topicId: requireTopicId(args),
1726
- sources: ["web"],
1727
- });
1728
- const sampleSize = args.depth === "deep" ? 10 : args.depth === "quick" ? 3 : 5;
1729
- const selected = sources.results.slice(0, sampleSize);
1730
- return {
1731
- report: {
1732
- summary: selected.length > 0
1733
- ? `Research completed for "${args.query}" with ${selected.length} relevant sources.`
1734
- : `No relevant sources found for "${args.query}".`,
1735
- findings: selected.map((source) => ({
1736
- title: source.title,
1737
- summary: source.snippet,
1738
- sourceUrl: source.url,
1739
- })),
1740
- sources: selected.map((source) => ({
1741
- title: source.title,
1742
- url: source.url,
1743
- })),
1744
- linkedEvidence: [],
1745
- linkedQuestions: [],
1746
- },
1747
- };
1748
- },
1749
- },
1750
- tools: {
1751
- register(registration) {
1752
- return registerCustomTool(registration);
1753
- },
1754
- unregister(fullName) {
1755
- return unregisterCustomTool(fullName);
1756
- },
1757
- list() {
1758
- return listRegisteredCustomTools();
1759
- },
1760
- clear() {
1761
- clearRegisteredCustomTools();
1762
- },
1763
- invoke(name, input = {}) {
1764
- const fullName = name.includes(".") ? name : `custom.${name}`;
1765
- return invokeCustomTool(fullName, input);
1766
- },
1767
- namespace(namespace) {
1768
- return getCustomNamespace(namespace);
1769
- },
1770
- },
1771
- packs: {
1772
- /**
1773
- * Ensure the configured packKey is installed.
1774
- * No-op if no packKey was provided or if the pack is already installed.
1775
- * Called automatically on first API use when packKey is set.
1776
- */
1777
- ensurePack,
1778
- /**
1779
- * Check if the configured pack has been installed in this session.
1780
- */
1781
- get isInstalled() {
1782
- return _packInstalled;
1783
- },
1784
- listCatalog() {
1785
- return packsClient.listCatalog();
1786
- },
1787
- catalog() {
1788
- return packsClient.getCatalog();
1789
- },
1790
- listStates(scope) {
1791
- return packsClient.listStates(scope);
1792
- },
1793
- states(scope) {
1794
- return packsClient.getStates(scope);
1795
- },
1796
- install(input) {
1797
- return packsClient.install(input);
1798
- },
1799
- enable(input) {
1800
- return packsClient.enable(input);
1801
- },
1802
- disable(input) {
1803
- return packsClient.disable(input);
1804
- },
1805
- },
1806
- nodes: nodesNamespace,
1807
- identity: identityFacade,
1808
- custom: getCustomNamespace("custom"),
1809
- extensions: extensionNamespaces,
1810
- raw: {
1811
- beliefs: beliefsClient,
1812
- graph: graphClient,
1813
- decisions: decisionsClient,
1814
- workflow: workflowClient,
1815
- audit: auditClient,
1816
- admin: adminClient,
1817
- identity: identityClient,
1818
- policy: policyClient,
1819
- answers: answersClient,
1820
- ontology: ontologyClient,
1821
- mcpParity: mcpParityClient,
1822
- packs: packsClient,
1823
- reports: reportsClient,
1824
- learning: learningClient,
1825
- harness: harnessClient,
1826
- schema: schemaClient,
1827
- audiences: audiencesClient,
1828
- topics: topicsClient,
1829
- },
1830
- };
1831
- }