@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
@@ -1,9 +1,176 @@
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';
2
3
  import * as v1 from '@lucern/contracts/questions/v1';
3
4
  export { v1 as questionsContracts };
4
5
  import * as toolContracts from '@lucern/contracts/tool-contracts';
5
6
  export { toolContracts as toolSchemas };
6
7
 
8
+ // src/authContext.ts
9
+ var LucernSdkAuthContextError = class extends Error {
10
+ reason;
11
+ constructor(reason, message) {
12
+ super(message);
13
+ this.name = "LucernSdkAuthContextError";
14
+ this.reason = reason;
15
+ }
16
+ };
17
+ function cleanString(value) {
18
+ const normalized = value?.trim();
19
+ return normalized ? normalized : void 0;
20
+ }
21
+ function cleanStringList(values) {
22
+ if (!values) {
23
+ return [];
24
+ }
25
+ return values.map((value) => value.trim()).filter(
26
+ (value, index, list) => value.length > 0 && list.indexOf(value) === index
27
+ );
28
+ }
29
+ function requireString(value, reason, label) {
30
+ const normalized = cleanString(value);
31
+ if (!normalized) {
32
+ throw new LucernSdkAuthContextError(
33
+ reason,
34
+ `Canonical Lucern SDK auth context is missing ${label}.`
35
+ );
36
+ }
37
+ return normalized;
38
+ }
39
+ function requirePrincipalType(principalType) {
40
+ if (!principalType) {
41
+ throw new LucernSdkAuthContextError(
42
+ "principal_missing",
43
+ "Canonical Lucern SDK auth context is missing principalType."
44
+ );
45
+ }
46
+ return principalType;
47
+ }
48
+ function requireAuthMode(authMode) {
49
+ if (!authMode) {
50
+ throw new LucernSdkAuthContextError(
51
+ "principal_missing",
52
+ "Canonical Lucern SDK auth context is missing authMode."
53
+ );
54
+ }
55
+ return authMode;
56
+ }
57
+ function ensurePermitMatch(args) {
58
+ const actual = cleanString(args.actual);
59
+ if (actual && actual !== args.expected) {
60
+ throw new LucernSdkAuthContextError(
61
+ "policy_denied",
62
+ `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
63
+ );
64
+ }
65
+ }
66
+ function normalizeCanonicalLucernAuthContext(input) {
67
+ if (!input) {
68
+ throw new LucernSdkAuthContextError(
69
+ "principal_missing",
70
+ "Canonical Lucern SDK auth context is required."
71
+ );
72
+ }
73
+ if (input.policyDecision === "deny") {
74
+ throw new LucernSdkAuthContextError(
75
+ "policy_denied",
76
+ "Canonical Lucern SDK auth context carries a denied policy decision."
77
+ );
78
+ }
79
+ const principalId = requireString(
80
+ input.principalId,
81
+ "principal_missing",
82
+ "principalId"
83
+ );
84
+ const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
85
+ const workspaceId = requireString(
86
+ input.workspaceId,
87
+ "workspace_missing",
88
+ "workspaceId"
89
+ );
90
+ const roles = cleanStringList(input.roles);
91
+ const scopes = cleanStringList(input.scopes);
92
+ if (roles.length === 0 || scopes.length === 0) {
93
+ throw new LucernSdkAuthContextError(
94
+ "membership_missing",
95
+ "Canonical Lucern SDK auth context requires non-empty roles and scopes."
96
+ );
97
+ }
98
+ const principalType = requirePrincipalType(input.principalType);
99
+ const authMode = requireAuthMode(input.authMode);
100
+ const subject = cleanString(input.permit?.subject) ?? principalId;
101
+ const tenant = cleanString(input.permit?.tenant) ?? tenantId;
102
+ const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
103
+ ensurePermitMatch({
104
+ field: "subject",
105
+ expected: principalId,
106
+ actual: subject
107
+ });
108
+ ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
109
+ ensurePermitMatch({
110
+ field: "workspace",
111
+ expected: workspaceId,
112
+ actual: workspace
113
+ });
114
+ const context = input.permit?.context ? { ...input.permit.context } : void 0;
115
+ return {
116
+ clerkId: cleanString(input.clerkId),
117
+ principalId,
118
+ tenantId,
119
+ workspaceId,
120
+ principalType,
121
+ authMode,
122
+ roles,
123
+ scopes,
124
+ delegationChain: input.delegationChain ? [...input.delegationChain] : [],
125
+ policyTraceId: cleanString(input.policyTraceId),
126
+ correlationId: cleanString(input.correlationId),
127
+ membershipId: cleanString(input.membershipId),
128
+ permit: {
129
+ subject,
130
+ tenant,
131
+ workspace,
132
+ resource: cleanString(input.permit?.resource),
133
+ action: cleanString(input.permit?.action),
134
+ relation: cleanString(input.permit?.relation),
135
+ context
136
+ }
137
+ };
138
+ }
139
+ function createCanonicalAuthHeaders(authContext) {
140
+ const headers = {
141
+ "x-lucern-principal-id": authContext.principalId,
142
+ "x-lucern-principal-type": authContext.principalType,
143
+ "x-lucern-tenant": authContext.tenantId,
144
+ "x-lucern-tenant-id": authContext.tenantId,
145
+ "x-lucern-workspace": authContext.workspaceId,
146
+ "x-lucern-workspace-id": authContext.workspaceId,
147
+ "x-lucern-auth-mode": authContext.authMode,
148
+ "x-lucern-roles": authContext.roles.join(","),
149
+ "x-lucern-scopes": authContext.scopes.join(","),
150
+ "x-lucern-permit-context": JSON.stringify(authContext.permit)
151
+ };
152
+ if (authContext.clerkId) {
153
+ headers["x-lucern-clerk-id"] = authContext.clerkId;
154
+ headers["x-lucern-user-id"] = authContext.clerkId;
155
+ }
156
+ if (authContext.delegationChain.length > 0) {
157
+ headers["x-lucern-delegation-chain"] = JSON.stringify(
158
+ authContext.delegationChain
159
+ );
160
+ }
161
+ if (authContext.policyTraceId) {
162
+ headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
163
+ }
164
+ if (authContext.correlationId) {
165
+ headers["x-correlation-id"] = authContext.correlationId;
166
+ headers["x-lucern-correlation-id"] = authContext.correlationId;
167
+ }
168
+ if (authContext.membershipId) {
169
+ headers["x-lucern-membership-id"] = authContext.membershipId;
170
+ }
171
+ return headers;
172
+ }
173
+
7
174
  // src/coreClient.ts
8
175
  var LucernApiError = class extends Error {
9
176
  code;
@@ -160,16 +327,41 @@ function readPolicySummaryFromDetails(details) {
160
327
  }
161
328
  return null;
162
329
  }
330
+ async function resolveConfiguredAuthContext(authContext) {
331
+ if (typeof authContext === "function") {
332
+ return await authContext();
333
+ }
334
+ return authContext;
335
+ }
336
+ function mergeHeaderRecord(base, addition) {
337
+ const headers = new Headers(base);
338
+ for (const [key, value] of Object.entries(addition)) {
339
+ const existing = headers.get(key);
340
+ if (existing !== null && existing !== value) {
341
+ throw new LucernSdkAuthContextError(
342
+ "policy_denied",
343
+ `Canonical Lucern SDK auth context conflicts with existing ${key} header.`
344
+ );
345
+ }
346
+ headers.set(key, value);
347
+ }
348
+ return Object.fromEntries(headers.entries());
349
+ }
163
350
  function createGatewayRequestClient(config = {}) {
164
351
  const fetchImpl = config.fetchImpl ?? fetch;
165
352
  const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
166
353
  const maxRetries = config.maxRetries ?? 2;
167
354
  const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
168
355
  async function resolveAuthHeaders() {
169
- if (!config.getAuthHeaders) {
170
- return {};
356
+ const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
357
+ const authContextInput = await resolveConfiguredAuthContext(
358
+ config.authContext
359
+ );
360
+ if (!authContextInput && !config.requireCanonicalAuthContext) {
361
+ return base;
171
362
  }
172
- return await config.getAuthHeaders();
363
+ const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
364
+ return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
173
365
  }
174
366
  async function fetchWithTimeout(url, init, timeoutMs) {
175
367
  const controller = new AbortController();
@@ -344,11 +536,11 @@ function createGatewayRequestClient(config = {}) {
344
536
  function asRecord(value) {
345
537
  return value && typeof value === "object" ? value : {};
346
538
  }
347
- function cleanString(value) {
539
+ function cleanString2(value) {
348
540
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
349
541
  }
350
542
  function normalizeVerificationStatus(value) {
351
- const status = cleanString(value);
543
+ const status = cleanString2(value);
352
544
  if (!status) {
353
545
  return void 0;
354
546
  }
@@ -364,20 +556,20 @@ function cloneWith(value, patch) {
364
556
  return { ...value, ...patch };
365
557
  }
366
558
  function resolveTopicId(value) {
367
- return cleanString(value.topicId);
559
+ return cleanString2(value.topicId);
368
560
  }
369
561
  function resolveText(value) {
370
- return cleanString(value.text) ?? cleanString(value.canonicalText);
562
+ return cleanString2(value.text) ?? cleanString2(value.canonicalText);
371
563
  }
372
564
  function withTopicAlias(value) {
373
- const topicId = cleanString(value.topicId) ?? void 0;
565
+ const topicId = cleanString2(value.topicId) ?? void 0;
374
566
  if (!topicId) {
375
567
  return value;
376
568
  }
377
569
  return cloneWith(value, { topicId });
378
570
  }
379
571
  function withTextAlias(value) {
380
- const text = cleanString(value.text) ?? cleanString(value.canonicalText) ?? void 0;
572
+ const text = cleanString2(value.text) ?? cleanString2(value.canonicalText) ?? void 0;
381
573
  if (!text) {
382
574
  return value;
383
575
  }
@@ -407,7 +599,7 @@ function normalizeNodeVerificationStatus(value) {
407
599
  return normalizeVerificationStatus(value);
408
600
  }
409
601
  function normalizeTopicQuery(value) {
410
- const topicId = cleanString(value.topicId);
602
+ const topicId = cleanString2(value.topicId);
411
603
  if (!topicId) {
412
604
  return value;
413
605
  }
@@ -480,9 +672,9 @@ function createAdminClient(config = {}) {
480
672
  /**
481
673
  * List tenants visible to the current principal.
482
674
  */
483
- async listTenants(query = {}) {
675
+ async listTenants(query5 = {}) {
484
676
  return gateway.request({
485
- path: `/api/platform/v1/tenants${toQueryString(query)}`
677
+ path: `/api/platform/v1/tenants${toQueryString(query5)}`
486
678
  }).then(
487
679
  (response) => mapGatewayData(
488
680
  response,
@@ -523,9 +715,9 @@ function createAdminClient(config = {}) {
523
715
  /**
524
716
  * List workspaces for the current admin scope.
525
717
  */
526
- async listWorkspaces(query = {}) {
718
+ async listWorkspaces(query5 = {}) {
527
719
  return gateway.request({
528
- path: `/api/platform/v1/workspaces${toQueryString(query)}`
720
+ path: `/api/platform/v1/workspaces${toQueryString(query5)}`
529
721
  }).then(
530
722
  (response) => mapGatewayData(
531
723
  response,
@@ -550,9 +742,9 @@ function createAdminClient(config = {}) {
550
742
  /**
551
743
  * List memberships for the current admin scope.
552
744
  */
553
- async listMemberships(query = {}) {
745
+ async listMemberships(query5 = {}) {
554
746
  return gateway.request({
555
- path: `/api/platform/v1/memberships${toQueryString(query)}`
747
+ path: `/api/platform/v1/memberships${toQueryString(query5)}`
556
748
  }).then(
557
749
  (response) => mapGatewayData(
558
750
  response,
@@ -789,9 +981,9 @@ function createAdminClient(config = {}) {
789
981
  /**
790
982
  * List group members.
791
983
  */
792
- async listGroupMembers(query) {
984
+ async listGroupMembers(query5) {
793
985
  return gateway.request({
794
- path: `/api/platform/v1/groups/members${toQueryString(query)}`
986
+ path: `/api/platform/v1/groups/members${toQueryString(query5)}`
795
987
  });
796
988
  },
797
989
  /**
@@ -818,9 +1010,9 @@ function createAdminClient(config = {}) {
818
1010
  /**
819
1011
  * List pack-to-group assignments.
820
1012
  */
821
- async listPackGroupAssignments(query = {}) {
1013
+ async listPackGroupAssignments(query5 = {}) {
822
1014
  return gateway.request({
823
- path: `/api/platform/v1/groups/packs${toQueryString(query)}`
1015
+ path: `/api/platform/v1/groups/packs${toQueryString(query5)}`
824
1016
  });
825
1017
  },
826
1018
  /**
@@ -871,12 +1063,12 @@ function createAudiencesClient(config = {}) {
871
1063
  /**
872
1064
  * List audience registry entries.
873
1065
  */
874
- async listRegistry(query = {}) {
1066
+ async listRegistry(query5 = {}) {
875
1067
  return gateway.request({
876
1068
  path: `/api/platform/v1/audiences/registry${toQueryString({
877
- ...query,
878
- effective: typeof query.effective === "boolean" ? query.effective ? "true" : "false" : void 0,
879
- status: query.status
1069
+ ...query5,
1070
+ effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1071
+ status: query5.status
880
1072
  })}`
881
1073
  }).then(
882
1074
  (response) => mapGatewayData(
@@ -891,8 +1083,8 @@ function createAudiencesClient(config = {}) {
891
1083
  /**
892
1084
  * @deprecated Use listRegistry.
893
1085
  */
894
- async getRegistry(query = {}) {
895
- return this.listRegistry(query);
1086
+ async getRegistry(query5 = {}) {
1087
+ return this.listRegistry(query5);
896
1088
  },
897
1089
  /**
898
1090
  * Create an audience registry entry.
@@ -920,14 +1112,14 @@ function createAudiencesClient(config = {}) {
920
1112
  /**
921
1113
  * List audience grants.
922
1114
  */
923
- async listGrants(query = {}) {
1115
+ async listGrants(query5 = {}) {
924
1116
  return gateway.request({
925
1117
  path: `/api/platform/v1/audiences/grants${toQueryString({
926
- ...query,
927
- audienceKey: query.audienceKey,
928
- principalId: query.principalId,
929
- groupId: query.groupId,
930
- status: query.status
1118
+ ...query5,
1119
+ audienceKey: query5.audienceKey,
1120
+ principalId: query5.principalId,
1121
+ groupId: query5.groupId,
1122
+ status: query5.status
931
1123
  })}`
932
1124
  }).then(
933
1125
  (response) => mapGatewayData(
@@ -939,8 +1131,8 @@ function createAudiencesClient(config = {}) {
939
1131
  /**
940
1132
  * @deprecated Use listGrants.
941
1133
  */
942
- async getGrants(query = {}) {
943
- return this.listGrants(query);
1134
+ async getGrants(query5 = {}) {
1135
+ return this.listGrants(query5);
944
1136
  },
945
1137
  /**
946
1138
  * Create an audience grant.
@@ -986,10 +1178,10 @@ function createAuditClient(config = {}) {
986
1178
  /**
987
1179
  * List audit events for the current scope.
988
1180
  */
989
- async listEvents(query = {}) {
1181
+ async listEvents(query5 = {}) {
990
1182
  return gateway.request({
991
1183
  path: `/api/platform/v1/audit/events${toQueryString(
992
- normalizeTopicQuery(query)
1184
+ normalizeTopicQuery(query5)
993
1185
  )}`
994
1186
  }).then(
995
1187
  (response) => mapGatewayData(
@@ -1001,11 +1193,116 @@ function createAuditClient(config = {}) {
1001
1193
  };
1002
1194
  }
1003
1195
 
1196
+ // src/authDeviceClient.ts
1197
+ var DeviceAuthorizationError = class extends Error {
1198
+ error;
1199
+ interval;
1200
+ constructor(args) {
1201
+ super(args.description ?? args.error);
1202
+ this.name = "DeviceAuthorizationError";
1203
+ this.error = args.error;
1204
+ this.interval = args.interval;
1205
+ }
1206
+ };
1207
+ function authBaseUrl(config) {
1208
+ return config.baseUrl?.replace(/\/+$/, "") ?? "";
1209
+ }
1210
+ async function readJson(response) {
1211
+ const payload = await response.json().catch(() => ({}));
1212
+ return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
1213
+ }
1214
+ function readString(value) {
1215
+ const normalized = typeof value === "string" ? value.trim() : "";
1216
+ return normalized || void 0;
1217
+ }
1218
+ function assertDeviceCodeResponse(payload) {
1219
+ const deviceCode = readString(payload.device_code);
1220
+ const userCode = readString(payload.user_code);
1221
+ const verificationUri = readString(payload.verification_uri);
1222
+ const verificationUriComplete = readString(payload.verification_uri_complete);
1223
+ const expiresIn = payload.expires_in;
1224
+ const interval = payload.interval;
1225
+ if (!deviceCode || !userCode || !verificationUri || !verificationUriComplete || typeof expiresIn !== "number" || typeof interval !== "number") {
1226
+ throw new Error("Gateway returned an invalid device-code response.");
1227
+ }
1228
+ return {
1229
+ device_code: deviceCode,
1230
+ user_code: userCode,
1231
+ verification_uri: verificationUri,
1232
+ verification_uri_complete: verificationUriComplete,
1233
+ expires_in: expiresIn,
1234
+ interval
1235
+ };
1236
+ }
1237
+ function assertDeviceTokenResponse(payload) {
1238
+ const accessToken = readString(payload.access_token);
1239
+ const tokenType = readString(payload.token_type);
1240
+ const scope = readString(payload.scope);
1241
+ const tenantId = readString(payload.tenant_id);
1242
+ const principalId = readString(payload.principal_id);
1243
+ if (!accessToken || tokenType !== "Bearer" || typeof payload.expires_in !== "number" || !scope || !tenantId || !principalId) {
1244
+ throw new Error("Gateway returned an invalid device token response.");
1245
+ }
1246
+ return {
1247
+ access_token: accessToken,
1248
+ token_type: "Bearer",
1249
+ expires_in: payload.expires_in,
1250
+ scope,
1251
+ tenant_id: tenantId,
1252
+ workspace_id: readString(payload.workspace_id),
1253
+ principal_id: principalId,
1254
+ user: payload.user && typeof payload.user === "object" && !Array.isArray(payload.user) ? payload.user : void 0
1255
+ };
1256
+ }
1257
+ function maybeThrowDeviceError(payload) {
1258
+ const error = readString(payload.error);
1259
+ throw new DeviceAuthorizationError({
1260
+ error: error ?? "invalid_request",
1261
+ description: readString(payload.error_description),
1262
+ interval: typeof payload.interval === "number" ? payload.interval : void 0
1263
+ });
1264
+ }
1265
+ function createAuthDeviceClient(config = {}) {
1266
+ const fetchImpl = config.fetchImpl ?? fetch;
1267
+ const baseUrl = authBaseUrl(config);
1268
+ async function post(path, body4) {
1269
+ return fetchImpl(`${baseUrl}${path}`, {
1270
+ method: "POST",
1271
+ headers: { "content-type": "application/json" },
1272
+ body: JSON.stringify(body4)
1273
+ });
1274
+ }
1275
+ return {
1276
+ async createDeviceCode(input = {}) {
1277
+ const response = await post("/api/platform/v1/auth/device/code", {
1278
+ client_id: input.clientId ?? "lucern-cli",
1279
+ scope: input.scope ?? "graph.read graph.write"
1280
+ });
1281
+ const payload = await readJson(response);
1282
+ if (!response.ok) {
1283
+ maybeThrowDeviceError(payload);
1284
+ }
1285
+ return assertDeviceCodeResponse(payload);
1286
+ },
1287
+ async pollDeviceToken(deviceCode) {
1288
+ const response = await post("/api/platform/v1/auth/device/token", {
1289
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
1290
+ device_code: deviceCode
1291
+ });
1292
+ const payload = await readJson(response);
1293
+ if (!response.ok) {
1294
+ maybeThrowDeviceError(payload);
1295
+ }
1296
+ return assertDeviceTokenResponse(payload);
1297
+ }
1298
+ };
1299
+ }
1300
+
1004
1301
  // src/beliefsClient.ts
1005
1302
  function asRecord2(value) {
1006
1303
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1007
1304
  }
1008
- function readString(value) {
1305
+ function readString2(value) {
1009
1306
  if (typeof value !== "string") {
1010
1307
  return void 0;
1011
1308
  }
@@ -1042,15 +1339,15 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1042
1339
  const record = asRecord2(value);
1043
1340
  const tuple = normalizeOpinionTuple(record);
1044
1341
  const projected = readNumber(record.confidence) ?? clamp01(tuple.b + tuple.a * tuple.u);
1045
- const triggeringEvidenceId = readString(record.triggeringEvidenceId);
1046
- const triggeringQuestionId = readString(record.triggeringQuestionId);
1047
- const triggeringAnswerId = readString(record.triggeringAnswerId);
1048
- const triggeringContradictionId = readString(
1342
+ const triggeringEvidenceId = readString2(record.triggeringEvidenceId);
1343
+ const triggeringQuestionId = readString2(record.triggeringQuestionId);
1344
+ const triggeringAnswerId = readString2(record.triggeringAnswerId);
1345
+ const triggeringContradictionId = readString2(
1049
1346
  record.triggeringContradictionId
1050
1347
  );
1051
- const triggeringWorktreeId = readString(record.triggeringWorktreeId);
1348
+ const triggeringWorktreeId = readString2(record.triggeringWorktreeId);
1052
1349
  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;
1053
- const trigger = readString(record.trigger);
1350
+ const trigger = readString2(record.trigger);
1054
1351
  if (!trigger) {
1055
1352
  throw new Error("Gateway opinion history entries must include trigger.");
1056
1353
  }
@@ -1063,9 +1360,9 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1063
1360
  P: clamp01(projected),
1064
1361
  trigger,
1065
1362
  ...triggeringRef ? { triggeringRef } : {},
1066
- ...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
1067
- ...readString(record.userId) ? { userId: readString(record.userId) } : {},
1068
- ...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
1363
+ ...readString2(record.rationale) ? { rationale: readString2(record.rationale) } : {},
1364
+ ...readString2(record.userId) ? { userId: readString2(record.userId) } : {},
1365
+ ...readString2(record.slOperator) ? { slOperator: readString2(record.slOperator) } : {}
1069
1366
  };
1070
1367
  }).sort((left, right) => left.t - right.t);
1071
1368
  }
@@ -1300,6 +1597,180 @@ function createEvidenceClient(config = {}) {
1300
1597
  }
1301
1598
  };
1302
1599
  }
1600
+
1601
+ // src/boundaryClientSurface.ts
1602
+ function cleanOptionalString(value) {
1603
+ const normalized = value?.trim();
1604
+ return normalized ? normalized : void 0;
1605
+ }
1606
+ function cleanRequiredString(value, label) {
1607
+ const normalized = cleanOptionalString(value);
1608
+ if (!normalized) {
1609
+ throw new Error(`${label} is required`);
1610
+ }
1611
+ return normalized;
1612
+ }
1613
+ function readTopicId(input) {
1614
+ return cleanOptionalString(input.topicId) ?? cleanOptionalString(input.projectId);
1615
+ }
1616
+ function requireTopicId(input) {
1617
+ const topicId = readTopicId(input);
1618
+ if (!topicId) {
1619
+ throw new Error("topicId is required");
1620
+ }
1621
+ return topicId;
1622
+ }
1623
+ function assertKnownKeys(input, allowed, operation) {
1624
+ const allowedSet = new Set(allowed);
1625
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
1626
+ if (unknownKeys.length > 0) {
1627
+ throw new Error(
1628
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
1629
+ );
1630
+ }
1631
+ }
1632
+ function knownPayload(input, allowed, operation) {
1633
+ assertKnownKeys(input, allowed, operation);
1634
+ return { ...input };
1635
+ }
1636
+ function topicPayload(input, allowed, operation) {
1637
+ assertKnownKeys(input, allowed, operation);
1638
+ return {
1639
+ ...input,
1640
+ topicId: requireTopicId(input),
1641
+ projectId: void 0
1642
+ };
1643
+ }
1644
+ function listResultFromEnvelope(data, legacyKey) {
1645
+ const record = data && typeof data === "object" ? data : {};
1646
+ return createListResult(
1647
+ Array.isArray(record[legacyKey]) ? record[legacyKey] : Array.isArray(data) ? data : [],
1648
+ legacyKey
1649
+ );
1650
+ }
1651
+
1652
+ // src/eventingClient.ts
1653
+ var EVENTING_FIELDS = [
1654
+ "tenantId",
1655
+ "workspaceId",
1656
+ "principalId",
1657
+ "topicId",
1658
+ "eventId",
1659
+ "eventType",
1660
+ "eventPayload",
1661
+ "webhookId",
1662
+ "deliveryId",
1663
+ "status",
1664
+ "attempt",
1665
+ "statusCode",
1666
+ "error",
1667
+ "responseBody",
1668
+ "durationMs",
1669
+ "metadata",
1670
+ "limit",
1671
+ "cursor"
1672
+ ];
1673
+ function query(input) {
1674
+ return {
1675
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
1676
+ workspaceId: input.workspaceId,
1677
+ principalId: input.principalId,
1678
+ topicId: input.topicId,
1679
+ eventType: input.eventType,
1680
+ webhookId: input.webhookId,
1681
+ status: input.status,
1682
+ limit: input.limit,
1683
+ cursor: input.cursor
1684
+ };
1685
+ }
1686
+ function body(input, operation) {
1687
+ return knownPayload(input, EVENTING_FIELDS, operation);
1688
+ }
1689
+ function createEventingClient(config = {}) {
1690
+ const gateway = createGatewayRequestClient(config);
1691
+ return {
1692
+ recordEvent(input, idempotencyKey) {
1693
+ cleanRequiredString(input.tenantId, "tenantId");
1694
+ cleanRequiredString(input.eventType, "eventType");
1695
+ return gateway.request({
1696
+ path: "/api/platform/v1/events",
1697
+ method: "POST",
1698
+ body: body(
1699
+ input,
1700
+ "events.recordEvent"
1701
+ ),
1702
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1703
+ });
1704
+ },
1705
+ listEvents(input) {
1706
+ return gateway.request({
1707
+ path: `/api/platform/v1/events${toQueryString(query(input))}`
1708
+ }).then(
1709
+ (response) => mapGatewayData(
1710
+ response,
1711
+ (data) => listResultFromEnvelope(data, "events")
1712
+ )
1713
+ );
1714
+ },
1715
+ listWebhooks(input) {
1716
+ return gateway.request({
1717
+ path: `/api/platform/v1/webhooks${toQueryString(query(input))}`
1718
+ }).then(
1719
+ (response) => mapGatewayData(
1720
+ response,
1721
+ (data) => listResultFromEnvelope(
1722
+ data,
1723
+ "webhooks"
1724
+ )
1725
+ )
1726
+ );
1727
+ },
1728
+ enqueueDelivery(input, idempotencyKey) {
1729
+ cleanRequiredString(input.tenantId, "tenantId");
1730
+ cleanRequiredString(input.eventId, "eventId");
1731
+ cleanRequiredString(input.webhookId, "webhookId");
1732
+ return gateway.request({
1733
+ path: "/api/platform/v1/events/deliveries",
1734
+ method: "POST",
1735
+ body: body(
1736
+ input,
1737
+ "events.enqueueDelivery"
1738
+ ),
1739
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1740
+ });
1741
+ },
1742
+ recordDeliveryAttempt(input, idempotencyKey) {
1743
+ cleanRequiredString(input.tenantId, "tenantId");
1744
+ cleanRequiredString(input.deliveryId, "deliveryId");
1745
+ return gateway.request({
1746
+ path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
1747
+ input.deliveryId
1748
+ )}/attempts`,
1749
+ method: "POST",
1750
+ body: body(
1751
+ input,
1752
+ "events.recordDeliveryAttempt"
1753
+ ),
1754
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1755
+ });
1756
+ },
1757
+ updateDeliveryStatus(input, idempotencyKey) {
1758
+ cleanRequiredString(input.tenantId, "tenantId");
1759
+ cleanRequiredString(input.deliveryId, "deliveryId");
1760
+ return gateway.request({
1761
+ path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
1762
+ input.deliveryId
1763
+ )}/status`,
1764
+ method: "PATCH",
1765
+ body: body(
1766
+ input,
1767
+ "events.updateDeliveryStatus"
1768
+ ),
1769
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1770
+ });
1771
+ }
1772
+ };
1773
+ }
1303
1774
  var DEFAULT_CUSTOM_NAMESPACE = "custom";
1304
1775
  var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
1305
1776
  var CustomToolRegistryError = class extends Error {
@@ -1705,10 +2176,10 @@ function createGraphClient(config = {}) {
1705
2176
  /**
1706
2177
  * List graph nodes matching the provided filters.
1707
2178
  */
1708
- async listNodes(query) {
2179
+ async listNodes(query5) {
1709
2180
  return gateway.request({
1710
2181
  path: `/api/platform/v1/graph/nodes${toQueryString(
1711
- normalizeTopicQuery(query)
2182
+ normalizeTopicQuery(query5)
1712
2183
  )}`
1713
2184
  }).then(
1714
2185
  (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
@@ -1717,15 +2188,15 @@ function createGraphClient(config = {}) {
1717
2188
  /**
1718
2189
  * @deprecated Use listNodes.
1719
2190
  */
1720
- async queryNodes(query) {
1721
- return this.listNodes(query);
2191
+ async queryNodes(query5) {
2192
+ return this.listNodes(query5);
1722
2193
  },
1723
2194
  /**
1724
2195
  * Retrieve a single graph node by nodeId or globalId.
1725
2196
  */
1726
- async getNode(query) {
2197
+ async getNode(query5) {
1727
2198
  return gateway.request({
1728
- path: `/api/platform/v1/graph/nodes${toQueryString(query)}`
2199
+ path: `/api/platform/v1/graph/nodes${toQueryString(query5)}`
1729
2200
  }).then(
1730
2201
  (response) => mapGatewayData(
1731
2202
  response,
@@ -1818,10 +2289,10 @@ function createGraphClient(config = {}) {
1818
2289
  /**
1819
2290
  * List graph edges matching the provided filters.
1820
2291
  */
1821
- async listEdges(query) {
2292
+ async listEdges(query5) {
1822
2293
  return gateway.request({
1823
2294
  path: `/api/platform/v1/graph/edges${toQueryString(
1824
- normalizeTopicQuery(query)
2295
+ normalizeTopicQuery(query5)
1825
2296
  )}`
1826
2297
  }).then(
1827
2298
  (response) => mapGatewayData(
@@ -1833,8 +2304,8 @@ function createGraphClient(config = {}) {
1833
2304
  /**
1834
2305
  * @deprecated Use listEdges.
1835
2306
  */
1836
- async queryEdges(query) {
1837
- return this.listEdges(query);
2307
+ async queryEdges(query5) {
2308
+ return this.listEdges(query5);
1838
2309
  },
1839
2310
  /**
1840
2311
  * Create a graph edge.
@@ -1850,9 +2321,9 @@ function createGraphClient(config = {}) {
1850
2321
  /**
1851
2322
  * Delete one or more edges matching the provided filter.
1852
2323
  */
1853
- async deleteEdge(query, idempotencyKey) {
2324
+ async deleteEdge(query5, idempotencyKey) {
1854
2325
  return gateway.request({
1855
- path: `/api/platform/v1/graph/edges${toQueryString(query)}`,
2326
+ path: `/api/platform/v1/graph/edges${toQueryString(query5)}`,
1856
2327
  method: "DELETE",
1857
2328
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1858
2329
  });
@@ -1860,26 +2331,26 @@ function createGraphClient(config = {}) {
1860
2331
  /**
1861
2332
  * Retrieve a graph neighborhood around a root node.
1862
2333
  */
1863
- async neighborhood(query) {
2334
+ async neighborhood(query5) {
1864
2335
  return gateway.request({
1865
- path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`
2336
+ path: `/api/platform/v1/graph/neighborhood${toQueryString(query5)}`
1866
2337
  });
1867
2338
  },
1868
2339
  /**
1869
2340
  * Traverse the graph from a starting node.
1870
2341
  */
1871
- async traverse(query) {
2342
+ async traverse(query5) {
1872
2343
  return gateway.request({
1873
2344
  path: "/api/platform/v1/graph/traverse",
1874
2345
  method: "POST",
1875
- body: normalizeTopicQuery(query)
2346
+ body: normalizeTopicQuery(query5)
1876
2347
  });
1877
2348
  },
1878
2349
  /**
1879
2350
  * Analyze graph structure for a topic.
1880
2351
  */
1881
- async analyze(query = {}) {
1882
- const normalized = normalizeTopicQuery(query);
2352
+ async analyze(query5 = {}) {
2353
+ const normalized = normalizeTopicQuery(query5);
1883
2354
  return gateway.request({
1884
2355
  path: `/api/platform/v1/graph/analyze${toQueryString({
1885
2356
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -1891,8 +2362,8 @@ function createGraphClient(config = {}) {
1891
2362
  /**
1892
2363
  * Detect confirmation-bias patterns for a topic graph.
1893
2364
  */
1894
- async bias(query = {}) {
1895
- const normalized = normalizeTopicQuery(query);
2365
+ async bias(query5 = {}) {
2366
+ const normalized = normalizeTopicQuery(query5);
1896
2367
  return gateway.request({
1897
2368
  path: `/api/platform/v1/graph/bias${toQueryString({
1898
2369
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -1904,8 +2375,8 @@ function createGraphClient(config = {}) {
1904
2375
  /**
1905
2376
  * Find graph gaps for beliefs that still need testing.
1906
2377
  */
1907
- async gaps(query) {
1908
- const normalized = normalizeTopicQuery(query);
2378
+ async gaps(query5) {
2379
+ const normalized = normalizeTopicQuery(query5);
1909
2380
  return gateway.request({
1910
2381
  path: `/api/platform/v1/graph/gaps${toQueryString({
1911
2382
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -1916,33 +2387,33 @@ function createGraphClient(config = {}) {
1916
2387
  /**
1917
2388
  * Search across graph resources within a topic.
1918
2389
  */
1919
- async search(query) {
2390
+ async search(query5) {
1920
2391
  return gateway.request({
1921
2392
  path: "/api/platform/v1/search",
1922
2393
  method: "POST",
1923
- body: normalizeTopicQuery(query)
2394
+ body: normalizeTopicQuery(query5)
1924
2395
  });
1925
2396
  },
1926
2397
  /**
1927
2398
  * Retrieve a graph neighborhood around a root node.
1928
2399
  */
1929
- async getNeighborhood(query) {
1930
- return this.neighborhood(query);
2400
+ async getNeighborhood(query5) {
2401
+ return this.neighborhood(query5);
1931
2402
  },
1932
2403
  /**
1933
2404
  * Retrieve the shortest known path between two graph nodes.
1934
2405
  */
1935
- async getPath(query) {
2406
+ async getPath(query5) {
1936
2407
  return gateway.request({
1937
- path: `/api/platform/v1/graph/path${toQueryString(query)}`
2408
+ path: `/api/platform/v1/graph/path${toQueryString(query5)}`
1938
2409
  });
1939
2410
  },
1940
2411
  /**
1941
2412
  * Retrieve graph analytics for the requested metric.
1942
2413
  */
1943
- async getAnalytics(query = {}) {
2414
+ async getAnalytics(query5 = {}) {
1944
2415
  return gateway.request({
1945
- path: `/api/platform/v1/graph/analytics${toQueryString(query)}`
2416
+ path: `/api/platform/v1/graph/analytics${toQueryString(query5)}`
1946
2417
  });
1947
2418
  }
1948
2419
  };
@@ -1959,6 +2430,37 @@ function createIdentityWhoamiClient(config = {}) {
1959
2430
  }
1960
2431
  };
1961
2432
  }
2433
+ var TENANT_IDENTITY_FIELDS = [
2434
+ "tenantId",
2435
+ "workspaceId",
2436
+ "principalId",
2437
+ "integrationKey",
2438
+ "secretRef",
2439
+ "policySubject",
2440
+ "policyAction",
2441
+ "policyResource",
2442
+ "decision",
2443
+ "config",
2444
+ "configKey",
2445
+ "configValue",
2446
+ "provider",
2447
+ "status",
2448
+ "metadata",
2449
+ "limit",
2450
+ "cursor"
2451
+ ];
2452
+ function tenantIdentityQuery(input) {
2453
+ return {
2454
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
2455
+ workspaceId: input.workspaceId,
2456
+ principalId: input.principalId,
2457
+ limit: input.limit,
2458
+ cursor: input.cursor
2459
+ };
2460
+ }
2461
+ function tenantIdentityBody(input, operation) {
2462
+ return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
2463
+ }
1962
2464
  function createIdentityClient(config = {}) {
1963
2465
  const gateway = createGatewayRequestClient(config);
1964
2466
  const whoamiClient = createIdentityWhoamiClient(config);
@@ -1994,9 +2496,9 @@ function createIdentityClient(config = {}) {
1994
2496
  /**
1995
2497
  * List principals in the current identity scope.
1996
2498
  */
1997
- async listPrincipals(query = {}) {
2499
+ async listPrincipals(query5 = {}) {
1998
2500
  return gateway.request({
1999
- path: `/api/platform/v1/identity/principals${toQueryString(query)}`
2501
+ path: `/api/platform/v1/identity/principals${toQueryString(query5)}`
2000
2502
  }).then(
2001
2503
  (response) => mapGatewayData(
2002
2504
  response,
@@ -2028,9 +2530,9 @@ function createIdentityClient(config = {}) {
2028
2530
  /**
2029
2531
  * List keys in the current identity scope.
2030
2532
  */
2031
- async listKeys(query = {}) {
2533
+ async listKeys(query5 = {}) {
2032
2534
  return gateway.request({
2033
- path: `/api/platform/v1/identity/keys${toQueryString(query)}`
2535
+ path: `/api/platform/v1/identity/keys${toQueryString(query5)}`
2034
2536
  }).then(
2035
2537
  (response) => mapGatewayData(
2036
2538
  response,
@@ -2084,6 +2586,109 @@ function createIdentityClient(config = {}) {
2084
2586
  return gateway.request({
2085
2587
  path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
2086
2588
  });
2589
+ },
2590
+ async getTenantConfig(input) {
2591
+ return gateway.request({
2592
+ path: `/api/platform/v1/identity/tenant-config${toQueryString(
2593
+ tenantIdentityQuery(input)
2594
+ )}`
2595
+ });
2596
+ },
2597
+ async updateTenantConfig(input, idempotencyKey) {
2598
+ cleanRequiredString(input.tenantId, "tenantId");
2599
+ return gateway.request({
2600
+ path: "/api/platform/v1/identity/tenant-config",
2601
+ method: "PATCH",
2602
+ body: tenantIdentityBody(
2603
+ input,
2604
+ "identity.updateTenantConfig"
2605
+ ),
2606
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2607
+ });
2608
+ },
2609
+ async listIntegrations(input) {
2610
+ return gateway.request({
2611
+ path: `/api/platform/v1/identity/integrations${toQueryString(
2612
+ tenantIdentityQuery(input)
2613
+ )}`
2614
+ }).then(
2615
+ (response) => mapGatewayData(
2616
+ response,
2617
+ (data) => listResultFromEnvelope(
2618
+ data,
2619
+ "integrations"
2620
+ )
2621
+ )
2622
+ );
2623
+ },
2624
+ async upsertIntegration(input, idempotencyKey) {
2625
+ cleanRequiredString(input.tenantId, "tenantId");
2626
+ cleanRequiredString(input.integrationKey, "integrationKey");
2627
+ return gateway.request({
2628
+ path: "/api/platform/v1/identity/integrations",
2629
+ method: "PUT",
2630
+ body: tenantIdentityBody(
2631
+ input,
2632
+ "identity.upsertIntegration"
2633
+ ),
2634
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2635
+ });
2636
+ },
2637
+ async listSecrets(input) {
2638
+ return gateway.request({
2639
+ path: `/api/platform/v1/identity/secrets${toQueryString(
2640
+ tenantIdentityQuery(input)
2641
+ )}`
2642
+ }).then(
2643
+ (response) => mapGatewayData(
2644
+ response,
2645
+ (data) => listResultFromEnvelope(
2646
+ data,
2647
+ "secrets"
2648
+ )
2649
+ )
2650
+ );
2651
+ },
2652
+ async putSecretReference(input, idempotencyKey) {
2653
+ cleanRequiredString(input.tenantId, "tenantId");
2654
+ cleanRequiredString(input.secretRef, "secretRef");
2655
+ return gateway.request({
2656
+ path: "/api/platform/v1/identity/secrets",
2657
+ method: "PUT",
2658
+ body: tenantIdentityBody(
2659
+ input,
2660
+ "identity.putSecretReference"
2661
+ ),
2662
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2663
+ });
2664
+ },
2665
+ async evaluatePolicy(input, idempotencyKey) {
2666
+ cleanRequiredString(input.tenantId, "tenantId");
2667
+ cleanRequiredString(input.policySubject, "policySubject");
2668
+ cleanRequiredString(input.policyAction, "policyAction");
2669
+ cleanRequiredString(input.policyResource, "policyResource");
2670
+ return gateway.request({
2671
+ path: "/api/platform/v1/identity/policy/evaluate",
2672
+ method: "POST",
2673
+ body: tenantIdentityBody(
2674
+ input,
2675
+ "identity.evaluatePolicy"
2676
+ ),
2677
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2678
+ });
2679
+ },
2680
+ async recordPolicyDecision(input, idempotencyKey) {
2681
+ cleanRequiredString(input.tenantId, "tenantId");
2682
+ cleanRequiredString(input.decision, "decision");
2683
+ return gateway.request({
2684
+ path: "/api/platform/v1/identity/policy/decisions",
2685
+ method: "POST",
2686
+ body: tenantIdentityBody(
2687
+ input,
2688
+ "identity.recordPolicyDecision"
2689
+ ),
2690
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2691
+ });
2087
2692
  }
2088
2693
  };
2089
2694
  }
@@ -2092,12 +2697,12 @@ function createIdentityClient(config = {}) {
2092
2697
  function asRecord3(value) {
2093
2698
  return value && typeof value === "object" ? value : {};
2094
2699
  }
2095
- function cleanString2(value) {
2700
+ function cleanString3(value) {
2096
2701
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
2097
2702
  }
2098
2703
  function normalizeTopicRecord(value) {
2099
2704
  const record = asRecord3(value);
2100
- const topicId = cleanString2(record.topicId) ?? cleanString2(record.id) ?? cleanString2(record._id);
2705
+ const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
2101
2706
  return withTopicAlias({
2102
2707
  ...record,
2103
2708
  ...topicId ? { topicId } : {}
@@ -2109,15 +2714,15 @@ function normalizeTopicTreeNode(value) {
2109
2714
  function createTopicsClient(config = {}) {
2110
2715
  const gateway = createGatewayRequestClient(config);
2111
2716
  return {
2112
- async list(query = {}) {
2113
- const topicId = resolveTopicId(query);
2717
+ async list(query5 = {}) {
2718
+ const topicId = resolveTopicId(query5);
2114
2719
  return gateway.request({
2115
2720
  path: `/api/platform/v1/topics${toQueryString({
2116
2721
  ...topicId ? { topicId } : {},
2117
- ontologyId: query.ontologyId,
2118
- parentTopicId: query.parentTopicId,
2119
- status: query.status,
2120
- type: query.type
2722
+ ontologyId: query5.ontologyId,
2723
+ parentTopicId: query5.parentTopicId,
2724
+ status: query5.status,
2725
+ type: query5.type
2121
2726
  })}`
2122
2727
  }).then(
2123
2728
  (response) => mapGatewayData(response, (data) => {
@@ -2167,10 +2772,10 @@ function createTopicsClient(config = {}) {
2167
2772
  (response) => mapGatewayData(response, (data) => normalizeTopicRecord(data))
2168
2773
  );
2169
2774
  },
2170
- async getTree(topicId, query = {}) {
2775
+ async getTree(topicId, query5 = {}) {
2171
2776
  return gateway.request({
2172
2777
  path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/tree${toQueryString(
2173
- query
2778
+ query5
2174
2779
  )}`
2175
2780
  }).then(
2176
2781
  (response) => mapGatewayData(response, (data) => {
@@ -2181,10 +2786,10 @@ function createTopicsClient(config = {}) {
2181
2786
  })
2182
2787
  );
2183
2788
  },
2184
- async getCoverage(topicId, query = {}) {
2789
+ async getCoverage(topicId, query5 = {}) {
2185
2790
  return gateway.request({
2186
2791
  path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/coverage${toQueryString(
2187
- query
2792
+ query5
2188
2793
  )}`
2189
2794
  });
2190
2795
  },
@@ -2244,15 +2849,15 @@ function createBeliefsFacade(config = {}) {
2244
2849
  path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`
2245
2850
  });
2246
2851
  },
2247
- async list(query) {
2852
+ async list(query5) {
2248
2853
  return gateway.request({
2249
2854
  path: `/api/platform/v1/beliefs${toQueryString({
2250
- topicId: query.topicId,
2251
- status: query.status,
2252
- worktreeId: query.worktreeId,
2253
- minConfidence: query.minConfidence,
2254
- limit: query.limit,
2255
- cursor: query.cursor
2855
+ topicId: query5.topicId,
2856
+ status: query5.status,
2857
+ worktreeId: query5.worktreeId,
2858
+ minConfidence: query5.minConfidence,
2859
+ limit: query5.limit,
2860
+ cursor: query5.cursor
2256
2861
  })}`
2257
2862
  });
2258
2863
  },
@@ -2388,13 +2993,13 @@ function createContradictionsFacade(config = {}) {
2388
2993
  idempotencyKey
2389
2994
  });
2390
2995
  },
2391
- async list(query) {
2996
+ async list(query5) {
2392
2997
  return gateway.request({
2393
2998
  path: `/api/platform/v1/contradictions${toQueryString({
2394
- topicId: query.topicId,
2395
- status: query.status,
2396
- limit: query.limit,
2397
- cursor: query.cursor
2999
+ topicId: query5.topicId,
3000
+ status: query5.status,
3001
+ limit: query5.limit,
3002
+ cursor: query5.cursor
2398
3003
  })}`
2399
3004
  });
2400
3005
  },
@@ -2416,13 +3021,13 @@ function createEdgesFacade(config = {}) {
2416
3021
  idempotencyKey
2417
3022
  });
2418
3023
  },
2419
- async list(query) {
3024
+ async list(query5) {
2420
3025
  return gateway.request({
2421
3026
  path: `/api/platform/v1/edges${toQueryString({
2422
- sourceId: query.sourceId,
2423
- edgeType: query.edgeType,
2424
- limit: query.limit,
2425
- cursor: query.cursor
3027
+ sourceId: query5.sourceId,
3028
+ edgeType: query5.edgeType,
3029
+ limit: query5.limit,
3030
+ cursor: query5.cursor
2426
3031
  })}`
2427
3032
  });
2428
3033
  },
@@ -2492,13 +3097,13 @@ function createEvidenceFacade(config = {}) {
2492
3097
  path: `/api/platform/v1/evidence/${encodeURIComponent(id)}`
2493
3098
  });
2494
3099
  },
2495
- async list(query) {
3100
+ async list(query5) {
2496
3101
  return gateway.request({
2497
3102
  path: `/api/platform/v1/evidence${toQueryString({
2498
- topicId: query.topicId,
2499
- targetId: query.targetId,
2500
- limit: query.limit,
2501
- cursor: query.cursor
3103
+ topicId: query5.topicId,
3104
+ targetId: query5.targetId,
3105
+ limit: query5.limit,
3106
+ cursor: query5.cursor
2502
3107
  })}`
2503
3108
  });
2504
3109
  },
@@ -2515,11 +3120,11 @@ function createEvidenceFacade(config = {}) {
2515
3120
  idempotencyKey
2516
3121
  });
2517
3122
  },
2518
- async search(query, idempotencyKey = randomIdempotencyKey()) {
3123
+ async search(query5, idempotencyKey = randomIdempotencyKey()) {
2519
3124
  return gateway.request({
2520
3125
  path: "/api/platform/v1/evidence/search",
2521
3126
  method: "POST",
2522
- body: query,
3127
+ body: query5,
2523
3128
  idempotencyKey
2524
3129
  });
2525
3130
  },
@@ -2568,15 +3173,15 @@ function createEvidenceFacade(config = {}) {
2568
3173
  function createEventsFacade(config = {}) {
2569
3174
  const gateway = createGatewayRequestClient(config);
2570
3175
  return {
2571
- async list(query = {}) {
3176
+ async list(query5 = {}) {
2572
3177
  return gateway.request({
2573
3178
  path: `/api/platform/v1/events${toQueryString({
2574
- topicId: query.topicId,
2575
- after: query.after,
2576
- types: serializeTypes(query.types),
2577
- startTime: query.startTime,
2578
- endTime: query.endTime,
2579
- limit: query.limit
3179
+ topicId: query5.topicId,
3180
+ after: query5.after,
3181
+ types: serializeTypes(query5.types),
3182
+ startTime: query5.startTime,
3183
+ endTime: query5.endTime,
3184
+ limit: query5.limit
2580
3185
  })}`
2581
3186
  });
2582
3187
  },
@@ -2641,8 +3246,8 @@ function createOntologiesFacade(config = {}) {
2641
3246
  path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2642
3247
  });
2643
3248
  },
2644
- async list(query = {}) {
2645
- return ontologyClient.list(query);
3249
+ async list(query5 = {}) {
3250
+ return ontologyClient.list(query5);
2646
3251
  },
2647
3252
  async bind(input, idempotencyKey) {
2648
3253
  return gateway.request({
@@ -2680,15 +3285,15 @@ function createQuestionsFacade(config = {}) {
2680
3285
  path: `/api/platform/v1/questions/${encodeURIComponent(id)}`
2681
3286
  });
2682
3287
  },
2683
- async list(query) {
3288
+ async list(query5) {
2684
3289
  return gateway.request({
2685
3290
  path: `/api/platform/v1/questions${toQueryString({
2686
- topicId: query.topicId,
2687
- status: query.status,
2688
- priority: query.priority,
2689
- worktreeId: query.worktreeId,
2690
- limit: query.limit,
2691
- cursor: query.cursor
3291
+ topicId: query5.topicId,
3292
+ status: query5.status,
3293
+ priority: query5.priority,
3294
+ worktreeId: query5.worktreeId,
3295
+ limit: query5.limit,
3296
+ cursor: query5.cursor
2692
3297
  })}`
2693
3298
  });
2694
3299
  },
@@ -2840,13 +3445,13 @@ function createTasksFacade(config = {}) {
2840
3445
  idempotencyKey
2841
3446
  });
2842
3447
  },
2843
- async list(query) {
3448
+ async list(query5) {
2844
3449
  return gateway.request({
2845
3450
  path: `/api/platform/v1/tasks${toQueryString({
2846
- topicId: query.topicId,
2847
- worktreeId: query.worktreeId,
2848
- status: query.status,
2849
- limit: query.limit
3451
+ topicId: query5.topicId,
3452
+ worktreeId: query5.worktreeId,
3453
+ status: query5.status,
3454
+ limit: query5.limit
2850
3455
  })}`
2851
3456
  });
2852
3457
  }
@@ -2861,8 +3466,8 @@ function createTopicsFacade(config = {}) {
2861
3466
  async get(id) {
2862
3467
  return topicsClient.get(id);
2863
3468
  },
2864
- async list(query = {}) {
2865
- return topicsClient.list(query);
3469
+ async list(query5 = {}) {
3470
+ return topicsClient.list(query5);
2866
3471
  },
2867
3472
  async update(input, idempotencyKey) {
2868
3473
  const { id, ...rest } = input;
@@ -2898,10 +3503,10 @@ function createWebhooksFacade(config = {}) {
2898
3503
  idempotencyKey
2899
3504
  });
2900
3505
  },
2901
- async list(query = {}) {
3506
+ async list(query5 = {}) {
2902
3507
  return gateway.request({
2903
3508
  path: `/api/platform/v1/webhooks${toQueryString({
2904
- topicId: query.topicId
3509
+ topicId: query5.topicId
2905
3510
  })}`
2906
3511
  });
2907
3512
  },
@@ -2933,10 +3538,10 @@ function createWebhooksFacade(config = {}) {
2933
3538
  idempotencyKey
2934
3539
  });
2935
3540
  },
2936
- async deliveries(id, query = {}) {
3541
+ async deliveries(id, query5 = {}) {
2937
3542
  return gateway.request({
2938
3543
  path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
2939
- limit: query.limit
3544
+ limit: query5.limit
2940
3545
  })}`
2941
3546
  });
2942
3547
  },
@@ -2958,24 +3563,24 @@ function createWorktreesFacade(config = {}) {
2958
3563
  idempotencyKey
2959
3564
  });
2960
3565
  },
2961
- async list(query) {
3566
+ async list(query5) {
2962
3567
  return gateway.request({
2963
3568
  path: `/api/platform/v1/worktrees${toQueryString({
2964
- topicId: query.topicId,
2965
- status: query.status,
2966
- groupBy: query.groupBy,
2967
- lane: query.lane,
2968
- campaign: query.campaign,
2969
- limit: query.limit
3569
+ topicId: query5.topicId,
3570
+ status: query5.status,
3571
+ groupBy: query5.groupBy,
3572
+ lane: query5.lane,
3573
+ campaign: query5.campaign,
3574
+ limit: query5.limit
2970
3575
  })}`
2971
3576
  });
2972
3577
  },
2973
- async listCampaigns(query = {}) {
3578
+ async listCampaigns(query5 = {}) {
2974
3579
  return gateway.request({
2975
3580
  path: `/api/platform/v1/worktrees/campaigns${toQueryString({
2976
- topicId: query.topicId,
2977
- status: query.status,
2978
- limit: query.limit
3581
+ topicId: query5.topicId,
3582
+ status: query5.status,
3583
+ limit: query5.limit
2979
3584
  })}`
2980
3585
  });
2981
3586
  },
@@ -3088,12 +3693,12 @@ function createDecisionsClient(config = {}) {
3088
3693
  /**
3089
3694
  * List judgments for a topic scope.
3090
3695
  */
3091
- async listJudgments(query) {
3696
+ async listJudgments(query5) {
3092
3697
  return gateway.request({
3093
3698
  path: `/api/platform/v1/graph/judgments${toQueryString({
3094
- ...normalizeTopicQuery(query),
3095
- includeArchived: typeof query.includeArchived === "boolean" ? query.includeArchived ? "true" : "false" : void 0,
3096
- limit: query.limit
3699
+ ...normalizeTopicQuery(query5),
3700
+ includeArchived: typeof query5.includeArchived === "boolean" ? query5.includeArchived ? "true" : "false" : void 0,
3701
+ limit: query5.limit
3097
3702
  })}`
3098
3703
  }).then(
3099
3704
  (response) => mapGatewayData(response, (data) => {
@@ -3125,30 +3730,30 @@ function createDecisionsClient(config = {}) {
3125
3730
  /**
3126
3731
  * Get readiness signals for creating a judgment.
3127
3732
  */
3128
- async getJudgmentReadiness(query) {
3733
+ async getJudgmentReadiness(query5) {
3129
3734
  return gateway.request({
3130
3735
  path: `/api/platform/v1/graph/judgments/readiness${toQueryString(
3131
- normalizeTopicQuery(query)
3736
+ normalizeTopicQuery(query5)
3132
3737
  )}`
3133
3738
  });
3134
3739
  },
3135
3740
  /**
3136
3741
  * Get calibration analytics for judgment outcomes.
3137
3742
  */
3138
- async getJudgmentCalibration(query) {
3743
+ async getJudgmentCalibration(query5) {
3139
3744
  return gateway.request({
3140
3745
  path: `/api/platform/v1/graph/judgments/calibration${toQueryString(
3141
- normalizeTopicQuery(query)
3746
+ normalizeTopicQuery(query5)
3142
3747
  )}`
3143
3748
  });
3144
3749
  },
3145
3750
  /**
3146
3751
  * List judgments still awaiting outcome review.
3147
3752
  */
3148
- async listPendingOutcomeReviews(query) {
3753
+ async listPendingOutcomeReviews(query5) {
3149
3754
  return gateway.request({
3150
3755
  path: `/api/platform/v1/graph/judgments/pending-outcome-review${toQueryString(
3151
- normalizeTopicQuery(query)
3756
+ normalizeTopicQuery(query5)
3152
3757
  )}`
3153
3758
  }).then(
3154
3759
  (response) => mapGatewayData(response, (data) => {
@@ -3165,19 +3770,19 @@ function createDecisionsClient(config = {}) {
3165
3770
  /**
3166
3771
  * @deprecated Use listPendingOutcomeReviews.
3167
3772
  */
3168
- async listPendingJudgmentOutcomeReview(query) {
3169
- return this.listPendingOutcomeReviews(query);
3773
+ async listPendingJudgmentOutcomeReview(query5) {
3774
+ return this.listPendingOutcomeReviews(query5);
3170
3775
  },
3171
3776
  /**
3172
3777
  * Get audit integrity checks for judgment transitions.
3173
3778
  */
3174
- async getJudgmentTransitionAuditIntegrity(query) {
3779
+ async getJudgmentTransitionAuditIntegrity(query5) {
3175
3780
  return gateway.request({
3176
3781
  path: `/api/platform/v1/graph/judgments/transition-audit-integrity${toQueryString(
3177
3782
  {
3178
- ...normalizeTopicQuery(query),
3179
- judgmentId: query.judgmentId,
3180
- includePassing: typeof query.includePassing === "boolean" ? query.includePassing ? "true" : "false" : void 0
3783
+ ...normalizeTopicQuery(query5),
3784
+ judgmentId: query5.judgmentId,
3785
+ includePassing: typeof query5.includePassing === "boolean" ? query5.includePassing ? "true" : "false" : void 0
3181
3786
  }
3182
3787
  )}`
3183
3788
  });
@@ -3226,58 +3831,170 @@ function createDecisionsClient(config = {}) {
3226
3831
  };
3227
3832
  }
3228
3833
 
3229
- // src/contextClient.ts
3230
- function cleanString3(value) {
3231
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
3232
- }
3233
- function cleanNumber(value) {
3234
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
3834
+ // src/embeddingsClient.ts
3835
+ var EMBEDDINGS_FIELDS = [
3836
+ "topicId",
3837
+ "projectId",
3838
+ "workspaceId",
3839
+ "nodeIds",
3840
+ "nodeType",
3841
+ "embeddingModel",
3842
+ "queryText",
3843
+ "queryVector",
3844
+ "minScore",
3845
+ "limit",
3846
+ "cursor",
3847
+ "metadata"
3848
+ ];
3849
+ function assertNodeIds(nodeIds) {
3850
+ if (!Array.isArray(nodeIds) || nodeIds.length === 0) {
3851
+ throw new Error("nodeIds is required");
3852
+ }
3235
3853
  }
3236
- function cleanBoolean(value) {
3237
- return typeof value === "boolean" ? value : void 0;
3854
+ function missingQuery(input) {
3855
+ return {
3856
+ topicId: requireTopicId(input),
3857
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId"),
3858
+ nodeType: input.nodeType,
3859
+ embeddingModel: input.embeddingModel,
3860
+ limit: input.limit,
3861
+ cursor: input.cursor
3862
+ };
3238
3863
  }
3239
- function buildCompileContextRequest(topicId, input = {}) {
3240
- const payload = { topicId };
3241
- const query = cleanString3(input.query);
3242
- if (query) {
3243
- payload.query = query;
3244
- }
3245
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3246
- if (budget !== void 0) {
3247
- payload.budget = budget;
3248
- }
3249
- const ranking = cleanString3(input.ranking) ?? cleanString3(input.rankingProfile);
3250
- if (ranking) {
3251
- payload.ranking = ranking;
3252
- }
3253
- const limit = cleanNumber(input.limit);
3254
- if (limit !== void 0) {
3255
- payload.limit = limit;
3256
- }
3257
- const maxDepth = cleanNumber(input.maxDepth);
3258
- if (maxDepth !== void 0) {
3259
- payload.maxDepth = maxDepth;
3260
- }
3261
- const includeEntities = cleanBoolean(input.includeEntities);
3262
- if (includeEntities !== void 0) {
3263
- payload.includeEntities = includeEntities;
3264
- }
3265
- const mode = cleanString3(input.mode);
3266
- if (mode) {
3267
- payload.mode = mode;
3268
- }
3269
- const includeFailures = cleanBoolean(input.includeFailures);
3270
- if (includeFailures !== void 0) {
3271
- payload.includeFailures = includeFailures;
3272
- }
3273
- const worktreeId = cleanString3(input.worktreeId);
3274
- if (worktreeId) {
3275
- payload.worktreeId = worktreeId;
3276
- }
3277
- const sessionId = cleanString3(input.sessionId);
3278
- if (sessionId) {
3279
- payload.sessionId = sessionId;
3280
- }
3864
+ function createEmbeddingsClient(config = {}) {
3865
+ const gateway = createGatewayRequestClient(config);
3866
+ return {
3867
+ getByNodeIds(input) {
3868
+ assertNodeIds(input.nodeIds);
3869
+ return gateway.request({
3870
+ path: "/api/platform/v1/embeddings/by-node-ids",
3871
+ method: "POST",
3872
+ body: topicPayload(
3873
+ {
3874
+ ...input,
3875
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
3876
+ },
3877
+ EMBEDDINGS_FIELDS,
3878
+ "embeddings.getByNodeIds"
3879
+ )
3880
+ }).then(
3881
+ (response) => mapGatewayData(
3882
+ response,
3883
+ (data) => listResultFromEnvelope(
3884
+ data,
3885
+ "embeddings"
3886
+ )
3887
+ )
3888
+ );
3889
+ },
3890
+ listMissingForTopic(input) {
3891
+ return gateway.request({
3892
+ path: `/api/platform/v1/embeddings/missing${toQueryString(
3893
+ missingQuery(input)
3894
+ )}`
3895
+ }).then(
3896
+ (response) => mapGatewayData(
3897
+ response,
3898
+ (data) => listResultFromEnvelope(
3899
+ data,
3900
+ "nodes"
3901
+ )
3902
+ )
3903
+ );
3904
+ },
3905
+ vectorSearchByTopic(input) {
3906
+ if (!input.queryText && !input.queryVector) {
3907
+ throw new Error("queryText or queryVector is required");
3908
+ }
3909
+ return gateway.request({
3910
+ path: "/api/platform/v1/embeddings/vector-search",
3911
+ method: "POST",
3912
+ body: topicPayload(
3913
+ {
3914
+ ...input,
3915
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
3916
+ },
3917
+ EMBEDDINGS_FIELDS,
3918
+ "embeddings.vectorSearchByTopic"
3919
+ )
3920
+ }).then(
3921
+ (response) => mapGatewayData(
3922
+ response,
3923
+ (data) => listResultFromEnvelope(data, "results")
3924
+ )
3925
+ );
3926
+ },
3927
+ markEmbeddingBackfillQueued(input, idempotencyKey) {
3928
+ assertNodeIds(input.nodeIds);
3929
+ return gateway.request({
3930
+ path: "/api/platform/v1/embeddings/backfill-queued",
3931
+ method: "POST",
3932
+ body: topicPayload(
3933
+ {
3934
+ ...input,
3935
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
3936
+ },
3937
+ EMBEDDINGS_FIELDS,
3938
+ "embeddings.markEmbeddingBackfillQueued"
3939
+ ),
3940
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
3941
+ });
3942
+ }
3943
+ };
3944
+ }
3945
+
3946
+ // src/contextClient.ts
3947
+ function cleanString4(value) {
3948
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
3949
+ }
3950
+ function cleanNumber(value) {
3951
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
3952
+ }
3953
+ function cleanBoolean(value) {
3954
+ return typeof value === "boolean" ? value : void 0;
3955
+ }
3956
+ function buildCompileContextRequest(topicId, input = {}) {
3957
+ const payload = { topicId };
3958
+ const query5 = cleanString4(input.query);
3959
+ if (query5) {
3960
+ payload.query = query5;
3961
+ }
3962
+ const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3963
+ if (budget !== void 0) {
3964
+ payload.budget = budget;
3965
+ }
3966
+ const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
3967
+ if (ranking) {
3968
+ payload.ranking = ranking;
3969
+ }
3970
+ const limit = cleanNumber(input.limit);
3971
+ if (limit !== void 0) {
3972
+ payload.limit = limit;
3973
+ }
3974
+ const maxDepth = cleanNumber(input.maxDepth);
3975
+ if (maxDepth !== void 0) {
3976
+ payload.maxDepth = maxDepth;
3977
+ }
3978
+ const includeEntities = cleanBoolean(input.includeEntities);
3979
+ if (includeEntities !== void 0) {
3980
+ payload.includeEntities = includeEntities;
3981
+ }
3982
+ const mode = cleanString4(input.mode);
3983
+ if (mode) {
3984
+ payload.mode = mode;
3985
+ }
3986
+ const includeFailures = cleanBoolean(input.includeFailures);
3987
+ if (includeFailures !== void 0) {
3988
+ payload.includeFailures = includeFailures;
3989
+ }
3990
+ const worktreeId = cleanString4(input.worktreeId);
3991
+ if (worktreeId) {
3992
+ payload.worktreeId = worktreeId;
3993
+ }
3994
+ const sessionId = cleanString4(input.sessionId);
3995
+ if (sessionId) {
3996
+ payload.sessionId = sessionId;
3997
+ }
3281
3998
  if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
3282
3999
  payload.packWeightOverrides = input.packWeightOverrides;
3283
4000
  }
@@ -3306,6 +4023,406 @@ function createContextClient(config = {}) {
3306
4023
  };
3307
4024
  }
3308
4025
 
4026
+ // src/graphAnalysisClient.ts
4027
+ var GRAPH_ANALYSIS_ANALYSIS_FIELDS = [
4028
+ "topicId",
4029
+ "projectId",
4030
+ "workspaceId",
4031
+ "analysisType",
4032
+ "healthScore",
4033
+ "findings",
4034
+ "suggestions",
4035
+ "sourceNodeIds",
4036
+ "sourceEdgeIds",
4037
+ "detectorVersions",
4038
+ "metadata"
4039
+ ];
4040
+ var GRAPH_ANALYSIS_SUGGESTION_FIELDS = [
4041
+ "topicId",
4042
+ "projectId",
4043
+ "workspaceId",
4044
+ "analysisId",
4045
+ "suggestions",
4046
+ "metadata"
4047
+ ];
4048
+ var GRAPH_ANALYSIS_COMPUTE_FIELDS = [
4049
+ "topicId",
4050
+ "projectId",
4051
+ "workspaceId",
4052
+ "analysisType",
4053
+ "sourceNodeIds",
4054
+ "sourceEdgeIds",
4055
+ "detectorVersions",
4056
+ "metadata"
4057
+ ];
4058
+ function readTopicId2(input) {
4059
+ return input.topicId?.trim() || input.projectId?.trim() || void 0;
4060
+ }
4061
+ function requireTopicId2(input) {
4062
+ const topicId = readTopicId2(input);
4063
+ if (!topicId) {
4064
+ throw new Error("topicId is required");
4065
+ }
4066
+ return topicId;
4067
+ }
4068
+ function assertKnownKeys2(input, allowed, operation) {
4069
+ const allowedSet = new Set(allowed);
4070
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
4071
+ if (unknownKeys.length > 0) {
4072
+ throw new Error(
4073
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
4074
+ );
4075
+ }
4076
+ }
4077
+ function normalizeAnalysisPayload(input) {
4078
+ assertKnownKeys2(
4079
+ input,
4080
+ GRAPH_ANALYSIS_ANALYSIS_FIELDS,
4081
+ "graphAnalysis.saveAnalysis"
4082
+ );
4083
+ return {
4084
+ ...input,
4085
+ topicId: requireTopicId2(input),
4086
+ projectId: void 0
4087
+ };
4088
+ }
4089
+ function normalizeSuggestionPayload(input) {
4090
+ assertKnownKeys2(
4091
+ input,
4092
+ GRAPH_ANALYSIS_SUGGESTION_FIELDS,
4093
+ "graphAnalysis.saveSuggestions"
4094
+ );
4095
+ return {
4096
+ ...input,
4097
+ topicId: requireTopicId2(input),
4098
+ projectId: void 0
4099
+ };
4100
+ }
4101
+ function normalizeComputePayload(input) {
4102
+ assertKnownKeys2(
4103
+ input,
4104
+ GRAPH_ANALYSIS_COMPUTE_FIELDS,
4105
+ "graphAnalysis.computeOrRequestAnalysis"
4106
+ );
4107
+ return {
4108
+ ...input,
4109
+ topicId: requireTopicId2(input),
4110
+ projectId: void 0
4111
+ };
4112
+ }
4113
+ function graphAnalysisQuery(input) {
4114
+ return {
4115
+ topicId: requireTopicId2(input),
4116
+ workspaceId: input.workspaceId,
4117
+ analysisType: input.analysisType,
4118
+ limit: input.limit,
4119
+ cursor: input.cursor
4120
+ };
4121
+ }
4122
+ function createGraphAnalysisClient(config = {}) {
4123
+ const gateway = createGatewayRequestClient(config);
4124
+ return {
4125
+ saveAnalysis(input, idempotencyKey) {
4126
+ return gateway.request({
4127
+ path: "/api/platform/v1/graph-analysis/analyses",
4128
+ method: "POST",
4129
+ body: normalizeAnalysisPayload(input),
4130
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4131
+ });
4132
+ },
4133
+ listAnalyses(input) {
4134
+ return gateway.request({
4135
+ path: `/api/platform/v1/graph-analysis/analyses${toQueryString(
4136
+ graphAnalysisQuery(input)
4137
+ )}`
4138
+ }).then(
4139
+ (response) => mapGatewayData(
4140
+ response,
4141
+ (data) => createListResult(
4142
+ Array.isArray(data.analyses) ? data.analyses : Array.isArray(data) ? data : [],
4143
+ "analyses"
4144
+ )
4145
+ )
4146
+ );
4147
+ },
4148
+ getLatestAnalysis(input) {
4149
+ return gateway.request({
4150
+ path: `/api/platform/v1/graph-analysis/analyses/latest${toQueryString({
4151
+ topicId: requireTopicId2(input),
4152
+ workspaceId: input.workspaceId,
4153
+ analysisType: input.analysisType
4154
+ })}`
4155
+ });
4156
+ },
4157
+ saveSuggestions(input, idempotencyKey) {
4158
+ return gateway.request({
4159
+ path: "/api/platform/v1/graph-analysis/suggestions",
4160
+ method: "POST",
4161
+ body: normalizeSuggestionPayload(input),
4162
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4163
+ });
4164
+ },
4165
+ updateSuggestionStatus(input, idempotencyKey) {
4166
+ return gateway.request({
4167
+ path: `/api/platform/v1/graph-analysis/suggestions/${encodeURIComponent(
4168
+ input.suggestionId
4169
+ )}`,
4170
+ method: "PATCH",
4171
+ body: {
4172
+ status: input.status,
4173
+ rationale: input.rationale,
4174
+ metadata: input.metadata
4175
+ },
4176
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4177
+ });
4178
+ },
4179
+ listSuggestions(input) {
4180
+ return gateway.request({
4181
+ path: `/api/platform/v1/graph-analysis/suggestions${toQueryString({
4182
+ topicId: requireTopicId2(input),
4183
+ workspaceId: input.workspaceId,
4184
+ analysisId: input.analysisId,
4185
+ findingId: input.findingId,
4186
+ status: input.status,
4187
+ limit: input.limit,
4188
+ cursor: input.cursor
4189
+ })}`
4190
+ }).then(
4191
+ (response) => mapGatewayData(
4192
+ response,
4193
+ (data) => createListResult(
4194
+ Array.isArray(data.suggestions) ? data.suggestions : Array.isArray(data) ? data : [],
4195
+ "suggestions"
4196
+ )
4197
+ )
4198
+ );
4199
+ },
4200
+ listGraphChanges(input) {
4201
+ return gateway.request({
4202
+ path: `/api/platform/v1/graph-analysis/changes${toQueryString({
4203
+ topicId: requireTopicId2(input),
4204
+ workspaceId: input.workspaceId,
4205
+ analysisId: input.analysisId,
4206
+ since: input.since,
4207
+ limit: input.limit,
4208
+ cursor: input.cursor
4209
+ })}`
4210
+ }).then(
4211
+ (response) => mapGatewayData(
4212
+ response,
4213
+ (data) => createListResult(
4214
+ Array.isArray(data.changes) ? data.changes : Array.isArray(data) ? data : [],
4215
+ "changes"
4216
+ )
4217
+ )
4218
+ );
4219
+ },
4220
+ computeOrRequestAnalysis(input, idempotencyKey) {
4221
+ return gateway.request({
4222
+ path: "/api/platform/v1/graph-analysis/compute",
4223
+ method: "POST",
4224
+ body: normalizeComputePayload(input),
4225
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4226
+ });
4227
+ }
4228
+ };
4229
+ }
4230
+
4231
+ // src/graphRecommendationsClient.ts
4232
+ var GRAPH_RECOMMENDATION_FIELDS = [
4233
+ "topicId",
4234
+ "projectId",
4235
+ "workspaceId",
4236
+ "limit",
4237
+ "cursor",
4238
+ "status",
4239
+ "findingId",
4240
+ "actionType",
4241
+ "targetNodeIds",
4242
+ "priority",
4243
+ "rationale",
4244
+ "healthScore",
4245
+ "metadata"
4246
+ ];
4247
+ function readTopicId3(input) {
4248
+ return input.topicId?.trim() || input.projectId?.trim() || void 0;
4249
+ }
4250
+ function requireTopicId3(input) {
4251
+ const topicId = readTopicId3(input);
4252
+ if (!topicId) {
4253
+ throw new Error("topicId is required");
4254
+ }
4255
+ return topicId;
4256
+ }
4257
+ function assertKnownKeys3(input, operation) {
4258
+ const allowed = new Set(GRAPH_RECOMMENDATION_FIELDS);
4259
+ const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
4260
+ if (unknownKeys.length > 0) {
4261
+ throw new Error(
4262
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
4263
+ );
4264
+ }
4265
+ }
4266
+ function listQuery(input) {
4267
+ assertKnownKeys3(
4268
+ input,
4269
+ "graphRecommendations.listForTopic"
4270
+ );
4271
+ return {
4272
+ workspaceId: input.workspaceId,
4273
+ topicId: requireTopicId3(input),
4274
+ limit: input.limit,
4275
+ cursor: input.cursor,
4276
+ status: input.status,
4277
+ findingId: input.findingId,
4278
+ actionType: input.actionType,
4279
+ priority: input.priority,
4280
+ targetNodeIds: input.targetNodeIds?.join(","),
4281
+ healthScore: input.healthScore
4282
+ };
4283
+ }
4284
+ function createGraphRecommendationsClient(config = {}) {
4285
+ const gateway = createGatewayRequestClient(config);
4286
+ return {
4287
+ listForTopic(input) {
4288
+ return gateway.request({
4289
+ path: `/api/platform/v1/graph-recommendations${toQueryString(
4290
+ listQuery(input)
4291
+ )}`
4292
+ }).then(
4293
+ (response) => mapGatewayData(
4294
+ response,
4295
+ (data) => createListResult(
4296
+ Array.isArray(
4297
+ data.recommendations
4298
+ ) ? data.recommendations : Array.isArray(data) ? data : [],
4299
+ "recommendations"
4300
+ )
4301
+ )
4302
+ );
4303
+ },
4304
+ getRecommendation(recommendationId) {
4305
+ return gateway.request({
4306
+ path: `/api/platform/v1/graph-recommendations/${encodeURIComponent(
4307
+ recommendationId
4308
+ )}`
4309
+ });
4310
+ },
4311
+ markRecommendationStatus(input, idempotencyKey) {
4312
+ return gateway.request({
4313
+ path: `/api/platform/v1/graph-recommendations/${encodeURIComponent(
4314
+ input.recommendationId
4315
+ )}/status`,
4316
+ method: "PATCH",
4317
+ body: {
4318
+ status: input.status,
4319
+ rationale: input.rationale,
4320
+ metadata: input.metadata
4321
+ },
4322
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4323
+ });
4324
+ }
4325
+ };
4326
+ }
4327
+
4328
+ // src/graphStateClassifierClient.ts
4329
+ var GRAPH_STATE_CLASSIFIER_FIELDS = [
4330
+ "topicId",
4331
+ "projectId",
4332
+ "workspaceId",
4333
+ "nodeId",
4334
+ "epistemicStatus",
4335
+ "beliefMaturity",
4336
+ "answerQuality",
4337
+ "evidenceNetwork",
4338
+ "logicalRole",
4339
+ "questionPriority",
4340
+ "layer",
4341
+ "modelVersion",
4342
+ "limit",
4343
+ "cursor",
4344
+ "metadata"
4345
+ ];
4346
+ function normalizeRecordPayload(input) {
4347
+ cleanRequiredString(input.workspaceId, "workspaceId");
4348
+ cleanRequiredString(input.nodeId, "nodeId");
4349
+ return topicPayload(
4350
+ input,
4351
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4352
+ "graphStateClassifier.recordClassification"
4353
+ );
4354
+ }
4355
+ function createGraphStateClassifierClient(config = {}) {
4356
+ const gateway = createGatewayRequestClient(config);
4357
+ return {
4358
+ classifyNode(input, idempotencyKey) {
4359
+ cleanRequiredString(input.workspaceId, "workspaceId");
4360
+ cleanRequiredString(input.nodeId, "nodeId");
4361
+ return gateway.request({
4362
+ path: "/api/platform/v1/graph-state-classifier/classify-node",
4363
+ method: "POST",
4364
+ body: topicPayload(
4365
+ input,
4366
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4367
+ "graphStateClassifier.classifyNode"
4368
+ ),
4369
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4370
+ });
4371
+ },
4372
+ classifyTopic(input, idempotencyKey) {
4373
+ cleanRequiredString(input.workspaceId, "workspaceId");
4374
+ return gateway.request({
4375
+ path: "/api/platform/v1/graph-state-classifier/classify-topic",
4376
+ method: "POST",
4377
+ body: topicPayload(
4378
+ input,
4379
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4380
+ "graphStateClassifier.classifyTopic"
4381
+ ),
4382
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4383
+ }).then(
4384
+ (response) => mapGatewayData(
4385
+ response,
4386
+ (data) => listResultFromEnvelope(
4387
+ data,
4388
+ "classifications"
4389
+ )
4390
+ )
4391
+ );
4392
+ },
4393
+ listClassifications(input) {
4394
+ return gateway.request({
4395
+ path: `/api/platform/v1/graph-state-classifier/classifications${toQueryString({
4396
+ topicId: requireTopicId(input),
4397
+ workspaceId: input.workspaceId,
4398
+ nodeId: input.nodeId,
4399
+ modelVersion: input.modelVersion,
4400
+ layer: input.layer,
4401
+ epistemicStatus: input.epistemicStatus,
4402
+ limit: input.limit,
4403
+ cursor: input.cursor
4404
+ })}`
4405
+ }).then(
4406
+ (response) => mapGatewayData(
4407
+ response,
4408
+ (data) => listResultFromEnvelope(
4409
+ data,
4410
+ "classifications"
4411
+ )
4412
+ )
4413
+ );
4414
+ },
4415
+ recordClassification(input, idempotencyKey) {
4416
+ return gateway.request({
4417
+ path: "/api/platform/v1/graph-state-classifier/classifications",
4418
+ method: "POST",
4419
+ body: normalizeRecordPayload(input),
4420
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4421
+ });
4422
+ }
4423
+ };
4424
+ }
4425
+
3309
4426
  // src/harnessClient.ts
3310
4427
  function createHarnessClient(config = {}) {
3311
4428
  const gateway = createGatewayRequestClient(config);
@@ -3525,9 +4642,9 @@ function createHarnessClient(config = {}) {
3525
4642
  /**
3526
4643
  * List prompt resolutions.
3527
4644
  */
3528
- async listPromptResolutions(query = {}) {
4645
+ async listPromptResolutions(query5 = {}) {
3529
4646
  return gateway.request({
3530
- path: `/api/platform/v1/harness/prompts${toQueryString(query)}`
4647
+ path: `/api/platform/v1/harness/prompts${toQueryString(query5)}`
3531
4648
  }).then(
3532
4649
  (response) => mapGatewayData(
3533
4650
  response,
@@ -3546,6 +4663,128 @@ function createHarnessClient(config = {}) {
3546
4663
  };
3547
4664
  }
3548
4665
 
4666
+ // src/jobsClient.ts
4667
+ var JOBS_FIELDS = [
4668
+ "tenantId",
4669
+ "workspaceId",
4670
+ "principalId",
4671
+ "topicId",
4672
+ "worktreeId",
4673
+ "jobId",
4674
+ "jobType",
4675
+ "payload",
4676
+ "status",
4677
+ "attempt",
4678
+ "runId",
4679
+ "queue",
4680
+ "priority",
4681
+ "error",
4682
+ "metadata",
4683
+ "limit",
4684
+ "cursor"
4685
+ ];
4686
+ function query2(input) {
4687
+ return {
4688
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
4689
+ workspaceId: input.workspaceId,
4690
+ principalId: input.principalId,
4691
+ topicId: input.topicId,
4692
+ worktreeId: input.worktreeId,
4693
+ jobType: input.jobType,
4694
+ status: input.status,
4695
+ queue: input.queue,
4696
+ limit: input.limit,
4697
+ cursor: input.cursor
4698
+ };
4699
+ }
4700
+ function body2(input, operation) {
4701
+ return knownPayload(input, JOBS_FIELDS, operation);
4702
+ }
4703
+ function createJobsClient(config = {}) {
4704
+ const gateway = createGatewayRequestClient(config);
4705
+ return {
4706
+ enqueue(input, idempotencyKey) {
4707
+ cleanRequiredString(input.tenantId, "tenantId");
4708
+ cleanRequiredString(input.jobType, "jobType");
4709
+ return gateway.request({
4710
+ path: "/api/platform/v1/jobs",
4711
+ method: "POST",
4712
+ body: body2(input, "jobs.enqueue"),
4713
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4714
+ });
4715
+ },
4716
+ list(input) {
4717
+ return gateway.request({
4718
+ path: `/api/platform/v1/jobs${toQueryString(query2(input))}`
4719
+ }).then(
4720
+ (response) => mapGatewayData(
4721
+ response,
4722
+ (data) => listResultFromEnvelope(data, "jobs")
4723
+ )
4724
+ );
4725
+ },
4726
+ claim(input, idempotencyKey) {
4727
+ cleanRequiredString(input.tenantId, "tenantId");
4728
+ return gateway.request({
4729
+ path: "/api/platform/v1/jobs/claim",
4730
+ method: "POST",
4731
+ body: body2(input, "jobs.claim"),
4732
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4733
+ });
4734
+ },
4735
+ updateStatus(input, idempotencyKey) {
4736
+ cleanRequiredString(input.tenantId, "tenantId");
4737
+ cleanRequiredString(input.jobId, "jobId");
4738
+ return gateway.request({
4739
+ path: `/api/platform/v1/jobs/${encodeURIComponent(input.jobId)}/status`,
4740
+ method: "PATCH",
4741
+ body: body2(
4742
+ input,
4743
+ "jobs.updateStatus"
4744
+ ),
4745
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4746
+ });
4747
+ },
4748
+ retry(input, idempotencyKey) {
4749
+ cleanRequiredString(input.tenantId, "tenantId");
4750
+ cleanRequiredString(input.jobId, "jobId");
4751
+ return gateway.request({
4752
+ path: `/api/platform/v1/jobs/${encodeURIComponent(input.jobId)}/retry`,
4753
+ method: "POST",
4754
+ body: body2(input, "jobs.retry"),
4755
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4756
+ });
4757
+ },
4758
+ recordRunStart(input, idempotencyKey) {
4759
+ cleanRequiredString(input.tenantId, "tenantId");
4760
+ return gateway.request({
4761
+ path: "/api/platform/v1/jobs/runs/start",
4762
+ method: "POST",
4763
+ body: body2(
4764
+ input,
4765
+ "jobs.recordRunStart"
4766
+ ),
4767
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4768
+ });
4769
+ },
4770
+ recordRunFinish(input, idempotencyKey) {
4771
+ cleanRequiredString(input.tenantId, "tenantId");
4772
+ cleanRequiredString(input.runId, "runId");
4773
+ return gateway.request({
4774
+ path: `/api/platform/v1/jobs/runs/${encodeURIComponent(
4775
+ input.runId
4776
+ )}/finish`,
4777
+ method: "POST",
4778
+ body: body2(
4779
+ input,
4780
+ "jobs.recordRunFinish"
4781
+ ),
4782
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4783
+ });
4784
+ }
4785
+ };
4786
+ }
4787
+
3549
4788
  // src/learningClient.ts
3550
4789
  function createLearningClient(config = {}) {
3551
4790
  const gateway = createGatewayRequestClient(config);
@@ -3575,17 +4814,133 @@ function createLearningClient(config = {}) {
3575
4814
  async getRecentExecutions(args = {}) {
3576
4815
  return this.listRecentExecutions(args);
3577
4816
  },
3578
- /**
3579
- * Get aggregate execution statistics.
3580
- */
3581
- async getExecutionStats(args = {}) {
4817
+ /**
4818
+ * Get aggregate execution statistics.
4819
+ */
4820
+ async getExecutionStats(args = {}) {
4821
+ return gateway.request({
4822
+ path: `/api/platform/v1/learning/executions/stats${toQueryString({
4823
+ ...normalizeTopicQuery(args),
4824
+ namespace: args.namespace,
4825
+ audienceMode: args.audienceMode,
4826
+ hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
4827
+ })}`
4828
+ });
4829
+ }
4830
+ };
4831
+ }
4832
+ function toJsonValue(value) {
4833
+ if (value === void 0) {
4834
+ return void 0;
4835
+ }
4836
+ const seen = /* @__PURE__ */ new WeakSet();
4837
+ const json = JSON.stringify(value, (_key, candidate) => {
4838
+ if (typeof candidate === "bigint") {
4839
+ return candidate.toString();
4840
+ }
4841
+ if (typeof candidate === "function" || typeof candidate === "symbol" || typeof candidate === "undefined") {
4842
+ return void 0;
4843
+ }
4844
+ if (candidate && typeof candidate === "object") {
4845
+ if (seen.has(candidate)) {
4846
+ return "[Circular]";
4847
+ }
4848
+ seen.add(candidate);
4849
+ }
4850
+ return candidate;
4851
+ });
4852
+ if (json === void 0) {
4853
+ return void 0;
4854
+ }
4855
+ return JSON.parse(json);
4856
+ }
4857
+ function createMcpClient(config = {}) {
4858
+ const gateway = createGatewayRequestClient(config);
4859
+ return {
4860
+ bootstrapSession(input = {}) {
4861
+ const scope = {
4862
+ tenantId: input.tenantId,
4863
+ workspaceId: input.workspaceId
4864
+ };
4865
+ const body4 = {
4866
+ transportKind: input.transportKind,
4867
+ sessionId: input.sessionId,
4868
+ agentIdentity: input.agentIdentity,
4869
+ workspaceId: input.workspaceId
4870
+ };
4871
+ return gateway.request({
4872
+ path: `${MCP_GATEWAY_BOOTSTRAP_ENDPOINT}${toQueryString(scope)}`,
4873
+ method: "POST",
4874
+ body: body4
4875
+ });
4876
+ },
4877
+ checkWritePolicy(input) {
4878
+ const scope = {
4879
+ tenantId: input.tenantId,
4880
+ workspaceId: input.workspaceId
4881
+ };
4882
+ return gateway.request({
4883
+ path: `${MCP_GATEWAY_WRITE_POLICY_CHECK_ENDPOINT}${toQueryString(scope)}`,
4884
+ method: "POST",
4885
+ body: {
4886
+ topicId: input.topicId,
4887
+ role: input.role,
4888
+ toolName: input.toolName
4889
+ }
4890
+ });
4891
+ },
4892
+ beginBuildSession(input) {
4893
+ const scope = {
4894
+ tenantId: input.tenantId,
4895
+ workspaceId: input.workspaceId
4896
+ };
4897
+ return gateway.request({
4898
+ path: `${MCP_GATEWAY_BEGIN_BUILD_SESSION_ENDPOINT}${toQueryString(scope)}`,
4899
+ method: "POST",
4900
+ body: {
4901
+ worktreeId: input.worktreeId,
4902
+ branch: input.branch,
4903
+ branchBase: input.branchBase,
4904
+ prBase: input.prBase,
4905
+ sessionMode: input.sessionMode,
4906
+ activateIfPlanning: input.activateIfPlanning
4907
+ }
4908
+ });
4909
+ },
4910
+ evaluateEngineeringContract(input) {
4911
+ const scope = {
4912
+ tenantId: input.tenantId,
4913
+ workspaceId: input.workspaceId
4914
+ };
4915
+ return gateway.request({
4916
+ path: `${MCP_GATEWAY_EVALUATE_ENGINEERING_CONTRACT_ENDPOINT}${toQueryString(scope)}`,
4917
+ method: "POST",
4918
+ body: {
4919
+ beliefNodeId: toJsonValue(input.beliefNodeId),
4920
+ trigger: toJsonValue(input.trigger),
4921
+ testOutput: toJsonValue(input.testOutput),
4922
+ tscOutput: toJsonValue(input.tscOutput),
4923
+ lintOutput: toJsonValue(input.lintOutput),
4924
+ sentryData: toJsonValue(input.sentryData)
4925
+ }
4926
+ });
4927
+ },
4928
+ evaluateResearchContract(input) {
4929
+ const scope = {
4930
+ tenantId: input.tenantId,
4931
+ workspaceId: input.workspaceId
4932
+ };
3582
4933
  return gateway.request({
3583
- path: `/api/platform/v1/learning/executions/stats${toQueryString({
3584
- ...normalizeTopicQuery(args),
3585
- namespace: args.namespace,
3586
- audienceMode: args.audienceMode,
3587
- hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? String(args.hours) : void 0
3588
- })}`
4934
+ path: `${MCP_GATEWAY_EVALUATE_RESEARCH_CONTRACT_ENDPOINT}${toQueryString(scope)}`,
4935
+ method: "POST",
4936
+ body: {
4937
+ beliefNodeId: toJsonValue(input.beliefNodeId),
4938
+ trigger: toJsonValue(input.trigger),
4939
+ metricData: toJsonValue(input.metricData),
4940
+ referenceCheckData: toJsonValue(input.referenceCheckData),
4941
+ marketIndexData: toJsonValue(input.marketIndexData),
4942
+ temporalData: toJsonValue(input.temporalData)
4943
+ }
3589
4944
  });
3590
4945
  }
3591
4946
  };
@@ -4072,6 +5427,304 @@ function createFunctionSurfaceClient(config = {}) {
4072
5427
  };
4073
5428
  }
4074
5429
 
5430
+ // src/modelRuntimeClient.ts
5431
+ var MODEL_RUNTIME_FIELDS = [
5432
+ "tenantId",
5433
+ "workspaceId",
5434
+ "principalId",
5435
+ "functionName",
5436
+ "slotKey",
5437
+ "modelId",
5438
+ "provider",
5439
+ "routingPolicy",
5440
+ "metadata",
5441
+ "limit",
5442
+ "cursor"
5443
+ ];
5444
+ function scopeQuery(input) {
5445
+ return {
5446
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
5447
+ workspaceId: input.workspaceId,
5448
+ principalId: input.principalId,
5449
+ provider: input.provider,
5450
+ limit: input.limit,
5451
+ cursor: input.cursor
5452
+ };
5453
+ }
5454
+ function modelRuntimeBody(input, operation) {
5455
+ return knownPayload(input, MODEL_RUNTIME_FIELDS, operation);
5456
+ }
5457
+ function createModelRuntimeClient(config = {}) {
5458
+ const gateway = createGatewayRequestClient(config);
5459
+ return {
5460
+ listModels(input) {
5461
+ return gateway.request({
5462
+ path: `/api/platform/v1/model-runtime/models${toQueryString(
5463
+ scopeQuery(input)
5464
+ )}`
5465
+ }).then(
5466
+ (response) => mapGatewayData(
5467
+ response,
5468
+ (data) => listResultFromEnvelope(data, "models")
5469
+ )
5470
+ );
5471
+ },
5472
+ getModel(input) {
5473
+ cleanRequiredString(input.tenantId, "tenantId");
5474
+ cleanRequiredString(input.modelId, "modelId");
5475
+ return gateway.request({
5476
+ path: `/api/platform/v1/model-runtime/models/${encodeURIComponent(
5477
+ input.modelId
5478
+ )}${toQueryString({
5479
+ tenantId: input.tenantId,
5480
+ workspaceId: input.workspaceId,
5481
+ principalId: input.principalId
5482
+ })}`
5483
+ });
5484
+ },
5485
+ listFunctionSlots(input) {
5486
+ return gateway.request({
5487
+ path: `/api/platform/v1/model-runtime/function-slots${toQueryString({
5488
+ ...scopeQuery(input),
5489
+ functionName: input.functionName
5490
+ })}`
5491
+ }).then(
5492
+ (response) => mapGatewayData(
5493
+ response,
5494
+ (data) => listResultFromEnvelope(data, "slots")
5495
+ )
5496
+ );
5497
+ },
5498
+ resolveSlot(input, idempotencyKey) {
5499
+ cleanRequiredString(input.tenantId, "tenantId");
5500
+ cleanRequiredString(input.functionName, "functionName");
5501
+ return gateway.request({
5502
+ path: "/api/platform/v1/model-runtime/function-slots/resolve",
5503
+ method: "POST",
5504
+ body: modelRuntimeBody(
5505
+ input,
5506
+ "modelRuntime.resolveSlot"
5507
+ ),
5508
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5509
+ });
5510
+ },
5511
+ updateSlotConfig(input, idempotencyKey) {
5512
+ cleanRequiredString(input.tenantId, "tenantId");
5513
+ cleanRequiredString(input.functionName, "functionName");
5514
+ cleanRequiredString(input.slotKey, "slotKey");
5515
+ cleanRequiredString(input.modelId, "modelId");
5516
+ return gateway.request({
5517
+ path: "/api/platform/v1/model-runtime/slot-configs",
5518
+ method: "PUT",
5519
+ body: modelRuntimeBody(
5520
+ input,
5521
+ "modelRuntime.updateSlotConfig"
5522
+ ),
5523
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5524
+ });
5525
+ }
5526
+ };
5527
+ }
5528
+
5529
+ // src/ontologyLinksClient.ts
5530
+ var ONTOLOGY_LINK_FIELDS = [
5531
+ "topicId",
5532
+ "workspaceId",
5533
+ "linkId",
5534
+ "sourceNodeId",
5535
+ "sourceGlobalId",
5536
+ "targetNodeId",
5537
+ "targetGlobalId",
5538
+ "ontologyId",
5539
+ "ontologyType",
5540
+ "edgeType",
5541
+ "weight",
5542
+ "confidence",
5543
+ "status",
5544
+ "metadata"
5545
+ ];
5546
+ function assertEndpoints(input) {
5547
+ if (!input.sourceNodeId && !input.sourceGlobalId) {
5548
+ throw new Error("sourceNodeId or sourceGlobalId is required");
5549
+ }
5550
+ if (!input.targetNodeId && !input.targetGlobalId) {
5551
+ throw new Error("targetNodeId or targetGlobalId is required");
5552
+ }
5553
+ }
5554
+ function normalizeLinkPayload(input, operation) {
5555
+ assertEndpoints(input);
5556
+ cleanRequiredString(input.ontologyId, "ontologyId");
5557
+ cleanRequiredString(input.edgeType, "edgeType");
5558
+ return knownPayload(input, ONTOLOGY_LINK_FIELDS, operation);
5559
+ }
5560
+ function createOntologyLinksClient(config = {}) {
5561
+ const gateway = createGatewayRequestClient(config);
5562
+ return {
5563
+ createLink(input, idempotencyKey) {
5564
+ return gateway.request({
5565
+ path: "/api/platform/v1/ontology-links",
5566
+ method: "POST",
5567
+ body: normalizeLinkPayload(input, "ontologyLinks.createLink"),
5568
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5569
+ });
5570
+ },
5571
+ upsertLink(input, idempotencyKey) {
5572
+ return gateway.request({
5573
+ path: "/api/platform/v1/ontology-links",
5574
+ method: "PUT",
5575
+ body: normalizeLinkPayload(input, "ontologyLinks.upsertLink"),
5576
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5577
+ });
5578
+ },
5579
+ listLinksForNode(input) {
5580
+ const nodeId = cleanOptionalString(input.nodeId);
5581
+ const globalId = cleanOptionalString(input.globalId);
5582
+ if (!nodeId && !globalId) {
5583
+ throw new Error("nodeId or globalId is required");
5584
+ }
5585
+ const pathId = encodeURIComponent(nodeId ?? globalId ?? "");
5586
+ return gateway.request({
5587
+ path: `/api/platform/v1/ontology-links/nodes/${pathId}${toQueryString({
5588
+ topicId: input.topicId,
5589
+ workspaceId: input.workspaceId,
5590
+ globalId: nodeId ? void 0 : globalId,
5591
+ ontologyId: input.ontologyId,
5592
+ ontologyType: input.ontologyType,
5593
+ edgeType: input.edgeType,
5594
+ status: input.status,
5595
+ limit: input.limit,
5596
+ cursor: input.cursor
5597
+ })}`
5598
+ }).then(
5599
+ (response) => mapGatewayData(
5600
+ response,
5601
+ (data) => listResultFromEnvelope(data, "links")
5602
+ )
5603
+ );
5604
+ },
5605
+ updateLinkStatus(input, idempotencyKey) {
5606
+ return gateway.request({
5607
+ path: `/api/platform/v1/ontology-links/${encodeURIComponent(
5608
+ input.linkId
5609
+ )}/status`,
5610
+ method: "PATCH",
5611
+ body: knownPayload(
5612
+ input,
5613
+ ONTOLOGY_LINK_FIELDS,
5614
+ "ontologyLinks.updateLinkStatus"
5615
+ ),
5616
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5617
+ });
5618
+ }
5619
+ };
5620
+ }
5621
+
5622
+ // src/orgGraphSearchClient.ts
5623
+ var ORG_GRAPH_SEARCH_FIELDS = [
5624
+ "tenantId",
5625
+ "workspaceId",
5626
+ "query",
5627
+ "nodeTypes",
5628
+ "minConfidence",
5629
+ "limit",
5630
+ "cursor",
5631
+ "provenanceScope"
5632
+ ];
5633
+ function cleanString5(value, label) {
5634
+ const normalized = value?.trim();
5635
+ if (!normalized) {
5636
+ throw new Error(`${label} is required`);
5637
+ }
5638
+ return normalized;
5639
+ }
5640
+ function assertKnownSearchKeys(input, operation) {
5641
+ const allowed = new Set(ORG_GRAPH_SEARCH_FIELDS);
5642
+ const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
5643
+ if (unknownKeys.length > 0) {
5644
+ throw new Error(
5645
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
5646
+ );
5647
+ }
5648
+ }
5649
+ function searchBody(input) {
5650
+ assertKnownSearchKeys(
5651
+ input,
5652
+ "orgGraphSearch.search"
5653
+ );
5654
+ return {
5655
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5656
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5657
+ query: cleanString5(input.query, "query"),
5658
+ nodeTypes: input.nodeTypes,
5659
+ minConfidence: input.minConfidence,
5660
+ limit: input.limit,
5661
+ cursor: input.cursor,
5662
+ provenanceScope: input.provenanceScope
5663
+ };
5664
+ }
5665
+ function listQuery2(input) {
5666
+ return {
5667
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5668
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5669
+ nodeTypes: input.nodeTypes?.join(","),
5670
+ minConfidence: input.minConfidence,
5671
+ limit: input.limit,
5672
+ cursor: input.cursor
5673
+ };
5674
+ }
5675
+ function mapResults(data) {
5676
+ const record = data && typeof data === "object" ? data : {};
5677
+ return createListResult(
5678
+ Array.isArray(record.results) ? record.results : Array.isArray(data) ? data : [],
5679
+ "results"
5680
+ );
5681
+ }
5682
+ function createOrgGraphSearchClient(config = {}) {
5683
+ const gateway = createGatewayRequestClient(config);
5684
+ return {
5685
+ search(input) {
5686
+ return gateway.request({
5687
+ path: "/api/platform/v1/org-graph-search/search",
5688
+ method: "POST",
5689
+ body: searchBody(input)
5690
+ }).then((response) => mapGatewayData(response, mapResults));
5691
+ },
5692
+ getNode(input) {
5693
+ const nodeId = input.nodeId?.trim();
5694
+ const globalId = input.globalId?.trim();
5695
+ if (!nodeId && !globalId) {
5696
+ throw new Error("nodeId or globalId is required");
5697
+ }
5698
+ const nodePath = encodeURIComponent(nodeId ?? globalId ?? "");
5699
+ return gateway.request({
5700
+ path: `/api/platform/v1/org-graph-search/nodes/${nodePath}${toQueryString(
5701
+ {
5702
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5703
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5704
+ globalId: nodeId ? void 0 : globalId
5705
+ }
5706
+ )}`
5707
+ });
5708
+ },
5709
+ listByProvenance(input) {
5710
+ return gateway.request({
5711
+ path: `/api/platform/v1/org-graph-search/provenance${toQueryString({
5712
+ ...listQuery2(input),
5713
+ provenanceScope: input.provenanceScope
5714
+ })}`
5715
+ }).then((response) => mapGatewayData(response, mapResults));
5716
+ },
5717
+ listPublishedFromWorkspace(input) {
5718
+ return gateway.request({
5719
+ path: `/api/platform/v1/org-graph-search/published${toQueryString({
5720
+ ...listQuery2(input),
5721
+ sourceWorkspaceId: input.sourceWorkspaceId
5722
+ })}`
5723
+ }).then((response) => mapGatewayData(response, mapResults));
5724
+ }
5725
+ };
5726
+ }
5727
+
4075
5728
  // src/packsClient.ts
4076
5729
  function createPacksClient(config = {}) {
4077
5730
  const gateway = createGatewayRequestClient(config);
@@ -4114,9 +5767,9 @@ function createPacksClient(config = {}) {
4114
5767
  /**
4115
5768
  * List pack states for the current scope.
4116
5769
  */
4117
- async listStates(query = {}) {
5770
+ async listStates(query5 = {}) {
4118
5771
  return gateway.request({
4119
- path: `/api/platform/v1/packs/states${toQueryString(query)}`
5772
+ path: `/api/platform/v1/packs/states${toQueryString(query5)}`
4120
5773
  }).then(
4121
5774
  (response) => mapGatewayData(
4122
5775
  response,
@@ -4127,25 +5780,25 @@ function createPacksClient(config = {}) {
4127
5780
  /**
4128
5781
  * @deprecated Use listStates.
4129
5782
  */
4130
- async getStates(query = {}) {
4131
- return this.listStates(query);
5783
+ async getStates(query5 = {}) {
5784
+ return this.listStates(query5);
4132
5785
  },
4133
5786
  /**
4134
5787
  * Get health details for a pack.
4135
5788
  */
4136
- async getHealth(packKey, query = {}) {
5789
+ async getHealth(packKey, query5 = {}) {
4137
5790
  return gateway.request({
4138
5791
  path: `/api/platform/v1/packs/${encodeURIComponent(packKey)}/health${toQueryString(
4139
- query
5792
+ query5
4140
5793
  )}`
4141
5794
  });
4142
5795
  },
4143
5796
  /**
4144
5797
  * List pack telemetry entries.
4145
5798
  */
4146
- async listTelemetry(query = {}) {
5799
+ async listTelemetry(query5 = {}) {
4147
5800
  return gateway.request({
4148
- path: `/api/platform/v1/packs/telemetry${toQueryString(query)}`
5801
+ path: `/api/platform/v1/packs/telemetry${toQueryString(query5)}`
4149
5802
  }).then(
4150
5803
  (response) => mapGatewayData(
4151
5804
  response,
@@ -4156,8 +5809,8 @@ function createPacksClient(config = {}) {
4156
5809
  /**
4157
5810
  * @deprecated Use listTelemetry.
4158
5811
  */
4159
- async getTelemetry(query = {}) {
4160
- return this.listTelemetry(query);
5812
+ async getTelemetry(query5 = {}) {
5813
+ return this.listTelemetry(query5);
4161
5814
  },
4162
5815
  /**
4163
5816
  * Create a pack entitlement.
@@ -4279,9 +5932,9 @@ function createPolicyClient(config = {}) {
4279
5932
  /**
4280
5933
  * List policy decisions in the current scope.
4281
5934
  */
4282
- async listDecisions(query = {}) {
5935
+ async listDecisions(query5 = {}) {
4283
5936
  return gateway.request({
4284
- path: `/api/platform/v1/policy/decisions${toQueryString(query)}`
5937
+ path: `/api/platform/v1/policy/decisions${toQueryString(query5)}`
4285
5938
  }).then(
4286
5939
  (response) => mapGatewayData(
4287
5940
  response,
@@ -4314,9 +5967,9 @@ function createPolicyClient(config = {}) {
4314
5967
  /**
4315
5968
  * List write policy rules for the current scope.
4316
5969
  */
4317
- async listWritePolicies(query = {}) {
5970
+ async listWritePolicies(query5 = {}) {
4318
5971
  const response = await gateway.request({
4319
- path: `/api/platform/v1/policy/write-policies${toQueryString(query)}`
5972
+ path: `/api/platform/v1/policy/write-policies${toQueryString(query5)}`
4320
5973
  });
4321
5974
  const rawPolicies = response.data && typeof response.data === "object" ? response.data.policies : response.data;
4322
5975
  return {
@@ -4379,9 +6032,9 @@ function createPolicyClient(config = {}) {
4379
6032
  /**
4380
6033
  * List tenant role policies for the current scope.
4381
6034
  */
4382
- async listRolePolicies(query = {}) {
6035
+ async listRolePolicies(query5 = {}) {
4383
6036
  const response = await gateway.request({
4384
- path: `/api/platform/v1/policy/roles${toQueryString(query)}`
6037
+ path: `/api/platform/v1/policy/roles${toQueryString(query5)}`
4385
6038
  });
4386
6039
  return {
4387
6040
  ...response,
@@ -4439,28 +6092,28 @@ function createPolicyClient(config = {}) {
4439
6092
  /**
4440
6093
  * Check a permission decision for a topic or project scope.
4441
6094
  */
4442
- async checkPermission(query) {
4443
- if (!query.topicId) {
6095
+ async checkPermission(query5) {
6096
+ if (!query5.topicId) {
4444
6097
  throw new Error("topicId is required");
4445
6098
  }
4446
6099
  return gateway.request({
4447
- path: `/api/platform/v1/policy/check${toQueryString(query)}`
6100
+ path: `/api/platform/v1/policy/check${toQueryString(query5)}`
4448
6101
  });
4449
6102
  },
4450
6103
  /**
4451
6104
  * List accessible topics for a principal.
4452
6105
  */
4453
- async listAccessibleTopics(query = {}) {
4454
- const permission = query.permission ?? "read";
4455
- const principal = query.principal ?? query.principalId;
6106
+ async listAccessibleTopics(query5 = {}) {
6107
+ const permission = query5.permission ?? "read";
6108
+ const principal = query5.principal ?? query5.principalId;
4456
6109
  const response = await gateway.request({
4457
6110
  path: `/api/platform/v1/policy/topics${toQueryString({
4458
- tenantId: query.tenantId,
4459
- workspaceId: query.workspaceId,
6111
+ tenantId: query5.tenantId,
6112
+ workspaceId: query5.workspaceId,
4460
6113
  permission,
4461
- includeShared: query.includeShared,
6114
+ includeShared: query5.includeShared,
4462
6115
  principal,
4463
- limit: query.limit
6116
+ limit: query5.limit
4464
6117
  })}`
4465
6118
  });
4466
6119
  return {
@@ -4643,6 +6296,294 @@ function createSchemaClient(config = {}) {
4643
6296
  };
4644
6297
  }
4645
6298
 
6299
+ // src/telemetryClient.ts
6300
+ var TELEMETRY_FIELDS = [
6301
+ "tenantId",
6302
+ "workspaceId",
6303
+ "principalId",
6304
+ "topicId",
6305
+ "worktreeId",
6306
+ "eventLevel",
6307
+ "eventType",
6308
+ "message",
6309
+ "toolName",
6310
+ "toolCalls",
6311
+ "decision",
6312
+ "policySubject",
6313
+ "policyAction",
6314
+ "policyResource",
6315
+ "runId",
6316
+ "runType",
6317
+ "status",
6318
+ "durationMs",
6319
+ "error",
6320
+ "metadata",
6321
+ "limit",
6322
+ "cursor"
6323
+ ];
6324
+ function query3(input) {
6325
+ return {
6326
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
6327
+ workspaceId: input.workspaceId,
6328
+ principalId: input.principalId,
6329
+ topicId: input.topicId,
6330
+ worktreeId: input.worktreeId,
6331
+ runType: input.runType,
6332
+ status: input.status,
6333
+ limit: input.limit,
6334
+ cursor: input.cursor
6335
+ };
6336
+ }
6337
+ function body3(input, operation) {
6338
+ return knownPayload(input, TELEMETRY_FIELDS, operation);
6339
+ }
6340
+ function createTelemetryClient(config = {}) {
6341
+ const gateway = createGatewayRequestClient(config);
6342
+ return {
6343
+ logSystemEvent(input, idempotencyKey) {
6344
+ cleanRequiredString(input.tenantId, "tenantId");
6345
+ cleanRequiredString(input.eventType, "eventType");
6346
+ cleanRequiredString(input.message, "message");
6347
+ return gateway.request({
6348
+ path: "/api/platform/v1/telemetry/system-events",
6349
+ method: "POST",
6350
+ body: body3(
6351
+ input,
6352
+ "telemetry.logSystemEvent"
6353
+ ),
6354
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6355
+ });
6356
+ },
6357
+ logToolCallsBatch(input, idempotencyKey) {
6358
+ cleanRequiredString(input.tenantId, "tenantId");
6359
+ return gateway.request({
6360
+ path: "/api/platform/v1/telemetry/tool-calls/batch",
6361
+ method: "POST",
6362
+ body: body3(
6363
+ input,
6364
+ "telemetry.logToolCallsBatch"
6365
+ ),
6366
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6367
+ });
6368
+ },
6369
+ recordEpistemicAudit(input, idempotencyKey) {
6370
+ cleanRequiredString(input.tenantId, "tenantId");
6371
+ cleanRequiredString(input.eventType, "eventType");
6372
+ return gateway.request({
6373
+ path: "/api/platform/v1/telemetry/epistemic-audits",
6374
+ method: "POST",
6375
+ body: body3(
6376
+ input,
6377
+ "telemetry.recordEpistemicAudit"
6378
+ ),
6379
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6380
+ });
6381
+ },
6382
+ recordPolicyDecision(input, idempotencyKey) {
6383
+ cleanRequiredString(input.tenantId, "tenantId");
6384
+ cleanRequiredString(input.decision, "decision");
6385
+ return gateway.request({
6386
+ path: "/api/platform/v1/telemetry/policy-decisions",
6387
+ method: "POST",
6388
+ body: body3(
6389
+ input,
6390
+ "telemetry.recordPolicyDecision"
6391
+ ),
6392
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6393
+ });
6394
+ },
6395
+ startRun(input, idempotencyKey) {
6396
+ cleanRequiredString(input.tenantId, "tenantId");
6397
+ cleanRequiredString(input.runType, "runType");
6398
+ return gateway.request({
6399
+ path: "/api/platform/v1/telemetry/runs/start",
6400
+ method: "POST",
6401
+ body: body3(
6402
+ input,
6403
+ "telemetry.startRun"
6404
+ ),
6405
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6406
+ });
6407
+ },
6408
+ finishRun(input, idempotencyKey) {
6409
+ cleanRequiredString(input.tenantId, "tenantId");
6410
+ cleanRequiredString(input.runId, "runId");
6411
+ return gateway.request({
6412
+ path: `/api/platform/v1/telemetry/runs/${encodeURIComponent(
6413
+ input.runId
6414
+ )}/finish`,
6415
+ method: "POST",
6416
+ body: body3(
6417
+ input,
6418
+ "telemetry.finishRun"
6419
+ ),
6420
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6421
+ });
6422
+ },
6423
+ listRuns(input) {
6424
+ return gateway.request({
6425
+ path: `/api/platform/v1/telemetry/runs${toQueryString(query3(input))}`
6426
+ }).then(
6427
+ (response) => mapGatewayData(
6428
+ response,
6429
+ (data) => listResultFromEnvelope(data, "runs")
6430
+ )
6431
+ );
6432
+ }
6433
+ };
6434
+ }
6435
+
6436
+ // src/toolRegistryClient.ts
6437
+ var TOOL_REGISTRY_FIELDS = [
6438
+ "tenantId",
6439
+ "workspaceId",
6440
+ "principalId",
6441
+ "toolName",
6442
+ "packKey",
6443
+ "packVersion",
6444
+ "status",
6445
+ "permissions",
6446
+ "role",
6447
+ "surface",
6448
+ "parameterSchema",
6449
+ "returnSchema",
6450
+ "handlerRef",
6451
+ "executionAdapter",
6452
+ "safetyMetadata",
6453
+ "aclId",
6454
+ "metadata",
6455
+ "limit",
6456
+ "cursor"
6457
+ ];
6458
+ function query4(input) {
6459
+ return {
6460
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
6461
+ workspaceId: input.workspaceId,
6462
+ principalId: input.principalId,
6463
+ packKey: input.packKey,
6464
+ status: input.status,
6465
+ limit: input.limit,
6466
+ cursor: input.cursor
6467
+ };
6468
+ }
6469
+ function writeBody(input, operation) {
6470
+ return knownPayload(input, TOOL_REGISTRY_FIELDS, operation);
6471
+ }
6472
+ function createToolRegistryClient(config = {}) {
6473
+ const gateway = createGatewayRequestClient(config);
6474
+ return {
6475
+ listCatalog(input) {
6476
+ return gateway.request({
6477
+ path: `/api/platform/v1/tools/catalog${toQueryString(query4(input))}`
6478
+ }).then(
6479
+ (response) => mapGatewayData(
6480
+ response,
6481
+ (data) => listResultFromEnvelope(data, "tools")
6482
+ )
6483
+ );
6484
+ },
6485
+ listExecutable(input) {
6486
+ return gateway.request({
6487
+ path: `/api/platform/v1/tools/executable${toQueryString(query4(input))}`
6488
+ }).then(
6489
+ (response) => mapGatewayData(
6490
+ response,
6491
+ (data) => listResultFromEnvelope(data, "tools")
6492
+ )
6493
+ );
6494
+ },
6495
+ listEffectiveTools(input) {
6496
+ return gateway.request({
6497
+ path: `/api/platform/v1/tools/effective${toQueryString(query4(input))}`
6498
+ }).then(
6499
+ (response) => mapGatewayData(
6500
+ response,
6501
+ (data) => listResultFromEnvelope(data, "tools")
6502
+ )
6503
+ );
6504
+ },
6505
+ upsertCoreTools(input, idempotencyKey) {
6506
+ cleanRequiredString(input.tenantId, "tenantId");
6507
+ return gateway.request({
6508
+ path: "/api/platform/v1/tools/core",
6509
+ method: "PUT",
6510
+ body: {
6511
+ tenantId: input.tenantId,
6512
+ workspaceId: input.workspaceId,
6513
+ metadata: input.metadata,
6514
+ tools: input.tools
6515
+ },
6516
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6517
+ }).then(
6518
+ (response) => mapGatewayData(
6519
+ response,
6520
+ (data) => listResultFromEnvelope(data, "tools")
6521
+ )
6522
+ );
6523
+ },
6524
+ setPackToolsStatus(input, idempotencyKey) {
6525
+ cleanRequiredString(input.tenantId, "tenantId");
6526
+ cleanRequiredString(input.packKey, "packKey");
6527
+ return gateway.request({
6528
+ path: `/api/platform/v1/tools/packs/${encodeURIComponent(
6529
+ input.packKey
6530
+ )}/status`,
6531
+ method: "PATCH",
6532
+ body: writeBody(
6533
+ input,
6534
+ "tools.setPackToolsStatus"
6535
+ ),
6536
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6537
+ }).then(
6538
+ (response) => mapGatewayData(
6539
+ response,
6540
+ (data) => listResultFromEnvelope(data, "tools")
6541
+ )
6542
+ );
6543
+ },
6544
+ createAcl(input, idempotencyKey) {
6545
+ cleanRequiredString(input.tenantId, "tenantId");
6546
+ cleanRequiredString(input.principalId, "principalId");
6547
+ cleanRequiredString(input.toolName, "toolName");
6548
+ return gateway.request({
6549
+ path: "/api/platform/v1/tools/acls",
6550
+ method: "POST",
6551
+ body: writeBody(
6552
+ input,
6553
+ "tools.createAcl"
6554
+ ),
6555
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6556
+ });
6557
+ },
6558
+ deleteAcl(input, idempotencyKey) {
6559
+ cleanRequiredString(input.tenantId, "tenantId");
6560
+ cleanRequiredString(input.aclId, "aclId");
6561
+ return gateway.request({
6562
+ path: `/api/platform/v1/tools/acls/${encodeURIComponent(input.aclId)}`,
6563
+ method: "DELETE",
6564
+ body: writeBody(
6565
+ input,
6566
+ "tools.deleteAcl"
6567
+ ),
6568
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6569
+ });
6570
+ },
6571
+ registerCustomTool(input, idempotencyKey) {
6572
+ cleanRequiredString(input.tenantId, "tenantId");
6573
+ cleanRequiredString(input.toolName, "toolName");
6574
+ return gateway.request({
6575
+ path: "/api/platform/v1/tools/custom",
6576
+ method: "POST",
6577
+ body: writeBody(
6578
+ input,
6579
+ "tools.registerCustomTool"
6580
+ ),
6581
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6582
+ });
6583
+ }
6584
+ };
6585
+ }
6586
+
4646
6587
  // src/version.ts
4647
6588
  var LUCERN_SDK_VERSION = "0.2.0-alpha.1";
4648
6589
 
@@ -4660,10 +6601,10 @@ function createWorkflowClient(config = {}) {
4660
6601
  /**
4661
6602
  * List workflow branches for a topic scope.
4662
6603
  */
4663
- async listBranches(query) {
6604
+ async listBranches(query5) {
4664
6605
  return gateway.request({
4665
6606
  path: `/api/platform/v1/workflow/branches${toQueryString(
4666
- normalizeTopicQuery(query)
6607
+ normalizeTopicQuery(query5)
4667
6608
  )}`
4668
6609
  }).then(
4669
6610
  (response) => mapGatewayData(
@@ -4691,10 +6632,10 @@ function createWorkflowClient(config = {}) {
4691
6632
  /**
4692
6633
  * List reusable lenses for a workspace or topic scope.
4693
6634
  */
4694
- async listLenses(query) {
6635
+ async listLenses(query5) {
4695
6636
  return gateway.request({
4696
6637
  path: `/api/platform/v1/workflow/lenses${toQueryString(
4697
- normalizeLensQuery(query)
6638
+ normalizeLensQuery(query5)
4698
6639
  )}`
4699
6640
  }).then(
4700
6641
  (response) => mapGatewayData(
@@ -4766,14 +6707,14 @@ function createWorkflowClient(config = {}) {
4766
6707
  /**
4767
6708
  * List worktrees for a topic scope.
4768
6709
  */
4769
- async listWorktrees(query) {
4770
- const normalized = normalizeTopicQuery(query);
6710
+ async listWorktrees(query5) {
6711
+ const normalized = normalizeTopicQuery(query5);
4771
6712
  return gateway.request({
4772
6713
  path: `/api/platform/v1/worktrees/all${toQueryString({
4773
6714
  ...normalized,
4774
- groupBy: query.groupBy,
4775
- lane: query.lane,
4776
- campaign: query.campaign
6715
+ groupBy: query5.groupBy,
6716
+ lane: query5.lane,
6717
+ campaign: query5.campaign
4777
6718
  })}`
4778
6719
  }).then(
4779
6720
  (response) => mapGatewayData(
@@ -4788,14 +6729,14 @@ function createWorkflowClient(config = {}) {
4788
6729
  /**
4789
6730
  * List all worktrees across accessible topics.
4790
6731
  */
4791
- async listAllWorktrees(query = {}) {
6732
+ async listAllWorktrees(query5 = {}) {
4792
6733
  return gateway.request({
4793
6734
  path: `/api/platform/v1/worktrees${toQueryString({
4794
- status: query.status,
4795
- groupBy: query.groupBy,
4796
- lane: query.lane,
4797
- campaign: query.campaign,
4798
- limit: query.limit
6735
+ status: query5.status,
6736
+ groupBy: query5.groupBy,
6737
+ lane: query5.lane,
6738
+ campaign: query5.campaign,
6739
+ limit: query5.limit
4799
6740
  })}`
4800
6741
  }).then(
4801
6742
  (response) => mapGatewayData(response, (data) => {
@@ -4815,10 +6756,10 @@ function createWorkflowClient(config = {}) {
4815
6756
  /**
4816
6757
  * List compact pipeline campaigns with nested lanes.
4817
6758
  */
4818
- async listCampaigns(query = {}) {
6759
+ async listCampaigns(query5 = {}) {
4819
6760
  return gateway.request({
4820
6761
  path: `/api/platform/v1/worktrees/campaigns${toQueryString(
4821
- normalizeTopicQuery(query)
6762
+ normalizeTopicQuery(query5)
4822
6763
  )}`
4823
6764
  });
4824
6765
  },
@@ -4874,11 +6815,11 @@ function createWorkflowClient(config = {}) {
4874
6815
  * Update targeted beliefs/questions for a worktree.
4875
6816
  */
4876
6817
  async updateWorktreeTargets(input, idempotencyKey) {
4877
- const { worktreeId, ...body } = input;
6818
+ const { worktreeId, ...body4 } = input;
4878
6819
  return gateway.request({
4879
6820
  path: `/api/platform/v1/worktrees/${encodeURIComponent(worktreeId)}/targets`,
4880
6821
  method: "POST",
4881
- body,
6822
+ body: body4,
4882
6823
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4883
6824
  }).then(
4884
6825
  (response) => mapGatewayData(
@@ -4967,11 +6908,11 @@ function createWorkflowClient(config = {}) {
4967
6908
  /**
4968
6909
  * List accessible topic contexts.
4969
6910
  */
4970
- async listTopics(query = {}) {
6911
+ async listTopics(query5 = {}) {
4971
6912
  return gateway.request({
4972
6913
  path: `/api/platform/v1/workflow/topics${toQueryString({
4973
- includeShared: typeof query.includeShared === "boolean" ? query.includeShared ? "true" : "false" : void 0,
4974
- limit: query.limit
6914
+ includeShared: typeof query5.includeShared === "boolean" ? query5.includeShared ? "true" : "false" : void 0,
6915
+ limit: query5.limit
4975
6916
  })}`
4976
6917
  }).then(
4977
6918
  (response) => mapGatewayData(response, (data) => {
@@ -5099,13 +7040,15 @@ function toGatewayConfig(config) {
5099
7040
  requestIdFactory: config.requestIdFactory,
5100
7041
  onRequest: config.onRequest,
5101
7042
  onResponse: config.onResponse,
7043
+ authContext: config.authContext,
7044
+ requireCanonicalAuthContext: config.requireCanonicalAuthContext,
5102
7045
  getAuthHeaders: async () => {
5103
7046
  const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
5104
7047
  if (config.apiKey && !base["x-lucern-key"] && !base.Authorization) {
5105
7048
  base["x-lucern-key"] = config.apiKey;
5106
7049
  }
5107
- if (config.userToken && !base["x-lucern-user-token"]) {
5108
- base["x-lucern-user-token"] = config.userToken;
7050
+ if (config.userToken && !base["x-lucern-session-token"]) {
7051
+ base["x-lucern-session-token"] = config.userToken;
5109
7052
  }
5110
7053
  if (config.environment && !base["x-lucern-environment"]) {
5111
7054
  base["x-lucern-environment"] = config.environment;
@@ -5114,7 +7057,7 @@ function toGatewayConfig(config) {
5114
7057
  }
5115
7058
  };
5116
7059
  }
5117
- function requireTopicId(args) {
7060
+ function requireTopicId4(args) {
5118
7061
  const topicId = resolveTopicId(args);
5119
7062
  if (!topicId) {
5120
7063
  throw new Error("topicId is required");
@@ -5162,12 +7105,18 @@ function createLucernClient(config = {}) {
5162
7105
  const sourcesClient = createSourcesClient(gatewayConfig);
5163
7106
  const beliefsFacade = createBeliefsFacade(gatewayConfig);
5164
7107
  const evidenceClient = createEvidenceClient(gatewayConfig);
7108
+ const embeddingsClient = createEmbeddingsClient(gatewayConfig);
7109
+ const eventingClient = createEventingClient(gatewayConfig);
5165
7110
  const graphClient = createGraphClient(gatewayConfig);
7111
+ const graphAnalysisClient = createGraphAnalysisClient(gatewayConfig);
7112
+ const graphRecommendationsClient = createGraphRecommendationsClient(gatewayConfig);
7113
+ const graphStateClassifierClient = createGraphStateClassifierClient(gatewayConfig);
5166
7114
  const graphFacade = createGraphFacade(gatewayConfig);
5167
7115
  const decisionsClient = createDecisionsClient(gatewayConfig);
5168
7116
  const contextClient = createContextClient(gatewayConfig);
5169
7117
  const workflowClient = createWorkflowClient(gatewayConfig);
5170
7118
  const auditClient = createAuditClient(gatewayConfig);
7119
+ const authDeviceClient = createAuthDeviceClient(gatewayConfig);
5171
7120
  const adminClient = createAdminClient(gatewayConfig);
5172
7121
  const answersClient = createAnswersClient(gatewayConfig);
5173
7122
  const contradictionsFacade = createContradictionsFacade(gatewayConfig);
@@ -5185,10 +7134,17 @@ function createLucernClient(config = {}) {
5185
7134
  const worktreesFacade = createWorktreesFacade(gatewayConfig);
5186
7135
  const policyClient = createPolicyClient(gatewayConfig);
5187
7136
  const ontologyClient = createOntologyClient(gatewayConfig);
7137
+ const ontologyLinksClient = createOntologyLinksClient(gatewayConfig);
7138
+ const orgGraphSearchClient = createOrgGraphSearchClient(gatewayConfig);
5188
7139
  const functionSurfaceClient = createFunctionSurfaceClient(gatewayConfig);
7140
+ const toolRegistryClient = createToolRegistryClient(gatewayConfig);
7141
+ const modelRuntimeClient = createModelRuntimeClient(gatewayConfig);
5189
7142
  const packsClient = createPacksClient(gatewayConfig);
5190
7143
  const reportsClient = createReportsClient(gatewayConfig);
5191
7144
  const learningClient = createLearningClient(gatewayConfig);
7145
+ const mcpClient = createMcpClient(gatewayConfig);
7146
+ const jobsClient = createJobsClient(gatewayConfig);
7147
+ const telemetryClient = createTelemetryClient(gatewayConfig);
5192
7148
  const harnessClient = createHarnessClient(gatewayConfig);
5193
7149
  const schemaClient = createSchemaClient(gatewayConfig);
5194
7150
  const audiencesClient = createAudiencesClient(gatewayConfig);
@@ -5317,7 +7273,7 @@ function createLucernClient(config = {}) {
5317
7273
  }
5318
7274
  async function listBeliefs(args) {
5319
7275
  const response = await beliefsFacade.list({
5320
- topicId: requireTopicId(args),
7276
+ topicId: requireTopicId4(args),
5321
7277
  status: args.status,
5322
7278
  worktreeId: args.worktreeId,
5323
7279
  minConfidence: args.minConfidence,
@@ -5345,13 +7301,13 @@ function createLucernClient(config = {}) {
5345
7301
  const results = groupedBeliefs.length > 0 ? groupedBeliefs : mergedResults.filter((result) => result.type === "belief");
5346
7302
  return { results };
5347
7303
  }
5348
- async function searchResources(query, options = {}) {
7304
+ async function searchResources(query5, options = {}) {
5349
7305
  const topicId = resolveTopicId(options);
5350
7306
  if (!topicId) {
5351
7307
  throw new Error("topicId is required");
5352
7308
  }
5353
7309
  return searchFacade.query({
5354
- q: query,
7310
+ q: query5,
5355
7311
  topicId,
5356
7312
  types: options.types,
5357
7313
  status: options.status,
@@ -5546,8 +7502,8 @@ function createLucernClient(config = {}) {
5546
7502
  }).then(exposeGatewayData);
5547
7503
  }
5548
7504
  const nodesNamespace = {
5549
- list(query) {
5550
- return graphClient.listNodes(query);
7505
+ list(query5) {
7506
+ return graphClient.listNodes(query5);
5551
7507
  },
5552
7508
  get(input) {
5553
7509
  return graphClient.getNode(
@@ -5576,16 +7532,22 @@ function createLucernClient(config = {}) {
5576
7532
  return {
5577
7533
  config,
5578
7534
  version: LUCERN_SDK_VERSION,
5579
- search(query, options) {
5580
- return searchResources(query, options);
7535
+ search(query5, options) {
7536
+ return searchResources(query5, options);
5581
7537
  },
5582
7538
  events: {
5583
- list(query = {}) {
5584
- return eventsFacade.list(query).then(exposeGatewayData);
7539
+ list(query5 = {}) {
7540
+ return eventsFacade.list(query5).then(exposeGatewayData);
5585
7541
  },
5586
7542
  replay(input) {
5587
7543
  return eventsFacade.replay(input).then(exposeGatewayData);
5588
- }
7544
+ },
7545
+ recordEvent: eventingClient.recordEvent,
7546
+ listEvents: eventingClient.listEvents,
7547
+ listWebhooks: eventingClient.listWebhooks,
7548
+ enqueueDelivery: eventingClient.enqueueDelivery,
7549
+ recordDeliveryAttempt: eventingClient.recordDeliveryAttempt,
7550
+ updateDeliveryStatus: eventingClient.updateDeliveryStatus
5589
7551
  },
5590
7552
  beliefs: {
5591
7553
  create(input) {
@@ -5654,7 +7616,7 @@ function createLucernClient(config = {}) {
5654
7616
  },
5655
7617
  list(args) {
5656
7618
  return beliefsFacade.list({
5657
- topicId: requireTopicId(args),
7619
+ topicId: requireTopicId4(args),
5658
7620
  worktreeId: args.worktreeId,
5659
7621
  status: args.status,
5660
7622
  minConfidence: args.minConfidence,
@@ -5683,8 +7645,8 @@ function createLucernClient(config = {}) {
5683
7645
  create(input) {
5684
7646
  return webhooksFacade.create(input).then(exposeGatewayData);
5685
7647
  },
5686
- list(query) {
5687
- return webhooksFacade.list(query).then(exposeGatewayData);
7648
+ list(query5) {
7649
+ return webhooksFacade.list(query5).then(exposeGatewayData);
5688
7650
  },
5689
7651
  get(id) {
5690
7652
  return webhooksFacade.get(id).then(exposeGatewayData);
@@ -5698,8 +7660,8 @@ function createLucernClient(config = {}) {
5698
7660
  test(id, input) {
5699
7661
  return webhooksFacade.test(id, input).then(exposeGatewayData);
5700
7662
  },
5701
- deliveries(id, query) {
5702
- return webhooksFacade.deliveries(id, query).then(exposeGatewayData);
7663
+ deliveries(id, query5) {
7664
+ return webhooksFacade.deliveries(id, query5).then(exposeGatewayData);
5703
7665
  },
5704
7666
  health(id) {
5705
7667
  return webhooksFacade.health(id).then(exposeGatewayData);
@@ -5854,7 +7816,7 @@ function createLucernClient(config = {}) {
5854
7816
  },
5855
7817
  list(args) {
5856
7818
  return questionsFacade.list({
5857
- topicId: requireTopicId(args),
7819
+ topicId: requireTopicId4(args),
5858
7820
  status: args.status,
5859
7821
  priority: args.priority,
5860
7822
  worktreeId: args.worktreeId,
@@ -5926,7 +7888,7 @@ function createLucernClient(config = {}) {
5926
7888
  },
5927
7889
  getHighPriority(args) {
5928
7890
  return this.list({
5929
- topicId: requireTopicId(args),
7891
+ topicId: requireTopicId4(args),
5930
7892
  status: args.includeAnswered ? void 0 : "open"
5931
7893
  }).then((data) => {
5932
7894
  const questions = Array.isArray(data.questions) ? data.questions : [];
@@ -5951,7 +7913,7 @@ function createLucernClient(config = {}) {
5951
7913
  },
5952
7914
  async findMissing(args) {
5953
7915
  return graphFacade.gaps({
5954
- topicId: requireTopicId(args),
7916
+ topicId: requireTopicId4(args),
5955
7917
  minConfidence: args.minConfidence
5956
7918
  }).then(exposeGatewayData);
5957
7919
  }
@@ -5982,21 +7944,21 @@ function createLucernClient(config = {}) {
5982
7944
  },
5983
7945
  analyze(args) {
5984
7946
  return graphFacade.analyze({
5985
- topicId: requireTopicId(args),
7947
+ topicId: requireTopicId4(args),
5986
7948
  limit: args.limit,
5987
7949
  metric: args.metric
5988
7950
  }).then(exposeGatewayData);
5989
7951
  },
5990
7952
  bias(args) {
5991
7953
  return graphFacade.bias({
5992
- topicId: requireTopicId(args),
7954
+ topicId: requireTopicId4(args),
5993
7955
  threshold: args.threshold,
5994
7956
  limit: args.limit
5995
7957
  }).then(exposeGatewayData);
5996
7958
  },
5997
7959
  gaps(args) {
5998
7960
  return graphFacade.gaps({
5999
- topicId: requireTopicId(args),
7961
+ topicId: requireTopicId4(args),
6000
7962
  minConfidence: args.minConfidence
6001
7963
  }).then(exposeGatewayData);
6002
7964
  },
@@ -6055,8 +8017,8 @@ function createLucernClient(config = {}) {
6055
8017
  record(input) {
6056
8018
  return decisionsClient.recordJudgment(input);
6057
8019
  },
6058
- list(query) {
6059
- return decisionsClient.listJudgments(query);
8020
+ list(query5) {
8021
+ return decisionsClient.listJudgments(query5);
6060
8022
  },
6061
8023
  get(judgmentId) {
6062
8024
  return decisionsClient.getJudgment(judgmentId);
@@ -6085,7 +8047,7 @@ function createLucernClient(config = {}) {
6085
8047
  transitionAuditIntegrity(args) {
6086
8048
  return decisionsClient.getJudgmentTransitionAuditIntegrity({
6087
8049
  ...args,
6088
- topicId: requireTopicId(args)
8050
+ topicId: requireTopicId4(args)
6089
8051
  });
6090
8052
  }
6091
8053
  },
@@ -6096,8 +8058,8 @@ function createLucernClient(config = {}) {
6096
8058
  createLens(input) {
6097
8059
  return workflowClient.createLens(input);
6098
8060
  },
6099
- listLenses(query) {
6100
- return workflowClient.listLenses(query);
8061
+ listLenses(query5) {
8062
+ return workflowClient.listLenses(query5);
6101
8063
  },
6102
8064
  applyLensToTopic(input) {
6103
8065
  return workflowClient.applyLensToTopic(input);
@@ -6108,7 +8070,7 @@ function createLucernClient(config = {}) {
6108
8070
  create(input) {
6109
8071
  return worktreesFacade.create({
6110
8072
  title: input.title,
6111
- topicId: requireTopicId(input),
8073
+ topicId: requireTopicId4(input),
6112
8074
  objective: input.objective,
6113
8075
  hypothesis: input.hypothesis,
6114
8076
  beliefIds: input.beliefIds,
@@ -6130,7 +8092,7 @@ function createLucernClient(config = {}) {
6130
8092
  add(input) {
6131
8093
  return worktreesFacade.create({
6132
8094
  title: input.title,
6133
- topicId: requireTopicId(input),
8095
+ topicId: requireTopicId4(input),
6134
8096
  objective: input.objective,
6135
8097
  hypothesis: input.hypothesis,
6136
8098
  beliefIds: input.beliefIds,
@@ -6149,11 +8111,11 @@ function createLucernClient(config = {}) {
6149
8111
  autoFixPolicy: input.autoFixPolicy
6150
8112
  });
6151
8113
  },
6152
- list(query) {
8114
+ list(query5) {
6153
8115
  return worktreesFacade.list({
6154
- topicId: requireTopicId(query),
6155
- status: query.status,
6156
- limit: query.limit
8116
+ topicId: requireTopicId4(query5),
8117
+ status: query5.status,
8118
+ limit: query5.limit
6157
8119
  });
6158
8120
  },
6159
8121
  activate(worktreeId) {
@@ -6188,8 +8150,8 @@ function createLucernClient(config = {}) {
6188
8150
  removeQuestionIds: input.removeQuestionIds
6189
8151
  });
6190
8152
  },
6191
- listAll(query = {}) {
6192
- return workflowClient.listAllWorktrees(query);
8153
+ listAll(query5 = {}) {
8154
+ return workflowClient.listAllWorktrees(query5);
6193
8155
  },
6194
8156
  merge(worktreeId, input) {
6195
8157
  return worktreesFacade.merge({
@@ -6230,12 +8192,12 @@ function createLucernClient(config = {}) {
6230
8192
  }
6231
8193
  },
6232
8194
  context: {
6233
- listTopics(query = {}) {
8195
+ listTopics(query5 = {}) {
6234
8196
  return topicsFacade.list({
6235
- ontologyId: query.ontologyId,
6236
- parentTopicId: query.parentTopicId,
6237
- status: query.status,
6238
- type: query.type
8197
+ ontologyId: query5.ontologyId,
8198
+ parentTopicId: query5.parentTopicId,
8199
+ status: query5.status,
8200
+ type: query5.type
6239
8201
  });
6240
8202
  },
6241
8203
  compile(topicId, input = {}) {
@@ -6346,10 +8308,10 @@ function createLucernClient(config = {}) {
6346
8308
  visibility: input.visibility
6347
8309
  });
6348
8310
  },
6349
- tree(topicId, query = {}) {
8311
+ tree(topicId, query5 = {}) {
6350
8312
  return topicsFacade.tree({
6351
8313
  id: topicId,
6352
- maxDepth: query.maxDepth
8314
+ maxDepth: query5.maxDepth
6353
8315
  });
6354
8316
  },
6355
8317
  getTree(input) {
@@ -6358,11 +8320,11 @@ function createLucernClient(config = {}) {
6358
8320
  maxDepth: input.maxDepth
6359
8321
  });
6360
8322
  },
6361
- coverage(topicId, query = {}) {
8323
+ coverage(topicId, query5 = {}) {
6362
8324
  return topicsFacade.coverage({
6363
8325
  id: topicId,
6364
- includeDescendants: query.includeDescendants,
6365
- maxDepth: query.maxDepth
8326
+ includeDescendants: query5.includeDescendants,
8327
+ maxDepth: query5.maxDepth
6366
8328
  });
6367
8329
  },
6368
8330
  remove(topicId, idempotencyKey) {
@@ -6412,7 +8374,7 @@ function createLucernClient(config = {}) {
6412
8374
  },
6413
8375
  list(args) {
6414
8376
  return contradictionsFacade.list({
6415
- topicId: requireTopicId(args),
8377
+ topicId: requireTopicId4(args),
6416
8378
  status: args.status,
6417
8379
  limit: args.limit,
6418
8380
  cursor: args.cursor
@@ -6587,7 +8549,24 @@ function createLucernClient(config = {}) {
6587
8549
  return functionSurfaceClient.generateSessionHandoff(input);
6588
8550
  }
6589
8551
  },
8552
+ embeddings: embeddingsClient,
8553
+ graphAnalysis: graphAnalysisClient,
8554
+ graphRecommendations: graphRecommendationsClient,
8555
+ orgGraphSearch: orgGraphSearchClient,
8556
+ ontologyLinks: ontologyLinksClient,
8557
+ graphStateClassifier: graphStateClassifierClient,
8558
+ modelRuntime: modelRuntimeClient,
8559
+ jobs: jobsClient,
8560
+ telemetry: telemetryClient,
6590
8561
  tools: {
8562
+ listCatalog: toolRegistryClient.listCatalog,
8563
+ listExecutable: toolRegistryClient.listExecutable,
8564
+ listEffectiveTools: toolRegistryClient.listEffectiveTools,
8565
+ upsertCoreTools: toolRegistryClient.upsertCoreTools,
8566
+ setPackToolsStatus: toolRegistryClient.setPackToolsStatus,
8567
+ createAcl: toolRegistryClient.createAcl,
8568
+ deleteAcl: toolRegistryClient.deleteAcl,
8569
+ registerCustomTool: toolRegistryClient.registerCustomTool,
6591
8570
  register(registration) {
6592
8571
  return registerCustomTool(registration);
6593
8572
  },
@@ -6644,26 +8623,74 @@ function createLucernClient(config = {}) {
6644
8623
  }
6645
8624
  },
6646
8625
  nodes: nodesNamespace,
6647
- identity: identityFacade,
8626
+ identity: {
8627
+ ...identityFacade,
8628
+ evaluatePolicy: identityClient.evaluatePolicy,
8629
+ recordPolicyDecision: identityClient.recordPolicyDecision,
8630
+ putSecretReference: identityClient.putSecretReference,
8631
+ createPrincipal: identityClient.createPrincipal,
8632
+ updatePrincipal: identityClient.updatePrincipal,
8633
+ raw: identityClient
8634
+ },
8635
+ mcp: {
8636
+ bootstrapSession(input) {
8637
+ return mcpClient.bootstrapSession(input);
8638
+ },
8639
+ checkWritePolicy(input) {
8640
+ return mcpClient.checkWritePolicy(input);
8641
+ },
8642
+ beginBuildSession(input) {
8643
+ return mcpClient.beginBuildSession(input);
8644
+ },
8645
+ evaluateEngineeringContract(input) {
8646
+ return mcpClient.evaluateEngineeringContract(input);
8647
+ },
8648
+ evaluateResearchContract(input) {
8649
+ return mcpClient.evaluateResearchContract(input);
8650
+ }
8651
+ },
8652
+ auth: {
8653
+ device: {
8654
+ createCode(input) {
8655
+ return authDeviceClient.createDeviceCode(input);
8656
+ },
8657
+ pollToken(deviceCode) {
8658
+ return authDeviceClient.pollDeviceToken(deviceCode);
8659
+ }
8660
+ }
8661
+ },
6648
8662
  custom: getCustomNamespace("custom"),
6649
8663
  extensions: extensionNamespaces,
6650
8664
  raw: {
6651
8665
  beliefs: beliefsClient,
6652
8666
  sources: sourcesClient,
6653
8667
  evidence: evidenceClient,
8668
+ embeddings: embeddingsClient,
8669
+ eventing: eventingClient,
6654
8670
  graph: graphClient,
8671
+ graphAnalysis: graphAnalysisClient,
8672
+ graphRecommendations: graphRecommendationsClient,
8673
+ graphStateClassifier: graphStateClassifierClient,
6655
8674
  decisions: decisionsClient,
6656
8675
  workflow: workflowClient,
6657
8676
  audit: auditClient,
8677
+ authDevice: authDeviceClient,
6658
8678
  admin: adminClient,
6659
8679
  identity: identityClient,
6660
8680
  policy: policyClient,
6661
8681
  answers: answersClient,
6662
8682
  ontology: ontologyClient,
8683
+ ontologyLinks: ontologyLinksClient,
8684
+ orgGraphSearch: orgGraphSearchClient,
6663
8685
  functionSurface: functionSurfaceClient,
8686
+ toolRegistry: toolRegistryClient,
8687
+ modelRuntime: modelRuntimeClient,
6664
8688
  packs: packsClient,
6665
8689
  reports: reportsClient,
6666
8690
  learning: learningClient,
8691
+ mcp: mcpClient,
8692
+ jobs: jobsClient,
8693
+ telemetry: telemetryClient,
6667
8694
  harness: harnessClient,
6668
8695
  schema: schemaClient,
6669
8696
  audiences: audiencesClient,