@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
@@ -0,0 +1,529 @@
1
+ import {
2
+ createGatewayRequestClient,
3
+ type GatewayClientConfig,
4
+ LucernApiError,
5
+ randomIdempotencyKey,
6
+ toQueryString,
7
+ } from "./coreClient";
8
+ import {
9
+ mapAliasedList,
10
+ mapGatewayData,
11
+ normalizeNodeWriteInput,
12
+ normalizeNodeVerificationStatus,
13
+ normalizeTopicQuery,
14
+ withSdkAliases,
15
+ } from "./sdkSurface";
16
+ import type {
17
+ CreateEdgeResponse,
18
+ CreateNodeResponse,
19
+ DeleteEdgeResponse,
20
+ GraphAnalyticsMetric,
21
+ GraphAnalyticsResponse,
22
+ GraphNeighborhoodResponse,
23
+ GraphPathResponse,
24
+ JsonObject,
25
+ ListResult,
26
+ PlatformGraphEdge,
27
+ PlatformGraphNode,
28
+ QueryEdgesResponse,
29
+ QueryNodesResponse,
30
+ TextAliasInput,
31
+ TopicIdentifierInput,
32
+ UpdateNodeResponse,
33
+ } from "./types";
34
+
35
+ export { LucernApiError };
36
+ export type { GatewayScope, PlatformGatewaySuccess } from "./coreClient";
37
+ export type {
38
+ CreateEdgeResponse,
39
+ CreateNodeResponse,
40
+ DeleteEdgeResponse,
41
+ GraphAnalyticsMetric,
42
+ GraphAnalyticsResponse,
43
+ GraphNeighborhoodResponse,
44
+ GraphPathResponse,
45
+ ListResult,
46
+ QueryEdgesResponse,
47
+ QueryNodesResponse,
48
+ UpdateNodeResponse,
49
+ } from "./types";
50
+
51
+ /** Configuration for the graph client. */
52
+ export type GraphClientConfig = GatewayClientConfig;
53
+
54
+ /** Filter parameters for listing graph nodes. */
55
+ export type ListNodesInput = {
56
+ nodeId?: string;
57
+ globalId?: string;
58
+ topicId?: string;
59
+ nodeType?: string;
60
+ limit?: number;
61
+ } & TopicIdentifierInput;
62
+
63
+ /** Paginated list response containing graph nodes. */
64
+ export type ListNodesResponse = ListResult<PlatformGraphNode, "nodes">;
65
+
66
+ /** @deprecated Use ListNodesInput. */
67
+ export type QueryNodesInput = ListNodesInput;
68
+
69
+ /** Input for creating a new graph node. */
70
+ export type CreateNodeInput = {
71
+ text?: string;
72
+ /** @deprecated Use text. */
73
+ canonicalText?: string;
74
+ nodeType: string;
75
+ topicId?: string;
76
+ content?: string;
77
+ contentHash?: string;
78
+ globalId?: string;
79
+ sourceType?: string;
80
+ subtype?: string;
81
+ title?: string;
82
+ confidence?: number;
83
+ status?: string;
84
+ tags?: string[];
85
+ metadata?: JsonObject;
86
+ verificationStatus?: string;
87
+ } & TextAliasInput &
88
+ TopicIdentifierInput;
89
+
90
+ /** Input for updating an existing graph node. */
91
+ export type UpdateNodeInput = {
92
+ nodeId: string;
93
+ text?: string;
94
+ canonicalText?: string;
95
+ content?: string;
96
+ contentHash?: string;
97
+ title?: string;
98
+ subtype?: string;
99
+ confidence?: number;
100
+ status?: string;
101
+ tags?: string[];
102
+ metadata?: JsonObject;
103
+ verificationStatus?: string;
104
+ } & TextAliasInput;
105
+
106
+ /** Input for retrieving a single graph node by canonical identifier. */
107
+ export type GetNodeInput = {
108
+ nodeId?: string;
109
+ globalId?: string;
110
+ };
111
+
112
+ /** Filter parameters for listing graph edges. */
113
+ export type ListEdgesInput = {
114
+ edgeId?: string;
115
+ topicId?: string;
116
+ fromNodeId?: string;
117
+ toNodeId?: string;
118
+ edgeType?: string;
119
+ limit?: number;
120
+ } & TopicIdentifierInput;
121
+
122
+ /** Paginated list response containing graph edges. */
123
+ export type ListEdgesResponse = ListResult<PlatformGraphEdge, "edges">;
124
+
125
+ /** @deprecated Use ListEdgesInput. */
126
+ export type QueryEdgesInput = ListEdgesInput;
127
+
128
+ /** Input for creating a typed edge between two graph nodes. */
129
+ export type CreateEdgeInput = {
130
+ fromNodeId: string;
131
+ toNodeId: string;
132
+ edgeType: string;
133
+ globalId?: string;
134
+ topicId?: string;
135
+ confidence?: number;
136
+ weight?: number;
137
+ context?: string;
138
+ derivationType?: string;
139
+ } & TopicIdentifierInput;
140
+
141
+ /** Filter for selecting edges to delete. */
142
+ export type DeleteEdgeInput = {
143
+ edgeId?: string;
144
+ fromNodeId?: string;
145
+ toNodeId?: string;
146
+ edgeType?: string;
147
+ };
148
+
149
+ /** Input for batch-creating multiple graph nodes. */
150
+ export type BatchCreateNodesInput = {
151
+ nodes: Array<CreateNodeInput>;
152
+ };
153
+
154
+ /** Input for superseding an existing graph node with a new version. */
155
+ export type SupersedeNodeInput = {
156
+ oldNodeId?: string;
157
+ nodeId?: string;
158
+ newGlobalId?: string;
159
+ newCanonicalText?: string;
160
+ text?: string;
161
+ canonicalText?: string;
162
+ newContentHash?: string;
163
+ reason?: string;
164
+ };
165
+
166
+ /** Input for updating a node's verification state. */
167
+ export type VerifyNodeInput = {
168
+ nodeId?: string;
169
+ id?: string;
170
+ verificationStatus: string;
171
+ confidence?: number;
172
+ };
173
+
174
+ /** Input for permanently deleting a node via admin-only API. */
175
+ export type HardDeleteNodeInput = {
176
+ nodeId?: string;
177
+ id?: string;
178
+ reason: string;
179
+ allowBeliefHardDelete?: boolean;
180
+ };
181
+
182
+ /** Input for retrieving the local neighborhood around a graph node. */
183
+ export type NeighborhoodInput = {
184
+ globalId?: string;
185
+ globalIds?: string;
186
+ maxDepth?: number;
187
+ };
188
+
189
+ /** Input for finding the shortest path between two graph nodes. */
190
+ export type PathInput = {
191
+ fromGlobalId: string;
192
+ toGlobalId: string;
193
+ maxDepth?: number;
194
+ };
195
+
196
+ /** Input for retrieving a specific graph analytics metric. */
197
+ export type AnalyticsInput = {
198
+ metric?: GraphAnalyticsMetric;
199
+ limit?: number;
200
+ };
201
+
202
+ /** Input for traversing the graph from a starting node. */
203
+ export type TraverseInput = {
204
+ startNode: string;
205
+ direction?: string;
206
+ maxDepth?: number;
207
+ topicId?: string;
208
+ } & TopicIdentifierInput;
209
+
210
+ /** Input for structural analysis of a topic graph. */
211
+ export type AnalyzeInput = {
212
+ topicId?: string;
213
+ metric?: GraphAnalyticsMetric;
214
+ limit?: number;
215
+ } & TopicIdentifierInput;
216
+
217
+ /** Input for detecting confirmation-bias patterns in a topic graph. */
218
+ export type BiasInput = {
219
+ topicId?: string;
220
+ threshold?: number;
221
+ limit?: number;
222
+ } & TopicIdentifierInput;
223
+
224
+ /** Input for finding beliefs without sufficient testing questions. */
225
+ export type GapsInput = {
226
+ topicId?: string;
227
+ minConfidence?: number;
228
+ } & TopicIdentifierInput;
229
+
230
+ /** Input for cross-resource search within a topic scope. */
231
+ export type SearchInput = {
232
+ q?: string;
233
+ query?: string;
234
+ topicId?: string;
235
+ types?: string[];
236
+ status?: string;
237
+ minConfidence?: number;
238
+ limit?: number;
239
+ cursor?: string;
240
+ } & TopicIdentifierInput;
241
+
242
+ /**
243
+ * Create the low-level graph client for nodes, edges, and graph analytics.
244
+ * @param config - Gateway transport configuration.
245
+ * @returns An object with methods for CRUD on nodes/edges plus analytics, traversal, and search.
246
+ */
247
+ export function createGraphClient(config: GraphClientConfig = {}) {
248
+ const gateway = createGatewayRequestClient(config);
249
+
250
+ return {
251
+ /**
252
+ * List graph nodes matching the provided filters.
253
+ */
254
+ async listNodes(query: ListNodesInput) {
255
+ return gateway.request<ListNodesResponse>({
256
+ path: `/api/platform/v1/graph/nodes${toQueryString(
257
+ normalizeTopicQuery(query)
258
+ )}`,
259
+ }).then((response) =>
260
+ mapGatewayData(response, (data) => mapAliasedList<PlatformGraphNode, "nodes">(data, "nodes"))
261
+ );
262
+ },
263
+
264
+ /**
265
+ * @deprecated Use listNodes.
266
+ */
267
+ async queryNodes(query: QueryNodesInput) {
268
+ return this.listNodes(query);
269
+ },
270
+
271
+ /**
272
+ * Retrieve a single graph node by nodeId or globalId.
273
+ */
274
+ async getNode(query: GetNodeInput) {
275
+ return gateway.request<PlatformGraphNode>({
276
+ path: `/api/platform/v1/graph/nodes${toQueryString(query)}`,
277
+ }).then((response) =>
278
+ mapGatewayData(response, (data) =>
279
+ withSdkAliases(data as Record<string, unknown>) as PlatformGraphNode
280
+ )
281
+ );
282
+ },
283
+
284
+ /**
285
+ * Create a graph node.
286
+ */
287
+ async createNode(input: CreateNodeInput, idempotencyKey?: string) {
288
+ return gateway.request<CreateNodeResponse>({
289
+ path: "/api/platform/v1/graph/nodes",
290
+ method: "POST",
291
+ body: normalizeNodeWriteInput(input),
292
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
293
+ }).then((response) =>
294
+ mapGatewayData(response, (data) =>
295
+ withSdkAliases(data as Record<string, unknown>) as CreateNodeResponse
296
+ )
297
+ );
298
+ },
299
+
300
+ /**
301
+ * Update a graph node.
302
+ */
303
+ async updateNode(input: UpdateNodeInput, idempotencyKey?: string) {
304
+ return gateway.request<UpdateNodeResponse>({
305
+ path: "/api/platform/v1/graph/nodes",
306
+ method: "PUT",
307
+ body: normalizeNodeWriteInput(input as UpdateNodeInput & JsonObject),
308
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
309
+ }).then((response) =>
310
+ mapGatewayData(response, (data) =>
311
+ withSdkAliases(data as Record<string, unknown>) as UpdateNodeResponse
312
+ )
313
+ );
314
+ },
315
+
316
+ /**
317
+ * Batch create graph nodes through the admin route surface.
318
+ */
319
+ async batchCreateNodes(
320
+ input: BatchCreateNodesInput,
321
+ idempotencyKey?: string
322
+ ) {
323
+ return gateway.request<Record<string, unknown>>({
324
+ path: "/api/platform/v1/graph/nodes/batch",
325
+ method: "POST",
326
+ body: {
327
+ nodes: input.nodes.map((node) => normalizeNodeWriteInput(node)),
328
+ } as JsonObject,
329
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
330
+ });
331
+ },
332
+
333
+ /**
334
+ * Supersede an existing graph node with a new canonical version.
335
+ */
336
+ async supersedeNode(input: SupersedeNodeInput, idempotencyKey?: string) {
337
+ return gateway.request<Record<string, unknown>>({
338
+ path: "/api/platform/v1/graph/nodes/supersede",
339
+ method: "POST",
340
+ body: input as JsonObject,
341
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
342
+ });
343
+ },
344
+
345
+ /**
346
+ * Update a node's verification status.
347
+ */
348
+ async verifyNode(input: VerifyNodeInput, idempotencyKey?: string) {
349
+ const verificationStatus =
350
+ normalizeNodeVerificationStatus(input.verificationStatus) ??
351
+ input.verificationStatus;
352
+ return gateway.request<Record<string, unknown>>({
353
+ path: "/api/platform/v1/graph/nodes/verify",
354
+ method: "POST",
355
+ body: {
356
+ ...input,
357
+ verificationStatus,
358
+ } as JsonObject,
359
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
360
+ });
361
+ },
362
+
363
+ /**
364
+ * Permanently delete a node via the admin-only hard-delete route.
365
+ */
366
+ async hardDeleteNode(input: HardDeleteNodeInput, idempotencyKey?: string) {
367
+ return gateway.request<Record<string, unknown>>({
368
+ path: "/api/platform/v1/graph/nodes/hard-delete",
369
+ method: "POST",
370
+ body: input as JsonObject,
371
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
372
+ });
373
+ },
374
+
375
+ /**
376
+ * List graph edges matching the provided filters.
377
+ */
378
+ async listEdges(query: ListEdgesInput) {
379
+ return gateway.request<ListEdgesResponse>({
380
+ path: `/api/platform/v1/graph/edges${toQueryString(
381
+ normalizeTopicQuery(query)
382
+ )}`,
383
+ }).then((response) =>
384
+ mapGatewayData(response, (data) =>
385
+ mapAliasedList<PlatformGraphEdge, "edges">(data, "edges")
386
+ )
387
+ );
388
+ },
389
+
390
+ /**
391
+ * @deprecated Use listEdges.
392
+ */
393
+ async queryEdges(query: QueryEdgesInput) {
394
+ return this.listEdges(query);
395
+ },
396
+
397
+ /**
398
+ * Create a graph edge.
399
+ */
400
+ async createEdge(input: CreateEdgeInput, idempotencyKey?: string) {
401
+ return gateway.request<CreateEdgeResponse>({
402
+ path: "/api/platform/v1/graph/edges",
403
+ method: "POST",
404
+ body: normalizeTopicQuery(input as CreateEdgeInput & JsonObject),
405
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
406
+ });
407
+ },
408
+
409
+ /**
410
+ * Delete one or more edges matching the provided filter.
411
+ */
412
+ async deleteEdge(query: DeleteEdgeInput, idempotencyKey?: string) {
413
+ return gateway.request<DeleteEdgeResponse>({
414
+ path: `/api/platform/v1/graph/edges${toQueryString(query)}`,
415
+ method: "DELETE",
416
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
417
+ });
418
+ },
419
+
420
+ /**
421
+ * Retrieve a graph neighborhood around a root node.
422
+ */
423
+ async neighborhood(query: NeighborhoodInput) {
424
+ return gateway.request<GraphNeighborhoodResponse>({
425
+ path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`,
426
+ });
427
+ },
428
+
429
+ /**
430
+ * Traverse the graph from a starting node.
431
+ */
432
+ async traverse(query: TraverseInput) {
433
+ return gateway.request<Record<string, unknown>>({
434
+ path: "/api/platform/v1/graph/traverse",
435
+ method: "POST",
436
+ body: normalizeTopicQuery(query as TraverseInput & JsonObject),
437
+ });
438
+ },
439
+
440
+ /**
441
+ * Analyze graph structure for a topic.
442
+ */
443
+ async analyze(query: AnalyzeInput = {}) {
444
+ const normalized = normalizeTopicQuery(query as AnalyzeInput & JsonObject);
445
+ return gateway.request<Record<string, unknown>>({
446
+ path: `/api/platform/v1/graph/analyze${toQueryString({
447
+ topicId:
448
+ typeof normalized.topicId === "string" ? normalized.topicId : undefined,
449
+ metric:
450
+ typeof normalized.metric === "string" ? normalized.metric : undefined,
451
+ limit:
452
+ typeof normalized.limit === "number" ? normalized.limit : undefined,
453
+ })}`,
454
+ });
455
+ },
456
+
457
+ /**
458
+ * Detect confirmation-bias patterns for a topic graph.
459
+ */
460
+ async bias(query: BiasInput = {}) {
461
+ const normalized = normalizeTopicQuery(query as BiasInput & JsonObject);
462
+ return gateway.request<Record<string, unknown>>({
463
+ path: `/api/platform/v1/graph/bias${toQueryString({
464
+ topicId:
465
+ typeof normalized.topicId === "string" ? normalized.topicId : undefined,
466
+ threshold:
467
+ typeof normalized.threshold === "number"
468
+ ? normalized.threshold
469
+ : undefined,
470
+ limit:
471
+ typeof normalized.limit === "number" ? normalized.limit : undefined,
472
+ })}`,
473
+ });
474
+ },
475
+
476
+ /**
477
+ * Find graph gaps for beliefs that still need testing.
478
+ */
479
+ async gaps(query: GapsInput) {
480
+ const normalized = normalizeTopicQuery(query as GapsInput & JsonObject);
481
+ return gateway.request<Record<string, unknown>>({
482
+ path: `/api/platform/v1/graph/gaps${toQueryString({
483
+ topicId:
484
+ typeof normalized.topicId === "string" ? normalized.topicId : undefined,
485
+ minConfidence:
486
+ typeof normalized.minConfidence === "number"
487
+ ? normalized.minConfidence
488
+ : undefined,
489
+ })}`,
490
+ });
491
+ },
492
+
493
+ /**
494
+ * Search across graph resources within a topic.
495
+ */
496
+ async search(query: SearchInput) {
497
+ return gateway.request<Record<string, unknown>>({
498
+ path: "/api/platform/v1/search",
499
+ method: "POST",
500
+ body: normalizeTopicQuery(query as SearchInput & JsonObject),
501
+ });
502
+ },
503
+
504
+ /**
505
+ * Retrieve a graph neighborhood around a root node.
506
+ */
507
+ async getNeighborhood(query: NeighborhoodInput) {
508
+ return this.neighborhood(query);
509
+ },
510
+
511
+ /**
512
+ * Retrieve the shortest known path between two graph nodes.
513
+ */
514
+ async getPath(query: PathInput) {
515
+ return gateway.request<GraphPathResponse>({
516
+ path: `/api/platform/v1/graph/path${toQueryString(query)}`,
517
+ });
518
+ },
519
+
520
+ /**
521
+ * Retrieve graph analytics for the requested metric.
522
+ */
523
+ async getAnalytics(query: AnalyticsInput = {}) {
524
+ return gateway.request<GraphAnalyticsResponse>({
525
+ path: `/api/platform/v1/graph/analytics${toQueryString(query)}`,
526
+ });
527
+ },
528
+ };
529
+ }