@lucern/sdk 0.3.0-alpha.2 → 0.3.0-alpha.3

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 (163) hide show
  1. package/dist/adminClient.d.ts +2 -0
  2. package/dist/adminClient.js +194 -3
  3. package/dist/adminClient.js.map +1 -1
  4. package/dist/answersClient.d.ts +2 -0
  5. package/dist/answersClient.js +194 -3
  6. package/dist/answersClient.js.map +1 -1
  7. package/dist/audiencesClient.d.ts +2 -0
  8. package/dist/audiencesClient.js +194 -3
  9. package/dist/audiencesClient.js.map +1 -1
  10. package/dist/auditClient.d.ts +2 -0
  11. package/dist/auditClient.js +196 -5
  12. package/dist/auditClient.js.map +1 -1
  13. package/dist/authContext.d.ts +56 -0
  14. package/dist/authContext.js +169 -0
  15. package/dist/authContext.js.map +1 -0
  16. package/dist/authDeviceClient.d.ts +49 -0
  17. package/dist/authDeviceClient.js +108 -0
  18. package/dist/authDeviceClient.js.map +1 -0
  19. package/dist/beliefs/index.d.ts +19 -2
  20. package/dist/beliefs/index.js +2356 -329
  21. package/dist/beliefs/index.js.map +1 -1
  22. package/dist/beliefsClient.d.ts +2 -0
  23. package/dist/beliefsClient.js +198 -7
  24. package/dist/beliefsClient.js.map +1 -1
  25. package/dist/boundaryClientSurface.d.ts +20 -0
  26. package/dist/boundaryClientSurface.js +66 -0
  27. package/dist/boundaryClientSurface.js.map +1 -0
  28. package/dist/{client-B6aWUUwp.d.ts → client-EiG9nJOY.d.ts} +365 -6
  29. package/dist/client.d.ts +20 -3
  30. package/dist/client.js +2356 -329
  31. package/dist/client.js.map +1 -1
  32. package/dist/contextClient.d.ts +2 -0
  33. package/dist/contextClient.js +200 -9
  34. package/dist/contextClient.js.map +1 -1
  35. package/dist/contracts/index.d.ts +1 -0
  36. package/dist/contracts/index.js +104 -1
  37. package/dist/contracts/index.js.map +1 -1
  38. package/dist/contracts/mcpTools.d.ts +46 -1
  39. package/dist/contracts/mcpTools.js +102 -0
  40. package/dist/contracts/mcpTools.js.map +1 -1
  41. package/dist/contradictions/index.d.ts +19 -2
  42. package/dist/contradictions/index.js +2356 -329
  43. package/dist/contradictions/index.js.map +1 -1
  44. package/dist/coreClient.d.ts +9 -0
  45. package/dist/coreClient.js +194 -3
  46. package/dist/coreClient.js.map +1 -1
  47. package/dist/decisions/index.d.ts +19 -2
  48. package/dist/decisions/index.js +2356 -329
  49. package/dist/decisions/index.js.map +1 -1
  50. package/dist/decisionsClient.d.ts +2 -0
  51. package/dist/decisionsClient.js +197 -6
  52. package/dist/decisionsClient.js.map +1 -1
  53. package/dist/edges/index.d.ts +19 -2
  54. package/dist/edges/index.js +2356 -329
  55. package/dist/edges/index.js.map +1 -1
  56. package/dist/embeddingsClient.d.ts +106 -0
  57. package/dist/embeddingsClient.js +707 -0
  58. package/dist/embeddingsClient.js.map +1 -0
  59. package/dist/eventingClient.d.ts +96 -0
  60. package/dist/eventingClient.js +704 -0
  61. package/dist/eventingClient.js.map +1 -0
  62. package/dist/eventsCore.d.ts +2 -0
  63. package/dist/eventsCore.js +194 -3
  64. package/dist/eventsCore.js.map +1 -1
  65. package/dist/evidence/index.d.ts +19 -2
  66. package/dist/evidence/index.js +2356 -329
  67. package/dist/evidence/index.js.map +1 -1
  68. package/dist/evidenceClient.d.ts +2 -0
  69. package/dist/evidenceClient.js +194 -3
  70. package/dist/evidenceClient.js.map +1 -1
  71. package/dist/gatewayFacades.d.ts +4 -2
  72. package/dist/gatewayFacades.js +370 -12
  73. package/dist/gatewayFacades.js.map +1 -1
  74. package/dist/graphAnalysisClient.d.ts +140 -0
  75. package/dist/graphAnalysisClient.js +753 -0
  76. package/dist/graphAnalysisClient.js.map +1 -0
  77. package/dist/graphClient.d.ts +2 -0
  78. package/dist/graphClient.js +201 -10
  79. package/dist/graphClient.js.map +1 -1
  80. package/dist/graphRecommendationsClient.d.ts +56 -0
  81. package/dist/graphRecommendationsClient.js +645 -0
  82. package/dist/graphRecommendationsClient.js.map +1 -0
  83. package/dist/graphStateClassifierClient.d.ts +73 -0
  84. package/dist/graphStateClassifierClient.js +693 -0
  85. package/dist/graphStateClassifierClient.js.map +1 -0
  86. package/dist/harnessClient.d.ts +2 -0
  87. package/dist/harnessClient.js +196 -5
  88. package/dist/harnessClient.js.map +1 -1
  89. package/dist/identityClient.d.ts +89 -3
  90. package/dist/identityClient.js +362 -4
  91. package/dist/identityClient.js.map +1 -1
  92. package/dist/index.d.ts +20 -3
  93. package/dist/index.js +2516 -356
  94. package/dist/index.js.map +1 -1
  95. package/dist/jobsClient.d.ts +98 -0
  96. package/dist/jobsClient.js +703 -0
  97. package/dist/jobsClient.js.map +1 -0
  98. package/dist/learningClient.d.ts +2 -0
  99. package/dist/learningClient.js +196 -5
  100. package/dist/learningClient.js.map +1 -1
  101. package/dist/lenses/index.d.ts +19 -2
  102. package/dist/lenses/index.js +2356 -329
  103. package/dist/lenses/index.js.map +1 -1
  104. package/dist/mcpClient.d.ts +28 -0
  105. package/dist/mcpClient.js +649 -0
  106. package/dist/mcpClient.js.map +1 -0
  107. package/dist/modelRuntimeClient.d.ts +72 -0
  108. package/dist/modelRuntimeClient.js +680 -0
  109. package/dist/modelRuntimeClient.js.map +1 -0
  110. package/dist/nodes/index.d.ts +19 -2
  111. package/dist/nodes/index.js +2356 -329
  112. package/dist/nodes/index.js.map +1 -1
  113. package/dist/ontologies/index.d.ts +19 -2
  114. package/dist/ontologies/index.js +2356 -329
  115. package/dist/ontologies/index.js.map +1 -1
  116. package/dist/ontologyClient.d.ts +2 -0
  117. package/dist/ontologyClient.js +194 -3
  118. package/dist/ontologyClient.js.map +1 -1
  119. package/dist/ontologyLinksClient.d.ts +71 -0
  120. package/dist/ontologyLinksClient.js +674 -0
  121. package/dist/ontologyLinksClient.js.map +1 -0
  122. package/dist/orgGraphSearchClient.d.ts +85 -0
  123. package/dist/orgGraphSearchClient.js +651 -0
  124. package/dist/orgGraphSearchClient.js.map +1 -0
  125. package/dist/packRuntime.d.ts +1 -2
  126. package/dist/packsClient.d.ts +2 -0
  127. package/dist/packsClient.js +194 -3
  128. package/dist/packsClient.js.map +1 -1
  129. package/dist/policyClient.d.ts +2 -0
  130. package/dist/policyClient.js +194 -3
  131. package/dist/policyClient.js.map +1 -1
  132. package/dist/questions/index.d.ts +19 -2
  133. package/dist/questions/index.js +2356 -329
  134. package/dist/questions/index.js.map +1 -1
  135. package/dist/reportsClient.d.ts +2 -0
  136. package/dist/reportsClient.js +196 -5
  137. package/dist/reportsClient.js.map +1 -1
  138. package/dist/schemaClient.d.ts +2 -0
  139. package/dist/schemaClient.js +194 -3
  140. package/dist/schemaClient.js.map +1 -1
  141. package/dist/sdkSurface.d.ts +2 -0
  142. package/dist/sourcesClient.d.ts +2 -0
  143. package/dist/sourcesClient.js +194 -3
  144. package/dist/sourcesClient.js.map +1 -1
  145. package/dist/telemetryClient.d.ts +94 -0
  146. package/dist/telemetryClient.js +718 -0
  147. package/dist/telemetryClient.js.map +1 -0
  148. package/dist/toolRegistryClient.d.ts +107 -0
  149. package/dist/toolRegistryClient.js +732 -0
  150. package/dist/toolRegistryClient.js.map +1 -0
  151. package/dist/topics/index.d.ts +19 -2
  152. package/dist/topics/index.js +2356 -329
  153. package/dist/topics/index.js.map +1 -1
  154. package/dist/topicsClient.d.ts +2 -0
  155. package/dist/topicsClient.js +199 -8
  156. package/dist/topicsClient.js.map +1 -1
  157. package/dist/workflowClient.d.ts +2 -0
  158. package/dist/workflowClient.js +199 -8
  159. package/dist/workflowClient.js.map +1 -1
  160. package/dist/worktrees/index.d.ts +19 -2
  161. package/dist/worktrees/index.js +2356 -329
  162. package/dist/worktrees/index.js.map +1 -1
  163. package/package.json +3 -3
package/dist/client.js CHANGED
@@ -1,4 +1,171 @@
1
1
  import { z } from 'zod';
2
+ import { MCP_GATEWAY_EVALUATE_RESEARCH_CONTRACT_ENDPOINT, MCP_GATEWAY_EVALUATE_ENGINEERING_CONTRACT_ENDPOINT, MCP_GATEWAY_BEGIN_BUILD_SESSION_ENDPOINT, MCP_GATEWAY_WRITE_POLICY_CHECK_ENDPOINT, MCP_GATEWAY_BOOTSTRAP_ENDPOINT } from '@lucern/contracts/mcp-gateway-boundary.contract';
3
+
4
+ // src/authContext.ts
5
+ var LucernSdkAuthContextError = class extends Error {
6
+ reason;
7
+ constructor(reason, message) {
8
+ super(message);
9
+ this.name = "LucernSdkAuthContextError";
10
+ this.reason = reason;
11
+ }
12
+ };
13
+ function cleanString(value) {
14
+ const normalized = value?.trim();
15
+ return normalized ? normalized : void 0;
16
+ }
17
+ function cleanStringList(values) {
18
+ if (!values) {
19
+ return [];
20
+ }
21
+ return values.map((value) => value.trim()).filter(
22
+ (value, index, list) => value.length > 0 && list.indexOf(value) === index
23
+ );
24
+ }
25
+ function requireString(value, reason, label) {
26
+ const normalized = cleanString(value);
27
+ if (!normalized) {
28
+ throw new LucernSdkAuthContextError(
29
+ reason,
30
+ `Canonical Lucern SDK auth context is missing ${label}.`
31
+ );
32
+ }
33
+ return normalized;
34
+ }
35
+ function requirePrincipalType(principalType) {
36
+ if (!principalType) {
37
+ throw new LucernSdkAuthContextError(
38
+ "principal_missing",
39
+ "Canonical Lucern SDK auth context is missing principalType."
40
+ );
41
+ }
42
+ return principalType;
43
+ }
44
+ function requireAuthMode(authMode) {
45
+ if (!authMode) {
46
+ throw new LucernSdkAuthContextError(
47
+ "principal_missing",
48
+ "Canonical Lucern SDK auth context is missing authMode."
49
+ );
50
+ }
51
+ return authMode;
52
+ }
53
+ function ensurePermitMatch(args) {
54
+ const actual = cleanString(args.actual);
55
+ if (actual && actual !== args.expected) {
56
+ throw new LucernSdkAuthContextError(
57
+ "policy_denied",
58
+ `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
59
+ );
60
+ }
61
+ }
62
+ function normalizeCanonicalLucernAuthContext(input) {
63
+ if (!input) {
64
+ throw new LucernSdkAuthContextError(
65
+ "principal_missing",
66
+ "Canonical Lucern SDK auth context is required."
67
+ );
68
+ }
69
+ if (input.policyDecision === "deny") {
70
+ throw new LucernSdkAuthContextError(
71
+ "policy_denied",
72
+ "Canonical Lucern SDK auth context carries a denied policy decision."
73
+ );
74
+ }
75
+ const principalId = requireString(
76
+ input.principalId,
77
+ "principal_missing",
78
+ "principalId"
79
+ );
80
+ const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
81
+ const workspaceId = requireString(
82
+ input.workspaceId,
83
+ "workspace_missing",
84
+ "workspaceId"
85
+ );
86
+ const roles = cleanStringList(input.roles);
87
+ const scopes = cleanStringList(input.scopes);
88
+ if (roles.length === 0 || scopes.length === 0) {
89
+ throw new LucernSdkAuthContextError(
90
+ "membership_missing",
91
+ "Canonical Lucern SDK auth context requires non-empty roles and scopes."
92
+ );
93
+ }
94
+ const principalType = requirePrincipalType(input.principalType);
95
+ const authMode = requireAuthMode(input.authMode);
96
+ const subject = cleanString(input.permit?.subject) ?? principalId;
97
+ const tenant = cleanString(input.permit?.tenant) ?? tenantId;
98
+ const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
99
+ ensurePermitMatch({
100
+ field: "subject",
101
+ expected: principalId,
102
+ actual: subject
103
+ });
104
+ ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
105
+ ensurePermitMatch({
106
+ field: "workspace",
107
+ expected: workspaceId,
108
+ actual: workspace
109
+ });
110
+ const context = input.permit?.context ? { ...input.permit.context } : void 0;
111
+ return {
112
+ clerkId: cleanString(input.clerkId),
113
+ principalId,
114
+ tenantId,
115
+ workspaceId,
116
+ principalType,
117
+ authMode,
118
+ roles,
119
+ scopes,
120
+ delegationChain: input.delegationChain ? [...input.delegationChain] : [],
121
+ policyTraceId: cleanString(input.policyTraceId),
122
+ correlationId: cleanString(input.correlationId),
123
+ membershipId: cleanString(input.membershipId),
124
+ permit: {
125
+ subject,
126
+ tenant,
127
+ workspace,
128
+ resource: cleanString(input.permit?.resource),
129
+ action: cleanString(input.permit?.action),
130
+ relation: cleanString(input.permit?.relation),
131
+ context
132
+ }
133
+ };
134
+ }
135
+ function createCanonicalAuthHeaders(authContext) {
136
+ const headers = {
137
+ "x-lucern-principal-id": authContext.principalId,
138
+ "x-lucern-principal-type": authContext.principalType,
139
+ "x-lucern-tenant": authContext.tenantId,
140
+ "x-lucern-tenant-id": authContext.tenantId,
141
+ "x-lucern-workspace": authContext.workspaceId,
142
+ "x-lucern-workspace-id": authContext.workspaceId,
143
+ "x-lucern-auth-mode": authContext.authMode,
144
+ "x-lucern-roles": authContext.roles.join(","),
145
+ "x-lucern-scopes": authContext.scopes.join(","),
146
+ "x-lucern-permit-context": JSON.stringify(authContext.permit)
147
+ };
148
+ if (authContext.clerkId) {
149
+ headers["x-lucern-clerk-id"] = authContext.clerkId;
150
+ headers["x-lucern-user-id"] = authContext.clerkId;
151
+ }
152
+ if (authContext.delegationChain.length > 0) {
153
+ headers["x-lucern-delegation-chain"] = JSON.stringify(
154
+ authContext.delegationChain
155
+ );
156
+ }
157
+ if (authContext.policyTraceId) {
158
+ headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
159
+ }
160
+ if (authContext.correlationId) {
161
+ headers["x-correlation-id"] = authContext.correlationId;
162
+ headers["x-lucern-correlation-id"] = authContext.correlationId;
163
+ }
164
+ if (authContext.membershipId) {
165
+ headers["x-lucern-membership-id"] = authContext.membershipId;
166
+ }
167
+ return headers;
168
+ }
2
169
 
3
170
  // src/coreClient.ts
4
171
  var LucernApiError = class extends Error {
@@ -156,16 +323,41 @@ function readPolicySummaryFromDetails(details) {
156
323
  }
157
324
  return null;
158
325
  }
326
+ async function resolveConfiguredAuthContext(authContext) {
327
+ if (typeof authContext === "function") {
328
+ return await authContext();
329
+ }
330
+ return authContext;
331
+ }
332
+ function mergeHeaderRecord(base, addition) {
333
+ const headers = new Headers(base);
334
+ for (const [key, value] of Object.entries(addition)) {
335
+ const existing = headers.get(key);
336
+ if (existing !== null && existing !== value) {
337
+ throw new LucernSdkAuthContextError(
338
+ "policy_denied",
339
+ `Canonical Lucern SDK auth context conflicts with existing ${key} header.`
340
+ );
341
+ }
342
+ headers.set(key, value);
343
+ }
344
+ return Object.fromEntries(headers.entries());
345
+ }
159
346
  function createGatewayRequestClient(config = {}) {
160
347
  const fetchImpl = config.fetchImpl ?? fetch;
161
348
  const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
162
349
  const maxRetries = config.maxRetries ?? 2;
163
350
  const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
164
351
  async function resolveAuthHeaders() {
165
- if (!config.getAuthHeaders) {
166
- return {};
352
+ const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
353
+ const authContextInput = await resolveConfiguredAuthContext(
354
+ config.authContext
355
+ );
356
+ if (!authContextInput && !config.requireCanonicalAuthContext) {
357
+ return base;
167
358
  }
168
- return await config.getAuthHeaders();
359
+ const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
360
+ return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
169
361
  }
170
362
  async function fetchWithTimeout(url, init, timeoutMs) {
171
363
  const controller = new AbortController();
@@ -340,11 +532,11 @@ function createGatewayRequestClient(config = {}) {
340
532
  function asRecord(value) {
341
533
  return value && typeof value === "object" ? value : {};
342
534
  }
343
- function cleanString(value) {
535
+ function cleanString2(value) {
344
536
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
345
537
  }
346
538
  function normalizeVerificationStatus(value) {
347
- const status = cleanString(value);
539
+ const status = cleanString2(value);
348
540
  if (!status) {
349
541
  return void 0;
350
542
  }
@@ -360,20 +552,20 @@ function cloneWith(value, patch) {
360
552
  return { ...value, ...patch };
361
553
  }
362
554
  function resolveTopicId(value) {
363
- return cleanString(value.topicId);
555
+ return cleanString2(value.topicId);
364
556
  }
365
557
  function resolveText(value) {
366
- return cleanString(value.text) ?? cleanString(value.canonicalText);
558
+ return cleanString2(value.text) ?? cleanString2(value.canonicalText);
367
559
  }
368
560
  function withTopicAlias(value) {
369
- const topicId = cleanString(value.topicId) ?? void 0;
561
+ const topicId = cleanString2(value.topicId) ?? void 0;
370
562
  if (!topicId) {
371
563
  return value;
372
564
  }
373
565
  return cloneWith(value, { topicId });
374
566
  }
375
567
  function withTextAlias(value) {
376
- const text = cleanString(value.text) ?? cleanString(value.canonicalText) ?? void 0;
568
+ const text = cleanString2(value.text) ?? cleanString2(value.canonicalText) ?? void 0;
377
569
  if (!text) {
378
570
  return value;
379
571
  }
@@ -403,7 +595,7 @@ function normalizeNodeVerificationStatus(value) {
403
595
  return normalizeVerificationStatus(value);
404
596
  }
405
597
  function normalizeTopicQuery(value) {
406
- const topicId = cleanString(value.topicId);
598
+ const topicId = cleanString2(value.topicId);
407
599
  if (!topicId) {
408
600
  return value;
409
601
  }
@@ -476,9 +668,9 @@ function createAdminClient(config = {}) {
476
668
  /**
477
669
  * List tenants visible to the current principal.
478
670
  */
479
- async listTenants(query = {}) {
671
+ async listTenants(query5 = {}) {
480
672
  return gateway.request({
481
- path: `/api/platform/v1/tenants${toQueryString(query)}`
673
+ path: `/api/platform/v1/tenants${toQueryString(query5)}`
482
674
  }).then(
483
675
  (response) => mapGatewayData(
484
676
  response,
@@ -519,9 +711,9 @@ function createAdminClient(config = {}) {
519
711
  /**
520
712
  * List workspaces for the current admin scope.
521
713
  */
522
- async listWorkspaces(query = {}) {
714
+ async listWorkspaces(query5 = {}) {
523
715
  return gateway.request({
524
- path: `/api/platform/v1/workspaces${toQueryString(query)}`
716
+ path: `/api/platform/v1/workspaces${toQueryString(query5)}`
525
717
  }).then(
526
718
  (response) => mapGatewayData(
527
719
  response,
@@ -546,9 +738,9 @@ function createAdminClient(config = {}) {
546
738
  /**
547
739
  * List memberships for the current admin scope.
548
740
  */
549
- async listMemberships(query = {}) {
741
+ async listMemberships(query5 = {}) {
550
742
  return gateway.request({
551
- path: `/api/platform/v1/memberships${toQueryString(query)}`
743
+ path: `/api/platform/v1/memberships${toQueryString(query5)}`
552
744
  }).then(
553
745
  (response) => mapGatewayData(
554
746
  response,
@@ -785,9 +977,9 @@ function createAdminClient(config = {}) {
785
977
  /**
786
978
  * List group members.
787
979
  */
788
- async listGroupMembers(query) {
980
+ async listGroupMembers(query5) {
789
981
  return gateway.request({
790
- path: `/api/platform/v1/groups/members${toQueryString(query)}`
982
+ path: `/api/platform/v1/groups/members${toQueryString(query5)}`
791
983
  });
792
984
  },
793
985
  /**
@@ -814,9 +1006,9 @@ function createAdminClient(config = {}) {
814
1006
  /**
815
1007
  * List pack-to-group assignments.
816
1008
  */
817
- async listPackGroupAssignments(query = {}) {
1009
+ async listPackGroupAssignments(query5 = {}) {
818
1010
  return gateway.request({
819
- path: `/api/platform/v1/groups/packs${toQueryString(query)}`
1011
+ path: `/api/platform/v1/groups/packs${toQueryString(query5)}`
820
1012
  });
821
1013
  },
822
1014
  /**
@@ -867,12 +1059,12 @@ function createAudiencesClient(config = {}) {
867
1059
  /**
868
1060
  * List audience registry entries.
869
1061
  */
870
- async listRegistry(query = {}) {
1062
+ async listRegistry(query5 = {}) {
871
1063
  return gateway.request({
872
1064
  path: `/api/platform/v1/audiences/registry${toQueryString({
873
- ...query,
874
- effective: typeof query.effective === "boolean" ? query.effective ? "true" : "false" : void 0,
875
- status: query.status
1065
+ ...query5,
1066
+ effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1067
+ status: query5.status
876
1068
  })}`
877
1069
  }).then(
878
1070
  (response) => mapGatewayData(
@@ -887,8 +1079,8 @@ function createAudiencesClient(config = {}) {
887
1079
  /**
888
1080
  * @deprecated Use listRegistry.
889
1081
  */
890
- async getRegistry(query = {}) {
891
- return this.listRegistry(query);
1082
+ async getRegistry(query5 = {}) {
1083
+ return this.listRegistry(query5);
892
1084
  },
893
1085
  /**
894
1086
  * Create an audience registry entry.
@@ -916,14 +1108,14 @@ function createAudiencesClient(config = {}) {
916
1108
  /**
917
1109
  * List audience grants.
918
1110
  */
919
- async listGrants(query = {}) {
1111
+ async listGrants(query5 = {}) {
920
1112
  return gateway.request({
921
1113
  path: `/api/platform/v1/audiences/grants${toQueryString({
922
- ...query,
923
- audienceKey: query.audienceKey,
924
- principalId: query.principalId,
925
- groupId: query.groupId,
926
- status: query.status
1114
+ ...query5,
1115
+ audienceKey: query5.audienceKey,
1116
+ principalId: query5.principalId,
1117
+ groupId: query5.groupId,
1118
+ status: query5.status
927
1119
  })}`
928
1120
  }).then(
929
1121
  (response) => mapGatewayData(
@@ -935,8 +1127,8 @@ function createAudiencesClient(config = {}) {
935
1127
  /**
936
1128
  * @deprecated Use listGrants.
937
1129
  */
938
- async getGrants(query = {}) {
939
- return this.listGrants(query);
1130
+ async getGrants(query5 = {}) {
1131
+ return this.listGrants(query5);
940
1132
  },
941
1133
  /**
942
1134
  * Create an audience grant.
@@ -982,10 +1174,10 @@ function createAuditClient(config = {}) {
982
1174
  /**
983
1175
  * List audit events for the current scope.
984
1176
  */
985
- async listEvents(query = {}) {
1177
+ async listEvents(query5 = {}) {
986
1178
  return gateway.request({
987
1179
  path: `/api/platform/v1/audit/events${toQueryString(
988
- normalizeTopicQuery(query)
1180
+ normalizeTopicQuery(query5)
989
1181
  )}`
990
1182
  }).then(
991
1183
  (response) => mapGatewayData(
@@ -997,11 +1189,116 @@ function createAuditClient(config = {}) {
997
1189
  };
998
1190
  }
999
1191
 
1192
+ // src/authDeviceClient.ts
1193
+ var DeviceAuthorizationError = class extends Error {
1194
+ error;
1195
+ interval;
1196
+ constructor(args) {
1197
+ super(args.description ?? args.error);
1198
+ this.name = "DeviceAuthorizationError";
1199
+ this.error = args.error;
1200
+ this.interval = args.interval;
1201
+ }
1202
+ };
1203
+ function authBaseUrl(config) {
1204
+ return config.baseUrl?.replace(/\/+$/, "") ?? "";
1205
+ }
1206
+ async function readJson(response) {
1207
+ const payload = await response.json().catch(() => ({}));
1208
+ return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
1209
+ }
1210
+ function readString(value) {
1211
+ const normalized = typeof value === "string" ? value.trim() : "";
1212
+ return normalized || void 0;
1213
+ }
1214
+ function assertDeviceCodeResponse(payload) {
1215
+ const deviceCode = readString(payload.device_code);
1216
+ const userCode = readString(payload.user_code);
1217
+ const verificationUri = readString(payload.verification_uri);
1218
+ const verificationUriComplete = readString(payload.verification_uri_complete);
1219
+ const expiresIn = payload.expires_in;
1220
+ const interval = payload.interval;
1221
+ if (!deviceCode || !userCode || !verificationUri || !verificationUriComplete || typeof expiresIn !== "number" || typeof interval !== "number") {
1222
+ throw new Error("Gateway returned an invalid device-code response.");
1223
+ }
1224
+ return {
1225
+ device_code: deviceCode,
1226
+ user_code: userCode,
1227
+ verification_uri: verificationUri,
1228
+ verification_uri_complete: verificationUriComplete,
1229
+ expires_in: expiresIn,
1230
+ interval
1231
+ };
1232
+ }
1233
+ function assertDeviceTokenResponse(payload) {
1234
+ const accessToken = readString(payload.access_token);
1235
+ const tokenType = readString(payload.token_type);
1236
+ const scope = readString(payload.scope);
1237
+ const tenantId = readString(payload.tenant_id);
1238
+ const principalId = readString(payload.principal_id);
1239
+ if (!accessToken || tokenType !== "Bearer" || typeof payload.expires_in !== "number" || !scope || !tenantId || !principalId) {
1240
+ throw new Error("Gateway returned an invalid device token response.");
1241
+ }
1242
+ return {
1243
+ access_token: accessToken,
1244
+ token_type: "Bearer",
1245
+ expires_in: payload.expires_in,
1246
+ scope,
1247
+ tenant_id: tenantId,
1248
+ workspace_id: readString(payload.workspace_id),
1249
+ principal_id: principalId,
1250
+ user: payload.user && typeof payload.user === "object" && !Array.isArray(payload.user) ? payload.user : void 0
1251
+ };
1252
+ }
1253
+ function maybeThrowDeviceError(payload) {
1254
+ const error = readString(payload.error);
1255
+ throw new DeviceAuthorizationError({
1256
+ error: error ?? "invalid_request",
1257
+ description: readString(payload.error_description),
1258
+ interval: typeof payload.interval === "number" ? payload.interval : void 0
1259
+ });
1260
+ }
1261
+ function createAuthDeviceClient(config = {}) {
1262
+ const fetchImpl = config.fetchImpl ?? fetch;
1263
+ const baseUrl = authBaseUrl(config);
1264
+ async function post(path, body4) {
1265
+ return fetchImpl(`${baseUrl}${path}`, {
1266
+ method: "POST",
1267
+ headers: { "content-type": "application/json" },
1268
+ body: JSON.stringify(body4)
1269
+ });
1270
+ }
1271
+ return {
1272
+ async createDeviceCode(input = {}) {
1273
+ const response = await post("/api/platform/v1/auth/device/code", {
1274
+ client_id: input.clientId ?? "lucern-cli",
1275
+ scope: input.scope ?? "graph.read graph.write"
1276
+ });
1277
+ const payload = await readJson(response);
1278
+ if (!response.ok) {
1279
+ maybeThrowDeviceError(payload);
1280
+ }
1281
+ return assertDeviceCodeResponse(payload);
1282
+ },
1283
+ async pollDeviceToken(deviceCode) {
1284
+ const response = await post("/api/platform/v1/auth/device/token", {
1285
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
1286
+ device_code: deviceCode
1287
+ });
1288
+ const payload = await readJson(response);
1289
+ if (!response.ok) {
1290
+ maybeThrowDeviceError(payload);
1291
+ }
1292
+ return assertDeviceTokenResponse(payload);
1293
+ }
1294
+ };
1295
+ }
1296
+
1000
1297
  // src/beliefsClient.ts
1001
1298
  function asRecord2(value) {
1002
1299
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1003
1300
  }
1004
- function readString(value) {
1301
+ function readString2(value) {
1005
1302
  if (typeof value !== "string") {
1006
1303
  return void 0;
1007
1304
  }
@@ -1038,15 +1335,15 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1038
1335
  const record = asRecord2(value);
1039
1336
  const tuple = normalizeOpinionTuple(record);
1040
1337
  const projected = readNumber(record.confidence) ?? clamp01(tuple.b + tuple.a * tuple.u);
1041
- const triggeringEvidenceId = readString(record.triggeringEvidenceId);
1042
- const triggeringQuestionId = readString(record.triggeringQuestionId);
1043
- const triggeringAnswerId = readString(record.triggeringAnswerId);
1044
- const triggeringContradictionId = readString(
1338
+ const triggeringEvidenceId = readString2(record.triggeringEvidenceId);
1339
+ const triggeringQuestionId = readString2(record.triggeringQuestionId);
1340
+ const triggeringAnswerId = readString2(record.triggeringAnswerId);
1341
+ const triggeringContradictionId = readString2(
1045
1342
  record.triggeringContradictionId
1046
1343
  );
1047
- const triggeringWorktreeId = readString(record.triggeringWorktreeId);
1344
+ const triggeringWorktreeId = readString2(record.triggeringWorktreeId);
1048
1345
  const triggeringRef = triggeringEvidenceId ? { kind: "evidence", id: triggeringEvidenceId } : triggeringQuestionId ? { kind: "question", id: triggeringQuestionId } : triggeringAnswerId ? { kind: "answer", id: triggeringAnswerId } : triggeringContradictionId ? { kind: "contradiction", id: triggeringContradictionId } : triggeringWorktreeId ? { kind: "worktree", id: triggeringWorktreeId } : void 0;
1049
- const trigger = readString(record.trigger);
1346
+ const trigger = readString2(record.trigger);
1050
1347
  if (!trigger) {
1051
1348
  throw new Error("Gateway opinion history entries must include trigger.");
1052
1349
  }
@@ -1059,9 +1356,9 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1059
1356
  P: clamp01(projected),
1060
1357
  trigger,
1061
1358
  ...triggeringRef ? { triggeringRef } : {},
1062
- ...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
1063
- ...readString(record.userId) ? { userId: readString(record.userId) } : {},
1064
- ...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
1359
+ ...readString2(record.rationale) ? { rationale: readString2(record.rationale) } : {},
1360
+ ...readString2(record.userId) ? { userId: readString2(record.userId) } : {},
1361
+ ...readString2(record.slOperator) ? { slOperator: readString2(record.slOperator) } : {}
1065
1362
  };
1066
1363
  }).sort((left, right) => left.t - right.t);
1067
1364
  }
@@ -1296,6 +1593,180 @@ function createEvidenceClient(config = {}) {
1296
1593
  }
1297
1594
  };
1298
1595
  }
1596
+
1597
+ // src/boundaryClientSurface.ts
1598
+ function cleanOptionalString(value) {
1599
+ const normalized = value?.trim();
1600
+ return normalized ? normalized : void 0;
1601
+ }
1602
+ function cleanRequiredString(value, label) {
1603
+ const normalized = cleanOptionalString(value);
1604
+ if (!normalized) {
1605
+ throw new Error(`${label} is required`);
1606
+ }
1607
+ return normalized;
1608
+ }
1609
+ function readTopicId(input) {
1610
+ return cleanOptionalString(input.topicId) ?? cleanOptionalString(input.projectId);
1611
+ }
1612
+ function requireTopicId(input) {
1613
+ const topicId = readTopicId(input);
1614
+ if (!topicId) {
1615
+ throw new Error("topicId is required");
1616
+ }
1617
+ return topicId;
1618
+ }
1619
+ function assertKnownKeys(input, allowed, operation) {
1620
+ const allowedSet = new Set(allowed);
1621
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
1622
+ if (unknownKeys.length > 0) {
1623
+ throw new Error(
1624
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
1625
+ );
1626
+ }
1627
+ }
1628
+ function knownPayload(input, allowed, operation) {
1629
+ assertKnownKeys(input, allowed, operation);
1630
+ return { ...input };
1631
+ }
1632
+ function topicPayload(input, allowed, operation) {
1633
+ assertKnownKeys(input, allowed, operation);
1634
+ return {
1635
+ ...input,
1636
+ topicId: requireTopicId(input),
1637
+ projectId: void 0
1638
+ };
1639
+ }
1640
+ function listResultFromEnvelope(data, legacyKey) {
1641
+ const record = data && typeof data === "object" ? data : {};
1642
+ return createListResult(
1643
+ Array.isArray(record[legacyKey]) ? record[legacyKey] : Array.isArray(data) ? data : [],
1644
+ legacyKey
1645
+ );
1646
+ }
1647
+
1648
+ // src/eventingClient.ts
1649
+ var EVENTING_FIELDS = [
1650
+ "tenantId",
1651
+ "workspaceId",
1652
+ "principalId",
1653
+ "topicId",
1654
+ "eventId",
1655
+ "eventType",
1656
+ "eventPayload",
1657
+ "webhookId",
1658
+ "deliveryId",
1659
+ "status",
1660
+ "attempt",
1661
+ "statusCode",
1662
+ "error",
1663
+ "responseBody",
1664
+ "durationMs",
1665
+ "metadata",
1666
+ "limit",
1667
+ "cursor"
1668
+ ];
1669
+ function query(input) {
1670
+ return {
1671
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
1672
+ workspaceId: input.workspaceId,
1673
+ principalId: input.principalId,
1674
+ topicId: input.topicId,
1675
+ eventType: input.eventType,
1676
+ webhookId: input.webhookId,
1677
+ status: input.status,
1678
+ limit: input.limit,
1679
+ cursor: input.cursor
1680
+ };
1681
+ }
1682
+ function body(input, operation) {
1683
+ return knownPayload(input, EVENTING_FIELDS, operation);
1684
+ }
1685
+ function createEventingClient(config = {}) {
1686
+ const gateway = createGatewayRequestClient(config);
1687
+ return {
1688
+ recordEvent(input, idempotencyKey) {
1689
+ cleanRequiredString(input.tenantId, "tenantId");
1690
+ cleanRequiredString(input.eventType, "eventType");
1691
+ return gateway.request({
1692
+ path: "/api/platform/v1/events",
1693
+ method: "POST",
1694
+ body: body(
1695
+ input,
1696
+ "events.recordEvent"
1697
+ ),
1698
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1699
+ });
1700
+ },
1701
+ listEvents(input) {
1702
+ return gateway.request({
1703
+ path: `/api/platform/v1/events${toQueryString(query(input))}`
1704
+ }).then(
1705
+ (response) => mapGatewayData(
1706
+ response,
1707
+ (data) => listResultFromEnvelope(data, "events")
1708
+ )
1709
+ );
1710
+ },
1711
+ listWebhooks(input) {
1712
+ return gateway.request({
1713
+ path: `/api/platform/v1/webhooks${toQueryString(query(input))}`
1714
+ }).then(
1715
+ (response) => mapGatewayData(
1716
+ response,
1717
+ (data) => listResultFromEnvelope(
1718
+ data,
1719
+ "webhooks"
1720
+ )
1721
+ )
1722
+ );
1723
+ },
1724
+ enqueueDelivery(input, idempotencyKey) {
1725
+ cleanRequiredString(input.tenantId, "tenantId");
1726
+ cleanRequiredString(input.eventId, "eventId");
1727
+ cleanRequiredString(input.webhookId, "webhookId");
1728
+ return gateway.request({
1729
+ path: "/api/platform/v1/events/deliveries",
1730
+ method: "POST",
1731
+ body: body(
1732
+ input,
1733
+ "events.enqueueDelivery"
1734
+ ),
1735
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1736
+ });
1737
+ },
1738
+ recordDeliveryAttempt(input, idempotencyKey) {
1739
+ cleanRequiredString(input.tenantId, "tenantId");
1740
+ cleanRequiredString(input.deliveryId, "deliveryId");
1741
+ return gateway.request({
1742
+ path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
1743
+ input.deliveryId
1744
+ )}/attempts`,
1745
+ method: "POST",
1746
+ body: body(
1747
+ input,
1748
+ "events.recordDeliveryAttempt"
1749
+ ),
1750
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1751
+ });
1752
+ },
1753
+ updateDeliveryStatus(input, idempotencyKey) {
1754
+ cleanRequiredString(input.tenantId, "tenantId");
1755
+ cleanRequiredString(input.deliveryId, "deliveryId");
1756
+ return gateway.request({
1757
+ path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
1758
+ input.deliveryId
1759
+ )}/status`,
1760
+ method: "PATCH",
1761
+ body: body(
1762
+ input,
1763
+ "events.updateDeliveryStatus"
1764
+ ),
1765
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1766
+ });
1767
+ }
1768
+ };
1769
+ }
1299
1770
  var DEFAULT_CUSTOM_NAMESPACE = "custom";
1300
1771
  var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
1301
1772
  var CustomToolRegistryError = class extends Error {
@@ -1701,10 +2172,10 @@ function createGraphClient(config = {}) {
1701
2172
  /**
1702
2173
  * List graph nodes matching the provided filters.
1703
2174
  */
1704
- async listNodes(query) {
2175
+ async listNodes(query5) {
1705
2176
  return gateway.request({
1706
2177
  path: `/api/platform/v1/graph/nodes${toQueryString(
1707
- normalizeTopicQuery(query)
2178
+ normalizeTopicQuery(query5)
1708
2179
  )}`
1709
2180
  }).then(
1710
2181
  (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
@@ -1713,15 +2184,15 @@ function createGraphClient(config = {}) {
1713
2184
  /**
1714
2185
  * @deprecated Use listNodes.
1715
2186
  */
1716
- async queryNodes(query) {
1717
- return this.listNodes(query);
2187
+ async queryNodes(query5) {
2188
+ return this.listNodes(query5);
1718
2189
  },
1719
2190
  /**
1720
2191
  * Retrieve a single graph node by nodeId or globalId.
1721
2192
  */
1722
- async getNode(query) {
2193
+ async getNode(query5) {
1723
2194
  return gateway.request({
1724
- path: `/api/platform/v1/graph/nodes${toQueryString(query)}`
2195
+ path: `/api/platform/v1/graph/nodes${toQueryString(query5)}`
1725
2196
  }).then(
1726
2197
  (response) => mapGatewayData(
1727
2198
  response,
@@ -1814,10 +2285,10 @@ function createGraphClient(config = {}) {
1814
2285
  /**
1815
2286
  * List graph edges matching the provided filters.
1816
2287
  */
1817
- async listEdges(query) {
2288
+ async listEdges(query5) {
1818
2289
  return gateway.request({
1819
2290
  path: `/api/platform/v1/graph/edges${toQueryString(
1820
- normalizeTopicQuery(query)
2291
+ normalizeTopicQuery(query5)
1821
2292
  )}`
1822
2293
  }).then(
1823
2294
  (response) => mapGatewayData(
@@ -1829,8 +2300,8 @@ function createGraphClient(config = {}) {
1829
2300
  /**
1830
2301
  * @deprecated Use listEdges.
1831
2302
  */
1832
- async queryEdges(query) {
1833
- return this.listEdges(query);
2303
+ async queryEdges(query5) {
2304
+ return this.listEdges(query5);
1834
2305
  },
1835
2306
  /**
1836
2307
  * Create a graph edge.
@@ -1846,9 +2317,9 @@ function createGraphClient(config = {}) {
1846
2317
  /**
1847
2318
  * Delete one or more edges matching the provided filter.
1848
2319
  */
1849
- async deleteEdge(query, idempotencyKey) {
2320
+ async deleteEdge(query5, idempotencyKey) {
1850
2321
  return gateway.request({
1851
- path: `/api/platform/v1/graph/edges${toQueryString(query)}`,
2322
+ path: `/api/platform/v1/graph/edges${toQueryString(query5)}`,
1852
2323
  method: "DELETE",
1853
2324
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1854
2325
  });
@@ -1856,26 +2327,26 @@ function createGraphClient(config = {}) {
1856
2327
  /**
1857
2328
  * Retrieve a graph neighborhood around a root node.
1858
2329
  */
1859
- async neighborhood(query) {
2330
+ async neighborhood(query5) {
1860
2331
  return gateway.request({
1861
- path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`
2332
+ path: `/api/platform/v1/graph/neighborhood${toQueryString(query5)}`
1862
2333
  });
1863
2334
  },
1864
2335
  /**
1865
2336
  * Traverse the graph from a starting node.
1866
2337
  */
1867
- async traverse(query) {
2338
+ async traverse(query5) {
1868
2339
  return gateway.request({
1869
2340
  path: "/api/platform/v1/graph/traverse",
1870
2341
  method: "POST",
1871
- body: normalizeTopicQuery(query)
2342
+ body: normalizeTopicQuery(query5)
1872
2343
  });
1873
2344
  },
1874
2345
  /**
1875
2346
  * Analyze graph structure for a topic.
1876
2347
  */
1877
- async analyze(query = {}) {
1878
- const normalized = normalizeTopicQuery(query);
2348
+ async analyze(query5 = {}) {
2349
+ const normalized = normalizeTopicQuery(query5);
1879
2350
  return gateway.request({
1880
2351
  path: `/api/platform/v1/graph/analyze${toQueryString({
1881
2352
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -1887,8 +2358,8 @@ function createGraphClient(config = {}) {
1887
2358
  /**
1888
2359
  * Detect confirmation-bias patterns for a topic graph.
1889
2360
  */
1890
- async bias(query = {}) {
1891
- const normalized = normalizeTopicQuery(query);
2361
+ async bias(query5 = {}) {
2362
+ const normalized = normalizeTopicQuery(query5);
1892
2363
  return gateway.request({
1893
2364
  path: `/api/platform/v1/graph/bias${toQueryString({
1894
2365
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -1900,8 +2371,8 @@ function createGraphClient(config = {}) {
1900
2371
  /**
1901
2372
  * Find graph gaps for beliefs that still need testing.
1902
2373
  */
1903
- async gaps(query) {
1904
- const normalized = normalizeTopicQuery(query);
2374
+ async gaps(query5) {
2375
+ const normalized = normalizeTopicQuery(query5);
1905
2376
  return gateway.request({
1906
2377
  path: `/api/platform/v1/graph/gaps${toQueryString({
1907
2378
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -1912,33 +2383,33 @@ function createGraphClient(config = {}) {
1912
2383
  /**
1913
2384
  * Search across graph resources within a topic.
1914
2385
  */
1915
- async search(query) {
2386
+ async search(query5) {
1916
2387
  return gateway.request({
1917
2388
  path: "/api/platform/v1/search",
1918
2389
  method: "POST",
1919
- body: normalizeTopicQuery(query)
2390
+ body: normalizeTopicQuery(query5)
1920
2391
  });
1921
2392
  },
1922
2393
  /**
1923
2394
  * Retrieve a graph neighborhood around a root node.
1924
2395
  */
1925
- async getNeighborhood(query) {
1926
- return this.neighborhood(query);
2396
+ async getNeighborhood(query5) {
2397
+ return this.neighborhood(query5);
1927
2398
  },
1928
2399
  /**
1929
2400
  * Retrieve the shortest known path between two graph nodes.
1930
2401
  */
1931
- async getPath(query) {
2402
+ async getPath(query5) {
1932
2403
  return gateway.request({
1933
- path: `/api/platform/v1/graph/path${toQueryString(query)}`
2404
+ path: `/api/platform/v1/graph/path${toQueryString(query5)}`
1934
2405
  });
1935
2406
  },
1936
2407
  /**
1937
2408
  * Retrieve graph analytics for the requested metric.
1938
2409
  */
1939
- async getAnalytics(query = {}) {
2410
+ async getAnalytics(query5 = {}) {
1940
2411
  return gateway.request({
1941
- path: `/api/platform/v1/graph/analytics${toQueryString(query)}`
2412
+ path: `/api/platform/v1/graph/analytics${toQueryString(query5)}`
1942
2413
  });
1943
2414
  }
1944
2415
  };
@@ -1955,6 +2426,37 @@ function createIdentityWhoamiClient(config = {}) {
1955
2426
  }
1956
2427
  };
1957
2428
  }
2429
+ var TENANT_IDENTITY_FIELDS = [
2430
+ "tenantId",
2431
+ "workspaceId",
2432
+ "principalId",
2433
+ "integrationKey",
2434
+ "secretRef",
2435
+ "policySubject",
2436
+ "policyAction",
2437
+ "policyResource",
2438
+ "decision",
2439
+ "config",
2440
+ "configKey",
2441
+ "configValue",
2442
+ "provider",
2443
+ "status",
2444
+ "metadata",
2445
+ "limit",
2446
+ "cursor"
2447
+ ];
2448
+ function tenantIdentityQuery(input) {
2449
+ return {
2450
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
2451
+ workspaceId: input.workspaceId,
2452
+ principalId: input.principalId,
2453
+ limit: input.limit,
2454
+ cursor: input.cursor
2455
+ };
2456
+ }
2457
+ function tenantIdentityBody(input, operation) {
2458
+ return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
2459
+ }
1958
2460
  function createIdentityClient(config = {}) {
1959
2461
  const gateway = createGatewayRequestClient(config);
1960
2462
  const whoamiClient = createIdentityWhoamiClient(config);
@@ -1990,9 +2492,9 @@ function createIdentityClient(config = {}) {
1990
2492
  /**
1991
2493
  * List principals in the current identity scope.
1992
2494
  */
1993
- async listPrincipals(query = {}) {
2495
+ async listPrincipals(query5 = {}) {
1994
2496
  return gateway.request({
1995
- path: `/api/platform/v1/identity/principals${toQueryString(query)}`
2497
+ path: `/api/platform/v1/identity/principals${toQueryString(query5)}`
1996
2498
  }).then(
1997
2499
  (response) => mapGatewayData(
1998
2500
  response,
@@ -2024,9 +2526,9 @@ function createIdentityClient(config = {}) {
2024
2526
  /**
2025
2527
  * List keys in the current identity scope.
2026
2528
  */
2027
- async listKeys(query = {}) {
2529
+ async listKeys(query5 = {}) {
2028
2530
  return gateway.request({
2029
- path: `/api/platform/v1/identity/keys${toQueryString(query)}`
2531
+ path: `/api/platform/v1/identity/keys${toQueryString(query5)}`
2030
2532
  }).then(
2031
2533
  (response) => mapGatewayData(
2032
2534
  response,
@@ -2080,6 +2582,109 @@ function createIdentityClient(config = {}) {
2080
2582
  return gateway.request({
2081
2583
  path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
2082
2584
  });
2585
+ },
2586
+ async getTenantConfig(input) {
2587
+ return gateway.request({
2588
+ path: `/api/platform/v1/identity/tenant-config${toQueryString(
2589
+ tenantIdentityQuery(input)
2590
+ )}`
2591
+ });
2592
+ },
2593
+ async updateTenantConfig(input, idempotencyKey) {
2594
+ cleanRequiredString(input.tenantId, "tenantId");
2595
+ return gateway.request({
2596
+ path: "/api/platform/v1/identity/tenant-config",
2597
+ method: "PATCH",
2598
+ body: tenantIdentityBody(
2599
+ input,
2600
+ "identity.updateTenantConfig"
2601
+ ),
2602
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2603
+ });
2604
+ },
2605
+ async listIntegrations(input) {
2606
+ return gateway.request({
2607
+ path: `/api/platform/v1/identity/integrations${toQueryString(
2608
+ tenantIdentityQuery(input)
2609
+ )}`
2610
+ }).then(
2611
+ (response) => mapGatewayData(
2612
+ response,
2613
+ (data) => listResultFromEnvelope(
2614
+ data,
2615
+ "integrations"
2616
+ )
2617
+ )
2618
+ );
2619
+ },
2620
+ async upsertIntegration(input, idempotencyKey) {
2621
+ cleanRequiredString(input.tenantId, "tenantId");
2622
+ cleanRequiredString(input.integrationKey, "integrationKey");
2623
+ return gateway.request({
2624
+ path: "/api/platform/v1/identity/integrations",
2625
+ method: "PUT",
2626
+ body: tenantIdentityBody(
2627
+ input,
2628
+ "identity.upsertIntegration"
2629
+ ),
2630
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2631
+ });
2632
+ },
2633
+ async listSecrets(input) {
2634
+ return gateway.request({
2635
+ path: `/api/platform/v1/identity/secrets${toQueryString(
2636
+ tenantIdentityQuery(input)
2637
+ )}`
2638
+ }).then(
2639
+ (response) => mapGatewayData(
2640
+ response,
2641
+ (data) => listResultFromEnvelope(
2642
+ data,
2643
+ "secrets"
2644
+ )
2645
+ )
2646
+ );
2647
+ },
2648
+ async putSecretReference(input, idempotencyKey) {
2649
+ cleanRequiredString(input.tenantId, "tenantId");
2650
+ cleanRequiredString(input.secretRef, "secretRef");
2651
+ return gateway.request({
2652
+ path: "/api/platform/v1/identity/secrets",
2653
+ method: "PUT",
2654
+ body: tenantIdentityBody(
2655
+ input,
2656
+ "identity.putSecretReference"
2657
+ ),
2658
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2659
+ });
2660
+ },
2661
+ async evaluatePolicy(input, idempotencyKey) {
2662
+ cleanRequiredString(input.tenantId, "tenantId");
2663
+ cleanRequiredString(input.policySubject, "policySubject");
2664
+ cleanRequiredString(input.policyAction, "policyAction");
2665
+ cleanRequiredString(input.policyResource, "policyResource");
2666
+ return gateway.request({
2667
+ path: "/api/platform/v1/identity/policy/evaluate",
2668
+ method: "POST",
2669
+ body: tenantIdentityBody(
2670
+ input,
2671
+ "identity.evaluatePolicy"
2672
+ ),
2673
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2674
+ });
2675
+ },
2676
+ async recordPolicyDecision(input, idempotencyKey) {
2677
+ cleanRequiredString(input.tenantId, "tenantId");
2678
+ cleanRequiredString(input.decision, "decision");
2679
+ return gateway.request({
2680
+ path: "/api/platform/v1/identity/policy/decisions",
2681
+ method: "POST",
2682
+ body: tenantIdentityBody(
2683
+ input,
2684
+ "identity.recordPolicyDecision"
2685
+ ),
2686
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2687
+ });
2083
2688
  }
2084
2689
  };
2085
2690
  }
@@ -2088,12 +2693,12 @@ function createIdentityClient(config = {}) {
2088
2693
  function asRecord3(value) {
2089
2694
  return value && typeof value === "object" ? value : {};
2090
2695
  }
2091
- function cleanString2(value) {
2696
+ function cleanString3(value) {
2092
2697
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
2093
2698
  }
2094
2699
  function normalizeTopicRecord(value) {
2095
2700
  const record = asRecord3(value);
2096
- const topicId = cleanString2(record.topicId) ?? cleanString2(record.id) ?? cleanString2(record._id);
2701
+ const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
2097
2702
  return withTopicAlias({
2098
2703
  ...record,
2099
2704
  ...topicId ? { topicId } : {}
@@ -2105,15 +2710,15 @@ function normalizeTopicTreeNode(value) {
2105
2710
  function createTopicsClient(config = {}) {
2106
2711
  const gateway = createGatewayRequestClient(config);
2107
2712
  return {
2108
- async list(query = {}) {
2109
- const topicId = resolveTopicId(query);
2713
+ async list(query5 = {}) {
2714
+ const topicId = resolveTopicId(query5);
2110
2715
  return gateway.request({
2111
2716
  path: `/api/platform/v1/topics${toQueryString({
2112
2717
  ...topicId ? { topicId } : {},
2113
- ontologyId: query.ontologyId,
2114
- parentTopicId: query.parentTopicId,
2115
- status: query.status,
2116
- type: query.type
2718
+ ontologyId: query5.ontologyId,
2719
+ parentTopicId: query5.parentTopicId,
2720
+ status: query5.status,
2721
+ type: query5.type
2117
2722
  })}`
2118
2723
  }).then(
2119
2724
  (response) => mapGatewayData(response, (data) => {
@@ -2163,10 +2768,10 @@ function createTopicsClient(config = {}) {
2163
2768
  (response) => mapGatewayData(response, (data) => normalizeTopicRecord(data))
2164
2769
  );
2165
2770
  },
2166
- async getTree(topicId, query = {}) {
2771
+ async getTree(topicId, query5 = {}) {
2167
2772
  return gateway.request({
2168
2773
  path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/tree${toQueryString(
2169
- query
2774
+ query5
2170
2775
  )}`
2171
2776
  }).then(
2172
2777
  (response) => mapGatewayData(response, (data) => {
@@ -2177,10 +2782,10 @@ function createTopicsClient(config = {}) {
2177
2782
  })
2178
2783
  );
2179
2784
  },
2180
- async getCoverage(topicId, query = {}) {
2785
+ async getCoverage(topicId, query5 = {}) {
2181
2786
  return gateway.request({
2182
2787
  path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/coverage${toQueryString(
2183
- query
2788
+ query5
2184
2789
  )}`
2185
2790
  });
2186
2791
  },
@@ -2240,15 +2845,15 @@ function createBeliefsFacade(config = {}) {
2240
2845
  path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`
2241
2846
  });
2242
2847
  },
2243
- async list(query) {
2848
+ async list(query5) {
2244
2849
  return gateway.request({
2245
2850
  path: `/api/platform/v1/beliefs${toQueryString({
2246
- topicId: query.topicId,
2247
- status: query.status,
2248
- worktreeId: query.worktreeId,
2249
- minConfidence: query.minConfidence,
2250
- limit: query.limit,
2251
- cursor: query.cursor
2851
+ topicId: query5.topicId,
2852
+ status: query5.status,
2853
+ worktreeId: query5.worktreeId,
2854
+ minConfidence: query5.minConfidence,
2855
+ limit: query5.limit,
2856
+ cursor: query5.cursor
2252
2857
  })}`
2253
2858
  });
2254
2859
  },
@@ -2384,13 +2989,13 @@ function createContradictionsFacade(config = {}) {
2384
2989
  idempotencyKey
2385
2990
  });
2386
2991
  },
2387
- async list(query) {
2992
+ async list(query5) {
2388
2993
  return gateway.request({
2389
2994
  path: `/api/platform/v1/contradictions${toQueryString({
2390
- topicId: query.topicId,
2391
- status: query.status,
2392
- limit: query.limit,
2393
- cursor: query.cursor
2995
+ topicId: query5.topicId,
2996
+ status: query5.status,
2997
+ limit: query5.limit,
2998
+ cursor: query5.cursor
2394
2999
  })}`
2395
3000
  });
2396
3001
  },
@@ -2412,13 +3017,13 @@ function createEdgesFacade(config = {}) {
2412
3017
  idempotencyKey
2413
3018
  });
2414
3019
  },
2415
- async list(query) {
3020
+ async list(query5) {
2416
3021
  return gateway.request({
2417
3022
  path: `/api/platform/v1/edges${toQueryString({
2418
- sourceId: query.sourceId,
2419
- edgeType: query.edgeType,
2420
- limit: query.limit,
2421
- cursor: query.cursor
3023
+ sourceId: query5.sourceId,
3024
+ edgeType: query5.edgeType,
3025
+ limit: query5.limit,
3026
+ cursor: query5.cursor
2422
3027
  })}`
2423
3028
  });
2424
3029
  },
@@ -2488,13 +3093,13 @@ function createEvidenceFacade(config = {}) {
2488
3093
  path: `/api/platform/v1/evidence/${encodeURIComponent(id)}`
2489
3094
  });
2490
3095
  },
2491
- async list(query) {
3096
+ async list(query5) {
2492
3097
  return gateway.request({
2493
3098
  path: `/api/platform/v1/evidence${toQueryString({
2494
- topicId: query.topicId,
2495
- targetId: query.targetId,
2496
- limit: query.limit,
2497
- cursor: query.cursor
3099
+ topicId: query5.topicId,
3100
+ targetId: query5.targetId,
3101
+ limit: query5.limit,
3102
+ cursor: query5.cursor
2498
3103
  })}`
2499
3104
  });
2500
3105
  },
@@ -2511,11 +3116,11 @@ function createEvidenceFacade(config = {}) {
2511
3116
  idempotencyKey
2512
3117
  });
2513
3118
  },
2514
- async search(query, idempotencyKey = randomIdempotencyKey()) {
3119
+ async search(query5, idempotencyKey = randomIdempotencyKey()) {
2515
3120
  return gateway.request({
2516
3121
  path: "/api/platform/v1/evidence/search",
2517
3122
  method: "POST",
2518
- body: query,
3123
+ body: query5,
2519
3124
  idempotencyKey
2520
3125
  });
2521
3126
  },
@@ -2564,15 +3169,15 @@ function createEvidenceFacade(config = {}) {
2564
3169
  function createEventsFacade(config = {}) {
2565
3170
  const gateway = createGatewayRequestClient(config);
2566
3171
  return {
2567
- async list(query = {}) {
3172
+ async list(query5 = {}) {
2568
3173
  return gateway.request({
2569
3174
  path: `/api/platform/v1/events${toQueryString({
2570
- topicId: query.topicId,
2571
- after: query.after,
2572
- types: serializeTypes(query.types),
2573
- startTime: query.startTime,
2574
- endTime: query.endTime,
2575
- limit: query.limit
3175
+ topicId: query5.topicId,
3176
+ after: query5.after,
3177
+ types: serializeTypes(query5.types),
3178
+ startTime: query5.startTime,
3179
+ endTime: query5.endTime,
3180
+ limit: query5.limit
2576
3181
  })}`
2577
3182
  });
2578
3183
  },
@@ -2637,8 +3242,8 @@ function createOntologiesFacade(config = {}) {
2637
3242
  path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2638
3243
  });
2639
3244
  },
2640
- async list(query = {}) {
2641
- return ontologyClient.list(query);
3245
+ async list(query5 = {}) {
3246
+ return ontologyClient.list(query5);
2642
3247
  },
2643
3248
  async bind(input, idempotencyKey) {
2644
3249
  return gateway.request({
@@ -2676,15 +3281,15 @@ function createQuestionsFacade(config = {}) {
2676
3281
  path: `/api/platform/v1/questions/${encodeURIComponent(id)}`
2677
3282
  });
2678
3283
  },
2679
- async list(query) {
3284
+ async list(query5) {
2680
3285
  return gateway.request({
2681
3286
  path: `/api/platform/v1/questions${toQueryString({
2682
- topicId: query.topicId,
2683
- status: query.status,
2684
- priority: query.priority,
2685
- worktreeId: query.worktreeId,
2686
- limit: query.limit,
2687
- cursor: query.cursor
3287
+ topicId: query5.topicId,
3288
+ status: query5.status,
3289
+ priority: query5.priority,
3290
+ worktreeId: query5.worktreeId,
3291
+ limit: query5.limit,
3292
+ cursor: query5.cursor
2688
3293
  })}`
2689
3294
  });
2690
3295
  },
@@ -2836,13 +3441,13 @@ function createTasksFacade(config = {}) {
2836
3441
  idempotencyKey
2837
3442
  });
2838
3443
  },
2839
- async list(query) {
3444
+ async list(query5) {
2840
3445
  return gateway.request({
2841
3446
  path: `/api/platform/v1/tasks${toQueryString({
2842
- topicId: query.topicId,
2843
- worktreeId: query.worktreeId,
2844
- status: query.status,
2845
- limit: query.limit
3447
+ topicId: query5.topicId,
3448
+ worktreeId: query5.worktreeId,
3449
+ status: query5.status,
3450
+ limit: query5.limit
2846
3451
  })}`
2847
3452
  });
2848
3453
  }
@@ -2857,8 +3462,8 @@ function createTopicsFacade(config = {}) {
2857
3462
  async get(id) {
2858
3463
  return topicsClient.get(id);
2859
3464
  },
2860
- async list(query = {}) {
2861
- return topicsClient.list(query);
3465
+ async list(query5 = {}) {
3466
+ return topicsClient.list(query5);
2862
3467
  },
2863
3468
  async update(input, idempotencyKey) {
2864
3469
  const { id, ...rest } = input;
@@ -2894,10 +3499,10 @@ function createWebhooksFacade(config = {}) {
2894
3499
  idempotencyKey
2895
3500
  });
2896
3501
  },
2897
- async list(query = {}) {
3502
+ async list(query5 = {}) {
2898
3503
  return gateway.request({
2899
3504
  path: `/api/platform/v1/webhooks${toQueryString({
2900
- topicId: query.topicId
3505
+ topicId: query5.topicId
2901
3506
  })}`
2902
3507
  });
2903
3508
  },
@@ -2929,10 +3534,10 @@ function createWebhooksFacade(config = {}) {
2929
3534
  idempotencyKey
2930
3535
  });
2931
3536
  },
2932
- async deliveries(id, query = {}) {
3537
+ async deliveries(id, query5 = {}) {
2933
3538
  return gateway.request({
2934
3539
  path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
2935
- limit: query.limit
3540
+ limit: query5.limit
2936
3541
  })}`
2937
3542
  });
2938
3543
  },
@@ -2954,24 +3559,24 @@ function createWorktreesFacade(config = {}) {
2954
3559
  idempotencyKey
2955
3560
  });
2956
3561
  },
2957
- async list(query) {
3562
+ async list(query5) {
2958
3563
  return gateway.request({
2959
3564
  path: `/api/platform/v1/worktrees${toQueryString({
2960
- topicId: query.topicId,
2961
- status: query.status,
2962
- groupBy: query.groupBy,
2963
- lane: query.lane,
2964
- campaign: query.campaign,
2965
- limit: query.limit
3565
+ topicId: query5.topicId,
3566
+ status: query5.status,
3567
+ groupBy: query5.groupBy,
3568
+ lane: query5.lane,
3569
+ campaign: query5.campaign,
3570
+ limit: query5.limit
2966
3571
  })}`
2967
3572
  });
2968
3573
  },
2969
- async listCampaigns(query = {}) {
3574
+ async listCampaigns(query5 = {}) {
2970
3575
  return gateway.request({
2971
3576
  path: `/api/platform/v1/worktrees/campaigns${toQueryString({
2972
- topicId: query.topicId,
2973
- status: query.status,
2974
- limit: query.limit
3577
+ topicId: query5.topicId,
3578
+ status: query5.status,
3579
+ limit: query5.limit
2975
3580
  })}`
2976
3581
  });
2977
3582
  },
@@ -3084,12 +3689,12 @@ function createDecisionsClient(config = {}) {
3084
3689
  /**
3085
3690
  * List judgments for a topic scope.
3086
3691
  */
3087
- async listJudgments(query) {
3692
+ async listJudgments(query5) {
3088
3693
  return gateway.request({
3089
3694
  path: `/api/platform/v1/graph/judgments${toQueryString({
3090
- ...normalizeTopicQuery(query),
3091
- includeArchived: typeof query.includeArchived === "boolean" ? query.includeArchived ? "true" : "false" : void 0,
3092
- limit: query.limit
3695
+ ...normalizeTopicQuery(query5),
3696
+ includeArchived: typeof query5.includeArchived === "boolean" ? query5.includeArchived ? "true" : "false" : void 0,
3697
+ limit: query5.limit
3093
3698
  })}`
3094
3699
  }).then(
3095
3700
  (response) => mapGatewayData(response, (data) => {
@@ -3121,30 +3726,30 @@ function createDecisionsClient(config = {}) {
3121
3726
  /**
3122
3727
  * Get readiness signals for creating a judgment.
3123
3728
  */
3124
- async getJudgmentReadiness(query) {
3729
+ async getJudgmentReadiness(query5) {
3125
3730
  return gateway.request({
3126
3731
  path: `/api/platform/v1/graph/judgments/readiness${toQueryString(
3127
- normalizeTopicQuery(query)
3732
+ normalizeTopicQuery(query5)
3128
3733
  )}`
3129
3734
  });
3130
3735
  },
3131
3736
  /**
3132
3737
  * Get calibration analytics for judgment outcomes.
3133
3738
  */
3134
- async getJudgmentCalibration(query) {
3739
+ async getJudgmentCalibration(query5) {
3135
3740
  return gateway.request({
3136
3741
  path: `/api/platform/v1/graph/judgments/calibration${toQueryString(
3137
- normalizeTopicQuery(query)
3742
+ normalizeTopicQuery(query5)
3138
3743
  )}`
3139
3744
  });
3140
3745
  },
3141
3746
  /**
3142
3747
  * List judgments still awaiting outcome review.
3143
3748
  */
3144
- async listPendingOutcomeReviews(query) {
3749
+ async listPendingOutcomeReviews(query5) {
3145
3750
  return gateway.request({
3146
3751
  path: `/api/platform/v1/graph/judgments/pending-outcome-review${toQueryString(
3147
- normalizeTopicQuery(query)
3752
+ normalizeTopicQuery(query5)
3148
3753
  )}`
3149
3754
  }).then(
3150
3755
  (response) => mapGatewayData(response, (data) => {
@@ -3161,19 +3766,19 @@ function createDecisionsClient(config = {}) {
3161
3766
  /**
3162
3767
  * @deprecated Use listPendingOutcomeReviews.
3163
3768
  */
3164
- async listPendingJudgmentOutcomeReview(query) {
3165
- return this.listPendingOutcomeReviews(query);
3769
+ async listPendingJudgmentOutcomeReview(query5) {
3770
+ return this.listPendingOutcomeReviews(query5);
3166
3771
  },
3167
3772
  /**
3168
3773
  * Get audit integrity checks for judgment transitions.
3169
3774
  */
3170
- async getJudgmentTransitionAuditIntegrity(query) {
3775
+ async getJudgmentTransitionAuditIntegrity(query5) {
3171
3776
  return gateway.request({
3172
3777
  path: `/api/platform/v1/graph/judgments/transition-audit-integrity${toQueryString(
3173
3778
  {
3174
- ...normalizeTopicQuery(query),
3175
- judgmentId: query.judgmentId,
3176
- includePassing: typeof query.includePassing === "boolean" ? query.includePassing ? "true" : "false" : void 0
3779
+ ...normalizeTopicQuery(query5),
3780
+ judgmentId: query5.judgmentId,
3781
+ includePassing: typeof query5.includePassing === "boolean" ? query5.includePassing ? "true" : "false" : void 0
3177
3782
  }
3178
3783
  )}`
3179
3784
  });
@@ -3222,58 +3827,170 @@ function createDecisionsClient(config = {}) {
3222
3827
  };
3223
3828
  }
3224
3829
 
3225
- // src/contextClient.ts
3226
- function cleanString3(value) {
3227
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
3228
- }
3229
- function cleanNumber(value) {
3230
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
3830
+ // src/embeddingsClient.ts
3831
+ var EMBEDDINGS_FIELDS = [
3832
+ "topicId",
3833
+ "projectId",
3834
+ "workspaceId",
3835
+ "nodeIds",
3836
+ "nodeType",
3837
+ "embeddingModel",
3838
+ "queryText",
3839
+ "queryVector",
3840
+ "minScore",
3841
+ "limit",
3842
+ "cursor",
3843
+ "metadata"
3844
+ ];
3845
+ function assertNodeIds(nodeIds) {
3846
+ if (!Array.isArray(nodeIds) || nodeIds.length === 0) {
3847
+ throw new Error("nodeIds is required");
3848
+ }
3231
3849
  }
3232
- function cleanBoolean(value) {
3233
- return typeof value === "boolean" ? value : void 0;
3850
+ function missingQuery(input) {
3851
+ return {
3852
+ topicId: requireTopicId(input),
3853
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId"),
3854
+ nodeType: input.nodeType,
3855
+ embeddingModel: input.embeddingModel,
3856
+ limit: input.limit,
3857
+ cursor: input.cursor
3858
+ };
3234
3859
  }
3235
- function buildCompileContextRequest(topicId, input = {}) {
3236
- const payload = { topicId };
3237
- const query = cleanString3(input.query);
3238
- if (query) {
3239
- payload.query = query;
3240
- }
3241
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3242
- if (budget !== void 0) {
3243
- payload.budget = budget;
3244
- }
3245
- const ranking = cleanString3(input.ranking) ?? cleanString3(input.rankingProfile);
3246
- if (ranking) {
3247
- payload.ranking = ranking;
3248
- }
3249
- const limit = cleanNumber(input.limit);
3250
- if (limit !== void 0) {
3251
- payload.limit = limit;
3252
- }
3253
- const maxDepth = cleanNumber(input.maxDepth);
3254
- if (maxDepth !== void 0) {
3255
- payload.maxDepth = maxDepth;
3256
- }
3257
- const includeEntities = cleanBoolean(input.includeEntities);
3258
- if (includeEntities !== void 0) {
3259
- payload.includeEntities = includeEntities;
3260
- }
3261
- const mode = cleanString3(input.mode);
3262
- if (mode) {
3263
- payload.mode = mode;
3264
- }
3265
- const includeFailures = cleanBoolean(input.includeFailures);
3266
- if (includeFailures !== void 0) {
3267
- payload.includeFailures = includeFailures;
3268
- }
3269
- const worktreeId = cleanString3(input.worktreeId);
3270
- if (worktreeId) {
3271
- payload.worktreeId = worktreeId;
3272
- }
3273
- const sessionId = cleanString3(input.sessionId);
3274
- if (sessionId) {
3275
- payload.sessionId = sessionId;
3276
- }
3860
+ function createEmbeddingsClient(config = {}) {
3861
+ const gateway = createGatewayRequestClient(config);
3862
+ return {
3863
+ getByNodeIds(input) {
3864
+ assertNodeIds(input.nodeIds);
3865
+ return gateway.request({
3866
+ path: "/api/platform/v1/embeddings/by-node-ids",
3867
+ method: "POST",
3868
+ body: topicPayload(
3869
+ {
3870
+ ...input,
3871
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
3872
+ },
3873
+ EMBEDDINGS_FIELDS,
3874
+ "embeddings.getByNodeIds"
3875
+ )
3876
+ }).then(
3877
+ (response) => mapGatewayData(
3878
+ response,
3879
+ (data) => listResultFromEnvelope(
3880
+ data,
3881
+ "embeddings"
3882
+ )
3883
+ )
3884
+ );
3885
+ },
3886
+ listMissingForTopic(input) {
3887
+ return gateway.request({
3888
+ path: `/api/platform/v1/embeddings/missing${toQueryString(
3889
+ missingQuery(input)
3890
+ )}`
3891
+ }).then(
3892
+ (response) => mapGatewayData(
3893
+ response,
3894
+ (data) => listResultFromEnvelope(
3895
+ data,
3896
+ "nodes"
3897
+ )
3898
+ )
3899
+ );
3900
+ },
3901
+ vectorSearchByTopic(input) {
3902
+ if (!input.queryText && !input.queryVector) {
3903
+ throw new Error("queryText or queryVector is required");
3904
+ }
3905
+ return gateway.request({
3906
+ path: "/api/platform/v1/embeddings/vector-search",
3907
+ method: "POST",
3908
+ body: topicPayload(
3909
+ {
3910
+ ...input,
3911
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
3912
+ },
3913
+ EMBEDDINGS_FIELDS,
3914
+ "embeddings.vectorSearchByTopic"
3915
+ )
3916
+ }).then(
3917
+ (response) => mapGatewayData(
3918
+ response,
3919
+ (data) => listResultFromEnvelope(data, "results")
3920
+ )
3921
+ );
3922
+ },
3923
+ markEmbeddingBackfillQueued(input, idempotencyKey) {
3924
+ assertNodeIds(input.nodeIds);
3925
+ return gateway.request({
3926
+ path: "/api/platform/v1/embeddings/backfill-queued",
3927
+ method: "POST",
3928
+ body: topicPayload(
3929
+ {
3930
+ ...input,
3931
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
3932
+ },
3933
+ EMBEDDINGS_FIELDS,
3934
+ "embeddings.markEmbeddingBackfillQueued"
3935
+ ),
3936
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3937
+ });
3938
+ }
3939
+ };
3940
+ }
3941
+
3942
+ // src/contextClient.ts
3943
+ function cleanString4(value) {
3944
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
3945
+ }
3946
+ function cleanNumber(value) {
3947
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
3948
+ }
3949
+ function cleanBoolean(value) {
3950
+ return typeof value === "boolean" ? value : void 0;
3951
+ }
3952
+ function buildCompileContextRequest(topicId, input = {}) {
3953
+ const payload = { topicId };
3954
+ const query5 = cleanString4(input.query);
3955
+ if (query5) {
3956
+ payload.query = query5;
3957
+ }
3958
+ const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3959
+ if (budget !== void 0) {
3960
+ payload.budget = budget;
3961
+ }
3962
+ const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
3963
+ if (ranking) {
3964
+ payload.ranking = ranking;
3965
+ }
3966
+ const limit = cleanNumber(input.limit);
3967
+ if (limit !== void 0) {
3968
+ payload.limit = limit;
3969
+ }
3970
+ const maxDepth = cleanNumber(input.maxDepth);
3971
+ if (maxDepth !== void 0) {
3972
+ payload.maxDepth = maxDepth;
3973
+ }
3974
+ const includeEntities = cleanBoolean(input.includeEntities);
3975
+ if (includeEntities !== void 0) {
3976
+ payload.includeEntities = includeEntities;
3977
+ }
3978
+ const mode = cleanString4(input.mode);
3979
+ if (mode) {
3980
+ payload.mode = mode;
3981
+ }
3982
+ const includeFailures = cleanBoolean(input.includeFailures);
3983
+ if (includeFailures !== void 0) {
3984
+ payload.includeFailures = includeFailures;
3985
+ }
3986
+ const worktreeId = cleanString4(input.worktreeId);
3987
+ if (worktreeId) {
3988
+ payload.worktreeId = worktreeId;
3989
+ }
3990
+ const sessionId = cleanString4(input.sessionId);
3991
+ if (sessionId) {
3992
+ payload.sessionId = sessionId;
3993
+ }
3277
3994
  if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
3278
3995
  payload.packWeightOverrides = input.packWeightOverrides;
3279
3996
  }
@@ -3302,6 +4019,406 @@ function createContextClient(config = {}) {
3302
4019
  };
3303
4020
  }
3304
4021
 
4022
+ // src/graphAnalysisClient.ts
4023
+ var GRAPH_ANALYSIS_ANALYSIS_FIELDS = [
4024
+ "topicId",
4025
+ "projectId",
4026
+ "workspaceId",
4027
+ "analysisType",
4028
+ "healthScore",
4029
+ "findings",
4030
+ "suggestions",
4031
+ "sourceNodeIds",
4032
+ "sourceEdgeIds",
4033
+ "detectorVersions",
4034
+ "metadata"
4035
+ ];
4036
+ var GRAPH_ANALYSIS_SUGGESTION_FIELDS = [
4037
+ "topicId",
4038
+ "projectId",
4039
+ "workspaceId",
4040
+ "analysisId",
4041
+ "suggestions",
4042
+ "metadata"
4043
+ ];
4044
+ var GRAPH_ANALYSIS_COMPUTE_FIELDS = [
4045
+ "topicId",
4046
+ "projectId",
4047
+ "workspaceId",
4048
+ "analysisType",
4049
+ "sourceNodeIds",
4050
+ "sourceEdgeIds",
4051
+ "detectorVersions",
4052
+ "metadata"
4053
+ ];
4054
+ function readTopicId2(input) {
4055
+ return input.topicId?.trim() || input.projectId?.trim() || void 0;
4056
+ }
4057
+ function requireTopicId2(input) {
4058
+ const topicId = readTopicId2(input);
4059
+ if (!topicId) {
4060
+ throw new Error("topicId is required");
4061
+ }
4062
+ return topicId;
4063
+ }
4064
+ function assertKnownKeys2(input, allowed, operation) {
4065
+ const allowedSet = new Set(allowed);
4066
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
4067
+ if (unknownKeys.length > 0) {
4068
+ throw new Error(
4069
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
4070
+ );
4071
+ }
4072
+ }
4073
+ function normalizeAnalysisPayload(input) {
4074
+ assertKnownKeys2(
4075
+ input,
4076
+ GRAPH_ANALYSIS_ANALYSIS_FIELDS,
4077
+ "graphAnalysis.saveAnalysis"
4078
+ );
4079
+ return {
4080
+ ...input,
4081
+ topicId: requireTopicId2(input),
4082
+ projectId: void 0
4083
+ };
4084
+ }
4085
+ function normalizeSuggestionPayload(input) {
4086
+ assertKnownKeys2(
4087
+ input,
4088
+ GRAPH_ANALYSIS_SUGGESTION_FIELDS,
4089
+ "graphAnalysis.saveSuggestions"
4090
+ );
4091
+ return {
4092
+ ...input,
4093
+ topicId: requireTopicId2(input),
4094
+ projectId: void 0
4095
+ };
4096
+ }
4097
+ function normalizeComputePayload(input) {
4098
+ assertKnownKeys2(
4099
+ input,
4100
+ GRAPH_ANALYSIS_COMPUTE_FIELDS,
4101
+ "graphAnalysis.computeOrRequestAnalysis"
4102
+ );
4103
+ return {
4104
+ ...input,
4105
+ topicId: requireTopicId2(input),
4106
+ projectId: void 0
4107
+ };
4108
+ }
4109
+ function graphAnalysisQuery(input) {
4110
+ return {
4111
+ topicId: requireTopicId2(input),
4112
+ workspaceId: input.workspaceId,
4113
+ analysisType: input.analysisType,
4114
+ limit: input.limit,
4115
+ cursor: input.cursor
4116
+ };
4117
+ }
4118
+ function createGraphAnalysisClient(config = {}) {
4119
+ const gateway = createGatewayRequestClient(config);
4120
+ return {
4121
+ saveAnalysis(input, idempotencyKey) {
4122
+ return gateway.request({
4123
+ path: "/api/platform/v1/graph-analysis/analyses",
4124
+ method: "POST",
4125
+ body: normalizeAnalysisPayload(input),
4126
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4127
+ });
4128
+ },
4129
+ listAnalyses(input) {
4130
+ return gateway.request({
4131
+ path: `/api/platform/v1/graph-analysis/analyses${toQueryString(
4132
+ graphAnalysisQuery(input)
4133
+ )}`
4134
+ }).then(
4135
+ (response) => mapGatewayData(
4136
+ response,
4137
+ (data) => createListResult(
4138
+ Array.isArray(data.analyses) ? data.analyses : Array.isArray(data) ? data : [],
4139
+ "analyses"
4140
+ )
4141
+ )
4142
+ );
4143
+ },
4144
+ getLatestAnalysis(input) {
4145
+ return gateway.request({
4146
+ path: `/api/platform/v1/graph-analysis/analyses/latest${toQueryString({
4147
+ topicId: requireTopicId2(input),
4148
+ workspaceId: input.workspaceId,
4149
+ analysisType: input.analysisType
4150
+ })}`
4151
+ });
4152
+ },
4153
+ saveSuggestions(input, idempotencyKey) {
4154
+ return gateway.request({
4155
+ path: "/api/platform/v1/graph-analysis/suggestions",
4156
+ method: "POST",
4157
+ body: normalizeSuggestionPayload(input),
4158
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4159
+ });
4160
+ },
4161
+ updateSuggestionStatus(input, idempotencyKey) {
4162
+ return gateway.request({
4163
+ path: `/api/platform/v1/graph-analysis/suggestions/${encodeURIComponent(
4164
+ input.suggestionId
4165
+ )}`,
4166
+ method: "PATCH",
4167
+ body: {
4168
+ status: input.status,
4169
+ rationale: input.rationale,
4170
+ metadata: input.metadata
4171
+ },
4172
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4173
+ });
4174
+ },
4175
+ listSuggestions(input) {
4176
+ return gateway.request({
4177
+ path: `/api/platform/v1/graph-analysis/suggestions${toQueryString({
4178
+ topicId: requireTopicId2(input),
4179
+ workspaceId: input.workspaceId,
4180
+ analysisId: input.analysisId,
4181
+ findingId: input.findingId,
4182
+ status: input.status,
4183
+ limit: input.limit,
4184
+ cursor: input.cursor
4185
+ })}`
4186
+ }).then(
4187
+ (response) => mapGatewayData(
4188
+ response,
4189
+ (data) => createListResult(
4190
+ Array.isArray(data.suggestions) ? data.suggestions : Array.isArray(data) ? data : [],
4191
+ "suggestions"
4192
+ )
4193
+ )
4194
+ );
4195
+ },
4196
+ listGraphChanges(input) {
4197
+ return gateway.request({
4198
+ path: `/api/platform/v1/graph-analysis/changes${toQueryString({
4199
+ topicId: requireTopicId2(input),
4200
+ workspaceId: input.workspaceId,
4201
+ analysisId: input.analysisId,
4202
+ since: input.since,
4203
+ limit: input.limit,
4204
+ cursor: input.cursor
4205
+ })}`
4206
+ }).then(
4207
+ (response) => mapGatewayData(
4208
+ response,
4209
+ (data) => createListResult(
4210
+ Array.isArray(data.changes) ? data.changes : Array.isArray(data) ? data : [],
4211
+ "changes"
4212
+ )
4213
+ )
4214
+ );
4215
+ },
4216
+ computeOrRequestAnalysis(input, idempotencyKey) {
4217
+ return gateway.request({
4218
+ path: "/api/platform/v1/graph-analysis/compute",
4219
+ method: "POST",
4220
+ body: normalizeComputePayload(input),
4221
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4222
+ });
4223
+ }
4224
+ };
4225
+ }
4226
+
4227
+ // src/graphRecommendationsClient.ts
4228
+ var GRAPH_RECOMMENDATION_FIELDS = [
4229
+ "topicId",
4230
+ "projectId",
4231
+ "workspaceId",
4232
+ "limit",
4233
+ "cursor",
4234
+ "status",
4235
+ "findingId",
4236
+ "actionType",
4237
+ "targetNodeIds",
4238
+ "priority",
4239
+ "rationale",
4240
+ "healthScore",
4241
+ "metadata"
4242
+ ];
4243
+ function readTopicId3(input) {
4244
+ return input.topicId?.trim() || input.projectId?.trim() || void 0;
4245
+ }
4246
+ function requireTopicId3(input) {
4247
+ const topicId = readTopicId3(input);
4248
+ if (!topicId) {
4249
+ throw new Error("topicId is required");
4250
+ }
4251
+ return topicId;
4252
+ }
4253
+ function assertKnownKeys3(input, operation) {
4254
+ const allowed = new Set(GRAPH_RECOMMENDATION_FIELDS);
4255
+ const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
4256
+ if (unknownKeys.length > 0) {
4257
+ throw new Error(
4258
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
4259
+ );
4260
+ }
4261
+ }
4262
+ function listQuery(input) {
4263
+ assertKnownKeys3(
4264
+ input,
4265
+ "graphRecommendations.listForTopic"
4266
+ );
4267
+ return {
4268
+ workspaceId: input.workspaceId,
4269
+ topicId: requireTopicId3(input),
4270
+ limit: input.limit,
4271
+ cursor: input.cursor,
4272
+ status: input.status,
4273
+ findingId: input.findingId,
4274
+ actionType: input.actionType,
4275
+ priority: input.priority,
4276
+ targetNodeIds: input.targetNodeIds?.join(","),
4277
+ healthScore: input.healthScore
4278
+ };
4279
+ }
4280
+ function createGraphRecommendationsClient(config = {}) {
4281
+ const gateway = createGatewayRequestClient(config);
4282
+ return {
4283
+ listForTopic(input) {
4284
+ return gateway.request({
4285
+ path: `/api/platform/v1/graph-recommendations${toQueryString(
4286
+ listQuery(input)
4287
+ )}`
4288
+ }).then(
4289
+ (response) => mapGatewayData(
4290
+ response,
4291
+ (data) => createListResult(
4292
+ Array.isArray(
4293
+ data.recommendations
4294
+ ) ? data.recommendations : Array.isArray(data) ? data : [],
4295
+ "recommendations"
4296
+ )
4297
+ )
4298
+ );
4299
+ },
4300
+ getRecommendation(recommendationId) {
4301
+ return gateway.request({
4302
+ path: `/api/platform/v1/graph-recommendations/${encodeURIComponent(
4303
+ recommendationId
4304
+ )}`
4305
+ });
4306
+ },
4307
+ markRecommendationStatus(input, idempotencyKey) {
4308
+ return gateway.request({
4309
+ path: `/api/platform/v1/graph-recommendations/${encodeURIComponent(
4310
+ input.recommendationId
4311
+ )}/status`,
4312
+ method: "PATCH",
4313
+ body: {
4314
+ status: input.status,
4315
+ rationale: input.rationale,
4316
+ metadata: input.metadata
4317
+ },
4318
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4319
+ });
4320
+ }
4321
+ };
4322
+ }
4323
+
4324
+ // src/graphStateClassifierClient.ts
4325
+ var GRAPH_STATE_CLASSIFIER_FIELDS = [
4326
+ "topicId",
4327
+ "projectId",
4328
+ "workspaceId",
4329
+ "nodeId",
4330
+ "epistemicStatus",
4331
+ "beliefMaturity",
4332
+ "answerQuality",
4333
+ "evidenceNetwork",
4334
+ "logicalRole",
4335
+ "questionPriority",
4336
+ "layer",
4337
+ "modelVersion",
4338
+ "limit",
4339
+ "cursor",
4340
+ "metadata"
4341
+ ];
4342
+ function normalizeRecordPayload(input) {
4343
+ cleanRequiredString(input.workspaceId, "workspaceId");
4344
+ cleanRequiredString(input.nodeId, "nodeId");
4345
+ return topicPayload(
4346
+ input,
4347
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4348
+ "graphStateClassifier.recordClassification"
4349
+ );
4350
+ }
4351
+ function createGraphStateClassifierClient(config = {}) {
4352
+ const gateway = createGatewayRequestClient(config);
4353
+ return {
4354
+ classifyNode(input, idempotencyKey) {
4355
+ cleanRequiredString(input.workspaceId, "workspaceId");
4356
+ cleanRequiredString(input.nodeId, "nodeId");
4357
+ return gateway.request({
4358
+ path: "/api/platform/v1/graph-state-classifier/classify-node",
4359
+ method: "POST",
4360
+ body: topicPayload(
4361
+ input,
4362
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4363
+ "graphStateClassifier.classifyNode"
4364
+ ),
4365
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4366
+ });
4367
+ },
4368
+ classifyTopic(input, idempotencyKey) {
4369
+ cleanRequiredString(input.workspaceId, "workspaceId");
4370
+ return gateway.request({
4371
+ path: "/api/platform/v1/graph-state-classifier/classify-topic",
4372
+ method: "POST",
4373
+ body: topicPayload(
4374
+ input,
4375
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4376
+ "graphStateClassifier.classifyTopic"
4377
+ ),
4378
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4379
+ }).then(
4380
+ (response) => mapGatewayData(
4381
+ response,
4382
+ (data) => listResultFromEnvelope(
4383
+ data,
4384
+ "classifications"
4385
+ )
4386
+ )
4387
+ );
4388
+ },
4389
+ listClassifications(input) {
4390
+ return gateway.request({
4391
+ path: `/api/platform/v1/graph-state-classifier/classifications${toQueryString({
4392
+ topicId: requireTopicId(input),
4393
+ workspaceId: input.workspaceId,
4394
+ nodeId: input.nodeId,
4395
+ modelVersion: input.modelVersion,
4396
+ layer: input.layer,
4397
+ epistemicStatus: input.epistemicStatus,
4398
+ limit: input.limit,
4399
+ cursor: input.cursor
4400
+ })}`
4401
+ }).then(
4402
+ (response) => mapGatewayData(
4403
+ response,
4404
+ (data) => listResultFromEnvelope(
4405
+ data,
4406
+ "classifications"
4407
+ )
4408
+ )
4409
+ );
4410
+ },
4411
+ recordClassification(input, idempotencyKey) {
4412
+ return gateway.request({
4413
+ path: "/api/platform/v1/graph-state-classifier/classifications",
4414
+ method: "POST",
4415
+ body: normalizeRecordPayload(input),
4416
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4417
+ });
4418
+ }
4419
+ };
4420
+ }
4421
+
3305
4422
  // src/harnessClient.ts
3306
4423
  function createHarnessClient(config = {}) {
3307
4424
  const gateway = createGatewayRequestClient(config);
@@ -3521,9 +4638,9 @@ function createHarnessClient(config = {}) {
3521
4638
  /**
3522
4639
  * List prompt resolutions.
3523
4640
  */
3524
- async listPromptResolutions(query = {}) {
4641
+ async listPromptResolutions(query5 = {}) {
3525
4642
  return gateway.request({
3526
- path: `/api/platform/v1/harness/prompts${toQueryString(query)}`
4643
+ path: `/api/platform/v1/harness/prompts${toQueryString(query5)}`
3527
4644
  }).then(
3528
4645
  (response) => mapGatewayData(
3529
4646
  response,
@@ -3542,6 +4659,128 @@ function createHarnessClient(config = {}) {
3542
4659
  };
3543
4660
  }
3544
4661
 
4662
+ // src/jobsClient.ts
4663
+ var JOBS_FIELDS = [
4664
+ "tenantId",
4665
+ "workspaceId",
4666
+ "principalId",
4667
+ "topicId",
4668
+ "worktreeId",
4669
+ "jobId",
4670
+ "jobType",
4671
+ "payload",
4672
+ "status",
4673
+ "attempt",
4674
+ "runId",
4675
+ "queue",
4676
+ "priority",
4677
+ "error",
4678
+ "metadata",
4679
+ "limit",
4680
+ "cursor"
4681
+ ];
4682
+ function query2(input) {
4683
+ return {
4684
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
4685
+ workspaceId: input.workspaceId,
4686
+ principalId: input.principalId,
4687
+ topicId: input.topicId,
4688
+ worktreeId: input.worktreeId,
4689
+ jobType: input.jobType,
4690
+ status: input.status,
4691
+ queue: input.queue,
4692
+ limit: input.limit,
4693
+ cursor: input.cursor
4694
+ };
4695
+ }
4696
+ function body2(input, operation) {
4697
+ return knownPayload(input, JOBS_FIELDS, operation);
4698
+ }
4699
+ function createJobsClient(config = {}) {
4700
+ const gateway = createGatewayRequestClient(config);
4701
+ return {
4702
+ enqueue(input, idempotencyKey) {
4703
+ cleanRequiredString(input.tenantId, "tenantId");
4704
+ cleanRequiredString(input.jobType, "jobType");
4705
+ return gateway.request({
4706
+ path: "/api/platform/v1/jobs",
4707
+ method: "POST",
4708
+ body: body2(input, "jobs.enqueue"),
4709
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4710
+ });
4711
+ },
4712
+ list(input) {
4713
+ return gateway.request({
4714
+ path: `/api/platform/v1/jobs${toQueryString(query2(input))}`
4715
+ }).then(
4716
+ (response) => mapGatewayData(
4717
+ response,
4718
+ (data) => listResultFromEnvelope(data, "jobs")
4719
+ )
4720
+ );
4721
+ },
4722
+ claim(input, idempotencyKey) {
4723
+ cleanRequiredString(input.tenantId, "tenantId");
4724
+ return gateway.request({
4725
+ path: "/api/platform/v1/jobs/claim",
4726
+ method: "POST",
4727
+ body: body2(input, "jobs.claim"),
4728
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4729
+ });
4730
+ },
4731
+ updateStatus(input, idempotencyKey) {
4732
+ cleanRequiredString(input.tenantId, "tenantId");
4733
+ cleanRequiredString(input.jobId, "jobId");
4734
+ return gateway.request({
4735
+ path: `/api/platform/v1/jobs/${encodeURIComponent(input.jobId)}/status`,
4736
+ method: "PATCH",
4737
+ body: body2(
4738
+ input,
4739
+ "jobs.updateStatus"
4740
+ ),
4741
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4742
+ });
4743
+ },
4744
+ retry(input, idempotencyKey) {
4745
+ cleanRequiredString(input.tenantId, "tenantId");
4746
+ cleanRequiredString(input.jobId, "jobId");
4747
+ return gateway.request({
4748
+ path: `/api/platform/v1/jobs/${encodeURIComponent(input.jobId)}/retry`,
4749
+ method: "POST",
4750
+ body: body2(input, "jobs.retry"),
4751
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4752
+ });
4753
+ },
4754
+ recordRunStart(input, idempotencyKey) {
4755
+ cleanRequiredString(input.tenantId, "tenantId");
4756
+ return gateway.request({
4757
+ path: "/api/platform/v1/jobs/runs/start",
4758
+ method: "POST",
4759
+ body: body2(
4760
+ input,
4761
+ "jobs.recordRunStart"
4762
+ ),
4763
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4764
+ });
4765
+ },
4766
+ recordRunFinish(input, idempotencyKey) {
4767
+ cleanRequiredString(input.tenantId, "tenantId");
4768
+ cleanRequiredString(input.runId, "runId");
4769
+ return gateway.request({
4770
+ path: `/api/platform/v1/jobs/runs/${encodeURIComponent(
4771
+ input.runId
4772
+ )}/finish`,
4773
+ method: "POST",
4774
+ body: body2(
4775
+ input,
4776
+ "jobs.recordRunFinish"
4777
+ ),
4778
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4779
+ });
4780
+ }
4781
+ };
4782
+ }
4783
+
3545
4784
  // src/learningClient.ts
3546
4785
  function createLearningClient(config = {}) {
3547
4786
  const gateway = createGatewayRequestClient(config);
@@ -3571,17 +4810,133 @@ function createLearningClient(config = {}) {
3571
4810
  async getRecentExecutions(args = {}) {
3572
4811
  return this.listRecentExecutions(args);
3573
4812
  },
3574
- /**
3575
- * Get aggregate execution statistics.
3576
- */
3577
- async getExecutionStats(args = {}) {
4813
+ /**
4814
+ * Get aggregate execution statistics.
4815
+ */
4816
+ async getExecutionStats(args = {}) {
4817
+ return gateway.request({
4818
+ path: `/api/platform/v1/learning/executions/stats${toQueryString({
4819
+ ...normalizeTopicQuery(args),
4820
+ namespace: args.namespace,
4821
+ audienceMode: args.audienceMode,
4822
+ hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
4823
+ })}`
4824
+ });
4825
+ }
4826
+ };
4827
+ }
4828
+ function toJsonValue(value) {
4829
+ if (value === void 0) {
4830
+ return void 0;
4831
+ }
4832
+ const seen = /* @__PURE__ */ new WeakSet();
4833
+ const json = JSON.stringify(value, (_key, candidate) => {
4834
+ if (typeof candidate === "bigint") {
4835
+ return candidate.toString();
4836
+ }
4837
+ if (typeof candidate === "function" || typeof candidate === "symbol" || typeof candidate === "undefined") {
4838
+ return void 0;
4839
+ }
4840
+ if (candidate && typeof candidate === "object") {
4841
+ if (seen.has(candidate)) {
4842
+ return "[Circular]";
4843
+ }
4844
+ seen.add(candidate);
4845
+ }
4846
+ return candidate;
4847
+ });
4848
+ if (json === void 0) {
4849
+ return void 0;
4850
+ }
4851
+ return JSON.parse(json);
4852
+ }
4853
+ function createMcpClient(config = {}) {
4854
+ const gateway = createGatewayRequestClient(config);
4855
+ return {
4856
+ bootstrapSession(input = {}) {
4857
+ const scope = {
4858
+ tenantId: input.tenantId,
4859
+ workspaceId: input.workspaceId
4860
+ };
4861
+ const body4 = {
4862
+ transportKind: input.transportKind,
4863
+ sessionId: input.sessionId,
4864
+ agentIdentity: input.agentIdentity,
4865
+ workspaceId: input.workspaceId
4866
+ };
4867
+ return gateway.request({
4868
+ path: `${MCP_GATEWAY_BOOTSTRAP_ENDPOINT}${toQueryString(scope)}`,
4869
+ method: "POST",
4870
+ body: body4
4871
+ });
4872
+ },
4873
+ checkWritePolicy(input) {
4874
+ const scope = {
4875
+ tenantId: input.tenantId,
4876
+ workspaceId: input.workspaceId
4877
+ };
4878
+ return gateway.request({
4879
+ path: `${MCP_GATEWAY_WRITE_POLICY_CHECK_ENDPOINT}${toQueryString(scope)}`,
4880
+ method: "POST",
4881
+ body: {
4882
+ topicId: input.topicId,
4883
+ role: input.role,
4884
+ toolName: input.toolName
4885
+ }
4886
+ });
4887
+ },
4888
+ beginBuildSession(input) {
4889
+ const scope = {
4890
+ tenantId: input.tenantId,
4891
+ workspaceId: input.workspaceId
4892
+ };
4893
+ return gateway.request({
4894
+ path: `${MCP_GATEWAY_BEGIN_BUILD_SESSION_ENDPOINT}${toQueryString(scope)}`,
4895
+ method: "POST",
4896
+ body: {
4897
+ worktreeId: input.worktreeId,
4898
+ branch: input.branch,
4899
+ branchBase: input.branchBase,
4900
+ prBase: input.prBase,
4901
+ sessionMode: input.sessionMode,
4902
+ activateIfPlanning: input.activateIfPlanning
4903
+ }
4904
+ });
4905
+ },
4906
+ evaluateEngineeringContract(input) {
4907
+ const scope = {
4908
+ tenantId: input.tenantId,
4909
+ workspaceId: input.workspaceId
4910
+ };
4911
+ return gateway.request({
4912
+ path: `${MCP_GATEWAY_EVALUATE_ENGINEERING_CONTRACT_ENDPOINT}${toQueryString(scope)}`,
4913
+ method: "POST",
4914
+ body: {
4915
+ beliefNodeId: toJsonValue(input.beliefNodeId),
4916
+ trigger: toJsonValue(input.trigger),
4917
+ testOutput: toJsonValue(input.testOutput),
4918
+ tscOutput: toJsonValue(input.tscOutput),
4919
+ lintOutput: toJsonValue(input.lintOutput),
4920
+ sentryData: toJsonValue(input.sentryData)
4921
+ }
4922
+ });
4923
+ },
4924
+ evaluateResearchContract(input) {
4925
+ const scope = {
4926
+ tenantId: input.tenantId,
4927
+ workspaceId: input.workspaceId
4928
+ };
3578
4929
  return gateway.request({
3579
- path: `/api/platform/v1/learning/executions/stats${toQueryString({
3580
- ...normalizeTopicQuery(args),
3581
- namespace: args.namespace,
3582
- audienceMode: args.audienceMode,
3583
- hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
3584
- })}`
4930
+ path: `${MCP_GATEWAY_EVALUATE_RESEARCH_CONTRACT_ENDPOINT}${toQueryString(scope)}`,
4931
+ method: "POST",
4932
+ body: {
4933
+ beliefNodeId: toJsonValue(input.beliefNodeId),
4934
+ trigger: toJsonValue(input.trigger),
4935
+ metricData: toJsonValue(input.metricData),
4936
+ referenceCheckData: toJsonValue(input.referenceCheckData),
4937
+ marketIndexData: toJsonValue(input.marketIndexData),
4938
+ temporalData: toJsonValue(input.temporalData)
4939
+ }
3585
4940
  });
3586
4941
  }
3587
4942
  };
@@ -4068,6 +5423,304 @@ function createFunctionSurfaceClient(config = {}) {
4068
5423
  };
4069
5424
  }
4070
5425
 
5426
+ // src/modelRuntimeClient.ts
5427
+ var MODEL_RUNTIME_FIELDS = [
5428
+ "tenantId",
5429
+ "workspaceId",
5430
+ "principalId",
5431
+ "functionName",
5432
+ "slotKey",
5433
+ "modelId",
5434
+ "provider",
5435
+ "routingPolicy",
5436
+ "metadata",
5437
+ "limit",
5438
+ "cursor"
5439
+ ];
5440
+ function scopeQuery(input) {
5441
+ return {
5442
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
5443
+ workspaceId: input.workspaceId,
5444
+ principalId: input.principalId,
5445
+ provider: input.provider,
5446
+ limit: input.limit,
5447
+ cursor: input.cursor
5448
+ };
5449
+ }
5450
+ function modelRuntimeBody(input, operation) {
5451
+ return knownPayload(input, MODEL_RUNTIME_FIELDS, operation);
5452
+ }
5453
+ function createModelRuntimeClient(config = {}) {
5454
+ const gateway = createGatewayRequestClient(config);
5455
+ return {
5456
+ listModels(input) {
5457
+ return gateway.request({
5458
+ path: `/api/platform/v1/model-runtime/models${toQueryString(
5459
+ scopeQuery(input)
5460
+ )}`
5461
+ }).then(
5462
+ (response) => mapGatewayData(
5463
+ response,
5464
+ (data) => listResultFromEnvelope(data, "models")
5465
+ )
5466
+ );
5467
+ },
5468
+ getModel(input) {
5469
+ cleanRequiredString(input.tenantId, "tenantId");
5470
+ cleanRequiredString(input.modelId, "modelId");
5471
+ return gateway.request({
5472
+ path: `/api/platform/v1/model-runtime/models/${encodeURIComponent(
5473
+ input.modelId
5474
+ )}${toQueryString({
5475
+ tenantId: input.tenantId,
5476
+ workspaceId: input.workspaceId,
5477
+ principalId: input.principalId
5478
+ })}`
5479
+ });
5480
+ },
5481
+ listFunctionSlots(input) {
5482
+ return gateway.request({
5483
+ path: `/api/platform/v1/model-runtime/function-slots${toQueryString({
5484
+ ...scopeQuery(input),
5485
+ functionName: input.functionName
5486
+ })}`
5487
+ }).then(
5488
+ (response) => mapGatewayData(
5489
+ response,
5490
+ (data) => listResultFromEnvelope(data, "slots")
5491
+ )
5492
+ );
5493
+ },
5494
+ resolveSlot(input, idempotencyKey) {
5495
+ cleanRequiredString(input.tenantId, "tenantId");
5496
+ cleanRequiredString(input.functionName, "functionName");
5497
+ return gateway.request({
5498
+ path: "/api/platform/v1/model-runtime/function-slots/resolve",
5499
+ method: "POST",
5500
+ body: modelRuntimeBody(
5501
+ input,
5502
+ "modelRuntime.resolveSlot"
5503
+ ),
5504
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5505
+ });
5506
+ },
5507
+ updateSlotConfig(input, idempotencyKey) {
5508
+ cleanRequiredString(input.tenantId, "tenantId");
5509
+ cleanRequiredString(input.functionName, "functionName");
5510
+ cleanRequiredString(input.slotKey, "slotKey");
5511
+ cleanRequiredString(input.modelId, "modelId");
5512
+ return gateway.request({
5513
+ path: "/api/platform/v1/model-runtime/slot-configs",
5514
+ method: "PUT",
5515
+ body: modelRuntimeBody(
5516
+ input,
5517
+ "modelRuntime.updateSlotConfig"
5518
+ ),
5519
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5520
+ });
5521
+ }
5522
+ };
5523
+ }
5524
+
5525
+ // src/ontologyLinksClient.ts
5526
+ var ONTOLOGY_LINK_FIELDS = [
5527
+ "topicId",
5528
+ "workspaceId",
5529
+ "linkId",
5530
+ "sourceNodeId",
5531
+ "sourceGlobalId",
5532
+ "targetNodeId",
5533
+ "targetGlobalId",
5534
+ "ontologyId",
5535
+ "ontologyType",
5536
+ "edgeType",
5537
+ "weight",
5538
+ "confidence",
5539
+ "status",
5540
+ "metadata"
5541
+ ];
5542
+ function assertEndpoints(input) {
5543
+ if (!input.sourceNodeId && !input.sourceGlobalId) {
5544
+ throw new Error("sourceNodeId or sourceGlobalId is required");
5545
+ }
5546
+ if (!input.targetNodeId && !input.targetGlobalId) {
5547
+ throw new Error("targetNodeId or targetGlobalId is required");
5548
+ }
5549
+ }
5550
+ function normalizeLinkPayload(input, operation) {
5551
+ assertEndpoints(input);
5552
+ cleanRequiredString(input.ontologyId, "ontologyId");
5553
+ cleanRequiredString(input.edgeType, "edgeType");
5554
+ return knownPayload(input, ONTOLOGY_LINK_FIELDS, operation);
5555
+ }
5556
+ function createOntologyLinksClient(config = {}) {
5557
+ const gateway = createGatewayRequestClient(config);
5558
+ return {
5559
+ createLink(input, idempotencyKey) {
5560
+ return gateway.request({
5561
+ path: "/api/platform/v1/ontology-links",
5562
+ method: "POST",
5563
+ body: normalizeLinkPayload(input, "ontologyLinks.createLink"),
5564
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5565
+ });
5566
+ },
5567
+ upsertLink(input, idempotencyKey) {
5568
+ return gateway.request({
5569
+ path: "/api/platform/v1/ontology-links",
5570
+ method: "PUT",
5571
+ body: normalizeLinkPayload(input, "ontologyLinks.upsertLink"),
5572
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5573
+ });
5574
+ },
5575
+ listLinksForNode(input) {
5576
+ const nodeId = cleanOptionalString(input.nodeId);
5577
+ const globalId = cleanOptionalString(input.globalId);
5578
+ if (!nodeId && !globalId) {
5579
+ throw new Error("nodeId or globalId is required");
5580
+ }
5581
+ const pathId = encodeURIComponent(nodeId ?? globalId ?? "");
5582
+ return gateway.request({
5583
+ path: `/api/platform/v1/ontology-links/nodes/${pathId}${toQueryString({
5584
+ topicId: input.topicId,
5585
+ workspaceId: input.workspaceId,
5586
+ globalId: nodeId ? void 0 : globalId,
5587
+ ontologyId: input.ontologyId,
5588
+ ontologyType: input.ontologyType,
5589
+ edgeType: input.edgeType,
5590
+ status: input.status,
5591
+ limit: input.limit,
5592
+ cursor: input.cursor
5593
+ })}`
5594
+ }).then(
5595
+ (response) => mapGatewayData(
5596
+ response,
5597
+ (data) => listResultFromEnvelope(data, "links")
5598
+ )
5599
+ );
5600
+ },
5601
+ updateLinkStatus(input, idempotencyKey) {
5602
+ return gateway.request({
5603
+ path: `/api/platform/v1/ontology-links/${encodeURIComponent(
5604
+ input.linkId
5605
+ )}/status`,
5606
+ method: "PATCH",
5607
+ body: knownPayload(
5608
+ input,
5609
+ ONTOLOGY_LINK_FIELDS,
5610
+ "ontologyLinks.updateLinkStatus"
5611
+ ),
5612
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5613
+ });
5614
+ }
5615
+ };
5616
+ }
5617
+
5618
+ // src/orgGraphSearchClient.ts
5619
+ var ORG_GRAPH_SEARCH_FIELDS = [
5620
+ "tenantId",
5621
+ "workspaceId",
5622
+ "query",
5623
+ "nodeTypes",
5624
+ "minConfidence",
5625
+ "limit",
5626
+ "cursor",
5627
+ "provenanceScope"
5628
+ ];
5629
+ function cleanString5(value, label) {
5630
+ const normalized = value?.trim();
5631
+ if (!normalized) {
5632
+ throw new Error(`${label} is required`);
5633
+ }
5634
+ return normalized;
5635
+ }
5636
+ function assertKnownSearchKeys(input, operation) {
5637
+ const allowed = new Set(ORG_GRAPH_SEARCH_FIELDS);
5638
+ const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
5639
+ if (unknownKeys.length > 0) {
5640
+ throw new Error(
5641
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
5642
+ );
5643
+ }
5644
+ }
5645
+ function searchBody(input) {
5646
+ assertKnownSearchKeys(
5647
+ input,
5648
+ "orgGraphSearch.search"
5649
+ );
5650
+ return {
5651
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5652
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5653
+ query: cleanString5(input.query, "query"),
5654
+ nodeTypes: input.nodeTypes,
5655
+ minConfidence: input.minConfidence,
5656
+ limit: input.limit,
5657
+ cursor: input.cursor,
5658
+ provenanceScope: input.provenanceScope
5659
+ };
5660
+ }
5661
+ function listQuery2(input) {
5662
+ return {
5663
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5664
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5665
+ nodeTypes: input.nodeTypes?.join(","),
5666
+ minConfidence: input.minConfidence,
5667
+ limit: input.limit,
5668
+ cursor: input.cursor
5669
+ };
5670
+ }
5671
+ function mapResults(data) {
5672
+ const record = data && typeof data === "object" ? data : {};
5673
+ return createListResult(
5674
+ Array.isArray(record.results) ? record.results : Array.isArray(data) ? data : [],
5675
+ "results"
5676
+ );
5677
+ }
5678
+ function createOrgGraphSearchClient(config = {}) {
5679
+ const gateway = createGatewayRequestClient(config);
5680
+ return {
5681
+ search(input) {
5682
+ return gateway.request({
5683
+ path: "/api/platform/v1/org-graph-search/search",
5684
+ method: "POST",
5685
+ body: searchBody(input)
5686
+ }).then((response) => mapGatewayData(response, mapResults));
5687
+ },
5688
+ getNode(input) {
5689
+ const nodeId = input.nodeId?.trim();
5690
+ const globalId = input.globalId?.trim();
5691
+ if (!nodeId && !globalId) {
5692
+ throw new Error("nodeId or globalId is required");
5693
+ }
5694
+ const nodePath = encodeURIComponent(nodeId ?? globalId ?? "");
5695
+ return gateway.request({
5696
+ path: `/api/platform/v1/org-graph-search/nodes/${nodePath}${toQueryString(
5697
+ {
5698
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5699
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5700
+ globalId: nodeId ? void 0 : globalId
5701
+ }
5702
+ )}`
5703
+ });
5704
+ },
5705
+ listByProvenance(input) {
5706
+ return gateway.request({
5707
+ path: `/api/platform/v1/org-graph-search/provenance${toQueryString({
5708
+ ...listQuery2(input),
5709
+ provenanceScope: input.provenanceScope
5710
+ })}`
5711
+ }).then((response) => mapGatewayData(response, mapResults));
5712
+ },
5713
+ listPublishedFromWorkspace(input) {
5714
+ return gateway.request({
5715
+ path: `/api/platform/v1/org-graph-search/published${toQueryString({
5716
+ ...listQuery2(input),
5717
+ sourceWorkspaceId: input.sourceWorkspaceId
5718
+ })}`
5719
+ }).then((response) => mapGatewayData(response, mapResults));
5720
+ }
5721
+ };
5722
+ }
5723
+
4071
5724
  // src/packsClient.ts
4072
5725
  function createPacksClient(config = {}) {
4073
5726
  const gateway = createGatewayRequestClient(config);
@@ -4110,9 +5763,9 @@ function createPacksClient(config = {}) {
4110
5763
  /**
4111
5764
  * List pack states for the current scope.
4112
5765
  */
4113
- async listStates(query = {}) {
5766
+ async listStates(query5 = {}) {
4114
5767
  return gateway.request({
4115
- path: `/api/platform/v1/packs/states${toQueryString(query)}`
5768
+ path: `/api/platform/v1/packs/states${toQueryString(query5)}`
4116
5769
  }).then(
4117
5770
  (response) => mapGatewayData(
4118
5771
  response,
@@ -4123,25 +5776,25 @@ function createPacksClient(config = {}) {
4123
5776
  /**
4124
5777
  * @deprecated Use listStates.
4125
5778
  */
4126
- async getStates(query = {}) {
4127
- return this.listStates(query);
5779
+ async getStates(query5 = {}) {
5780
+ return this.listStates(query5);
4128
5781
  },
4129
5782
  /**
4130
5783
  * Get health details for a pack.
4131
5784
  */
4132
- async getHealth(packKey, query = {}) {
5785
+ async getHealth(packKey, query5 = {}) {
4133
5786
  return gateway.request({
4134
5787
  path: `/api/platform/v1/packs/${encodeURIComponent(packKey)}/health${toQueryString(
4135
- query
5788
+ query5
4136
5789
  )}`
4137
5790
  });
4138
5791
  },
4139
5792
  /**
4140
5793
  * List pack telemetry entries.
4141
5794
  */
4142
- async listTelemetry(query = {}) {
5795
+ async listTelemetry(query5 = {}) {
4143
5796
  return gateway.request({
4144
- path: `/api/platform/v1/packs/telemetry${toQueryString(query)}`
5797
+ path: `/api/platform/v1/packs/telemetry${toQueryString(query5)}`
4145
5798
  }).then(
4146
5799
  (response) => mapGatewayData(
4147
5800
  response,
@@ -4152,8 +5805,8 @@ function createPacksClient(config = {}) {
4152
5805
  /**
4153
5806
  * @deprecated Use listTelemetry.
4154
5807
  */
4155
- async getTelemetry(query = {}) {
4156
- return this.listTelemetry(query);
5808
+ async getTelemetry(query5 = {}) {
5809
+ return this.listTelemetry(query5);
4157
5810
  },
4158
5811
  /**
4159
5812
  * Create a pack entitlement.
@@ -4275,9 +5928,9 @@ function createPolicyClient(config = {}) {
4275
5928
  /**
4276
5929
  * List policy decisions in the current scope.
4277
5930
  */
4278
- async listDecisions(query = {}) {
5931
+ async listDecisions(query5 = {}) {
4279
5932
  return gateway.request({
4280
- path: `/api/platform/v1/policy/decisions${toQueryString(query)}`
5933
+ path: `/api/platform/v1/policy/decisions${toQueryString(query5)}`
4281
5934
  }).then(
4282
5935
  (response) => mapGatewayData(
4283
5936
  response,
@@ -4310,9 +5963,9 @@ function createPolicyClient(config = {}) {
4310
5963
  /**
4311
5964
  * List write policy rules for the current scope.
4312
5965
  */
4313
- async listWritePolicies(query = {}) {
5966
+ async listWritePolicies(query5 = {}) {
4314
5967
  const response = await gateway.request({
4315
- path: `/api/platform/v1/policy/write-policies${toQueryString(query)}`
5968
+ path: `/api/platform/v1/policy/write-policies${toQueryString(query5)}`
4316
5969
  });
4317
5970
  const rawPolicies = response.data && typeof response.data === "object" ? response.data.policies : response.data;
4318
5971
  return {
@@ -4375,9 +6028,9 @@ function createPolicyClient(config = {}) {
4375
6028
  /**
4376
6029
  * List tenant role policies for the current scope.
4377
6030
  */
4378
- async listRolePolicies(query = {}) {
6031
+ async listRolePolicies(query5 = {}) {
4379
6032
  const response = await gateway.request({
4380
- path: `/api/platform/v1/policy/roles${toQueryString(query)}`
6033
+ path: `/api/platform/v1/policy/roles${toQueryString(query5)}`
4381
6034
  });
4382
6035
  return {
4383
6036
  ...response,
@@ -4435,28 +6088,28 @@ function createPolicyClient(config = {}) {
4435
6088
  /**
4436
6089
  * Check a permission decision for a topic or project scope.
4437
6090
  */
4438
- async checkPermission(query) {
4439
- if (!query.topicId) {
6091
+ async checkPermission(query5) {
6092
+ if (!query5.topicId) {
4440
6093
  throw new Error("topicId is required");
4441
6094
  }
4442
6095
  return gateway.request({
4443
- path: `/api/platform/v1/policy/check${toQueryString(query)}`
6096
+ path: `/api/platform/v1/policy/check${toQueryString(query5)}`
4444
6097
  });
4445
6098
  },
4446
6099
  /**
4447
6100
  * List accessible topics for a principal.
4448
6101
  */
4449
- async listAccessibleTopics(query = {}) {
4450
- const permission = query.permission ?? "read";
4451
- const principal = query.principal ?? query.principalId;
6102
+ async listAccessibleTopics(query5 = {}) {
6103
+ const permission = query5.permission ?? "read";
6104
+ const principal = query5.principal ?? query5.principalId;
4452
6105
  const response = await gateway.request({
4453
6106
  path: `/api/platform/v1/policy/topics${toQueryString({
4454
- tenantId: query.tenantId,
4455
- workspaceId: query.workspaceId,
6107
+ tenantId: query5.tenantId,
6108
+ workspaceId: query5.workspaceId,
4456
6109
  permission,
4457
- includeShared: query.includeShared,
6110
+ includeShared: query5.includeShared,
4458
6111
  principal,
4459
- limit: query.limit
6112
+ limit: query5.limit
4460
6113
  })}`
4461
6114
  });
4462
6115
  return {
@@ -4639,6 +6292,294 @@ function createSchemaClient(config = {}) {
4639
6292
  };
4640
6293
  }
4641
6294
 
6295
+ // src/telemetryClient.ts
6296
+ var TELEMETRY_FIELDS = [
6297
+ "tenantId",
6298
+ "workspaceId",
6299
+ "principalId",
6300
+ "topicId",
6301
+ "worktreeId",
6302
+ "eventLevel",
6303
+ "eventType",
6304
+ "message",
6305
+ "toolName",
6306
+ "toolCalls",
6307
+ "decision",
6308
+ "policySubject",
6309
+ "policyAction",
6310
+ "policyResource",
6311
+ "runId",
6312
+ "runType",
6313
+ "status",
6314
+ "durationMs",
6315
+ "error",
6316
+ "metadata",
6317
+ "limit",
6318
+ "cursor"
6319
+ ];
6320
+ function query3(input) {
6321
+ return {
6322
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
6323
+ workspaceId: input.workspaceId,
6324
+ principalId: input.principalId,
6325
+ topicId: input.topicId,
6326
+ worktreeId: input.worktreeId,
6327
+ runType: input.runType,
6328
+ status: input.status,
6329
+ limit: input.limit,
6330
+ cursor: input.cursor
6331
+ };
6332
+ }
6333
+ function body3(input, operation) {
6334
+ return knownPayload(input, TELEMETRY_FIELDS, operation);
6335
+ }
6336
+ function createTelemetryClient(config = {}) {
6337
+ const gateway = createGatewayRequestClient(config);
6338
+ return {
6339
+ logSystemEvent(input, idempotencyKey) {
6340
+ cleanRequiredString(input.tenantId, "tenantId");
6341
+ cleanRequiredString(input.eventType, "eventType");
6342
+ cleanRequiredString(input.message, "message");
6343
+ return gateway.request({
6344
+ path: "/api/platform/v1/telemetry/system-events",
6345
+ method: "POST",
6346
+ body: body3(
6347
+ input,
6348
+ "telemetry.logSystemEvent"
6349
+ ),
6350
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6351
+ });
6352
+ },
6353
+ logToolCallsBatch(input, idempotencyKey) {
6354
+ cleanRequiredString(input.tenantId, "tenantId");
6355
+ return gateway.request({
6356
+ path: "/api/platform/v1/telemetry/tool-calls/batch",
6357
+ method: "POST",
6358
+ body: body3(
6359
+ input,
6360
+ "telemetry.logToolCallsBatch"
6361
+ ),
6362
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6363
+ });
6364
+ },
6365
+ recordEpistemicAudit(input, idempotencyKey) {
6366
+ cleanRequiredString(input.tenantId, "tenantId");
6367
+ cleanRequiredString(input.eventType, "eventType");
6368
+ return gateway.request({
6369
+ path: "/api/platform/v1/telemetry/epistemic-audits",
6370
+ method: "POST",
6371
+ body: body3(
6372
+ input,
6373
+ "telemetry.recordEpistemicAudit"
6374
+ ),
6375
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6376
+ });
6377
+ },
6378
+ recordPolicyDecision(input, idempotencyKey) {
6379
+ cleanRequiredString(input.tenantId, "tenantId");
6380
+ cleanRequiredString(input.decision, "decision");
6381
+ return gateway.request({
6382
+ path: "/api/platform/v1/telemetry/policy-decisions",
6383
+ method: "POST",
6384
+ body: body3(
6385
+ input,
6386
+ "telemetry.recordPolicyDecision"
6387
+ ),
6388
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6389
+ });
6390
+ },
6391
+ startRun(input, idempotencyKey) {
6392
+ cleanRequiredString(input.tenantId, "tenantId");
6393
+ cleanRequiredString(input.runType, "runType");
6394
+ return gateway.request({
6395
+ path: "/api/platform/v1/telemetry/runs/start",
6396
+ method: "POST",
6397
+ body: body3(
6398
+ input,
6399
+ "telemetry.startRun"
6400
+ ),
6401
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6402
+ });
6403
+ },
6404
+ finishRun(input, idempotencyKey) {
6405
+ cleanRequiredString(input.tenantId, "tenantId");
6406
+ cleanRequiredString(input.runId, "runId");
6407
+ return gateway.request({
6408
+ path: `/api/platform/v1/telemetry/runs/${encodeURIComponent(
6409
+ input.runId
6410
+ )}/finish`,
6411
+ method: "POST",
6412
+ body: body3(
6413
+ input,
6414
+ "telemetry.finishRun"
6415
+ ),
6416
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6417
+ });
6418
+ },
6419
+ listRuns(input) {
6420
+ return gateway.request({
6421
+ path: `/api/platform/v1/telemetry/runs${toQueryString(query3(input))}`
6422
+ }).then(
6423
+ (response) => mapGatewayData(
6424
+ response,
6425
+ (data) => listResultFromEnvelope(data, "runs")
6426
+ )
6427
+ );
6428
+ }
6429
+ };
6430
+ }
6431
+
6432
+ // src/toolRegistryClient.ts
6433
+ var TOOL_REGISTRY_FIELDS = [
6434
+ "tenantId",
6435
+ "workspaceId",
6436
+ "principalId",
6437
+ "toolName",
6438
+ "packKey",
6439
+ "packVersion",
6440
+ "status",
6441
+ "permissions",
6442
+ "role",
6443
+ "surface",
6444
+ "parameterSchema",
6445
+ "returnSchema",
6446
+ "handlerRef",
6447
+ "executionAdapter",
6448
+ "safetyMetadata",
6449
+ "aclId",
6450
+ "metadata",
6451
+ "limit",
6452
+ "cursor"
6453
+ ];
6454
+ function query4(input) {
6455
+ return {
6456
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
6457
+ workspaceId: input.workspaceId,
6458
+ principalId: input.principalId,
6459
+ packKey: input.packKey,
6460
+ status: input.status,
6461
+ limit: input.limit,
6462
+ cursor: input.cursor
6463
+ };
6464
+ }
6465
+ function writeBody(input, operation) {
6466
+ return knownPayload(input, TOOL_REGISTRY_FIELDS, operation);
6467
+ }
6468
+ function createToolRegistryClient(config = {}) {
6469
+ const gateway = createGatewayRequestClient(config);
6470
+ return {
6471
+ listCatalog(input) {
6472
+ return gateway.request({
6473
+ path: `/api/platform/v1/tools/catalog${toQueryString(query4(input))}`
6474
+ }).then(
6475
+ (response) => mapGatewayData(
6476
+ response,
6477
+ (data) => listResultFromEnvelope(data, "tools")
6478
+ )
6479
+ );
6480
+ },
6481
+ listExecutable(input) {
6482
+ return gateway.request({
6483
+ path: `/api/platform/v1/tools/executable${toQueryString(query4(input))}`
6484
+ }).then(
6485
+ (response) => mapGatewayData(
6486
+ response,
6487
+ (data) => listResultFromEnvelope(data, "tools")
6488
+ )
6489
+ );
6490
+ },
6491
+ listEffectiveTools(input) {
6492
+ return gateway.request({
6493
+ path: `/api/platform/v1/tools/effective${toQueryString(query4(input))}`
6494
+ }).then(
6495
+ (response) => mapGatewayData(
6496
+ response,
6497
+ (data) => listResultFromEnvelope(data, "tools")
6498
+ )
6499
+ );
6500
+ },
6501
+ upsertCoreTools(input, idempotencyKey) {
6502
+ cleanRequiredString(input.tenantId, "tenantId");
6503
+ return gateway.request({
6504
+ path: "/api/platform/v1/tools/core",
6505
+ method: "PUT",
6506
+ body: {
6507
+ tenantId: input.tenantId,
6508
+ workspaceId: input.workspaceId,
6509
+ metadata: input.metadata,
6510
+ tools: input.tools
6511
+ },
6512
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6513
+ }).then(
6514
+ (response) => mapGatewayData(
6515
+ response,
6516
+ (data) => listResultFromEnvelope(data, "tools")
6517
+ )
6518
+ );
6519
+ },
6520
+ setPackToolsStatus(input, idempotencyKey) {
6521
+ cleanRequiredString(input.tenantId, "tenantId");
6522
+ cleanRequiredString(input.packKey, "packKey");
6523
+ return gateway.request({
6524
+ path: `/api/platform/v1/tools/packs/${encodeURIComponent(
6525
+ input.packKey
6526
+ )}/status`,
6527
+ method: "PATCH",
6528
+ body: writeBody(
6529
+ input,
6530
+ "tools.setPackToolsStatus"
6531
+ ),
6532
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6533
+ }).then(
6534
+ (response) => mapGatewayData(
6535
+ response,
6536
+ (data) => listResultFromEnvelope(data, "tools")
6537
+ )
6538
+ );
6539
+ },
6540
+ createAcl(input, idempotencyKey) {
6541
+ cleanRequiredString(input.tenantId, "tenantId");
6542
+ cleanRequiredString(input.principalId, "principalId");
6543
+ cleanRequiredString(input.toolName, "toolName");
6544
+ return gateway.request({
6545
+ path: "/api/platform/v1/tools/acls",
6546
+ method: "POST",
6547
+ body: writeBody(
6548
+ input,
6549
+ "tools.createAcl"
6550
+ ),
6551
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6552
+ });
6553
+ },
6554
+ deleteAcl(input, idempotencyKey) {
6555
+ cleanRequiredString(input.tenantId, "tenantId");
6556
+ cleanRequiredString(input.aclId, "aclId");
6557
+ return gateway.request({
6558
+ path: `/api/platform/v1/tools/acls/${encodeURIComponent(input.aclId)}`,
6559
+ method: "DELETE",
6560
+ body: writeBody(
6561
+ input,
6562
+ "tools.deleteAcl"
6563
+ ),
6564
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6565
+ });
6566
+ },
6567
+ registerCustomTool(input, idempotencyKey) {
6568
+ cleanRequiredString(input.tenantId, "tenantId");
6569
+ cleanRequiredString(input.toolName, "toolName");
6570
+ return gateway.request({
6571
+ path: "/api/platform/v1/tools/custom",
6572
+ method: "POST",
6573
+ body: writeBody(
6574
+ input,
6575
+ "tools.registerCustomTool"
6576
+ ),
6577
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6578
+ });
6579
+ }
6580
+ };
6581
+ }
6582
+
4642
6583
  // src/version.ts
4643
6584
  var LUCERN_SDK_VERSION = "0.2.0-alpha.1";
4644
6585
 
@@ -4656,10 +6597,10 @@ function createWorkflowClient(config = {}) {
4656
6597
  /**
4657
6598
  * List workflow branches for a topic scope.
4658
6599
  */
4659
- async listBranches(query) {
6600
+ async listBranches(query5) {
4660
6601
  return gateway.request({
4661
6602
  path: `/api/platform/v1/workflow/branches${toQueryString(
4662
- normalizeTopicQuery(query)
6603
+ normalizeTopicQuery(query5)
4663
6604
  )}`
4664
6605
  }).then(
4665
6606
  (response) => mapGatewayData(
@@ -4687,10 +6628,10 @@ function createWorkflowClient(config = {}) {
4687
6628
  /**
4688
6629
  * List reusable lenses for a workspace or topic scope.
4689
6630
  */
4690
- async listLenses(query) {
6631
+ async listLenses(query5) {
4691
6632
  return gateway.request({
4692
6633
  path: `/api/platform/v1/workflow/lenses${toQueryString(
4693
- normalizeLensQuery(query)
6634
+ normalizeLensQuery(query5)
4694
6635
  )}`
4695
6636
  }).then(
4696
6637
  (response) => mapGatewayData(
@@ -4762,14 +6703,14 @@ function createWorkflowClient(config = {}) {
4762
6703
  /**
4763
6704
  * List worktrees for a topic scope.
4764
6705
  */
4765
- async listWorktrees(query) {
4766
- const normalized = normalizeTopicQuery(query);
6706
+ async listWorktrees(query5) {
6707
+ const normalized = normalizeTopicQuery(query5);
4767
6708
  return gateway.request({
4768
6709
  path: `/api/platform/v1/worktrees/all${toQueryString({
4769
6710
  ...normalized,
4770
- groupBy: query.groupBy,
4771
- lane: query.lane,
4772
- campaign: query.campaign
6711
+ groupBy: query5.groupBy,
6712
+ lane: query5.lane,
6713
+ campaign: query5.campaign
4773
6714
  })}`
4774
6715
  }).then(
4775
6716
  (response) => mapGatewayData(
@@ -4784,14 +6725,14 @@ function createWorkflowClient(config = {}) {
4784
6725
  /**
4785
6726
  * List all worktrees across accessible topics.
4786
6727
  */
4787
- async listAllWorktrees(query = {}) {
6728
+ async listAllWorktrees(query5 = {}) {
4788
6729
  return gateway.request({
4789
6730
  path: `/api/platform/v1/worktrees${toQueryString({
4790
- status: query.status,
4791
- groupBy: query.groupBy,
4792
- lane: query.lane,
4793
- campaign: query.campaign,
4794
- limit: query.limit
6731
+ status: query5.status,
6732
+ groupBy: query5.groupBy,
6733
+ lane: query5.lane,
6734
+ campaign: query5.campaign,
6735
+ limit: query5.limit
4795
6736
  })}`
4796
6737
  }).then(
4797
6738
  (response) => mapGatewayData(response, (data) => {
@@ -4811,10 +6752,10 @@ function createWorkflowClient(config = {}) {
4811
6752
  /**
4812
6753
  * List compact pipeline campaigns with nested lanes.
4813
6754
  */
4814
- async listCampaigns(query = {}) {
6755
+ async listCampaigns(query5 = {}) {
4815
6756
  return gateway.request({
4816
6757
  path: `/api/platform/v1/worktrees/campaigns${toQueryString(
4817
- normalizeTopicQuery(query)
6758
+ normalizeTopicQuery(query5)
4818
6759
  )}`
4819
6760
  });
4820
6761
  },
@@ -4870,11 +6811,11 @@ function createWorkflowClient(config = {}) {
4870
6811
  * Update targeted beliefs/questions for a worktree.
4871
6812
  */
4872
6813
  async updateWorktreeTargets(input, idempotencyKey) {
4873
- const { worktreeId, ...body } = input;
6814
+ const { worktreeId, ...body4 } = input;
4874
6815
  return gateway.request({
4875
6816
  path: `/api/platform/v1/worktrees/${encodeURIComponent(worktreeId)}/targets`,
4876
6817
  method: "POST",
4877
- body,
6818
+ body: body4,
4878
6819
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4879
6820
  }).then(
4880
6821
  (response) => mapGatewayData(
@@ -4963,11 +6904,11 @@ function createWorkflowClient(config = {}) {
4963
6904
  /**
4964
6905
  * List accessible topic contexts.
4965
6906
  */
4966
- async listTopics(query = {}) {
6907
+ async listTopics(query5 = {}) {
4967
6908
  return gateway.request({
4968
6909
  path: `/api/platform/v1/workflow/topics${toQueryString({
4969
- includeShared: typeof query.includeShared === "boolean" ? query.includeShared ? "true" : "false" : void 0,
4970
- limit: query.limit
6910
+ includeShared: typeof query5.includeShared === "boolean" ? query5.includeShared ? "true" : "false" : void 0,
6911
+ limit: query5.limit
4971
6912
  })}`
4972
6913
  }).then(
4973
6914
  (response) => mapGatewayData(response, (data) => {
@@ -5095,13 +7036,15 @@ function toGatewayConfig(config) {
5095
7036
  requestIdFactory: config.requestIdFactory,
5096
7037
  onRequest: config.onRequest,
5097
7038
  onResponse: config.onResponse,
7039
+ authContext: config.authContext,
7040
+ requireCanonicalAuthContext: config.requireCanonicalAuthContext,
5098
7041
  getAuthHeaders: async () => {
5099
7042
  const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
5100
7043
  if (config.apiKey && !base["x-lucern-key"] && !base.Authorization) {
5101
7044
  base["x-lucern-key"] = config.apiKey;
5102
7045
  }
5103
- if (config.userToken && !base["x-lucern-user-token"]) {
5104
- base["x-lucern-user-token"] = config.userToken;
7046
+ if (config.userToken && !base["x-lucern-session-token"]) {
7047
+ base["x-lucern-session-token"] = config.userToken;
5105
7048
  }
5106
7049
  if (config.environment && !base["x-lucern-environment"]) {
5107
7050
  base["x-lucern-environment"] = config.environment;
@@ -5110,7 +7053,7 @@ function toGatewayConfig(config) {
5110
7053
  }
5111
7054
  };
5112
7055
  }
5113
- function requireTopicId(args) {
7056
+ function requireTopicId4(args) {
5114
7057
  const topicId = resolveTopicId(args);
5115
7058
  if (!topicId) {
5116
7059
  throw new Error("topicId is required");
@@ -5158,12 +7101,18 @@ function createLucernClient(config = {}) {
5158
7101
  const sourcesClient = createSourcesClient(gatewayConfig);
5159
7102
  const beliefsFacade = createBeliefsFacade(gatewayConfig);
5160
7103
  const evidenceClient = createEvidenceClient(gatewayConfig);
7104
+ const embeddingsClient = createEmbeddingsClient(gatewayConfig);
7105
+ const eventingClient = createEventingClient(gatewayConfig);
5161
7106
  const graphClient = createGraphClient(gatewayConfig);
7107
+ const graphAnalysisClient = createGraphAnalysisClient(gatewayConfig);
7108
+ const graphRecommendationsClient = createGraphRecommendationsClient(gatewayConfig);
7109
+ const graphStateClassifierClient = createGraphStateClassifierClient(gatewayConfig);
5162
7110
  const graphFacade = createGraphFacade(gatewayConfig);
5163
7111
  const decisionsClient = createDecisionsClient(gatewayConfig);
5164
7112
  const contextClient = createContextClient(gatewayConfig);
5165
7113
  const workflowClient = createWorkflowClient(gatewayConfig);
5166
7114
  const auditClient = createAuditClient(gatewayConfig);
7115
+ const authDeviceClient = createAuthDeviceClient(gatewayConfig);
5167
7116
  const adminClient = createAdminClient(gatewayConfig);
5168
7117
  const answersClient = createAnswersClient(gatewayConfig);
5169
7118
  const contradictionsFacade = createContradictionsFacade(gatewayConfig);
@@ -5181,10 +7130,17 @@ function createLucernClient(config = {}) {
5181
7130
  const worktreesFacade = createWorktreesFacade(gatewayConfig);
5182
7131
  const policyClient = createPolicyClient(gatewayConfig);
5183
7132
  const ontologyClient = createOntologyClient(gatewayConfig);
7133
+ const ontologyLinksClient = createOntologyLinksClient(gatewayConfig);
7134
+ const orgGraphSearchClient = createOrgGraphSearchClient(gatewayConfig);
5184
7135
  const functionSurfaceClient = createFunctionSurfaceClient(gatewayConfig);
7136
+ const toolRegistryClient = createToolRegistryClient(gatewayConfig);
7137
+ const modelRuntimeClient = createModelRuntimeClient(gatewayConfig);
5185
7138
  const packsClient = createPacksClient(gatewayConfig);
5186
7139
  const reportsClient = createReportsClient(gatewayConfig);
5187
7140
  const learningClient = createLearningClient(gatewayConfig);
7141
+ const mcpClient = createMcpClient(gatewayConfig);
7142
+ const jobsClient = createJobsClient(gatewayConfig);
7143
+ const telemetryClient = createTelemetryClient(gatewayConfig);
5188
7144
  const harnessClient = createHarnessClient(gatewayConfig);
5189
7145
  const schemaClient = createSchemaClient(gatewayConfig);
5190
7146
  const audiencesClient = createAudiencesClient(gatewayConfig);
@@ -5313,7 +7269,7 @@ function createLucernClient(config = {}) {
5313
7269
  }
5314
7270
  async function listBeliefs(args) {
5315
7271
  const response = await beliefsFacade.list({
5316
- topicId: requireTopicId(args),
7272
+ topicId: requireTopicId4(args),
5317
7273
  status: args.status,
5318
7274
  worktreeId: args.worktreeId,
5319
7275
  minConfidence: args.minConfidence,
@@ -5341,13 +7297,13 @@ function createLucernClient(config = {}) {
5341
7297
  const results = groupedBeliefs.length > 0 ? groupedBeliefs : mergedResults.filter((result) => result.type === "belief");
5342
7298
  return { results };
5343
7299
  }
5344
- async function searchResources(query, options = {}) {
7300
+ async function searchResources(query5, options = {}) {
5345
7301
  const topicId = resolveTopicId(options);
5346
7302
  if (!topicId) {
5347
7303
  throw new Error("topicId is required");
5348
7304
  }
5349
7305
  return searchFacade.query({
5350
- q: query,
7306
+ q: query5,
5351
7307
  topicId,
5352
7308
  types: options.types,
5353
7309
  status: options.status,
@@ -5542,8 +7498,8 @@ function createLucernClient(config = {}) {
5542
7498
  }).then(exposeGatewayData);
5543
7499
  }
5544
7500
  const nodesNamespace = {
5545
- list(query) {
5546
- return graphClient.listNodes(query);
7501
+ list(query5) {
7502
+ return graphClient.listNodes(query5);
5547
7503
  },
5548
7504
  get(input) {
5549
7505
  return graphClient.getNode(
@@ -5572,16 +7528,22 @@ function createLucernClient(config = {}) {
5572
7528
  return {
5573
7529
  config,
5574
7530
  version: LUCERN_SDK_VERSION,
5575
- search(query, options) {
5576
- return searchResources(query, options);
7531
+ search(query5, options) {
7532
+ return searchResources(query5, options);
5577
7533
  },
5578
7534
  events: {
5579
- list(query = {}) {
5580
- return eventsFacade.list(query).then(exposeGatewayData);
7535
+ list(query5 = {}) {
7536
+ return eventsFacade.list(query5).then(exposeGatewayData);
5581
7537
  },
5582
7538
  replay(input) {
5583
7539
  return eventsFacade.replay(input).then(exposeGatewayData);
5584
- }
7540
+ },
7541
+ recordEvent: eventingClient.recordEvent,
7542
+ listEvents: eventingClient.listEvents,
7543
+ listWebhooks: eventingClient.listWebhooks,
7544
+ enqueueDelivery: eventingClient.enqueueDelivery,
7545
+ recordDeliveryAttempt: eventingClient.recordDeliveryAttempt,
7546
+ updateDeliveryStatus: eventingClient.updateDeliveryStatus
5585
7547
  },
5586
7548
  beliefs: {
5587
7549
  create(input) {
@@ -5650,7 +7612,7 @@ function createLucernClient(config = {}) {
5650
7612
  },
5651
7613
  list(args) {
5652
7614
  return beliefsFacade.list({
5653
- topicId: requireTopicId(args),
7615
+ topicId: requireTopicId4(args),
5654
7616
  worktreeId: args.worktreeId,
5655
7617
  status: args.status,
5656
7618
  minConfidence: args.minConfidence,
@@ -5679,8 +7641,8 @@ function createLucernClient(config = {}) {
5679
7641
  create(input) {
5680
7642
  return webhooksFacade.create(input).then(exposeGatewayData);
5681
7643
  },
5682
- list(query) {
5683
- return webhooksFacade.list(query).then(exposeGatewayData);
7644
+ list(query5) {
7645
+ return webhooksFacade.list(query5).then(exposeGatewayData);
5684
7646
  },
5685
7647
  get(id) {
5686
7648
  return webhooksFacade.get(id).then(exposeGatewayData);
@@ -5694,8 +7656,8 @@ function createLucernClient(config = {}) {
5694
7656
  test(id, input) {
5695
7657
  return webhooksFacade.test(id, input).then(exposeGatewayData);
5696
7658
  },
5697
- deliveries(id, query) {
5698
- return webhooksFacade.deliveries(id, query).then(exposeGatewayData);
7659
+ deliveries(id, query5) {
7660
+ return webhooksFacade.deliveries(id, query5).then(exposeGatewayData);
5699
7661
  },
5700
7662
  health(id) {
5701
7663
  return webhooksFacade.health(id).then(exposeGatewayData);
@@ -5850,7 +7812,7 @@ function createLucernClient(config = {}) {
5850
7812
  },
5851
7813
  list(args) {
5852
7814
  return questionsFacade.list({
5853
- topicId: requireTopicId(args),
7815
+ topicId: requireTopicId4(args),
5854
7816
  status: args.status,
5855
7817
  priority: args.priority,
5856
7818
  worktreeId: args.worktreeId,
@@ -5922,7 +7884,7 @@ function createLucernClient(config = {}) {
5922
7884
  },
5923
7885
  getHighPriority(args) {
5924
7886
  return this.list({
5925
- topicId: requireTopicId(args),
7887
+ topicId: requireTopicId4(args),
5926
7888
  status: args.includeAnswered ? void 0 : "open"
5927
7889
  }).then((data) => {
5928
7890
  const questions = Array.isArray(data.questions) ? data.questions : [];
@@ -5947,7 +7909,7 @@ function createLucernClient(config = {}) {
5947
7909
  },
5948
7910
  async findMissing(args) {
5949
7911
  return graphFacade.gaps({
5950
- topicId: requireTopicId(args),
7912
+ topicId: requireTopicId4(args),
5951
7913
  minConfidence: args.minConfidence
5952
7914
  }).then(exposeGatewayData);
5953
7915
  }
@@ -5978,21 +7940,21 @@ function createLucernClient(config = {}) {
5978
7940
  },
5979
7941
  analyze(args) {
5980
7942
  return graphFacade.analyze({
5981
- topicId: requireTopicId(args),
7943
+ topicId: requireTopicId4(args),
5982
7944
  limit: args.limit,
5983
7945
  metric: args.metric
5984
7946
  }).then(exposeGatewayData);
5985
7947
  },
5986
7948
  bias(args) {
5987
7949
  return graphFacade.bias({
5988
- topicId: requireTopicId(args),
7950
+ topicId: requireTopicId4(args),
5989
7951
  threshold: args.threshold,
5990
7952
  limit: args.limit
5991
7953
  }).then(exposeGatewayData);
5992
7954
  },
5993
7955
  gaps(args) {
5994
7956
  return graphFacade.gaps({
5995
- topicId: requireTopicId(args),
7957
+ topicId: requireTopicId4(args),
5996
7958
  minConfidence: args.minConfidence
5997
7959
  }).then(exposeGatewayData);
5998
7960
  },
@@ -6051,8 +8013,8 @@ function createLucernClient(config = {}) {
6051
8013
  record(input) {
6052
8014
  return decisionsClient.recordJudgment(input);
6053
8015
  },
6054
- list(query) {
6055
- return decisionsClient.listJudgments(query);
8016
+ list(query5) {
8017
+ return decisionsClient.listJudgments(query5);
6056
8018
  },
6057
8019
  get(judgmentId) {
6058
8020
  return decisionsClient.getJudgment(judgmentId);
@@ -6081,7 +8043,7 @@ function createLucernClient(config = {}) {
6081
8043
  transitionAuditIntegrity(args) {
6082
8044
  return decisionsClient.getJudgmentTransitionAuditIntegrity({
6083
8045
  ...args,
6084
- topicId: requireTopicId(args)
8046
+ topicId: requireTopicId4(args)
6085
8047
  });
6086
8048
  }
6087
8049
  },
@@ -6092,8 +8054,8 @@ function createLucernClient(config = {}) {
6092
8054
  createLens(input) {
6093
8055
  return workflowClient.createLens(input);
6094
8056
  },
6095
- listLenses(query) {
6096
- return workflowClient.listLenses(query);
8057
+ listLenses(query5) {
8058
+ return workflowClient.listLenses(query5);
6097
8059
  },
6098
8060
  applyLensToTopic(input) {
6099
8061
  return workflowClient.applyLensToTopic(input);
@@ -6104,7 +8066,7 @@ function createLucernClient(config = {}) {
6104
8066
  create(input) {
6105
8067
  return worktreesFacade.create({
6106
8068
  title: input.title,
6107
- topicId: requireTopicId(input),
8069
+ topicId: requireTopicId4(input),
6108
8070
  objective: input.objective,
6109
8071
  hypothesis: input.hypothesis,
6110
8072
  beliefIds: input.beliefIds,
@@ -6126,7 +8088,7 @@ function createLucernClient(config = {}) {
6126
8088
  add(input) {
6127
8089
  return worktreesFacade.create({
6128
8090
  title: input.title,
6129
- topicId: requireTopicId(input),
8091
+ topicId: requireTopicId4(input),
6130
8092
  objective: input.objective,
6131
8093
  hypothesis: input.hypothesis,
6132
8094
  beliefIds: input.beliefIds,
@@ -6145,11 +8107,11 @@ function createLucernClient(config = {}) {
6145
8107
  autoFixPolicy: input.autoFixPolicy
6146
8108
  });
6147
8109
  },
6148
- list(query) {
8110
+ list(query5) {
6149
8111
  return worktreesFacade.list({
6150
- topicId: requireTopicId(query),
6151
- status: query.status,
6152
- limit: query.limit
8112
+ topicId: requireTopicId4(query5),
8113
+ status: query5.status,
8114
+ limit: query5.limit
6153
8115
  });
6154
8116
  },
6155
8117
  activate(worktreeId) {
@@ -6184,8 +8146,8 @@ function createLucernClient(config = {}) {
6184
8146
  removeQuestionIds: input.removeQuestionIds
6185
8147
  });
6186
8148
  },
6187
- listAll(query = {}) {
6188
- return workflowClient.listAllWorktrees(query);
8149
+ listAll(query5 = {}) {
8150
+ return workflowClient.listAllWorktrees(query5);
6189
8151
  },
6190
8152
  merge(worktreeId, input) {
6191
8153
  return worktreesFacade.merge({
@@ -6226,12 +8188,12 @@ function createLucernClient(config = {}) {
6226
8188
  }
6227
8189
  },
6228
8190
  context: {
6229
- listTopics(query = {}) {
8191
+ listTopics(query5 = {}) {
6230
8192
  return topicsFacade.list({
6231
- ontologyId: query.ontologyId,
6232
- parentTopicId: query.parentTopicId,
6233
- status: query.status,
6234
- type: query.type
8193
+ ontologyId: query5.ontologyId,
8194
+ parentTopicId: query5.parentTopicId,
8195
+ status: query5.status,
8196
+ type: query5.type
6235
8197
  });
6236
8198
  },
6237
8199
  compile(topicId, input = {}) {
@@ -6342,10 +8304,10 @@ function createLucernClient(config = {}) {
6342
8304
  visibility: input.visibility
6343
8305
  });
6344
8306
  },
6345
- tree(topicId, query = {}) {
8307
+ tree(topicId, query5 = {}) {
6346
8308
  return topicsFacade.tree({
6347
8309
  id: topicId,
6348
- maxDepth: query.maxDepth
8310
+ maxDepth: query5.maxDepth
6349
8311
  });
6350
8312
  },
6351
8313
  getTree(input) {
@@ -6354,11 +8316,11 @@ function createLucernClient(config = {}) {
6354
8316
  maxDepth: input.maxDepth
6355
8317
  });
6356
8318
  },
6357
- coverage(topicId, query = {}) {
8319
+ coverage(topicId, query5 = {}) {
6358
8320
  return topicsFacade.coverage({
6359
8321
  id: topicId,
6360
- includeDescendants: query.includeDescendants,
6361
- maxDepth: query.maxDepth
8322
+ includeDescendants: query5.includeDescendants,
8323
+ maxDepth: query5.maxDepth
6362
8324
  });
6363
8325
  },
6364
8326
  remove(topicId, idempotencyKey) {
@@ -6408,7 +8370,7 @@ function createLucernClient(config = {}) {
6408
8370
  },
6409
8371
  list(args) {
6410
8372
  return contradictionsFacade.list({
6411
- topicId: requireTopicId(args),
8373
+ topicId: requireTopicId4(args),
6412
8374
  status: args.status,
6413
8375
  limit: args.limit,
6414
8376
  cursor: args.cursor
@@ -6583,7 +8545,24 @@ function createLucernClient(config = {}) {
6583
8545
  return functionSurfaceClient.generateSessionHandoff(input);
6584
8546
  }
6585
8547
  },
8548
+ embeddings: embeddingsClient,
8549
+ graphAnalysis: graphAnalysisClient,
8550
+ graphRecommendations: graphRecommendationsClient,
8551
+ orgGraphSearch: orgGraphSearchClient,
8552
+ ontologyLinks: ontologyLinksClient,
8553
+ graphStateClassifier: graphStateClassifierClient,
8554
+ modelRuntime: modelRuntimeClient,
8555
+ jobs: jobsClient,
8556
+ telemetry: telemetryClient,
6586
8557
  tools: {
8558
+ listCatalog: toolRegistryClient.listCatalog,
8559
+ listExecutable: toolRegistryClient.listExecutable,
8560
+ listEffectiveTools: toolRegistryClient.listEffectiveTools,
8561
+ upsertCoreTools: toolRegistryClient.upsertCoreTools,
8562
+ setPackToolsStatus: toolRegistryClient.setPackToolsStatus,
8563
+ createAcl: toolRegistryClient.createAcl,
8564
+ deleteAcl: toolRegistryClient.deleteAcl,
8565
+ registerCustomTool: toolRegistryClient.registerCustomTool,
6587
8566
  register(registration) {
6588
8567
  return registerCustomTool(registration);
6589
8568
  },
@@ -6640,26 +8619,74 @@ function createLucernClient(config = {}) {
6640
8619
  }
6641
8620
  },
6642
8621
  nodes: nodesNamespace,
6643
- identity: identityFacade,
8622
+ identity: {
8623
+ ...identityFacade,
8624
+ evaluatePolicy: identityClient.evaluatePolicy,
8625
+ recordPolicyDecision: identityClient.recordPolicyDecision,
8626
+ putSecretReference: identityClient.putSecretReference,
8627
+ createPrincipal: identityClient.createPrincipal,
8628
+ updatePrincipal: identityClient.updatePrincipal,
8629
+ raw: identityClient
8630
+ },
8631
+ mcp: {
8632
+ bootstrapSession(input) {
8633
+ return mcpClient.bootstrapSession(input);
8634
+ },
8635
+ checkWritePolicy(input) {
8636
+ return mcpClient.checkWritePolicy(input);
8637
+ },
8638
+ beginBuildSession(input) {
8639
+ return mcpClient.beginBuildSession(input);
8640
+ },
8641
+ evaluateEngineeringContract(input) {
8642
+ return mcpClient.evaluateEngineeringContract(input);
8643
+ },
8644
+ evaluateResearchContract(input) {
8645
+ return mcpClient.evaluateResearchContract(input);
8646
+ }
8647
+ },
8648
+ auth: {
8649
+ device: {
8650
+ createCode(input) {
8651
+ return authDeviceClient.createDeviceCode(input);
8652
+ },
8653
+ pollToken(deviceCode) {
8654
+ return authDeviceClient.pollDeviceToken(deviceCode);
8655
+ }
8656
+ }
8657
+ },
6644
8658
  custom: getCustomNamespace("custom"),
6645
8659
  extensions: extensionNamespaces,
6646
8660
  raw: {
6647
8661
  beliefs: beliefsClient,
6648
8662
  sources: sourcesClient,
6649
8663
  evidence: evidenceClient,
8664
+ embeddings: embeddingsClient,
8665
+ eventing: eventingClient,
6650
8666
  graph: graphClient,
8667
+ graphAnalysis: graphAnalysisClient,
8668
+ graphRecommendations: graphRecommendationsClient,
8669
+ graphStateClassifier: graphStateClassifierClient,
6651
8670
  decisions: decisionsClient,
6652
8671
  workflow: workflowClient,
6653
8672
  audit: auditClient,
8673
+ authDevice: authDeviceClient,
6654
8674
  admin: adminClient,
6655
8675
  identity: identityClient,
6656
8676
  policy: policyClient,
6657
8677
  answers: answersClient,
6658
8678
  ontology: ontologyClient,
8679
+ ontologyLinks: ontologyLinksClient,
8680
+ orgGraphSearch: orgGraphSearchClient,
6659
8681
  functionSurface: functionSurfaceClient,
8682
+ toolRegistry: toolRegistryClient,
8683
+ modelRuntime: modelRuntimeClient,
6660
8684
  packs: packsClient,
6661
8685
  reports: reportsClient,
6662
8686
  learning: learningClient,
8687
+ mcp: mcpClient,
8688
+ jobs: jobsClient,
8689
+ telemetry: telemetryClient,
6663
8690
  harness: harnessClient,
6664
8691
  schema: schemaClient,
6665
8692
  audiences: audiencesClient,