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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/adminClient.d.ts +2 -0
  2. package/dist/adminClient.js +194 -3
  3. package/dist/adminClient.js.map +1 -1
  4. package/dist/answersClient.d.ts +2 -0
  5. package/dist/answersClient.js +194 -3
  6. package/dist/answersClient.js.map +1 -1
  7. package/dist/audiencesClient.d.ts +2 -0
  8. package/dist/audiencesClient.js +194 -3
  9. package/dist/audiencesClient.js.map +1 -1
  10. package/dist/auditClient.d.ts +2 -0
  11. package/dist/auditClient.js +196 -5
  12. package/dist/auditClient.js.map +1 -1
  13. package/dist/authContext.d.ts +56 -0
  14. package/dist/authContext.js +169 -0
  15. package/dist/authContext.js.map +1 -0
  16. package/dist/authDeviceClient.d.ts +49 -0
  17. package/dist/authDeviceClient.js +108 -0
  18. package/dist/authDeviceClient.js.map +1 -0
  19. package/dist/beliefs/index.d.ts +19 -2
  20. package/dist/beliefs/index.js +2356 -329
  21. package/dist/beliefs/index.js.map +1 -1
  22. package/dist/beliefsClient.d.ts +2 -0
  23. package/dist/beliefsClient.js +198 -7
  24. package/dist/beliefsClient.js.map +1 -1
  25. package/dist/boundaryClientSurface.d.ts +20 -0
  26. package/dist/boundaryClientSurface.js +66 -0
  27. package/dist/boundaryClientSurface.js.map +1 -0
  28. package/dist/{client-B6aWUUwp.d.ts → client-EiG9nJOY.d.ts} +365 -6
  29. package/dist/client.d.ts +20 -3
  30. package/dist/client.js +2356 -329
  31. package/dist/client.js.map +1 -1
  32. package/dist/contextClient.d.ts +2 -0
  33. package/dist/contextClient.js +200 -9
  34. package/dist/contextClient.js.map +1 -1
  35. package/dist/contracts/index.d.ts +1 -0
  36. package/dist/contracts/index.js +104 -1
  37. package/dist/contracts/index.js.map +1 -1
  38. package/dist/contracts/mcpTools.d.ts +46 -1
  39. package/dist/contracts/mcpTools.js +102 -0
  40. package/dist/contracts/mcpTools.js.map +1 -1
  41. package/dist/contradictions/index.d.ts +19 -2
  42. package/dist/contradictions/index.js +2356 -329
  43. package/dist/contradictions/index.js.map +1 -1
  44. package/dist/coreClient.d.ts +9 -0
  45. package/dist/coreClient.js +194 -3
  46. package/dist/coreClient.js.map +1 -1
  47. package/dist/decisions/index.d.ts +19 -2
  48. package/dist/decisions/index.js +2356 -329
  49. package/dist/decisions/index.js.map +1 -1
  50. package/dist/decisionsClient.d.ts +2 -0
  51. package/dist/decisionsClient.js +197 -6
  52. package/dist/decisionsClient.js.map +1 -1
  53. package/dist/edges/index.d.ts +19 -2
  54. package/dist/edges/index.js +2356 -329
  55. package/dist/edges/index.js.map +1 -1
  56. package/dist/embeddingsClient.d.ts +106 -0
  57. package/dist/embeddingsClient.js +707 -0
  58. package/dist/embeddingsClient.js.map +1 -0
  59. package/dist/eventingClient.d.ts +96 -0
  60. package/dist/eventingClient.js +704 -0
  61. package/dist/eventingClient.js.map +1 -0
  62. package/dist/eventsCore.d.ts +2 -0
  63. package/dist/eventsCore.js +194 -3
  64. package/dist/eventsCore.js.map +1 -1
  65. package/dist/evidence/index.d.ts +19 -2
  66. package/dist/evidence/index.js +2356 -329
  67. package/dist/evidence/index.js.map +1 -1
  68. package/dist/evidenceClient.d.ts +2 -0
  69. package/dist/evidenceClient.js +194 -3
  70. package/dist/evidenceClient.js.map +1 -1
  71. package/dist/gatewayFacades.d.ts +4 -2
  72. package/dist/gatewayFacades.js +370 -12
  73. package/dist/gatewayFacades.js.map +1 -1
  74. package/dist/graphAnalysisClient.d.ts +140 -0
  75. package/dist/graphAnalysisClient.js +753 -0
  76. package/dist/graphAnalysisClient.js.map +1 -0
  77. package/dist/graphClient.d.ts +2 -0
  78. package/dist/graphClient.js +201 -10
  79. package/dist/graphClient.js.map +1 -1
  80. package/dist/graphRecommendationsClient.d.ts +56 -0
  81. package/dist/graphRecommendationsClient.js +645 -0
  82. package/dist/graphRecommendationsClient.js.map +1 -0
  83. package/dist/graphStateClassifierClient.d.ts +73 -0
  84. package/dist/graphStateClassifierClient.js +693 -0
  85. package/dist/graphStateClassifierClient.js.map +1 -0
  86. package/dist/harnessClient.d.ts +2 -0
  87. package/dist/harnessClient.js +196 -5
  88. package/dist/harnessClient.js.map +1 -1
  89. package/dist/identityClient.d.ts +89 -3
  90. package/dist/identityClient.js +362 -4
  91. package/dist/identityClient.js.map +1 -1
  92. package/dist/index.d.ts +20 -3
  93. package/dist/index.js +2516 -356
  94. package/dist/index.js.map +1 -1
  95. package/dist/jobsClient.d.ts +98 -0
  96. package/dist/jobsClient.js +703 -0
  97. package/dist/jobsClient.js.map +1 -0
  98. package/dist/learningClient.d.ts +2 -0
  99. package/dist/learningClient.js +196 -5
  100. package/dist/learningClient.js.map +1 -1
  101. package/dist/lenses/index.d.ts +19 -2
  102. package/dist/lenses/index.js +2356 -329
  103. package/dist/lenses/index.js.map +1 -1
  104. package/dist/mcpClient.d.ts +28 -0
  105. package/dist/mcpClient.js +649 -0
  106. package/dist/mcpClient.js.map +1 -0
  107. package/dist/modelRuntimeClient.d.ts +72 -0
  108. package/dist/modelRuntimeClient.js +680 -0
  109. package/dist/modelRuntimeClient.js.map +1 -0
  110. package/dist/nodes/index.d.ts +19 -2
  111. package/dist/nodes/index.js +2356 -329
  112. package/dist/nodes/index.js.map +1 -1
  113. package/dist/ontologies/index.d.ts +19 -2
  114. package/dist/ontologies/index.js +2356 -329
  115. package/dist/ontologies/index.js.map +1 -1
  116. package/dist/ontologyClient.d.ts +2 -0
  117. package/dist/ontologyClient.js +194 -3
  118. package/dist/ontologyClient.js.map +1 -1
  119. package/dist/ontologyLinksClient.d.ts +71 -0
  120. package/dist/ontologyLinksClient.js +674 -0
  121. package/dist/ontologyLinksClient.js.map +1 -0
  122. package/dist/orgGraphSearchClient.d.ts +85 -0
  123. package/dist/orgGraphSearchClient.js +651 -0
  124. package/dist/orgGraphSearchClient.js.map +1 -0
  125. package/dist/packRuntime.d.ts +1 -2
  126. package/dist/packsClient.d.ts +2 -0
  127. package/dist/packsClient.js +194 -3
  128. package/dist/packsClient.js.map +1 -1
  129. package/dist/policyClient.d.ts +2 -0
  130. package/dist/policyClient.js +194 -3
  131. package/dist/policyClient.js.map +1 -1
  132. package/dist/questions/index.d.ts +19 -2
  133. package/dist/questions/index.js +2356 -329
  134. package/dist/questions/index.js.map +1 -1
  135. package/dist/reportsClient.d.ts +2 -0
  136. package/dist/reportsClient.js +196 -5
  137. package/dist/reportsClient.js.map +1 -1
  138. package/dist/schemaClient.d.ts +2 -0
  139. package/dist/schemaClient.js +194 -3
  140. package/dist/schemaClient.js.map +1 -1
  141. package/dist/sdkSurface.d.ts +2 -0
  142. package/dist/sourcesClient.d.ts +2 -0
  143. package/dist/sourcesClient.js +194 -3
  144. package/dist/sourcesClient.js.map +1 -1
  145. package/dist/telemetryClient.d.ts +94 -0
  146. package/dist/telemetryClient.js +718 -0
  147. package/dist/telemetryClient.js.map +1 -0
  148. package/dist/toolRegistryClient.d.ts +107 -0
  149. package/dist/toolRegistryClient.js +732 -0
  150. package/dist/toolRegistryClient.js.map +1 -0
  151. package/dist/topics/index.d.ts +19 -2
  152. package/dist/topics/index.js +2356 -329
  153. package/dist/topics/index.js.map +1 -1
  154. package/dist/topicsClient.d.ts +2 -0
  155. package/dist/topicsClient.js +199 -8
  156. package/dist/topicsClient.js.map +1 -1
  157. package/dist/workflowClient.d.ts +2 -0
  158. package/dist/workflowClient.js +199 -8
  159. package/dist/workflowClient.js.map +1 -1
  160. package/dist/worktrees/index.d.ts +19 -2
  161. package/dist/worktrees/index.js +2356 -329
  162. package/dist/worktrees/index.js.map +1 -1
  163. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
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 tool_contracts_star from '@lucern/contracts/tool-contracts';
4
+ import { LUCERN_OPERATION_MANIFEST } from '@lucern/contracts/function-registry/manifest';
3
5
 
4
6
  var __defProp = Object.defineProperty;
5
7
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -42,27 +44,44 @@ __export(src_exports, {
42
44
  DEFEAT_TYPES: () => DEFEAT_TYPES,
43
45
  DOMAIN_EVENT_TYPES: () => DOMAIN_EVENT_TYPES,
44
46
  DOMAIN_EVENT_VERSION: () => DOMAIN_EVENT_VERSION,
47
+ DeviceAuthorizationError: () => DeviceAuthorizationError,
45
48
  EDGE_TYPES: () => EDGE_TYPES,
49
+ EMBEDDINGS_FIELDS: () => EMBEDDINGS_FIELDS,
46
50
  EPISTEMIC_EDGE_TYPES: () => EPISTEMIC_EDGE_TYPES,
47
51
  EPISTEMIC_LAYERS: () => EPISTEMIC_LAYERS,
52
+ EVENTING_FIELDS: () => EVENTING_FIELDS,
48
53
  EVENT_RETENTION_DEFAULT_DAYS: () => EVENT_RETENTION_DEFAULT_DAYS,
49
54
  FORK_REASONS: () => FORK_REASONS,
50
55
  FUNCTION_SURFACE_METHOD_PATHS: () => FUNCTION_SURFACE_METHOD_PATHS,
56
+ GRAPH_ANALYSIS_ANALYSIS_FIELDS: () => GRAPH_ANALYSIS_ANALYSIS_FIELDS,
57
+ GRAPH_ANALYSIS_COMPUTE_FIELDS: () => GRAPH_ANALYSIS_COMPUTE_FIELDS,
58
+ GRAPH_ANALYSIS_SUGGESTION_FIELDS: () => GRAPH_ANALYSIS_SUGGESTION_FIELDS,
59
+ GRAPH_RECOMMENDATION_FIELDS: () => GRAPH_RECOMMENDATION_FIELDS,
60
+ GRAPH_STATE_CLASSIFIER_FIELDS: () => GRAPH_STATE_CLASSIFIER_FIELDS,
61
+ JOBS_FIELDS: () => JOBS_FIELDS,
51
62
  JUDGMENT_TYPES: () => JUDGMENT_TYPES,
52
63
  LENS_PERSPECTIVE_TYPES: () => LENS_PERSPECTIVE_TYPES,
53
64
  LENS_STATUSES: () => LENS_STATUSES,
54
65
  LENS_TASK_TEMPLATE_PRIORITIES: () => LENS_TASK_TEMPLATE_PRIORITIES,
55
66
  LUCERN_SDK_VERSION: () => LUCERN_SDK_VERSION,
56
67
  LucernApiError: () => LucernApiError,
68
+ LucernSdkAuthContextError: () => LucernSdkAuthContextError,
57
69
  MAX_ENTITY_LIMIT: () => MAX_ENTITY_LIMIT,
70
+ MCP_ALWAYS_ALLOWED_TOOL_NAMES: () => MCP_ALWAYS_ALLOWED_TOOL_NAMES,
58
71
  MERGE_OUTCOMES: () => MERGE_OUTCOMES,
72
+ MODEL_RUNTIME_FIELDS: () => MODEL_RUNTIME_FIELDS,
59
73
  MORNING_BRIEF_WORKFLOW_ID: () => MORNING_BRIEF_WORKFLOW_ID,
60
74
  NIGHTLY_RECONCILIATION_WORKFLOW_ID: () => NIGHTLY_RECONCILIATION_WORKFLOW_ID,
75
+ ONTOLOGY_LINK_FIELDS: () => ONTOLOGY_LINK_FIELDS,
76
+ ORG_GRAPH_SEARCH_FIELDS: () => ORG_GRAPH_SEARCH_FIELDS,
61
77
  REASONING_METHODS: () => REASONING_METHODS,
62
78
  SESSION_AUTH_MODES: () => SESSION_AUTH_MODES,
63
79
  SESSION_LIFECYCLE_STATUSES: () => SESSION_LIFECYCLE_STATUSES,
64
80
  SESSION_PRINCIPAL_TYPES: () => SESSION_PRINCIPAL_TYPES,
65
81
  STRUCTURAL_EDGE_TYPES: () => STRUCTURAL_EDGE_TYPES,
82
+ TELEMETRY_FIELDS: () => TELEMETRY_FIELDS,
83
+ TENANT_IDENTITY_FIELDS: () => TENANT_IDENTITY_FIELDS,
84
+ TOOL_REGISTRY_FIELDS: () => TOOL_REGISTRY_FIELDS,
66
85
  WEBHOOK_MAX_ATTEMPTS: () => WEBHOOK_MAX_ATTEMPTS,
67
86
  WEBHOOK_RETRY_DELAYS_MS: () => WEBHOOK_RETRY_DELAYS_MS,
68
87
  WORKFLOW_ACTION_KINDS: () => WORKFLOW_ACTION_KINDS,
@@ -83,6 +102,8 @@ __export(src_exports, {
83
102
  assertValidWebhookUrl: () => assertValidWebhookUrl,
84
103
  buildDeprecatedBranchMetadata: () => buildDeprecatedBranchMetadata,
85
104
  buildDomainEvent: () => buildDomainEvent,
105
+ buildMcpToolContracts: () => buildMcpToolContracts,
106
+ buildMcpToolManifest: () => buildMcpToolManifest,
86
107
  clearRegisteredCustomTools: () => clearRegisteredCustomTools,
87
108
  compareEventCursor: () => compareEventCursor,
88
109
  compileContextPackFromSnapshot: () => compileContextPackFromSnapshot,
@@ -91,27 +112,40 @@ __export(src_exports, {
91
112
  createAnswersClient: () => createAnswersClient,
92
113
  createAudiencesClient: () => createAudiencesClient,
93
114
  createAuditClient: () => createAuditClient,
115
+ createAuthDeviceClient: () => createAuthDeviceClient,
94
116
  createBeliefsClient: () => createBeliefsClient,
117
+ createCanonicalAuthHeaders: () => createCanonicalAuthHeaders,
95
118
  createContextClient: () => createContextClient,
96
119
  createContextFacade: () => createContextFacade,
97
120
  createDecisionsClient: () => createDecisionsClient,
121
+ createEmbeddingsClient: () => createEmbeddingsClient,
98
122
  createEventId: () => createEventId,
123
+ createEventingClient: () => createEventingClient,
99
124
  createEventsClientCore: () => createEventsClientCore,
100
125
  createEvidenceClient: () => createEvidenceClient,
101
126
  createFunctionSurfaceClient: () => createFunctionSurfaceClient,
102
127
  createGatewayRequestClient: () => createGatewayRequestClient,
128
+ createGraphAnalysisClient: () => createGraphAnalysisClient,
103
129
  createGraphClient: () => createGraphClient,
130
+ createGraphRecommendationsClient: () => createGraphRecommendationsClient,
131
+ createGraphStateClassifierClient: () => createGraphStateClassifierClient,
104
132
  createHarnessClient: () => createHarnessClient,
105
133
  createIdentityClient: () => createIdentityClient,
134
+ createJobsClient: () => createJobsClient,
106
135
  createLearningClient: () => createLearningClient,
107
136
  createListResult: () => createListResult,
108
137
  createLucernClient: () => createLucernClient,
138
+ createModelRuntimeClient: () => createModelRuntimeClient,
109
139
  createOntologyClient: () => createOntologyClient,
140
+ createOntologyLinksClient: () => createOntologyLinksClient,
141
+ createOrgGraphSearchClient: () => createOrgGraphSearchClient,
110
142
  createPacksClient: () => createPacksClient,
111
143
  createPolicyClient: () => createPolicyClient,
112
144
  createReportsClient: () => createReportsClient,
113
145
  createSchemaClient: () => createSchemaClient,
114
146
  createSourcesClient: () => createSourcesClient,
147
+ createTelemetryClient: () => createTelemetryClient,
148
+ createToolRegistryClient: () => createToolRegistryClient,
115
149
  createTopicsClient: () => createTopicsClient,
116
150
  createWebhooksClientCore: () => createWebhooksClientCore,
117
151
  createWorkflowClient: () => createWorkflowClient,
@@ -120,6 +154,7 @@ __export(src_exports, {
120
154
  encodeEventCursor: () => encodeEventCursor,
121
155
  eventPatternToRegExp: () => eventPatternToRegExp,
122
156
  getControlObjectOwnershipCase: () => getControlObjectOwnershipCase,
157
+ getMcpToolExposure: () => getMcpToolExposure,
123
158
  getRegisteredCustomTool: () => getRegisteredCustomTool,
124
159
  inferActorType: () => inferActorType,
125
160
  inferLensPerspectiveTypeFromBranchSchema: () => inferLensPerspectiveTypeFromBranchSchema,
@@ -128,6 +163,7 @@ __export(src_exports, {
128
163
  isAfterCursor: () => isAfterCursor,
129
164
  isLensFilterCriteria: () => isLensFilterCriteria,
130
165
  isLucernPrompt: () => isLucernPrompt,
166
+ isMcpToolAllowed: () => isMcpToolAllowed,
131
167
  isTaxonomyFilterCriteriaV1: () => isTaxonomyFilterCriteriaV1,
132
168
  lastDelegator: () => lastDelegator,
133
169
  listControlObjectOwnershipCases: () => listControlObjectOwnershipCases,
@@ -137,8 +173,11 @@ __export(src_exports, {
137
173
  mapOpinionHistoryEntriesFromGatewayData: () => mapOpinionHistoryEntriesFromGatewayData,
138
174
  matchesAnyEventPattern: () => matchesAnyEventPattern,
139
175
  matchesEventPattern: () => matchesEventPattern,
176
+ mcpContractToInputSchema: () => mcpContractToInputSchema,
177
+ mcpContractToManifestEntry: () => mcpContractToManifestEntry,
140
178
  migrateBranchToLens: () => migrateBranchToLens,
141
179
  nextDeliveryAttemptAt: () => nextDeliveryAttemptAt,
180
+ normalizeCanonicalLucernAuthContext: () => normalizeCanonicalLucernAuthContext,
142
181
  normalizeDelegationChain: () => normalizeDelegationChain,
143
182
  normalizeNodeVerificationStatus: () => normalizeNodeVerificationStatus,
144
183
  normalizeNodeWriteInput: () => normalizeNodeWriteInput,
@@ -197,6 +236,172 @@ function opinionFromProjected(probability, uncertainty, baseRate) {
197
236
  };
198
237
  }
199
238
 
239
+ // src/authContext.ts
240
+ var LucernSdkAuthContextError = class extends Error {
241
+ reason;
242
+ constructor(reason, message) {
243
+ super(message);
244
+ this.name = "LucernSdkAuthContextError";
245
+ this.reason = reason;
246
+ }
247
+ };
248
+ function cleanString(value) {
249
+ const normalized = value?.trim();
250
+ return normalized ? normalized : void 0;
251
+ }
252
+ function cleanStringList(values) {
253
+ if (!values) {
254
+ return [];
255
+ }
256
+ return values.map((value) => value.trim()).filter(
257
+ (value, index, list) => value.length > 0 && list.indexOf(value) === index
258
+ );
259
+ }
260
+ function requireString(value, reason, label) {
261
+ const normalized = cleanString(value);
262
+ if (!normalized) {
263
+ throw new LucernSdkAuthContextError(
264
+ reason,
265
+ `Canonical Lucern SDK auth context is missing ${label}.`
266
+ );
267
+ }
268
+ return normalized;
269
+ }
270
+ function requirePrincipalType(principalType) {
271
+ if (!principalType) {
272
+ throw new LucernSdkAuthContextError(
273
+ "principal_missing",
274
+ "Canonical Lucern SDK auth context is missing principalType."
275
+ );
276
+ }
277
+ return principalType;
278
+ }
279
+ function requireAuthMode(authMode) {
280
+ if (!authMode) {
281
+ throw new LucernSdkAuthContextError(
282
+ "principal_missing",
283
+ "Canonical Lucern SDK auth context is missing authMode."
284
+ );
285
+ }
286
+ return authMode;
287
+ }
288
+ function ensurePermitMatch(args) {
289
+ const actual = cleanString(args.actual);
290
+ if (actual && actual !== args.expected) {
291
+ throw new LucernSdkAuthContextError(
292
+ "policy_denied",
293
+ `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
294
+ );
295
+ }
296
+ }
297
+ function normalizeCanonicalLucernAuthContext(input) {
298
+ if (!input) {
299
+ throw new LucernSdkAuthContextError(
300
+ "principal_missing",
301
+ "Canonical Lucern SDK auth context is required."
302
+ );
303
+ }
304
+ if (input.policyDecision === "deny") {
305
+ throw new LucernSdkAuthContextError(
306
+ "policy_denied",
307
+ "Canonical Lucern SDK auth context carries a denied policy decision."
308
+ );
309
+ }
310
+ const principalId = requireString(
311
+ input.principalId,
312
+ "principal_missing",
313
+ "principalId"
314
+ );
315
+ const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
316
+ const workspaceId = requireString(
317
+ input.workspaceId,
318
+ "workspace_missing",
319
+ "workspaceId"
320
+ );
321
+ const roles = cleanStringList(input.roles);
322
+ const scopes = cleanStringList(input.scopes);
323
+ if (roles.length === 0 || scopes.length === 0) {
324
+ throw new LucernSdkAuthContextError(
325
+ "membership_missing",
326
+ "Canonical Lucern SDK auth context requires non-empty roles and scopes."
327
+ );
328
+ }
329
+ const principalType = requirePrincipalType(input.principalType);
330
+ const authMode = requireAuthMode(input.authMode);
331
+ const subject = cleanString(input.permit?.subject) ?? principalId;
332
+ const tenant = cleanString(input.permit?.tenant) ?? tenantId;
333
+ const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
334
+ ensurePermitMatch({
335
+ field: "subject",
336
+ expected: principalId,
337
+ actual: subject
338
+ });
339
+ ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
340
+ ensurePermitMatch({
341
+ field: "workspace",
342
+ expected: workspaceId,
343
+ actual: workspace
344
+ });
345
+ const context = input.permit?.context ? { ...input.permit.context } : void 0;
346
+ return {
347
+ clerkId: cleanString(input.clerkId),
348
+ principalId,
349
+ tenantId,
350
+ workspaceId,
351
+ principalType,
352
+ authMode,
353
+ roles,
354
+ scopes,
355
+ delegationChain: input.delegationChain ? [...input.delegationChain] : [],
356
+ policyTraceId: cleanString(input.policyTraceId),
357
+ correlationId: cleanString(input.correlationId),
358
+ membershipId: cleanString(input.membershipId),
359
+ permit: {
360
+ subject,
361
+ tenant,
362
+ workspace,
363
+ resource: cleanString(input.permit?.resource),
364
+ action: cleanString(input.permit?.action),
365
+ relation: cleanString(input.permit?.relation),
366
+ context
367
+ }
368
+ };
369
+ }
370
+ function createCanonicalAuthHeaders(authContext) {
371
+ const headers = {
372
+ "x-lucern-principal-id": authContext.principalId,
373
+ "x-lucern-principal-type": authContext.principalType,
374
+ "x-lucern-tenant": authContext.tenantId,
375
+ "x-lucern-tenant-id": authContext.tenantId,
376
+ "x-lucern-workspace": authContext.workspaceId,
377
+ "x-lucern-workspace-id": authContext.workspaceId,
378
+ "x-lucern-auth-mode": authContext.authMode,
379
+ "x-lucern-roles": authContext.roles.join(","),
380
+ "x-lucern-scopes": authContext.scopes.join(","),
381
+ "x-lucern-permit-context": JSON.stringify(authContext.permit)
382
+ };
383
+ if (authContext.clerkId) {
384
+ headers["x-lucern-clerk-id"] = authContext.clerkId;
385
+ headers["x-lucern-user-id"] = authContext.clerkId;
386
+ }
387
+ if (authContext.delegationChain.length > 0) {
388
+ headers["x-lucern-delegation-chain"] = JSON.stringify(
389
+ authContext.delegationChain
390
+ );
391
+ }
392
+ if (authContext.policyTraceId) {
393
+ headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
394
+ }
395
+ if (authContext.correlationId) {
396
+ headers["x-correlation-id"] = authContext.correlationId;
397
+ headers["x-lucern-correlation-id"] = authContext.correlationId;
398
+ }
399
+ if (authContext.membershipId) {
400
+ headers["x-lucern-membership-id"] = authContext.membershipId;
401
+ }
402
+ return headers;
403
+ }
404
+
200
405
  // src/coreClient.ts
201
406
  var LucernApiError = class extends Error {
202
407
  code;
@@ -353,16 +558,41 @@ function readPolicySummaryFromDetails(details) {
353
558
  }
354
559
  return null;
355
560
  }
561
+ async function resolveConfiguredAuthContext(authContext) {
562
+ if (typeof authContext === "function") {
563
+ return await authContext();
564
+ }
565
+ return authContext;
566
+ }
567
+ function mergeHeaderRecord(base, addition) {
568
+ const headers = new Headers(base);
569
+ for (const [key, value] of Object.entries(addition)) {
570
+ const existing = headers.get(key);
571
+ if (existing !== null && existing !== value) {
572
+ throw new LucernSdkAuthContextError(
573
+ "policy_denied",
574
+ `Canonical Lucern SDK auth context conflicts with existing ${key} header.`
575
+ );
576
+ }
577
+ headers.set(key, value);
578
+ }
579
+ return Object.fromEntries(headers.entries());
580
+ }
356
581
  function createGatewayRequestClient(config = {}) {
357
582
  const fetchImpl = config.fetchImpl ?? fetch;
358
583
  const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
359
584
  const maxRetries = config.maxRetries ?? 2;
360
585
  const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
361
586
  async function resolveAuthHeaders() {
362
- if (!config.getAuthHeaders) {
363
- return {};
587
+ const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
588
+ const authContextInput = await resolveConfiguredAuthContext(
589
+ config.authContext
590
+ );
591
+ if (!authContextInput && !config.requireCanonicalAuthContext) {
592
+ return base;
364
593
  }
365
- return await config.getAuthHeaders();
594
+ const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
595
+ return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
366
596
  }
367
597
  async function fetchWithTimeout(url, init, timeoutMs) {
368
598
  const controller = new AbortController();
@@ -537,11 +767,11 @@ function createGatewayRequestClient(config = {}) {
537
767
  function asRecord(value) {
538
768
  return value && typeof value === "object" ? value : {};
539
769
  }
540
- function cleanString(value) {
770
+ function cleanString2(value) {
541
771
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
542
772
  }
543
773
  function normalizeVerificationStatus(value) {
544
- const status = cleanString(value);
774
+ const status = cleanString2(value);
545
775
  if (!status) {
546
776
  return void 0;
547
777
  }
@@ -557,20 +787,20 @@ function cloneWith(value, patch) {
557
787
  return { ...value, ...patch };
558
788
  }
559
789
  function resolveTopicId(value) {
560
- return cleanString(value.topicId);
790
+ return cleanString2(value.topicId);
561
791
  }
562
792
  function resolveText(value) {
563
- return cleanString(value.text) ?? cleanString(value.canonicalText);
793
+ return cleanString2(value.text) ?? cleanString2(value.canonicalText);
564
794
  }
565
795
  function withTopicAlias(value) {
566
- const topicId = cleanString(value.topicId) ?? void 0;
796
+ const topicId = cleanString2(value.topicId) ?? void 0;
567
797
  if (!topicId) {
568
798
  return value;
569
799
  }
570
800
  return cloneWith(value, { topicId });
571
801
  }
572
802
  function withTextAlias(value) {
573
- const text = cleanString(value.text) ?? cleanString(value.canonicalText) ?? void 0;
803
+ const text = cleanString2(value.text) ?? cleanString2(value.canonicalText) ?? void 0;
574
804
  if (!text) {
575
805
  return value;
576
806
  }
@@ -600,7 +830,7 @@ function normalizeNodeVerificationStatus(value) {
600
830
  return normalizeVerificationStatus(value);
601
831
  }
602
832
  function normalizeTopicQuery(value) {
603
- const topicId = cleanString(value.topicId);
833
+ const topicId = cleanString2(value.topicId);
604
834
  if (!topicId) {
605
835
  return value;
606
836
  }
@@ -673,9 +903,9 @@ function createAdminClient(config = {}) {
673
903
  /**
674
904
  * List tenants visible to the current principal.
675
905
  */
676
- async listTenants(query = {}) {
906
+ async listTenants(query5 = {}) {
677
907
  return gateway.request({
678
- path: `/api/platform/v1/tenants${toQueryString(query)}`
908
+ path: `/api/platform/v1/tenants${toQueryString(query5)}`
679
909
  }).then(
680
910
  (response) => mapGatewayData(
681
911
  response,
@@ -716,9 +946,9 @@ function createAdminClient(config = {}) {
716
946
  /**
717
947
  * List workspaces for the current admin scope.
718
948
  */
719
- async listWorkspaces(query = {}) {
949
+ async listWorkspaces(query5 = {}) {
720
950
  return gateway.request({
721
- path: `/api/platform/v1/workspaces${toQueryString(query)}`
951
+ path: `/api/platform/v1/workspaces${toQueryString(query5)}`
722
952
  }).then(
723
953
  (response) => mapGatewayData(
724
954
  response,
@@ -743,9 +973,9 @@ function createAdminClient(config = {}) {
743
973
  /**
744
974
  * List memberships for the current admin scope.
745
975
  */
746
- async listMemberships(query = {}) {
976
+ async listMemberships(query5 = {}) {
747
977
  return gateway.request({
748
- path: `/api/platform/v1/memberships${toQueryString(query)}`
978
+ path: `/api/platform/v1/memberships${toQueryString(query5)}`
749
979
  }).then(
750
980
  (response) => mapGatewayData(
751
981
  response,
@@ -982,9 +1212,9 @@ function createAdminClient(config = {}) {
982
1212
  /**
983
1213
  * List group members.
984
1214
  */
985
- async listGroupMembers(query) {
1215
+ async listGroupMembers(query5) {
986
1216
  return gateway.request({
987
- path: `/api/platform/v1/groups/members${toQueryString(query)}`
1217
+ path: `/api/platform/v1/groups/members${toQueryString(query5)}`
988
1218
  });
989
1219
  },
990
1220
  /**
@@ -1011,9 +1241,9 @@ function createAdminClient(config = {}) {
1011
1241
  /**
1012
1242
  * List pack-to-group assignments.
1013
1243
  */
1014
- async listPackGroupAssignments(query = {}) {
1244
+ async listPackGroupAssignments(query5 = {}) {
1015
1245
  return gateway.request({
1016
- path: `/api/platform/v1/groups/packs${toQueryString(query)}`
1246
+ path: `/api/platform/v1/groups/packs${toQueryString(query5)}`
1017
1247
  });
1018
1248
  },
1019
1249
  /**
@@ -1064,12 +1294,12 @@ function createAudiencesClient(config = {}) {
1064
1294
  /**
1065
1295
  * List audience registry entries.
1066
1296
  */
1067
- async listRegistry(query = {}) {
1297
+ async listRegistry(query5 = {}) {
1068
1298
  return gateway.request({
1069
1299
  path: `/api/platform/v1/audiences/registry${toQueryString({
1070
- ...query,
1071
- effective: typeof query.effective === "boolean" ? query.effective ? "true" : "false" : void 0,
1072
- status: query.status
1300
+ ...query5,
1301
+ effective: typeof query5.effective === "boolean" ? query5.effective ? "true" : "false" : void 0,
1302
+ status: query5.status
1073
1303
  })}`
1074
1304
  }).then(
1075
1305
  (response) => mapGatewayData(
@@ -1084,8 +1314,8 @@ function createAudiencesClient(config = {}) {
1084
1314
  /**
1085
1315
  * @deprecated Use listRegistry.
1086
1316
  */
1087
- async getRegistry(query = {}) {
1088
- return this.listRegistry(query);
1317
+ async getRegistry(query5 = {}) {
1318
+ return this.listRegistry(query5);
1089
1319
  },
1090
1320
  /**
1091
1321
  * Create an audience registry entry.
@@ -1113,14 +1343,14 @@ function createAudiencesClient(config = {}) {
1113
1343
  /**
1114
1344
  * List audience grants.
1115
1345
  */
1116
- async listGrants(query = {}) {
1346
+ async listGrants(query5 = {}) {
1117
1347
  return gateway.request({
1118
1348
  path: `/api/platform/v1/audiences/grants${toQueryString({
1119
- ...query,
1120
- audienceKey: query.audienceKey,
1121
- principalId: query.principalId,
1122
- groupId: query.groupId,
1123
- status: query.status
1349
+ ...query5,
1350
+ audienceKey: query5.audienceKey,
1351
+ principalId: query5.principalId,
1352
+ groupId: query5.groupId,
1353
+ status: query5.status
1124
1354
  })}`
1125
1355
  }).then(
1126
1356
  (response) => mapGatewayData(
@@ -1132,8 +1362,8 @@ function createAudiencesClient(config = {}) {
1132
1362
  /**
1133
1363
  * @deprecated Use listGrants.
1134
1364
  */
1135
- async getGrants(query = {}) {
1136
- return this.listGrants(query);
1365
+ async getGrants(query5 = {}) {
1366
+ return this.listGrants(query5);
1137
1367
  },
1138
1368
  /**
1139
1369
  * Create an audience grant.
@@ -1179,10 +1409,10 @@ function createAuditClient(config = {}) {
1179
1409
  /**
1180
1410
  * List audit events for the current scope.
1181
1411
  */
1182
- async listEvents(query = {}) {
1412
+ async listEvents(query5 = {}) {
1183
1413
  return gateway.request({
1184
1414
  path: `/api/platform/v1/audit/events${toQueryString(
1185
- normalizeTopicQuery(query)
1415
+ normalizeTopicQuery(query5)
1186
1416
  )}`
1187
1417
  }).then(
1188
1418
  (response) => mapGatewayData(
@@ -1194,11 +1424,116 @@ function createAuditClient(config = {}) {
1194
1424
  };
1195
1425
  }
1196
1426
 
1427
+ // src/authDeviceClient.ts
1428
+ var DeviceAuthorizationError = class extends Error {
1429
+ error;
1430
+ interval;
1431
+ constructor(args) {
1432
+ super(args.description ?? args.error);
1433
+ this.name = "DeviceAuthorizationError";
1434
+ this.error = args.error;
1435
+ this.interval = args.interval;
1436
+ }
1437
+ };
1438
+ function authBaseUrl(config) {
1439
+ return config.baseUrl?.replace(/\/+$/, "") ?? "";
1440
+ }
1441
+ async function readJson(response) {
1442
+ const payload = await response.json().catch(() => ({}));
1443
+ return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
1444
+ }
1445
+ function readString(value) {
1446
+ const normalized = typeof value === "string" ? value.trim() : "";
1447
+ return normalized || void 0;
1448
+ }
1449
+ function assertDeviceCodeResponse(payload) {
1450
+ const deviceCode = readString(payload.device_code);
1451
+ const userCode = readString(payload.user_code);
1452
+ const verificationUri = readString(payload.verification_uri);
1453
+ const verificationUriComplete = readString(payload.verification_uri_complete);
1454
+ const expiresIn = payload.expires_in;
1455
+ const interval = payload.interval;
1456
+ if (!deviceCode || !userCode || !verificationUri || !verificationUriComplete || typeof expiresIn !== "number" || typeof interval !== "number") {
1457
+ throw new Error("Gateway returned an invalid device-code response.");
1458
+ }
1459
+ return {
1460
+ device_code: deviceCode,
1461
+ user_code: userCode,
1462
+ verification_uri: verificationUri,
1463
+ verification_uri_complete: verificationUriComplete,
1464
+ expires_in: expiresIn,
1465
+ interval
1466
+ };
1467
+ }
1468
+ function assertDeviceTokenResponse(payload) {
1469
+ const accessToken = readString(payload.access_token);
1470
+ const tokenType = readString(payload.token_type);
1471
+ const scope = readString(payload.scope);
1472
+ const tenantId = readString(payload.tenant_id);
1473
+ const principalId = readString(payload.principal_id);
1474
+ if (!accessToken || tokenType !== "Bearer" || typeof payload.expires_in !== "number" || !scope || !tenantId || !principalId) {
1475
+ throw new Error("Gateway returned an invalid device token response.");
1476
+ }
1477
+ return {
1478
+ access_token: accessToken,
1479
+ token_type: "Bearer",
1480
+ expires_in: payload.expires_in,
1481
+ scope,
1482
+ tenant_id: tenantId,
1483
+ workspace_id: readString(payload.workspace_id),
1484
+ principal_id: principalId,
1485
+ user: payload.user && typeof payload.user === "object" && !Array.isArray(payload.user) ? payload.user : void 0
1486
+ };
1487
+ }
1488
+ function maybeThrowDeviceError(payload) {
1489
+ const error = readString(payload.error);
1490
+ throw new DeviceAuthorizationError({
1491
+ error: error ?? "invalid_request",
1492
+ description: readString(payload.error_description),
1493
+ interval: typeof payload.interval === "number" ? payload.interval : void 0
1494
+ });
1495
+ }
1496
+ function createAuthDeviceClient(config = {}) {
1497
+ const fetchImpl = config.fetchImpl ?? fetch;
1498
+ const baseUrl = authBaseUrl(config);
1499
+ async function post(path, body4) {
1500
+ return fetchImpl(`${baseUrl}${path}`, {
1501
+ method: "POST",
1502
+ headers: { "content-type": "application/json" },
1503
+ body: JSON.stringify(body4)
1504
+ });
1505
+ }
1506
+ return {
1507
+ async createDeviceCode(input = {}) {
1508
+ const response = await post("/api/platform/v1/auth/device/code", {
1509
+ client_id: input.clientId ?? "lucern-cli",
1510
+ scope: input.scope ?? "graph.read graph.write"
1511
+ });
1512
+ const payload = await readJson(response);
1513
+ if (!response.ok) {
1514
+ maybeThrowDeviceError(payload);
1515
+ }
1516
+ return assertDeviceCodeResponse(payload);
1517
+ },
1518
+ async pollDeviceToken(deviceCode) {
1519
+ const response = await post("/api/platform/v1/auth/device/token", {
1520
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
1521
+ device_code: deviceCode
1522
+ });
1523
+ const payload = await readJson(response);
1524
+ if (!response.ok) {
1525
+ maybeThrowDeviceError(payload);
1526
+ }
1527
+ return assertDeviceTokenResponse(payload);
1528
+ }
1529
+ };
1530
+ }
1531
+
1197
1532
  // src/beliefsClient.ts
1198
1533
  function asRecord2(value) {
1199
1534
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1200
1535
  }
1201
- function readString(value) {
1536
+ function readString2(value) {
1202
1537
  if (typeof value !== "string") {
1203
1538
  return void 0;
1204
1539
  }
@@ -1235,15 +1570,15 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1235
1570
  const record = asRecord2(value);
1236
1571
  const tuple = normalizeOpinionTuple(record);
1237
1572
  const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
1238
- const triggeringEvidenceId = readString(record.triggeringEvidenceId);
1239
- const triggeringQuestionId = readString(record.triggeringQuestionId);
1240
- const triggeringAnswerId = readString(record.triggeringAnswerId);
1241
- const triggeringContradictionId = readString(
1573
+ const triggeringEvidenceId = readString2(record.triggeringEvidenceId);
1574
+ const triggeringQuestionId = readString2(record.triggeringQuestionId);
1575
+ const triggeringAnswerId = readString2(record.triggeringAnswerId);
1576
+ const triggeringContradictionId = readString2(
1242
1577
  record.triggeringContradictionId
1243
1578
  );
1244
- const triggeringWorktreeId = readString(record.triggeringWorktreeId);
1579
+ const triggeringWorktreeId = readString2(record.triggeringWorktreeId);
1245
1580
  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;
1246
- const trigger = readString(record.trigger);
1581
+ const trigger = readString2(record.trigger);
1247
1582
  if (!trigger) {
1248
1583
  throw new Error("Gateway opinion history entries must include trigger.");
1249
1584
  }
@@ -1256,9 +1591,9 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1256
1591
  P: clamp012(projected),
1257
1592
  trigger,
1258
1593
  ...triggeringRef ? { triggeringRef } : {},
1259
- ...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
1260
- ...readString(record.userId) ? { userId: readString(record.userId) } : {},
1261
- ...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
1594
+ ...readString2(record.rationale) ? { rationale: readString2(record.rationale) } : {},
1595
+ ...readString2(record.userId) ? { userId: readString2(record.userId) } : {},
1596
+ ...readString2(record.slOperator) ? { slOperator: readString2(record.slOperator) } : {}
1262
1597
  };
1263
1598
  }).sort((left, right) => left.t - right.t);
1264
1599
  }
@@ -1493,6 +1828,180 @@ function createEvidenceClient(config = {}) {
1493
1828
  }
1494
1829
  };
1495
1830
  }
1831
+
1832
+ // src/boundaryClientSurface.ts
1833
+ function cleanOptionalString(value) {
1834
+ const normalized = value?.trim();
1835
+ return normalized ? normalized : void 0;
1836
+ }
1837
+ function cleanRequiredString(value, label) {
1838
+ const normalized = cleanOptionalString(value);
1839
+ if (!normalized) {
1840
+ throw new Error(`${label} is required`);
1841
+ }
1842
+ return normalized;
1843
+ }
1844
+ function readTopicId(input) {
1845
+ return cleanOptionalString(input.topicId) ?? cleanOptionalString(input.projectId);
1846
+ }
1847
+ function requireTopicId(input) {
1848
+ const topicId = readTopicId(input);
1849
+ if (!topicId) {
1850
+ throw new Error("topicId is required");
1851
+ }
1852
+ return topicId;
1853
+ }
1854
+ function assertKnownKeys(input, allowed, operation) {
1855
+ const allowedSet = new Set(allowed);
1856
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
1857
+ if (unknownKeys.length > 0) {
1858
+ throw new Error(
1859
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
1860
+ );
1861
+ }
1862
+ }
1863
+ function knownPayload(input, allowed, operation) {
1864
+ assertKnownKeys(input, allowed, operation);
1865
+ return { ...input };
1866
+ }
1867
+ function topicPayload(input, allowed, operation) {
1868
+ assertKnownKeys(input, allowed, operation);
1869
+ return {
1870
+ ...input,
1871
+ topicId: requireTopicId(input),
1872
+ projectId: void 0
1873
+ };
1874
+ }
1875
+ function listResultFromEnvelope(data, legacyKey) {
1876
+ const record = data && typeof data === "object" ? data : {};
1877
+ return createListResult(
1878
+ Array.isArray(record[legacyKey]) ? record[legacyKey] : Array.isArray(data) ? data : [],
1879
+ legacyKey
1880
+ );
1881
+ }
1882
+
1883
+ // src/eventingClient.ts
1884
+ var EVENTING_FIELDS = [
1885
+ "tenantId",
1886
+ "workspaceId",
1887
+ "principalId",
1888
+ "topicId",
1889
+ "eventId",
1890
+ "eventType",
1891
+ "eventPayload",
1892
+ "webhookId",
1893
+ "deliveryId",
1894
+ "status",
1895
+ "attempt",
1896
+ "statusCode",
1897
+ "error",
1898
+ "responseBody",
1899
+ "durationMs",
1900
+ "metadata",
1901
+ "limit",
1902
+ "cursor"
1903
+ ];
1904
+ function query(input) {
1905
+ return {
1906
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
1907
+ workspaceId: input.workspaceId,
1908
+ principalId: input.principalId,
1909
+ topicId: input.topicId,
1910
+ eventType: input.eventType,
1911
+ webhookId: input.webhookId,
1912
+ status: input.status,
1913
+ limit: input.limit,
1914
+ cursor: input.cursor
1915
+ };
1916
+ }
1917
+ function body(input, operation) {
1918
+ return knownPayload(input, EVENTING_FIELDS, operation);
1919
+ }
1920
+ function createEventingClient(config = {}) {
1921
+ const gateway = createGatewayRequestClient(config);
1922
+ return {
1923
+ recordEvent(input, idempotencyKey) {
1924
+ cleanRequiredString(input.tenantId, "tenantId");
1925
+ cleanRequiredString(input.eventType, "eventType");
1926
+ return gateway.request({
1927
+ path: "/api/platform/v1/events",
1928
+ method: "POST",
1929
+ body: body(
1930
+ input,
1931
+ "events.recordEvent"
1932
+ ),
1933
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1934
+ });
1935
+ },
1936
+ listEvents(input) {
1937
+ return gateway.request({
1938
+ path: `/api/platform/v1/events${toQueryString(query(input))}`
1939
+ }).then(
1940
+ (response) => mapGatewayData(
1941
+ response,
1942
+ (data) => listResultFromEnvelope(data, "events")
1943
+ )
1944
+ );
1945
+ },
1946
+ listWebhooks(input) {
1947
+ return gateway.request({
1948
+ path: `/api/platform/v1/webhooks${toQueryString(query(input))}`
1949
+ }).then(
1950
+ (response) => mapGatewayData(
1951
+ response,
1952
+ (data) => listResultFromEnvelope(
1953
+ data,
1954
+ "webhooks"
1955
+ )
1956
+ )
1957
+ );
1958
+ },
1959
+ enqueueDelivery(input, idempotencyKey) {
1960
+ cleanRequiredString(input.tenantId, "tenantId");
1961
+ cleanRequiredString(input.eventId, "eventId");
1962
+ cleanRequiredString(input.webhookId, "webhookId");
1963
+ return gateway.request({
1964
+ path: "/api/platform/v1/events/deliveries",
1965
+ method: "POST",
1966
+ body: body(
1967
+ input,
1968
+ "events.enqueueDelivery"
1969
+ ),
1970
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1971
+ });
1972
+ },
1973
+ recordDeliveryAttempt(input, idempotencyKey) {
1974
+ cleanRequiredString(input.tenantId, "tenantId");
1975
+ cleanRequiredString(input.deliveryId, "deliveryId");
1976
+ return gateway.request({
1977
+ path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
1978
+ input.deliveryId
1979
+ )}/attempts`,
1980
+ method: "POST",
1981
+ body: body(
1982
+ input,
1983
+ "events.recordDeliveryAttempt"
1984
+ ),
1985
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
1986
+ });
1987
+ },
1988
+ updateDeliveryStatus(input, idempotencyKey) {
1989
+ cleanRequiredString(input.tenantId, "tenantId");
1990
+ cleanRequiredString(input.deliveryId, "deliveryId");
1991
+ return gateway.request({
1992
+ path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
1993
+ input.deliveryId
1994
+ )}/status`,
1995
+ method: "PATCH",
1996
+ body: body(
1997
+ input,
1998
+ "events.updateDeliveryStatus"
1999
+ ),
2000
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2001
+ });
2002
+ }
2003
+ };
2004
+ }
1496
2005
  var DEFAULT_CUSTOM_NAMESPACE = "custom";
1497
2006
  var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
1498
2007
  var CustomToolRegistryError = class extends Error {
@@ -1898,10 +2407,10 @@ function createGraphClient(config = {}) {
1898
2407
  /**
1899
2408
  * List graph nodes matching the provided filters.
1900
2409
  */
1901
- async listNodes(query) {
2410
+ async listNodes(query5) {
1902
2411
  return gateway.request({
1903
2412
  path: `/api/platform/v1/graph/nodes${toQueryString(
1904
- normalizeTopicQuery(query)
2413
+ normalizeTopicQuery(query5)
1905
2414
  )}`
1906
2415
  }).then(
1907
2416
  (response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
@@ -1910,15 +2419,15 @@ function createGraphClient(config = {}) {
1910
2419
  /**
1911
2420
  * @deprecated Use listNodes.
1912
2421
  */
1913
- async queryNodes(query) {
1914
- return this.listNodes(query);
2422
+ async queryNodes(query5) {
2423
+ return this.listNodes(query5);
1915
2424
  },
1916
2425
  /**
1917
2426
  * Retrieve a single graph node by nodeId or globalId.
1918
2427
  */
1919
- async getNode(query) {
2428
+ async getNode(query5) {
1920
2429
  return gateway.request({
1921
- path: `/api/platform/v1/graph/nodes${toQueryString(query)}`
2430
+ path: `/api/platform/v1/graph/nodes${toQueryString(query5)}`
1922
2431
  }).then(
1923
2432
  (response) => mapGatewayData(
1924
2433
  response,
@@ -2011,10 +2520,10 @@ function createGraphClient(config = {}) {
2011
2520
  /**
2012
2521
  * List graph edges matching the provided filters.
2013
2522
  */
2014
- async listEdges(query) {
2523
+ async listEdges(query5) {
2015
2524
  return gateway.request({
2016
2525
  path: `/api/platform/v1/graph/edges${toQueryString(
2017
- normalizeTopicQuery(query)
2526
+ normalizeTopicQuery(query5)
2018
2527
  )}`
2019
2528
  }).then(
2020
2529
  (response) => mapGatewayData(
@@ -2026,8 +2535,8 @@ function createGraphClient(config = {}) {
2026
2535
  /**
2027
2536
  * @deprecated Use listEdges.
2028
2537
  */
2029
- async queryEdges(query) {
2030
- return this.listEdges(query);
2538
+ async queryEdges(query5) {
2539
+ return this.listEdges(query5);
2031
2540
  },
2032
2541
  /**
2033
2542
  * Create a graph edge.
@@ -2043,9 +2552,9 @@ function createGraphClient(config = {}) {
2043
2552
  /**
2044
2553
  * Delete one or more edges matching the provided filter.
2045
2554
  */
2046
- async deleteEdge(query, idempotencyKey) {
2555
+ async deleteEdge(query5, idempotencyKey) {
2047
2556
  return gateway.request({
2048
- path: `/api/platform/v1/graph/edges${toQueryString(query)}`,
2557
+ path: `/api/platform/v1/graph/edges${toQueryString(query5)}`,
2049
2558
  method: "DELETE",
2050
2559
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2051
2560
  });
@@ -2053,26 +2562,26 @@ function createGraphClient(config = {}) {
2053
2562
  /**
2054
2563
  * Retrieve a graph neighborhood around a root node.
2055
2564
  */
2056
- async neighborhood(query) {
2565
+ async neighborhood(query5) {
2057
2566
  return gateway.request({
2058
- path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`
2567
+ path: `/api/platform/v1/graph/neighborhood${toQueryString(query5)}`
2059
2568
  });
2060
2569
  },
2061
2570
  /**
2062
2571
  * Traverse the graph from a starting node.
2063
2572
  */
2064
- async traverse(query) {
2573
+ async traverse(query5) {
2065
2574
  return gateway.request({
2066
2575
  path: "/api/platform/v1/graph/traverse",
2067
2576
  method: "POST",
2068
- body: normalizeTopicQuery(query)
2577
+ body: normalizeTopicQuery(query5)
2069
2578
  });
2070
2579
  },
2071
2580
  /**
2072
2581
  * Analyze graph structure for a topic.
2073
2582
  */
2074
- async analyze(query = {}) {
2075
- const normalized = normalizeTopicQuery(query);
2583
+ async analyze(query5 = {}) {
2584
+ const normalized = normalizeTopicQuery(query5);
2076
2585
  return gateway.request({
2077
2586
  path: `/api/platform/v1/graph/analyze${toQueryString({
2078
2587
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -2084,8 +2593,8 @@ function createGraphClient(config = {}) {
2084
2593
  /**
2085
2594
  * Detect confirmation-bias patterns for a topic graph.
2086
2595
  */
2087
- async bias(query = {}) {
2088
- const normalized = normalizeTopicQuery(query);
2596
+ async bias(query5 = {}) {
2597
+ const normalized = normalizeTopicQuery(query5);
2089
2598
  return gateway.request({
2090
2599
  path: `/api/platform/v1/graph/bias${toQueryString({
2091
2600
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -2097,8 +2606,8 @@ function createGraphClient(config = {}) {
2097
2606
  /**
2098
2607
  * Find graph gaps for beliefs that still need testing.
2099
2608
  */
2100
- async gaps(query) {
2101
- const normalized = normalizeTopicQuery(query);
2609
+ async gaps(query5) {
2610
+ const normalized = normalizeTopicQuery(query5);
2102
2611
  return gateway.request({
2103
2612
  path: `/api/platform/v1/graph/gaps${toQueryString({
2104
2613
  topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
@@ -2109,33 +2618,33 @@ function createGraphClient(config = {}) {
2109
2618
  /**
2110
2619
  * Search across graph resources within a topic.
2111
2620
  */
2112
- async search(query) {
2621
+ async search(query5) {
2113
2622
  return gateway.request({
2114
2623
  path: "/api/platform/v1/search",
2115
2624
  method: "POST",
2116
- body: normalizeTopicQuery(query)
2625
+ body: normalizeTopicQuery(query5)
2117
2626
  });
2118
2627
  },
2119
2628
  /**
2120
2629
  * Retrieve a graph neighborhood around a root node.
2121
2630
  */
2122
- async getNeighborhood(query) {
2123
- return this.neighborhood(query);
2631
+ async getNeighborhood(query5) {
2632
+ return this.neighborhood(query5);
2124
2633
  },
2125
2634
  /**
2126
2635
  * Retrieve the shortest known path between two graph nodes.
2127
2636
  */
2128
- async getPath(query) {
2637
+ async getPath(query5) {
2129
2638
  return gateway.request({
2130
- path: `/api/platform/v1/graph/path${toQueryString(query)}`
2639
+ path: `/api/platform/v1/graph/path${toQueryString(query5)}`
2131
2640
  });
2132
2641
  },
2133
2642
  /**
2134
2643
  * Retrieve graph analytics for the requested metric.
2135
2644
  */
2136
- async getAnalytics(query = {}) {
2645
+ async getAnalytics(query5 = {}) {
2137
2646
  return gateway.request({
2138
- path: `/api/platform/v1/graph/analytics${toQueryString(query)}`
2647
+ path: `/api/platform/v1/graph/analytics${toQueryString(query5)}`
2139
2648
  });
2140
2649
  }
2141
2650
  };
@@ -2152,6 +2661,37 @@ function createIdentityWhoamiClient(config = {}) {
2152
2661
  }
2153
2662
  };
2154
2663
  }
2664
+ var TENANT_IDENTITY_FIELDS = [
2665
+ "tenantId",
2666
+ "workspaceId",
2667
+ "principalId",
2668
+ "integrationKey",
2669
+ "secretRef",
2670
+ "policySubject",
2671
+ "policyAction",
2672
+ "policyResource",
2673
+ "decision",
2674
+ "config",
2675
+ "configKey",
2676
+ "configValue",
2677
+ "provider",
2678
+ "status",
2679
+ "metadata",
2680
+ "limit",
2681
+ "cursor"
2682
+ ];
2683
+ function tenantIdentityQuery(input) {
2684
+ return {
2685
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
2686
+ workspaceId: input.workspaceId,
2687
+ principalId: input.principalId,
2688
+ limit: input.limit,
2689
+ cursor: input.cursor
2690
+ };
2691
+ }
2692
+ function tenantIdentityBody(input, operation) {
2693
+ return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
2694
+ }
2155
2695
  function createIdentityClient(config = {}) {
2156
2696
  const gateway = createGatewayRequestClient(config);
2157
2697
  const whoamiClient = createIdentityWhoamiClient(config);
@@ -2187,9 +2727,9 @@ function createIdentityClient(config = {}) {
2187
2727
  /**
2188
2728
  * List principals in the current identity scope.
2189
2729
  */
2190
- async listPrincipals(query = {}) {
2730
+ async listPrincipals(query5 = {}) {
2191
2731
  return gateway.request({
2192
- path: `/api/platform/v1/identity/principals${toQueryString(query)}`
2732
+ path: `/api/platform/v1/identity/principals${toQueryString(query5)}`
2193
2733
  }).then(
2194
2734
  (response) => mapGatewayData(
2195
2735
  response,
@@ -2221,9 +2761,9 @@ function createIdentityClient(config = {}) {
2221
2761
  /**
2222
2762
  * List keys in the current identity scope.
2223
2763
  */
2224
- async listKeys(query = {}) {
2764
+ async listKeys(query5 = {}) {
2225
2765
  return gateway.request({
2226
- path: `/api/platform/v1/identity/keys${toQueryString(query)}`
2766
+ path: `/api/platform/v1/identity/keys${toQueryString(query5)}`
2227
2767
  }).then(
2228
2768
  (response) => mapGatewayData(
2229
2769
  response,
@@ -2277,6 +2817,109 @@ function createIdentityClient(config = {}) {
2277
2817
  return gateway.request({
2278
2818
  path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
2279
2819
  });
2820
+ },
2821
+ async getTenantConfig(input) {
2822
+ return gateway.request({
2823
+ path: `/api/platform/v1/identity/tenant-config${toQueryString(
2824
+ tenantIdentityQuery(input)
2825
+ )}`
2826
+ });
2827
+ },
2828
+ async updateTenantConfig(input, idempotencyKey) {
2829
+ cleanRequiredString(input.tenantId, "tenantId");
2830
+ return gateway.request({
2831
+ path: "/api/platform/v1/identity/tenant-config",
2832
+ method: "PATCH",
2833
+ body: tenantIdentityBody(
2834
+ input,
2835
+ "identity.updateTenantConfig"
2836
+ ),
2837
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2838
+ });
2839
+ },
2840
+ async listIntegrations(input) {
2841
+ return gateway.request({
2842
+ path: `/api/platform/v1/identity/integrations${toQueryString(
2843
+ tenantIdentityQuery(input)
2844
+ )}`
2845
+ }).then(
2846
+ (response) => mapGatewayData(
2847
+ response,
2848
+ (data) => listResultFromEnvelope(
2849
+ data,
2850
+ "integrations"
2851
+ )
2852
+ )
2853
+ );
2854
+ },
2855
+ async upsertIntegration(input, idempotencyKey) {
2856
+ cleanRequiredString(input.tenantId, "tenantId");
2857
+ cleanRequiredString(input.integrationKey, "integrationKey");
2858
+ return gateway.request({
2859
+ path: "/api/platform/v1/identity/integrations",
2860
+ method: "PUT",
2861
+ body: tenantIdentityBody(
2862
+ input,
2863
+ "identity.upsertIntegration"
2864
+ ),
2865
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2866
+ });
2867
+ },
2868
+ async listSecrets(input) {
2869
+ return gateway.request({
2870
+ path: `/api/platform/v1/identity/secrets${toQueryString(
2871
+ tenantIdentityQuery(input)
2872
+ )}`
2873
+ }).then(
2874
+ (response) => mapGatewayData(
2875
+ response,
2876
+ (data) => listResultFromEnvelope(
2877
+ data,
2878
+ "secrets"
2879
+ )
2880
+ )
2881
+ );
2882
+ },
2883
+ async putSecretReference(input, idempotencyKey) {
2884
+ cleanRequiredString(input.tenantId, "tenantId");
2885
+ cleanRequiredString(input.secretRef, "secretRef");
2886
+ return gateway.request({
2887
+ path: "/api/platform/v1/identity/secrets",
2888
+ method: "PUT",
2889
+ body: tenantIdentityBody(
2890
+ input,
2891
+ "identity.putSecretReference"
2892
+ ),
2893
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2894
+ });
2895
+ },
2896
+ async evaluatePolicy(input, idempotencyKey) {
2897
+ cleanRequiredString(input.tenantId, "tenantId");
2898
+ cleanRequiredString(input.policySubject, "policySubject");
2899
+ cleanRequiredString(input.policyAction, "policyAction");
2900
+ cleanRequiredString(input.policyResource, "policyResource");
2901
+ return gateway.request({
2902
+ path: "/api/platform/v1/identity/policy/evaluate",
2903
+ method: "POST",
2904
+ body: tenantIdentityBody(
2905
+ input,
2906
+ "identity.evaluatePolicy"
2907
+ ),
2908
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2909
+ });
2910
+ },
2911
+ async recordPolicyDecision(input, idempotencyKey) {
2912
+ cleanRequiredString(input.tenantId, "tenantId");
2913
+ cleanRequiredString(input.decision, "decision");
2914
+ return gateway.request({
2915
+ path: "/api/platform/v1/identity/policy/decisions",
2916
+ method: "POST",
2917
+ body: tenantIdentityBody(
2918
+ input,
2919
+ "identity.recordPolicyDecision"
2920
+ ),
2921
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
2922
+ });
2280
2923
  }
2281
2924
  };
2282
2925
  }
@@ -2285,12 +2928,12 @@ function createIdentityClient(config = {}) {
2285
2928
  function asRecord3(value) {
2286
2929
  return value && typeof value === "object" ? value : {};
2287
2930
  }
2288
- function cleanString2(value) {
2931
+ function cleanString3(value) {
2289
2932
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
2290
2933
  }
2291
2934
  function normalizeTopicRecord(value) {
2292
2935
  const record = asRecord3(value);
2293
- const topicId = cleanString2(record.topicId) ?? cleanString2(record.id) ?? cleanString2(record._id);
2936
+ const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
2294
2937
  return withTopicAlias({
2295
2938
  ...record,
2296
2939
  ...topicId ? { topicId } : {}
@@ -2302,15 +2945,15 @@ function normalizeTopicTreeNode(value) {
2302
2945
  function createTopicsClient(config = {}) {
2303
2946
  const gateway = createGatewayRequestClient(config);
2304
2947
  return {
2305
- async list(query = {}) {
2306
- const topicId = resolveTopicId(query);
2948
+ async list(query5 = {}) {
2949
+ const topicId = resolveTopicId(query5);
2307
2950
  return gateway.request({
2308
2951
  path: `/api/platform/v1/topics${toQueryString({
2309
2952
  ...topicId ? { topicId } : {},
2310
- ontologyId: query.ontologyId,
2311
- parentTopicId: query.parentTopicId,
2312
- status: query.status,
2313
- type: query.type
2953
+ ontologyId: query5.ontologyId,
2954
+ parentTopicId: query5.parentTopicId,
2955
+ status: query5.status,
2956
+ type: query5.type
2314
2957
  })}`
2315
2958
  }).then(
2316
2959
  (response) => mapGatewayData(response, (data) => {
@@ -2360,10 +3003,10 @@ function createTopicsClient(config = {}) {
2360
3003
  (response) => mapGatewayData(response, (data) => normalizeTopicRecord(data))
2361
3004
  );
2362
3005
  },
2363
- async getTree(topicId, query = {}) {
3006
+ async getTree(topicId, query5 = {}) {
2364
3007
  return gateway.request({
2365
3008
  path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/tree${toQueryString(
2366
- query
3009
+ query5
2367
3010
  )}`
2368
3011
  }).then(
2369
3012
  (response) => mapGatewayData(response, (data) => {
@@ -2374,10 +3017,10 @@ function createTopicsClient(config = {}) {
2374
3017
  })
2375
3018
  );
2376
3019
  },
2377
- async getCoverage(topicId, query = {}) {
3020
+ async getCoverage(topicId, query5 = {}) {
2378
3021
  return gateway.request({
2379
3022
  path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/coverage${toQueryString(
2380
- query
3023
+ query5
2381
3024
  )}`
2382
3025
  });
2383
3026
  },
@@ -2437,15 +3080,15 @@ function createBeliefsFacade(config = {}) {
2437
3080
  path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`
2438
3081
  });
2439
3082
  },
2440
- async list(query) {
3083
+ async list(query5) {
2441
3084
  return gateway.request({
2442
3085
  path: `/api/platform/v1/beliefs${toQueryString({
2443
- topicId: query.topicId,
2444
- status: query.status,
2445
- worktreeId: query.worktreeId,
2446
- minConfidence: query.minConfidence,
2447
- limit: query.limit,
2448
- cursor: query.cursor
3086
+ topicId: query5.topicId,
3087
+ status: query5.status,
3088
+ worktreeId: query5.worktreeId,
3089
+ minConfidence: query5.minConfidence,
3090
+ limit: query5.limit,
3091
+ cursor: query5.cursor
2449
3092
  })}`
2450
3093
  });
2451
3094
  },
@@ -2581,13 +3224,13 @@ function createContradictionsFacade(config = {}) {
2581
3224
  idempotencyKey
2582
3225
  });
2583
3226
  },
2584
- async list(query) {
3227
+ async list(query5) {
2585
3228
  return gateway.request({
2586
3229
  path: `/api/platform/v1/contradictions${toQueryString({
2587
- topicId: query.topicId,
2588
- status: query.status,
2589
- limit: query.limit,
2590
- cursor: query.cursor
3230
+ topicId: query5.topicId,
3231
+ status: query5.status,
3232
+ limit: query5.limit,
3233
+ cursor: query5.cursor
2591
3234
  })}`
2592
3235
  });
2593
3236
  },
@@ -2609,13 +3252,13 @@ function createEdgesFacade(config = {}) {
2609
3252
  idempotencyKey
2610
3253
  });
2611
3254
  },
2612
- async list(query) {
3255
+ async list(query5) {
2613
3256
  return gateway.request({
2614
3257
  path: `/api/platform/v1/edges${toQueryString({
2615
- sourceId: query.sourceId,
2616
- edgeType: query.edgeType,
2617
- limit: query.limit,
2618
- cursor: query.cursor
3258
+ sourceId: query5.sourceId,
3259
+ edgeType: query5.edgeType,
3260
+ limit: query5.limit,
3261
+ cursor: query5.cursor
2619
3262
  })}`
2620
3263
  });
2621
3264
  },
@@ -2685,13 +3328,13 @@ function createEvidenceFacade(config = {}) {
2685
3328
  path: `/api/platform/v1/evidence/${encodeURIComponent(id)}`
2686
3329
  });
2687
3330
  },
2688
- async list(query) {
3331
+ async list(query5) {
2689
3332
  return gateway.request({
2690
3333
  path: `/api/platform/v1/evidence${toQueryString({
2691
- topicId: query.topicId,
2692
- targetId: query.targetId,
2693
- limit: query.limit,
2694
- cursor: query.cursor
3334
+ topicId: query5.topicId,
3335
+ targetId: query5.targetId,
3336
+ limit: query5.limit,
3337
+ cursor: query5.cursor
2695
3338
  })}`
2696
3339
  });
2697
3340
  },
@@ -2708,11 +3351,11 @@ function createEvidenceFacade(config = {}) {
2708
3351
  idempotencyKey
2709
3352
  });
2710
3353
  },
2711
- async search(query, idempotencyKey = randomIdempotencyKey()) {
3354
+ async search(query5, idempotencyKey = randomIdempotencyKey()) {
2712
3355
  return gateway.request({
2713
3356
  path: "/api/platform/v1/evidence/search",
2714
3357
  method: "POST",
2715
- body: query,
3358
+ body: query5,
2716
3359
  idempotencyKey
2717
3360
  });
2718
3361
  },
@@ -2761,15 +3404,15 @@ function createEvidenceFacade(config = {}) {
2761
3404
  function createEventsFacade(config = {}) {
2762
3405
  const gateway = createGatewayRequestClient(config);
2763
3406
  return {
2764
- async list(query = {}) {
3407
+ async list(query5 = {}) {
2765
3408
  return gateway.request({
2766
3409
  path: `/api/platform/v1/events${toQueryString({
2767
- topicId: query.topicId,
2768
- after: query.after,
2769
- types: serializeTypes(query.types),
2770
- startTime: query.startTime,
2771
- endTime: query.endTime,
2772
- limit: query.limit
3410
+ topicId: query5.topicId,
3411
+ after: query5.after,
3412
+ types: serializeTypes(query5.types),
3413
+ startTime: query5.startTime,
3414
+ endTime: query5.endTime,
3415
+ limit: query5.limit
2773
3416
  })}`
2774
3417
  });
2775
3418
  },
@@ -2834,8 +3477,8 @@ function createOntologiesFacade(config = {}) {
2834
3477
  path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
2835
3478
  });
2836
3479
  },
2837
- async list(query = {}) {
2838
- return ontologyClient.list(query);
3480
+ async list(query5 = {}) {
3481
+ return ontologyClient.list(query5);
2839
3482
  },
2840
3483
  async bind(input, idempotencyKey) {
2841
3484
  return gateway.request({
@@ -2873,15 +3516,15 @@ function createQuestionsFacade(config = {}) {
2873
3516
  path: `/api/platform/v1/questions/${encodeURIComponent(id)}`
2874
3517
  });
2875
3518
  },
2876
- async list(query) {
3519
+ async list(query5) {
2877
3520
  return gateway.request({
2878
3521
  path: `/api/platform/v1/questions${toQueryString({
2879
- topicId: query.topicId,
2880
- status: query.status,
2881
- priority: query.priority,
2882
- worktreeId: query.worktreeId,
2883
- limit: query.limit,
2884
- cursor: query.cursor
3522
+ topicId: query5.topicId,
3523
+ status: query5.status,
3524
+ priority: query5.priority,
3525
+ worktreeId: query5.worktreeId,
3526
+ limit: query5.limit,
3527
+ cursor: query5.cursor
2885
3528
  })}`
2886
3529
  });
2887
3530
  },
@@ -3033,13 +3676,13 @@ function createTasksFacade(config = {}) {
3033
3676
  idempotencyKey
3034
3677
  });
3035
3678
  },
3036
- async list(query) {
3679
+ async list(query5) {
3037
3680
  return gateway.request({
3038
3681
  path: `/api/platform/v1/tasks${toQueryString({
3039
- topicId: query.topicId,
3040
- worktreeId: query.worktreeId,
3041
- status: query.status,
3042
- limit: query.limit
3682
+ topicId: query5.topicId,
3683
+ worktreeId: query5.worktreeId,
3684
+ status: query5.status,
3685
+ limit: query5.limit
3043
3686
  })}`
3044
3687
  });
3045
3688
  }
@@ -3054,8 +3697,8 @@ function createTopicsFacade(config = {}) {
3054
3697
  async get(id) {
3055
3698
  return topicsClient.get(id);
3056
3699
  },
3057
- async list(query = {}) {
3058
- return topicsClient.list(query);
3700
+ async list(query5 = {}) {
3701
+ return topicsClient.list(query5);
3059
3702
  },
3060
3703
  async update(input, idempotencyKey) {
3061
3704
  const { id, ...rest } = input;
@@ -3091,10 +3734,10 @@ function createWebhooksFacade(config = {}) {
3091
3734
  idempotencyKey
3092
3735
  });
3093
3736
  },
3094
- async list(query = {}) {
3737
+ async list(query5 = {}) {
3095
3738
  return gateway.request({
3096
3739
  path: `/api/platform/v1/webhooks${toQueryString({
3097
- topicId: query.topicId
3740
+ topicId: query5.topicId
3098
3741
  })}`
3099
3742
  });
3100
3743
  },
@@ -3126,10 +3769,10 @@ function createWebhooksFacade(config = {}) {
3126
3769
  idempotencyKey
3127
3770
  });
3128
3771
  },
3129
- async deliveries(id, query = {}) {
3772
+ async deliveries(id, query5 = {}) {
3130
3773
  return gateway.request({
3131
3774
  path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
3132
- limit: query.limit
3775
+ limit: query5.limit
3133
3776
  })}`
3134
3777
  });
3135
3778
  },
@@ -3151,24 +3794,24 @@ function createWorktreesFacade(config = {}) {
3151
3794
  idempotencyKey
3152
3795
  });
3153
3796
  },
3154
- async list(query) {
3797
+ async list(query5) {
3155
3798
  return gateway.request({
3156
3799
  path: `/api/platform/v1/worktrees${toQueryString({
3157
- topicId: query.topicId,
3158
- status: query.status,
3159
- groupBy: query.groupBy,
3160
- lane: query.lane,
3161
- campaign: query.campaign,
3162
- limit: query.limit
3800
+ topicId: query5.topicId,
3801
+ status: query5.status,
3802
+ groupBy: query5.groupBy,
3803
+ lane: query5.lane,
3804
+ campaign: query5.campaign,
3805
+ limit: query5.limit
3163
3806
  })}`
3164
3807
  });
3165
3808
  },
3166
- async listCampaigns(query = {}) {
3809
+ async listCampaigns(query5 = {}) {
3167
3810
  return gateway.request({
3168
3811
  path: `/api/platform/v1/worktrees/campaigns${toQueryString({
3169
- topicId: query.topicId,
3170
- status: query.status,
3171
- limit: query.limit
3812
+ topicId: query5.topicId,
3813
+ status: query5.status,
3814
+ limit: query5.limit
3172
3815
  })}`
3173
3816
  });
3174
3817
  },
@@ -3281,12 +3924,12 @@ function createDecisionsClient(config = {}) {
3281
3924
  /**
3282
3925
  * List judgments for a topic scope.
3283
3926
  */
3284
- async listJudgments(query) {
3927
+ async listJudgments(query5) {
3285
3928
  return gateway.request({
3286
3929
  path: `/api/platform/v1/graph/judgments${toQueryString({
3287
- ...normalizeTopicQuery(query),
3288
- includeArchived: typeof query.includeArchived === "boolean" ? query.includeArchived ? "true" : "false" : void 0,
3289
- limit: query.limit
3930
+ ...normalizeTopicQuery(query5),
3931
+ includeArchived: typeof query5.includeArchived === "boolean" ? query5.includeArchived ? "true" : "false" : void 0,
3932
+ limit: query5.limit
3290
3933
  })}`
3291
3934
  }).then(
3292
3935
  (response) => mapGatewayData(response, (data) => {
@@ -3318,30 +3961,30 @@ function createDecisionsClient(config = {}) {
3318
3961
  /**
3319
3962
  * Get readiness signals for creating a judgment.
3320
3963
  */
3321
- async getJudgmentReadiness(query) {
3964
+ async getJudgmentReadiness(query5) {
3322
3965
  return gateway.request({
3323
3966
  path: `/api/platform/v1/graph/judgments/readiness${toQueryString(
3324
- normalizeTopicQuery(query)
3967
+ normalizeTopicQuery(query5)
3325
3968
  )}`
3326
3969
  });
3327
3970
  },
3328
3971
  /**
3329
3972
  * Get calibration analytics for judgment outcomes.
3330
3973
  */
3331
- async getJudgmentCalibration(query) {
3974
+ async getJudgmentCalibration(query5) {
3332
3975
  return gateway.request({
3333
3976
  path: `/api/platform/v1/graph/judgments/calibration${toQueryString(
3334
- normalizeTopicQuery(query)
3977
+ normalizeTopicQuery(query5)
3335
3978
  )}`
3336
3979
  });
3337
3980
  },
3338
3981
  /**
3339
3982
  * List judgments still awaiting outcome review.
3340
3983
  */
3341
- async listPendingOutcomeReviews(query) {
3984
+ async listPendingOutcomeReviews(query5) {
3342
3985
  return gateway.request({
3343
3986
  path: `/api/platform/v1/graph/judgments/pending-outcome-review${toQueryString(
3344
- normalizeTopicQuery(query)
3987
+ normalizeTopicQuery(query5)
3345
3988
  )}`
3346
3989
  }).then(
3347
3990
  (response) => mapGatewayData(response, (data) => {
@@ -3358,19 +4001,19 @@ function createDecisionsClient(config = {}) {
3358
4001
  /**
3359
4002
  * @deprecated Use listPendingOutcomeReviews.
3360
4003
  */
3361
- async listPendingJudgmentOutcomeReview(query) {
3362
- return this.listPendingOutcomeReviews(query);
4004
+ async listPendingJudgmentOutcomeReview(query5) {
4005
+ return this.listPendingOutcomeReviews(query5);
3363
4006
  },
3364
4007
  /**
3365
4008
  * Get audit integrity checks for judgment transitions.
3366
4009
  */
3367
- async getJudgmentTransitionAuditIntegrity(query) {
4010
+ async getJudgmentTransitionAuditIntegrity(query5) {
3368
4011
  return gateway.request({
3369
4012
  path: `/api/platform/v1/graph/judgments/transition-audit-integrity${toQueryString(
3370
4013
  {
3371
- ...normalizeTopicQuery(query),
3372
- judgmentId: query.judgmentId,
3373
- includePassing: typeof query.includePassing === "boolean" ? query.includePassing ? "true" : "false" : void 0
4014
+ ...normalizeTopicQuery(query5),
4015
+ judgmentId: query5.judgmentId,
4016
+ includePassing: typeof query5.includePassing === "boolean" ? query5.includePassing ? "true" : "false" : void 0
3374
4017
  }
3375
4018
  )}`
3376
4019
  });
@@ -3419,56 +4062,168 @@ function createDecisionsClient(config = {}) {
3419
4062
  };
3420
4063
  }
3421
4064
 
3422
- // src/contextClient.ts
3423
- function cleanString3(value) {
3424
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
3425
- }
3426
- function cleanNumber(value) {
3427
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
4065
+ // src/embeddingsClient.ts
4066
+ var EMBEDDINGS_FIELDS = [
4067
+ "topicId",
4068
+ "projectId",
4069
+ "workspaceId",
4070
+ "nodeIds",
4071
+ "nodeType",
4072
+ "embeddingModel",
4073
+ "queryText",
4074
+ "queryVector",
4075
+ "minScore",
4076
+ "limit",
4077
+ "cursor",
4078
+ "metadata"
4079
+ ];
4080
+ function assertNodeIds(nodeIds) {
4081
+ if (!Array.isArray(nodeIds) || nodeIds.length === 0) {
4082
+ throw new Error("nodeIds is required");
4083
+ }
3428
4084
  }
3429
- function cleanBoolean(value) {
3430
- return typeof value === "boolean" ? value : void 0;
4085
+ function missingQuery(input) {
4086
+ return {
4087
+ topicId: requireTopicId(input),
4088
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId"),
4089
+ nodeType: input.nodeType,
4090
+ embeddingModel: input.embeddingModel,
4091
+ limit: input.limit,
4092
+ cursor: input.cursor
4093
+ };
3431
4094
  }
3432
- function buildCompileContextRequest(topicId, input = {}) {
3433
- const payload = { topicId };
3434
- const query = cleanString3(input.query);
3435
- if (query) {
3436
- payload.query = query;
3437
- }
3438
- const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
3439
- if (budget !== void 0) {
3440
- payload.budget = budget;
3441
- }
3442
- const ranking = cleanString3(input.ranking) ?? cleanString3(input.rankingProfile);
3443
- if (ranking) {
3444
- payload.ranking = ranking;
3445
- }
3446
- const limit = cleanNumber(input.limit);
3447
- if (limit !== void 0) {
3448
- payload.limit = limit;
3449
- }
3450
- const maxDepth = cleanNumber(input.maxDepth);
3451
- if (maxDepth !== void 0) {
3452
- payload.maxDepth = maxDepth;
3453
- }
3454
- const includeEntities = cleanBoolean(input.includeEntities);
3455
- if (includeEntities !== void 0) {
3456
- payload.includeEntities = includeEntities;
3457
- }
3458
- const mode = cleanString3(input.mode);
3459
- if (mode) {
3460
- payload.mode = mode;
3461
- }
3462
- const includeFailures = cleanBoolean(input.includeFailures);
3463
- if (includeFailures !== void 0) {
3464
- payload.includeFailures = includeFailures;
3465
- }
3466
- const worktreeId = cleanString3(input.worktreeId);
3467
- if (worktreeId) {
3468
- payload.worktreeId = worktreeId;
3469
- }
3470
- const sessionId = cleanString3(input.sessionId);
3471
- if (sessionId) {
4095
+ function createEmbeddingsClient(config = {}) {
4096
+ const gateway = createGatewayRequestClient(config);
4097
+ return {
4098
+ getByNodeIds(input) {
4099
+ assertNodeIds(input.nodeIds);
4100
+ return gateway.request({
4101
+ path: "/api/platform/v1/embeddings/by-node-ids",
4102
+ method: "POST",
4103
+ body: topicPayload(
4104
+ {
4105
+ ...input,
4106
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
4107
+ },
4108
+ EMBEDDINGS_FIELDS,
4109
+ "embeddings.getByNodeIds"
4110
+ )
4111
+ }).then(
4112
+ (response) => mapGatewayData(
4113
+ response,
4114
+ (data) => listResultFromEnvelope(
4115
+ data,
4116
+ "embeddings"
4117
+ )
4118
+ )
4119
+ );
4120
+ },
4121
+ listMissingForTopic(input) {
4122
+ return gateway.request({
4123
+ path: `/api/platform/v1/embeddings/missing${toQueryString(
4124
+ missingQuery(input)
4125
+ )}`
4126
+ }).then(
4127
+ (response) => mapGatewayData(
4128
+ response,
4129
+ (data) => listResultFromEnvelope(
4130
+ data,
4131
+ "nodes"
4132
+ )
4133
+ )
4134
+ );
4135
+ },
4136
+ vectorSearchByTopic(input) {
4137
+ if (!input.queryText && !input.queryVector) {
4138
+ throw new Error("queryText or queryVector is required");
4139
+ }
4140
+ return gateway.request({
4141
+ path: "/api/platform/v1/embeddings/vector-search",
4142
+ method: "POST",
4143
+ body: topicPayload(
4144
+ {
4145
+ ...input,
4146
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
4147
+ },
4148
+ EMBEDDINGS_FIELDS,
4149
+ "embeddings.vectorSearchByTopic"
4150
+ )
4151
+ }).then(
4152
+ (response) => mapGatewayData(
4153
+ response,
4154
+ (data) => listResultFromEnvelope(data, "results")
4155
+ )
4156
+ );
4157
+ },
4158
+ markEmbeddingBackfillQueued(input, idempotencyKey) {
4159
+ assertNodeIds(input.nodeIds);
4160
+ return gateway.request({
4161
+ path: "/api/platform/v1/embeddings/backfill-queued",
4162
+ method: "POST",
4163
+ body: topicPayload(
4164
+ {
4165
+ ...input,
4166
+ workspaceId: cleanRequiredString(input.workspaceId, "workspaceId")
4167
+ },
4168
+ EMBEDDINGS_FIELDS,
4169
+ "embeddings.markEmbeddingBackfillQueued"
4170
+ ),
4171
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4172
+ });
4173
+ }
4174
+ };
4175
+ }
4176
+
4177
+ // src/contextClient.ts
4178
+ function cleanString4(value) {
4179
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
4180
+ }
4181
+ function cleanNumber(value) {
4182
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
4183
+ }
4184
+ function cleanBoolean(value) {
4185
+ return typeof value === "boolean" ? value : void 0;
4186
+ }
4187
+ function buildCompileContextRequest(topicId, input = {}) {
4188
+ const payload = { topicId };
4189
+ const query5 = cleanString4(input.query);
4190
+ if (query5) {
4191
+ payload.query = query5;
4192
+ }
4193
+ const budget = cleanNumber(input.budget) ?? cleanNumber(input.tokenBudget);
4194
+ if (budget !== void 0) {
4195
+ payload.budget = budget;
4196
+ }
4197
+ const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
4198
+ if (ranking) {
4199
+ payload.ranking = ranking;
4200
+ }
4201
+ const limit = cleanNumber(input.limit);
4202
+ if (limit !== void 0) {
4203
+ payload.limit = limit;
4204
+ }
4205
+ const maxDepth = cleanNumber(input.maxDepth);
4206
+ if (maxDepth !== void 0) {
4207
+ payload.maxDepth = maxDepth;
4208
+ }
4209
+ const includeEntities = cleanBoolean(input.includeEntities);
4210
+ if (includeEntities !== void 0) {
4211
+ payload.includeEntities = includeEntities;
4212
+ }
4213
+ const mode = cleanString4(input.mode);
4214
+ if (mode) {
4215
+ payload.mode = mode;
4216
+ }
4217
+ const includeFailures = cleanBoolean(input.includeFailures);
4218
+ if (includeFailures !== void 0) {
4219
+ payload.includeFailures = includeFailures;
4220
+ }
4221
+ const worktreeId = cleanString4(input.worktreeId);
4222
+ if (worktreeId) {
4223
+ payload.worktreeId = worktreeId;
4224
+ }
4225
+ const sessionId = cleanString4(input.sessionId);
4226
+ if (sessionId) {
3472
4227
  payload.sessionId = sessionId;
3473
4228
  }
3474
4229
  if (Array.isArray(input.packWeightOverrides) && input.packWeightOverrides.length > 0) {
@@ -3499,6 +4254,406 @@ function createContextClient(config = {}) {
3499
4254
  };
3500
4255
  }
3501
4256
 
4257
+ // src/graphAnalysisClient.ts
4258
+ var GRAPH_ANALYSIS_ANALYSIS_FIELDS = [
4259
+ "topicId",
4260
+ "projectId",
4261
+ "workspaceId",
4262
+ "analysisType",
4263
+ "healthScore",
4264
+ "findings",
4265
+ "suggestions",
4266
+ "sourceNodeIds",
4267
+ "sourceEdgeIds",
4268
+ "detectorVersions",
4269
+ "metadata"
4270
+ ];
4271
+ var GRAPH_ANALYSIS_SUGGESTION_FIELDS = [
4272
+ "topicId",
4273
+ "projectId",
4274
+ "workspaceId",
4275
+ "analysisId",
4276
+ "suggestions",
4277
+ "metadata"
4278
+ ];
4279
+ var GRAPH_ANALYSIS_COMPUTE_FIELDS = [
4280
+ "topicId",
4281
+ "projectId",
4282
+ "workspaceId",
4283
+ "analysisType",
4284
+ "sourceNodeIds",
4285
+ "sourceEdgeIds",
4286
+ "detectorVersions",
4287
+ "metadata"
4288
+ ];
4289
+ function readTopicId2(input) {
4290
+ return input.topicId?.trim() || input.projectId?.trim() || void 0;
4291
+ }
4292
+ function requireTopicId2(input) {
4293
+ const topicId = readTopicId2(input);
4294
+ if (!topicId) {
4295
+ throw new Error("topicId is required");
4296
+ }
4297
+ return topicId;
4298
+ }
4299
+ function assertKnownKeys2(input, allowed, operation) {
4300
+ const allowedSet = new Set(allowed);
4301
+ const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
4302
+ if (unknownKeys.length > 0) {
4303
+ throw new Error(
4304
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
4305
+ );
4306
+ }
4307
+ }
4308
+ function normalizeAnalysisPayload(input) {
4309
+ assertKnownKeys2(
4310
+ input,
4311
+ GRAPH_ANALYSIS_ANALYSIS_FIELDS,
4312
+ "graphAnalysis.saveAnalysis"
4313
+ );
4314
+ return {
4315
+ ...input,
4316
+ topicId: requireTopicId2(input),
4317
+ projectId: void 0
4318
+ };
4319
+ }
4320
+ function normalizeSuggestionPayload(input) {
4321
+ assertKnownKeys2(
4322
+ input,
4323
+ GRAPH_ANALYSIS_SUGGESTION_FIELDS,
4324
+ "graphAnalysis.saveSuggestions"
4325
+ );
4326
+ return {
4327
+ ...input,
4328
+ topicId: requireTopicId2(input),
4329
+ projectId: void 0
4330
+ };
4331
+ }
4332
+ function normalizeComputePayload(input) {
4333
+ assertKnownKeys2(
4334
+ input,
4335
+ GRAPH_ANALYSIS_COMPUTE_FIELDS,
4336
+ "graphAnalysis.computeOrRequestAnalysis"
4337
+ );
4338
+ return {
4339
+ ...input,
4340
+ topicId: requireTopicId2(input),
4341
+ projectId: void 0
4342
+ };
4343
+ }
4344
+ function graphAnalysisQuery(input) {
4345
+ return {
4346
+ topicId: requireTopicId2(input),
4347
+ workspaceId: input.workspaceId,
4348
+ analysisType: input.analysisType,
4349
+ limit: input.limit,
4350
+ cursor: input.cursor
4351
+ };
4352
+ }
4353
+ function createGraphAnalysisClient(config = {}) {
4354
+ const gateway = createGatewayRequestClient(config);
4355
+ return {
4356
+ saveAnalysis(input, idempotencyKey) {
4357
+ return gateway.request({
4358
+ path: "/api/platform/v1/graph-analysis/analyses",
4359
+ method: "POST",
4360
+ body: normalizeAnalysisPayload(input),
4361
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4362
+ });
4363
+ },
4364
+ listAnalyses(input) {
4365
+ return gateway.request({
4366
+ path: `/api/platform/v1/graph-analysis/analyses${toQueryString(
4367
+ graphAnalysisQuery(input)
4368
+ )}`
4369
+ }).then(
4370
+ (response) => mapGatewayData(
4371
+ response,
4372
+ (data) => createListResult(
4373
+ Array.isArray(data.analyses) ? data.analyses : Array.isArray(data) ? data : [],
4374
+ "analyses"
4375
+ )
4376
+ )
4377
+ );
4378
+ },
4379
+ getLatestAnalysis(input) {
4380
+ return gateway.request({
4381
+ path: `/api/platform/v1/graph-analysis/analyses/latest${toQueryString({
4382
+ topicId: requireTopicId2(input),
4383
+ workspaceId: input.workspaceId,
4384
+ analysisType: input.analysisType
4385
+ })}`
4386
+ });
4387
+ },
4388
+ saveSuggestions(input, idempotencyKey) {
4389
+ return gateway.request({
4390
+ path: "/api/platform/v1/graph-analysis/suggestions",
4391
+ method: "POST",
4392
+ body: normalizeSuggestionPayload(input),
4393
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4394
+ });
4395
+ },
4396
+ updateSuggestionStatus(input, idempotencyKey) {
4397
+ return gateway.request({
4398
+ path: `/api/platform/v1/graph-analysis/suggestions/${encodeURIComponent(
4399
+ input.suggestionId
4400
+ )}`,
4401
+ method: "PATCH",
4402
+ body: {
4403
+ status: input.status,
4404
+ rationale: input.rationale,
4405
+ metadata: input.metadata
4406
+ },
4407
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4408
+ });
4409
+ },
4410
+ listSuggestions(input) {
4411
+ return gateway.request({
4412
+ path: `/api/platform/v1/graph-analysis/suggestions${toQueryString({
4413
+ topicId: requireTopicId2(input),
4414
+ workspaceId: input.workspaceId,
4415
+ analysisId: input.analysisId,
4416
+ findingId: input.findingId,
4417
+ status: input.status,
4418
+ limit: input.limit,
4419
+ cursor: input.cursor
4420
+ })}`
4421
+ }).then(
4422
+ (response) => mapGatewayData(
4423
+ response,
4424
+ (data) => createListResult(
4425
+ Array.isArray(data.suggestions) ? data.suggestions : Array.isArray(data) ? data : [],
4426
+ "suggestions"
4427
+ )
4428
+ )
4429
+ );
4430
+ },
4431
+ listGraphChanges(input) {
4432
+ return gateway.request({
4433
+ path: `/api/platform/v1/graph-analysis/changes${toQueryString({
4434
+ topicId: requireTopicId2(input),
4435
+ workspaceId: input.workspaceId,
4436
+ analysisId: input.analysisId,
4437
+ since: input.since,
4438
+ limit: input.limit,
4439
+ cursor: input.cursor
4440
+ })}`
4441
+ }).then(
4442
+ (response) => mapGatewayData(
4443
+ response,
4444
+ (data) => createListResult(
4445
+ Array.isArray(data.changes) ? data.changes : Array.isArray(data) ? data : [],
4446
+ "changes"
4447
+ )
4448
+ )
4449
+ );
4450
+ },
4451
+ computeOrRequestAnalysis(input, idempotencyKey) {
4452
+ return gateway.request({
4453
+ path: "/api/platform/v1/graph-analysis/compute",
4454
+ method: "POST",
4455
+ body: normalizeComputePayload(input),
4456
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4457
+ });
4458
+ }
4459
+ };
4460
+ }
4461
+
4462
+ // src/graphRecommendationsClient.ts
4463
+ var GRAPH_RECOMMENDATION_FIELDS = [
4464
+ "topicId",
4465
+ "projectId",
4466
+ "workspaceId",
4467
+ "limit",
4468
+ "cursor",
4469
+ "status",
4470
+ "findingId",
4471
+ "actionType",
4472
+ "targetNodeIds",
4473
+ "priority",
4474
+ "rationale",
4475
+ "healthScore",
4476
+ "metadata"
4477
+ ];
4478
+ function readTopicId3(input) {
4479
+ return input.topicId?.trim() || input.projectId?.trim() || void 0;
4480
+ }
4481
+ function requireTopicId3(input) {
4482
+ const topicId = readTopicId3(input);
4483
+ if (!topicId) {
4484
+ throw new Error("topicId is required");
4485
+ }
4486
+ return topicId;
4487
+ }
4488
+ function assertKnownKeys3(input, operation) {
4489
+ const allowed = new Set(GRAPH_RECOMMENDATION_FIELDS);
4490
+ const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
4491
+ if (unknownKeys.length > 0) {
4492
+ throw new Error(
4493
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
4494
+ );
4495
+ }
4496
+ }
4497
+ function listQuery(input) {
4498
+ assertKnownKeys3(
4499
+ input,
4500
+ "graphRecommendations.listForTopic"
4501
+ );
4502
+ return {
4503
+ workspaceId: input.workspaceId,
4504
+ topicId: requireTopicId3(input),
4505
+ limit: input.limit,
4506
+ cursor: input.cursor,
4507
+ status: input.status,
4508
+ findingId: input.findingId,
4509
+ actionType: input.actionType,
4510
+ priority: input.priority,
4511
+ targetNodeIds: input.targetNodeIds?.join(","),
4512
+ healthScore: input.healthScore
4513
+ };
4514
+ }
4515
+ function createGraphRecommendationsClient(config = {}) {
4516
+ const gateway = createGatewayRequestClient(config);
4517
+ return {
4518
+ listForTopic(input) {
4519
+ return gateway.request({
4520
+ path: `/api/platform/v1/graph-recommendations${toQueryString(
4521
+ listQuery(input)
4522
+ )}`
4523
+ }).then(
4524
+ (response) => mapGatewayData(
4525
+ response,
4526
+ (data) => createListResult(
4527
+ Array.isArray(
4528
+ data.recommendations
4529
+ ) ? data.recommendations : Array.isArray(data) ? data : [],
4530
+ "recommendations"
4531
+ )
4532
+ )
4533
+ );
4534
+ },
4535
+ getRecommendation(recommendationId) {
4536
+ return gateway.request({
4537
+ path: `/api/platform/v1/graph-recommendations/${encodeURIComponent(
4538
+ recommendationId
4539
+ )}`
4540
+ });
4541
+ },
4542
+ markRecommendationStatus(input, idempotencyKey) {
4543
+ return gateway.request({
4544
+ path: `/api/platform/v1/graph-recommendations/${encodeURIComponent(
4545
+ input.recommendationId
4546
+ )}/status`,
4547
+ method: "PATCH",
4548
+ body: {
4549
+ status: input.status,
4550
+ rationale: input.rationale,
4551
+ metadata: input.metadata
4552
+ },
4553
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4554
+ });
4555
+ }
4556
+ };
4557
+ }
4558
+
4559
+ // src/graphStateClassifierClient.ts
4560
+ var GRAPH_STATE_CLASSIFIER_FIELDS = [
4561
+ "topicId",
4562
+ "projectId",
4563
+ "workspaceId",
4564
+ "nodeId",
4565
+ "epistemicStatus",
4566
+ "beliefMaturity",
4567
+ "answerQuality",
4568
+ "evidenceNetwork",
4569
+ "logicalRole",
4570
+ "questionPriority",
4571
+ "layer",
4572
+ "modelVersion",
4573
+ "limit",
4574
+ "cursor",
4575
+ "metadata"
4576
+ ];
4577
+ function normalizeRecordPayload(input) {
4578
+ cleanRequiredString(input.workspaceId, "workspaceId");
4579
+ cleanRequiredString(input.nodeId, "nodeId");
4580
+ return topicPayload(
4581
+ input,
4582
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4583
+ "graphStateClassifier.recordClassification"
4584
+ );
4585
+ }
4586
+ function createGraphStateClassifierClient(config = {}) {
4587
+ const gateway = createGatewayRequestClient(config);
4588
+ return {
4589
+ classifyNode(input, idempotencyKey) {
4590
+ cleanRequiredString(input.workspaceId, "workspaceId");
4591
+ cleanRequiredString(input.nodeId, "nodeId");
4592
+ return gateway.request({
4593
+ path: "/api/platform/v1/graph-state-classifier/classify-node",
4594
+ method: "POST",
4595
+ body: topicPayload(
4596
+ input,
4597
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4598
+ "graphStateClassifier.classifyNode"
4599
+ ),
4600
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4601
+ });
4602
+ },
4603
+ classifyTopic(input, idempotencyKey) {
4604
+ cleanRequiredString(input.workspaceId, "workspaceId");
4605
+ return gateway.request({
4606
+ path: "/api/platform/v1/graph-state-classifier/classify-topic",
4607
+ method: "POST",
4608
+ body: topicPayload(
4609
+ input,
4610
+ GRAPH_STATE_CLASSIFIER_FIELDS,
4611
+ "graphStateClassifier.classifyTopic"
4612
+ ),
4613
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4614
+ }).then(
4615
+ (response) => mapGatewayData(
4616
+ response,
4617
+ (data) => listResultFromEnvelope(
4618
+ data,
4619
+ "classifications"
4620
+ )
4621
+ )
4622
+ );
4623
+ },
4624
+ listClassifications(input) {
4625
+ return gateway.request({
4626
+ path: `/api/platform/v1/graph-state-classifier/classifications${toQueryString({
4627
+ topicId: requireTopicId(input),
4628
+ workspaceId: input.workspaceId,
4629
+ nodeId: input.nodeId,
4630
+ modelVersion: input.modelVersion,
4631
+ layer: input.layer,
4632
+ epistemicStatus: input.epistemicStatus,
4633
+ limit: input.limit,
4634
+ cursor: input.cursor
4635
+ })}`
4636
+ }).then(
4637
+ (response) => mapGatewayData(
4638
+ response,
4639
+ (data) => listResultFromEnvelope(
4640
+ data,
4641
+ "classifications"
4642
+ )
4643
+ )
4644
+ );
4645
+ },
4646
+ recordClassification(input, idempotencyKey) {
4647
+ return gateway.request({
4648
+ path: "/api/platform/v1/graph-state-classifier/classifications",
4649
+ method: "POST",
4650
+ body: normalizeRecordPayload(input),
4651
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4652
+ });
4653
+ }
4654
+ };
4655
+ }
4656
+
3502
4657
  // src/harnessClient.ts
3503
4658
  function createHarnessClient(config = {}) {
3504
4659
  const gateway = createGatewayRequestClient(config);
@@ -3718,9 +4873,9 @@ function createHarnessClient(config = {}) {
3718
4873
  /**
3719
4874
  * List prompt resolutions.
3720
4875
  */
3721
- async listPromptResolutions(query = {}) {
4876
+ async listPromptResolutions(query5 = {}) {
3722
4877
  return gateway.request({
3723
- path: `/api/platform/v1/harness/prompts${toQueryString(query)}`
4878
+ path: `/api/platform/v1/harness/prompts${toQueryString(query5)}`
3724
4879
  }).then(
3725
4880
  (response) => mapGatewayData(
3726
4881
  response,
@@ -3739,6 +4894,128 @@ function createHarnessClient(config = {}) {
3739
4894
  };
3740
4895
  }
3741
4896
 
4897
+ // src/jobsClient.ts
4898
+ var JOBS_FIELDS = [
4899
+ "tenantId",
4900
+ "workspaceId",
4901
+ "principalId",
4902
+ "topicId",
4903
+ "worktreeId",
4904
+ "jobId",
4905
+ "jobType",
4906
+ "payload",
4907
+ "status",
4908
+ "attempt",
4909
+ "runId",
4910
+ "queue",
4911
+ "priority",
4912
+ "error",
4913
+ "metadata",
4914
+ "limit",
4915
+ "cursor"
4916
+ ];
4917
+ function query2(input) {
4918
+ return {
4919
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
4920
+ workspaceId: input.workspaceId,
4921
+ principalId: input.principalId,
4922
+ topicId: input.topicId,
4923
+ worktreeId: input.worktreeId,
4924
+ jobType: input.jobType,
4925
+ status: input.status,
4926
+ queue: input.queue,
4927
+ limit: input.limit,
4928
+ cursor: input.cursor
4929
+ };
4930
+ }
4931
+ function body2(input, operation) {
4932
+ return knownPayload(input, JOBS_FIELDS, operation);
4933
+ }
4934
+ function createJobsClient(config = {}) {
4935
+ const gateway = createGatewayRequestClient(config);
4936
+ return {
4937
+ enqueue(input, idempotencyKey) {
4938
+ cleanRequiredString(input.tenantId, "tenantId");
4939
+ cleanRequiredString(input.jobType, "jobType");
4940
+ return gateway.request({
4941
+ path: "/api/platform/v1/jobs",
4942
+ method: "POST",
4943
+ body: body2(input, "jobs.enqueue"),
4944
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4945
+ });
4946
+ },
4947
+ list(input) {
4948
+ return gateway.request({
4949
+ path: `/api/platform/v1/jobs${toQueryString(query2(input))}`
4950
+ }).then(
4951
+ (response) => mapGatewayData(
4952
+ response,
4953
+ (data) => listResultFromEnvelope(data, "jobs")
4954
+ )
4955
+ );
4956
+ },
4957
+ claim(input, idempotencyKey) {
4958
+ cleanRequiredString(input.tenantId, "tenantId");
4959
+ return gateway.request({
4960
+ path: "/api/platform/v1/jobs/claim",
4961
+ method: "POST",
4962
+ body: body2(input, "jobs.claim"),
4963
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4964
+ });
4965
+ },
4966
+ updateStatus(input, idempotencyKey) {
4967
+ cleanRequiredString(input.tenantId, "tenantId");
4968
+ cleanRequiredString(input.jobId, "jobId");
4969
+ return gateway.request({
4970
+ path: `/api/platform/v1/jobs/${encodeURIComponent(input.jobId)}/status`,
4971
+ method: "PATCH",
4972
+ body: body2(
4973
+ input,
4974
+ "jobs.updateStatus"
4975
+ ),
4976
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4977
+ });
4978
+ },
4979
+ retry(input, idempotencyKey) {
4980
+ cleanRequiredString(input.tenantId, "tenantId");
4981
+ cleanRequiredString(input.jobId, "jobId");
4982
+ return gateway.request({
4983
+ path: `/api/platform/v1/jobs/${encodeURIComponent(input.jobId)}/retry`,
4984
+ method: "POST",
4985
+ body: body2(input, "jobs.retry"),
4986
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4987
+ });
4988
+ },
4989
+ recordRunStart(input, idempotencyKey) {
4990
+ cleanRequiredString(input.tenantId, "tenantId");
4991
+ return gateway.request({
4992
+ path: "/api/platform/v1/jobs/runs/start",
4993
+ method: "POST",
4994
+ body: body2(
4995
+ input,
4996
+ "jobs.recordRunStart"
4997
+ ),
4998
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
4999
+ });
5000
+ },
5001
+ recordRunFinish(input, idempotencyKey) {
5002
+ cleanRequiredString(input.tenantId, "tenantId");
5003
+ cleanRequiredString(input.runId, "runId");
5004
+ return gateway.request({
5005
+ path: `/api/platform/v1/jobs/runs/${encodeURIComponent(
5006
+ input.runId
5007
+ )}/finish`,
5008
+ method: "POST",
5009
+ body: body2(
5010
+ input,
5011
+ "jobs.recordRunFinish"
5012
+ ),
5013
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5014
+ });
5015
+ }
5016
+ };
5017
+ }
5018
+
3742
5019
  // src/learningClient.ts
3743
5020
  function createLearningClient(config = {}) {
3744
5021
  const gateway = createGatewayRequestClient(config);
@@ -3783,6 +5060,122 @@ function createLearningClient(config = {}) {
3783
5060
  }
3784
5061
  };
3785
5062
  }
5063
+ function toJsonValue(value) {
5064
+ if (value === void 0) {
5065
+ return void 0;
5066
+ }
5067
+ const seen = /* @__PURE__ */ new WeakSet();
5068
+ const json = JSON.stringify(value, (_key, candidate) => {
5069
+ if (typeof candidate === "bigint") {
5070
+ return candidate.toString();
5071
+ }
5072
+ if (typeof candidate === "function" || typeof candidate === "symbol" || typeof candidate === "undefined") {
5073
+ return void 0;
5074
+ }
5075
+ if (candidate && typeof candidate === "object") {
5076
+ if (seen.has(candidate)) {
5077
+ return "[Circular]";
5078
+ }
5079
+ seen.add(candidate);
5080
+ }
5081
+ return candidate;
5082
+ });
5083
+ if (json === void 0) {
5084
+ return void 0;
5085
+ }
5086
+ return JSON.parse(json);
5087
+ }
5088
+ function createMcpClient(config = {}) {
5089
+ const gateway = createGatewayRequestClient(config);
5090
+ return {
5091
+ bootstrapSession(input = {}) {
5092
+ const scope = {
5093
+ tenantId: input.tenantId,
5094
+ workspaceId: input.workspaceId
5095
+ };
5096
+ const body4 = {
5097
+ transportKind: input.transportKind,
5098
+ sessionId: input.sessionId,
5099
+ agentIdentity: input.agentIdentity,
5100
+ workspaceId: input.workspaceId
5101
+ };
5102
+ return gateway.request({
5103
+ path: `${MCP_GATEWAY_BOOTSTRAP_ENDPOINT}${toQueryString(scope)}`,
5104
+ method: "POST",
5105
+ body: body4
5106
+ });
5107
+ },
5108
+ checkWritePolicy(input) {
5109
+ const scope = {
5110
+ tenantId: input.tenantId,
5111
+ workspaceId: input.workspaceId
5112
+ };
5113
+ return gateway.request({
5114
+ path: `${MCP_GATEWAY_WRITE_POLICY_CHECK_ENDPOINT}${toQueryString(scope)}`,
5115
+ method: "POST",
5116
+ body: {
5117
+ topicId: input.topicId,
5118
+ role: input.role,
5119
+ toolName: input.toolName
5120
+ }
5121
+ });
5122
+ },
5123
+ beginBuildSession(input) {
5124
+ const scope = {
5125
+ tenantId: input.tenantId,
5126
+ workspaceId: input.workspaceId
5127
+ };
5128
+ return gateway.request({
5129
+ path: `${MCP_GATEWAY_BEGIN_BUILD_SESSION_ENDPOINT}${toQueryString(scope)}`,
5130
+ method: "POST",
5131
+ body: {
5132
+ worktreeId: input.worktreeId,
5133
+ branch: input.branch,
5134
+ branchBase: input.branchBase,
5135
+ prBase: input.prBase,
5136
+ sessionMode: input.sessionMode,
5137
+ activateIfPlanning: input.activateIfPlanning
5138
+ }
5139
+ });
5140
+ },
5141
+ evaluateEngineeringContract(input) {
5142
+ const scope = {
5143
+ tenantId: input.tenantId,
5144
+ workspaceId: input.workspaceId
5145
+ };
5146
+ return gateway.request({
5147
+ path: `${MCP_GATEWAY_EVALUATE_ENGINEERING_CONTRACT_ENDPOINT}${toQueryString(scope)}`,
5148
+ method: "POST",
5149
+ body: {
5150
+ beliefNodeId: toJsonValue(input.beliefNodeId),
5151
+ trigger: toJsonValue(input.trigger),
5152
+ testOutput: toJsonValue(input.testOutput),
5153
+ tscOutput: toJsonValue(input.tscOutput),
5154
+ lintOutput: toJsonValue(input.lintOutput),
5155
+ sentryData: toJsonValue(input.sentryData)
5156
+ }
5157
+ });
5158
+ },
5159
+ evaluateResearchContract(input) {
5160
+ const scope = {
5161
+ tenantId: input.tenantId,
5162
+ workspaceId: input.workspaceId
5163
+ };
5164
+ return gateway.request({
5165
+ path: `${MCP_GATEWAY_EVALUATE_RESEARCH_CONTRACT_ENDPOINT}${toQueryString(scope)}`,
5166
+ method: "POST",
5167
+ body: {
5168
+ beliefNodeId: toJsonValue(input.beliefNodeId),
5169
+ trigger: toJsonValue(input.trigger),
5170
+ metricData: toJsonValue(input.metricData),
5171
+ referenceCheckData: toJsonValue(input.referenceCheckData),
5172
+ marketIndexData: toJsonValue(input.marketIndexData),
5173
+ temporalData: toJsonValue(input.temporalData)
5174
+ }
5175
+ });
5176
+ }
5177
+ };
5178
+ }
3786
5179
 
3787
5180
  // src/generated/functionSurface.ts
3788
5181
  var FUNCTION_SURFACE_METHOD_PATHS = [
@@ -4349,29 +5742,327 @@ function createFunctionSurfaceClient(config = {}) {
4349
5742
  traceEntityImpact(input = {}, idempotencyKey) {
4350
5743
  return execute("trace_entity_impact", input, idempotencyKey);
4351
5744
  },
4352
- traverseGraph(input = {}, idempotencyKey) {
4353
- return execute("traverse_graph", input, idempotencyKey);
5745
+ traverseGraph(input = {}, idempotencyKey) {
5746
+ return execute("traverse_graph", input, idempotencyKey);
5747
+ },
5748
+ triggerBeliefReview(input = {}, idempotencyKey) {
5749
+ return execute("trigger_belief_review", input, idempotencyKey);
5750
+ },
5751
+ updateOntology(input = {}, idempotencyKey) {
5752
+ return execute("update_ontology", input, idempotencyKey);
5753
+ },
5754
+ updateQuestionStatus(input = {}, idempotencyKey) {
5755
+ return execute("update_question_status", input, idempotencyKey);
5756
+ },
5757
+ updateTask(input = {}, idempotencyKey) {
5758
+ return execute("update_task", input, idempotencyKey);
5759
+ },
5760
+ updateTopic(input = {}, idempotencyKey) {
5761
+ return execute("update_topic", input, idempotencyKey);
5762
+ },
5763
+ updateWorktreeMetadata(input = {}, idempotencyKey) {
5764
+ return execute("update_worktree_metadata", input, idempotencyKey);
5765
+ },
5766
+ updateWorktreeTargets(input = {}, idempotencyKey) {
5767
+ return execute("update_worktree_targets", input, idempotencyKey);
5768
+ }
5769
+ };
5770
+ }
5771
+
5772
+ // src/modelRuntimeClient.ts
5773
+ var MODEL_RUNTIME_FIELDS = [
5774
+ "tenantId",
5775
+ "workspaceId",
5776
+ "principalId",
5777
+ "functionName",
5778
+ "slotKey",
5779
+ "modelId",
5780
+ "provider",
5781
+ "routingPolicy",
5782
+ "metadata",
5783
+ "limit",
5784
+ "cursor"
5785
+ ];
5786
+ function scopeQuery(input) {
5787
+ return {
5788
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
5789
+ workspaceId: input.workspaceId,
5790
+ principalId: input.principalId,
5791
+ provider: input.provider,
5792
+ limit: input.limit,
5793
+ cursor: input.cursor
5794
+ };
5795
+ }
5796
+ function modelRuntimeBody(input, operation) {
5797
+ return knownPayload(input, MODEL_RUNTIME_FIELDS, operation);
5798
+ }
5799
+ function createModelRuntimeClient(config = {}) {
5800
+ const gateway = createGatewayRequestClient(config);
5801
+ return {
5802
+ listModels(input) {
5803
+ return gateway.request({
5804
+ path: `/api/platform/v1/model-runtime/models${toQueryString(
5805
+ scopeQuery(input)
5806
+ )}`
5807
+ }).then(
5808
+ (response) => mapGatewayData(
5809
+ response,
5810
+ (data) => listResultFromEnvelope(data, "models")
5811
+ )
5812
+ );
5813
+ },
5814
+ getModel(input) {
5815
+ cleanRequiredString(input.tenantId, "tenantId");
5816
+ cleanRequiredString(input.modelId, "modelId");
5817
+ return gateway.request({
5818
+ path: `/api/platform/v1/model-runtime/models/${encodeURIComponent(
5819
+ input.modelId
5820
+ )}${toQueryString({
5821
+ tenantId: input.tenantId,
5822
+ workspaceId: input.workspaceId,
5823
+ principalId: input.principalId
5824
+ })}`
5825
+ });
5826
+ },
5827
+ listFunctionSlots(input) {
5828
+ return gateway.request({
5829
+ path: `/api/platform/v1/model-runtime/function-slots${toQueryString({
5830
+ ...scopeQuery(input),
5831
+ functionName: input.functionName
5832
+ })}`
5833
+ }).then(
5834
+ (response) => mapGatewayData(
5835
+ response,
5836
+ (data) => listResultFromEnvelope(data, "slots")
5837
+ )
5838
+ );
5839
+ },
5840
+ resolveSlot(input, idempotencyKey) {
5841
+ cleanRequiredString(input.tenantId, "tenantId");
5842
+ cleanRequiredString(input.functionName, "functionName");
5843
+ return gateway.request({
5844
+ path: "/api/platform/v1/model-runtime/function-slots/resolve",
5845
+ method: "POST",
5846
+ body: modelRuntimeBody(
5847
+ input,
5848
+ "modelRuntime.resolveSlot"
5849
+ ),
5850
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5851
+ });
4354
5852
  },
4355
- triggerBeliefReview(input = {}, idempotencyKey) {
4356
- return execute("trigger_belief_review", input, idempotencyKey);
5853
+ updateSlotConfig(input, idempotencyKey) {
5854
+ cleanRequiredString(input.tenantId, "tenantId");
5855
+ cleanRequiredString(input.functionName, "functionName");
5856
+ cleanRequiredString(input.slotKey, "slotKey");
5857
+ cleanRequiredString(input.modelId, "modelId");
5858
+ return gateway.request({
5859
+ path: "/api/platform/v1/model-runtime/slot-configs",
5860
+ method: "PUT",
5861
+ body: modelRuntimeBody(
5862
+ input,
5863
+ "modelRuntime.updateSlotConfig"
5864
+ ),
5865
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5866
+ });
5867
+ }
5868
+ };
5869
+ }
5870
+
5871
+ // src/ontologyLinksClient.ts
5872
+ var ONTOLOGY_LINK_FIELDS = [
5873
+ "topicId",
5874
+ "workspaceId",
5875
+ "linkId",
5876
+ "sourceNodeId",
5877
+ "sourceGlobalId",
5878
+ "targetNodeId",
5879
+ "targetGlobalId",
5880
+ "ontologyId",
5881
+ "ontologyType",
5882
+ "edgeType",
5883
+ "weight",
5884
+ "confidence",
5885
+ "status",
5886
+ "metadata"
5887
+ ];
5888
+ function assertEndpoints(input) {
5889
+ if (!input.sourceNodeId && !input.sourceGlobalId) {
5890
+ throw new Error("sourceNodeId or sourceGlobalId is required");
5891
+ }
5892
+ if (!input.targetNodeId && !input.targetGlobalId) {
5893
+ throw new Error("targetNodeId or targetGlobalId is required");
5894
+ }
5895
+ }
5896
+ function normalizeLinkPayload(input, operation) {
5897
+ assertEndpoints(input);
5898
+ cleanRequiredString(input.ontologyId, "ontologyId");
5899
+ cleanRequiredString(input.edgeType, "edgeType");
5900
+ return knownPayload(input, ONTOLOGY_LINK_FIELDS, operation);
5901
+ }
5902
+ function createOntologyLinksClient(config = {}) {
5903
+ const gateway = createGatewayRequestClient(config);
5904
+ return {
5905
+ createLink(input, idempotencyKey) {
5906
+ return gateway.request({
5907
+ path: "/api/platform/v1/ontology-links",
5908
+ method: "POST",
5909
+ body: normalizeLinkPayload(input, "ontologyLinks.createLink"),
5910
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5911
+ });
4357
5912
  },
4358
- updateOntology(input = {}, idempotencyKey) {
4359
- return execute("update_ontology", input, idempotencyKey);
5913
+ upsertLink(input, idempotencyKey) {
5914
+ return gateway.request({
5915
+ path: "/api/platform/v1/ontology-links",
5916
+ method: "PUT",
5917
+ body: normalizeLinkPayload(input, "ontologyLinks.upsertLink"),
5918
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5919
+ });
4360
5920
  },
4361
- updateQuestionStatus(input = {}, idempotencyKey) {
4362
- return execute("update_question_status", input, idempotencyKey);
5921
+ listLinksForNode(input) {
5922
+ const nodeId = cleanOptionalString(input.nodeId);
5923
+ const globalId = cleanOptionalString(input.globalId);
5924
+ if (!nodeId && !globalId) {
5925
+ throw new Error("nodeId or globalId is required");
5926
+ }
5927
+ const pathId = encodeURIComponent(nodeId ?? globalId ?? "");
5928
+ return gateway.request({
5929
+ path: `/api/platform/v1/ontology-links/nodes/${pathId}${toQueryString({
5930
+ topicId: input.topicId,
5931
+ workspaceId: input.workspaceId,
5932
+ globalId: nodeId ? void 0 : globalId,
5933
+ ontologyId: input.ontologyId,
5934
+ ontologyType: input.ontologyType,
5935
+ edgeType: input.edgeType,
5936
+ status: input.status,
5937
+ limit: input.limit,
5938
+ cursor: input.cursor
5939
+ })}`
5940
+ }).then(
5941
+ (response) => mapGatewayData(
5942
+ response,
5943
+ (data) => listResultFromEnvelope(data, "links")
5944
+ )
5945
+ );
4363
5946
  },
4364
- updateTask(input = {}, idempotencyKey) {
4365
- return execute("update_task", input, idempotencyKey);
5947
+ updateLinkStatus(input, idempotencyKey) {
5948
+ return gateway.request({
5949
+ path: `/api/platform/v1/ontology-links/${encodeURIComponent(
5950
+ input.linkId
5951
+ )}/status`,
5952
+ method: "PATCH",
5953
+ body: knownPayload(
5954
+ input,
5955
+ ONTOLOGY_LINK_FIELDS,
5956
+ "ontologyLinks.updateLinkStatus"
5957
+ ),
5958
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5959
+ });
5960
+ }
5961
+ };
5962
+ }
5963
+
5964
+ // src/orgGraphSearchClient.ts
5965
+ var ORG_GRAPH_SEARCH_FIELDS = [
5966
+ "tenantId",
5967
+ "workspaceId",
5968
+ "query",
5969
+ "nodeTypes",
5970
+ "minConfidence",
5971
+ "limit",
5972
+ "cursor",
5973
+ "provenanceScope"
5974
+ ];
5975
+ function cleanString5(value, label) {
5976
+ const normalized = value?.trim();
5977
+ if (!normalized) {
5978
+ throw new Error(`${label} is required`);
5979
+ }
5980
+ return normalized;
5981
+ }
5982
+ function assertKnownSearchKeys(input, operation) {
5983
+ const allowed = new Set(ORG_GRAPH_SEARCH_FIELDS);
5984
+ const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
5985
+ if (unknownKeys.length > 0) {
5986
+ throw new Error(
5987
+ `${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
5988
+ );
5989
+ }
5990
+ }
5991
+ function searchBody(input) {
5992
+ assertKnownSearchKeys(
5993
+ input,
5994
+ "orgGraphSearch.search"
5995
+ );
5996
+ return {
5997
+ tenantId: cleanString5(input.tenantId, "tenantId"),
5998
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
5999
+ query: cleanString5(input.query, "query"),
6000
+ nodeTypes: input.nodeTypes,
6001
+ minConfidence: input.minConfidence,
6002
+ limit: input.limit,
6003
+ cursor: input.cursor,
6004
+ provenanceScope: input.provenanceScope
6005
+ };
6006
+ }
6007
+ function listQuery2(input) {
6008
+ return {
6009
+ tenantId: cleanString5(input.tenantId, "tenantId"),
6010
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
6011
+ nodeTypes: input.nodeTypes?.join(","),
6012
+ minConfidence: input.minConfidence,
6013
+ limit: input.limit,
6014
+ cursor: input.cursor
6015
+ };
6016
+ }
6017
+ function mapResults(data) {
6018
+ const record = data && typeof data === "object" ? data : {};
6019
+ return createListResult(
6020
+ Array.isArray(record.results) ? record.results : Array.isArray(data) ? data : [],
6021
+ "results"
6022
+ );
6023
+ }
6024
+ function createOrgGraphSearchClient(config = {}) {
6025
+ const gateway = createGatewayRequestClient(config);
6026
+ return {
6027
+ search(input) {
6028
+ return gateway.request({
6029
+ path: "/api/platform/v1/org-graph-search/search",
6030
+ method: "POST",
6031
+ body: searchBody(input)
6032
+ }).then((response) => mapGatewayData(response, mapResults));
4366
6033
  },
4367
- updateTopic(input = {}, idempotencyKey) {
4368
- return execute("update_topic", input, idempotencyKey);
6034
+ getNode(input) {
6035
+ const nodeId = input.nodeId?.trim();
6036
+ const globalId = input.globalId?.trim();
6037
+ if (!nodeId && !globalId) {
6038
+ throw new Error("nodeId or globalId is required");
6039
+ }
6040
+ const nodePath = encodeURIComponent(nodeId ?? globalId ?? "");
6041
+ return gateway.request({
6042
+ path: `/api/platform/v1/org-graph-search/nodes/${nodePath}${toQueryString(
6043
+ {
6044
+ tenantId: cleanString5(input.tenantId, "tenantId"),
6045
+ workspaceId: cleanString5(input.workspaceId, "workspaceId"),
6046
+ globalId: nodeId ? void 0 : globalId
6047
+ }
6048
+ )}`
6049
+ });
4369
6050
  },
4370
- updateWorktreeMetadata(input = {}, idempotencyKey) {
4371
- return execute("update_worktree_metadata", input, idempotencyKey);
6051
+ listByProvenance(input) {
6052
+ return gateway.request({
6053
+ path: `/api/platform/v1/org-graph-search/provenance${toQueryString({
6054
+ ...listQuery2(input),
6055
+ provenanceScope: input.provenanceScope
6056
+ })}`
6057
+ }).then((response) => mapGatewayData(response, mapResults));
4372
6058
  },
4373
- updateWorktreeTargets(input = {}, idempotencyKey) {
4374
- return execute("update_worktree_targets", input, idempotencyKey);
6059
+ listPublishedFromWorkspace(input) {
6060
+ return gateway.request({
6061
+ path: `/api/platform/v1/org-graph-search/published${toQueryString({
6062
+ ...listQuery2(input),
6063
+ sourceWorkspaceId: input.sourceWorkspaceId
6064
+ })}`
6065
+ }).then((response) => mapGatewayData(response, mapResults));
4375
6066
  }
4376
6067
  };
4377
6068
  }
@@ -4418,9 +6109,9 @@ function createPacksClient(config = {}) {
4418
6109
  /**
4419
6110
  * List pack states for the current scope.
4420
6111
  */
4421
- async listStates(query = {}) {
6112
+ async listStates(query5 = {}) {
4422
6113
  return gateway.request({
4423
- path: `/api/platform/v1/packs/states${toQueryString(query)}`
6114
+ path: `/api/platform/v1/packs/states${toQueryString(query5)}`
4424
6115
  }).then(
4425
6116
  (response) => mapGatewayData(
4426
6117
  response,
@@ -4431,25 +6122,25 @@ function createPacksClient(config = {}) {
4431
6122
  /**
4432
6123
  * @deprecated Use listStates.
4433
6124
  */
4434
- async getStates(query = {}) {
4435
- return this.listStates(query);
6125
+ async getStates(query5 = {}) {
6126
+ return this.listStates(query5);
4436
6127
  },
4437
6128
  /**
4438
6129
  * Get health details for a pack.
4439
6130
  */
4440
- async getHealth(packKey, query = {}) {
6131
+ async getHealth(packKey, query5 = {}) {
4441
6132
  return gateway.request({
4442
6133
  path: `/api/platform/v1/packs/${encodeURIComponent(packKey)}/health${toQueryString(
4443
- query
6134
+ query5
4444
6135
  )}`
4445
6136
  });
4446
6137
  },
4447
6138
  /**
4448
6139
  * List pack telemetry entries.
4449
6140
  */
4450
- async listTelemetry(query = {}) {
6141
+ async listTelemetry(query5 = {}) {
4451
6142
  return gateway.request({
4452
- path: `/api/platform/v1/packs/telemetry${toQueryString(query)}`
6143
+ path: `/api/platform/v1/packs/telemetry${toQueryString(query5)}`
4453
6144
  }).then(
4454
6145
  (response) => mapGatewayData(
4455
6146
  response,
@@ -4460,8 +6151,8 @@ function createPacksClient(config = {}) {
4460
6151
  /**
4461
6152
  * @deprecated Use listTelemetry.
4462
6153
  */
4463
- async getTelemetry(query = {}) {
4464
- return this.listTelemetry(query);
6154
+ async getTelemetry(query5 = {}) {
6155
+ return this.listTelemetry(query5);
4465
6156
  },
4466
6157
  /**
4467
6158
  * Create a pack entitlement.
@@ -4583,9 +6274,9 @@ function createPolicyClient(config = {}) {
4583
6274
  /**
4584
6275
  * List policy decisions in the current scope.
4585
6276
  */
4586
- async listDecisions(query = {}) {
6277
+ async listDecisions(query5 = {}) {
4587
6278
  return gateway.request({
4588
- path: `/api/platform/v1/policy/decisions${toQueryString(query)}`
6279
+ path: `/api/platform/v1/policy/decisions${toQueryString(query5)}`
4589
6280
  }).then(
4590
6281
  (response) => mapGatewayData(
4591
6282
  response,
@@ -4618,9 +6309,9 @@ function createPolicyClient(config = {}) {
4618
6309
  /**
4619
6310
  * List write policy rules for the current scope.
4620
6311
  */
4621
- async listWritePolicies(query = {}) {
6312
+ async listWritePolicies(query5 = {}) {
4622
6313
  const response = await gateway.request({
4623
- path: `/api/platform/v1/policy/write-policies${toQueryString(query)}`
6314
+ path: `/api/platform/v1/policy/write-policies${toQueryString(query5)}`
4624
6315
  });
4625
6316
  const rawPolicies = response.data && typeof response.data === "object" ? response.data.policies : response.data;
4626
6317
  return {
@@ -4683,9 +6374,9 @@ function createPolicyClient(config = {}) {
4683
6374
  /**
4684
6375
  * List tenant role policies for the current scope.
4685
6376
  */
4686
- async listRolePolicies(query = {}) {
6377
+ async listRolePolicies(query5 = {}) {
4687
6378
  const response = await gateway.request({
4688
- path: `/api/platform/v1/policy/roles${toQueryString(query)}`
6379
+ path: `/api/platform/v1/policy/roles${toQueryString(query5)}`
4689
6380
  });
4690
6381
  return {
4691
6382
  ...response,
@@ -4743,28 +6434,28 @@ function createPolicyClient(config = {}) {
4743
6434
  /**
4744
6435
  * Check a permission decision for a topic or project scope.
4745
6436
  */
4746
- async checkPermission(query) {
4747
- if (!query.topicId) {
6437
+ async checkPermission(query5) {
6438
+ if (!query5.topicId) {
4748
6439
  throw new Error("topicId is required");
4749
6440
  }
4750
6441
  return gateway.request({
4751
- path: `/api/platform/v1/policy/check${toQueryString(query)}`
6442
+ path: `/api/platform/v1/policy/check${toQueryString(query5)}`
4752
6443
  });
4753
6444
  },
4754
6445
  /**
4755
6446
  * List accessible topics for a principal.
4756
6447
  */
4757
- async listAccessibleTopics(query = {}) {
4758
- const permission = query.permission ?? "read";
4759
- const principal = query.principal ?? query.principalId;
6448
+ async listAccessibleTopics(query5 = {}) {
6449
+ const permission = query5.permission ?? "read";
6450
+ const principal = query5.principal ?? query5.principalId;
4760
6451
  const response = await gateway.request({
4761
6452
  path: `/api/platform/v1/policy/topics${toQueryString({
4762
- tenantId: query.tenantId,
4763
- workspaceId: query.workspaceId,
6453
+ tenantId: query5.tenantId,
6454
+ workspaceId: query5.workspaceId,
4764
6455
  permission,
4765
- includeShared: query.includeShared,
6456
+ includeShared: query5.includeShared,
4766
6457
  principal,
4767
- limit: query.limit
6458
+ limit: query5.limit
4768
6459
  })}`
4769
6460
  });
4770
6461
  return {
@@ -4947,6 +6638,294 @@ function createSchemaClient(config = {}) {
4947
6638
  };
4948
6639
  }
4949
6640
 
6641
+ // src/telemetryClient.ts
6642
+ var TELEMETRY_FIELDS = [
6643
+ "tenantId",
6644
+ "workspaceId",
6645
+ "principalId",
6646
+ "topicId",
6647
+ "worktreeId",
6648
+ "eventLevel",
6649
+ "eventType",
6650
+ "message",
6651
+ "toolName",
6652
+ "toolCalls",
6653
+ "decision",
6654
+ "policySubject",
6655
+ "policyAction",
6656
+ "policyResource",
6657
+ "runId",
6658
+ "runType",
6659
+ "status",
6660
+ "durationMs",
6661
+ "error",
6662
+ "metadata",
6663
+ "limit",
6664
+ "cursor"
6665
+ ];
6666
+ function query3(input) {
6667
+ return {
6668
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
6669
+ workspaceId: input.workspaceId,
6670
+ principalId: input.principalId,
6671
+ topicId: input.topicId,
6672
+ worktreeId: input.worktreeId,
6673
+ runType: input.runType,
6674
+ status: input.status,
6675
+ limit: input.limit,
6676
+ cursor: input.cursor
6677
+ };
6678
+ }
6679
+ function body3(input, operation) {
6680
+ return knownPayload(input, TELEMETRY_FIELDS, operation);
6681
+ }
6682
+ function createTelemetryClient(config = {}) {
6683
+ const gateway = createGatewayRequestClient(config);
6684
+ return {
6685
+ logSystemEvent(input, idempotencyKey) {
6686
+ cleanRequiredString(input.tenantId, "tenantId");
6687
+ cleanRequiredString(input.eventType, "eventType");
6688
+ cleanRequiredString(input.message, "message");
6689
+ return gateway.request({
6690
+ path: "/api/platform/v1/telemetry/system-events",
6691
+ method: "POST",
6692
+ body: body3(
6693
+ input,
6694
+ "telemetry.logSystemEvent"
6695
+ ),
6696
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6697
+ });
6698
+ },
6699
+ logToolCallsBatch(input, idempotencyKey) {
6700
+ cleanRequiredString(input.tenantId, "tenantId");
6701
+ return gateway.request({
6702
+ path: "/api/platform/v1/telemetry/tool-calls/batch",
6703
+ method: "POST",
6704
+ body: body3(
6705
+ input,
6706
+ "telemetry.logToolCallsBatch"
6707
+ ),
6708
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6709
+ });
6710
+ },
6711
+ recordEpistemicAudit(input, idempotencyKey) {
6712
+ cleanRequiredString(input.tenantId, "tenantId");
6713
+ cleanRequiredString(input.eventType, "eventType");
6714
+ return gateway.request({
6715
+ path: "/api/platform/v1/telemetry/epistemic-audits",
6716
+ method: "POST",
6717
+ body: body3(
6718
+ input,
6719
+ "telemetry.recordEpistemicAudit"
6720
+ ),
6721
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6722
+ });
6723
+ },
6724
+ recordPolicyDecision(input, idempotencyKey) {
6725
+ cleanRequiredString(input.tenantId, "tenantId");
6726
+ cleanRequiredString(input.decision, "decision");
6727
+ return gateway.request({
6728
+ path: "/api/platform/v1/telemetry/policy-decisions",
6729
+ method: "POST",
6730
+ body: body3(
6731
+ input,
6732
+ "telemetry.recordPolicyDecision"
6733
+ ),
6734
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6735
+ });
6736
+ },
6737
+ startRun(input, idempotencyKey) {
6738
+ cleanRequiredString(input.tenantId, "tenantId");
6739
+ cleanRequiredString(input.runType, "runType");
6740
+ return gateway.request({
6741
+ path: "/api/platform/v1/telemetry/runs/start",
6742
+ method: "POST",
6743
+ body: body3(
6744
+ input,
6745
+ "telemetry.startRun"
6746
+ ),
6747
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6748
+ });
6749
+ },
6750
+ finishRun(input, idempotencyKey) {
6751
+ cleanRequiredString(input.tenantId, "tenantId");
6752
+ cleanRequiredString(input.runId, "runId");
6753
+ return gateway.request({
6754
+ path: `/api/platform/v1/telemetry/runs/${encodeURIComponent(
6755
+ input.runId
6756
+ )}/finish`,
6757
+ method: "POST",
6758
+ body: body3(
6759
+ input,
6760
+ "telemetry.finishRun"
6761
+ ),
6762
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6763
+ });
6764
+ },
6765
+ listRuns(input) {
6766
+ return gateway.request({
6767
+ path: `/api/platform/v1/telemetry/runs${toQueryString(query3(input))}`
6768
+ }).then(
6769
+ (response) => mapGatewayData(
6770
+ response,
6771
+ (data) => listResultFromEnvelope(data, "runs")
6772
+ )
6773
+ );
6774
+ }
6775
+ };
6776
+ }
6777
+
6778
+ // src/toolRegistryClient.ts
6779
+ var TOOL_REGISTRY_FIELDS = [
6780
+ "tenantId",
6781
+ "workspaceId",
6782
+ "principalId",
6783
+ "toolName",
6784
+ "packKey",
6785
+ "packVersion",
6786
+ "status",
6787
+ "permissions",
6788
+ "role",
6789
+ "surface",
6790
+ "parameterSchema",
6791
+ "returnSchema",
6792
+ "handlerRef",
6793
+ "executionAdapter",
6794
+ "safetyMetadata",
6795
+ "aclId",
6796
+ "metadata",
6797
+ "limit",
6798
+ "cursor"
6799
+ ];
6800
+ function query4(input) {
6801
+ return {
6802
+ tenantId: cleanRequiredString(input.tenantId, "tenantId"),
6803
+ workspaceId: input.workspaceId,
6804
+ principalId: input.principalId,
6805
+ packKey: input.packKey,
6806
+ status: input.status,
6807
+ limit: input.limit,
6808
+ cursor: input.cursor
6809
+ };
6810
+ }
6811
+ function writeBody(input, operation) {
6812
+ return knownPayload(input, TOOL_REGISTRY_FIELDS, operation);
6813
+ }
6814
+ function createToolRegistryClient(config = {}) {
6815
+ const gateway = createGatewayRequestClient(config);
6816
+ return {
6817
+ listCatalog(input) {
6818
+ return gateway.request({
6819
+ path: `/api/platform/v1/tools/catalog${toQueryString(query4(input))}`
6820
+ }).then(
6821
+ (response) => mapGatewayData(
6822
+ response,
6823
+ (data) => listResultFromEnvelope(data, "tools")
6824
+ )
6825
+ );
6826
+ },
6827
+ listExecutable(input) {
6828
+ return gateway.request({
6829
+ path: `/api/platform/v1/tools/executable${toQueryString(query4(input))}`
6830
+ }).then(
6831
+ (response) => mapGatewayData(
6832
+ response,
6833
+ (data) => listResultFromEnvelope(data, "tools")
6834
+ )
6835
+ );
6836
+ },
6837
+ listEffectiveTools(input) {
6838
+ return gateway.request({
6839
+ path: `/api/platform/v1/tools/effective${toQueryString(query4(input))}`
6840
+ }).then(
6841
+ (response) => mapGatewayData(
6842
+ response,
6843
+ (data) => listResultFromEnvelope(data, "tools")
6844
+ )
6845
+ );
6846
+ },
6847
+ upsertCoreTools(input, idempotencyKey) {
6848
+ cleanRequiredString(input.tenantId, "tenantId");
6849
+ return gateway.request({
6850
+ path: "/api/platform/v1/tools/core",
6851
+ method: "PUT",
6852
+ body: {
6853
+ tenantId: input.tenantId,
6854
+ workspaceId: input.workspaceId,
6855
+ metadata: input.metadata,
6856
+ tools: input.tools
6857
+ },
6858
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6859
+ }).then(
6860
+ (response) => mapGatewayData(
6861
+ response,
6862
+ (data) => listResultFromEnvelope(data, "tools")
6863
+ )
6864
+ );
6865
+ },
6866
+ setPackToolsStatus(input, idempotencyKey) {
6867
+ cleanRequiredString(input.tenantId, "tenantId");
6868
+ cleanRequiredString(input.packKey, "packKey");
6869
+ return gateway.request({
6870
+ path: `/api/platform/v1/tools/packs/${encodeURIComponent(
6871
+ input.packKey
6872
+ )}/status`,
6873
+ method: "PATCH",
6874
+ body: writeBody(
6875
+ input,
6876
+ "tools.setPackToolsStatus"
6877
+ ),
6878
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6879
+ }).then(
6880
+ (response) => mapGatewayData(
6881
+ response,
6882
+ (data) => listResultFromEnvelope(data, "tools")
6883
+ )
6884
+ );
6885
+ },
6886
+ createAcl(input, idempotencyKey) {
6887
+ cleanRequiredString(input.tenantId, "tenantId");
6888
+ cleanRequiredString(input.principalId, "principalId");
6889
+ cleanRequiredString(input.toolName, "toolName");
6890
+ return gateway.request({
6891
+ path: "/api/platform/v1/tools/acls",
6892
+ method: "POST",
6893
+ body: writeBody(
6894
+ input,
6895
+ "tools.createAcl"
6896
+ ),
6897
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6898
+ });
6899
+ },
6900
+ deleteAcl(input, idempotencyKey) {
6901
+ cleanRequiredString(input.tenantId, "tenantId");
6902
+ cleanRequiredString(input.aclId, "aclId");
6903
+ return gateway.request({
6904
+ path: `/api/platform/v1/tools/acls/${encodeURIComponent(input.aclId)}`,
6905
+ method: "DELETE",
6906
+ body: writeBody(
6907
+ input,
6908
+ "tools.deleteAcl"
6909
+ ),
6910
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6911
+ });
6912
+ },
6913
+ registerCustomTool(input, idempotencyKey) {
6914
+ cleanRequiredString(input.tenantId, "tenantId");
6915
+ cleanRequiredString(input.toolName, "toolName");
6916
+ return gateway.request({
6917
+ path: "/api/platform/v1/tools/custom",
6918
+ method: "POST",
6919
+ body: writeBody(
6920
+ input,
6921
+ "tools.registerCustomTool"
6922
+ ),
6923
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
6924
+ });
6925
+ }
6926
+ };
6927
+ }
6928
+
4950
6929
  // src/version.ts
4951
6930
  var LUCERN_SDK_VERSION = "0.2.0-alpha.1";
4952
6931
 
@@ -4964,10 +6943,10 @@ function createWorkflowClient(config = {}) {
4964
6943
  /**
4965
6944
  * List workflow branches for a topic scope.
4966
6945
  */
4967
- async listBranches(query) {
6946
+ async listBranches(query5) {
4968
6947
  return gateway.request({
4969
6948
  path: `/api/platform/v1/workflow/branches${toQueryString(
4970
- normalizeTopicQuery(query)
6949
+ normalizeTopicQuery(query5)
4971
6950
  )}`
4972
6951
  }).then(
4973
6952
  (response) => mapGatewayData(
@@ -4995,10 +6974,10 @@ function createWorkflowClient(config = {}) {
4995
6974
  /**
4996
6975
  * List reusable lenses for a workspace or topic scope.
4997
6976
  */
4998
- async listLenses(query) {
6977
+ async listLenses(query5) {
4999
6978
  return gateway.request({
5000
6979
  path: `/api/platform/v1/workflow/lenses${toQueryString(
5001
- normalizeLensQuery(query)
6980
+ normalizeLensQuery(query5)
5002
6981
  )}`
5003
6982
  }).then(
5004
6983
  (response) => mapGatewayData(
@@ -5070,14 +7049,14 @@ function createWorkflowClient(config = {}) {
5070
7049
  /**
5071
7050
  * List worktrees for a topic scope.
5072
7051
  */
5073
- async listWorktrees(query) {
5074
- const normalized = normalizeTopicQuery(query);
7052
+ async listWorktrees(query5) {
7053
+ const normalized = normalizeTopicQuery(query5);
5075
7054
  return gateway.request({
5076
7055
  path: `/api/platform/v1/worktrees/all${toQueryString({
5077
7056
  ...normalized,
5078
- groupBy: query.groupBy,
5079
- lane: query.lane,
5080
- campaign: query.campaign
7057
+ groupBy: query5.groupBy,
7058
+ lane: query5.lane,
7059
+ campaign: query5.campaign
5081
7060
  })}`
5082
7061
  }).then(
5083
7062
  (response) => mapGatewayData(
@@ -5092,14 +7071,14 @@ function createWorkflowClient(config = {}) {
5092
7071
  /**
5093
7072
  * List all worktrees across accessible topics.
5094
7073
  */
5095
- async listAllWorktrees(query = {}) {
7074
+ async listAllWorktrees(query5 = {}) {
5096
7075
  return gateway.request({
5097
7076
  path: `/api/platform/v1/worktrees${toQueryString({
5098
- status: query.status,
5099
- groupBy: query.groupBy,
5100
- lane: query.lane,
5101
- campaign: query.campaign,
5102
- limit: query.limit
7077
+ status: query5.status,
7078
+ groupBy: query5.groupBy,
7079
+ lane: query5.lane,
7080
+ campaign: query5.campaign,
7081
+ limit: query5.limit
5103
7082
  })}`
5104
7083
  }).then(
5105
7084
  (response) => mapGatewayData(response, (data) => {
@@ -5119,10 +7098,10 @@ function createWorkflowClient(config = {}) {
5119
7098
  /**
5120
7099
  * List compact pipeline campaigns with nested lanes.
5121
7100
  */
5122
- async listCampaigns(query = {}) {
7101
+ async listCampaigns(query5 = {}) {
5123
7102
  return gateway.request({
5124
7103
  path: `/api/platform/v1/worktrees/campaigns${toQueryString(
5125
- normalizeTopicQuery(query)
7104
+ normalizeTopicQuery(query5)
5126
7105
  )}`
5127
7106
  });
5128
7107
  },
@@ -5178,11 +7157,11 @@ function createWorkflowClient(config = {}) {
5178
7157
  * Update targeted beliefs/questions for a worktree.
5179
7158
  */
5180
7159
  async updateWorktreeTargets(input, idempotencyKey) {
5181
- const { worktreeId, ...body } = input;
7160
+ const { worktreeId, ...body4 } = input;
5182
7161
  return gateway.request({
5183
7162
  path: `/api/platform/v1/worktrees/${encodeURIComponent(worktreeId)}/targets`,
5184
7163
  method: "POST",
5185
- body,
7164
+ body: body4,
5186
7165
  idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
5187
7166
  }).then(
5188
7167
  (response) => mapGatewayData(
@@ -5271,11 +7250,11 @@ function createWorkflowClient(config = {}) {
5271
7250
  /**
5272
7251
  * List accessible topic contexts.
5273
7252
  */
5274
- async listTopics(query = {}) {
7253
+ async listTopics(query5 = {}) {
5275
7254
  return gateway.request({
5276
7255
  path: `/api/platform/v1/workflow/topics${toQueryString({
5277
- includeShared: typeof query.includeShared === "boolean" ? query.includeShared ? "true" : "false" : void 0,
5278
- limit: query.limit
7256
+ includeShared: typeof query5.includeShared === "boolean" ? query5.includeShared ? "true" : "false" : void 0,
7257
+ limit: query5.limit
5279
7258
  })}`
5280
7259
  }).then(
5281
7260
  (response) => mapGatewayData(response, (data) => {
@@ -5403,13 +7382,15 @@ function toGatewayConfig(config) {
5403
7382
  requestIdFactory: config.requestIdFactory,
5404
7383
  onRequest: config.onRequest,
5405
7384
  onResponse: config.onResponse,
7385
+ authContext: config.authContext,
7386
+ requireCanonicalAuthContext: config.requireCanonicalAuthContext,
5406
7387
  getAuthHeaders: async () => {
5407
7388
  const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
5408
7389
  if (config.apiKey && !base["x-lucern-key"] && !base.Authorization) {
5409
7390
  base["x-lucern-key"] = config.apiKey;
5410
7391
  }
5411
- if (config.userToken && !base["x-lucern-user-token"]) {
5412
- base["x-lucern-user-token"] = config.userToken;
7392
+ if (config.userToken && !base["x-lucern-session-token"]) {
7393
+ base["x-lucern-session-token"] = config.userToken;
5413
7394
  }
5414
7395
  if (config.environment && !base["x-lucern-environment"]) {
5415
7396
  base["x-lucern-environment"] = config.environment;
@@ -5418,7 +7399,7 @@ function toGatewayConfig(config) {
5418
7399
  }
5419
7400
  };
5420
7401
  }
5421
- function requireTopicId(args) {
7402
+ function requireTopicId4(args) {
5422
7403
  const topicId = resolveTopicId(args);
5423
7404
  if (!topicId) {
5424
7405
  throw new Error("topicId is required");
@@ -5466,12 +7447,18 @@ function createLucernClient(config = {}) {
5466
7447
  const sourcesClient = createSourcesClient(gatewayConfig);
5467
7448
  const beliefsFacade = createBeliefsFacade(gatewayConfig);
5468
7449
  const evidenceClient = createEvidenceClient(gatewayConfig);
7450
+ const embeddingsClient = createEmbeddingsClient(gatewayConfig);
7451
+ const eventingClient = createEventingClient(gatewayConfig);
5469
7452
  const graphClient = createGraphClient(gatewayConfig);
7453
+ const graphAnalysisClient = createGraphAnalysisClient(gatewayConfig);
7454
+ const graphRecommendationsClient = createGraphRecommendationsClient(gatewayConfig);
7455
+ const graphStateClassifierClient = createGraphStateClassifierClient(gatewayConfig);
5470
7456
  const graphFacade = createGraphFacade(gatewayConfig);
5471
7457
  const decisionsClient = createDecisionsClient(gatewayConfig);
5472
7458
  const contextClient = createContextClient(gatewayConfig);
5473
7459
  const workflowClient = createWorkflowClient(gatewayConfig);
5474
7460
  const auditClient = createAuditClient(gatewayConfig);
7461
+ const authDeviceClient = createAuthDeviceClient(gatewayConfig);
5475
7462
  const adminClient = createAdminClient(gatewayConfig);
5476
7463
  const answersClient = createAnswersClient(gatewayConfig);
5477
7464
  const contradictionsFacade = createContradictionsFacade(gatewayConfig);
@@ -5489,10 +7476,17 @@ function createLucernClient(config = {}) {
5489
7476
  const worktreesFacade = createWorktreesFacade(gatewayConfig);
5490
7477
  const policyClient = createPolicyClient(gatewayConfig);
5491
7478
  const ontologyClient = createOntologyClient(gatewayConfig);
7479
+ const ontologyLinksClient = createOntologyLinksClient(gatewayConfig);
7480
+ const orgGraphSearchClient = createOrgGraphSearchClient(gatewayConfig);
5492
7481
  const functionSurfaceClient = createFunctionSurfaceClient(gatewayConfig);
7482
+ const toolRegistryClient = createToolRegistryClient(gatewayConfig);
7483
+ const modelRuntimeClient = createModelRuntimeClient(gatewayConfig);
5493
7484
  const packsClient = createPacksClient(gatewayConfig);
5494
7485
  const reportsClient = createReportsClient(gatewayConfig);
5495
7486
  const learningClient = createLearningClient(gatewayConfig);
7487
+ const mcpClient = createMcpClient(gatewayConfig);
7488
+ const jobsClient = createJobsClient(gatewayConfig);
7489
+ const telemetryClient = createTelemetryClient(gatewayConfig);
5496
7490
  const harnessClient = createHarnessClient(gatewayConfig);
5497
7491
  const schemaClient = createSchemaClient(gatewayConfig);
5498
7492
  const audiencesClient = createAudiencesClient(gatewayConfig);
@@ -5621,7 +7615,7 @@ function createLucernClient(config = {}) {
5621
7615
  }
5622
7616
  async function listBeliefs(args) {
5623
7617
  const response = await beliefsFacade.list({
5624
- topicId: requireTopicId(args),
7618
+ topicId: requireTopicId4(args),
5625
7619
  status: args.status,
5626
7620
  worktreeId: args.worktreeId,
5627
7621
  minConfidence: args.minConfidence,
@@ -5649,13 +7643,13 @@ function createLucernClient(config = {}) {
5649
7643
  const results = groupedBeliefs.length > 0 ? groupedBeliefs : mergedResults.filter((result) => result.type === "belief");
5650
7644
  return { results };
5651
7645
  }
5652
- async function searchResources(query, options = {}) {
7646
+ async function searchResources(query5, options = {}) {
5653
7647
  const topicId = resolveTopicId(options);
5654
7648
  if (!topicId) {
5655
7649
  throw new Error("topicId is required");
5656
7650
  }
5657
7651
  return searchFacade.query({
5658
- q: query,
7652
+ q: query5,
5659
7653
  topicId,
5660
7654
  types: options.types,
5661
7655
  status: options.status,
@@ -5850,8 +7844,8 @@ function createLucernClient(config = {}) {
5850
7844
  }).then(exposeGatewayData);
5851
7845
  }
5852
7846
  const nodesNamespace = {
5853
- list(query) {
5854
- return graphClient.listNodes(query);
7847
+ list(query5) {
7848
+ return graphClient.listNodes(query5);
5855
7849
  },
5856
7850
  get(input) {
5857
7851
  return graphClient.getNode(
@@ -5880,16 +7874,22 @@ function createLucernClient(config = {}) {
5880
7874
  return {
5881
7875
  config,
5882
7876
  version: LUCERN_SDK_VERSION,
5883
- search(query, options) {
5884
- return searchResources(query, options);
7877
+ search(query5, options) {
7878
+ return searchResources(query5, options);
5885
7879
  },
5886
7880
  events: {
5887
- list(query = {}) {
5888
- return eventsFacade.list(query).then(exposeGatewayData);
7881
+ list(query5 = {}) {
7882
+ return eventsFacade.list(query5).then(exposeGatewayData);
5889
7883
  },
5890
7884
  replay(input) {
5891
7885
  return eventsFacade.replay(input).then(exposeGatewayData);
5892
- }
7886
+ },
7887
+ recordEvent: eventingClient.recordEvent,
7888
+ listEvents: eventingClient.listEvents,
7889
+ listWebhooks: eventingClient.listWebhooks,
7890
+ enqueueDelivery: eventingClient.enqueueDelivery,
7891
+ recordDeliveryAttempt: eventingClient.recordDeliveryAttempt,
7892
+ updateDeliveryStatus: eventingClient.updateDeliveryStatus
5893
7893
  },
5894
7894
  beliefs: {
5895
7895
  create(input) {
@@ -5958,7 +7958,7 @@ function createLucernClient(config = {}) {
5958
7958
  },
5959
7959
  list(args) {
5960
7960
  return beliefsFacade.list({
5961
- topicId: requireTopicId(args),
7961
+ topicId: requireTopicId4(args),
5962
7962
  worktreeId: args.worktreeId,
5963
7963
  status: args.status,
5964
7964
  minConfidence: args.minConfidence,
@@ -5987,8 +7987,8 @@ function createLucernClient(config = {}) {
5987
7987
  create(input) {
5988
7988
  return webhooksFacade.create(input).then(exposeGatewayData);
5989
7989
  },
5990
- list(query) {
5991
- return webhooksFacade.list(query).then(exposeGatewayData);
7990
+ list(query5) {
7991
+ return webhooksFacade.list(query5).then(exposeGatewayData);
5992
7992
  },
5993
7993
  get(id) {
5994
7994
  return webhooksFacade.get(id).then(exposeGatewayData);
@@ -6002,8 +8002,8 @@ function createLucernClient(config = {}) {
6002
8002
  test(id, input) {
6003
8003
  return webhooksFacade.test(id, input).then(exposeGatewayData);
6004
8004
  },
6005
- deliveries(id, query) {
6006
- return webhooksFacade.deliveries(id, query).then(exposeGatewayData);
8005
+ deliveries(id, query5) {
8006
+ return webhooksFacade.deliveries(id, query5).then(exposeGatewayData);
6007
8007
  },
6008
8008
  health(id) {
6009
8009
  return webhooksFacade.health(id).then(exposeGatewayData);
@@ -6158,7 +8158,7 @@ function createLucernClient(config = {}) {
6158
8158
  },
6159
8159
  list(args) {
6160
8160
  return questionsFacade.list({
6161
- topicId: requireTopicId(args),
8161
+ topicId: requireTopicId4(args),
6162
8162
  status: args.status,
6163
8163
  priority: args.priority,
6164
8164
  worktreeId: args.worktreeId,
@@ -6230,7 +8230,7 @@ function createLucernClient(config = {}) {
6230
8230
  },
6231
8231
  getHighPriority(args) {
6232
8232
  return this.list({
6233
- topicId: requireTopicId(args),
8233
+ topicId: requireTopicId4(args),
6234
8234
  status: args.includeAnswered ? void 0 : "open"
6235
8235
  }).then((data) => {
6236
8236
  const questions = Array.isArray(data.questions) ? data.questions : [];
@@ -6255,7 +8255,7 @@ function createLucernClient(config = {}) {
6255
8255
  },
6256
8256
  async findMissing(args) {
6257
8257
  return graphFacade.gaps({
6258
- topicId: requireTopicId(args),
8258
+ topicId: requireTopicId4(args),
6259
8259
  minConfidence: args.minConfidence
6260
8260
  }).then(exposeGatewayData);
6261
8261
  }
@@ -6286,21 +8286,21 @@ function createLucernClient(config = {}) {
6286
8286
  },
6287
8287
  analyze(args) {
6288
8288
  return graphFacade.analyze({
6289
- topicId: requireTopicId(args),
8289
+ topicId: requireTopicId4(args),
6290
8290
  limit: args.limit,
6291
8291
  metric: args.metric
6292
8292
  }).then(exposeGatewayData);
6293
8293
  },
6294
8294
  bias(args) {
6295
8295
  return graphFacade.bias({
6296
- topicId: requireTopicId(args),
8296
+ topicId: requireTopicId4(args),
6297
8297
  threshold: args.threshold,
6298
8298
  limit: args.limit
6299
8299
  }).then(exposeGatewayData);
6300
8300
  },
6301
8301
  gaps(args) {
6302
8302
  return graphFacade.gaps({
6303
- topicId: requireTopicId(args),
8303
+ topicId: requireTopicId4(args),
6304
8304
  minConfidence: args.minConfidence
6305
8305
  }).then(exposeGatewayData);
6306
8306
  },
@@ -6359,8 +8359,8 @@ function createLucernClient(config = {}) {
6359
8359
  record(input) {
6360
8360
  return decisionsClient.recordJudgment(input);
6361
8361
  },
6362
- list(query) {
6363
- return decisionsClient.listJudgments(query);
8362
+ list(query5) {
8363
+ return decisionsClient.listJudgments(query5);
6364
8364
  },
6365
8365
  get(judgmentId) {
6366
8366
  return decisionsClient.getJudgment(judgmentId);
@@ -6389,7 +8389,7 @@ function createLucernClient(config = {}) {
6389
8389
  transitionAuditIntegrity(args) {
6390
8390
  return decisionsClient.getJudgmentTransitionAuditIntegrity({
6391
8391
  ...args,
6392
- topicId: requireTopicId(args)
8392
+ topicId: requireTopicId4(args)
6393
8393
  });
6394
8394
  }
6395
8395
  },
@@ -6400,8 +8400,8 @@ function createLucernClient(config = {}) {
6400
8400
  createLens(input) {
6401
8401
  return workflowClient.createLens(input);
6402
8402
  },
6403
- listLenses(query) {
6404
- return workflowClient.listLenses(query);
8403
+ listLenses(query5) {
8404
+ return workflowClient.listLenses(query5);
6405
8405
  },
6406
8406
  applyLensToTopic(input) {
6407
8407
  return workflowClient.applyLensToTopic(input);
@@ -6412,7 +8412,7 @@ function createLucernClient(config = {}) {
6412
8412
  create(input) {
6413
8413
  return worktreesFacade.create({
6414
8414
  title: input.title,
6415
- topicId: requireTopicId(input),
8415
+ topicId: requireTopicId4(input),
6416
8416
  objective: input.objective,
6417
8417
  hypothesis: input.hypothesis,
6418
8418
  beliefIds: input.beliefIds,
@@ -6434,7 +8434,7 @@ function createLucernClient(config = {}) {
6434
8434
  add(input) {
6435
8435
  return worktreesFacade.create({
6436
8436
  title: input.title,
6437
- topicId: requireTopicId(input),
8437
+ topicId: requireTopicId4(input),
6438
8438
  objective: input.objective,
6439
8439
  hypothesis: input.hypothesis,
6440
8440
  beliefIds: input.beliefIds,
@@ -6453,11 +8453,11 @@ function createLucernClient(config = {}) {
6453
8453
  autoFixPolicy: input.autoFixPolicy
6454
8454
  });
6455
8455
  },
6456
- list(query) {
8456
+ list(query5) {
6457
8457
  return worktreesFacade.list({
6458
- topicId: requireTopicId(query),
6459
- status: query.status,
6460
- limit: query.limit
8458
+ topicId: requireTopicId4(query5),
8459
+ status: query5.status,
8460
+ limit: query5.limit
6461
8461
  });
6462
8462
  },
6463
8463
  activate(worktreeId) {
@@ -6492,8 +8492,8 @@ function createLucernClient(config = {}) {
6492
8492
  removeQuestionIds: input.removeQuestionIds
6493
8493
  });
6494
8494
  },
6495
- listAll(query = {}) {
6496
- return workflowClient.listAllWorktrees(query);
8495
+ listAll(query5 = {}) {
8496
+ return workflowClient.listAllWorktrees(query5);
6497
8497
  },
6498
8498
  merge(worktreeId, input) {
6499
8499
  return worktreesFacade.merge({
@@ -6534,12 +8534,12 @@ function createLucernClient(config = {}) {
6534
8534
  }
6535
8535
  },
6536
8536
  context: {
6537
- listTopics(query = {}) {
8537
+ listTopics(query5 = {}) {
6538
8538
  return topicsFacade.list({
6539
- ontologyId: query.ontologyId,
6540
- parentTopicId: query.parentTopicId,
6541
- status: query.status,
6542
- type: query.type
8539
+ ontologyId: query5.ontologyId,
8540
+ parentTopicId: query5.parentTopicId,
8541
+ status: query5.status,
8542
+ type: query5.type
6543
8543
  });
6544
8544
  },
6545
8545
  compile(topicId, input = {}) {
@@ -6650,10 +8650,10 @@ function createLucernClient(config = {}) {
6650
8650
  visibility: input.visibility
6651
8651
  });
6652
8652
  },
6653
- tree(topicId, query = {}) {
8653
+ tree(topicId, query5 = {}) {
6654
8654
  return topicsFacade.tree({
6655
8655
  id: topicId,
6656
- maxDepth: query.maxDepth
8656
+ maxDepth: query5.maxDepth
6657
8657
  });
6658
8658
  },
6659
8659
  getTree(input) {
@@ -6662,11 +8662,11 @@ function createLucernClient(config = {}) {
6662
8662
  maxDepth: input.maxDepth
6663
8663
  });
6664
8664
  },
6665
- coverage(topicId, query = {}) {
8665
+ coverage(topicId, query5 = {}) {
6666
8666
  return topicsFacade.coverage({
6667
8667
  id: topicId,
6668
- includeDescendants: query.includeDescendants,
6669
- maxDepth: query.maxDepth
8668
+ includeDescendants: query5.includeDescendants,
8669
+ maxDepth: query5.maxDepth
6670
8670
  });
6671
8671
  },
6672
8672
  remove(topicId, idempotencyKey) {
@@ -6716,7 +8716,7 @@ function createLucernClient(config = {}) {
6716
8716
  },
6717
8717
  list(args) {
6718
8718
  return contradictionsFacade.list({
6719
- topicId: requireTopicId(args),
8719
+ topicId: requireTopicId4(args),
6720
8720
  status: args.status,
6721
8721
  limit: args.limit,
6722
8722
  cursor: args.cursor
@@ -6891,7 +8891,24 @@ function createLucernClient(config = {}) {
6891
8891
  return functionSurfaceClient.generateSessionHandoff(input);
6892
8892
  }
6893
8893
  },
8894
+ embeddings: embeddingsClient,
8895
+ graphAnalysis: graphAnalysisClient,
8896
+ graphRecommendations: graphRecommendationsClient,
8897
+ orgGraphSearch: orgGraphSearchClient,
8898
+ ontologyLinks: ontologyLinksClient,
8899
+ graphStateClassifier: graphStateClassifierClient,
8900
+ modelRuntime: modelRuntimeClient,
8901
+ jobs: jobsClient,
8902
+ telemetry: telemetryClient,
6894
8903
  tools: {
8904
+ listCatalog: toolRegistryClient.listCatalog,
8905
+ listExecutable: toolRegistryClient.listExecutable,
8906
+ listEffectiveTools: toolRegistryClient.listEffectiveTools,
8907
+ upsertCoreTools: toolRegistryClient.upsertCoreTools,
8908
+ setPackToolsStatus: toolRegistryClient.setPackToolsStatus,
8909
+ createAcl: toolRegistryClient.createAcl,
8910
+ deleteAcl: toolRegistryClient.deleteAcl,
8911
+ registerCustomTool: toolRegistryClient.registerCustomTool,
6895
8912
  register(registration) {
6896
8913
  return registerCustomTool(registration);
6897
8914
  },
@@ -6948,26 +8965,74 @@ function createLucernClient(config = {}) {
6948
8965
  }
6949
8966
  },
6950
8967
  nodes: nodesNamespace,
6951
- identity: identityFacade,
8968
+ identity: {
8969
+ ...identityFacade,
8970
+ evaluatePolicy: identityClient.evaluatePolicy,
8971
+ recordPolicyDecision: identityClient.recordPolicyDecision,
8972
+ putSecretReference: identityClient.putSecretReference,
8973
+ createPrincipal: identityClient.createPrincipal,
8974
+ updatePrincipal: identityClient.updatePrincipal,
8975
+ raw: identityClient
8976
+ },
8977
+ mcp: {
8978
+ bootstrapSession(input) {
8979
+ return mcpClient.bootstrapSession(input);
8980
+ },
8981
+ checkWritePolicy(input) {
8982
+ return mcpClient.checkWritePolicy(input);
8983
+ },
8984
+ beginBuildSession(input) {
8985
+ return mcpClient.beginBuildSession(input);
8986
+ },
8987
+ evaluateEngineeringContract(input) {
8988
+ return mcpClient.evaluateEngineeringContract(input);
8989
+ },
8990
+ evaluateResearchContract(input) {
8991
+ return mcpClient.evaluateResearchContract(input);
8992
+ }
8993
+ },
8994
+ auth: {
8995
+ device: {
8996
+ createCode(input) {
8997
+ return authDeviceClient.createDeviceCode(input);
8998
+ },
8999
+ pollToken(deviceCode) {
9000
+ return authDeviceClient.pollDeviceToken(deviceCode);
9001
+ }
9002
+ }
9003
+ },
6952
9004
  custom: getCustomNamespace("custom"),
6953
9005
  extensions: extensionNamespaces,
6954
9006
  raw: {
6955
9007
  beliefs: beliefsClient,
6956
9008
  sources: sourcesClient,
6957
9009
  evidence: evidenceClient,
9010
+ embeddings: embeddingsClient,
9011
+ eventing: eventingClient,
6958
9012
  graph: graphClient,
9013
+ graphAnalysis: graphAnalysisClient,
9014
+ graphRecommendations: graphRecommendationsClient,
9015
+ graphStateClassifier: graphStateClassifierClient,
6959
9016
  decisions: decisionsClient,
6960
9017
  workflow: workflowClient,
6961
9018
  audit: auditClient,
9019
+ authDevice: authDeviceClient,
6962
9020
  admin: adminClient,
6963
9021
  identity: identityClient,
6964
9022
  policy: policyClient,
6965
9023
  answers: answersClient,
6966
9024
  ontology: ontologyClient,
9025
+ ontologyLinks: ontologyLinksClient,
9026
+ orgGraphSearch: orgGraphSearchClient,
6967
9027
  functionSurface: functionSurfaceClient,
9028
+ toolRegistry: toolRegistryClient,
9029
+ modelRuntime: modelRuntimeClient,
6968
9030
  packs: packsClient,
6969
9031
  reports: reportsClient,
6970
9032
  learning: learningClient,
9033
+ mcp: mcpClient,
9034
+ jobs: jobsClient,
9035
+ telemetry: telemetryClient,
6971
9036
  harness: harnessClient,
6972
9037
  schema: schemaClient,
6973
9038
  audiences: audiencesClient,
@@ -6977,7 +9042,7 @@ function createLucernClient(config = {}) {
6977
9042
  }
6978
9043
 
6979
9044
  // src/facade/context.ts
6980
- function cleanString4(value) {
9045
+ function cleanString6(value) {
6981
9046
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
6982
9047
  }
6983
9048
  function cleanNumber2(value) {
@@ -6988,15 +9053,15 @@ function cleanBoolean2(value) {
6988
9053
  }
6989
9054
  function buildCompileContextRequest2(topicId, input = {}) {
6990
9055
  const payload = { topicId };
6991
- const query = cleanString4(input.query);
6992
- if (query) {
6993
- payload.query = query;
9056
+ const query5 = cleanString6(input.query);
9057
+ if (query5) {
9058
+ payload.query = query5;
6994
9059
  }
6995
9060
  const budget = cleanNumber2(input.budget) ?? cleanNumber2(input.tokenBudget);
6996
9061
  if (budget !== void 0) {
6997
9062
  payload.budget = budget;
6998
9063
  }
6999
- const ranking = cleanString4(input.ranking) ?? cleanString4(input.rankingProfile);
9064
+ const ranking = cleanString6(input.ranking) ?? cleanString6(input.rankingProfile);
7000
9065
  if (ranking) {
7001
9066
  payload.ranking = ranking;
7002
9067
  }
@@ -7012,7 +9077,7 @@ function buildCompileContextRequest2(topicId, input = {}) {
7012
9077
  if (includeEntities !== void 0) {
7013
9078
  payload.includeEntities = includeEntities;
7014
9079
  }
7015
- const mode = cleanString4(input.mode);
9080
+ const mode = cleanString6(input.mode);
7016
9081
  if (mode) {
7017
9082
  payload.mode = mode;
7018
9083
  }
@@ -7020,11 +9085,11 @@ function buildCompileContextRequest2(topicId, input = {}) {
7020
9085
  if (includeFailures !== void 0) {
7021
9086
  payload.includeFailures = includeFailures;
7022
9087
  }
7023
- const worktreeId = cleanString4(input.worktreeId);
9088
+ const worktreeId = cleanString6(input.worktreeId);
7024
9089
  if (worktreeId) {
7025
9090
  payload.worktreeId = worktreeId;
7026
9091
  }
7027
- const sessionId = cleanString4(input.sessionId);
9092
+ const sessionId = cleanString6(input.sessionId);
7028
9093
  if (sessionId) {
7029
9094
  payload.sessionId = sessionId;
7030
9095
  }
@@ -7614,11 +9679,11 @@ function toPositiveInt(value, fallback, max) {
7614
9679
  const floored = Math.floor(value);
7615
9680
  return Math.max(1, Math.min(floored, max));
7616
9681
  }
7617
- function normalizeQueryTokens(query) {
7618
- if (!query) {
9682
+ function normalizeQueryTokens(query5) {
9683
+ if (!query5) {
7619
9684
  return [];
7620
9685
  }
7621
- return query.toLowerCase().split(/[^a-z0-9]+/).map((token) => token.trim()).filter((token) => token.length >= 2);
9686
+ return query5.toLowerCase().split(/[^a-z0-9]+/).map((token) => token.trim()).filter((token) => token.length >= 2);
7622
9687
  }
7623
9688
  function parseRankingProfile(value) {
7624
9689
  return value === "baseline_v1" ? "baseline_v1" : "weighted_v1";
@@ -8608,6 +10673,15 @@ function buildDeprecatedBranchMetadata(args) {
8608
10673
 
8609
10674
  // src/contracts/mcpTools.ts
8610
10675
  var mcpTools_exports = {};
10676
+ __export(mcpTools_exports, {
10677
+ MCP_ALWAYS_ALLOWED_TOOL_NAMES: () => MCP_ALWAYS_ALLOWED_TOOL_NAMES,
10678
+ buildMcpToolContracts: () => buildMcpToolContracts,
10679
+ buildMcpToolManifest: () => buildMcpToolManifest,
10680
+ getMcpToolExposure: () => getMcpToolExposure,
10681
+ isMcpToolAllowed: () => isMcpToolAllowed,
10682
+ mcpContractToInputSchema: () => mcpContractToInputSchema,
10683
+ mcpContractToManifestEntry: () => mcpContractToManifestEntry
10684
+ });
8611
10685
 
8612
10686
  // src/contracts/tool-contracts.ts
8613
10687
  var tool_contracts_exports = {};
@@ -8615,6 +10689,92 @@ __reExport(tool_contracts_exports, tool_contracts_star);
8615
10689
 
8616
10690
  // src/contracts/mcpTools.ts
8617
10691
  __reExport(mcpTools_exports, tool_contracts_exports);
10692
+ var OPERATION_MANIFEST = LUCERN_OPERATION_MANIFEST;
10693
+ var MCP_ALWAYS_ALLOWED_TOOL_NAMES = ["identity_whoami"];
10694
+ function getMcpToolExposure(toolName) {
10695
+ return OPERATION_MANIFEST[toolName]?.surfaces.mcp ?? "none";
10696
+ }
10697
+ function decorateMcpToolContract(toolName, contract) {
10698
+ const exposure = getMcpToolExposure(toolName);
10699
+ if (exposure === "none") {
10700
+ return null;
10701
+ }
10702
+ return exposure === "internal" || contract.internal ? { ...contract, internal: true } : contract;
10703
+ }
10704
+ function buildMcpToolContracts(options = {}) {
10705
+ const merged = {
10706
+ ...tool_contracts_exports.MCP_TOOL_CONTRACTS,
10707
+ ...options.extensions ?? {}
10708
+ };
10709
+ return Object.fromEntries(
10710
+ Object.entries(merged).flatMap(([toolName, contract]) => {
10711
+ const decorated = decorateMcpToolContract(toolName, contract);
10712
+ return decorated ? [[toolName, decorated]] : [];
10713
+ })
10714
+ );
10715
+ }
10716
+ function mcpContractToInputSchema(contract) {
10717
+ const properties = {};
10718
+ for (const [paramName, paramDef] of Object.entries(contract.parameters)) {
10719
+ const prop = {
10720
+ type: paramDef.type,
10721
+ description: paramDef.description
10722
+ };
10723
+ if (paramDef.enum) {
10724
+ prop.enum = paramDef.enum;
10725
+ }
10726
+ properties[paramName] = prop;
10727
+ }
10728
+ return {
10729
+ type: "object",
10730
+ properties,
10731
+ required: contract.required
10732
+ };
10733
+ }
10734
+ function mcpContractToManifestEntry(name, contract) {
10735
+ return {
10736
+ name,
10737
+ description: contract.description,
10738
+ inputSchema: mcpContractToInputSchema(contract),
10739
+ internal: Boolean(contract.internal),
10740
+ ownerModule: contract.ownerModule,
10741
+ ontologyPrimitive: contract.ontologyPrimitive,
10742
+ tier: contract.tier
10743
+ };
10744
+ }
10745
+ function isMcpToolAllowed(toolName, options = {}) {
10746
+ const contracts = options.contracts ?? buildMcpToolContracts();
10747
+ const contract = contracts[toolName];
10748
+ const alwaysAllowed = /* @__PURE__ */ new Set([
10749
+ ...MCP_ALWAYS_ALLOWED_TOOL_NAMES,
10750
+ ...options.alwaysAllowedTools ?? []
10751
+ ]);
10752
+ if (alwaysAllowed.has(toolName)) {
10753
+ return true;
10754
+ }
10755
+ if (options.sessionType === "user" && contract?.internal) {
10756
+ return false;
10757
+ }
10758
+ if (options.permittedTools !== void 0 && options.permittedTools !== null) {
10759
+ return options.permittedTools.some((tool) => tool.toolName === toolName);
10760
+ }
10761
+ if (options.allowedTools === null || options.allowedTools === void 0) {
10762
+ return true;
10763
+ }
10764
+ return options.allowedTools.includes(toolName);
10765
+ }
10766
+ function buildMcpToolManifest(args = {}) {
10767
+ const contracts = args.contracts ?? buildMcpToolContracts();
10768
+ return Object.entries(contracts).filter(([name, contract]) => {
10769
+ if (args.visibility?.sessionType === "user" && contract.internal) {
10770
+ return false;
10771
+ }
10772
+ return isMcpToolAllowed(name, {
10773
+ ...args.visibility,
10774
+ contracts
10775
+ });
10776
+ }).map(([name, contract]) => mcpContractToManifestEntry(name, contract));
10777
+ }
8618
10778
 
8619
10779
  // src/index.ts
8620
10780
  __reExport(src_exports, mcpTools_exports);
@@ -9125,15 +11285,15 @@ function serializeTypes2(types) {
9125
11285
  function createEventsClientCore(config = {}) {
9126
11286
  const gateway = createGatewayRequestClient(config);
9127
11287
  return {
9128
- async list(query = {}) {
11288
+ async list(query5 = {}) {
9129
11289
  return gateway.request({
9130
11290
  path: `/v1/events${toQueryString({
9131
- topicId: query.topicId,
9132
- after: query.after,
9133
- types: serializeTypes2(query.types),
9134
- startTime: query.startTime,
9135
- endTime: query.endTime,
9136
- limit: query.limit
11291
+ topicId: query5.topicId,
11292
+ after: query5.after,
11293
+ types: serializeTypes2(query5.types),
11294
+ startTime: query5.startTime,
11295
+ endTime: query5.endTime,
11296
+ limit: query5.limit
9137
11297
  })}`
9138
11298
  });
9139
11299
  },
@@ -9158,10 +11318,10 @@ function createWebhooksClientCore(config = {}) {
9158
11318
  idempotencyKey
9159
11319
  });
9160
11320
  },
9161
- async list(query = {}) {
11321
+ async list(query5 = {}) {
9162
11322
  return gateway.request({
9163
11323
  path: `/v1/webhooks${toQueryString({
9164
- topicId: query.topicId
11324
+ topicId: query5.topicId
9165
11325
  })}`
9166
11326
  });
9167
11327
  },
@@ -9193,10 +11353,10 @@ function createWebhooksClientCore(config = {}) {
9193
11353
  idempotencyKey
9194
11354
  });
9195
11355
  },
9196
- async deliveries(id, query = {}) {
11356
+ async deliveries(id, query5 = {}) {
9197
11357
  return gateway.request({
9198
11358
  path: `/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
9199
- limit: query.limit
11359
+ limit: query5.limit
9200
11360
  })}`
9201
11361
  });
9202
11362
  },
@@ -9208,6 +11368,6 @@ function createWebhooksClientCore(config = {}) {
9208
11368
  };
9209
11369
  }
9210
11370
 
9211
- export { BELIEF_STATUSES, BRANCH_DEPRECATION_MESSAGE, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, CONTROL_OBJECT_BLAST_RADII, CONTROL_OBJECT_EDIT_SURFACES, CONTROL_OBJECT_INHERITANCE_RULES, CONTROL_OBJECT_KINDS, CONTROL_OBJECT_OWNERSHIP_CONTRACT, CONTROL_OBJECT_OWNERSHIP_MATRIX, CONTROL_OBJECT_OWNERSHIP_ROWS, CONTROL_OBJECT_OWNER_SCOPES, CustomToolRegistryError, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, EDGE_TYPES, EPISTEMIC_EDGE_TYPES, EPISTEMIC_LAYERS, EVENT_RETENTION_DEFAULT_DAYS, FORK_REASONS, FUNCTION_SURFACE_METHOD_PATHS, JUDGMENT_TYPES, LENS_PERSPECTIVE_TYPES, LENS_STATUSES, LENS_TASK_TEMPLATE_PRIORITIES, LUCERN_SDK_VERSION, LucernApiError, MAX_ENTITY_LIMIT, MERGE_OUTCOMES, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, REASONING_METHODS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, STRUCTURAL_EDGE_TYPES, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, asListItems, assertValidWebhookSecret, assertValidWebhookUrl, buildDeprecatedBranchMetadata, buildDomainEvent, clearRegisteredCustomTools, compareEventCursor, compileContextPackFromSnapshot, computeWebhookSignature, createAdminClient, createAnswersClient, createAudiencesClient, createAuditClient, createBeliefsClient, createContextClient, createContextFacade, createDecisionsClient, createEventId, createEventsClientCore, createEvidenceClient, createFunctionSurfaceClient, createGatewayRequestClient, createGraphClient, createHarnessClient, createIdentityClient, createLearningClient, createListResult, createLucernClient, createOntologyClient, createPacksClient, createPolicyClient, createReportsClient, createSchemaClient, createSourcesClient, createTopicsClient, createWebhooksClientCore, createWorkflowClient, decodeEventCursor, emitDomainEvent, encodeEventCursor, eventPatternToRegExp, getControlObjectOwnershipCase, getRegisteredCustomTool, inferActorType, inferLensPerspectiveTypeFromBranchSchema, inferSessionPrincipalType, invokeRegisteredCustomTool, isAfterCursor, isLensFilterCriteria, isLucernPrompt, isTaxonomyFilterCriteriaV1, lastDelegator, listControlObjectOwnershipCases, listRegisteredCustomTools, mapAliasedList, mapGatewayData, mapOpinionHistoryEntriesFromGatewayData, matchesAnyEventPattern, matchesEventPattern, migrateBranchToLens, nextDeliveryAttemptAt, normalizeDelegationChain, normalizeNodeVerificationStatus, normalizeNodeWriteInput, normalizeRetentionDays, normalizeTopicQuery, normalizeWebhookPatterns, opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected, planContextPackCompilation, randomIdempotencyKey, registerCustomTool, resolveDeliveryFailureStatus, resolveText, resolveTopicId, sanitizeWebhookRecord, sortEventsByCursor, toQueryString, truncateWebhookResponseBody, unregisterCustomTool, validateFilterCriteria, withSdkAliases, withTextAlias, withTopicAlias };
11371
+ export { BELIEF_STATUSES, BRANCH_DEPRECATION_MESSAGE, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, CONTROL_OBJECT_BLAST_RADII, CONTROL_OBJECT_EDIT_SURFACES, CONTROL_OBJECT_INHERITANCE_RULES, CONTROL_OBJECT_KINDS, CONTROL_OBJECT_OWNERSHIP_CONTRACT, CONTROL_OBJECT_OWNERSHIP_MATRIX, CONTROL_OBJECT_OWNERSHIP_ROWS, CONTROL_OBJECT_OWNER_SCOPES, CustomToolRegistryError, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, DeviceAuthorizationError, EDGE_TYPES, EMBEDDINGS_FIELDS, EPISTEMIC_EDGE_TYPES, EPISTEMIC_LAYERS, EVENTING_FIELDS, EVENT_RETENTION_DEFAULT_DAYS, FORK_REASONS, FUNCTION_SURFACE_METHOD_PATHS, GRAPH_ANALYSIS_ANALYSIS_FIELDS, GRAPH_ANALYSIS_COMPUTE_FIELDS, GRAPH_ANALYSIS_SUGGESTION_FIELDS, GRAPH_RECOMMENDATION_FIELDS, GRAPH_STATE_CLASSIFIER_FIELDS, JOBS_FIELDS, JUDGMENT_TYPES, LENS_PERSPECTIVE_TYPES, LENS_STATUSES, LENS_TASK_TEMPLATE_PRIORITIES, LUCERN_SDK_VERSION, LucernApiError, LucernSdkAuthContextError, MAX_ENTITY_LIMIT, MCP_ALWAYS_ALLOWED_TOOL_NAMES, MERGE_OUTCOMES, MODEL_RUNTIME_FIELDS, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, ONTOLOGY_LINK_FIELDS, ORG_GRAPH_SEARCH_FIELDS, REASONING_METHODS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, STRUCTURAL_EDGE_TYPES, TELEMETRY_FIELDS, TENANT_IDENTITY_FIELDS, TOOL_REGISTRY_FIELDS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, asListItems, assertValidWebhookSecret, assertValidWebhookUrl, buildDeprecatedBranchMetadata, buildDomainEvent, buildMcpToolContracts, buildMcpToolManifest, clearRegisteredCustomTools, compareEventCursor, compileContextPackFromSnapshot, computeWebhookSignature, createAdminClient, createAnswersClient, createAudiencesClient, createAuditClient, createAuthDeviceClient, createBeliefsClient, createCanonicalAuthHeaders, createContextClient, createContextFacade, createDecisionsClient, createEmbeddingsClient, createEventId, createEventingClient, createEventsClientCore, createEvidenceClient, createFunctionSurfaceClient, createGatewayRequestClient, createGraphAnalysisClient, createGraphClient, createGraphRecommendationsClient, createGraphStateClassifierClient, createHarnessClient, createIdentityClient, createJobsClient, createLearningClient, createListResult, createLucernClient, createModelRuntimeClient, createOntologyClient, createOntologyLinksClient, createOrgGraphSearchClient, createPacksClient, createPolicyClient, createReportsClient, createSchemaClient, createSourcesClient, createTelemetryClient, createToolRegistryClient, createTopicsClient, createWebhooksClientCore, createWorkflowClient, decodeEventCursor, emitDomainEvent, encodeEventCursor, eventPatternToRegExp, getControlObjectOwnershipCase, getMcpToolExposure, getRegisteredCustomTool, inferActorType, inferLensPerspectiveTypeFromBranchSchema, inferSessionPrincipalType, invokeRegisteredCustomTool, isAfterCursor, isLensFilterCriteria, isLucernPrompt, isMcpToolAllowed, isTaxonomyFilterCriteriaV1, lastDelegator, listControlObjectOwnershipCases, listRegisteredCustomTools, mapAliasedList, mapGatewayData, mapOpinionHistoryEntriesFromGatewayData, matchesAnyEventPattern, matchesEventPattern, mcpContractToInputSchema, mcpContractToManifestEntry, migrateBranchToLens, nextDeliveryAttemptAt, normalizeCanonicalLucernAuthContext, normalizeDelegationChain, normalizeNodeVerificationStatus, normalizeNodeWriteInput, normalizeRetentionDays, normalizeTopicQuery, normalizeWebhookPatterns, opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected, planContextPackCompilation, randomIdempotencyKey, registerCustomTool, resolveDeliveryFailureStatus, resolveText, resolveTopicId, sanitizeWebhookRecord, sortEventsByCursor, toQueryString, truncateWebhookResponseBody, unregisterCustomTool, validateFilterCriteria, withSdkAliases, withTextAlias, withTopicAlias };
9212
11372
  //# sourceMappingURL=index.js.map
9213
11373
  //# sourceMappingURL=index.js.map