@lucern/sdk 0.2.0-alpha.6 → 0.2.0-alpha.8

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 (274) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{lib/platform/sdk/adminClient.d.ts → adminClient.d.ts} +56 -51
  3. package/dist/adminClient.js +755 -0
  4. package/dist/adminClient.js.map +1 -0
  5. package/dist/answersClient.d.ts +23 -0
  6. package/dist/answersClient.js +333 -0
  7. package/dist/answersClient.js.map +1 -0
  8. package/dist/{lib/platform/sdk/audiencesClient.d.ts → audiencesClient.d.ts} +24 -18
  9. package/dist/audiencesClient.js +472 -0
  10. package/dist/audiencesClient.js.map +1 -0
  11. package/dist/auditClient.d.ts +29 -0
  12. package/dist/auditClient.js +386 -0
  13. package/dist/auditClient.js.map +1 -0
  14. package/dist/{lib/platform/sdk/beliefsClient.d.ts → beliefsClient.d.ts} +32 -27
  15. package/dist/beliefsClient.js +477 -0
  16. package/dist/beliefsClient.js.map +1 -0
  17. package/dist/{lib/platform/sdk/client.d.ts → client.d.ts} +404 -395
  18. package/dist/client.js +6134 -0
  19. package/dist/client.js.map +1 -0
  20. package/dist/{lib/platform/sdk/contextClient.d.ts → contextClient.d.ts} +13 -7
  21. package/dist/contextClient.js +396 -0
  22. package/dist/contextClient.js.map +1 -0
  23. package/dist/contextFacade.d.ts +2 -0
  24. package/dist/contextFacade.js +73 -0
  25. package/dist/contextFacade.js.map +1 -0
  26. package/dist/{lib/platform/sdk/contextPackCompiler.d.ts → contextPackCompiler.d.ts} +11 -9
  27. package/dist/contextPackCompiler.js +1091 -0
  28. package/dist/contextPackCompiler.js.map +1 -0
  29. package/dist/contextPackPolicy.d.ts +84 -0
  30. package/dist/contextPackPolicy.js +347 -0
  31. package/dist/contextPackPolicy.js.map +1 -0
  32. package/dist/contextPackSchema.d.ts +7 -0
  33. package/dist/contextPackSchema.js +203 -0
  34. package/dist/contextPackSchema.js.map +1 -0
  35. package/dist/{lib/platform/sdk/contextTypes.d.ts → contextTypes.d.ts} +15 -13
  36. package/dist/contextTypes.js +3 -0
  37. package/dist/contextTypes.js.map +1 -0
  38. package/dist/contracts/api-enums.contract.d.ts +81 -0
  39. package/dist/contracts/api-enums.contract.js +92 -0
  40. package/dist/contracts/api-enums.contract.js.map +1 -0
  41. package/dist/contracts/auth-session.contract.d.ts +55 -0
  42. package/dist/contracts/auth-session.contract.js +48 -0
  43. package/dist/contracts/auth-session.contract.js.map +1 -0
  44. package/dist/{lucern/contracts/src → contracts}/context-pack.contract.d.ts +56 -58
  45. package/dist/contracts/context-pack.contract.js +98 -0
  46. package/dist/contracts/context-pack.contract.js.map +1 -0
  47. package/dist/contracts/contextPack.d.ts +1 -0
  48. package/dist/contracts/contextPack.js +98 -0
  49. package/dist/contracts/contextPack.js.map +1 -0
  50. package/dist/contracts/index.d.ts +9 -0
  51. package/dist/contracts/index.js +4892 -0
  52. package/dist/contracts/index.js.map +1 -0
  53. package/dist/{lucern/contracts/src → contracts}/lens-filter.contract.d.ts +10 -8
  54. package/dist/contracts/lens-filter.contract.js +71 -0
  55. package/dist/contracts/lens-filter.contract.js.map +1 -0
  56. package/dist/contracts/lens-workflow.contract.d.ts +87 -0
  57. package/dist/contracts/lens-workflow.contract.js +123 -0
  58. package/dist/contracts/lens-workflow.contract.js.map +1 -0
  59. package/dist/contracts/lensFilter.d.ts +1 -0
  60. package/dist/contracts/lensFilter.js +71 -0
  61. package/dist/contracts/lensFilter.js.map +1 -0
  62. package/dist/contracts/lensWorkflow.d.ts +2 -0
  63. package/dist/contracts/lensWorkflow.js +123 -0
  64. package/dist/contracts/lensWorkflow.js.map +1 -0
  65. package/dist/contracts/mcp-tools.contract.d.ts +1 -0
  66. package/dist/contracts/mcp-tools.contract.js +2986 -0
  67. package/dist/contracts/mcp-tools.contract.js.map +1 -0
  68. package/dist/contracts/mcpTools.d.ts +1 -0
  69. package/dist/contracts/mcpTools.js +2986 -0
  70. package/dist/contracts/mcpTools.js.map +1 -0
  71. package/dist/{lucern/contracts/src → contracts}/prompt.contract.d.ts +5 -3
  72. package/dist/contracts/prompt.contract.js +12 -0
  73. package/dist/contracts/prompt.contract.js.map +1 -0
  74. package/dist/contracts/prompt.d.ts +1 -0
  75. package/dist/contracts/prompt.js +12 -0
  76. package/dist/contracts/prompt.js.map +1 -0
  77. package/dist/contracts/sdk-tools.contract.d.ts +2 -0
  78. package/dist/contracts/sdk-tools.contract.js +4134 -0
  79. package/dist/contracts/sdk-tools.contract.js.map +1 -0
  80. package/dist/contracts/sdkTools.d.ts +2 -0
  81. package/dist/contracts/sdkTools.js +4134 -0
  82. package/dist/contracts/sdkTools.js.map +1 -0
  83. package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
  84. package/dist/contracts/workflow-runtime.contract.js +245 -0
  85. package/dist/contracts/workflow-runtime.contract.js.map +1 -0
  86. package/dist/contracts/workflowRuntime.d.ts +1 -0
  87. package/dist/contracts/workflowRuntime.js +245 -0
  88. package/dist/contracts/workflowRuntime.js.map +1 -0
  89. package/dist/{lib/platform/sdk/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +20 -18
  90. package/dist/controlObjectOwnership.js +215 -0
  91. package/dist/controlObjectOwnership.js.map +1 -0
  92. package/dist/{lib/platform/sdk/coreClient.d.ts → coreClient.d.ts} +19 -14
  93. package/dist/coreClient.js +339 -0
  94. package/dist/coreClient.js.map +1 -0
  95. package/dist/{lib/platform/sdk/customTools.d.ts → customTools.d.ts} +21 -16
  96. package/dist/customTools.js +248 -0
  97. package/dist/customTools.js.map +1 -0
  98. package/dist/{lib/platform/sdk/decisionsClient.d.ts → decisionsClient.d.ts} +29 -24
  99. package/dist/decisionsClient.js +522 -0
  100. package/dist/decisionsClient.js.map +1 -0
  101. package/dist/domainContext.d.ts +1 -0
  102. package/dist/domainContext.js +3 -0
  103. package/dist/domainContext.js.map +1 -0
  104. package/dist/events.d.ts +178 -0
  105. package/dist/events.js +249 -0
  106. package/dist/events.js.map +1 -0
  107. package/dist/eventsCore.d.ts +49 -0
  108. package/dist/eventsCore.js +429 -0
  109. package/dist/eventsCore.js.map +1 -0
  110. package/dist/facade/context.d.ts +18 -0
  111. package/dist/facade/context.js +73 -0
  112. package/dist/facade/context.js.map +1 -0
  113. package/dist/{lib/platform/sdk/gatewayFacades.d.ts → gatewayFacades.d.ts} +31 -26
  114. package/dist/gatewayFacades.js +1953 -0
  115. package/dist/gatewayFacades.js.map +1 -0
  116. package/dist/{lib/platform/sdk/graphClient.d.ts → graphClient.d.ts} +57 -52
  117. package/dist/graphClient.js +698 -0
  118. package/dist/graphClient.js.map +1 -0
  119. package/dist/{lib/platform/sdk/harnessClient.d.ts → harnessClient.d.ts} +44 -39
  120. package/dist/harnessClient.js +607 -0
  121. package/dist/harnessClient.js.map +1 -0
  122. package/dist/{lib/platform/sdk/identityClient.d.ts → identityClient.d.ts} +17 -11
  123. package/dist/identityClient.js +497 -0
  124. package/dist/identityClient.js.map +1 -0
  125. package/dist/index.d.ts +42 -3
  126. package/dist/index.js +11381 -3
  127. package/dist/index.js.map +1 -0
  128. package/dist/{lib/platform/sdk/learningClient.d.ts → learningClient.d.ts} +13 -7
  129. package/dist/learningClient.js +409 -0
  130. package/dist/learningClient.js.map +1 -0
  131. package/dist/{lib/platform/sdk/mcpParityClient.d.ts → mcpParityClient.d.ts} +10 -5
  132. package/dist/mcpParityClient.js +516 -0
  133. package/dist/mcpParityClient.js.map +1 -0
  134. package/dist/mcpParitySurface.d.ts +12 -0
  135. package/dist/mcpParitySurface.js +65 -0
  136. package/dist/mcpParitySurface.js.map +1 -0
  137. package/dist/mcpTools-DPZxowDX.d.ts +254 -0
  138. package/dist/{lib/platform/sdk/ontologyClient.d.ts → ontologyClient.d.ts} +28 -22
  139. package/dist/ontologyClient.js +513 -0
  140. package/dist/ontologyClient.js.map +1 -0
  141. package/dist/packRuntime.d.ts +2 -0
  142. package/dist/packRuntime.js +3 -0
  143. package/dist/packRuntime.js.map +1 -0
  144. package/dist/{lib/platform/sdk/packsClient.d.ts → packsClient.d.ts} +34 -29
  145. package/dist/packsClient.js +525 -0
  146. package/dist/packsClient.js.map +1 -0
  147. package/dist/{lib/platform/sdk/policyClient.d.ts → policyClient.d.ts} +26 -20
  148. package/dist/policyClient.js +625 -0
  149. package/dist/policyClient.js.map +1 -0
  150. package/dist/realtime/index.d.ts +29 -0
  151. package/dist/realtime/index.js +23 -0
  152. package/dist/realtime/index.js.map +1 -0
  153. package/dist/realtime/refs.d.ts +17 -0
  154. package/dist/realtime/refs.js +9 -0
  155. package/dist/realtime/refs.js.map +1 -0
  156. package/dist/reportsClient.d.ts +41 -0
  157. package/dist/reportsClient.js +418 -0
  158. package/dist/reportsClient.js.map +1 -0
  159. package/dist/{lib/platform/sdk/schemaClient.d.ts → schemaClient.d.ts} +20 -15
  160. package/dist/schemaClient.js +434 -0
  161. package/dist/schemaClient.js.map +1 -0
  162. package/dist/sdkSurface.d.ts +61 -0
  163. package/dist/sdkSurface.js +112 -0
  164. package/dist/sdkSurface.js.map +1 -0
  165. package/dist/sdkTools-CwXJDACb.d.ts +150 -0
  166. package/dist/{lib/platform/sdk/topicsClient.d.ts → topicsClient.d.ts} +24 -18
  167. package/dist/topicsClient.js +492 -0
  168. package/dist/topicsClient.js.map +1 -0
  169. package/dist/{lib/platform/sdk/types.d.ts → types.d.ts} +84 -80
  170. package/dist/types.js +3 -0
  171. package/dist/types.js.map +1 -0
  172. package/dist/version.d.ts +4 -0
  173. package/dist/version.js +6 -0
  174. package/dist/version.js.map +1 -0
  175. package/dist/{lib/platform/sdk/workflowClient.d.ts → workflowClient.d.ts} +60 -57
  176. package/dist/workflowClient.js +830 -0
  177. package/dist/workflowClient.js.map +1 -0
  178. package/package.json +25 -43
  179. package/dist/.generated +0 -2
  180. package/dist/lib/platform/auth/credentials.d.ts +0 -5
  181. package/dist/lib/platform/auth/credentials.js +0 -40
  182. package/dist/lib/platform/sdk/adminClient.js +0 -384
  183. package/dist/lib/platform/sdk/answersClient.d.ts +0 -16
  184. package/dist/lib/platform/sdk/answersClient.js +0 -21
  185. package/dist/lib/platform/sdk/audiencesClient.js +0 -111
  186. package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
  187. package/dist/lib/platform/sdk/auditClient.js +0 -21
  188. package/dist/lib/platform/sdk/beliefsClient.js +0 -124
  189. package/dist/lib/platform/sdk/client.js +0 -1831
  190. package/dist/lib/platform/sdk/contextClient.js +0 -86
  191. package/dist/lib/platform/sdk/contextFacade.d.ts +0 -10
  192. package/dist/lib/platform/sdk/contextFacade.js +0 -10
  193. package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
  194. package/dist/lib/platform/sdk/contextTypes.js +0 -1
  195. package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
  196. package/dist/lib/platform/sdk/coreClient.js +0 -366
  197. package/dist/lib/platform/sdk/customTools.js +0 -247
  198. package/dist/lib/platform/sdk/decisionsClient.js +0 -129
  199. package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
  200. package/dist/lib/platform/sdk/domainContext.js +0 -1
  201. package/dist/lib/platform/sdk/events.d.ts +0 -176
  202. package/dist/lib/platform/sdk/events.js +0 -261
  203. package/dist/lib/platform/sdk/eventsCore.d.ts +0 -13
  204. package/dist/lib/platform/sdk/eventsCore.js +0 -13
  205. package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
  206. package/dist/lib/platform/sdk/graphClient.js +0 -235
  207. package/dist/lib/platform/sdk/harnessClient.js +0 -219
  208. package/dist/lib/platform/sdk/identityClient.js +0 -131
  209. package/dist/lib/platform/sdk/index.d.ts +0 -49
  210. package/dist/lib/platform/sdk/index.js +0 -49
  211. package/dist/lib/platform/sdk/learningClient.js +0 -53
  212. package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
  213. package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
  214. package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
  215. package/dist/lib/platform/sdk/ontologyClient.js +0 -161
  216. package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
  217. package/dist/lib/platform/sdk/packRuntime.js +0 -1
  218. package/dist/lib/platform/sdk/packsClient.js +0 -157
  219. package/dist/lib/platform/sdk/policyClient.js +0 -277
  220. package/dist/lib/platform/sdk/promptCatalog.d.ts +0 -1
  221. package/dist/lib/platform/sdk/promptCatalog.js +0 -1
  222. package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
  223. package/dist/lib/platform/sdk/reportsClient.js +0 -64
  224. package/dist/lib/platform/sdk/schemaClient.js +0 -71
  225. package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
  226. package/dist/lib/platform/sdk/sdkSurface.js +0 -140
  227. package/dist/lib/platform/sdk/topicsClient.js +0 -118
  228. package/dist/lib/platform/sdk/types.js +0 -1
  229. package/dist/lib/platform/sdk/version.d.ts +0 -2
  230. package/dist/lib/platform/sdk/version.js +0 -2
  231. package/dist/lib/platform/sdk/workflowClient.js +0 -366
  232. package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
  233. package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
  234. package/dist/lucern/contracts/src/auth-context.contract.d.ts +0 -8
  235. package/dist/lucern/contracts/src/auth-context.contract.js +0 -8
  236. package/dist/lucern/contracts/src/auth-session.contract.d.ts +0 -8
  237. package/dist/lucern/contracts/src/auth-session.contract.js +0 -8
  238. package/dist/lucern/contracts/src/auth.contract.d.ts +0 -88
  239. package/dist/lucern/contracts/src/auth.contract.js +0 -57
  240. package/dist/lucern/contracts/src/context-pack.contract.js +0 -169
  241. package/dist/lucern/contracts/src/convex-admin.contract.d.ts +0 -5
  242. package/dist/lucern/contracts/src/convex-admin.contract.js +0 -1
  243. package/dist/lucern/contracts/src/events-types.contract.d.ts +0 -8
  244. package/dist/lucern/contracts/src/events-types.contract.js +0 -8
  245. package/dist/lucern/contracts/src/events.contract.d.ts +0 -176
  246. package/dist/lucern/contracts/src/events.contract.js +0 -159
  247. package/dist/lucern/contracts/src/gateway.contract.d.ts +0 -74
  248. package/dist/lucern/contracts/src/gateway.contract.js +0 -19
  249. package/dist/lucern/contracts/src/ids.contract.d.ts +0 -7
  250. package/dist/lucern/contracts/src/ids.contract.js +0 -24
  251. package/dist/lucern/contracts/src/index.d.ts +0 -29
  252. package/dist/lucern/contracts/src/index.js +0 -29
  253. package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
  254. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
  255. package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
  256. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
  257. package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
  258. package/dist/lucern/contracts/src/ontology-matching.contract.d.ts +0 -8
  259. package/dist/lucern/contracts/src/ontology-matching.contract.js +0 -8
  260. package/dist/lucern/contracts/src/prompt.contract.js +0 -24
  261. package/dist/lucern/contracts/src/sdk-methods.contract.d.ts +0 -358
  262. package/dist/lucern/contracts/src/sdk-methods.contract.js +0 -19
  263. package/dist/lucern/contracts/src/sdk-tools.contract.d.ts +0 -92
  264. package/dist/lucern/contracts/src/sdk-tools.contract.js +0 -1398
  265. package/dist/lucern/contracts/src/text-matching.contract.d.ts +0 -53
  266. package/dist/lucern/contracts/src/text-matching.contract.js +0 -277
  267. package/dist/lucern/contracts/src/topic-scope.contract.d.ts +0 -8
  268. package/dist/lucern/contracts/src/topic-scope.contract.js +0 -8
  269. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
  270. package/dist/lucern/contracts/src/workflow-runtime.contract.js +0 -257
  271. package/dist/realtime-refs.d.ts +0 -1
  272. package/dist/realtime-refs.js +0 -1
  273. package/dist/realtime.d.ts +0 -1
  274. package/dist/realtime.js +0 -1
@@ -1,41 +1,44 @@
1
- import { type GatewayClientConfig, type GatewayScope, LucernApiError } from "./coreClient";
2
- import type { JsonObject } from "./types";
3
- export { LucernApiError };
4
- export type { GatewayScope, PlatformGatewaySuccess } from "./coreClient";
1
+ import { GatewayClientConfig, GatewayScope, PlatformGatewaySuccess } from './coreClient.js';
2
+ export { LucernApiError } from './coreClient.js';
3
+ import { JsonObject, ListResult } from './types.js';
4
+ import './contracts/workflow-runtime.contract.js';
5
+ import './contracts/lens-workflow.contract.js';
6
+ import './contracts/lens-filter.contract.js';
7
+
5
8
  /** Configuration for the packs client. */
6
- export type PacksClientConfig = GatewayClientConfig;
9
+ type PacksClientConfig = GatewayClientConfig;
7
10
  /** Input for installing a pack into a tenant or workspace scope. */
8
- export type PackInstallInput = GatewayScope & {
11
+ type PackInstallInput = GatewayScope & {
9
12
  packKey: string;
10
13
  version?: string;
11
14
  autoEnable?: boolean;
12
15
  metadata?: JsonObject;
13
16
  };
14
17
  /** Input for enabling a previously installed pack. */
15
- export type PackEnableInput = GatewayScope & {
18
+ type PackEnableInput = GatewayScope & {
16
19
  packKey: string;
17
20
  metadata?: JsonObject;
18
21
  };
19
22
  /** Input for disabling an active pack. */
20
- export type PackDisableInput = GatewayScope & {
23
+ type PackDisableInput = GatewayScope & {
21
24
  packKey: string;
22
25
  force?: boolean;
23
26
  metadata?: JsonObject;
24
27
  };
25
28
  /** Input for uninstalling a pack from a tenant or workspace scope. */
26
- export type PackUninstallInput = GatewayScope & {
29
+ type PackUninstallInput = GatewayScope & {
27
30
  packKey: string;
28
31
  metadata?: JsonObject;
29
32
  };
30
33
  /** Input for upgrading a pack through the prepare/canary/commit/rollback lifecycle. */
31
- export type PackUpgradeInput = GatewayScope & {
34
+ type PackUpgradeInput = GatewayScope & {
32
35
  packKey: string;
33
36
  mode: "prepare" | "canary" | "commit" | "rollback";
34
37
  targetVersion?: string;
35
38
  metadata?: JsonObject;
36
39
  };
37
40
  /** Input for creating or updating a pack entitlement record. */
38
- export type PackEntitlementInput = GatewayScope & {
41
+ type PackEntitlementInput = GatewayScope & {
39
42
  packKey: string;
40
43
  status: "active" | "disabled" | "revoked";
41
44
  allowedLifecycles?: Array<"active" | "beta" | "experimental">;
@@ -48,79 +51,81 @@ export type PackEntitlementInput = GatewayScope & {
48
51
  * @param config - Gateway transport configuration.
49
52
  * @returns An object with methods to manage pack lifecycle, telemetry, and entitlements.
50
53
  */
51
- export declare function createPacksClient(config?: PacksClientConfig): {
54
+ declare function createPacksClient(config?: PacksClientConfig): {
52
55
  /**
53
56
  * List catalog entries for available packs.
54
57
  */
55
- listCatalog(): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "catalog">>>;
58
+ listCatalog(): Promise<PlatformGatewaySuccess<ListResult<any, "catalog">>>;
56
59
  /**
57
60
  * @deprecated Use listCatalog.
58
61
  */
59
- getCatalog(): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "catalog">>>;
62
+ getCatalog(): Promise<PlatformGatewaySuccess<ListResult<any, "catalog">>>;
60
63
  /**
61
64
  * Get the discovery catalog for packs.
62
65
  */
63
- getDiscoveryCatalog(): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
66
+ getDiscoveryCatalog(): Promise<PlatformGatewaySuccess<unknown>>;
64
67
  /**
65
68
  * Get discovery details for a specific pack.
66
69
  */
67
- getDiscoveryDetail(packKey: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
70
+ getDiscoveryDetail(packKey: string): Promise<PlatformGatewaySuccess<unknown>>;
68
71
  /**
69
72
  * List pack states for the current scope.
70
73
  */
71
- listStates(query?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "states">>>;
74
+ listStates(query?: GatewayScope): Promise<PlatformGatewaySuccess<ListResult<any, "states">>>;
72
75
  /**
73
76
  * @deprecated Use listStates.
74
77
  */
75
- getStates(query?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "states">>>;
78
+ getStates(query?: GatewayScope): Promise<PlatformGatewaySuccess<ListResult<any, "states">>>;
76
79
  /**
77
80
  * Get health details for a pack.
78
81
  */
79
- getHealth(packKey: string, query?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
82
+ getHealth(packKey: string, query?: GatewayScope): Promise<PlatformGatewaySuccess<unknown>>;
80
83
  /**
81
84
  * List pack telemetry entries.
82
85
  */
83
86
  listTelemetry(query?: GatewayScope & {
84
87
  lookbackHours?: number;
85
88
  limit?: number;
86
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "telemetry">>>;
89
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "telemetry">>>;
87
90
  /**
88
91
  * @deprecated Use listTelemetry.
89
92
  */
90
93
  getTelemetry(query?: GatewayScope & {
91
94
  lookbackHours?: number;
92
95
  limit?: number;
93
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "telemetry">>>;
96
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "telemetry">>>;
94
97
  /**
95
98
  * Create a pack entitlement.
96
99
  */
97
- createEntitlement(input: PackEntitlementInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
100
+ createEntitlement(input: PackEntitlementInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
98
101
  /**
99
102
  * Update a pack entitlement.
100
103
  */
101
- updateEntitlement(input: PackEntitlementInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
104
+ updateEntitlement(input: PackEntitlementInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
102
105
  /**
103
106
  * @deprecated Use createEntitlement or updateEntitlement.
104
107
  */
105
- upsertEntitlement(input: PackEntitlementInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
108
+ upsertEntitlement(input: PackEntitlementInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
106
109
  /**
107
110
  * Install a pack.
108
111
  */
109
- install(input: PackInstallInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
112
+ install(input: PackInstallInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
110
113
  /**
111
114
  * Enable a pack.
112
115
  */
113
- enable(input: PackEnableInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
116
+ enable(input: PackEnableInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
114
117
  /**
115
118
  * Disable a pack.
116
119
  */
117
- disable(input: PackDisableInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
120
+ disable(input: PackDisableInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
118
121
  /**
119
122
  * Uninstall a pack.
120
123
  */
121
- uninstall(input: PackUninstallInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
124
+ uninstall(input: PackUninstallInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
122
125
  /**
123
126
  * Upgrade a pack.
124
127
  */
125
- upgrade(input: PackUpgradeInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
128
+ upgrade(input: PackUpgradeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
126
129
  };
130
+
131
+ export { GatewayScope, type PackDisableInput, type PackEnableInput, type PackEntitlementInput, type PackInstallInput, type PackUninstallInput, type PackUpgradeInput, type PacksClientConfig, PlatformGatewaySuccess, createPacksClient };
@@ -0,0 +1,525 @@
1
+ // src/coreClient.ts
2
+ var LucernApiError = class extends Error {
3
+ code;
4
+ status;
5
+ invariant;
6
+ suggestion;
7
+ details;
8
+ requestId;
9
+ correlationId;
10
+ policyTraceId;
11
+ constructor(args) {
12
+ super(args.message);
13
+ this.name = "LucernApiError";
14
+ this.code = args.code;
15
+ this.status = args.status;
16
+ this.invariant = args.invariant;
17
+ this.suggestion = args.suggestion;
18
+ this.details = args.details;
19
+ this.requestId = args.requestId;
20
+ this.correlationId = args.correlationId;
21
+ this.policyTraceId = args.policyTraceId;
22
+ }
23
+ };
24
+ function toQueryString(scope) {
25
+ const params = new URLSearchParams();
26
+ if (scope.tenantId) {
27
+ params.set("tenantId", scope.tenantId);
28
+ }
29
+ if (scope.workspaceId) {
30
+ params.set("workspaceId", scope.workspaceId);
31
+ }
32
+ for (const [key, value] of Object.entries(scope)) {
33
+ if (key === "tenantId" || key === "workspaceId") {
34
+ continue;
35
+ }
36
+ if (value === void 0) {
37
+ continue;
38
+ }
39
+ params.set(key, String(value));
40
+ }
41
+ const serialized = params.toString();
42
+ return serialized.length > 0 ? `?${serialized}` : "";
43
+ }
44
+ function fillRandomBytes(length) {
45
+ const bytes = new Uint8Array(length);
46
+ if (typeof globalThis.crypto?.getRandomValues === "function") {
47
+ globalThis.crypto.getRandomValues(bytes);
48
+ return bytes;
49
+ }
50
+ for (let index = 0; index < length; index += 1) {
51
+ bytes[index] = Math.floor(Math.random() * 256);
52
+ }
53
+ return bytes;
54
+ }
55
+ function generatePortableRequestId() {
56
+ if (typeof globalThis.crypto?.randomUUID === "function") {
57
+ return globalThis.crypto.randomUUID();
58
+ }
59
+ const bytes = fillRandomBytes(16);
60
+ bytes[6] = bytes[6] & 15 | 64;
61
+ bytes[8] = bytes[8] & 63 | 128;
62
+ const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
63
+ return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
64
+ 6,
65
+ 8
66
+ ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
67
+ }
68
+ function randomIdempotencyKey() {
69
+ return generatePortableRequestId();
70
+ }
71
+ function isRetryableStatus(status) {
72
+ return status >= 500 || status === 408 || status === 429;
73
+ }
74
+ function fallbackErrorCode(status) {
75
+ if (status === 401) {
76
+ return "AUTHENTICATION_REQUIRED";
77
+ }
78
+ if (status === 403) {
79
+ return "FORBIDDEN";
80
+ }
81
+ if (status === 404) {
82
+ return "NOT_FOUND";
83
+ }
84
+ if (status === 408) {
85
+ return "UPSTREAM_ERROR";
86
+ }
87
+ if (status === 409) {
88
+ return "CONFLICT";
89
+ }
90
+ if (status === 429) {
91
+ return "RATE_LIMIT_EXCEEDED";
92
+ }
93
+ if (status >= 500) {
94
+ return "UPSTREAM_ERROR";
95
+ }
96
+ return "INTERNAL_ERROR";
97
+ }
98
+ function delay(ms) {
99
+ return new Promise((resolve) => setTimeout(resolve, ms));
100
+ }
101
+ function parseRetryAfterMs(value) {
102
+ if (!value) {
103
+ return null;
104
+ }
105
+ const trimmed = value.trim();
106
+ if (!trimmed) {
107
+ return null;
108
+ }
109
+ const numeric = Number(trimmed);
110
+ if (Number.isFinite(numeric)) {
111
+ return Math.max(0, Math.round(numeric * 1e3));
112
+ }
113
+ const parsedDate = Date.parse(trimmed);
114
+ if (Number.isFinite(parsedDate)) {
115
+ return Math.max(0, parsedDate - Date.now());
116
+ }
117
+ return null;
118
+ }
119
+ function computeRetryDelayMs(args) {
120
+ const baseDelay = args.status === 429 ? Math.max(
121
+ args.retryAfterMs ?? 0,
122
+ Math.min(1e3 * 2 ** args.attempt, 1e4)
123
+ ) : Math.min(1e3 * 2 ** args.attempt, 4e3);
124
+ if (args.status !== 429) {
125
+ return baseDelay;
126
+ }
127
+ const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
128
+ return baseDelay + Math.round(Math.random() * jitterWindow);
129
+ }
130
+ function timeoutError(timeoutMs) {
131
+ const error = new Error(`Request timed out after ${timeoutMs}ms`);
132
+ error.name = "AbortError";
133
+ return error;
134
+ }
135
+ function readPolicySummaryFromDetails(details) {
136
+ if (!details || typeof details !== "object" || Array.isArray(details)) {
137
+ return null;
138
+ }
139
+ const directSummary = details.summary;
140
+ if (typeof directSummary === "string" && directSummary.trim().length > 0) {
141
+ return directSummary.trim();
142
+ }
143
+ const policy = details.policy;
144
+ if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
145
+ return null;
146
+ }
147
+ const explanation = policy.explanation;
148
+ if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
149
+ return null;
150
+ }
151
+ const nestedSummary = explanation.summary;
152
+ if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
153
+ return nestedSummary.trim();
154
+ }
155
+ return null;
156
+ }
157
+ function createGatewayRequestClient(config = {}) {
158
+ const fetchImpl = config.fetchImpl ?? fetch;
159
+ const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
160
+ const maxRetries = config.maxRetries ?? 2;
161
+ const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
162
+ async function resolveAuthHeaders() {
163
+ if (!config.getAuthHeaders) {
164
+ return {};
165
+ }
166
+ return await config.getAuthHeaders();
167
+ }
168
+ async function fetchWithTimeout(url, init, timeoutMs) {
169
+ const controller = new AbortController();
170
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
171
+ try {
172
+ return await fetchImpl(url, { ...init, signal: controller.signal });
173
+ } catch (error) {
174
+ if (controller.signal.aborted) {
175
+ throw timeoutError(timeoutMs);
176
+ }
177
+ throw error;
178
+ } finally {
179
+ clearTimeout(timer);
180
+ }
181
+ }
182
+ async function parsePayload(response) {
183
+ const text = await response.text();
184
+ if (!text) {
185
+ return null;
186
+ }
187
+ try {
188
+ return JSON.parse(text);
189
+ } catch {
190
+ return null;
191
+ }
192
+ }
193
+ function resolveTimeoutMs(method, requestTimeoutMs) {
194
+ if (typeof requestTimeoutMs === "number") {
195
+ return requestTimeoutMs;
196
+ }
197
+ const methodTimeoutMs = config.timeoutMsByMethod?.[method];
198
+ if (typeof methodTimeoutMs === "number") {
199
+ return methodTimeoutMs;
200
+ }
201
+ return config.timeoutMs ?? 15e3;
202
+ }
203
+ function buildApiError(args) {
204
+ const failure = args.failure;
205
+ const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
206
+ const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
207
+ const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
208
+ const details = failure?.details ?? legacyError?.details;
209
+ const policySummary = readPolicySummaryFromDetails(details);
210
+ return new LucernApiError({
211
+ code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
212
+ message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
213
+ status: args.response.status,
214
+ invariant: failure?.invariant,
215
+ suggestion: failure?.suggestion,
216
+ details,
217
+ requestId: args.requestId,
218
+ correlationId,
219
+ policyTraceId
220
+ });
221
+ }
222
+ async function request(args) {
223
+ const authHeaders = await resolveAuthHeaders();
224
+ const method = args.method ?? "GET";
225
+ const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
226
+ const headers = new Headers({
227
+ "content-type": "application/json",
228
+ ...authHeaders
229
+ });
230
+ if (args.idempotencyKey) {
231
+ headers.set("idempotency-key", args.idempotencyKey);
232
+ }
233
+ const requestId = headers.get("x-correlation-id")?.trim() || headers.get("x-request-id")?.trim() || args.requestId || requestIdFactory();
234
+ if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
235
+ headers.set("x-correlation-id", requestId);
236
+ }
237
+ const url = `${baseUrl}${args.path}`;
238
+ const serializedBody = args.body ? JSON.stringify(args.body) : void 0;
239
+ const init = {
240
+ method,
241
+ headers,
242
+ body: serializedBody
243
+ };
244
+ let lastError;
245
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
246
+ const hookRequestContext = {
247
+ requestId,
248
+ attempt,
249
+ maxRetries,
250
+ method,
251
+ path: args.path,
252
+ url,
253
+ headers: new Headers(headers),
254
+ body: serializedBody,
255
+ timeoutMs
256
+ };
257
+ await config.onRequest?.(hookRequestContext);
258
+ const startedAt = Date.now();
259
+ try {
260
+ const response = await fetchWithTimeout(url, init, timeoutMs);
261
+ const responseClone = response.clone();
262
+ const payload = await parsePayload(response);
263
+ const retryAfterMs = parseRetryAfterMs(
264
+ response.headers.get("Retry-After")
265
+ );
266
+ if (!response.ok || !payload?.success) {
267
+ const failure = payload && !payload.success ? payload : null;
268
+ const apiError = buildApiError({
269
+ requestId,
270
+ response,
271
+ failure
272
+ });
273
+ const willRetry = attempt < maxRetries && isRetryableStatus(response.status);
274
+ await config.onResponse?.({
275
+ ...hookRequestContext,
276
+ durationMs: Date.now() - startedAt,
277
+ status: response.status,
278
+ response: responseClone,
279
+ error: apiError,
280
+ correlationId: apiError.correlationId ?? requestId,
281
+ policyTraceId: apiError.policyTraceId ?? null,
282
+ retryAfterMs,
283
+ willRetry
284
+ });
285
+ if (willRetry) {
286
+ lastError = apiError;
287
+ await delay(
288
+ computeRetryDelayMs({
289
+ attempt,
290
+ status: response.status,
291
+ retryAfterMs
292
+ })
293
+ );
294
+ continue;
295
+ }
296
+ throw apiError;
297
+ }
298
+ const successPayload = payload;
299
+ await config.onResponse?.({
300
+ ...hookRequestContext,
301
+ durationMs: Date.now() - startedAt,
302
+ status: response.status,
303
+ response: responseClone,
304
+ correlationId: successPayload.correlationId ?? response.headers.get("x-lucern-correlation-id")?.trim() ?? requestId,
305
+ policyTraceId: successPayload.policyTraceId ?? response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null,
306
+ idempotentReplay: successPayload.idempotentReplay,
307
+ retryAfterMs,
308
+ willRetry: false
309
+ });
310
+ return successPayload;
311
+ } catch (fetchError) {
312
+ if (fetchError instanceof LucernApiError) {
313
+ throw fetchError;
314
+ }
315
+ const willRetry = attempt < maxRetries;
316
+ await config.onResponse?.({
317
+ ...hookRequestContext,
318
+ durationMs: Date.now() - startedAt,
319
+ error: fetchError,
320
+ correlationId: requestId,
321
+ policyTraceId: null,
322
+ willRetry
323
+ });
324
+ lastError = fetchError;
325
+ if (willRetry) {
326
+ await delay(computeRetryDelayMs({ attempt }));
327
+ }
328
+ }
329
+ }
330
+ throw lastError instanceof Error ? lastError : new Error("Platform API request failed after retries.");
331
+ }
332
+ return {
333
+ request
334
+ };
335
+ }
336
+
337
+ // src/sdkSurface.ts
338
+ function createListResult(items, legacyKey) {
339
+ const result = {
340
+ items,
341
+ total: items.length
342
+ };
343
+ if (legacyKey) {
344
+ result[legacyKey] = items;
345
+ }
346
+ return result;
347
+ }
348
+ function mapGatewayData(response, mapper) {
349
+ return {
350
+ ...response,
351
+ data: mapper(response.data)
352
+ };
353
+ }
354
+
355
+ // src/packsClient.ts
356
+ function createPacksClient(config = {}) {
357
+ const gateway = createGatewayRequestClient(config);
358
+ return {
359
+ /**
360
+ * List catalog entries for available packs.
361
+ */
362
+ async listCatalog() {
363
+ return gateway.request({
364
+ path: "/api/platform/v1/packs/catalog"
365
+ }).then(
366
+ (response) => mapGatewayData(
367
+ response,
368
+ (data) => createListResult(Array.isArray(data) ? data : [], "catalog")
369
+ )
370
+ );
371
+ },
372
+ /**
373
+ * @deprecated Use listCatalog.
374
+ */
375
+ async getCatalog() {
376
+ return this.listCatalog();
377
+ },
378
+ /**
379
+ * Get the discovery catalog for packs.
380
+ */
381
+ async getDiscoveryCatalog() {
382
+ return gateway.request({
383
+ path: "/api/platform/v1/packs/discovery"
384
+ });
385
+ },
386
+ /**
387
+ * Get discovery details for a specific pack.
388
+ */
389
+ async getDiscoveryDetail(packKey) {
390
+ return gateway.request({
391
+ path: `/api/platform/v1/packs/discovery/${encodeURIComponent(packKey)}`
392
+ });
393
+ },
394
+ /**
395
+ * List pack states for the current scope.
396
+ */
397
+ async listStates(query = {}) {
398
+ return gateway.request({
399
+ path: `/api/platform/v1/packs/states${toQueryString(query)}`
400
+ }).then(
401
+ (response) => mapGatewayData(
402
+ response,
403
+ (data) => createListResult(Array.isArray(data) ? data : [], "states")
404
+ )
405
+ );
406
+ },
407
+ /**
408
+ * @deprecated Use listStates.
409
+ */
410
+ async getStates(query = {}) {
411
+ return this.listStates(query);
412
+ },
413
+ /**
414
+ * Get health details for a pack.
415
+ */
416
+ async getHealth(packKey, query = {}) {
417
+ return gateway.request({
418
+ path: `/api/platform/v1/packs/${encodeURIComponent(packKey)}/health${toQueryString(
419
+ query
420
+ )}`
421
+ });
422
+ },
423
+ /**
424
+ * List pack telemetry entries.
425
+ */
426
+ async listTelemetry(query = {}) {
427
+ return gateway.request({
428
+ path: `/api/platform/v1/packs/telemetry${toQueryString(query)}`
429
+ }).then(
430
+ (response) => mapGatewayData(
431
+ response,
432
+ (data) => createListResult(Array.isArray(data) ? data : [], "telemetry")
433
+ )
434
+ );
435
+ },
436
+ /**
437
+ * @deprecated Use listTelemetry.
438
+ */
439
+ async getTelemetry(query = {}) {
440
+ return this.listTelemetry(query);
441
+ },
442
+ /**
443
+ * Create a pack entitlement.
444
+ */
445
+ async createEntitlement(input, idempotencyKey) {
446
+ return gateway.request({
447
+ path: "/api/platform/v1/packs/entitlements",
448
+ method: "POST",
449
+ body: input,
450
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
451
+ });
452
+ },
453
+ /**
454
+ * Update a pack entitlement.
455
+ */
456
+ async updateEntitlement(input, idempotencyKey) {
457
+ return this.createEntitlement(input, idempotencyKey);
458
+ },
459
+ /**
460
+ * @deprecated Use createEntitlement or updateEntitlement.
461
+ */
462
+ async upsertEntitlement(input, idempotencyKey) {
463
+ return this.createEntitlement(input, idempotencyKey);
464
+ },
465
+ /**
466
+ * Install a pack.
467
+ */
468
+ async install(input, idempotencyKey) {
469
+ return gateway.request({
470
+ path: "/api/platform/v1/packs/install",
471
+ method: "POST",
472
+ body: input,
473
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
474
+ });
475
+ },
476
+ /**
477
+ * Enable a pack.
478
+ */
479
+ async enable(input, idempotencyKey) {
480
+ return gateway.request({
481
+ path: "/api/platform/v1/packs/enable",
482
+ method: "POST",
483
+ body: input,
484
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
485
+ });
486
+ },
487
+ /**
488
+ * Disable a pack.
489
+ */
490
+ async disable(input, idempotencyKey) {
491
+ return gateway.request({
492
+ path: "/api/platform/v1/packs/disable",
493
+ method: "POST",
494
+ body: input,
495
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
496
+ });
497
+ },
498
+ /**
499
+ * Uninstall a pack.
500
+ */
501
+ async uninstall(input, idempotencyKey) {
502
+ return gateway.request({
503
+ path: "/api/platform/v1/packs/uninstall",
504
+ method: "POST",
505
+ body: input,
506
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
507
+ });
508
+ },
509
+ /**
510
+ * Upgrade a pack.
511
+ */
512
+ async upgrade(input, idempotencyKey) {
513
+ return gateway.request({
514
+ path: "/api/platform/v1/packs/upgrade",
515
+ method: "POST",
516
+ body: input,
517
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
518
+ });
519
+ }
520
+ };
521
+ }
522
+
523
+ export { LucernApiError, createPacksClient };
524
+ //# sourceMappingURL=packsClient.js.map
525
+ //# sourceMappingURL=packsClient.js.map