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