@lucern/sdk 0.2.0-alpha.7 → 0.2.0-alpha.9

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 (257) hide show
  1. package/dist/adminClient.d.ts +409 -0
  2. package/dist/adminClient.js +755 -0
  3. package/dist/adminClient.js.map +1 -0
  4. package/dist/answersClient.d.ts +23 -0
  5. package/dist/answersClient.js +333 -0
  6. package/dist/answersClient.js.map +1 -0
  7. package/dist/audiencesClient.d.ts +99 -0
  8. package/dist/audiencesClient.js +472 -0
  9. package/dist/audiencesClient.js.map +1 -0
  10. package/dist/auditClient.d.ts +29 -0
  11. package/dist/auditClient.js +386 -0
  12. package/dist/auditClient.js.map +1 -0
  13. package/dist/beliefsClient.d.ts +162 -0
  14. package/dist/beliefsClient.js +477 -0
  15. package/dist/beliefsClient.js.map +1 -0
  16. package/dist/client.d.ts +2378 -0
  17. package/dist/client.js +6134 -0
  18. package/dist/client.js.map +1 -0
  19. package/dist/contextClient.d.ts +27 -0
  20. package/dist/contextClient.js +396 -0
  21. package/dist/contextClient.js.map +1 -0
  22. package/dist/contextFacade.d.ts +2 -0
  23. package/dist/contextFacade.js +73 -0
  24. package/dist/contextFacade.js.map +1 -0
  25. package/dist/contextPackCompiler.d.ts +102 -0
  26. package/dist/contextPackCompiler.js +1091 -0
  27. package/dist/contextPackCompiler.js.map +1 -0
  28. package/dist/contextPackPolicy.d.ts +84 -0
  29. package/dist/contextPackPolicy.js +347 -0
  30. package/dist/contextPackPolicy.js.map +1 -0
  31. package/dist/contextPackSchema.d.ts +7 -0
  32. package/{src/contextPackSchema.ts → dist/contextPackSchema.js} +22 -70
  33. package/dist/contextPackSchema.js.map +1 -0
  34. package/dist/contextTypes.d.ts +135 -0
  35. package/dist/contextTypes.js +3 -0
  36. package/dist/contextTypes.js.map +1 -0
  37. package/dist/contracts/api-enums.contract.d.ts +81 -0
  38. package/dist/contracts/api-enums.contract.js +92 -0
  39. package/dist/contracts/api-enums.contract.js.map +1 -0
  40. package/dist/contracts/auth-session.contract.d.ts +55 -0
  41. package/dist/contracts/auth-session.contract.js +48 -0
  42. package/dist/contracts/auth-session.contract.js.map +1 -0
  43. package/dist/contracts/context-pack.contract.d.ts +492 -0
  44. package/dist/contracts/context-pack.contract.js +98 -0
  45. package/dist/contracts/context-pack.contract.js.map +1 -0
  46. package/dist/contracts/contextPack.d.ts +1 -0
  47. package/dist/contracts/contextPack.js +98 -0
  48. package/dist/contracts/contextPack.js.map +1 -0
  49. package/dist/contracts/index.d.ts +9 -0
  50. package/dist/contracts/index.js +4892 -0
  51. package/dist/contracts/index.js.map +1 -0
  52. package/dist/contracts/lens-filter.contract.d.ts +72 -0
  53. package/dist/contracts/lens-filter.contract.js +71 -0
  54. package/dist/contracts/lens-filter.contract.js.map +1 -0
  55. package/dist/contracts/lens-workflow.contract.d.ts +87 -0
  56. package/dist/contracts/lens-workflow.contract.js +123 -0
  57. package/dist/contracts/lens-workflow.contract.js.map +1 -0
  58. package/dist/contracts/lensFilter.d.ts +1 -0
  59. package/dist/contracts/lensFilter.js +71 -0
  60. package/dist/contracts/lensFilter.js.map +1 -0
  61. package/dist/contracts/lensWorkflow.d.ts +2 -0
  62. package/dist/contracts/lensWorkflow.js +123 -0
  63. package/dist/contracts/lensWorkflow.js.map +1 -0
  64. package/dist/contracts/mcp-tools.contract.d.ts +1 -0
  65. package/dist/contracts/mcp-tools.contract.js +2986 -0
  66. package/dist/contracts/mcp-tools.contract.js.map +1 -0
  67. package/dist/contracts/mcpTools.d.ts +1 -0
  68. package/dist/contracts/mcpTools.js +2986 -0
  69. package/dist/contracts/mcpTools.js.map +1 -0
  70. package/dist/contracts/prompt.contract.d.ts +26 -0
  71. package/dist/contracts/prompt.contract.js +12 -0
  72. package/dist/contracts/prompt.contract.js.map +1 -0
  73. package/dist/contracts/prompt.d.ts +1 -0
  74. package/dist/contracts/prompt.js +12 -0
  75. package/dist/contracts/prompt.js.map +1 -0
  76. package/dist/contracts/sdk-tools.contract.d.ts +2 -0
  77. package/dist/contracts/sdk-tools.contract.js +4134 -0
  78. package/dist/contracts/sdk-tools.contract.js.map +1 -0
  79. package/dist/contracts/sdkTools.d.ts +2 -0
  80. package/dist/contracts/sdkTools.js +4134 -0
  81. package/dist/contracts/sdkTools.js.map +1 -0
  82. package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
  83. package/dist/contracts/workflow-runtime.contract.js +245 -0
  84. package/dist/contracts/workflow-runtime.contract.js.map +1 -0
  85. package/dist/contracts/workflowRuntime.d.ts +1 -0
  86. package/dist/contracts/workflowRuntime.js +245 -0
  87. package/dist/contracts/workflowRuntime.js.map +1 -0
  88. package/dist/controlObjectOwnership.d.ts +310 -0
  89. package/{src/controlObjectOwnership.ts → dist/controlObjectOwnership.js} +53 -124
  90. package/dist/controlObjectOwnership.js.map +1 -0
  91. package/dist/coreClient.d.ts +144 -0
  92. package/dist/coreClient.js +339 -0
  93. package/dist/coreClient.js.map +1 -0
  94. package/dist/customTools.d.ts +88 -0
  95. package/dist/customTools.js +248 -0
  96. package/dist/customTools.js.map +1 -0
  97. package/dist/decisionsClient.d.ts +111 -0
  98. package/dist/decisionsClient.js +522 -0
  99. package/dist/decisionsClient.js.map +1 -0
  100. package/dist/domainContext.d.ts +1 -0
  101. package/dist/domainContext.js +3 -0
  102. package/dist/domainContext.js.map +1 -0
  103. package/dist/events.d.ts +178 -0
  104. package/dist/events.js +249 -0
  105. package/dist/events.js.map +1 -0
  106. package/dist/eventsCore.d.ts +49 -0
  107. package/dist/eventsCore.js +429 -0
  108. package/dist/eventsCore.js.map +1 -0
  109. package/dist/facade/context.d.ts +18 -0
  110. package/dist/facade/context.js +73 -0
  111. package/dist/facade/context.js.map +1 -0
  112. package/dist/gatewayFacades.d.ts +591 -0
  113. package/dist/gatewayFacades.js +1953 -0
  114. package/dist/gatewayFacades.js.map +1 -0
  115. package/dist/graphClient.d.ts +271 -0
  116. package/dist/graphClient.js +698 -0
  117. package/dist/graphClient.js.map +1 -0
  118. package/dist/harnessClient.d.ts +314 -0
  119. package/dist/harnessClient.js +607 -0
  120. package/dist/harnessClient.js.map +1 -0
  121. package/dist/identityClient.d.ts +140 -0
  122. package/dist/identityClient.js +497 -0
  123. package/dist/identityClient.js.map +1 -0
  124. package/dist/index.d.ts +42 -0
  125. package/dist/index.js +11381 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/learningClient.d.ts +46 -0
  128. package/dist/learningClient.js +409 -0
  129. package/dist/learningClient.js.map +1 -0
  130. package/dist/mcpParityClient.d.ts +74 -0
  131. package/dist/mcpParityClient.js +516 -0
  132. package/dist/mcpParityClient.js.map +1 -0
  133. package/dist/mcpParitySurface.d.ts +12 -0
  134. package/{src/mcpParitySurface.ts → dist/mcpParitySurface.js} +9 -14
  135. package/dist/mcpParitySurface.js.map +1 -0
  136. package/dist/mcpTools-DPZxowDX.d.ts +254 -0
  137. package/dist/ontologyClient.d.ts +137 -0
  138. package/dist/ontologyClient.js +513 -0
  139. package/dist/ontologyClient.js.map +1 -0
  140. package/dist/packRuntime.d.ts +2 -0
  141. package/dist/packRuntime.js +3 -0
  142. package/dist/packRuntime.js.map +1 -0
  143. package/dist/packsClient.d.ts +131 -0
  144. package/dist/packsClient.js +525 -0
  145. package/dist/packsClient.js.map +1 -0
  146. package/dist/policyClient.d.ts +299 -0
  147. package/dist/policyClient.js +625 -0
  148. package/dist/policyClient.js.map +1 -0
  149. package/dist/realtime/index.d.ts +29 -0
  150. package/dist/realtime/index.js +23 -0
  151. package/dist/realtime/index.js.map +1 -0
  152. package/{src/realtime/refs.ts → dist/realtime/refs.d.ts} +5 -5
  153. package/dist/realtime/refs.js +9 -0
  154. package/dist/realtime/refs.js.map +1 -0
  155. package/dist/reportsClient.d.ts +41 -0
  156. package/dist/reportsClient.js +418 -0
  157. package/dist/reportsClient.js.map +1 -0
  158. package/dist/schemaClient.d.ts +64 -0
  159. package/dist/schemaClient.js +434 -0
  160. package/dist/schemaClient.js.map +1 -0
  161. package/dist/sdkSurface.d.ts +61 -0
  162. package/dist/sdkSurface.js +112 -0
  163. package/dist/sdkSurface.js.map +1 -0
  164. package/dist/sdkTools-CwXJDACb.d.ts +150 -0
  165. package/dist/topicsClient.d.ts +84 -0
  166. package/dist/topicsClient.js +492 -0
  167. package/dist/topicsClient.js.map +1 -0
  168. package/dist/types.d.ts +696 -0
  169. package/dist/types.js +3 -0
  170. package/dist/types.js.map +1 -0
  171. package/dist/version.d.ts +4 -0
  172. package/dist/version.js +6 -0
  173. package/dist/version.js.map +1 -0
  174. package/dist/workflowClient.d.ts +316 -0
  175. package/dist/workflowClient.js +830 -0
  176. package/dist/workflowClient.js.map +1 -0
  177. package/package.json +39 -7
  178. package/.turbo/turbo-build.log +0 -7
  179. package/.turbo/turbo-typecheck.log +0 -4
  180. package/examples/README.md +0 -69
  181. package/examples/contradiction.ts +0 -94
  182. package/examples/investigation-context.ts +0 -118
  183. package/examples/questions-and-tasks.ts +0 -55
  184. package/examples/quickstart.ts +0 -97
  185. package/examples/shared.ts +0 -318
  186. package/examples/strict-public-types.ts +0 -143
  187. package/examples/worktree-lifecycle.ts +0 -79
  188. package/src/README.md +0 -6
  189. package/src/adminClient.ts +0 -789
  190. package/src/answersClient.ts +0 -29
  191. package/src/audiencesClient.ts +0 -209
  192. package/src/auditClient.ts +0 -50
  193. package/src/beliefsClient.ts +0 -319
  194. package/src/client.ts +0 -2647
  195. package/src/contextClient.ts +0 -130
  196. package/src/contextFacade.ts +0 -15
  197. package/src/contextPackCompiler.ts +0 -828
  198. package/src/contextTypes.ts +0 -153
  199. package/src/contracts/api-enums.contract.ts +0 -202
  200. package/src/contracts/auth-session.contract.ts +0 -109
  201. package/src/contracts/context-pack.contract.ts +0 -700
  202. package/src/contracts/contextPack.ts +0 -1
  203. package/src/contracts/index.ts +0 -10
  204. package/src/contracts/lens-filter.contract.ts +0 -183
  205. package/src/contracts/lens-workflow.contract.ts +0 -162
  206. package/src/contracts/lensFilter.ts +0 -1
  207. package/src/contracts/lensWorkflow.ts +0 -1
  208. package/src/contracts/mcp-tools.contract.ts +0 -3636
  209. package/src/contracts/mcpTools.ts +0 -1
  210. package/src/contracts/prompt.contract.ts +0 -50
  211. package/src/contracts/prompt.ts +0 -1
  212. package/src/contracts/sdk-tools.contract.ts +0 -1457
  213. package/src/contracts/sdkTools.ts +0 -1
  214. package/src/contracts/workflow-runtime.contract.ts +0 -440
  215. package/src/contracts/workflowRuntime.ts +0 -1
  216. package/src/coreClient.ts +0 -570
  217. package/src/customTools.ts +0 -398
  218. package/src/decisionsClient.ts +0 -286
  219. package/src/domainContext.ts +0 -15
  220. package/src/events.ts +0 -531
  221. package/src/eventsCore.ts +0 -168
  222. package/src/facade/beliefs.ts +0 -83
  223. package/src/facade/context.ts +0 -110
  224. package/src/facade/contradictions.ts +0 -29
  225. package/src/facade/edges.ts +0 -30
  226. package/src/facade/events.ts +0 -23
  227. package/src/facade/evidence.ts +0 -41
  228. package/src/facade/graph.ts +0 -38
  229. package/src/facade/identity.ts +0 -16
  230. package/src/facade/ontologies.ts +0 -34
  231. package/src/facade/questions.ts +0 -59
  232. package/src/facade/search.ts +0 -16
  233. package/src/facade/tasks.ts +0 -37
  234. package/src/facade/topics.ts +0 -42
  235. package/src/facade/webhooks.ts +0 -58
  236. package/src/facade/worktrees.ts +0 -51
  237. package/src/gatewayFacades.ts +0 -1666
  238. package/src/graphClient.ts +0 -529
  239. package/src/harnessClient.ts +0 -585
  240. package/src/identityClient.ts +0 -278
  241. package/src/index.ts +0 -49
  242. package/src/learningClient.ts +0 -95
  243. package/src/mcpParityClient.ts +0 -240
  244. package/src/ontologyClient.ts +0 -275
  245. package/src/packRuntime.ts +0 -3
  246. package/src/packsClient.ts +0 -260
  247. package/src/policyClient.ts +0 -572
  248. package/src/promptCatalog.ts +0 -1
  249. package/src/realtime/index.ts +0 -51
  250. package/src/reportsClient.ts +0 -99
  251. package/src/schemaClient.ts +0 -129
  252. package/src/sdkSurface.ts +0 -190
  253. package/src/topicsClient.ts +0 -243
  254. package/src/types.ts +0 -807
  255. package/src/version.ts +0 -2
  256. package/src/workflowClient.ts +0 -826
  257. package/tsconfig.json +0 -9
@@ -1,826 +0,0 @@
1
- import {
2
- createGatewayRequestClient,
3
- type GatewayClientConfig,
4
- LucernApiError,
5
- randomIdempotencyKey,
6
- toQueryString,
7
- } from "./coreClient";
8
- import {
9
- asListItems,
10
- createListResult,
11
- mapAliasedList,
12
- mapGatewayData,
13
- normalizeTopicQuery,
14
- resolveTopicId,
15
- withTopicAlias,
16
- } from "./sdkSurface";
17
- import type {
18
- LensPerspectiveType,
19
- LensPromptTemplateReference,
20
- LensStatus,
21
- LensTaskTemplate,
22
- LensWorkflowTemplate,
23
- } from "./contracts/lensWorkflow";
24
- import type {
25
- WorkflowAutoFixPolicy,
26
- WorkflowProofArtifact,
27
- WorkflowStaffingHint,
28
- } from "./contracts/workflowRuntime";
29
- import type {
30
- AddWorktreeResponse,
31
- CompleteTaskResponse,
32
- CreateBranchResponse,
33
- CreateLensResponse,
34
- CreateTaskResponse,
35
- JsonObject,
36
- JsonValue,
37
- LensTopicBindingResponse,
38
- ListBranchesResponse,
39
- ListLensesResponse,
40
- ListTopicsResponse,
41
- ListWorktreesResponse,
42
- MergeWorktreeResponse,
43
- OpenPullRequestResponse,
44
- PushWorktreeResponse,
45
- SwitchTopicContextResponse,
46
- TopicIdentifierInput,
47
- UpdateTaskResponse,
48
- WorkflowBranchRecord,
49
- WorkflowLensRecord,
50
- WorkflowTopicRecord,
51
- WorkflowWorktreeRecord,
52
- } from "./types";
53
-
54
- export { LucernApiError };
55
- export type { PlatformGatewaySuccess } from "./coreClient";
56
- export type {
57
- AddWorktreeResponse,
58
- CompleteTaskResponse,
59
- CreateBranchResponse,
60
- CreateLensResponse,
61
- CreateTaskResponse,
62
- LensTopicBindingResponse,
63
- ListBranchesResponse,
64
- ListLensesResponse,
65
- ListTopicsResponse,
66
- ListWorktreesResponse,
67
- MergeWorktreeResponse,
68
- OpenPullRequestResponse,
69
- PushWorktreeResponse,
70
- SwitchTopicContextResponse,
71
- UpdateTaskResponse,
72
- } from "./types";
73
-
74
- /** Configuration for the workflow client. */
75
- export type WorkflowClientConfig = GatewayClientConfig;
76
-
77
- /** Lifecycle status of a workflow branch. */
78
- export type WorkflowBranchStatus = "dormant" | "active" | "archived";
79
-
80
- /** Lifecycle status of a workflow lens. */
81
- export type WorkflowLensStatus = LensStatus;
82
-
83
- /** Analytical perspective type for a lens overlay. */
84
- export type WorkflowLensPerspectiveType = LensPerspectiveType;
85
-
86
- /** Lifecycle status of a workflow worktree. */
87
- export type WorkflowWorktreeStatus =
88
- | "planning"
89
- | "active"
90
- | "paused"
91
- | "completed"
92
- | "merged"
93
- | "failed"
94
- | "archived";
95
-
96
- /** Possible outcomes when merging worktree findings into the main belief line. */
97
- export type WorkflowMergeOutcome =
98
- | "validated"
99
- | "invalidated"
100
- | "forked"
101
- | "inconclusive";
102
-
103
- /** Input for creating a new workflow worktree. */
104
- export type AddWorktreeInput = {
105
- title: string;
106
- topicId?: string;
107
- branchId?: string;
108
- objective?: string;
109
- hypothesis?: string;
110
- beliefIds?: string[];
111
- autoShape?: boolean;
112
- domainPackId?: string;
113
- executionOrder?: number;
114
- dependsOn?: string[];
115
- blocks?: string[];
116
- gate?: string;
117
- proofArtifacts?: WorkflowProofArtifact[];
118
- staffingHint?: WorkflowStaffingHint | string;
119
- lastReconciledAt?: number;
120
- autoFixPolicy?: WorkflowAutoFixPolicy;
121
- } & TopicIdentifierInput;
122
-
123
- /** Input for merging worktree findings with belief confidence outcomes. */
124
- export type MergeInput = {
125
- outcomes: Array<{
126
- beliefId: string;
127
- confidence: number;
128
- rationale: string;
129
- }>;
130
- summary?: string;
131
- };
132
-
133
- /** Input for updating the beliefs and questions tracked by a worktree. */
134
- export type UpdateWorktreeTargetsInput = {
135
- worktreeId: string;
136
- addBeliefIds?: string[];
137
- addQuestionIds?: string[];
138
- removeBeliefIds?: string[];
139
- removeQuestionIds?: string[];
140
- };
141
-
142
- /** Input for marking a worktree complete with recorded outcomes. */
143
- export type CompleteWorktreeInput = {
144
- worktreeId: string;
145
- keyFindings?: string[];
146
- decisionsReached?: string[];
147
- nextSteps?: string[];
148
- };
149
-
150
- /** Input for moving a worktree forward to its next phase. */
151
- export type AdvanceWorktreePhaseInput = {
152
- worktreeId: string;
153
- };
154
-
155
- /** Input for forcing a worktree into a specific phase. */
156
- export type SetWorktreePhaseInput = {
157
- worktreeId: string;
158
- phase: string;
159
- };
160
-
161
- /** Input for patching arbitrary structured worktree state. */
162
- export type PatchWorktreeStateInput = {
163
- worktreeId: string;
164
- patch: JsonObject;
165
- };
166
-
167
- /** Input for batch-creating worktrees through the workflow surface. */
168
- export type BulkCreateWorktreesInput = {
169
- worktrees: unknown[];
170
- };
171
-
172
- /** Input for listing accessible topic contexts. */
173
- export type ListTopicsInput = {
174
- includeShared?: boolean;
175
- limit?: number;
176
- };
177
-
178
- /** Input for switching the active topic context by name. */
179
- export type SwitchTopicContextInput = {
180
- targetTopicName: string;
181
- };
182
-
183
- /** Input for creating a workflow task linked to a question or worktree. */
184
- export type CreateTaskInput = {
185
- title: string;
186
- topicId?: string;
187
- taskType?: "research" | "interview" | "analysis" | "data_collection";
188
- linkedQuestionId?: string;
189
- linkedWorktreeId?: string;
190
- linkedBeliefId?: string;
191
- description?: string;
192
- priority?: "low" | "medium" | "high" | "urgent";
193
- } & TopicIdentifierInput;
194
-
195
- /** Input for marking a workflow task as completed with an output summary. */
196
- export type CompleteTaskInput = {
197
- outputSummary: string;
198
- evidenceCreated?: boolean;
199
- };
200
-
201
- /** Input for partially updating an existing workflow task. */
202
- export type UpdateTaskInput = {
203
- title?: string;
204
- description?: string;
205
- linkedBeliefId?: string;
206
- linkedQuestionId?: string;
207
- linkedWorktreeId?: string;
208
- priority?: "critical" | "high" | "medium" | "low";
209
- status?: "todo" | "in_progress" | "blocked" | "done";
210
- };
211
-
212
- function normalizeLensQuery<T extends { topicId?: string }>(
213
- value: T
214
- ) {
215
- const topicId = resolveTopicId(value);
216
- return {
217
- ...value,
218
- ...(topicId ? { topicId } : {}),
219
- };
220
- }
221
-
222
- /**
223
- * Create the workflow client for lenses, legacy branches, worktrees, context,
224
- * and tasks.
225
- * @param config - Gateway transport configuration.
226
- * @returns An object with methods to manage branches, lenses, worktrees, topics, and tasks.
227
- */
228
- export function createWorkflowClient(config: WorkflowClientConfig = {}) {
229
- const gateway = createGatewayRequestClient(config);
230
- const client = {
231
- /**
232
- * List workflow branches for a topic scope.
233
- */
234
- async listBranches(query: {
235
- topicId?: string;
236
- status?: WorkflowBranchStatus;
237
- limit?: number;
238
- } & TopicIdentifierInput) {
239
- return gateway.request<ListBranchesResponse>({
240
- path: `/api/platform/v1/workflow/branches${toQueryString(
241
- normalizeTopicQuery(query)
242
- )}`,
243
- }).then((response) =>
244
- mapGatewayData(response, (data) =>
245
- mapAliasedList<WorkflowBranchRecord, "branches">(data, "branches")
246
- )
247
- );
248
- },
249
-
250
- /**
251
- * Create a workflow branch.
252
- */
253
- async createBranch(
254
- input: {
255
- name: string;
256
- topicId?: string;
257
- description?: string;
258
- metadata?: JsonObject;
259
- } & TopicIdentifierInput,
260
- idempotencyKey?: string
261
- ) {
262
- return gateway.request<CreateBranchResponse>({
263
- path: "/api/platform/v1/workflow/branches",
264
- method: "POST",
265
- body: normalizeTopicQuery(input),
266
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
267
- }).then((response) =>
268
- mapGatewayData(response, (data) =>
269
- withTopicAlias(data as Record<string, unknown>) as CreateBranchResponse
270
- )
271
- );
272
- },
273
-
274
- /**
275
- * List reusable lenses for a workspace or topic scope.
276
- */
277
- async listLenses(query: {
278
- workspaceId?: string;
279
- topicId?: string;
280
- status?: WorkflowLensStatus;
281
- perspectiveType?: WorkflowLensPerspectiveType;
282
- } & TopicIdentifierInput) {
283
- return gateway.request<ListLensesResponse>({
284
- path: `/api/platform/v1/workflow/lenses${toQueryString(
285
- normalizeLensQuery(query)
286
- )}`,
287
- }).then((response) =>
288
- mapGatewayData(response, (data) =>
289
- mapAliasedList<WorkflowLensRecord, "lenses">(data, "lenses")
290
- )
291
- );
292
- },
293
-
294
- /**
295
- * Create a reusable workflow lens.
296
- */
297
- async createLens(
298
- input: {
299
- name: string;
300
- workspaceId?: string;
301
- topicId?: string;
302
- description?: string;
303
- perspectiveType: WorkflowLensPerspectiveType;
304
- promptTemplates?: LensPromptTemplateReference[];
305
- workflowTemplates?: LensWorkflowTemplate[];
306
- taskTemplates?: LensTaskTemplate[];
307
- filterCriteria?: JsonObject;
308
- } & TopicIdentifierInput,
309
- idempotencyKey?: string
310
- ) {
311
- const payload = normalizeLensQuery(input);
312
- return gateway.request<CreateLensResponse>({
313
- path: "/api/platform/v1/workflow/lenses",
314
- method: "POST",
315
- body: payload as JsonObject,
316
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
317
- }).then((response) =>
318
- mapGatewayData(response, (data) =>
319
- withTopicAlias(data as Record<string, unknown>) as CreateLensResponse
320
- )
321
- );
322
- },
323
-
324
- /**
325
- * Apply an existing lens to a topic.
326
- */
327
- async applyLensToTopic(
328
- input: {
329
- lensId: string;
330
- topicId?: string;
331
- metadata?: JsonObject;
332
- } & TopicIdentifierInput,
333
- idempotencyKey?: string
334
- ) {
335
- const payload = normalizeLensQuery(input);
336
- return gateway.request<LensTopicBindingResponse>({
337
- path: "/api/platform/v1/workflow/lens-bindings",
338
- method: "POST",
339
- body: payload,
340
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
341
- }).then((response) =>
342
- mapGatewayData(response, (data) =>
343
- withTopicAlias(data as Record<string, unknown>) as LensTopicBindingResponse
344
- )
345
- );
346
- },
347
-
348
- /**
349
- * Remove an applied lens from a topic.
350
- */
351
- async removeLensFromTopic(
352
- input: {
353
- lensId: string;
354
- topicId?: string;
355
- } & TopicIdentifierInput,
356
- idempotencyKey?: string
357
- ) {
358
- const topicId = resolveTopicId(input);
359
- if (!topicId) {
360
- throw new LucernApiError({
361
- code: "INVALID_REQUEST",
362
- message: "topicId is required",
363
- status: 400,
364
- });
365
- }
366
-
367
- return gateway.request<LensTopicBindingResponse>({
368
- path: `/api/platform/v1/workflow/lens-bindings${toQueryString({
369
- lensId: input.lensId,
370
- topicId,
371
- })}`,
372
- method: "DELETE",
373
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
374
- }).then((response) =>
375
- mapGatewayData(response, (data) =>
376
- withTopicAlias(data as Record<string, unknown>) as LensTopicBindingResponse
377
- )
378
- );
379
- },
380
-
381
- /**
382
- * List worktrees for a topic scope.
383
- */
384
- async listWorktrees(query: {
385
- topicId?: string;
386
- branchId?: string;
387
- status?: WorkflowWorktreeStatus;
388
- track?: string;
389
- executionBand?: number;
390
- limit?: number;
391
- } & TopicIdentifierInput) {
392
- const normalized = normalizeTopicQuery(query);
393
- return gateway.request<ListWorktreesResponse>({
394
- path: `/api/platform/v1/worktrees${toQueryString({
395
- ...normalized,
396
- track: query.track,
397
- executionBand: query.executionBand,
398
- })}`,
399
- }).then((response) =>
400
- mapGatewayData(response, (data) =>
401
- mapAliasedList<WorkflowWorktreeRecord, "worktrees">(
402
- data,
403
- "worktrees"
404
- )
405
- )
406
- );
407
- },
408
-
409
- /**
410
- * List all worktrees across accessible topics.
411
- */
412
- async listAllWorktrees(query: {
413
- status?: WorkflowWorktreeStatus;
414
- track?: string;
415
- executionBand?: number;
416
- limit?: number;
417
- } = {}) {
418
- return gateway.request<ListWorktreesResponse>({
419
- path: `/api/platform/v1/worktrees${toQueryString({
420
- status: query.status,
421
- track: query.track,
422
- executionBand: query.executionBand,
423
- limit: query.limit,
424
- })}`,
425
- }).then((response) =>
426
- mapGatewayData(response, (data) => {
427
- const record =
428
- data && typeof data === "object" && !Array.isArray(data)
429
- ? (data as Record<string, unknown>)
430
- : {};
431
- const list = mapAliasedList<WorkflowWorktreeRecord, "worktrees">(
432
- data,
433
- "worktrees"
434
- );
435
- return {
436
- ...list,
437
- ...(record.tracks &&
438
- typeof record.tracks === "object" &&
439
- !Array.isArray(record.tracks)
440
- ? { tracks: record.tracks as Record<string, number> }
441
- : {}),
442
- ...(record.bands &&
443
- typeof record.bands === "object" &&
444
- !Array.isArray(record.bands)
445
- ? { bands: record.bands as Record<string, number> }
446
- : {}),
447
- } as ListWorktreesResponse;
448
- })
449
- );
450
- },
451
-
452
- /**
453
- * Create a workflow worktree.
454
- */
455
- async createWorktree(input: AddWorktreeInput, idempotencyKey?: string) {
456
- return gateway.request<AddWorktreeResponse>({
457
- path: "/api/platform/v1/worktrees",
458
- method: "POST",
459
- body: normalizeTopicQuery(input),
460
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
461
- }).then((response) =>
462
- mapGatewayData(response, (data) =>
463
- withTopicAlias(data as Record<string, unknown>) as AddWorktreeResponse
464
- )
465
- );
466
- },
467
-
468
- /**
469
- * @deprecated Use createWorktree.
470
- */
471
- async addWorktree(input: AddWorktreeInput, idempotencyKey?: string) {
472
- return client.createWorktree(input, idempotencyKey);
473
- },
474
-
475
- /**
476
- * Merge a worktree into the main belief line.
477
- */
478
- async merge(
479
- worktreeId: string,
480
- input: MergeInput,
481
- idempotencyKey?: string
482
- ) {
483
- return gateway.request<MergeWorktreeResponse>({
484
- path: `/api/platform/v1/worktrees/${encodeURIComponent(worktreeId)}/merge`,
485
- method: "POST",
486
- body: input,
487
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
488
- });
489
- },
490
-
491
- /**
492
- * Activate a planning worktree.
493
- */
494
- async activateWorktree(worktreeId: string, idempotencyKey?: string) {
495
- return gateway.request<AddWorktreeResponse>({
496
- path: `/api/platform/v1/worktrees/${encodeURIComponent(worktreeId)}/activate`,
497
- method: "POST",
498
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
499
- }).then((response) =>
500
- mapGatewayData(response, (data) =>
501
- withTopicAlias(data as Record<string, unknown>) as AddWorktreeResponse
502
- )
503
- );
504
- },
505
-
506
- /**
507
- * Update targeted beliefs/questions for a worktree.
508
- */
509
- async updateWorktreeTargets(
510
- input: UpdateWorktreeTargetsInput,
511
- idempotencyKey?: string
512
- ) {
513
- const { worktreeId, ...body } = input;
514
- return gateway.request<AddWorktreeResponse>({
515
- path: `/api/platform/v1/worktrees/${encodeURIComponent(worktreeId)}/targets`,
516
- method: "POST",
517
- body,
518
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
519
- }).then((response) =>
520
- mapGatewayData(response, (data) =>
521
- withTopicAlias(data as Record<string, unknown>) as AddWorktreeResponse
522
- )
523
- );
524
- },
525
-
526
- /**
527
- * Mark a worktree record complete.
528
- */
529
- async completeWorktree(
530
- input: CompleteWorktreeInput,
531
- idempotencyKey?: string
532
- ) {
533
- return gateway.request<Record<string, unknown>>({
534
- path: "/api/platform/v1/worktrees/complete",
535
- method: "POST",
536
- body: input,
537
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
538
- });
539
- },
540
-
541
- /**
542
- * Advance a worktree to its next lifecycle phase.
543
- */
544
- async advanceWorktreePhase(
545
- input: AdvanceWorktreePhaseInput,
546
- idempotencyKey?: string
547
- ) {
548
- return gateway.request<Record<string, unknown>>({
549
- path: "/api/platform/v1/worktrees/advance-phase",
550
- method: "POST",
551
- body: input,
552
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
553
- });
554
- },
555
-
556
- /**
557
- * Force a worktree into a specific lifecycle phase.
558
- */
559
- async setWorktreePhase(
560
- input: SetWorktreePhaseInput,
561
- idempotencyKey?: string
562
- ) {
563
- return gateway.request<Record<string, unknown>>({
564
- path: "/api/platform/v1/worktrees/set-phase",
565
- method: "POST",
566
- body: input,
567
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
568
- });
569
- },
570
-
571
- /**
572
- * Patch opaque worktree state for orchestration flows.
573
- */
574
- async patchWorktreeState(
575
- input: PatchWorktreeStateInput,
576
- idempotencyKey?: string
577
- ) {
578
- return gateway.request<Record<string, unknown>>({
579
- path: "/api/platform/v1/worktrees/patch-state",
580
- method: "POST",
581
- body: input,
582
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
583
- });
584
- },
585
-
586
- /**
587
- * Batch create worktree records.
588
- */
589
- async bulkCreateWorktrees(
590
- input: BulkCreateWorktreesInput,
591
- idempotencyKey?: string
592
- ) {
593
- return gateway.request<Record<string, unknown>>({
594
- path: "/api/platform/v1/worktrees/bulk",
595
- method: "POST",
596
- body: input as unknown as JsonObject,
597
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
598
- });
599
- },
600
-
601
- /**
602
- * Open a pull request for a worktree.
603
- */
604
- async openPullRequest(
605
- worktreeId: string,
606
- input: {
607
- summary: string;
608
- reviewers?: string[];
609
- status?:
610
- | "pending_review"
611
- | "changes_requested"
612
- | "approved"
613
- | "blocked";
614
- },
615
- idempotencyKey?: string
616
- ) {
617
- return gateway.request<OpenPullRequestResponse>({
618
- path: `/api/platform/v1/workflow/worktrees/${encodeURIComponent(worktreeId)}/pull-request`,
619
- method: "POST",
620
- body: input,
621
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
622
- });
623
- },
624
-
625
- /**
626
- * Push scored worktree findings into another context.
627
- */
628
- async push(
629
- worktreeId: string,
630
- input: {
631
- targetContext: string;
632
- beliefIds?: string[];
633
- metadata?: JsonObject;
634
- },
635
- idempotencyKey?: string
636
- ) {
637
- return gateway.request<PushWorktreeResponse>({
638
- path: `/api/platform/v1/workflow/worktrees/${encodeURIComponent(worktreeId)}/push`,
639
- method: "POST",
640
- body: input,
641
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
642
- });
643
- },
644
-
645
- /**
646
- * List accessible topic contexts.
647
- */
648
- async listTopics(query: ListTopicsInput = {}) {
649
- return gateway.request<ListTopicsResponse>({
650
- path: `/api/platform/v1/workflow/topics${toQueryString({
651
- includeShared:
652
- typeof query.includeShared === "boolean"
653
- ? query.includeShared
654
- ? "true"
655
- : "false"
656
- : undefined,
657
- limit: query.limit,
658
- })}`,
659
- }).then((response) =>
660
- mapGatewayData(response, (data) => {
661
- const items = asListItems<WorkflowTopicRecord>(data, "topics").map(
662
- (item) =>
663
- withTopicAlias(
664
- item as Record<string, unknown>
665
- ) as WorkflowTopicRecord
666
- );
667
- const record =
668
- data && typeof data === "object"
669
- ? (data as Record<string, unknown>)
670
- : {};
671
- return {
672
- ...record,
673
- ...createListResult(items, "topics"),
674
- total:
675
- typeof record.total === "number" ? record.total : items.length,
676
- } as ListTopicsResponse;
677
- })
678
- );
679
- },
680
-
681
- /**
682
- * Switch the active context by topic or project name.
683
- */
684
- async switchTopicContext(
685
- input: SwitchTopicContextInput,
686
- idempotencyKey?: string
687
- ) {
688
- return gateway.request<SwitchTopicContextResponse>({
689
- path: "/api/platform/v1/workflow/topics/switch",
690
- method: "POST",
691
- body: {
692
- targetTopicName: input.targetTopicName,
693
- },
694
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
695
- }).then((response) =>
696
- mapGatewayData(response, (data) =>
697
- withTopicAlias(
698
- data as Record<string, unknown>
699
- ) as SwitchTopicContextResponse
700
- )
701
- );
702
- },
703
-
704
- /**
705
- * Create a workflow task.
706
- */
707
- async createTask(input: CreateTaskInput, idempotencyKey?: string) {
708
- return gateway.request<CreateTaskResponse>({
709
- path: "/api/platform/v1/workflow/tasks",
710
- method: "POST",
711
- body: normalizeTopicQuery(input),
712
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
713
- });
714
- },
715
-
716
- /**
717
- * Complete a workflow task.
718
- */
719
- async completeTask(
720
- taskId: string,
721
- input: CompleteTaskInput,
722
- idempotencyKey?: string
723
- ) {
724
- return gateway.request<CompleteTaskResponse>({
725
- path: `/api/platform/v1/workflow/tasks/${encodeURIComponent(taskId)}/complete`,
726
- method: "POST",
727
- body: input,
728
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
729
- });
730
- },
731
-
732
- /**
733
- * Update a workflow task.
734
- */
735
- async updateTask(
736
- taskId: string,
737
- input: UpdateTaskInput,
738
- idempotencyKey?: string
739
- ) {
740
- return gateway.request<UpdateTaskResponse>({
741
- path: `/api/platform/v1/workflow/tasks/${encodeURIComponent(taskId)}`,
742
- method: "PATCH",
743
- body: input,
744
- idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
745
- });
746
- },
747
-
748
- /**
749
- * @deprecated Use createBranch.
750
- */
751
- async createPillar(
752
- input: {
753
- name: string;
754
- topicId?: string;
755
- description?: string;
756
- metadata?: JsonObject;
757
- } & TopicIdentifierInput,
758
- idempotencyKey?: string
759
- ) {
760
- return client.createBranch(input, idempotencyKey);
761
- },
762
-
763
- /**
764
- * @deprecated Use addWorktree.
765
- */
766
- async createSprint(
767
- input: {
768
- title: string;
769
- topicId?: string;
770
- branchId?: string;
771
- hypothesis?: string;
772
- beliefIds?: string[];
773
- } & TopicIdentifierInput,
774
- idempotencyKey?: string
775
- ) {
776
- return client.createWorktree(input, idempotencyKey);
777
- },
778
-
779
- /**
780
- * @deprecated Use merge.
781
- */
782
- async completeSprint(
783
- worktreeId: string,
784
- input: MergeInput,
785
- idempotencyKey?: string
786
- ) {
787
- return client.merge(worktreeId, input, idempotencyKey);
788
- },
789
-
790
- /**
791
- * @deprecated Use openPullRequest.
792
- */
793
- async requestReview(
794
- worktreeId: string,
795
- input: {
796
- summary: string;
797
- reviewers?: string[];
798
- status?:
799
- | "pending_review"
800
- | "changes_requested"
801
- | "approved"
802
- | "blocked";
803
- },
804
- idempotencyKey?: string
805
- ) {
806
- return client.openPullRequest(worktreeId, input, idempotencyKey);
807
- },
808
-
809
- /**
810
- * @deprecated Use push.
811
- */
812
- async publishFindings(
813
- worktreeId: string,
814
- input: {
815
- targetContext: string;
816
- beliefIds?: string[];
817
- metadata?: JsonObject;
818
- },
819
- idempotencyKey?: string
820
- ) {
821
- return client.push(worktreeId, input, idempotencyKey);
822
- },
823
- };
824
-
825
- return client;
826
- }