@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.
- package/CHANGELOG.md +10 -0
- package/README.md +24 -27
- package/dist/.generated +2 -0
- package/dist/accessControl.d.ts +19 -26
- package/dist/accessControl.js +195 -1423
- package/dist/adminClient.d.ts +52 -59
- package/dist/adminClient.js +364 -1142
- package/dist/answersClient.d.ts +5 -14
- package/dist/answersClient.js +19 -737
- package/dist/audience/index.d.ts +18 -18
- package/dist/audience/index.js +87 -90
- package/dist/audiencesClient.d.ts +19 -27
- package/dist/audiencesClient.js +107 -868
- package/dist/auditClient.d.ts +8 -15
- package/dist/auditClient.js +18 -791
- package/dist/authContext.d.ts +11 -16
- package/dist/authContext.js +122 -154
- package/dist/authDeviceClient.d.ts +8 -17
- package/dist/authDeviceClient.js +113 -102
- package/dist/beliefs/index.d.ts +16 -67
- package/dist/beliefs/index.js +20 -10181
- package/dist/beliefs/lifecycle.d.ts +10 -11
- package/dist/beliefs/lifecycle.js +78 -80
- package/dist/beliefsClient.d.ts +30 -35
- package/dist/beliefsClient.js +238 -994
- package/dist/boundaryClientSurface.d.ts +11 -16
- package/dist/boundaryClientSurface.js +49 -68
- package/dist/client.d.ts +82 -113
- package/dist/client.js +232 -10155
- package/dist/clientAssemblyTypes.d.ts +3 -3
- package/dist/clientAssemblyTypes.js +1 -2
- package/dist/clientConfig.d.ts +45 -59
- package/dist/clientConfig.js +1 -2
- package/dist/clientEvidenceCompat.d.ts +24 -14
- package/dist/clientEvidenceCompat.js +56 -64
- package/dist/clientGraphNamespaces.d.ts +3 -5
- package/dist/clientGraphNamespaces.js +170 -245
- package/dist/clientHelpers.d.ts +20 -25
- package/dist/clientHelpers.js +104 -127
- package/dist/clientKnowledgeNamespaces.d.ts +24 -54
- package/dist/clientKnowledgeNamespaces.js +506 -506
- package/dist/clientLocalHelpers.d.ts +11 -56
- package/dist/clientLocalHelpers.js +503 -732
- package/dist/clientPlatformNamespaces.d.ts +5 -53
- package/dist/clientPlatformNamespaces.js +229 -323
- package/dist/clientRuntime.d.ts +5 -53
- package/dist/clientRuntime.js +26 -30
- package/dist/clientWorkflowNamespaces.d.ts +6 -15
- package/dist/clientWorkflowNamespaces.js +529 -596
- package/dist/contextClient.d.ts +9 -17
- package/dist/contextClient.js +92 -805
- package/dist/contextFacade.d.ts +11 -2
- package/dist/contextFacade.js +10 -81
- package/dist/contextPackCompiler.d.ts +10 -11
- package/dist/contextPackCompiler.js +494 -1040
- package/dist/contextPackPolicy.d.ts +14 -15
- package/dist/contextPackPolicy.js +227 -305
- package/dist/contextPackSchema.d.ts +3 -3
- package/dist/contextPackSchema.js +169 -176
- package/dist/contextTypes.d.ts +14 -15
- package/dist/contextTypes.js +1 -2
- package/dist/contracts/api-enums.contract.d.ts +29 -30
- package/dist/contracts/api-enums.contract.js +162 -88
- package/dist/contracts/auth-session.contract.d.ts +13 -14
- package/dist/contracts/auth-session.contract.js +55 -52
- package/dist/contracts/context-pack.contract.d.ts +54 -55
- package/dist/contracts/context-pack.contract.js +160 -88
- package/dist/contracts/contextPack.d.ts +2 -1
- package/dist/contracts/contextPack.js +1 -97
- package/dist/contracts/index.d.ts +11 -12
- package/dist/contracts/index.js +10 -854
- package/dist/contracts/lens-filter.contract.d.ts +9 -10
- package/dist/contracts/lens-filter.contract.js +82 -58
- package/dist/contracts/lens-workflow.contract.d.ts +21 -23
- package/dist/contracts/lens-workflow.contract.js +48 -117
- package/dist/contracts/lensFilter.d.ts +2 -1
- package/dist/contracts/lensFilter.js +1 -71
- package/dist/contracts/lensWorkflow.d.ts +2 -2
- package/dist/contracts/lensWorkflow.js +1 -123
- package/dist/contracts/mcpTools.d.ts +16 -18
- package/dist/contracts/mcpTools.js +89 -123
- package/dist/contracts/prompt.contract.d.ts +4 -5
- package/dist/contracts/prompt.contract.js +23 -10
- package/dist/contracts/prompt.d.ts +2 -1
- package/dist/contracts/prompt.js +1 -11
- package/dist/contracts/sdk-tools.contract.d.ts +2 -1
- package/dist/contracts/sdk-tools.contract.js +1 -2
- package/dist/contracts/sdkTools.d.ts +2 -1
- package/dist/contracts/sdkTools.js +1 -26
- package/dist/contracts/tool-contracts.d.ts +2 -1
- package/dist/contracts/tool-contracts.js +1 -2
- package/dist/contracts/workflow-runtime.contract.d.ts +45 -46
- package/dist/contracts/workflow-runtime.contract.js +241 -228
- package/dist/contracts/workflowRuntime.d.ts +2 -1
- package/dist/contracts/workflowRuntime.js +1 -244
- package/dist/contradictions/index.d.ts +8 -60
- package/dist/contradictions/index.js +11 -10175
- package/dist/control-plane.d.ts +17 -24
- package/dist/control-plane.js +124 -840
- package/dist/controlObjectOwnership.d.ts +19 -20
- package/dist/controlObjectOwnership.js +207 -201
- package/dist/coreClient.d.ts +23 -28
- package/dist/coreClient.js +567 -692
- package/dist/customTools.d.ts +17 -21
- package/dist/customTools.js +221 -221
- package/dist/decisions/index.d.ts +7 -58
- package/dist/decisions/index.js +14 -10177
- package/dist/decisionsClient.d.ts +25 -32
- package/dist/decisionsClient.js +113 -913
- package/dist/domainContext.d.ts +2 -1
- package/dist/domainContext.js +1 -2
- package/dist/edges/index.d.ts +21 -73
- package/dist/edges/index.js +12 -10176
- package/dist/embeddingsClient.d.ts +22 -30
- package/dist/embeddingsClient.js +73 -922
- package/dist/eventingClient.d.ts +23 -31
- package/dist/eventingClient.js +89 -918
- package/dist/events.d.ts +48 -49
- package/dist/events.js +257 -241
- package/dist/eventsCore.d.ts +20 -29
- package/dist/eventsCore.js +86 -830
- package/dist/evidence/index.d.ts +42 -61
- package/dist/evidence/index.js +13 -10176
- package/dist/evidenceClient.d.ts +13 -22
- package/dist/evidenceClient.js +34 -751
- package/dist/facade/context.d.ts +7 -8
- package/dist/facade/context.js +73 -72
- package/dist/functionSurface.d.ts +2 -156
- package/dist/functionSurface.js +1 -1460
- package/dist/functionSurfaceClient.d.ts +2 -9
- package/dist/functionSurfaceClient.js +1 -1460
- package/dist/gatewayFacades.d.ts +93 -296
- package/dist/gatewayFacades.factories.d.ts +209 -14
- package/dist/gatewayFacades.factories.js +545 -2228
- package/dist/gatewayFacades.js +284 -2627
- package/dist/generated/functionSurface.d.ts +149 -0
- package/dist/generated/functionSurface.js +749 -0
- package/dist/graphAnalysisClient.d.ts +41 -49
- package/dist/graphAnalysisClient.js +185 -974
- package/dist/graphClient.d.ts +53 -60
- package/dist/graphClient.js +219 -1090
- package/dist/graphIntel.d.ts +2 -4
- package/dist/graphIntel.js +1 -2
- package/dist/graphIntelligence.d.ts +4 -2
- package/dist/graphIntelligence.js +2 -46
- package/dist/graphRecommendationsClient.d.ts +15 -23
- package/dist/graphRecommendationsClient.js +70 -849
- package/dist/graphStateClassifierClient.d.ts +17 -25
- package/dist/graphStateClassifierClient.js +67 -908
- package/dist/harnessClient.d.ts +40 -47
- package/dist/harnessClient.js +198 -993
- package/dist/identityClient.d.ts +25 -33
- package/dist/identityClient.js +245 -1186
- package/dist/index.d.ts +73 -69
- package/dist/index.js +72 -13313
- package/dist/infisicalRuntime.d.ts +12 -14
- package/dist/infisicalRuntime.js +290 -297
- package/dist/jobsClient.d.ts +24 -32
- package/dist/jobsClient.js +101 -916
- package/dist/learningClient.d.ts +8 -16
- package/dist/learningClient.js +45 -809
- package/dist/lenses/index.d.ts +13 -65
- package/dist/lenses/index.js +11 -10175
- package/dist/mcpClient.d.ts +14 -23
- package/dist/mcpClient.js +115 -856
- package/dist/modelRuntimeClient.d.ts +18 -26
- package/dist/modelRuntimeClient.js +74 -894
- package/dist/nodes/index.d.ts +7 -58
- package/dist/nodes/index.js +14 -10177
- package/dist/ontologies/index.d.ts +21 -73
- package/dist/ontologies/index.js +14 -10178
- package/dist/ontologyClient.d.ts +23 -31
- package/dist/ontologyClient.js +138 -924
- package/dist/ontologyLinksClient.d.ts +16 -24
- package/dist/ontologyLinksClient.js +76 -886
- package/dist/opinion.d.ts +5 -6
- package/dist/opinion.js +21 -25
- package/dist/orgGraphSearchClient.d.ts +19 -27
- package/dist/orgGraphSearchClient.js +89 -857
- package/dist/packRuntime.d.ts +2 -2
- package/dist/packRuntime.js +1 -2
- package/dist/packsClient.d.ts +30 -37
- package/dist/packsClient.js +131 -906
- package/dist/policyClient.d.ts +21 -29
- package/dist/policyClient.js +267 -1026
- package/dist/proof-attestation.json +1 -1
- package/dist/questions/index.d.ts +9 -60
- package/dist/questions/index.js +15 -10178
- package/dist/realtime/index.d.ts +20 -16
- package/dist/realtime/index.js +30 -19
- package/dist/realtime/refs.d.ts +4 -6
- package/dist/realtime/refs.js +12 -7
- package/dist/realtime-refs.d.ts +1 -0
- package/dist/realtime-refs.js +1 -0
- package/dist/realtime.d.ts +1 -0
- package/dist/realtime.js +1 -0
- package/dist/reportsClient.d.ts +10 -19
- package/dist/reportsClient.js +48 -836
- package/dist/schemaClient.d.ts +16 -23
- package/dist/schemaClient.js +62 -832
- package/dist/sdkSurface.d.ts +18 -25
- package/dist/sdkSurface.js +135 -106
- package/dist/secrets.d.ts +2 -1
- package/dist/secrets.js +1 -2
- package/dist/sourcesClient.d.ts +11 -18
- package/dist/sourcesClient.js +18 -741
- package/dist/telemetryClient.d.ts +22 -30
- package/dist/telemetryClient.js +107 -931
- package/dist/toolRegistryClient.d.ts +27 -35
- package/dist/toolRegistryClient.js +116 -954
- package/dist/topics/index.d.ts +13 -64
- package/dist/topics/index.js +15 -10178
- package/dist/topicsClient.d.ts +19 -27
- package/dist/topicsClient.js +106 -894
- package/dist/types.d.ts +84 -87
- package/dist/types.js +1 -2
- package/dist/version.d.ts +2 -3
- package/dist/version.js +2 -5
- package/dist/workflowClient.d.ts +60 -65
- package/dist/workflowClient.js +343 -1219
- package/dist/worktrees/index.d.ts +16 -68
- package/dist/worktrees/index.js +14 -10178
- package/package.json +6 -6
- package/dist/accessControl.js.map +0 -1
- package/dist/adminClient.js.map +0 -1
- package/dist/answersClient.js.map +0 -1
- package/dist/audience/index.js.map +0 -1
- package/dist/audiencesClient.js.map +0 -1
- package/dist/auditClient.js.map +0 -1
- package/dist/authContext.js.map +0 -1
- package/dist/authDeviceClient.js.map +0 -1
- package/dist/beliefs/index.js.map +0 -1
- package/dist/beliefs/lifecycle.js.map +0 -1
- package/dist/beliefsClient.js.map +0 -1
- package/dist/boundaryClientSurface.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/clientAssemblyTypes.js.map +0 -1
- package/dist/clientConfig.js.map +0 -1
- package/dist/clientEvidenceCompat.js.map +0 -1
- package/dist/clientGraphNamespaces.js.map +0 -1
- package/dist/clientHelpers.js.map +0 -1
- package/dist/clientKnowledgeNamespaces.js.map +0 -1
- package/dist/clientLocalHelpers.js.map +0 -1
- package/dist/clientPlatformNamespaces.js.map +0 -1
- package/dist/clientRuntime.js.map +0 -1
- package/dist/clientWorkflowNamespaces.js.map +0 -1
- package/dist/contextClient.js.map +0 -1
- package/dist/contextFacade.js.map +0 -1
- package/dist/contextPackCompiler.js.map +0 -1
- package/dist/contextPackPolicy.js.map +0 -1
- package/dist/contextPackSchema.js.map +0 -1
- package/dist/contextTypes.js.map +0 -1
- package/dist/contracts/api-enums.contract.js.map +0 -1
- package/dist/contracts/auth-session.contract.js.map +0 -1
- package/dist/contracts/context-pack.contract.js.map +0 -1
- package/dist/contracts/contextPack.js.map +0 -1
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/lens-filter.contract.js.map +0 -1
- package/dist/contracts/lens-workflow.contract.js.map +0 -1
- package/dist/contracts/lensFilter.js.map +0 -1
- package/dist/contracts/lensWorkflow.js.map +0 -1
- package/dist/contracts/mcpTools.js.map +0 -1
- package/dist/contracts/prompt.contract.js.map +0 -1
- package/dist/contracts/prompt.js.map +0 -1
- package/dist/contracts/sdk-tools.contract.js.map +0 -1
- package/dist/contracts/sdkTools.js.map +0 -1
- package/dist/contracts/tool-contracts.js.map +0 -1
- package/dist/contracts/workflow-runtime.contract.js.map +0 -1
- package/dist/contracts/workflowRuntime.js.map +0 -1
- package/dist/contradictions/index.js.map +0 -1
- package/dist/control-plane.js.map +0 -1
- package/dist/controlObjectOwnership.js.map +0 -1
- package/dist/coreClient.js.map +0 -1
- package/dist/customTools.js.map +0 -1
- package/dist/decisions/index.js.map +0 -1
- package/dist/decisionsClient.js.map +0 -1
- package/dist/domainContext.js.map +0 -1
- package/dist/edges/index.js.map +0 -1
- package/dist/embeddingsClient.js.map +0 -1
- package/dist/eventingClient.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/eventsCore.js.map +0 -1
- package/dist/evidence/index.js.map +0 -1
- package/dist/evidenceClient.js.map +0 -1
- package/dist/facade/context.js.map +0 -1
- package/dist/functionSurface.js.map +0 -1
- package/dist/functionSurfaceClient.js.map +0 -1
- package/dist/gatewayFacades.factories.js.map +0 -1
- package/dist/gatewayFacades.js.map +0 -1
- package/dist/graphAnalysisClient.js.map +0 -1
- package/dist/graphClient.js.map +0 -1
- package/dist/graphIntel.js.map +0 -1
- package/dist/graphIntelligence.js.map +0 -1
- package/dist/graphRecommendationsClient.js.map +0 -1
- package/dist/graphStateClassifierClient.js.map +0 -1
- package/dist/harnessClient.js.map +0 -1
- package/dist/identityClient.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infisicalRuntime.js.map +0 -1
- package/dist/jobsClient.js.map +0 -1
- package/dist/learningClient.js.map +0 -1
- package/dist/lenses/index.js.map +0 -1
- package/dist/mcpClient.js.map +0 -1
- package/dist/modelRuntimeClient.js.map +0 -1
- package/dist/nodes/index.js.map +0 -1
- package/dist/ontologies/index.js.map +0 -1
- package/dist/ontologyClient.js.map +0 -1
- package/dist/ontologyLinksClient.js.map +0 -1
- package/dist/opinion.js.map +0 -1
- package/dist/orgGraphSearchClient.js.map +0 -1
- package/dist/packRuntime.js.map +0 -1
- package/dist/packsClient.js.map +0 -1
- package/dist/policyClient.js.map +0 -1
- package/dist/questions/index.js.map +0 -1
- package/dist/realtime/index.js.map +0 -1
- package/dist/realtime/refs.js.map +0 -1
- package/dist/reportsClient.js.map +0 -1
- package/dist/schemaClient.js.map +0 -1
- package/dist/sdk-tools.contract-B4c1Zr1o.d.ts +0 -22
- package/dist/sdkSurface.js.map +0 -1
- package/dist/secrets.js.map +0 -1
- package/dist/sourcesClient.js.map +0 -1
- package/dist/telemetryClient.js.map +0 -1
- package/dist/tool-contracts-BUiL9P6z.d.ts +0 -22
- package/dist/toolRegistryClient.js.map +0 -1
- package/dist/topics/index.js.map +0 -1
- package/dist/topicsClient.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/workflowClient.js.map +0 -1
- package/dist/worktrees/index.js.map +0 -1
package/dist/customTools.d.ts
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { McpToolContract } from
|
|
3
|
-
import { JsonObject } from
|
|
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
|
-
|
|
82
|
+
export declare function invokeRegisteredCustomTool(fullName: string, params: JsonObject, context: CustomToolInvocationContext): Promise<unknown>;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=customTools.d.ts.map
|
package/dist/customTools.js
CHANGED
|
@@ -1,248 +1,248 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
38
|
+
return `${namespace}.${shortName}`;
|
|
47
39
|
}
|
|
48
40
|
function unwrapSchema(schema) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
157
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
fullName,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
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
|