@lucern/sdk 1.0.11 → 1.0.13

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 (331) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +24 -27
  3. package/dist/.generated +2 -0
  4. package/dist/accessControl.d.ts +19 -26
  5. package/dist/accessControl.js +195 -1423
  6. package/dist/adminClient.d.ts +52 -59
  7. package/dist/adminClient.js +364 -1142
  8. package/dist/answersClient.d.ts +5 -14
  9. package/dist/answersClient.js +19 -737
  10. package/dist/audience/index.d.ts +18 -18
  11. package/dist/audience/index.js +87 -90
  12. package/dist/audiencesClient.d.ts +19 -27
  13. package/dist/audiencesClient.js +107 -868
  14. package/dist/auditClient.d.ts +8 -15
  15. package/dist/auditClient.js +18 -791
  16. package/dist/authContext.d.ts +11 -16
  17. package/dist/authContext.js +122 -154
  18. package/dist/authDeviceClient.d.ts +8 -17
  19. package/dist/authDeviceClient.js +113 -102
  20. package/dist/beliefs/index.d.ts +16 -67
  21. package/dist/beliefs/index.js +20 -10181
  22. package/dist/beliefs/lifecycle.d.ts +10 -11
  23. package/dist/beliefs/lifecycle.js +78 -80
  24. package/dist/beliefsClient.d.ts +30 -35
  25. package/dist/beliefsClient.js +238 -994
  26. package/dist/boundaryClientSurface.d.ts +11 -16
  27. package/dist/boundaryClientSurface.js +49 -68
  28. package/dist/client.d.ts +82 -113
  29. package/dist/client.js +232 -10155
  30. package/dist/clientAssemblyTypes.d.ts +3 -3
  31. package/dist/clientAssemblyTypes.js +1 -2
  32. package/dist/clientConfig.d.ts +45 -59
  33. package/dist/clientConfig.js +1 -2
  34. package/dist/clientEvidenceCompat.d.ts +24 -14
  35. package/dist/clientEvidenceCompat.js +56 -64
  36. package/dist/clientGraphNamespaces.d.ts +3 -5
  37. package/dist/clientGraphNamespaces.js +170 -245
  38. package/dist/clientHelpers.d.ts +20 -25
  39. package/dist/clientHelpers.js +104 -127
  40. package/dist/clientKnowledgeNamespaces.d.ts +24 -54
  41. package/dist/clientKnowledgeNamespaces.js +506 -506
  42. package/dist/clientLocalHelpers.d.ts +11 -56
  43. package/dist/clientLocalHelpers.js +503 -732
  44. package/dist/clientPlatformNamespaces.d.ts +5 -53
  45. package/dist/clientPlatformNamespaces.js +229 -323
  46. package/dist/clientRuntime.d.ts +5 -53
  47. package/dist/clientRuntime.js +26 -30
  48. package/dist/clientWorkflowNamespaces.d.ts +6 -15
  49. package/dist/clientWorkflowNamespaces.js +529 -596
  50. package/dist/contextClient.d.ts +9 -17
  51. package/dist/contextClient.js +92 -805
  52. package/dist/contextFacade.d.ts +11 -2
  53. package/dist/contextFacade.js +10 -81
  54. package/dist/contextPackCompiler.d.ts +10 -11
  55. package/dist/contextPackCompiler.js +494 -1040
  56. package/dist/contextPackPolicy.d.ts +14 -15
  57. package/dist/contextPackPolicy.js +227 -305
  58. package/dist/contextPackSchema.d.ts +3 -3
  59. package/dist/contextPackSchema.js +169 -176
  60. package/dist/contextTypes.d.ts +14 -15
  61. package/dist/contextTypes.js +1 -2
  62. package/dist/contracts/api-enums.contract.d.ts +29 -30
  63. package/dist/contracts/api-enums.contract.js +162 -88
  64. package/dist/contracts/auth-session.contract.d.ts +13 -14
  65. package/dist/contracts/auth-session.contract.js +55 -52
  66. package/dist/contracts/context-pack.contract.d.ts +54 -55
  67. package/dist/contracts/context-pack.contract.js +160 -88
  68. package/dist/contracts/contextPack.d.ts +2 -1
  69. package/dist/contracts/contextPack.js +1 -97
  70. package/dist/contracts/index.d.ts +11 -12
  71. package/dist/contracts/index.js +10 -854
  72. package/dist/contracts/lens-filter.contract.d.ts +9 -10
  73. package/dist/contracts/lens-filter.contract.js +82 -58
  74. package/dist/contracts/lens-workflow.contract.d.ts +21 -23
  75. package/dist/contracts/lens-workflow.contract.js +48 -117
  76. package/dist/contracts/lensFilter.d.ts +2 -1
  77. package/dist/contracts/lensFilter.js +1 -71
  78. package/dist/contracts/lensWorkflow.d.ts +2 -2
  79. package/dist/contracts/lensWorkflow.js +1 -123
  80. package/dist/contracts/mcpTools.d.ts +16 -18
  81. package/dist/contracts/mcpTools.js +89 -123
  82. package/dist/contracts/prompt.contract.d.ts +4 -5
  83. package/dist/contracts/prompt.contract.js +23 -10
  84. package/dist/contracts/prompt.d.ts +2 -1
  85. package/dist/contracts/prompt.js +1 -11
  86. package/dist/contracts/sdk-tools.contract.d.ts +2 -1
  87. package/dist/contracts/sdk-tools.contract.js +1 -2
  88. package/dist/contracts/sdkTools.d.ts +2 -1
  89. package/dist/contracts/sdkTools.js +1 -26
  90. package/dist/contracts/tool-contracts.d.ts +2 -1
  91. package/dist/contracts/tool-contracts.js +1 -2
  92. package/dist/contracts/workflow-runtime.contract.d.ts +45 -46
  93. package/dist/contracts/workflow-runtime.contract.js +241 -228
  94. package/dist/contracts/workflowRuntime.d.ts +2 -1
  95. package/dist/contracts/workflowRuntime.js +1 -244
  96. package/dist/contradictions/index.d.ts +8 -60
  97. package/dist/contradictions/index.js +11 -10175
  98. package/dist/control-plane.d.ts +17 -24
  99. package/dist/control-plane.js +124 -840
  100. package/dist/controlObjectOwnership.d.ts +19 -20
  101. package/dist/controlObjectOwnership.js +207 -201
  102. package/dist/coreClient.d.ts +23 -28
  103. package/dist/coreClient.js +567 -692
  104. package/dist/customTools.d.ts +17 -21
  105. package/dist/customTools.js +221 -221
  106. package/dist/decisions/index.d.ts +7 -58
  107. package/dist/decisions/index.js +14 -10177
  108. package/dist/decisionsClient.d.ts +25 -32
  109. package/dist/decisionsClient.js +113 -913
  110. package/dist/domainContext.d.ts +2 -1
  111. package/dist/domainContext.js +1 -2
  112. package/dist/edges/index.d.ts +21 -73
  113. package/dist/edges/index.js +12 -10176
  114. package/dist/embeddingsClient.d.ts +22 -30
  115. package/dist/embeddingsClient.js +73 -922
  116. package/dist/eventingClient.d.ts +23 -31
  117. package/dist/eventingClient.js +89 -918
  118. package/dist/events.d.ts +48 -49
  119. package/dist/events.js +257 -241
  120. package/dist/eventsCore.d.ts +20 -29
  121. package/dist/eventsCore.js +86 -830
  122. package/dist/evidence/index.d.ts +42 -61
  123. package/dist/evidence/index.js +13 -10176
  124. package/dist/evidenceClient.d.ts +13 -22
  125. package/dist/evidenceClient.js +34 -751
  126. package/dist/facade/context.d.ts +7 -8
  127. package/dist/facade/context.js +73 -72
  128. package/dist/functionSurface.d.ts +2 -156
  129. package/dist/functionSurface.js +1 -1460
  130. package/dist/functionSurfaceClient.d.ts +2 -9
  131. package/dist/functionSurfaceClient.js +1 -1460
  132. package/dist/gatewayFacades.d.ts +93 -296
  133. package/dist/gatewayFacades.factories.d.ts +209 -14
  134. package/dist/gatewayFacades.factories.js +545 -2228
  135. package/dist/gatewayFacades.js +284 -2627
  136. package/dist/generated/functionSurface.d.ts +149 -0
  137. package/dist/generated/functionSurface.js +749 -0
  138. package/dist/graphAnalysisClient.d.ts +41 -49
  139. package/dist/graphAnalysisClient.js +185 -974
  140. package/dist/graphClient.d.ts +53 -60
  141. package/dist/graphClient.js +219 -1090
  142. package/dist/graphIntel.d.ts +2 -4
  143. package/dist/graphIntel.js +1 -2
  144. package/dist/graphIntelligence.d.ts +4 -2
  145. package/dist/graphIntelligence.js +2 -46
  146. package/dist/graphRecommendationsClient.d.ts +15 -23
  147. package/dist/graphRecommendationsClient.js +70 -849
  148. package/dist/graphStateClassifierClient.d.ts +17 -25
  149. package/dist/graphStateClassifierClient.js +67 -908
  150. package/dist/harnessClient.d.ts +40 -47
  151. package/dist/harnessClient.js +198 -993
  152. package/dist/identityClient.d.ts +25 -33
  153. package/dist/identityClient.js +245 -1186
  154. package/dist/index.d.ts +73 -69
  155. package/dist/index.js +72 -13313
  156. package/dist/infisicalRuntime.d.ts +12 -14
  157. package/dist/infisicalRuntime.js +290 -297
  158. package/dist/jobsClient.d.ts +24 -32
  159. package/dist/jobsClient.js +101 -916
  160. package/dist/learningClient.d.ts +8 -16
  161. package/dist/learningClient.js +45 -809
  162. package/dist/lenses/index.d.ts +13 -65
  163. package/dist/lenses/index.js +11 -10175
  164. package/dist/mcpClient.d.ts +14 -23
  165. package/dist/mcpClient.js +115 -856
  166. package/dist/modelRuntimeClient.d.ts +18 -26
  167. package/dist/modelRuntimeClient.js +74 -894
  168. package/dist/nodes/index.d.ts +7 -58
  169. package/dist/nodes/index.js +14 -10177
  170. package/dist/ontologies/index.d.ts +21 -73
  171. package/dist/ontologies/index.js +14 -10178
  172. package/dist/ontologyClient.d.ts +23 -31
  173. package/dist/ontologyClient.js +138 -924
  174. package/dist/ontologyLinksClient.d.ts +16 -24
  175. package/dist/ontologyLinksClient.js +76 -886
  176. package/dist/opinion.d.ts +5 -6
  177. package/dist/opinion.js +21 -25
  178. package/dist/orgGraphSearchClient.d.ts +19 -27
  179. package/dist/orgGraphSearchClient.js +89 -857
  180. package/dist/packRuntime.d.ts +2 -2
  181. package/dist/packRuntime.js +1 -2
  182. package/dist/packsClient.d.ts +30 -37
  183. package/dist/packsClient.js +131 -906
  184. package/dist/policyClient.d.ts +21 -29
  185. package/dist/policyClient.js +267 -1026
  186. package/dist/proof-attestation.json +1 -1
  187. package/dist/questions/index.d.ts +9 -60
  188. package/dist/questions/index.js +15 -10178
  189. package/dist/realtime/index.d.ts +20 -16
  190. package/dist/realtime/index.js +30 -19
  191. package/dist/realtime/refs.d.ts +4 -6
  192. package/dist/realtime/refs.js +12 -7
  193. package/dist/realtime-refs.d.ts +1 -0
  194. package/dist/realtime-refs.js +1 -0
  195. package/dist/realtime.d.ts +1 -0
  196. package/dist/realtime.js +1 -0
  197. package/dist/reportsClient.d.ts +10 -19
  198. package/dist/reportsClient.js +48 -836
  199. package/dist/schemaClient.d.ts +16 -23
  200. package/dist/schemaClient.js +62 -832
  201. package/dist/sdkSurface.d.ts +18 -25
  202. package/dist/sdkSurface.js +135 -106
  203. package/dist/secrets.d.ts +2 -1
  204. package/dist/secrets.js +1 -2
  205. package/dist/sourcesClient.d.ts +11 -18
  206. package/dist/sourcesClient.js +18 -741
  207. package/dist/telemetryClient.d.ts +22 -30
  208. package/dist/telemetryClient.js +107 -931
  209. package/dist/toolRegistryClient.d.ts +27 -35
  210. package/dist/toolRegistryClient.js +116 -954
  211. package/dist/topics/index.d.ts +13 -64
  212. package/dist/topics/index.js +15 -10178
  213. package/dist/topicsClient.d.ts +19 -27
  214. package/dist/topicsClient.js +106 -894
  215. package/dist/types.d.ts +84 -87
  216. package/dist/types.js +1 -2
  217. package/dist/version.d.ts +2 -3
  218. package/dist/version.js +2 -5
  219. package/dist/workflowClient.d.ts +60 -65
  220. package/dist/workflowClient.js +343 -1219
  221. package/dist/worktrees/index.d.ts +16 -68
  222. package/dist/worktrees/index.js +14 -10178
  223. package/package.json +6 -6
  224. package/dist/accessControl.js.map +0 -1
  225. package/dist/adminClient.js.map +0 -1
  226. package/dist/answersClient.js.map +0 -1
  227. package/dist/audience/index.js.map +0 -1
  228. package/dist/audiencesClient.js.map +0 -1
  229. package/dist/auditClient.js.map +0 -1
  230. package/dist/authContext.js.map +0 -1
  231. package/dist/authDeviceClient.js.map +0 -1
  232. package/dist/beliefs/index.js.map +0 -1
  233. package/dist/beliefs/lifecycle.js.map +0 -1
  234. package/dist/beliefsClient.js.map +0 -1
  235. package/dist/boundaryClientSurface.js.map +0 -1
  236. package/dist/client.js.map +0 -1
  237. package/dist/clientAssemblyTypes.js.map +0 -1
  238. package/dist/clientConfig.js.map +0 -1
  239. package/dist/clientEvidenceCompat.js.map +0 -1
  240. package/dist/clientGraphNamespaces.js.map +0 -1
  241. package/dist/clientHelpers.js.map +0 -1
  242. package/dist/clientKnowledgeNamespaces.js.map +0 -1
  243. package/dist/clientLocalHelpers.js.map +0 -1
  244. package/dist/clientPlatformNamespaces.js.map +0 -1
  245. package/dist/clientRuntime.js.map +0 -1
  246. package/dist/clientWorkflowNamespaces.js.map +0 -1
  247. package/dist/contextClient.js.map +0 -1
  248. package/dist/contextFacade.js.map +0 -1
  249. package/dist/contextPackCompiler.js.map +0 -1
  250. package/dist/contextPackPolicy.js.map +0 -1
  251. package/dist/contextPackSchema.js.map +0 -1
  252. package/dist/contextTypes.js.map +0 -1
  253. package/dist/contracts/api-enums.contract.js.map +0 -1
  254. package/dist/contracts/auth-session.contract.js.map +0 -1
  255. package/dist/contracts/context-pack.contract.js.map +0 -1
  256. package/dist/contracts/contextPack.js.map +0 -1
  257. package/dist/contracts/index.js.map +0 -1
  258. package/dist/contracts/lens-filter.contract.js.map +0 -1
  259. package/dist/contracts/lens-workflow.contract.js.map +0 -1
  260. package/dist/contracts/lensFilter.js.map +0 -1
  261. package/dist/contracts/lensWorkflow.js.map +0 -1
  262. package/dist/contracts/mcpTools.js.map +0 -1
  263. package/dist/contracts/prompt.contract.js.map +0 -1
  264. package/dist/contracts/prompt.js.map +0 -1
  265. package/dist/contracts/sdk-tools.contract.js.map +0 -1
  266. package/dist/contracts/sdkTools.js.map +0 -1
  267. package/dist/contracts/tool-contracts.js.map +0 -1
  268. package/dist/contracts/workflow-runtime.contract.js.map +0 -1
  269. package/dist/contracts/workflowRuntime.js.map +0 -1
  270. package/dist/contradictions/index.js.map +0 -1
  271. package/dist/control-plane.js.map +0 -1
  272. package/dist/controlObjectOwnership.js.map +0 -1
  273. package/dist/coreClient.js.map +0 -1
  274. package/dist/customTools.js.map +0 -1
  275. package/dist/decisions/index.js.map +0 -1
  276. package/dist/decisionsClient.js.map +0 -1
  277. package/dist/domainContext.js.map +0 -1
  278. package/dist/edges/index.js.map +0 -1
  279. package/dist/embeddingsClient.js.map +0 -1
  280. package/dist/eventingClient.js.map +0 -1
  281. package/dist/events.js.map +0 -1
  282. package/dist/eventsCore.js.map +0 -1
  283. package/dist/evidence/index.js.map +0 -1
  284. package/dist/evidenceClient.js.map +0 -1
  285. package/dist/facade/context.js.map +0 -1
  286. package/dist/functionSurface.js.map +0 -1
  287. package/dist/functionSurfaceClient.js.map +0 -1
  288. package/dist/gatewayFacades.factories.js.map +0 -1
  289. package/dist/gatewayFacades.js.map +0 -1
  290. package/dist/graphAnalysisClient.js.map +0 -1
  291. package/dist/graphClient.js.map +0 -1
  292. package/dist/graphIntel.js.map +0 -1
  293. package/dist/graphIntelligence.js.map +0 -1
  294. package/dist/graphRecommendationsClient.js.map +0 -1
  295. package/dist/graphStateClassifierClient.js.map +0 -1
  296. package/dist/harnessClient.js.map +0 -1
  297. package/dist/identityClient.js.map +0 -1
  298. package/dist/index.js.map +0 -1
  299. package/dist/infisicalRuntime.js.map +0 -1
  300. package/dist/jobsClient.js.map +0 -1
  301. package/dist/learningClient.js.map +0 -1
  302. package/dist/lenses/index.js.map +0 -1
  303. package/dist/mcpClient.js.map +0 -1
  304. package/dist/modelRuntimeClient.js.map +0 -1
  305. package/dist/nodes/index.js.map +0 -1
  306. package/dist/ontologies/index.js.map +0 -1
  307. package/dist/ontologyClient.js.map +0 -1
  308. package/dist/ontologyLinksClient.js.map +0 -1
  309. package/dist/opinion.js.map +0 -1
  310. package/dist/orgGraphSearchClient.js.map +0 -1
  311. package/dist/packRuntime.js.map +0 -1
  312. package/dist/packsClient.js.map +0 -1
  313. package/dist/policyClient.js.map +0 -1
  314. package/dist/questions/index.js.map +0 -1
  315. package/dist/realtime/index.js.map +0 -1
  316. package/dist/realtime/refs.js.map +0 -1
  317. package/dist/reportsClient.js.map +0 -1
  318. package/dist/schemaClient.js.map +0 -1
  319. package/dist/sdk-tools.contract-B4c1Zr1o.d.ts +0 -22
  320. package/dist/sdkSurface.js.map +0 -1
  321. package/dist/secrets.js.map +0 -1
  322. package/dist/sourcesClient.js.map +0 -1
  323. package/dist/telemetryClient.js.map +0 -1
  324. package/dist/tool-contracts-BUiL9P6z.d.ts +0 -22
  325. package/dist/toolRegistryClient.js.map +0 -1
  326. package/dist/topics/index.js.map +0 -1
  327. package/dist/topicsClient.js.map +0 -1
  328. package/dist/types.js.map +0 -1
  329. package/dist/version.js.map +0 -1
  330. package/dist/workflowClient.js.map +0 -1
  331. package/dist/worktrees/index.js.map +0 -1
@@ -1,25 +1,21 @@
1
- import { z } from 'zod';
2
- import { McpToolContract } from '@lucern/contracts/tool-contracts';
3
- import { JsonObject } from './types.js';
4
- import './contracts/workflow-runtime.contract.js';
5
- import './contracts/lens-workflow.contract.js';
6
- import './contracts/lens-filter.contract.js';
7
-
1
+ import { z } from "zod";
2
+ import type { McpToolContract } from "./contracts/mcpTools";
3
+ import type { JsonObject } from "./types";
8
4
  type AnyZodObject = z.ZodObject<z.ZodRawShape>;
9
5
  /** Origin of a custom tool invocation (SDK call or MCP request). */
10
- type CustomToolInvocationSource = "sdk" | "mcp";
6
+ export type CustomToolInvocationSource = "sdk" | "mcp";
11
7
  /** Runtime context passed to a custom tool handler during invocation. */
12
- type CustomToolInvocationContext = {
8
+ export type CustomToolInvocationContext = {
13
9
  source: CustomToolInvocationSource;
14
10
  };
15
11
  /** Optional metadata attached to a custom tool registration. */
16
- type CustomToolMetadata = {
12
+ export type CustomToolMetadata = {
17
13
  category?: string;
18
14
  tags?: string[];
19
15
  requiredScopes?: string[];
20
16
  };
21
17
  /** Input descriptor for registering a custom tool with its schemas and handler. */
22
- type CustomToolRegistration<TInput extends AnyZodObject = AnyZodObject, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
18
+ export type CustomToolRegistration<TInput extends AnyZodObject = AnyZodObject, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
23
19
  namespace?: string;
24
20
  name: string;
25
21
  description: string;
@@ -32,7 +28,7 @@ type CustomToolRegistration<TInput extends AnyZodObject = AnyZodObject, TOutput
32
28
  tier?: McpToolContract["tier"];
33
29
  };
34
30
  /** A fully resolved custom tool entry stored in the in-memory registry. */
35
- type RegisteredCustomTool = {
31
+ export type RegisteredCustomTool = {
36
32
  fullName: string;
37
33
  namespace: string;
38
34
  shortName: string;
@@ -43,7 +39,7 @@ type RegisteredCustomTool = {
43
39
  invoke: (input: JsonObject, context: CustomToolInvocationContext) => Promise<unknown>;
44
40
  };
45
41
  /** Error thrown when custom tool registration or invocation fails validation. */
46
- declare class CustomToolRegistryError extends Error {
42
+ export declare class CustomToolRegistryError extends Error {
47
43
  constructor(message: string);
48
44
  }
49
45
  /**
@@ -52,7 +48,7 @@ declare class CustomToolRegistryError extends Error {
52
48
  * @param options - Optional flags; set `replace` to overwrite an existing registration.
53
49
  * @returns The fully resolved registered tool entry.
54
50
  */
55
- declare function registerCustomTool<TInput extends AnyZodObject, TOutput extends z.ZodTypeAny>(registration: CustomToolRegistration<TInput, TOutput>, options?: {
51
+ export declare function registerCustomTool<TInput extends AnyZodObject, TOutput extends z.ZodTypeAny>(registration: CustomToolRegistration<TInput, TOutput>, options?: {
56
52
  replace?: boolean;
57
53
  }): RegisteredCustomTool;
58
54
  /**
@@ -60,22 +56,22 @@ declare function registerCustomTool<TInput extends AnyZodObject, TOutput extends
60
56
  * @param fullName - Fully qualified tool name (`namespace.name`).
61
57
  * @returns `true` if the tool was found and removed, `false` otherwise.
62
58
  */
63
- declare function unregisterCustomTool(fullName: string): boolean;
59
+ export declare function unregisterCustomTool(fullName: string): boolean;
64
60
  /**
65
61
  * Get a custom SDK tool by fully qualified name.
66
62
  * @param fullName - Fully qualified tool name (`namespace.name`).
67
63
  * @returns The registered tool entry, or `undefined` if not found.
68
64
  */
69
- declare function getRegisteredCustomTool(fullName: string): RegisteredCustomTool | undefined;
65
+ export declare function getRegisteredCustomTool(fullName: string): RegisteredCustomTool | undefined;
70
66
  /**
71
67
  * List all registered custom SDK tools, sorted alphabetically by full name.
72
68
  * @returns An array of all registered tool entries.
73
69
  */
74
- declare function listRegisteredCustomTools(): RegisteredCustomTool[];
70
+ export declare function listRegisteredCustomTools(): RegisteredCustomTool[];
75
71
  /**
76
72
  * Clear the registered custom tool registry.
77
73
  */
78
- declare function clearRegisteredCustomTools(): void;
74
+ export declare function clearRegisteredCustomTools(): void;
79
75
  /**
80
76
  * Invoke a registered custom SDK tool by fully qualified name.
81
77
  * @param fullName - Fully qualified tool name (`namespace.name`).
@@ -83,6 +79,6 @@ declare function clearRegisteredCustomTools(): void;
83
79
  * @param context - Invocation context indicating the call source.
84
80
  * @returns The validated output from the tool handler.
85
81
  */
86
- declare function invokeRegisteredCustomTool(fullName: string, params: JsonObject, context: CustomToolInvocationContext): Promise<unknown>;
87
-
88
- export { type CustomToolInvocationContext, type CustomToolInvocationSource, type CustomToolMetadata, type CustomToolRegistration, CustomToolRegistryError, type RegisteredCustomTool, clearRegisteredCustomTools, getRegisteredCustomTool, invokeRegisteredCustomTool, listRegisteredCustomTools, registerCustomTool, unregisterCustomTool };
82
+ export declare function invokeRegisteredCustomTool(fullName: string, params: JsonObject, context: CustomToolInvocationContext): Promise<unknown>;
83
+ export {};
84
+ //# sourceMappingURL=customTools.d.ts.map
@@ -1,248 +1,248 @@
1
- import { z } from 'zod';
2
-
3
- // src/customTools.ts
4
- var DEFAULT_CUSTOM_NAMESPACE = "custom";
5
- var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
6
- var CustomToolRegistryError = class extends Error {
7
- constructor(message) {
8
- super(message);
9
- this.name = "CustomToolRegistryError";
10
- }
11
- };
12
- var customToolRegistry = /* @__PURE__ */ new Map();
1
+ import { z } from "zod";
2
+ /** Default namespace assigned to custom tools when none is specified. */
3
+ const DEFAULT_CUSTOM_NAMESPACE = "custom";
4
+ /** Namespace strings reserved for platform-internal tools. */
5
+ const RESERVED_NAMESPACES = new Set(["lucern"]);
6
+ /** Error thrown when custom tool registration or invocation fails validation. */
7
+ export class CustomToolRegistryError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "CustomToolRegistryError";
11
+ }
12
+ }
13
+ const customToolRegistry = new Map();
13
14
  function normalizeSegment(value, field) {
14
- const normalized = value.trim();
15
- if (!normalized) {
16
- throw new CustomToolRegistryError(`Custom tool ${field} is required.`);
17
- }
18
- if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(normalized)) {
19
- throw new CustomToolRegistryError(
20
- `Invalid custom tool ${field}: "${value}". Use letters, numbers, "_" or "-".`
21
- );
22
- }
23
- return normalized;
15
+ const normalized = value.trim();
16
+ if (!normalized) {
17
+ throw new CustomToolRegistryError(`Custom tool ${field} is required.`);
18
+ }
19
+ if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(normalized)) {
20
+ throw new CustomToolRegistryError(`Invalid custom tool ${field}: "${value}". Use letters, numbers, "_" or "-".`);
21
+ }
22
+ return normalized;
24
23
  }
25
24
  function normalizeNamespace(namespace) {
26
- const resolved = normalizeSegment(
27
- namespace ?? DEFAULT_CUSTOM_NAMESPACE,
28
- "namespace"
29
- );
30
- if (RESERVED_NAMESPACES.has(resolved.toLowerCase())) {
31
- throw new CustomToolRegistryError(
32
- `Namespace "${resolved}" is reserved for platform tools.`
33
- );
34
- }
35
- return resolved;
25
+ const resolved = normalizeSegment(namespace ?? DEFAULT_CUSTOM_NAMESPACE, "namespace");
26
+ if (RESERVED_NAMESPACES.has(resolved.toLowerCase())) {
27
+ throw new CustomToolRegistryError(`Namespace "${resolved}" is reserved for platform tools.`);
28
+ }
29
+ return resolved;
36
30
  }
37
31
  function normalizeName(name) {
38
- if (name.includes(".")) {
39
- throw new CustomToolRegistryError(
40
- `Custom tool name "${name}" must not include "."; use namespace + name.`
41
- );
42
- }
43
- return normalizeSegment(name, "name");
32
+ if (name.includes(".")) {
33
+ throw new CustomToolRegistryError(`Custom tool name "${name}" must not include "."; use namespace + name.`);
34
+ }
35
+ return normalizeSegment(name, "name");
44
36
  }
45
37
  function buildFullName(namespace, shortName) {
46
- return `${namespace}.${shortName}`;
38
+ return `${namespace}.${shortName}`;
47
39
  }
48
40
  function unwrapSchema(schema) {
49
- if (schema instanceof z.ZodOptional) {
50
- return { schema: schema.unwrap(), required: false };
51
- }
52
- if (schema instanceof z.ZodDefault) {
53
- const removeDefault = schema.removeDefault;
54
- if (typeof removeDefault === "function") {
55
- return { schema: removeDefault.call(schema), required: false };
56
- }
57
- const inner = schema._def?.innerType;
58
- return { schema: inner ?? schema, required: false };
59
- }
60
- return { schema, required: true };
41
+ if (schema instanceof z.ZodOptional) {
42
+ return { schema: schema.unwrap(), required: false };
43
+ }
44
+ if (schema instanceof z.ZodDefault) {
45
+ const removeDefault = schema.removeDefault;
46
+ if (typeof removeDefault === "function") {
47
+ return { schema: removeDefault.call(schema), required: false };
48
+ }
49
+ const inner = schema
50
+ ._def?.innerType;
51
+ return { schema: inner ?? schema, required: false };
52
+ }
53
+ return { schema, required: true };
61
54
  }
62
55
  function resolveParameterType(schema) {
63
- if (schema instanceof z.ZodString) {
64
- return { type: "string" };
65
- }
66
- if (schema instanceof z.ZodEnum) {
67
- return { type: "string", enum: schema.options };
68
- }
69
- if (schema instanceof z.ZodNativeEnum) {
70
- const values = Object.values(schema.enum).filter(
71
- (value) => typeof value === "string"
72
- );
73
- return values.length > 0 ? { type: "string", enum: values } : { type: "string" };
74
- }
75
- if (schema instanceof z.ZodLiteral) {
76
- const literalValue = schema.value;
77
- if (typeof literalValue === "string") {
78
- return { type: "string", enum: [literalValue] };
79
- }
80
- if (typeof literalValue === "number") {
81
- return { type: "number" };
82
- }
83
- if (typeof literalValue === "boolean") {
84
- return { type: "boolean" };
56
+ if (schema instanceof z.ZodString) {
57
+ return { type: "string" };
58
+ }
59
+ if (schema instanceof z.ZodEnum) {
60
+ return { type: "string", enum: schema.options };
61
+ }
62
+ if (schema instanceof z.ZodNativeEnum) {
63
+ const values = Object.values(schema.enum).filter((value) => typeof value === "string");
64
+ return values.length > 0
65
+ ? { type: "string", enum: values }
66
+ : { type: "string" };
67
+ }
68
+ if (schema instanceof z.ZodLiteral) {
69
+ const literalValue = schema.value;
70
+ if (typeof literalValue === "string") {
71
+ return { type: "string", enum: [literalValue] };
72
+ }
73
+ if (typeof literalValue === "number") {
74
+ return { type: "number" };
75
+ }
76
+ if (typeof literalValue === "boolean") {
77
+ return { type: "boolean" };
78
+ }
79
+ return { type: "object" };
80
+ }
81
+ if (schema instanceof z.ZodNumber) {
82
+ return { type: "number" };
83
+ }
84
+ if (schema instanceof z.ZodBoolean) {
85
+ return { type: "boolean" };
86
+ }
87
+ if (schema instanceof z.ZodArray) {
88
+ return { type: "array" };
85
89
  }
86
90
  return { type: "object" };
87
- }
88
- if (schema instanceof z.ZodNumber) {
89
- return { type: "number" };
90
- }
91
- if (schema instanceof z.ZodBoolean) {
92
- return { type: "boolean" };
93
- }
94
- if (schema instanceof z.ZodArray) {
95
- return { type: "array" };
96
- }
97
- return { type: "object" };
98
91
  }
99
92
  function schemaTypeLabel(schema) {
100
- if (schema instanceof z.ZodString || schema instanceof z.ZodEnum) {
101
- return "string";
102
- }
103
- if (schema instanceof z.ZodNumber) {
104
- return "number";
105
- }
106
- if (schema instanceof z.ZodBoolean) {
107
- return "boolean";
108
- }
109
- if (schema instanceof z.ZodArray) {
110
- return "array";
111
- }
112
- if (schema instanceof z.ZodObject) {
113
- return "object";
114
- }
115
- return "unknown";
93
+ if (schema instanceof z.ZodString || schema instanceof z.ZodEnum) {
94
+ return "string";
95
+ }
96
+ if (schema instanceof z.ZodNumber) {
97
+ return "number";
98
+ }
99
+ if (schema instanceof z.ZodBoolean) {
100
+ return "boolean";
101
+ }
102
+ if (schema instanceof z.ZodArray) {
103
+ return "array";
104
+ }
105
+ if (schema instanceof z.ZodObject) {
106
+ return "object";
107
+ }
108
+ return "unknown";
116
109
  }
117
110
  function parseObjectSchema(value, fieldName) {
118
- if (!(value instanceof z.ZodObject)) {
119
- throw new CustomToolRegistryError(
120
- `${fieldName} must be a Zod object schema.`
121
- );
122
- }
123
- return value;
111
+ if (!(value instanceof z.ZodObject)) {
112
+ throw new CustomToolRegistryError(`${fieldName} must be a Zod object schema.`);
113
+ }
114
+ return value;
124
115
  }
125
116
  function deriveParameters(schema) {
126
- const shape = schema.shape;
127
- const parameters = {};
128
- const required = [];
129
- for (const [key, raw] of Object.entries(shape)) {
130
- const { schema: unwrapped, required: isRequired } = unwrapSchema(
131
- raw
132
- );
133
- const parameterType = resolveParameterType(unwrapped);
134
- parameters[key] = {
135
- type: parameterType.type,
136
- description: raw.description ?? `${key} parameter`,
137
- ...parameterType.enum ? { enum: parameterType.enum } : {}
138
- };
139
- if (isRequired) {
140
- required.push(key);
117
+ const shape = schema.shape;
118
+ const parameters = {};
119
+ const required = [];
120
+ for (const [key, raw] of Object.entries(shape)) {
121
+ const { schema: unwrapped, required: isRequired } = unwrapSchema(raw);
122
+ const parameterType = resolveParameterType(unwrapped);
123
+ parameters[key] = {
124
+ type: parameterType.type,
125
+ description: raw.description ?? `${key} parameter`,
126
+ ...(parameterType.enum ? { enum: parameterType.enum } : {}),
127
+ };
128
+ if (isRequired) {
129
+ required.push(key);
130
+ }
141
131
  }
142
- }
143
- return { parameters, required };
132
+ return { parameters, required };
144
133
  }
145
134
  function deriveResponse(schema) {
146
- if (schema instanceof z.ZodObject) {
147
- const fields = Object.fromEntries(
148
- Object.entries(schema.shape).map(([key, value]) => {
149
- const zodValue = value;
150
- const label = schemaTypeLabel(unwrapSchema(zodValue).schema);
151
- const description = zodValue.description ?? "custom output field";
152
- return [key, `${label} \u2014 ${description}`];
153
- })
154
- );
135
+ if (schema instanceof z.ZodObject) {
136
+ const fields = Object.fromEntries(Object.entries(schema.shape).map(([key, value]) => {
137
+ const zodValue = value;
138
+ const label = schemaTypeLabel(unwrapSchema(zodValue).schema);
139
+ const description = zodValue.description ?? "custom output field";
140
+ return [key, `${label} — ${description}`];
141
+ }));
142
+ return {
143
+ description: "Custom tool result payload",
144
+ fields,
145
+ };
146
+ }
155
147
  return {
156
- description: "Custom tool result payload",
157
- fields
148
+ description: "Custom tool result payload",
149
+ fields: {
150
+ result: `${schemaTypeLabel(schema)} — custom output payload`,
151
+ },
158
152
  };
159
- }
160
- return {
161
- description: "Custom tool result payload",
162
- fields: {
163
- result: `${schemaTypeLabel(schema)} \u2014 custom output payload`
164
- }
165
- };
166
153
  }
167
154
  function buildContract(fullName, namespace, registration, inputSchema) {
168
- const { parameters, required } = deriveParameters(inputSchema);
169
- return {
170
- name: fullName,
171
- description: registration.description,
172
- parameters,
173
- required,
174
- response: deriveResponse(registration.outputSchema),
175
- ownerModule: registration.ownerModule ?? `${namespace}-extension`,
176
- ontologyPrimitive: registration.ontologyPrimitive ?? "task",
177
- tier: registration.tier ?? "workhorse"
178
- };
179
- }
180
- function registerCustomTool(registration, options = {}) {
181
- const namespace = normalizeNamespace(registration.namespace);
182
- const shortName = normalizeName(registration.name);
183
- const fullName = buildFullName(namespace, shortName);
184
- if (customToolRegistry.has(fullName) && !options.replace) {
185
- throw new CustomToolRegistryError(
186
- `Custom tool "${fullName}" is already registered.`
187
- );
188
- }
189
- const inputSchema = parseObjectSchema(
190
- registration.inputSchema,
191
- "inputSchema"
192
- );
193
- const outputSchema = registration.outputSchema;
194
- const contract = buildContract(
195
- fullName,
196
- namespace,
197
- registration,
198
- inputSchema
199
- );
200
- const metadata = {
201
- category: registration.metadata?.category,
202
- tags: registration.metadata?.tags ?? [],
203
- requiredScopes: registration.metadata?.requiredScopes ?? ["custom:execute"]
204
- };
205
- const registered = {
206
- fullName,
207
- namespace,
208
- shortName,
209
- metadata,
210
- contract,
211
- inputSchema,
212
- outputSchema,
213
- invoke: async (input, context) => {
214
- const parsedInput = inputSchema.parse(input);
215
- const rawOutput = await registration.handler(parsedInput, context);
216
- return outputSchema.parse(rawOutput);
217
- }
218
- };
219
- customToolRegistry.set(fullName, registered);
220
- return registered;
221
- }
222
- function unregisterCustomTool(fullName) {
223
- return customToolRegistry.delete(fullName.trim());
224
- }
225
- function getRegisteredCustomTool(fullName) {
226
- return customToolRegistry.get(fullName.trim());
227
- }
228
- function listRegisteredCustomTools() {
229
- return [...customToolRegistry.values()].sort(
230
- (left, right) => left.fullName.localeCompare(right.fullName)
231
- );
232
- }
233
- function clearRegisteredCustomTools() {
234
- customToolRegistry.clear();
235
- }
236
- async function invokeRegisteredCustomTool(fullName, params, context) {
237
- const registered = getRegisteredCustomTool(fullName);
238
- if (!registered) {
239
- throw new CustomToolRegistryError(
240
- `Custom tool "${fullName}" is not registered.`
241
- );
242
- }
243
- return registered.invoke(params, context);
244
- }
245
-
246
- export { CustomToolRegistryError, clearRegisteredCustomTools, getRegisteredCustomTool, invokeRegisteredCustomTool, listRegisteredCustomTools, registerCustomTool, unregisterCustomTool };
247
- //# sourceMappingURL=customTools.js.map
155
+ const { parameters, required } = deriveParameters(inputSchema);
156
+ return {
157
+ name: fullName,
158
+ description: registration.description,
159
+ parameters,
160
+ required,
161
+ response: deriveResponse(registration.outputSchema),
162
+ ownerModule: registration.ownerModule ?? `${namespace}-extension`,
163
+ ontologyPrimitive: registration.ontologyPrimitive ?? "task",
164
+ tier: registration.tier ?? "workhorse",
165
+ };
166
+ }
167
+ /**
168
+ * Register a custom SDK tool in the in-memory registry.
169
+ * @param registration - The tool definition including name, schemas, and handler.
170
+ * @param options - Optional flags; set `replace` to overwrite an existing registration.
171
+ * @returns The fully resolved registered tool entry.
172
+ */
173
+ export function registerCustomTool(registration, options = {}) {
174
+ const namespace = normalizeNamespace(registration.namespace);
175
+ const shortName = normalizeName(registration.name);
176
+ const fullName = buildFullName(namespace, shortName);
177
+ if (customToolRegistry.has(fullName) && !options.replace) {
178
+ throw new CustomToolRegistryError(`Custom tool "${fullName}" is already registered.`);
179
+ }
180
+ const inputSchema = parseObjectSchema(registration.inputSchema, "inputSchema");
181
+ const outputSchema = registration.outputSchema;
182
+ const contract = buildContract(fullName, namespace, registration, inputSchema);
183
+ const metadata = {
184
+ category: registration.metadata?.category,
185
+ tags: registration.metadata?.tags ?? [],
186
+ requiredScopes: registration.metadata?.requiredScopes ?? ["custom:execute"],
187
+ };
188
+ const registered = {
189
+ fullName,
190
+ namespace,
191
+ shortName,
192
+ metadata,
193
+ contract,
194
+ inputSchema,
195
+ outputSchema,
196
+ invoke: async (input, context) => {
197
+ const parsedInput = inputSchema.parse(input);
198
+ const rawOutput = await registration.handler(parsedInput, context);
199
+ return outputSchema.parse(rawOutput);
200
+ },
201
+ };
202
+ customToolRegistry.set(fullName, registered);
203
+ return registered;
204
+ }
205
+ /**
206
+ * Remove a custom SDK tool from the registry.
207
+ * @param fullName - Fully qualified tool name (`namespace.name`).
208
+ * @returns `true` if the tool was found and removed, `false` otherwise.
209
+ */
210
+ export function unregisterCustomTool(fullName) {
211
+ return customToolRegistry.delete(fullName.trim());
212
+ }
213
+ /**
214
+ * Get a custom SDK tool by fully qualified name.
215
+ * @param fullName - Fully qualified tool name (`namespace.name`).
216
+ * @returns The registered tool entry, or `undefined` if not found.
217
+ */
218
+ export function getRegisteredCustomTool(fullName) {
219
+ return customToolRegistry.get(fullName.trim());
220
+ }
221
+ /**
222
+ * List all registered custom SDK tools, sorted alphabetically by full name.
223
+ * @returns An array of all registered tool entries.
224
+ */
225
+ export function listRegisteredCustomTools() {
226
+ return [...customToolRegistry.values()].sort((left, right) => left.fullName.localeCompare(right.fullName));
227
+ }
228
+ /**
229
+ * Clear the registered custom tool registry.
230
+ */
231
+ export function clearRegisteredCustomTools() {
232
+ customToolRegistry.clear();
233
+ }
234
+ /**
235
+ * Invoke a registered custom SDK tool by fully qualified name.
236
+ * @param fullName - Fully qualified tool name (`namespace.name`).
237
+ * @param params - JSON-serializable input parameters for the tool handler.
238
+ * @param context - Invocation context indicating the call source.
239
+ * @returns The validated output from the tool handler.
240
+ */
241
+ export async function invokeRegisteredCustomTool(fullName, params, context) {
242
+ const registered = getRegisteredCustomTool(fullName);
243
+ if (!registered) {
244
+ throw new CustomToolRegistryError(`Custom tool "${fullName}" is not registered.`);
245
+ }
246
+ return registered.invoke(params, context);
247
+ }
248
248
  //# sourceMappingURL=customTools.js.map
@@ -1,59 +1,9 @@
1
- import { LucernClientConfig } from '../clientConfig.js';
2
- import * as sdkMethods_contract from '@lucern/contracts/sdk-methods.contract';
3
- export { sdkMethods_contract as methodSchemas };
4
- import * as toolContracts from '@lucern/contracts/tool-contracts';
5
- export { toolContracts as toolSchemas };
6
- import '../clientHelpers.js';
7
- import '../types.js';
8
- import '../contracts/workflow-runtime.contract.js';
9
- import '../contracts/lens-workflow.contract.js';
10
- import '../contracts/lens-filter.contract.js';
11
- import '../adminClient.js';
12
- import '../coreClient.js';
13
- import '@lucern/transport-core';
14
- import '../authContext.js';
15
- import '../contracts/auth-session.contract.js';
16
- import '../controlObjectOwnership.js';
17
- import '../answersClient.js';
18
- import '../audiencesClient.js';
19
- import '../auditClient.js';
20
- import '../beliefsClient.js';
21
- import '../opinion.js';
22
- import '../contextClient.js';
23
- import '../contextTypes.js';
24
- import '../control-plane.js';
25
- import '../decisionsClient.js';
26
- import '../embeddingsClient.js';
27
- import '../boundaryClientSurface.js';
28
- import '../eventingClient.js';
29
- import '../evidenceClient.js';
30
- import '../functionSurface.js';
31
- import '../graphAnalysisClient.js';
32
- import '@lucern/contracts';
33
- import '../graphClient.js';
34
- import '../graphRecommendationsClient.js';
35
- import '../graphStateClassifierClient.js';
36
- import '../harnessClient.js';
37
- import '../identityClient.js';
38
- import '../jobsClient.js';
39
- import '../learningClient.js';
40
- import '../modelRuntimeClient.js';
41
- import '../ontologyClient.js';
42
- import '../ontologyLinksClient.js';
43
- import '../orgGraphSearchClient.js';
44
- import '../packsClient.js';
45
- import '../policyClient.js';
46
- import '../reportsClient.js';
47
- import '../schemaClient.js';
48
- import '../sourcesClient.js';
49
- import '../telemetryClient.js';
50
- import '../toolRegistryClient.js';
51
- import '../topicsClient.js';
52
- import '../workflowClient.js';
53
-
54
- type DecisionsClientConfig = LucernClientConfig;
55
- type DecisionsClient = ReturnType<typeof createDecisionsClient>;
56
- declare function createDecisionsClient(config?: DecisionsClientConfig): {
1
+ import { type LucernClientConfig } from "../client";
2
+ export * as methodSchemas from "@lucern/contracts/sdk-methods.contract";
3
+ export * as toolSchemas from "@lucern/contracts/tool-contracts";
4
+ export type DecisionsClientConfig = LucernClientConfig;
5
+ export type DecisionsClient = ReturnType<typeof createDecisionsClient>;
6
+ export declare function createDecisionsClient(config?: DecisionsClientConfig): {
57
7
  createDecision: any;
58
8
  getDecision: any;
59
9
  listDecisions: any;
@@ -79,5 +29,4 @@ declare function createDecisionsClient(config?: DecisionsClientConfig): {
79
29
  }): any;
80
30
  };
81
31
  };
82
-
83
- export { type DecisionsClient, type DecisionsClientConfig, createDecisionsClient };
32
+ //# sourceMappingURL=index.d.ts.map