@lucern/sdk 0.2.0-alpha.4 → 0.2.0-alpha.5

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 (155) hide show
  1. package/README.md +31 -0
  2. package/dist/.generated +2 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +3 -8894
  5. package/dist/lib/platform/auth/credentials.d.ts +5 -0
  6. package/dist/lib/platform/auth/credentials.js +40 -0
  7. package/dist/lib/platform/sdk/adminClient.d.ts +404 -0
  8. package/dist/lib/platform/sdk/adminClient.js +384 -0
  9. package/dist/lib/platform/sdk/answersClient.d.ts +16 -0
  10. package/dist/lib/platform/sdk/answersClient.js +21 -0
  11. package/dist/{packages/sdk/src → lib/platform/sdk}/audiencesClient.d.ts +6 -0
  12. package/dist/lib/platform/sdk/audiencesClient.js +111 -0
  13. package/dist/{packages/sdk/src → lib/platform/sdk}/auditClient.d.ts +3 -0
  14. package/dist/lib/platform/sdk/auditClient.js +21 -0
  15. package/dist/lib/platform/sdk/beliefsClient.d.ts +157 -0
  16. package/dist/lib/platform/sdk/beliefsClient.js +124 -0
  17. package/dist/{packages/sdk/src → lib/platform/sdk}/client.d.ts +957 -146
  18. package/dist/lib/platform/sdk/client.js +1831 -0
  19. package/dist/lib/platform/sdk/contextClient.d.ts +21 -0
  20. package/dist/lib/platform/sdk/contextClient.js +86 -0
  21. package/dist/{lucern/packages/domain-context/src/context-pack-compiler.d.ts → lib/platform/sdk/contextPackCompiler.d.ts} +2 -3
  22. package/dist/lib/platform/sdk/contextPackCompiler.js +534 -0
  23. package/dist/lib/platform/sdk/contextTypes.d.ts +133 -0
  24. package/dist/lib/platform/sdk/contextTypes.js +1 -0
  25. package/dist/{packages/sdk/src → lib/platform/sdk}/controlObjectOwnership.d.ts +15 -0
  26. package/dist/lib/platform/sdk/controlObjectOwnership.js +220 -0
  27. package/dist/{packages/sdk/src → lib/platform/sdk}/coreClient.d.ts +19 -0
  28. package/dist/lib/platform/sdk/coreClient.js +366 -0
  29. package/dist/{packages/sdk/src → lib/platform/sdk}/customTools.d.ts +21 -3
  30. package/dist/lib/platform/sdk/customTools.js +247 -0
  31. package/dist/{packages/sdk/src → lib/platform/sdk}/decisionsClient.d.ts +9 -0
  32. package/dist/lib/platform/sdk/decisionsClient.js +129 -0
  33. package/dist/lib/platform/sdk/domainContext.d.ts +1 -0
  34. package/dist/lib/platform/sdk/domainContext.js +1 -0
  35. package/dist/{lucern/packages/events/src/types.d.ts → lib/platform/sdk/events.d.ts} +25 -0
  36. package/dist/lib/platform/sdk/events.js +261 -0
  37. package/dist/lib/platform/sdk/gatewayFacades.d.ts +586 -0
  38. package/dist/lib/platform/sdk/gatewayFacades.js +845 -0
  39. package/dist/{packages/sdk/src → lib/platform/sdk}/graphClient.d.ts +75 -0
  40. package/dist/lib/platform/sdk/graphClient.js +235 -0
  41. package/dist/{packages/sdk/src → lib/platform/sdk}/harnessClient.d.ts +90 -1
  42. package/dist/lib/platform/sdk/harnessClient.js +219 -0
  43. package/dist/{packages/sdk/src → lib/platform/sdk}/identityClient.d.ts +45 -15
  44. package/dist/lib/platform/sdk/identityClient.js +131 -0
  45. package/dist/{packages/sdk/src → lib/platform/sdk}/index.d.ts +21 -3
  46. package/dist/lib/platform/sdk/index.js +46 -0
  47. package/dist/{packages/sdk/src → lib/platform/sdk}/learningClient.d.ts +3 -0
  48. package/dist/lib/platform/sdk/learningClient.js +53 -0
  49. package/dist/{packages/sdk/src → lib/platform/sdk}/mcpParityClient.d.ts +1 -0
  50. package/dist/lib/platform/sdk/mcpParityClient.js +196 -0
  51. package/dist/{packages/sdk/src → lib/platform/sdk}/mcpParitySurface.d.ts +2 -0
  52. package/dist/lib/platform/sdk/mcpParitySurface.js +57 -0
  53. package/dist/{packages/sdk/src → lib/platform/sdk}/ontologyClient.d.ts +16 -0
  54. package/dist/lib/platform/sdk/ontologyClient.js +161 -0
  55. package/dist/lib/platform/sdk/packRuntime.d.ts +1 -0
  56. package/dist/lib/platform/sdk/packRuntime.js +1 -0
  57. package/dist/{packages/sdk/src → lib/platform/sdk}/packsClient.d.ts +25 -0
  58. package/dist/lib/platform/sdk/packsClient.js +157 -0
  59. package/dist/{packages/sdk/src → lib/platform/sdk}/policyClient.d.ts +90 -1
  60. package/dist/lib/platform/sdk/policyClient.js +277 -0
  61. package/dist/lib/platform/sdk/promptCatalog.d.ts +1 -0
  62. package/dist/lib/platform/sdk/promptCatalog.js +1 -0
  63. package/dist/{packages/sdk/src → lib/platform/sdk}/reportsClient.d.ts +3 -0
  64. package/dist/lib/platform/sdk/reportsClient.js +64 -0
  65. package/dist/{packages/sdk/src → lib/platform/sdk}/schemaClient.d.ts +5 -0
  66. package/dist/lib/platform/sdk/schemaClient.js +71 -0
  67. package/dist/{packages/sdk/src → lib/platform/sdk}/sdkSurface.d.ts +1 -0
  68. package/dist/lib/platform/sdk/sdkSurface.js +140 -0
  69. package/dist/{packages/sdk/src → lib/platform/sdk}/topicsClient.d.ts +33 -0
  70. package/dist/lib/platform/sdk/topicsClient.js +118 -0
  71. package/dist/{packages/sdk/src → lib/platform/sdk}/types.d.ts +224 -2
  72. package/dist/lib/platform/sdk/types.js +1 -0
  73. package/dist/lib/platform/sdk/version.js +2 -0
  74. package/dist/{packages/sdk/src → lib/platform/sdk}/workflowClient.d.ts +63 -2
  75. package/dist/lib/platform/sdk/workflowClient.js +366 -0
  76. package/dist/lucern/contracts/src/api-enums.contract.d.ts +58 -0
  77. package/dist/lucern/contracts/src/api-enums.contract.js +147 -0
  78. package/dist/lucern/contracts/src/lens-filter.contract.js +95 -0
  79. package/dist/lucern/contracts/src/lens-workflow.contract.js +54 -0
  80. package/dist/lucern/contracts/src/mcp-tools.contract.js +3281 -0
  81. package/package.json +17 -3
  82. package/dist/index.js.map +0 -1
  83. package/dist/lucern/contracts/src/auth-session.contract.d.ts +0 -53
  84. package/dist/lucern/contracts/src/context-pack.contract.d.ts +0 -494
  85. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
  86. package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +0 -119
  87. package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +0 -18
  88. package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +0 -78
  89. package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +0 -53
  90. package/dist/lucern/packages/client-core/src/beliefs.d.ts +0 -30
  91. package/dist/lucern/packages/client-core/src/context.d.ts +0 -29
  92. package/dist/lucern/packages/client-core/src/contradictions.d.ts +0 -11
  93. package/dist/lucern/packages/client-core/src/edges.d.ts +0 -11
  94. package/dist/lucern/packages/client-core/src/events.d.ts +0 -9
  95. package/dist/lucern/packages/client-core/src/evidence.d.ts +0 -21
  96. package/dist/lucern/packages/client-core/src/graph.d.ts +0 -17
  97. package/dist/lucern/packages/client-core/src/identity.d.ts +0 -7
  98. package/dist/lucern/packages/client-core/src/ids.d.ts +0 -7
  99. package/dist/lucern/packages/client-core/src/ontologies.d.ts +0 -13
  100. package/dist/lucern/packages/client-core/src/questions.d.ts +0 -39
  101. package/dist/lucern/packages/client-core/src/search.d.ts +0 -7
  102. package/dist/lucern/packages/client-core/src/tasks.d.ts +0 -13
  103. package/dist/lucern/packages/client-core/src/topics.d.ts +0 -17
  104. package/dist/lucern/packages/client-core/src/webhooks.d.ts +0 -35
  105. package/dist/lucern/packages/client-core/src/worktrees.d.ts +0 -17
  106. package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +0 -283
  107. package/dist/lucern/packages/domain-beliefs/src/index.d.ts +0 -1
  108. package/dist/lucern/packages/domain-context/src/compile.d.ts +0 -11
  109. package/dist/lucern/packages/domain-context/src/index.d.ts +0 -4
  110. package/dist/lucern/packages/domain-context/src/ports.d.ts +0 -58
  111. package/dist/lucern/packages/domain-context/src/public-types.d.ts +0 -1
  112. package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +0 -59
  113. package/dist/lucern/packages/domain-edges/src/edges.d.ts +0 -91
  114. package/dist/lucern/packages/domain-edges/src/index.d.ts +0 -2
  115. package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +0 -115
  116. package/dist/lucern/packages/domain-evidence/src/index.d.ts +0 -1
  117. package/dist/lucern/packages/domain-graph/src/graph.d.ts +0 -150
  118. package/dist/lucern/packages/domain-identity/src/index.d.ts +0 -1
  119. package/dist/lucern/packages/domain-identity/src/whoami.d.ts +0 -13
  120. package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +0 -123
  121. package/dist/lucern/packages/domain-questions/src/index.d.ts +0 -1
  122. package/dist/lucern/packages/domain-questions/src/questions.d.ts +0 -147
  123. package/dist/lucern/packages/domain-search/src/search.d.ts +0 -97
  124. package/dist/lucern/packages/domain-tasks/src/index.d.ts +0 -1
  125. package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +0 -102
  126. package/dist/lucern/packages/domain-topics/src/index.d.ts +0 -1
  127. package/dist/lucern/packages/domain-topics/src/topics.d.ts +0 -147
  128. package/dist/lucern/packages/domain-worktrees/src/index.d.ts +0 -1
  129. package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +0 -185
  130. package/dist/lucern/packages/events/src/index.d.ts +0 -4
  131. package/dist/lucern/packages/events/src/matching.d.ts +0 -3
  132. package/dist/lucern/packages/events/src/outbox.d.ts +0 -15
  133. package/dist/lucern/packages/events/src/webhooks.d.ts +0 -9
  134. package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +0 -15
  135. package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +0 -12
  136. package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +0 -7
  137. package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +0 -7
  138. package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +0 -6
  139. package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +0 -21
  140. package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +0 -10
  141. package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +0 -5
  142. package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +0 -8
  143. package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +0 -39
  144. package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +0 -5
  145. package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +0 -8
  146. package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +0 -10
  147. package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +0 -16
  148. package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +0 -10
  149. package/dist/lucern/packages/sdk-typescript/src/index.d.ts +0 -28
  150. package/dist/packages/sdk/src/adminClient.d.ts +0 -89
  151. package/dist/packages/sdk/src/answersClient.d.ts +0 -5
  152. package/dist/packages/sdk/src/beliefsClient.d.ts +0 -52
  153. package/dist/packages/sdk/src/contextClient.d.ts +0 -9
  154. package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +0 -79
  155. /package/dist/{packages/sdk/src → lib/platform/sdk}/version.d.ts +0 -0
@@ -0,0 +1,157 @@
1
+ import { createGatewayRequestClient, LucernApiError, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
2
+ import { createListResult, mapGatewayData } from "./sdkSurface.js";
3
+ export { LucernApiError };
4
+ /**
5
+ * Create the packs client for pack catalog, state, and entitlement operations.
6
+ * @param config - Gateway transport configuration.
7
+ * @returns An object with methods to manage pack lifecycle, telemetry, and entitlements.
8
+ */
9
+ export function createPacksClient(config = {}) {
10
+ const gateway = createGatewayRequestClient(config);
11
+ return {
12
+ /**
13
+ * List catalog entries for available packs.
14
+ */
15
+ async listCatalog() {
16
+ return gateway.request({
17
+ path: "/api/platform/v1/packs/catalog",
18
+ }).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "catalog")));
19
+ },
20
+ /**
21
+ * @deprecated Use listCatalog.
22
+ */
23
+ async getCatalog() {
24
+ return this.listCatalog();
25
+ },
26
+ /**
27
+ * Get the discovery catalog for packs.
28
+ */
29
+ async getDiscoveryCatalog() {
30
+ return gateway.request({
31
+ path: "/api/platform/v1/packs/discovery",
32
+ });
33
+ },
34
+ /**
35
+ * Get discovery details for a specific pack.
36
+ */
37
+ async getDiscoveryDetail(packKey) {
38
+ return gateway.request({
39
+ path: `/api/platform/v1/packs/discovery/${encodeURIComponent(packKey)}`,
40
+ });
41
+ },
42
+ /**
43
+ * List pack states for the current scope.
44
+ */
45
+ async listStates(query = {}) {
46
+ return gateway.request({
47
+ path: `/api/platform/v1/packs/states${toQueryString(query)}`,
48
+ }).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "states")));
49
+ },
50
+ /**
51
+ * @deprecated Use listStates.
52
+ */
53
+ async getStates(query = {}) {
54
+ return this.listStates(query);
55
+ },
56
+ /**
57
+ * Get health details for a pack.
58
+ */
59
+ async getHealth(packKey, query = {}) {
60
+ return gateway.request({
61
+ path: `/api/platform/v1/packs/${encodeURIComponent(packKey)}/health${toQueryString(query)}`,
62
+ });
63
+ },
64
+ /**
65
+ * List pack telemetry entries.
66
+ */
67
+ async listTelemetry(query = {}) {
68
+ return gateway.request({
69
+ path: `/api/platform/v1/packs/telemetry${toQueryString(query)}`,
70
+ }).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "telemetry")));
71
+ },
72
+ /**
73
+ * @deprecated Use listTelemetry.
74
+ */
75
+ async getTelemetry(query = {}) {
76
+ return this.listTelemetry(query);
77
+ },
78
+ /**
79
+ * Create a pack entitlement.
80
+ */
81
+ async createEntitlement(input, idempotencyKey) {
82
+ return gateway.request({
83
+ path: "/api/platform/v1/packs/entitlements",
84
+ method: "POST",
85
+ body: input,
86
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
87
+ });
88
+ },
89
+ /**
90
+ * Update a pack entitlement.
91
+ */
92
+ async updateEntitlement(input, idempotencyKey) {
93
+ return this.createEntitlement(input, idempotencyKey);
94
+ },
95
+ /**
96
+ * @deprecated Use createEntitlement or updateEntitlement.
97
+ */
98
+ async upsertEntitlement(input, idempotencyKey) {
99
+ return this.createEntitlement(input, idempotencyKey);
100
+ },
101
+ /**
102
+ * Install a pack.
103
+ */
104
+ async install(input, idempotencyKey) {
105
+ return gateway.request({
106
+ path: "/api/platform/v1/packs/install",
107
+ method: "POST",
108
+ body: input,
109
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
110
+ });
111
+ },
112
+ /**
113
+ * Enable a pack.
114
+ */
115
+ async enable(input, idempotencyKey) {
116
+ return gateway.request({
117
+ path: "/api/platform/v1/packs/enable",
118
+ method: "POST",
119
+ body: input,
120
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
121
+ });
122
+ },
123
+ /**
124
+ * Disable a pack.
125
+ */
126
+ async disable(input, idempotencyKey) {
127
+ return gateway.request({
128
+ path: "/api/platform/v1/packs/disable",
129
+ method: "POST",
130
+ body: input,
131
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
132
+ });
133
+ },
134
+ /**
135
+ * Uninstall a pack.
136
+ */
137
+ async uninstall(input, idempotencyKey) {
138
+ return gateway.request({
139
+ path: "/api/platform/v1/packs/uninstall",
140
+ method: "POST",
141
+ body: input,
142
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
143
+ });
144
+ },
145
+ /**
146
+ * Upgrade a pack.
147
+ */
148
+ async upgrade(input, idempotencyKey) {
149
+ return gateway.request({
150
+ path: "/api/platform/v1/packs/upgrade",
151
+ method: "POST",
152
+ body: input,
153
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
154
+ });
155
+ },
156
+ };
157
+ }
@@ -1,8 +1,11 @@
1
1
  import { type GatewayClientConfig, type GatewayScope, LucernApiError } from "./coreClient";
2
2
  export { LucernApiError };
3
3
  export type { GatewayScope, PlatformGatewaySuccess } from "./coreClient";
4
+ /** Configuration for the policy client. */
4
5
  export type PolicyClientConfig = GatewayClientConfig;
6
+ /** Permission direction: read access or write access. */
5
7
  export type PermissionKind = "read" | "write";
8
+ /** Permission level for a write policy rule. */
6
9
  export type WritePolicyPermission = "allow" | "deny" | "review_required";
7
10
  type TopicRecord = {
8
11
  topicId?: string;
@@ -11,6 +14,7 @@ type TopicRecord = {
11
14
  isOwner?: boolean;
12
15
  [key: string]: unknown;
13
16
  };
17
+ /** Structured explanation of how a policy decision was derived. */
14
18
  export type PolicyDecisionExplanation = {
15
19
  summary?: string;
16
20
  matchedReasonCode?: string;
@@ -22,6 +26,7 @@ export type PolicyDecisionExplanation = {
22
26
  }>;
23
27
  [key: string]: unknown;
24
28
  };
29
+ /** Result of a permission check against the policy engine. */
25
30
  export type PermissionDecision = {
26
31
  allowed?: boolean;
27
32
  decision?: string;
@@ -33,6 +38,7 @@ export type PermissionDecision = {
33
38
  traceId?: string | null;
34
39
  explanation?: PolicyDecisionExplanation;
35
40
  };
41
+ /** A persisted write policy rule controlling mutation access. */
36
42
  export type WritePolicyRecord = {
37
43
  id?: string;
38
44
  topicId?: string;
@@ -48,6 +54,7 @@ export type WritePolicyRecord = {
48
54
  resolution?: string;
49
55
  [key: string]: unknown;
50
56
  };
57
+ /** Input for creating a write policy rule. */
51
58
  export type WritePolicyCreateInput = GatewayScope & {
52
59
  topicId?: string;
53
60
  role: string;
@@ -58,6 +65,7 @@ export type WritePolicyCreateInput = GatewayScope & {
58
65
  rationale?: string;
59
66
  createdBy?: string;
60
67
  };
68
+ /** Input for partially updating an existing write policy rule. */
61
69
  export type WritePolicyUpdateInput = GatewayScope & {
62
70
  topicId?: string;
63
71
  clearTopicId?: boolean;
@@ -70,8 +78,27 @@ export type WritePolicyUpdateInput = GatewayScope & {
70
78
  rationale?: string;
71
79
  clearRationale?: boolean;
72
80
  };
81
+ export type TenantPolicyPermission = {
82
+ resource: string;
83
+ actions: string[];
84
+ };
85
+ export type TenantPolicyRecord = {
86
+ id?: string;
87
+ tenantId: string;
88
+ workspaceId?: string;
89
+ roleName: string;
90
+ description?: string;
91
+ permissions: TenantPolicyPermission[];
92
+ groupBindings: string[];
93
+ createdAt?: number;
94
+ updatedAt?: number;
95
+ createdBy?: string;
96
+ updatedBy?: string;
97
+ };
73
98
  /**
74
- * Create the policy client for permission checks and grants.
99
+ * Create the policy client for permission checks, grants, and write policies.
100
+ * @param config - Gateway transport configuration.
101
+ * @returns An object with methods to check permissions, manage grants, and manage write policies.
75
102
  */
76
103
  export declare function createPolicyClient(config?: PolicyClientConfig): {
77
104
  /**
@@ -107,6 +134,9 @@ export declare function createPolicyClient(config?: PolicyClientConfig): {
107
134
  groupId?: string;
108
135
  beliefClusterId?: string;
109
136
  }, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
137
+ /**
138
+ * List write policy rules for the current scope.
139
+ */
110
140
  listWritePolicies(query?: GatewayScope & {
111
141
  topicId?: string;
112
142
  role?: string;
@@ -121,6 +151,9 @@ export declare function createPolicyClient(config?: PolicyClientConfig): {
121
151
  policyTraceId: string | null;
122
152
  idempotentReplay: boolean;
123
153
  }>;
154
+ /**
155
+ * Create a write policy rule.
156
+ */
124
157
  createWritePolicy(input: WritePolicyCreateInput, idempotencyKey?: string): Promise<{
125
158
  data: {
126
159
  id: string | undefined;
@@ -132,6 +165,9 @@ export declare function createPolicyClient(config?: PolicyClientConfig): {
132
165
  policyTraceId: string | null;
133
166
  idempotentReplay: boolean;
134
167
  }>;
168
+ /**
169
+ * Update an existing write policy rule by identifier.
170
+ */
135
171
  updateWritePolicy(id: string, input: WritePolicyUpdateInput, idempotencyKey?: string): Promise<{
136
172
  data: {
137
173
  id: string | undefined;
@@ -143,10 +179,63 @@ export declare function createPolicyClient(config?: PolicyClientConfig): {
143
179
  policyTraceId: string | null;
144
180
  idempotentReplay: boolean;
145
181
  }>;
182
+ /**
183
+ * Delete a write policy rule by identifier.
184
+ */
146
185
  deleteWritePolicy(id: string, scope?: GatewayScope, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<{
147
186
  id?: string;
148
187
  deleted?: boolean;
149
188
  }>>;
189
+ /**
190
+ * List tenant role policies for the current scope.
191
+ */
192
+ listRolePolicies(query?: GatewayScope): Promise<{
193
+ data: {
194
+ policies: TenantPolicyRecord[];
195
+ };
196
+ success: true;
197
+ correlationId: string;
198
+ policyTraceId: string | null;
199
+ idempotentReplay: boolean;
200
+ }>;
201
+ /**
202
+ * Create a tenant role policy.
203
+ */
204
+ createRolePolicy(input: GatewayScope & {
205
+ roleName: string;
206
+ description?: string;
207
+ permissions: TenantPolicyPermission[];
208
+ groupBindings?: string[];
209
+ }, idempotencyKey?: string): Promise<{
210
+ data: {
211
+ policy: TenantPolicyRecord | null;
212
+ };
213
+ success: true;
214
+ correlationId: string;
215
+ policyTraceId: string | null;
216
+ idempotentReplay: boolean;
217
+ }>;
218
+ /**
219
+ * Update a tenant role policy by identifier.
220
+ */
221
+ updateRolePolicy(id: string, input: GatewayScope & {
222
+ roleName: string;
223
+ description?: string;
224
+ permissions: TenantPolicyPermission[];
225
+ groupBindings?: string[];
226
+ }, idempotencyKey?: string): Promise<{
227
+ data: {
228
+ policy: TenantPolicyRecord | null;
229
+ };
230
+ success: true;
231
+ correlationId: string;
232
+ policyTraceId: string | null;
233
+ idempotentReplay: boolean;
234
+ }>;
235
+ /**
236
+ * Delete a tenant role policy by identifier.
237
+ */
238
+ deleteRolePolicy(id: string, scope?: GatewayScope, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
150
239
  /**
151
240
  * Check a permission decision for a topic or project scope.
152
241
  */
@@ -0,0 +1,277 @@
1
+ import { createGatewayRequestClient, LucernApiError, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
2
+ import { createListResult, mapGatewayData } from "./sdkSurface.js";
3
+ export { LucernApiError };
4
+ function asTopicArray(data) {
5
+ if (Array.isArray(data)) {
6
+ return data.filter((row) => Boolean(row) && typeof row === "object");
7
+ }
8
+ return [];
9
+ }
10
+ function asWritePolicyRecord(data) {
11
+ if (!data || typeof data !== "object") {
12
+ return null;
13
+ }
14
+ return data;
15
+ }
16
+ function asWritePolicyArray(data) {
17
+ if (!Array.isArray(data)) {
18
+ return [];
19
+ }
20
+ return data
21
+ .map(asWritePolicyRecord)
22
+ .filter((row) => Boolean(row));
23
+ }
24
+ function asRolePolicyRecord(data) {
25
+ if (!data || typeof data !== "object") {
26
+ return null;
27
+ }
28
+ return data;
29
+ }
30
+ function asRolePolicyArray(data) {
31
+ if (!Array.isArray(data)) {
32
+ return [];
33
+ }
34
+ return data
35
+ .map(asRolePolicyRecord)
36
+ .filter((row) => Boolean(row));
37
+ }
38
+ /**
39
+ * Create the policy client for permission checks, grants, and write policies.
40
+ * @param config - Gateway transport configuration.
41
+ * @returns An object with methods to check permissions, manage grants, and manage write policies.
42
+ */
43
+ export function createPolicyClient(config = {}) {
44
+ const gateway = createGatewayRequestClient(config);
45
+ return {
46
+ /**
47
+ * List policy decisions in the current scope.
48
+ */
49
+ async listDecisions(query = {}) {
50
+ return gateway.request({
51
+ path: `/api/platform/v1/policy/decisions${toQueryString(query)}`,
52
+ }).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "decisions")));
53
+ },
54
+ /**
55
+ * Create a permission grant.
56
+ */
57
+ async grant(input, idempotencyKey) {
58
+ return gateway.request({
59
+ path: "/api/platform/v1/policy/grant",
60
+ method: "POST",
61
+ body: input,
62
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
63
+ });
64
+ },
65
+ /**
66
+ * Delete a permission grant by revoking it.
67
+ */
68
+ async revoke(input, idempotencyKey) {
69
+ return gateway.request({
70
+ path: "/api/platform/v1/policy/revoke",
71
+ method: "POST",
72
+ body: input,
73
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
74
+ });
75
+ },
76
+ /**
77
+ * List write policy rules for the current scope.
78
+ */
79
+ async listWritePolicies(query = {}) {
80
+ const response = await gateway.request({
81
+ path: `/api/platform/v1/policy/write-policies${toQueryString(query)}`,
82
+ });
83
+ const rawPolicies = response.data && typeof response.data === "object"
84
+ ? response.data.policies
85
+ : response.data;
86
+ return {
87
+ ...response,
88
+ data: {
89
+ policies: asWritePolicyArray(rawPolicies),
90
+ },
91
+ };
92
+ },
93
+ /**
94
+ * Create a write policy rule.
95
+ */
96
+ async createWritePolicy(input, idempotencyKey) {
97
+ const response = await gateway.request({
98
+ path: "/api/platform/v1/policy/write-policies",
99
+ method: "POST",
100
+ body: input,
101
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
102
+ });
103
+ return {
104
+ ...response,
105
+ data: {
106
+ id: typeof response.data?.id === "string" ? response.data.id : undefined,
107
+ created: response.data?.created === true,
108
+ policy: asWritePolicyRecord(response.data?.policy),
109
+ },
110
+ };
111
+ },
112
+ /**
113
+ * Update an existing write policy rule by identifier.
114
+ */
115
+ async updateWritePolicy(id, input, idempotencyKey) {
116
+ const response = await gateway.request({
117
+ path: `/api/platform/v1/policy/write-policies/${encodeURIComponent(id)}`,
118
+ method: "PATCH",
119
+ body: input,
120
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
121
+ });
122
+ return {
123
+ ...response,
124
+ data: {
125
+ id: typeof response.data?.id === "string" ? response.data.id : undefined,
126
+ updated: response.data?.updated === true,
127
+ policy: asWritePolicyRecord(response.data?.policy),
128
+ },
129
+ };
130
+ },
131
+ /**
132
+ * Delete a write policy rule by identifier.
133
+ */
134
+ async deleteWritePolicy(id, scope = {}, idempotencyKey) {
135
+ return gateway.request({
136
+ path: `/api/platform/v1/policy/write-policies/${encodeURIComponent(id)}${toQueryString(scope)}`,
137
+ method: "DELETE",
138
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
139
+ });
140
+ },
141
+ /**
142
+ * List tenant role policies for the current scope.
143
+ */
144
+ async listRolePolicies(query = {}) {
145
+ const response = await gateway.request({
146
+ path: `/api/platform/v1/policy/roles${toQueryString(query)}`,
147
+ });
148
+ return {
149
+ ...response,
150
+ data: {
151
+ policies: asRolePolicyArray(response.data?.policies),
152
+ },
153
+ };
154
+ },
155
+ /**
156
+ * Create a tenant role policy.
157
+ */
158
+ async createRolePolicy(input, idempotencyKey) {
159
+ const response = await gateway.request({
160
+ path: "/api/platform/v1/policy/roles",
161
+ method: "POST",
162
+ body: input,
163
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
164
+ });
165
+ return {
166
+ ...response,
167
+ data: {
168
+ policy: asRolePolicyRecord(response.data?.policy),
169
+ },
170
+ };
171
+ },
172
+ /**
173
+ * Update a tenant role policy by identifier.
174
+ */
175
+ async updateRolePolicy(id, input, idempotencyKey) {
176
+ const response = await gateway.request({
177
+ path: `/api/platform/v1/policy/roles/${encodeURIComponent(id)}`,
178
+ method: "PATCH",
179
+ body: input,
180
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
181
+ });
182
+ return {
183
+ ...response,
184
+ data: {
185
+ policy: asRolePolicyRecord(response.data?.policy),
186
+ },
187
+ };
188
+ },
189
+ /**
190
+ * Delete a tenant role policy by identifier.
191
+ */
192
+ async deleteRolePolicy(id, scope = {}, idempotencyKey) {
193
+ return gateway.request({
194
+ path: `/api/platform/v1/policy/roles/${encodeURIComponent(id)}${toQueryString(scope)}`,
195
+ method: "DELETE",
196
+ idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
197
+ });
198
+ },
199
+ /**
200
+ * Check a permission decision for a topic or project scope.
201
+ */
202
+ async checkPermission(query) {
203
+ if (!query.topicId) {
204
+ throw new Error("topicId is required");
205
+ }
206
+ return gateway.request({
207
+ path: `/api/platform/v1/policy/check${toQueryString(query)}`,
208
+ });
209
+ },
210
+ /**
211
+ * List accessible topics for a principal.
212
+ */
213
+ async listAccessibleTopics(query = {}) {
214
+ const permission = query.permission ?? "read";
215
+ const principal = query.principal ?? query.principalId;
216
+ const response = await gateway.request({
217
+ path: `/api/platform/v1/policy/topics${toQueryString({
218
+ tenantId: query.tenantId,
219
+ workspaceId: query.workspaceId,
220
+ permission,
221
+ includeShared: query.includeShared,
222
+ principal,
223
+ limit: query.limit,
224
+ })}`,
225
+ });
226
+ return {
227
+ ...response,
228
+ data: {
229
+ permission,
230
+ topics: asTopicArray(response.data?.topics),
231
+ total: typeof response.data?.total === "number"
232
+ ? response.data.total
233
+ : asTopicArray(response.data?.topics).length,
234
+ deniedTopics: Array.isArray(response.data?.deniedTopics)
235
+ ? response.data.deniedTopics
236
+ : [],
237
+ },
238
+ };
239
+ },
240
+ /**
241
+ * Filter topic identifiers by permission.
242
+ */
243
+ async filterByPermission(input) {
244
+ const permission = input.permission ?? "read";
245
+ const principal = input.principal ?? input.principalId;
246
+ const uniqueTopicIds = [...new Set(input.topicIds ?? [])].filter((topicId) => typeof topicId === "string" && topicId.trim().length > 0);
247
+ const response = await gateway.request({
248
+ path: "/api/platform/v1/policy/filter",
249
+ method: "POST",
250
+ body: {
251
+ tenantId: input.tenantId,
252
+ workspaceId: input.workspaceId,
253
+ topicIds: uniqueTopicIds,
254
+ permission,
255
+ principal,
256
+ },
257
+ });
258
+ const allowedTopicIds = Array.isArray(response.data?.allowedTopicIds)
259
+ ? response.data.allowedTopicIds
260
+ : [];
261
+ const deniedTopics = Array.isArray(response.data?.deniedTopics)
262
+ ? response.data.deniedTopics
263
+ : [];
264
+ return {
265
+ success: true,
266
+ data: {
267
+ permission,
268
+ allowedTopicIds,
269
+ deniedTopics,
270
+ count: typeof response.data?.count === "number"
271
+ ? response.data.count
272
+ : allowedTopicIds.length,
273
+ },
274
+ };
275
+ },
276
+ };
277
+ }
@@ -0,0 +1 @@
1
+ export { getPromptCatalogSnapshot } from "../../../lib/langfuse/prompt-catalog";
@@ -0,0 +1 @@
1
+ export { getPromptCatalogSnapshot } from "../../../lib/langfuse/prompt-catalog.js";
@@ -1,9 +1,12 @@
1
1
  import { type GatewayClientConfig } from "./coreClient";
2
2
  import type { TopicIdentifierInput, ReportTemplatesResponse, ReportWithSectionsResponse } from "./types";
3
+ /** Configuration for the reports client. */
3
4
  export type ReportsClientConfig = GatewayClientConfig;
4
5
  export type { ProjectReportsResponse, ReportTemplatesResponse, ReportWithSectionsResponse, } from "./types";
5
6
  /**
6
7
  * Create the reports client for report templates and generated reports.
8
+ * @param config - Gateway transport configuration.
9
+ * @returns An object with methods to list templates, list reports, and get a report.
7
10
  */
8
11
  export declare function createReportsClient(config?: ReportsClientConfig): {
9
12
  /**
@@ -0,0 +1,64 @@
1
+ import { createGatewayRequestClient, toQueryString, } from "./coreClient.js";
2
+ import { createListResult, mapGatewayData, resolveTopicId } from "./sdkSurface.js";
3
+ /**
4
+ * Create the reports client for report templates and generated reports.
5
+ * @param config - Gateway transport configuration.
6
+ * @returns An object with methods to list templates, list reports, and get a report.
7
+ */
8
+ export function createReportsClient(config = {}) {
9
+ const gateway = createGatewayRequestClient(config);
10
+ return {
11
+ /**
12
+ * List report templates.
13
+ */
14
+ async listTemplates(args = {}) {
15
+ return gateway.request({
16
+ path: `/api/platform/v1/reports/templates${toQueryString({
17
+ slug: args.slug,
18
+ })}`,
19
+ }).then((response) => mapGatewayData(response, (data) => {
20
+ const record = data && typeof data === "object"
21
+ ? data
22
+ : {};
23
+ const rows = Array.isArray(data)
24
+ ? data
25
+ : Array.isArray(record.templates)
26
+ ? record.templates
27
+ : [];
28
+ return createListResult(rows, "templates");
29
+ }));
30
+ },
31
+ /**
32
+ * @deprecated Use listTemplates.
33
+ */
34
+ async getTemplates(args = {}) {
35
+ return this.listTemplates(args);
36
+ },
37
+ /**
38
+ * List reports for a topic scope.
39
+ */
40
+ async listReports(input, args = {}) {
41
+ const topicId = resolveTopicId(input);
42
+ if (!topicId) {
43
+ throw new Error("topicId is required");
44
+ }
45
+ return gateway.request({
46
+ path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString({
47
+ summary: typeof args.summary === "boolean"
48
+ ? args.summary
49
+ ? "true"
50
+ : "false"
51
+ : undefined,
52
+ })}`,
53
+ }).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "reports")));
54
+ },
55
+ /**
56
+ * Get a generated report.
57
+ */
58
+ async getReport(reportId) {
59
+ return gateway.request({
60
+ path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`,
61
+ });
62
+ },
63
+ };
64
+ }