@lucern/sdk 0.2.0-alpha.13 → 0.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/README.md +112 -621
  2. package/dist/index.js +3447 -6249
  3. package/dist/index.js.map +1 -1
  4. package/dist/{contracts → lucern/contracts/src}/auth-session.contract.d.ts +12 -14
  5. package/dist/{contracts → lucern/contracts/src}/context-pack.contract.d.ts +58 -56
  6. package/dist/{contracts → lucern/contracts/src}/lens-filter.contract.d.ts +8 -10
  7. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +84 -0
  8. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +151 -0
  9. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +161 -0
  10. package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +119 -0
  11. package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +18 -0
  12. package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +78 -0
  13. package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +53 -0
  14. package/dist/lucern/packages/client-core/src/beliefs.d.ts +30 -0
  15. package/dist/lucern/packages/client-core/src/context.d.ts +29 -0
  16. package/dist/lucern/packages/client-core/src/contradictions.d.ts +11 -0
  17. package/dist/lucern/packages/client-core/src/edges.d.ts +11 -0
  18. package/dist/lucern/packages/client-core/src/events.d.ts +9 -0
  19. package/dist/lucern/packages/client-core/src/evidence.d.ts +21 -0
  20. package/dist/lucern/packages/client-core/src/graph.d.ts +17 -0
  21. package/dist/lucern/packages/client-core/src/identity.d.ts +7 -0
  22. package/dist/lucern/packages/client-core/src/ids.d.ts +7 -0
  23. package/dist/lucern/packages/client-core/src/ontologies.d.ts +13 -0
  24. package/dist/lucern/packages/client-core/src/questions.d.ts +39 -0
  25. package/dist/lucern/packages/client-core/src/search.d.ts +7 -0
  26. package/dist/lucern/packages/client-core/src/tasks.d.ts +13 -0
  27. package/dist/lucern/packages/client-core/src/topics.d.ts +17 -0
  28. package/dist/lucern/packages/client-core/src/webhooks.d.ts +35 -0
  29. package/dist/lucern/packages/client-core/src/worktrees.d.ts +17 -0
  30. package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +283 -0
  31. package/dist/lucern/packages/domain-beliefs/src/index.d.ts +1 -0
  32. package/dist/lucern/packages/domain-context/src/compile.d.ts +11 -0
  33. package/dist/{contextPackCompiler.d.ts → lucern/packages/domain-context/src/context-pack-compiler.d.ts} +10 -11
  34. package/dist/lucern/packages/domain-context/src/index.d.ts +4 -0
  35. package/dist/lucern/packages/domain-context/src/ports.d.ts +58 -0
  36. package/dist/lucern/packages/domain-context/src/public-types.d.ts +1 -0
  37. package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +59 -0
  38. package/dist/lucern/packages/domain-edges/src/edges.d.ts +91 -0
  39. package/dist/lucern/packages/domain-edges/src/index.d.ts +2 -0
  40. package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +115 -0
  41. package/dist/lucern/packages/domain-evidence/src/index.d.ts +1 -0
  42. package/dist/lucern/packages/domain-graph/src/graph.d.ts +150 -0
  43. package/dist/lucern/packages/domain-identity/src/index.d.ts +1 -0
  44. package/dist/lucern/packages/domain-identity/src/whoami.d.ts +13 -0
  45. package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +123 -0
  46. package/dist/lucern/packages/domain-questions/src/index.d.ts +1 -0
  47. package/dist/lucern/packages/domain-questions/src/questions.d.ts +147 -0
  48. package/dist/lucern/packages/domain-search/src/search.d.ts +97 -0
  49. package/dist/lucern/packages/domain-tasks/src/index.d.ts +1 -0
  50. package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +102 -0
  51. package/dist/lucern/packages/domain-topics/src/index.d.ts +1 -0
  52. package/dist/lucern/packages/domain-topics/src/topics.d.ts +147 -0
  53. package/dist/lucern/packages/domain-worktrees/src/index.d.ts +1 -0
  54. package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +185 -0
  55. package/dist/lucern/packages/events/src/index.d.ts +4 -0
  56. package/dist/lucern/packages/events/src/matching.d.ts +3 -0
  57. package/dist/lucern/packages/events/src/outbox.d.ts +15 -0
  58. package/dist/lucern/packages/events/src/types.d.ts +151 -0
  59. package/dist/lucern/packages/events/src/webhooks.d.ts +9 -0
  60. package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +15 -0
  61. package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +12 -0
  62. package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +7 -0
  63. package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +7 -0
  64. package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +6 -0
  65. package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +21 -0
  66. package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +10 -0
  67. package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +5 -0
  68. package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +8 -0
  69. package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +39 -0
  70. package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +5 -0
  71. package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +8 -0
  72. package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +10 -0
  73. package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +16 -0
  74. package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +10 -0
  75. package/dist/lucern/packages/sdk-typescript/src/index.d.ts +28 -0
  76. package/dist/packages/sdk/src/adminClient.d.ts +89 -0
  77. package/dist/packages/sdk/src/answersClient.d.ts +5 -0
  78. package/dist/{audiencesClient.d.ts → packages/sdk/src/audiencesClient.d.ts} +18 -30
  79. package/dist/packages/sdk/src/auditClient.d.ts +21 -0
  80. package/dist/packages/sdk/src/beliefsClient.d.ts +52 -0
  81. package/dist/packages/sdk/src/client.d.ts +1558 -0
  82. package/dist/packages/sdk/src/contextClient.d.ts +9 -0
  83. package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +79 -0
  84. package/dist/{controlObjectOwnership.d.ts → packages/sdk/src/controlObjectOwnership.d.ts} +18 -35
  85. package/dist/{coreClient.d.ts → packages/sdk/src/coreClient.d.ts} +14 -38
  86. package/dist/packages/sdk/src/customTools.d.ts +65 -0
  87. package/dist/packages/sdk/src/decisionsClient.d.ts +97 -0
  88. package/dist/packages/sdk/src/graphClient.d.ts +191 -0
  89. package/dist/{harnessClient.d.ts → packages/sdk/src/harnessClient.d.ts} +33 -127
  90. package/dist/packages/sdk/src/identityClient.d.ts +104 -0
  91. package/dist/packages/sdk/src/index.d.ts +28 -0
  92. package/dist/packages/sdk/src/learningClient.d.ts +37 -0
  93. package/dist/{mcpParityClient.d.ts → packages/sdk/src/mcpParityClient.d.ts} +5 -11
  94. package/dist/packages/sdk/src/mcpParitySurface.d.ts +8 -0
  95. package/dist/{ontologyClient.d.ts → packages/sdk/src/ontologyClient.d.ts} +22 -44
  96. package/dist/packages/sdk/src/packsClient.d.ts +101 -0
  97. package/dist/{policyClient.d.ts → packages/sdk/src/policyClient.d.ts} +18 -113
  98. package/dist/packages/sdk/src/reportsClient.d.ts +31 -0
  99. package/dist/packages/sdk/src/schemaClient.d.ts +54 -0
  100. package/dist/packages/sdk/src/sdkSurface.d.ts +55 -0
  101. package/dist/packages/sdk/src/topicsClient.d.ts +45 -0
  102. package/dist/packages/sdk/src/types.d.ts +470 -0
  103. package/dist/packages/sdk/src/version.d.ts +2 -0
  104. package/dist/packages/sdk/src/workflowClient.d.ts +252 -0
  105. package/package.json +37 -92
  106. package/CHANGELOG.md +0 -13
  107. package/dist/adminClient.d.ts +0 -409
  108. package/dist/adminClient.js +0 -755
  109. package/dist/adminClient.js.map +0 -1
  110. package/dist/answersClient.d.ts +0 -23
  111. package/dist/answersClient.js +0 -333
  112. package/dist/answersClient.js.map +0 -1
  113. package/dist/audience/index.d.ts +0 -38
  114. package/dist/audience/index.js +0 -110
  115. package/dist/audience/index.js.map +0 -1
  116. package/dist/audiencesClient.js +0 -472
  117. package/dist/audiencesClient.js.map +0 -1
  118. package/dist/auditClient.d.ts +0 -29
  119. package/dist/auditClient.js +0 -386
  120. package/dist/auditClient.js.map +0 -1
  121. package/dist/beliefs/index.d.ts +0 -465
  122. package/dist/beliefs/index.js +0 -6433
  123. package/dist/beliefs/index.js.map +0 -1
  124. package/dist/beliefs/lifecycle.d.ts +0 -24
  125. package/dist/beliefs/lifecycle.js +0 -98
  126. package/dist/beliefs/lifecycle.js.map +0 -1
  127. package/dist/beliefsClient.d.ts +0 -241
  128. package/dist/beliefsClient.js +0 -646
  129. package/dist/beliefsClient.js.map +0 -1
  130. package/dist/client.d.ts +0 -2398
  131. package/dist/client.js +0 -6411
  132. package/dist/client.js.map +0 -1
  133. package/dist/contextClient.d.ts +0 -27
  134. package/dist/contextClient.js +0 -396
  135. package/dist/contextClient.js.map +0 -1
  136. package/dist/contextFacade.d.ts +0 -2
  137. package/dist/contextFacade.js +0 -73
  138. package/dist/contextFacade.js.map +0 -1
  139. package/dist/contextPackCompiler.js +0 -1091
  140. package/dist/contextPackCompiler.js.map +0 -1
  141. package/dist/contextPackPolicy.d.ts +0 -84
  142. package/dist/contextPackPolicy.js +0 -347
  143. package/dist/contextPackPolicy.js.map +0 -1
  144. package/dist/contextPackSchema.d.ts +0 -7
  145. package/dist/contextPackSchema.js +0 -203
  146. package/dist/contextPackSchema.js.map +0 -1
  147. package/dist/contextTypes.d.ts +0 -135
  148. package/dist/contextTypes.js +0 -3
  149. package/dist/contextTypes.js.map +0 -1
  150. package/dist/contracts/api-enums.contract.d.ts +0 -81
  151. package/dist/contracts/api-enums.contract.js +0 -98
  152. package/dist/contracts/api-enums.contract.js.map +0 -1
  153. package/dist/contracts/auth-session.contract.js +0 -48
  154. package/dist/contracts/auth-session.contract.js.map +0 -1
  155. package/dist/contracts/context-pack.contract.js +0 -98
  156. package/dist/contracts/context-pack.contract.js.map +0 -1
  157. package/dist/contracts/contextPack.d.ts +0 -1
  158. package/dist/contracts/contextPack.js +0 -98
  159. package/dist/contracts/contextPack.js.map +0 -1
  160. package/dist/contracts/index.d.ts +0 -9
  161. package/dist/contracts/index.js +0 -4928
  162. package/dist/contracts/index.js.map +0 -1
  163. package/dist/contracts/lens-filter.contract.js +0 -71
  164. package/dist/contracts/lens-filter.contract.js.map +0 -1
  165. package/dist/contracts/lens-workflow.contract.d.ts +0 -87
  166. package/dist/contracts/lens-workflow.contract.js +0 -123
  167. package/dist/contracts/lens-workflow.contract.js.map +0 -1
  168. package/dist/contracts/lensFilter.d.ts +0 -1
  169. package/dist/contracts/lensFilter.js +0 -71
  170. package/dist/contracts/lensFilter.js.map +0 -1
  171. package/dist/contracts/lensWorkflow.d.ts +0 -2
  172. package/dist/contracts/lensWorkflow.js +0 -123
  173. package/dist/contracts/lensWorkflow.js.map +0 -1
  174. package/dist/contracts/mcp-tools.contract.d.ts +0 -1
  175. package/dist/contracts/mcp-tools.contract.js +0 -3016
  176. package/dist/contracts/mcp-tools.contract.js.map +0 -1
  177. package/dist/contracts/mcpTools.d.ts +0 -1
  178. package/dist/contracts/mcpTools.js +0 -3016
  179. package/dist/contracts/mcpTools.js.map +0 -1
  180. package/dist/contracts/prompt.contract.d.ts +0 -26
  181. package/dist/contracts/prompt.contract.js +0 -12
  182. package/dist/contracts/prompt.contract.js.map +0 -1
  183. package/dist/contracts/prompt.d.ts +0 -1
  184. package/dist/contracts/prompt.js +0 -12
  185. package/dist/contracts/prompt.js.map +0 -1
  186. package/dist/contracts/sdk-tools.contract.d.ts +0 -2
  187. package/dist/contracts/sdk-tools.contract.js +0 -4164
  188. package/dist/contracts/sdk-tools.contract.js.map +0 -1
  189. package/dist/contracts/sdkTools.d.ts +0 -2
  190. package/dist/contracts/sdkTools.js +0 -4164
  191. package/dist/contracts/sdkTools.js.map +0 -1
  192. package/dist/contracts/workflow-runtime.contract.d.ts +0 -163
  193. package/dist/contracts/workflow-runtime.contract.js +0 -245
  194. package/dist/contracts/workflow-runtime.contract.js.map +0 -1
  195. package/dist/contracts/workflowRuntime.d.ts +0 -1
  196. package/dist/contracts/workflowRuntime.js +0 -245
  197. package/dist/contracts/workflowRuntime.js.map +0 -1
  198. package/dist/contradictions/index.d.ts +0 -158
  199. package/dist/contradictions/index.js +0 -6427
  200. package/dist/contradictions/index.js.map +0 -1
  201. package/dist/controlObjectOwnership.js +0 -215
  202. package/dist/controlObjectOwnership.js.map +0 -1
  203. package/dist/coreClient.js +0 -339
  204. package/dist/coreClient.js.map +0 -1
  205. package/dist/customTools.d.ts +0 -88
  206. package/dist/customTools.js +0 -248
  207. package/dist/customTools.js.map +0 -1
  208. package/dist/decisions/index.d.ts +0 -68
  209. package/dist/decisions/index.js +0 -6429
  210. package/dist/decisions/index.js.map +0 -1
  211. package/dist/decisionsClient.d.ts +0 -111
  212. package/dist/decisionsClient.js +0 -522
  213. package/dist/decisionsClient.js.map +0 -1
  214. package/dist/domainContext.d.ts +0 -1
  215. package/dist/domainContext.js +0 -3
  216. package/dist/domainContext.js.map +0 -1
  217. package/dist/edges/index.d.ts +0 -204
  218. package/dist/edges/index.js +0 -6428
  219. package/dist/edges/index.js.map +0 -1
  220. package/dist/events.d.ts +0 -178
  221. package/dist/events.js +0 -251
  222. package/dist/events.js.map +0 -1
  223. package/dist/eventsCore.d.ts +0 -49
  224. package/dist/eventsCore.js +0 -429
  225. package/dist/eventsCore.js.map +0 -1
  226. package/dist/evidence/index.d.ts +0 -295
  227. package/dist/evidence/index.js +0 -6428
  228. package/dist/evidence/index.js.map +0 -1
  229. package/dist/evidenceClient.d.ts +0 -119
  230. package/dist/evidenceClient.js +0 -350
  231. package/dist/evidenceClient.js.map +0 -1
  232. package/dist/facade/context.d.ts +0 -18
  233. package/dist/facade/context.js +0 -73
  234. package/dist/facade/context.js.map +0 -1
  235. package/dist/gatewayFacades.d.ts +0 -589
  236. package/dist/gatewayFacades.js +0 -2006
  237. package/dist/gatewayFacades.js.map +0 -1
  238. package/dist/graphClient.d.ts +0 -271
  239. package/dist/graphClient.js +0 -698
  240. package/dist/graphClient.js.map +0 -1
  241. package/dist/harnessClient.js +0 -607
  242. package/dist/harnessClient.js.map +0 -1
  243. package/dist/identityClient.d.ts +0 -140
  244. package/dist/identityClient.js +0 -497
  245. package/dist/identityClient.js.map +0 -1
  246. package/dist/index.d.ts +0 -45
  247. package/dist/learningClient.d.ts +0 -46
  248. package/dist/learningClient.js +0 -409
  249. package/dist/learningClient.js.map +0 -1
  250. package/dist/lenses/index.d.ts +0 -194
  251. package/dist/lenses/index.js +0 -6427
  252. package/dist/lenses/index.js.map +0 -1
  253. package/dist/mcpParityClient.js +0 -516
  254. package/dist/mcpParityClient.js.map +0 -1
  255. package/dist/mcpParitySurface.d.ts +0 -12
  256. package/dist/mcpParitySurface.js +0 -65
  257. package/dist/mcpParitySurface.js.map +0 -1
  258. package/dist/mcpTools-DPZxowDX.d.ts +0 -254
  259. package/dist/nodes/index.d.ts +0 -62
  260. package/dist/nodes/index.js +0 -6429
  261. package/dist/nodes/index.js.map +0 -1
  262. package/dist/ontologies/index.d.ts +0 -178
  263. package/dist/ontologies/index.js +0 -6430
  264. package/dist/ontologies/index.js.map +0 -1
  265. package/dist/ontologyClient.js +0 -513
  266. package/dist/ontologyClient.js.map +0 -1
  267. package/dist/opinion.d.ts +0 -11
  268. package/dist/opinion.js +0 -35
  269. package/dist/opinion.js.map +0 -1
  270. package/dist/packRuntime.d.ts +0 -2
  271. package/dist/packRuntime.js +0 -3
  272. package/dist/packRuntime.js.map +0 -1
  273. package/dist/packsClient.d.ts +0 -131
  274. package/dist/packsClient.js +0 -525
  275. package/dist/packsClient.js.map +0 -1
  276. package/dist/policyClient.js +0 -625
  277. package/dist/policyClient.js.map +0 -1
  278. package/dist/questions/index.d.ts +0 -297
  279. package/dist/questions/index.js +0 -6430
  280. package/dist/questions/index.js.map +0 -1
  281. package/dist/realtime/index.d.ts +0 -29
  282. package/dist/realtime/index.js +0 -23
  283. package/dist/realtime/index.js.map +0 -1
  284. package/dist/realtime/refs.d.ts +0 -17
  285. package/dist/realtime/refs.js +0 -9
  286. package/dist/realtime/refs.js.map +0 -1
  287. package/dist/reportsClient.d.ts +0 -41
  288. package/dist/reportsClient.js +0 -418
  289. package/dist/reportsClient.js.map +0 -1
  290. package/dist/schemaClient.d.ts +0 -64
  291. package/dist/schemaClient.js +0 -434
  292. package/dist/schemaClient.js.map +0 -1
  293. package/dist/sdkSurface.d.ts +0 -61
  294. package/dist/sdkSurface.js +0 -112
  295. package/dist/sdkSurface.js.map +0 -1
  296. package/dist/sdkTools-CwXJDACb.d.ts +0 -150
  297. package/dist/sourcesClient.d.ts +0 -24
  298. package/dist/sourcesClient.js +0 -339
  299. package/dist/sourcesClient.js.map +0 -1
  300. package/dist/topics/index.d.ts +0 -68
  301. package/dist/topics/index.js +0 -6428
  302. package/dist/topics/index.js.map +0 -1
  303. package/dist/topicsClient.d.ts +0 -84
  304. package/dist/topicsClient.js +0 -492
  305. package/dist/topicsClient.js.map +0 -1
  306. package/dist/types.d.ts +0 -715
  307. package/dist/types.js +0 -3
  308. package/dist/types.js.map +0 -1
  309. package/dist/version.d.ts +0 -4
  310. package/dist/version.js +0 -6
  311. package/dist/version.js.map +0 -1
  312. package/dist/workflowClient.d.ts +0 -316
  313. package/dist/workflowClient.js +0 -830
  314. package/dist/workflowClient.js.map +0 -1
  315. package/dist/worktrees/index.d.ts +0 -210
  316. package/dist/worktrees/index.js +0 -6430
  317. package/dist/worktrees/index.js.map +0 -1
@@ -1,112 +0,0 @@
1
- // src/sdkSurface.ts
2
- function asRecord(value) {
3
- return value && typeof value === "object" ? value : {};
4
- }
5
- function cleanString(value) {
6
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
7
- }
8
- function normalizeVerificationStatus(value) {
9
- const status = cleanString(value);
10
- if (!status) {
11
- return void 0;
12
- }
13
- if (status === "verified") {
14
- return "human_verified";
15
- }
16
- if (status === "rejected") {
17
- return "contradicted";
18
- }
19
- return status;
20
- }
21
- function cloneWith(value, patch) {
22
- return { ...value, ...patch };
23
- }
24
- function resolveTopicId(value) {
25
- return cleanString(value.topicId);
26
- }
27
- function resolveText(value) {
28
- return cleanString(value.text) ?? cleanString(value.canonicalText);
29
- }
30
- function withTopicAlias(value) {
31
- const topicId = cleanString(value.topicId) ?? void 0;
32
- if (!topicId) {
33
- return value;
34
- }
35
- return cloneWith(value, { topicId });
36
- }
37
- function withTextAlias(value) {
38
- const text = cleanString(value.text) ?? cleanString(value.canonicalText) ?? void 0;
39
- if (!text) {
40
- return value;
41
- }
42
- return cloneWith(value, { text, canonicalText: text });
43
- }
44
- function withSdkAliases(value) {
45
- return withTopicAlias(withTextAlias(value));
46
- }
47
- function normalizeNodeWriteInput(value) {
48
- const topicId = resolveTopicId(value);
49
- const text = resolveText(value);
50
- const verificationStatus = normalizeVerificationStatus(value.verificationStatus);
51
- const next = { ...value };
52
- if (topicId) {
53
- next.topicId = topicId;
54
- }
55
- if (text) {
56
- next.text = text;
57
- next.canonicalText = text;
58
- }
59
- if (verificationStatus) {
60
- next.verificationStatus = verificationStatus;
61
- }
62
- return next;
63
- }
64
- function normalizeNodeVerificationStatus(value) {
65
- return normalizeVerificationStatus(value);
66
- }
67
- function normalizeTopicQuery(value) {
68
- const topicId = cleanString(value.topicId);
69
- if (!topicId) {
70
- return value;
71
- }
72
- return { ...value, topicId };
73
- }
74
- function asListItems(data, legacyKey) {
75
- if (Array.isArray(data)) {
76
- return data;
77
- }
78
- const record = asRecord(data);
79
- if (Array.isArray(record.items)) {
80
- return record.items;
81
- }
82
- if (legacyKey && Array.isArray(record[legacyKey])) {
83
- return record[legacyKey];
84
- }
85
- return [];
86
- }
87
- function createListResult(items, legacyKey) {
88
- const result = {
89
- items,
90
- total: items.length
91
- };
92
- if (legacyKey) {
93
- result[legacyKey] = items;
94
- }
95
- return result;
96
- }
97
- function mapGatewayData(response, mapper) {
98
- return {
99
- ...response,
100
- data: mapper(response.data)
101
- };
102
- }
103
- function mapAliasedList(data, legacyKey) {
104
- const items = asListItems(data, legacyKey).map(
105
- (item) => withSdkAliases(item)
106
- );
107
- return createListResult(items, legacyKey);
108
- }
109
-
110
- export { asListItems, createListResult, mapAliasedList, mapGatewayData, normalizeNodeVerificationStatus, normalizeNodeWriteInput, normalizeTopicQuery, resolveText, resolveTopicId, withSdkAliases, withTextAlias, withTopicAlias };
111
- //# sourceMappingURL=sdkSurface.js.map
112
- //# sourceMappingURL=sdkSurface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/sdkSurface.ts"],"names":[],"mappings":"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","file":"sdkSurface.js","sourcesContent":["import type { PlatformGatewaySuccess } from \"./coreClient\";\nimport type { JsonObject, ListResult } from \"./types\";\n\ntype TopicScopedValue = {\n topicId?: string;\n};\n\ntype TextScopedValue = {\n text?: string;\n canonicalText?: string;\n};\n\ntype AnyRecord = Record<string, unknown>;\n\nfunction asRecord(value: unknown): AnyRecord {\n return value && typeof value === \"object\" ? (value as AnyRecord) : {};\n}\n\nfunction cleanString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0\n ? value.trim()\n : undefined;\n}\n\nfunction normalizeVerificationStatus(value: unknown): string | undefined {\n const status = cleanString(value);\n if (!status) {\n return undefined;\n }\n if (status === \"verified\") {\n return \"human_verified\";\n }\n if (status === \"rejected\") {\n return \"contradicted\";\n }\n return status;\n}\n\nfunction cloneWith<T extends AnyRecord>(value: T, patch: AnyRecord): T {\n return { ...value, ...patch } as T;\n}\n\n/**\n * Resolve the canonical topic identifier.\n */\nexport function resolveTopicId(value: TopicScopedValue): string | undefined {\n return cleanString(value.topicId);\n}\n\n/**\n * Resolve the canonical text field from text-first or legacy canonicalText-first inputs.\n */\nexport function resolveText(value: TextScopedValue): string | undefined {\n return cleanString(value.text) ?? cleanString(value.canonicalText);\n}\n\n/**\n * Attach the topicId to a record.\n */\nexport function withTopicAlias<T extends AnyRecord>(value: T): T {\n const topicId = cleanString(value.topicId) ?? undefined;\n if (!topicId) {\n return value;\n }\n return cloneWith(value, { topicId });\n}\n\n/**\n * Attach the text/canonicalText alias pair to a record.\n */\nexport function withTextAlias<T extends AnyRecord>(value: T): T {\n const text =\n cleanString(value.text) ?? cleanString(value.canonicalText) ?? undefined;\n if (!text) {\n return value;\n }\n return cloneWith(value, { text, canonicalText: text });\n}\n\n/**\n * Attach topic and text aliases to SDK node-like records.\n */\nexport function withSdkAliases<T extends AnyRecord>(value: T): T {\n return withTopicAlias(withTextAlias(value));\n}\n\n/**\n * Normalize a belief/question/evidence write payload to the canonical gateway shape.\n */\nexport function normalizeNodeWriteInput<T extends JsonObject>(value: T): T {\n const topicId = resolveTopicId(value);\n const text = resolveText(value);\n const verificationStatus = normalizeVerificationStatus(value.verificationStatus);\n const next = { ...value } as JsonObject;\n\n if (topicId) {\n next.topicId = topicId;\n }\n if (text) {\n next.text = text;\n next.canonicalText = text;\n }\n if (verificationStatus) {\n next.verificationStatus = verificationStatus;\n }\n\n return next as T;\n}\n\nexport function normalizeNodeVerificationStatus(value: unknown) {\n return normalizeVerificationStatus(value);\n}\n\n/**\n * Build a topic-aware query object.\n */\nexport function normalizeTopicQuery<T extends JsonObject>(value: T): T {\n const topicId = cleanString(value.topicId);\n if (!topicId) {\n return value;\n }\n return { ...value, topicId } as T;\n}\n\n/**\n * Extract list items from array or list-envelope payloads.\n */\nexport function asListItems<T>(data: unknown, legacyKey?: string): T[] {\n if (Array.isArray(data)) {\n return data as T[];\n }\n\n const record = asRecord(data);\n if (Array.isArray(record.items)) {\n return record.items as T[];\n }\n if (legacyKey && Array.isArray(record[legacyKey])) {\n return record[legacyKey] as T[];\n }\n\n return [];\n}\n\n/**\n * Standardize list data to { items, total } while retaining an optional legacy array key.\n */\nexport function createListResult<T, LegacyKey extends string>(\n items: T[],\n legacyKey?: LegacyKey\n): ListResult<T, LegacyKey> {\n const result = {\n items,\n total: items.length,\n } as ListResult<T, LegacyKey>;\n\n if (legacyKey) {\n (result as Record<string, unknown>)[legacyKey] = items;\n }\n\n return result;\n}\n\n/**\n * Map a gateway success envelope's data while preserving the transport metadata.\n */\nexport function mapGatewayData<T, U>(\n response: PlatformGatewaySuccess<T>,\n mapper: (data: T) => U\n): PlatformGatewaySuccess<U> {\n return {\n ...response,\n data: mapper(response.data),\n };\n}\n\n/**\n * Apply SDK aliases across all items in a list-like payload.\n */\nexport function mapAliasedList<\n TItem extends AnyRecord,\n LegacyKey extends string,\n>(\n data: unknown,\n legacyKey?: LegacyKey\n): ListResult<TItem, LegacyKey> {\n const items = asListItems<TItem>(data, legacyKey).map((item) =>\n withSdkAliases(item)\n );\n return createListResult(items, legacyKey);\n}\n"]}
@@ -1,150 +0,0 @@
1
- import { M as McpToolContract } from './mcpTools-DPZxowDX.js';
2
-
3
- /**
4
- * SDK-Only Tool Contract Definitions
5
- *
6
- * Tools available in @lucern/sdk but NOT in the MCP gateway.
7
- * The SDK unfolds deeper capabilities after the MCP gateway shows developers what's possible.
8
- *
9
- * Total SDK surface = MCP tools (44) + SDK-only tools (44) = 88 tools
10
- *
11
- * These tools are organized into capability tiers:
12
- * - Advanced workflow & phase management (12 tools)
13
- * - Deeper graph navigation (6 tools)
14
- * - Conviction & analytics (7 tools)
15
- * - Extended question & evidence analytics (1 tool; core lifecycle promoted to MCP)
16
- * - Task lifecycle (5 tools)
17
- * - Domain analytics (8 tools)
18
- * - Bias detection suite (5 tools)
19
- *
20
- * CONTRACT SURFACE: These definitions are the external API for SDK consumers.
21
- * Renaming a tool or changing its description is a BREAKING CHANGE.
22
- *
23
- * Git-native naming rules (same as MCP, enforced by lint):
24
- * 1. Workflow tools use git verbs directly
25
- * 2. Knowledge tools use epistemic verbs
26
- * 3. First sentence of description includes the git analog verb
27
- * 4. Description includes "Like `git X`" parenthetical
28
- * 5. Parameter names use domain terms (canonicalText, nodeId, confidence)
29
- */
30
-
31
- /** SDK-only tool contract — same shape as MCP but with sdk-only tier marker */
32
- interface SdkToolContract extends Omit<McpToolContract, "tier"> {
33
- tier: "sdk-only";
34
- }
35
- declare const START_WORKTREE: SdkToolContract;
36
- declare const UPDATE_WORKTREE_PHASE: SdkToolContract;
37
- declare const ADVANCE_WORKTREE_PHASE: SdkToolContract;
38
- declare const ADD_NOTE_TO_WORKTREE: SdkToolContract;
39
- declare const LINK_DOCUMENT_TO_WORKTREE: SdkToolContract;
40
- declare const LINK_EVIDENCE_TO_WORKTREE: SdkToolContract;
41
- declare const LINK_QUESTION_TO_WORKTREE: SdkToolContract;
42
- declare const LINK_BELIEF_TO_WORKTREE: SdkToolContract;
43
- declare const CREATE_SYNTHESIZED_BELIEF: SdkToolContract;
44
- declare const COMPLETE_HYPOTHESIS_FORMATION: SdkToolContract;
45
- declare const COMPLETE_EVIDENCE_REVIEW: SdkToolContract;
46
- declare const REFINE_WORKTREE_BELIEF: SdkToolContract;
47
- declare const TRACE_PROVENANCE: SdkToolContract;
48
- declare const GET_BELIEF_RELATIONSHIPS: SdkToolContract;
49
- declare const GET_BELIEF_SUPPORT_CHAIN: SdkToolContract;
50
- declare const EXPLORE_CONNECTIONS: SdkToolContract;
51
- declare const GET_DEEP_LINEAGE: SdkToolContract;
52
- declare const GRAPH_AWARE_SEARCH: SdkToolContract;
53
- declare const GET_COLLECTION_CONVICTION: SdkToolContract;
54
- declare const GET_CONVICTION_TREND: SdkToolContract;
55
- declare const ANALYZE_BELIEF_CRITICALITY: SdkToolContract;
56
- declare const ANALYZE_BELIEF_CLUSTER_CANDIDATES: SdkToolContract;
57
- declare const CREATE_BELIEF_CONDITIONAL: SdkToolContract;
58
- declare const GET_NECESSARY_EVIDENCE: SdkToolContract;
59
- declare const ANALYZE_REASONING_DEPTH: SdkToolContract;
60
- declare const GET_EVIDENCE_BY_METHODOLOGY: SdkToolContract;
61
- declare const CREATE_EVIDENCE_TASK: SdkToolContract;
62
- declare const LIST_TASKS: SdkToolContract;
63
- declare const UPDATE_TASK: SdkToolContract;
64
- declare const GET_TASK_COUNTS: SdkToolContract;
65
- declare const ADD_RESEARCH_ACTION: SdkToolContract;
66
- declare const GET_PREDICTIONS: SdkToolContract;
67
- declare const GET_SURPRISE_DETECTION: SdkToolContract;
68
- declare const GET_CHALLENGED_BELIEFS: SdkToolContract;
69
- declare const GET_CAUSAL_CHAINS: SdkToolContract;
70
- declare const GET_NON_CONSENSUS_BELIEFS: SdkToolContract;
71
- declare const GET_BELIEFS_BY_EPISTEMIC_STATUS: SdkToolContract;
72
- declare const GET_PRIVILEGED_EVIDENCE: SdkToolContract;
73
- declare const GET_PRIVILEGED_SIGNALS: SdkToolContract;
74
- declare const DETECT_ANCHORING_BIAS: SdkToolContract;
75
- declare const DETECT_SOURCE_CONCENTRATION: SdkToolContract;
76
- declare const FIND_SOFT_CONTRADICTIONS: SdkToolContract;
77
- declare const FIND_SEMANTIC_BRIDGES: SdkToolContract;
78
- declare const FIND_SEMANTIC_ORPHANS: SdkToolContract;
79
- /** All SDK-only tool contracts, indexed by name */
80
- declare const SDK_ONLY_TOOL_CONTRACTS: Record<string, SdkToolContract>;
81
- /** Complete SDK surface: MCP gateway tools + SDK-only advanced tools */
82
- declare const ALL_SDK_TOOL_CONTRACTS: Record<string, McpToolContract | SdkToolContract>;
83
- /** All SDK-only tool names */
84
- declare const SDK_ONLY_TOOL_NAMES: string[];
85
- /** All tool names across the complete SDK surface */
86
- declare const ALL_SDK_TOOL_NAMES: string[];
87
- /**
88
- * Lint validation: every SDK tool description must contain "Like `git" reference.
89
- * Reuses the same git-semantic validation rule as MCP tools.
90
- */
91
- declare function validateSdkGitSemantics(tool: SdkToolContract): {
92
- valid: boolean;
93
- reason?: string;
94
- };
95
-
96
- declare const sdkTools_contract_ADD_NOTE_TO_WORKTREE: typeof ADD_NOTE_TO_WORKTREE;
97
- declare const sdkTools_contract_ADD_RESEARCH_ACTION: typeof ADD_RESEARCH_ACTION;
98
- declare const sdkTools_contract_ADVANCE_WORKTREE_PHASE: typeof ADVANCE_WORKTREE_PHASE;
99
- declare const sdkTools_contract_ALL_SDK_TOOL_CONTRACTS: typeof ALL_SDK_TOOL_CONTRACTS;
100
- declare const sdkTools_contract_ALL_SDK_TOOL_NAMES: typeof ALL_SDK_TOOL_NAMES;
101
- declare const sdkTools_contract_ANALYZE_BELIEF_CLUSTER_CANDIDATES: typeof ANALYZE_BELIEF_CLUSTER_CANDIDATES;
102
- declare const sdkTools_contract_ANALYZE_BELIEF_CRITICALITY: typeof ANALYZE_BELIEF_CRITICALITY;
103
- declare const sdkTools_contract_ANALYZE_REASONING_DEPTH: typeof ANALYZE_REASONING_DEPTH;
104
- declare const sdkTools_contract_COMPLETE_EVIDENCE_REVIEW: typeof COMPLETE_EVIDENCE_REVIEW;
105
- declare const sdkTools_contract_COMPLETE_HYPOTHESIS_FORMATION: typeof COMPLETE_HYPOTHESIS_FORMATION;
106
- declare const sdkTools_contract_CREATE_BELIEF_CONDITIONAL: typeof CREATE_BELIEF_CONDITIONAL;
107
- declare const sdkTools_contract_CREATE_EVIDENCE_TASK: typeof CREATE_EVIDENCE_TASK;
108
- declare const sdkTools_contract_CREATE_SYNTHESIZED_BELIEF: typeof CREATE_SYNTHESIZED_BELIEF;
109
- declare const sdkTools_contract_DETECT_ANCHORING_BIAS: typeof DETECT_ANCHORING_BIAS;
110
- declare const sdkTools_contract_DETECT_SOURCE_CONCENTRATION: typeof DETECT_SOURCE_CONCENTRATION;
111
- declare const sdkTools_contract_EXPLORE_CONNECTIONS: typeof EXPLORE_CONNECTIONS;
112
- declare const sdkTools_contract_FIND_SEMANTIC_BRIDGES: typeof FIND_SEMANTIC_BRIDGES;
113
- declare const sdkTools_contract_FIND_SEMANTIC_ORPHANS: typeof FIND_SEMANTIC_ORPHANS;
114
- declare const sdkTools_contract_FIND_SOFT_CONTRADICTIONS: typeof FIND_SOFT_CONTRADICTIONS;
115
- declare const sdkTools_contract_GET_BELIEFS_BY_EPISTEMIC_STATUS: typeof GET_BELIEFS_BY_EPISTEMIC_STATUS;
116
- declare const sdkTools_contract_GET_BELIEF_RELATIONSHIPS: typeof GET_BELIEF_RELATIONSHIPS;
117
- declare const sdkTools_contract_GET_BELIEF_SUPPORT_CHAIN: typeof GET_BELIEF_SUPPORT_CHAIN;
118
- declare const sdkTools_contract_GET_CAUSAL_CHAINS: typeof GET_CAUSAL_CHAINS;
119
- declare const sdkTools_contract_GET_CHALLENGED_BELIEFS: typeof GET_CHALLENGED_BELIEFS;
120
- declare const sdkTools_contract_GET_COLLECTION_CONVICTION: typeof GET_COLLECTION_CONVICTION;
121
- declare const sdkTools_contract_GET_CONVICTION_TREND: typeof GET_CONVICTION_TREND;
122
- declare const sdkTools_contract_GET_DEEP_LINEAGE: typeof GET_DEEP_LINEAGE;
123
- declare const sdkTools_contract_GET_EVIDENCE_BY_METHODOLOGY: typeof GET_EVIDENCE_BY_METHODOLOGY;
124
- declare const sdkTools_contract_GET_NECESSARY_EVIDENCE: typeof GET_NECESSARY_EVIDENCE;
125
- declare const sdkTools_contract_GET_NON_CONSENSUS_BELIEFS: typeof GET_NON_CONSENSUS_BELIEFS;
126
- declare const sdkTools_contract_GET_PREDICTIONS: typeof GET_PREDICTIONS;
127
- declare const sdkTools_contract_GET_PRIVILEGED_EVIDENCE: typeof GET_PRIVILEGED_EVIDENCE;
128
- declare const sdkTools_contract_GET_PRIVILEGED_SIGNALS: typeof GET_PRIVILEGED_SIGNALS;
129
- declare const sdkTools_contract_GET_SURPRISE_DETECTION: typeof GET_SURPRISE_DETECTION;
130
- declare const sdkTools_contract_GET_TASK_COUNTS: typeof GET_TASK_COUNTS;
131
- declare const sdkTools_contract_GRAPH_AWARE_SEARCH: typeof GRAPH_AWARE_SEARCH;
132
- declare const sdkTools_contract_LINK_BELIEF_TO_WORKTREE: typeof LINK_BELIEF_TO_WORKTREE;
133
- declare const sdkTools_contract_LINK_DOCUMENT_TO_WORKTREE: typeof LINK_DOCUMENT_TO_WORKTREE;
134
- declare const sdkTools_contract_LINK_EVIDENCE_TO_WORKTREE: typeof LINK_EVIDENCE_TO_WORKTREE;
135
- declare const sdkTools_contract_LINK_QUESTION_TO_WORKTREE: typeof LINK_QUESTION_TO_WORKTREE;
136
- declare const sdkTools_contract_LIST_TASKS: typeof LIST_TASKS;
137
- declare const sdkTools_contract_REFINE_WORKTREE_BELIEF: typeof REFINE_WORKTREE_BELIEF;
138
- declare const sdkTools_contract_SDK_ONLY_TOOL_CONTRACTS: typeof SDK_ONLY_TOOL_CONTRACTS;
139
- declare const sdkTools_contract_SDK_ONLY_TOOL_NAMES: typeof SDK_ONLY_TOOL_NAMES;
140
- declare const sdkTools_contract_START_WORKTREE: typeof START_WORKTREE;
141
- type sdkTools_contract_SdkToolContract = SdkToolContract;
142
- declare const sdkTools_contract_TRACE_PROVENANCE: typeof TRACE_PROVENANCE;
143
- declare const sdkTools_contract_UPDATE_TASK: typeof UPDATE_TASK;
144
- declare const sdkTools_contract_UPDATE_WORKTREE_PHASE: typeof UPDATE_WORKTREE_PHASE;
145
- declare const sdkTools_contract_validateSdkGitSemantics: typeof validateSdkGitSemantics;
146
- declare namespace sdkTools_contract {
147
- export { sdkTools_contract_ADD_NOTE_TO_WORKTREE as ADD_NOTE_TO_WORKTREE, sdkTools_contract_ADD_RESEARCH_ACTION as ADD_RESEARCH_ACTION, sdkTools_contract_ADVANCE_WORKTREE_PHASE as ADVANCE_WORKTREE_PHASE, sdkTools_contract_ALL_SDK_TOOL_CONTRACTS as ALL_SDK_TOOL_CONTRACTS, sdkTools_contract_ALL_SDK_TOOL_NAMES as ALL_SDK_TOOL_NAMES, sdkTools_contract_ANALYZE_BELIEF_CLUSTER_CANDIDATES as ANALYZE_BELIEF_CLUSTER_CANDIDATES, sdkTools_contract_ANALYZE_BELIEF_CRITICALITY as ANALYZE_BELIEF_CRITICALITY, sdkTools_contract_ANALYZE_REASONING_DEPTH as ANALYZE_REASONING_DEPTH, sdkTools_contract_COMPLETE_EVIDENCE_REVIEW as COMPLETE_EVIDENCE_REVIEW, sdkTools_contract_COMPLETE_HYPOTHESIS_FORMATION as COMPLETE_HYPOTHESIS_FORMATION, sdkTools_contract_CREATE_BELIEF_CONDITIONAL as CREATE_BELIEF_CONDITIONAL, sdkTools_contract_CREATE_EVIDENCE_TASK as CREATE_EVIDENCE_TASK, sdkTools_contract_CREATE_SYNTHESIZED_BELIEF as CREATE_SYNTHESIZED_BELIEF, sdkTools_contract_DETECT_ANCHORING_BIAS as DETECT_ANCHORING_BIAS, sdkTools_contract_DETECT_SOURCE_CONCENTRATION as DETECT_SOURCE_CONCENTRATION, sdkTools_contract_EXPLORE_CONNECTIONS as EXPLORE_CONNECTIONS, sdkTools_contract_FIND_SEMANTIC_BRIDGES as FIND_SEMANTIC_BRIDGES, sdkTools_contract_FIND_SEMANTIC_ORPHANS as FIND_SEMANTIC_ORPHANS, sdkTools_contract_FIND_SOFT_CONTRADICTIONS as FIND_SOFT_CONTRADICTIONS, sdkTools_contract_GET_BELIEFS_BY_EPISTEMIC_STATUS as GET_BELIEFS_BY_EPISTEMIC_STATUS, sdkTools_contract_GET_BELIEF_RELATIONSHIPS as GET_BELIEF_RELATIONSHIPS, sdkTools_contract_GET_BELIEF_SUPPORT_CHAIN as GET_BELIEF_SUPPORT_CHAIN, sdkTools_contract_GET_CAUSAL_CHAINS as GET_CAUSAL_CHAINS, sdkTools_contract_GET_CHALLENGED_BELIEFS as GET_CHALLENGED_BELIEFS, sdkTools_contract_GET_COLLECTION_CONVICTION as GET_COLLECTION_CONVICTION, sdkTools_contract_GET_CONVICTION_TREND as GET_CONVICTION_TREND, sdkTools_contract_GET_DEEP_LINEAGE as GET_DEEP_LINEAGE, sdkTools_contract_GET_EVIDENCE_BY_METHODOLOGY as GET_EVIDENCE_BY_METHODOLOGY, sdkTools_contract_GET_NECESSARY_EVIDENCE as GET_NECESSARY_EVIDENCE, sdkTools_contract_GET_NON_CONSENSUS_BELIEFS as GET_NON_CONSENSUS_BELIEFS, sdkTools_contract_GET_PREDICTIONS as GET_PREDICTIONS, sdkTools_contract_GET_PRIVILEGED_EVIDENCE as GET_PRIVILEGED_EVIDENCE, sdkTools_contract_GET_PRIVILEGED_SIGNALS as GET_PRIVILEGED_SIGNALS, sdkTools_contract_GET_SURPRISE_DETECTION as GET_SURPRISE_DETECTION, sdkTools_contract_GET_TASK_COUNTS as GET_TASK_COUNTS, sdkTools_contract_GRAPH_AWARE_SEARCH as GRAPH_AWARE_SEARCH, sdkTools_contract_LINK_BELIEF_TO_WORKTREE as LINK_BELIEF_TO_WORKTREE, sdkTools_contract_LINK_DOCUMENT_TO_WORKTREE as LINK_DOCUMENT_TO_WORKTREE, sdkTools_contract_LINK_EVIDENCE_TO_WORKTREE as LINK_EVIDENCE_TO_WORKTREE, sdkTools_contract_LINK_QUESTION_TO_WORKTREE as LINK_QUESTION_TO_WORKTREE, sdkTools_contract_LIST_TASKS as LIST_TASKS, sdkTools_contract_REFINE_WORKTREE_BELIEF as REFINE_WORKTREE_BELIEF, sdkTools_contract_SDK_ONLY_TOOL_CONTRACTS as SDK_ONLY_TOOL_CONTRACTS, sdkTools_contract_SDK_ONLY_TOOL_NAMES as SDK_ONLY_TOOL_NAMES, sdkTools_contract_START_WORKTREE as START_WORKTREE, type sdkTools_contract_SdkToolContract as SdkToolContract, sdkTools_contract_TRACE_PROVENANCE as TRACE_PROVENANCE, sdkTools_contract_UPDATE_TASK as UPDATE_TASK, sdkTools_contract_UPDATE_WORKTREE_PHASE as UPDATE_WORKTREE_PHASE, sdkTools_contract_validateSdkGitSemantics as validateSdkGitSemantics };
148
- }
149
-
150
- export { ADVANCE_WORKTREE_PHASE as A, GET_CHALLENGED_BELIEFS as B, CREATE_SYNTHESIZED_BELIEF as C, GET_CAUSAL_CHAINS as D, EXPLORE_CONNECTIONS as E, GET_NON_CONSENSUS_BELIEFS as F, GET_BELIEF_RELATIONSHIPS as G, GET_BELIEFS_BY_EPISTEMIC_STATUS as H, GET_PRIVILEGED_EVIDENCE as I, GET_PRIVILEGED_SIGNALS as J, DETECT_ANCHORING_BIAS as K, LINK_DOCUMENT_TO_WORKTREE as L, DETECT_SOURCE_CONCENTRATION as M, FIND_SOFT_CONTRADICTIONS as N, FIND_SEMANTIC_BRIDGES as O, FIND_SEMANTIC_ORPHANS as P, SDK_ONLY_TOOL_CONTRACTS as Q, REFINE_WORKTREE_BELIEF as R, type SdkToolContract as S, TRACE_PROVENANCE as T, UPDATE_WORKTREE_PHASE as U, ALL_SDK_TOOL_CONTRACTS as V, SDK_ONLY_TOOL_NAMES as W, ALL_SDK_TOOL_NAMES as X, validateSdkGitSemantics as Y, START_WORKTREE as a, ADD_NOTE_TO_WORKTREE as b, LINK_EVIDENCE_TO_WORKTREE as c, LINK_QUESTION_TO_WORKTREE as d, LINK_BELIEF_TO_WORKTREE as e, COMPLETE_HYPOTHESIS_FORMATION as f, COMPLETE_EVIDENCE_REVIEW as g, GET_BELIEF_SUPPORT_CHAIN as h, GET_DEEP_LINEAGE as i, GRAPH_AWARE_SEARCH as j, GET_COLLECTION_CONVICTION as k, GET_CONVICTION_TREND as l, ANALYZE_BELIEF_CRITICALITY as m, ANALYZE_BELIEF_CLUSTER_CANDIDATES as n, CREATE_BELIEF_CONDITIONAL as o, GET_NECESSARY_EVIDENCE as p, ANALYZE_REASONING_DEPTH as q, GET_EVIDENCE_BY_METHODOLOGY as r, sdkTools_contract as s, CREATE_EVIDENCE_TASK as t, LIST_TASKS as u, UPDATE_TASK as v, GET_TASK_COUNTS as w, ADD_RESEARCH_ACTION as x, GET_PREDICTIONS as y, GET_SURPRISE_DETECTION as z };
@@ -1,24 +0,0 @@
1
- import { GatewayClientConfig, PlatformGatewaySuccess } from './coreClient.js';
2
- export { LucernApiError } from './coreClient.js';
3
- import { JsonObject, PlatformSourceRecord } from './types.js';
4
- export { GetSourceResponse, UpsertSourceResponse } from './types.js';
5
- import './contracts/workflow-runtime.contract.js';
6
- import './contracts/lens-workflow.contract.js';
7
- import './contracts/lens-filter.contract.js';
8
-
9
- type SourcesClientConfig = GatewayClientConfig;
10
- type UpsertSourceSpec = {
11
- url?: string;
12
- sha?: string;
13
- kind: string;
14
- title?: string;
15
- capturedAt?: number;
16
- topicId?: string;
17
- metadata?: JsonObject;
18
- };
19
- declare function createSourcesClient(config?: SourcesClientConfig): {
20
- upsert(spec: UpsertSourceSpec, idempotencyKey?: string): Promise<PlatformGatewaySuccess<PlatformSourceRecord>>;
21
- get(sourceId: string): Promise<PlatformGatewaySuccess<PlatformSourceRecord>>;
22
- };
23
-
24
- export { PlatformGatewaySuccess, type SourcesClientConfig, type UpsertSourceSpec, createSourcesClient };
@@ -1,339 +0,0 @@
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 fillRandomBytes(length) {
25
- const bytes = new Uint8Array(length);
26
- if (typeof globalThis.crypto?.getRandomValues === "function") {
27
- globalThis.crypto.getRandomValues(bytes);
28
- return bytes;
29
- }
30
- for (let index = 0; index < length; index += 1) {
31
- bytes[index] = Math.floor(Math.random() * 256);
32
- }
33
- return bytes;
34
- }
35
- function generatePortableRequestId() {
36
- if (typeof globalThis.crypto?.randomUUID === "function") {
37
- return globalThis.crypto.randomUUID();
38
- }
39
- const bytes = fillRandomBytes(16);
40
- bytes[6] = bytes[6] & 15 | 64;
41
- bytes[8] = bytes[8] & 63 | 128;
42
- const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
43
- return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
44
- 6,
45
- 8
46
- ).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
47
- }
48
- function randomIdempotencyKey() {
49
- return generatePortableRequestId();
50
- }
51
- function isRetryableStatus(status) {
52
- return status >= 500 || status === 408 || status === 429;
53
- }
54
- function fallbackErrorCode(status) {
55
- if (status === 401) {
56
- return "AUTHENTICATION_REQUIRED";
57
- }
58
- if (status === 403) {
59
- return "FORBIDDEN";
60
- }
61
- if (status === 404) {
62
- return "NOT_FOUND";
63
- }
64
- if (status === 408) {
65
- return "UPSTREAM_ERROR";
66
- }
67
- if (status === 409) {
68
- return "CONFLICT";
69
- }
70
- if (status === 429) {
71
- return "RATE_LIMIT_EXCEEDED";
72
- }
73
- if (status >= 500) {
74
- return "UPSTREAM_ERROR";
75
- }
76
- return "INTERNAL_ERROR";
77
- }
78
- function delay(ms) {
79
- return new Promise((resolve) => setTimeout(resolve, ms));
80
- }
81
- function parseRetryAfterMs(value) {
82
- if (!value) {
83
- return null;
84
- }
85
- const trimmed = value.trim();
86
- if (!trimmed) {
87
- return null;
88
- }
89
- const numeric = Number(trimmed);
90
- if (Number.isFinite(numeric)) {
91
- return Math.max(0, Math.round(numeric * 1e3));
92
- }
93
- const parsedDate = Date.parse(trimmed);
94
- if (Number.isFinite(parsedDate)) {
95
- return Math.max(0, parsedDate - Date.now());
96
- }
97
- return null;
98
- }
99
- function computeRetryDelayMs(args) {
100
- const baseDelay = args.status === 429 ? Math.max(
101
- args.retryAfterMs ?? 0,
102
- Math.min(1e3 * 2 ** args.attempt, 1e4)
103
- ) : Math.min(1e3 * 2 ** args.attempt, 4e3);
104
- if (args.status !== 429) {
105
- return baseDelay;
106
- }
107
- const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
108
- return baseDelay + Math.round(Math.random() * jitterWindow);
109
- }
110
- function timeoutError(timeoutMs) {
111
- const error = new Error(`Request timed out after ${timeoutMs}ms`);
112
- error.name = "AbortError";
113
- return error;
114
- }
115
- function readPolicySummaryFromDetails(details) {
116
- if (!details || typeof details !== "object" || Array.isArray(details)) {
117
- return null;
118
- }
119
- const directSummary = details.summary;
120
- if (typeof directSummary === "string" && directSummary.trim().length > 0) {
121
- return directSummary.trim();
122
- }
123
- const policy = details.policy;
124
- if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
125
- return null;
126
- }
127
- const explanation = policy.explanation;
128
- if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
129
- return null;
130
- }
131
- const nestedSummary = explanation.summary;
132
- if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
133
- return nestedSummary.trim();
134
- }
135
- return null;
136
- }
137
- function createGatewayRequestClient(config = {}) {
138
- const fetchImpl = config.fetchImpl ?? fetch;
139
- const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
140
- const maxRetries = config.maxRetries ?? 2;
141
- const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
142
- async function resolveAuthHeaders() {
143
- if (!config.getAuthHeaders) {
144
- return {};
145
- }
146
- return await config.getAuthHeaders();
147
- }
148
- async function fetchWithTimeout(url, init, timeoutMs) {
149
- const controller = new AbortController();
150
- const timer = setTimeout(() => controller.abort(), timeoutMs);
151
- try {
152
- return await fetchImpl(url, { ...init, signal: controller.signal });
153
- } catch (error) {
154
- if (controller.signal.aborted) {
155
- throw timeoutError(timeoutMs);
156
- }
157
- throw error;
158
- } finally {
159
- clearTimeout(timer);
160
- }
161
- }
162
- async function parsePayload(response) {
163
- const text = await response.text();
164
- if (!text) {
165
- return null;
166
- }
167
- try {
168
- return JSON.parse(text);
169
- } catch {
170
- return null;
171
- }
172
- }
173
- function resolveTimeoutMs(method, requestTimeoutMs) {
174
- if (typeof requestTimeoutMs === "number") {
175
- return requestTimeoutMs;
176
- }
177
- const methodTimeoutMs = config.timeoutMsByMethod?.[method];
178
- if (typeof methodTimeoutMs === "number") {
179
- return methodTimeoutMs;
180
- }
181
- return config.timeoutMs ?? 15e3;
182
- }
183
- function buildApiError(args) {
184
- const failure = args.failure;
185
- const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
186
- const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
187
- const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
188
- const details = failure?.details ?? legacyError?.details;
189
- const policySummary = readPolicySummaryFromDetails(details);
190
- return new LucernApiError({
191
- code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
192
- message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
193
- status: args.response.status,
194
- invariant: failure?.invariant,
195
- suggestion: failure?.suggestion,
196
- details,
197
- requestId: args.requestId,
198
- correlationId,
199
- policyTraceId
200
- });
201
- }
202
- async function request(args) {
203
- const authHeaders = await resolveAuthHeaders();
204
- const method = args.method ?? "GET";
205
- const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
206
- const headers = new Headers({
207
- "content-type": "application/json",
208
- ...authHeaders
209
- });
210
- if (args.idempotencyKey) {
211
- headers.set("idempotency-key", args.idempotencyKey);
212
- }
213
- const requestId = headers.get("x-correlation-id")?.trim() || headers.get("x-request-id")?.trim() || args.requestId || requestIdFactory();
214
- if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
215
- headers.set("x-correlation-id", requestId);
216
- }
217
- const url = `${baseUrl}${args.path}`;
218
- const serializedBody = args.body ? JSON.stringify(args.body) : void 0;
219
- const init = {
220
- method,
221
- headers,
222
- body: serializedBody
223
- };
224
- let lastError;
225
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
226
- const hookRequestContext = {
227
- requestId,
228
- attempt,
229
- maxRetries,
230
- method,
231
- path: args.path,
232
- url,
233
- headers: new Headers(headers),
234
- body: serializedBody,
235
- timeoutMs
236
- };
237
- await config.onRequest?.(hookRequestContext);
238
- const startedAt = Date.now();
239
- try {
240
- const response = await fetchWithTimeout(url, init, timeoutMs);
241
- const responseClone = response.clone();
242
- const payload = await parsePayload(response);
243
- const retryAfterMs = parseRetryAfterMs(
244
- response.headers.get("Retry-After")
245
- );
246
- if (!response.ok || !payload?.success) {
247
- const failure = payload && !payload.success ? payload : null;
248
- const apiError = buildApiError({
249
- requestId,
250
- response,
251
- failure
252
- });
253
- const willRetry = attempt < maxRetries && isRetryableStatus(response.status);
254
- await config.onResponse?.({
255
- ...hookRequestContext,
256
- durationMs: Date.now() - startedAt,
257
- status: response.status,
258
- response: responseClone,
259
- error: apiError,
260
- correlationId: apiError.correlationId ?? requestId,
261
- policyTraceId: apiError.policyTraceId ?? null,
262
- retryAfterMs,
263
- willRetry
264
- });
265
- if (willRetry) {
266
- lastError = apiError;
267
- await delay(
268
- computeRetryDelayMs({
269
- attempt,
270
- status: response.status,
271
- retryAfterMs
272
- })
273
- );
274
- continue;
275
- }
276
- throw apiError;
277
- }
278
- const successPayload = payload;
279
- await config.onResponse?.({
280
- ...hookRequestContext,
281
- durationMs: Date.now() - startedAt,
282
- status: response.status,
283
- response: responseClone,
284
- correlationId: successPayload.correlationId ?? response.headers.get("x-lucern-correlation-id")?.trim() ?? requestId,
285
- policyTraceId: successPayload.policyTraceId ?? response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null,
286
- idempotentReplay: successPayload.idempotentReplay,
287
- retryAfterMs,
288
- willRetry: false
289
- });
290
- return successPayload;
291
- } catch (fetchError) {
292
- if (fetchError instanceof LucernApiError) {
293
- throw fetchError;
294
- }
295
- const willRetry = attempt < maxRetries;
296
- await config.onResponse?.({
297
- ...hookRequestContext,
298
- durationMs: Date.now() - startedAt,
299
- error: fetchError,
300
- correlationId: requestId,
301
- policyTraceId: null,
302
- willRetry
303
- });
304
- lastError = fetchError;
305
- if (willRetry) {
306
- await delay(computeRetryDelayMs({ attempt }));
307
- }
308
- }
309
- }
310
- throw lastError instanceof Error ? lastError : new Error("Platform API request failed after retries.");
311
- }
312
- return {
313
- request
314
- };
315
- }
316
-
317
- // src/sourcesClient.ts
318
- function createSourcesClient(config = {}) {
319
- const gateway = createGatewayRequestClient(config);
320
- return {
321
- async upsert(spec, idempotencyKey = randomIdempotencyKey()) {
322
- return gateway.request({
323
- path: "/api/platform/v1/sources/upsert",
324
- method: "POST",
325
- body: spec,
326
- idempotencyKey
327
- });
328
- },
329
- async get(sourceId) {
330
- return gateway.request({
331
- path: `/api/platform/v1/sources/${encodeURIComponent(sourceId)}`
332
- });
333
- }
334
- };
335
- }
336
-
337
- export { LucernApiError, createSourcesClient };
338
- //# sourceMappingURL=sourcesClient.js.map
339
- //# sourceMappingURL=sourcesClient.js.map