@salesforce/magen-mcp-workflow 0.0.1 → 0.0.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.
- package/dist/common/graphConfig.d.ts +26 -0
- package/dist/{tools/utilities/inputExtraction/index.js → common/graphConfig.js} +2 -4
- package/dist/common/graphConfig.js.map +1 -0
- package/dist/common/metadata.d.ts +51 -10
- package/dist/common/metadata.js +9 -0
- package/dist/common/metadata.js.map +1 -1
- package/dist/execution/commandRunner.d.ts +28 -0
- package/dist/execution/commandRunner.js +162 -0
- package/dist/execution/commandRunner.js.map +1 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +9 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/progressReporter.d.ts +33 -0
- package/dist/execution/progressReporter.js +58 -0
- package/dist/execution/progressReporter.js.map +1 -0
- package/dist/execution/types.d.ts +54 -0
- package/dist/execution/types.js +8 -0
- package/dist/execution/types.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/nodes/abstractBaseNode.d.ts +29 -3
- package/dist/nodes/abstractBaseNode.js +26 -2
- package/dist/nodes/abstractBaseNode.js.map +1 -1
- package/dist/nodes/abstractToolNode.d.ts +5 -3
- package/dist/nodes/abstractToolNode.js +5 -3
- package/dist/nodes/abstractToolNode.js.map +1 -1
- package/dist/nodes/getUserInput/factory.js +2 -2
- package/dist/nodes/getUserInput/factory.js.map +1 -1
- package/dist/nodes/getUserInput/node.d.ts +19 -1
- package/dist/nodes/getUserInput/node.js +2 -2
- package/dist/nodes/getUserInput/node.js.map +1 -1
- package/dist/nodes/toolExecutor.d.ts +5 -4
- package/dist/nodes/toolExecutor.js +2 -2
- package/dist/nodes/toolExecutor.js.map +1 -1
- package/dist/routers/checkPropertiesFulfilledRouter.js +2 -2
- package/dist/routers/checkPropertiesFulfilledRouter.js.map +1 -1
- package/dist/services/abstractService.d.ts +5 -5
- package/dist/services/abstractService.js +5 -5
- package/dist/services/abstractService.js.map +1 -1
- package/dist/services/getInputService.d.ts +10 -2
- package/dist/services/getInputService.js +50 -15
- package/dist/services/getInputService.js.map +1 -1
- package/dist/services/inputExtractionService.d.ts +11 -2
- package/dist/services/inputExtractionService.js +94 -18
- package/dist/services/inputExtractionService.js.map +1 -1
- package/dist/tools/orchestrator/metadata.d.ts +49 -3
- package/dist/tools/orchestrator/metadata.js +31 -4
- package/dist/tools/orchestrator/metadata.js.map +1 -1
- package/dist/tools/orchestrator/orchestratorTool.d.ts +44 -3
- package/dist/tools/orchestrator/orchestratorTool.js +138 -13
- package/dist/tools/orchestrator/orchestratorTool.js.map +1 -1
- package/dist/tools/utilities/getInput/index.d.ts +0 -2
- package/dist/tools/utilities/getInput/index.js +0 -2
- package/dist/tools/utilities/getInput/index.js.map +1 -1
- package/dist/tools/utilities/getInput/metadata.d.ts +2 -68
- package/dist/tools/utilities/getInput/metadata.js +2 -30
- package/dist/tools/utilities/getInput/metadata.js.map +1 -1
- package/dist/tools/utilities/index.d.ts +0 -1
- package/dist/tools/utilities/index.js +0 -1
- package/dist/tools/utilities/index.js.map +1 -1
- package/dist/utils/toolExecutionUtils.d.ts +6 -6
- package/dist/utils/toolExecutionUtils.js +7 -7
- package/dist/utils/toolExecutionUtils.js.map +1 -1
- package/package.json +3 -3
- package/dist/tools/utilities/getInput/factory.d.ts +0 -43
- package/dist/tools/utilities/getInput/factory.js +0 -32
- package/dist/tools/utilities/getInput/factory.js.map +0 -1
- package/dist/tools/utilities/getInput/tool.d.ts +0 -89
- package/dist/tools/utilities/getInput/tool.js +0 -69
- package/dist/tools/utilities/getInput/tool.js.map +0 -1
- package/dist/tools/utilities/inputExtraction/factory.d.ts +0 -43
- package/dist/tools/utilities/inputExtraction/factory.js +0 -32
- package/dist/tools/utilities/inputExtraction/factory.js.map +0 -1
- package/dist/tools/utilities/inputExtraction/index.d.ts +0 -3
- package/dist/tools/utilities/inputExtraction/index.js.map +0 -1
- package/dist/tools/utilities/inputExtraction/metadata.d.ts +0 -66
- package/dist/tools/utilities/inputExtraction/metadata.js +0 -52
- package/dist/tools/utilities/inputExtraction/metadata.js.map +0 -1
- package/dist/tools/utilities/inputExtraction/tool.d.ts +0 -82
- package/dist/tools/utilities/inputExtraction/tool.js +0 -71
- package/dist/tools/utilities/inputExtraction/tool.js.map +0 -1
|
@@ -1,62 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { WorkflowToolMetadata } from '../../../common/metadata.js';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Result schema for get input operations.
|
|
4
|
+
* The LLM wraps the user's response in this structure.
|
|
5
5
|
*/
|
|
6
|
-
export declare const GET_INPUT_PROPERTY_SCHEMA: z.ZodObject<{
|
|
7
|
-
propertyName: z.ZodString;
|
|
8
|
-
friendlyName: z.ZodString;
|
|
9
|
-
description: z.ZodString;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
description: string;
|
|
12
|
-
friendlyName: string;
|
|
13
|
-
propertyName: string;
|
|
14
|
-
}, {
|
|
15
|
-
description: string;
|
|
16
|
-
friendlyName: string;
|
|
17
|
-
propertyName: string;
|
|
18
|
-
}>;
|
|
19
|
-
export declare const GET_INPUT_WORKFLOW_INPUT_SCHEMA: z.ZodObject<{
|
|
20
|
-
workflowStateData: z.ZodObject<{
|
|
21
|
-
thread_id: z.ZodString;
|
|
22
|
-
}, "strip", z.ZodTypeAny, {
|
|
23
|
-
thread_id: string;
|
|
24
|
-
}, {
|
|
25
|
-
thread_id: string;
|
|
26
|
-
}>;
|
|
27
|
-
} & {
|
|
28
|
-
propertiesRequiringInput: z.ZodArray<z.ZodObject<{
|
|
29
|
-
propertyName: z.ZodString;
|
|
30
|
-
friendlyName: z.ZodString;
|
|
31
|
-
description: z.ZodString;
|
|
32
|
-
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
description: string;
|
|
34
|
-
friendlyName: string;
|
|
35
|
-
propertyName: string;
|
|
36
|
-
}, {
|
|
37
|
-
description: string;
|
|
38
|
-
friendlyName: string;
|
|
39
|
-
propertyName: string;
|
|
40
|
-
}>, "many">;
|
|
41
|
-
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
workflowStateData: {
|
|
43
|
-
thread_id: string;
|
|
44
|
-
};
|
|
45
|
-
propertiesRequiringInput: {
|
|
46
|
-
description: string;
|
|
47
|
-
friendlyName: string;
|
|
48
|
-
propertyName: string;
|
|
49
|
-
}[];
|
|
50
|
-
}, {
|
|
51
|
-
workflowStateData: {
|
|
52
|
-
thread_id: string;
|
|
53
|
-
};
|
|
54
|
-
propertiesRequiringInput: {
|
|
55
|
-
description: string;
|
|
56
|
-
friendlyName: string;
|
|
57
|
-
propertyName: string;
|
|
58
|
-
}[];
|
|
59
|
-
}>;
|
|
60
6
|
export declare const GET_INPUT_WORKFLOW_RESULT_SCHEMA: z.ZodObject<{
|
|
61
7
|
userUtterance: z.ZodUnknown;
|
|
62
8
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -64,15 +10,3 @@ export declare const GET_INPUT_WORKFLOW_RESULT_SCHEMA: z.ZodObject<{
|
|
|
64
10
|
}, {
|
|
65
11
|
userUtterance?: unknown;
|
|
66
12
|
}>;
|
|
67
|
-
export type GetInputWorkflowInput = z.infer<typeof GET_INPUT_WORKFLOW_INPUT_SCHEMA>;
|
|
68
|
-
/**
|
|
69
|
-
* Get Input Tool Metadata Type
|
|
70
|
-
*/
|
|
71
|
-
export type GetInputToolMetadata = WorkflowToolMetadata<typeof GET_INPUT_WORKFLOW_INPUT_SCHEMA, typeof GET_INPUT_WORKFLOW_RESULT_SCHEMA>;
|
|
72
|
-
/**
|
|
73
|
-
* Factory function to create Get Input Tool metadata with a dynamic tool ID
|
|
74
|
-
*
|
|
75
|
-
* @param toolId - The unique identifier for the tool (e.g., 'magen-get-input', 'mobile-magen-get-input')
|
|
76
|
-
* @returns Tool metadata object for Get Input Tool
|
|
77
|
-
*/
|
|
78
|
-
export declare function createGetInputMetadata(toolId: string): GetInputToolMetadata;
|
|
@@ -5,39 +5,11 @@
|
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import { WORKFLOW_TOOL_BASE_INPUT_SCHEMA, MCP_WORKFLOW_TOOL_OUTPUT_SCHEMA, } from '../../../common/metadata.js';
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* Result schema for get input operations.
|
|
10
|
+
* The LLM wraps the user's response in this structure.
|
|
11
11
|
*/
|
|
12
|
-
export const GET_INPUT_PROPERTY_SCHEMA = z
|
|
13
|
-
.object({
|
|
14
|
-
propertyName: z.string().describe('The name of the property'),
|
|
15
|
-
friendlyName: z.string().describe('The friendly name of the property'),
|
|
16
|
-
description: z.string().describe('The description of the property'),
|
|
17
|
-
})
|
|
18
|
-
.describe('The metadata for the property to be queried, used to formulate a prompting question for input');
|
|
19
|
-
export const GET_INPUT_WORKFLOW_INPUT_SCHEMA = WORKFLOW_TOOL_BASE_INPUT_SCHEMA.extend({
|
|
20
|
-
propertiesRequiringInput: z
|
|
21
|
-
.array(GET_INPUT_PROPERTY_SCHEMA)
|
|
22
|
-
.describe('The metadata for the properties that require input from the user'),
|
|
23
|
-
});
|
|
24
12
|
export const GET_INPUT_WORKFLOW_RESULT_SCHEMA = z.object({
|
|
25
13
|
userUtterance: z.unknown().describe("The user's response to the question"),
|
|
26
14
|
});
|
|
27
|
-
/**
|
|
28
|
-
* Factory function to create Get Input Tool metadata with a dynamic tool ID
|
|
29
|
-
*
|
|
30
|
-
* @param toolId - The unique identifier for the tool (e.g., 'magen-get-input', 'mobile-magen-get-input')
|
|
31
|
-
* @returns Tool metadata object for Get Input Tool
|
|
32
|
-
*/
|
|
33
|
-
export function createGetInputMetadata(toolId) {
|
|
34
|
-
return {
|
|
35
|
-
toolId,
|
|
36
|
-
title: 'Get User Input',
|
|
37
|
-
description: 'Provides a prompt to the user to elicit their input for a set of properties',
|
|
38
|
-
inputSchema: GET_INPUT_WORKFLOW_INPUT_SCHEMA,
|
|
39
|
-
outputSchema: MCP_WORKFLOW_TOOL_OUTPUT_SCHEMA,
|
|
40
|
-
resultSchema: GET_INPUT_WORKFLOW_RESULT_SCHEMA,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
15
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../../src/tools/utilities/getInput/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../../src/tools/utilities/getInput/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;CAC3E,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { InterruptData } from '../common/metadata.js';
|
|
3
3
|
import { Logger } from '../logging/logger.js';
|
|
4
4
|
import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
5
5
|
/**
|
|
6
6
|
* Executes a tool with logging and validation.
|
|
7
7
|
*
|
|
8
8
|
* This utility provides a standardized pattern for tool execution that includes:
|
|
9
|
-
* - Pre-execution logging of
|
|
9
|
+
* - Pre-execution logging of interrupt data
|
|
10
10
|
* - Tool execution via the provided executor
|
|
11
11
|
* - Post-execution logging of results
|
|
12
12
|
* - Result validation using Zod schemas
|
|
@@ -18,7 +18,7 @@ import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @param toolExecutor - The executor to use for running the tool
|
|
20
20
|
* @param logger - Logger instance for recording execution details
|
|
21
|
-
* @param
|
|
21
|
+
* @param interruptData - The interrupt data (MCPToolInvocationData or NodeGuidanceData)
|
|
22
22
|
* @param resultSchema - Zod schema to validate the result against
|
|
23
23
|
* @param validator - Optional custom validator function for additional validation logic
|
|
24
24
|
* @returns The validated result from the tool execution
|
|
@@ -31,7 +31,7 @@ import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
|
31
31
|
* const result = executeToolWithLogging(
|
|
32
32
|
* toolExecutor,
|
|
33
33
|
* logger,
|
|
34
|
-
*
|
|
34
|
+
* interruptData,
|
|
35
35
|
* MyToolResultSchema
|
|
36
36
|
* );
|
|
37
37
|
*
|
|
@@ -40,7 +40,7 @@ import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
|
40
40
|
* const result = executeToolWithLogging(
|
|
41
41
|
* toolExecutor,
|
|
42
42
|
* logger,
|
|
43
|
-
*
|
|
43
|
+
* interruptData,
|
|
44
44
|
* MyToolResultSchema,
|
|
45
45
|
* (result, schema) => {
|
|
46
46
|
* const validated = schema.parse(result);
|
|
@@ -52,4 +52,4 @@ import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
|
52
52
|
* }
|
|
53
53
|
* );
|
|
54
54
|
*/
|
|
55
|
-
export declare function executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(toolExecutor: ToolExecutor, logger: Logger,
|
|
55
|
+
export declare function executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(toolExecutor: ToolExecutor, logger: Logger, interruptData: InterruptData<z.ZodObject<z.ZodRawShape>, TResultSchema>, resultSchema: TResultSchema, validator?: (result: unknown, schema: TResultSchema) => z.infer<TResultSchema>): z.infer<TResultSchema>;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Executes a tool with logging and validation.
|
|
9
9
|
*
|
|
10
10
|
* This utility provides a standardized pattern for tool execution that includes:
|
|
11
|
-
* - Pre-execution logging of
|
|
11
|
+
* - Pre-execution logging of interrupt data
|
|
12
12
|
* - Tool execution via the provided executor
|
|
13
13
|
* - Post-execution logging of results
|
|
14
14
|
* - Result validation using Zod schemas
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @param toolExecutor - The executor to use for running the tool
|
|
22
22
|
* @param logger - Logger instance for recording execution details
|
|
23
|
-
* @param
|
|
23
|
+
* @param interruptData - The interrupt data (MCPToolInvocationData or NodeGuidanceData)
|
|
24
24
|
* @param resultSchema - Zod schema to validate the result against
|
|
25
25
|
* @param validator - Optional custom validator function for additional validation logic
|
|
26
26
|
* @returns The validated result from the tool execution
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* const result = executeToolWithLogging(
|
|
34
34
|
* toolExecutor,
|
|
35
35
|
* logger,
|
|
36
|
-
*
|
|
36
|
+
* interruptData,
|
|
37
37
|
* MyToolResultSchema
|
|
38
38
|
* );
|
|
39
39
|
*
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* const result = executeToolWithLogging(
|
|
43
43
|
* toolExecutor,
|
|
44
44
|
* logger,
|
|
45
|
-
*
|
|
45
|
+
* interruptData,
|
|
46
46
|
* MyToolResultSchema,
|
|
47
47
|
* (result, schema) => {
|
|
48
48
|
* const validated = schema.parse(result);
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
* }
|
|
55
55
|
* );
|
|
56
56
|
*/
|
|
57
|
-
export function executeToolWithLogging(toolExecutor, logger,
|
|
58
|
-
logger.debug('
|
|
59
|
-
const result = toolExecutor.execute(
|
|
57
|
+
export function executeToolWithLogging(toolExecutor, logger, interruptData, resultSchema, validator) {
|
|
58
|
+
logger.debug('Interrupt data (pre-execution)', { interruptData });
|
|
59
|
+
const result = toolExecutor.execute(interruptData);
|
|
60
60
|
logger.debug('Tool execution result (post-execution)', { result });
|
|
61
61
|
if (validator) {
|
|
62
62
|
return validator(result, resultSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolExecutionUtils.js","sourceRoot":"","sources":["../../src/utils/toolExecutionUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAA0B,EAC1B,MAAc,EACd,
|
|
1
|
+
{"version":3,"file":"toolExecutionUtils.js","sourceRoot":"","sources":["../../src/utils/toolExecutionUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAA0B,EAC1B,MAAc,EACd,aAAuE,EACvE,YAA2B,EAC3B,SAA8E;IAE9E,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAElE,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEnD,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAEnE,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,MAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3D,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/magen-mcp-workflow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@langchain/langgraph": "^0.4.9",
|
|
29
29
|
"@langchain/langgraph-checkpoint": "^0.0.11",
|
|
30
|
-
"@langchain/core": "^0.3.
|
|
31
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
30
|
+
"@langchain/core": "^0.3.80",
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
32
32
|
"pino": "^9.9.5",
|
|
33
33
|
"zod": "^3.25.67",
|
|
34
34
|
"zod-to-json-schema": "^3.24.6"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Logger } from '../../../logging/logger.js';
|
|
3
|
-
import { GetInputTool } from './tool.js';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for creating a Get Input Tool
|
|
6
|
-
*/
|
|
7
|
-
export interface GetInputToolOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The tool ID to use for the get input tool
|
|
10
|
-
*/
|
|
11
|
-
toolId: string;
|
|
12
|
-
/**
|
|
13
|
-
* Orchestrator tool ID that this tool reports back to
|
|
14
|
-
* @required
|
|
15
|
-
*/
|
|
16
|
-
orchestratorToolId: string;
|
|
17
|
-
/**
|
|
18
|
-
* Optional logger instance for tool operations
|
|
19
|
-
*/
|
|
20
|
-
logger?: Logger;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Factory function to create a Get Input Tool with configurable tool ID
|
|
24
|
-
*
|
|
25
|
-
* @param server - The MCP server instance
|
|
26
|
-
* @param options - Configuration options for the tool
|
|
27
|
-
* @returns A configured Get Input Tool instance ready for registration
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // Simple case - single MCP server
|
|
31
|
-
* const getInputTool = createGetInputTool(server, {
|
|
32
|
-
* toolId: 'magen-get-input',
|
|
33
|
-
* orchestratorToolId: 'my-orchestrator',
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* // Multi-server environment - avoid collisions
|
|
38
|
-
* const getInputTool = createGetInputTool(server, {
|
|
39
|
-
* toolId: 'mobile-magen-get-input',
|
|
40
|
-
* orchestratorToolId: 'mobile-orchestrator',
|
|
41
|
-
* });
|
|
42
|
-
*/
|
|
43
|
-
export declare function createGetInputTool(server: McpServer, options: GetInputToolOptions): GetInputTool;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025, salesforce.com, inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
|
-
*/
|
|
7
|
-
import { GetInputTool } from './tool.js';
|
|
8
|
-
/**
|
|
9
|
-
* Factory function to create a Get Input Tool with configurable tool ID
|
|
10
|
-
*
|
|
11
|
-
* @param server - The MCP server instance
|
|
12
|
-
* @param options - Configuration options for the tool
|
|
13
|
-
* @returns A configured Get Input Tool instance ready for registration
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // Simple case - single MCP server
|
|
17
|
-
* const getInputTool = createGetInputTool(server, {
|
|
18
|
-
* toolId: 'magen-get-input',
|
|
19
|
-
* orchestratorToolId: 'my-orchestrator',
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Multi-server environment - avoid collisions
|
|
24
|
-
* const getInputTool = createGetInputTool(server, {
|
|
25
|
-
* toolId: 'mobile-magen-get-input',
|
|
26
|
-
* orchestratorToolId: 'mobile-orchestrator',
|
|
27
|
-
* });
|
|
28
|
-
*/
|
|
29
|
-
export function createGetInputTool(server, options) {
|
|
30
|
-
return new GetInputTool(server, options.toolId, options.orchestratorToolId, options.logger);
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/tools/utilities/getInput/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAuBzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAiB,EAAE,OAA4B;IAChF,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Logger } from '../../../logging/logger.js';
|
|
3
|
-
import { GetInputWorkflowInput, GetInputToolMetadata } from './metadata.js';
|
|
4
|
-
import { AbstractWorkflowTool } from '../../base/abstractWorkflowTool.js';
|
|
5
|
-
export declare class GetInputTool extends AbstractWorkflowTool<GetInputToolMetadata> {
|
|
6
|
-
constructor(server: McpServer, toolId: string, orchestratorToolId: string, logger?: Logger);
|
|
7
|
-
handleRequest: (input: GetInputWorkflowInput) => Promise<{
|
|
8
|
-
[x: string]: unknown;
|
|
9
|
-
content: ({
|
|
10
|
-
[x: string]: unknown;
|
|
11
|
-
type: "text";
|
|
12
|
-
text: string;
|
|
13
|
-
_meta?: {
|
|
14
|
-
[x: string]: unknown;
|
|
15
|
-
} | undefined;
|
|
16
|
-
} | {
|
|
17
|
-
[x: string]: unknown;
|
|
18
|
-
type: "image";
|
|
19
|
-
data: string;
|
|
20
|
-
mimeType: string;
|
|
21
|
-
_meta?: {
|
|
22
|
-
[x: string]: unknown;
|
|
23
|
-
} | undefined;
|
|
24
|
-
} | {
|
|
25
|
-
[x: string]: unknown;
|
|
26
|
-
type: "audio";
|
|
27
|
-
data: string;
|
|
28
|
-
mimeType: string;
|
|
29
|
-
_meta?: {
|
|
30
|
-
[x: string]: unknown;
|
|
31
|
-
} | undefined;
|
|
32
|
-
} | {
|
|
33
|
-
[x: string]: unknown;
|
|
34
|
-
type: "resource_link";
|
|
35
|
-
name: string;
|
|
36
|
-
uri: string;
|
|
37
|
-
description?: string | undefined;
|
|
38
|
-
title?: string | undefined;
|
|
39
|
-
_meta?: {
|
|
40
|
-
[x: string]: unknown;
|
|
41
|
-
} | undefined;
|
|
42
|
-
mimeType?: string | undefined;
|
|
43
|
-
icons?: {
|
|
44
|
-
[x: string]: unknown;
|
|
45
|
-
src: string;
|
|
46
|
-
mimeType?: string | undefined;
|
|
47
|
-
sizes?: string[] | undefined;
|
|
48
|
-
}[] | undefined;
|
|
49
|
-
} | {
|
|
50
|
-
[x: string]: unknown;
|
|
51
|
-
type: "resource";
|
|
52
|
-
resource: {
|
|
53
|
-
[x: string]: unknown;
|
|
54
|
-
text: string;
|
|
55
|
-
uri: string;
|
|
56
|
-
_meta?: {
|
|
57
|
-
[x: string]: unknown;
|
|
58
|
-
} | undefined;
|
|
59
|
-
mimeType?: string | undefined;
|
|
60
|
-
} | {
|
|
61
|
-
[x: string]: unknown;
|
|
62
|
-
uri: string;
|
|
63
|
-
blob: string;
|
|
64
|
-
_meta?: {
|
|
65
|
-
[x: string]: unknown;
|
|
66
|
-
} | undefined;
|
|
67
|
-
mimeType?: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
_meta?: {
|
|
70
|
-
[x: string]: unknown;
|
|
71
|
-
} | undefined;
|
|
72
|
-
})[];
|
|
73
|
-
_meta?: {
|
|
74
|
-
[x: string]: unknown;
|
|
75
|
-
} | undefined;
|
|
76
|
-
structuredContent?: {
|
|
77
|
-
[x: string]: unknown;
|
|
78
|
-
} | undefined;
|
|
79
|
-
isError?: boolean | undefined;
|
|
80
|
-
}>;
|
|
81
|
-
private generatePromptForInputGuidance;
|
|
82
|
-
/**
|
|
83
|
-
* Creates a "prompt-friendly" description of the properties requiring input, for inclusion
|
|
84
|
-
* in the prompt to the LLM.
|
|
85
|
-
* @param input The input to the tool, containing the properties requiring input
|
|
86
|
-
* @returns A "prompt-friendly" description of the properties requiring input
|
|
87
|
-
*/
|
|
88
|
-
private generatePropertiesDescription;
|
|
89
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025, salesforce.com, inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
|
-
*/
|
|
7
|
-
import { createGetInputMetadata } from './metadata.js';
|
|
8
|
-
import { AbstractWorkflowTool } from '../../base/abstractWorkflowTool.js';
|
|
9
|
-
export class GetInputTool extends AbstractWorkflowTool {
|
|
10
|
-
constructor(server, toolId, orchestratorToolId, logger) {
|
|
11
|
-
super(server, createGetInputMetadata(toolId), orchestratorToolId, 'GetInputTool', logger);
|
|
12
|
-
}
|
|
13
|
-
handleRequest = async (input) => {
|
|
14
|
-
try {
|
|
15
|
-
const guidance = this.generatePromptForInputGuidance(input);
|
|
16
|
-
return this.finalizeWorkflowToolOutput(guidance, input.workflowStateData);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
const toolError = error instanceof Error ? error : new Error('Unknown error occurred');
|
|
20
|
-
return {
|
|
21
|
-
isError: true,
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: 'text',
|
|
25
|
-
text: `Error: ${toolError.message}`,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
generatePromptForInputGuidance(input) {
|
|
32
|
-
return `
|
|
33
|
-
# ROLE
|
|
34
|
-
You are an input gathering tool, responsible for explicitly requesting and gathering the
|
|
35
|
-
user's input for a set of unfulfilled properties.
|
|
36
|
-
|
|
37
|
-
# TASK
|
|
38
|
-
Your job is to provide a prompt to the user that outlines the details for a set of properties
|
|
39
|
-
that require the user's input. The prompt should be polite and conversational.
|
|
40
|
-
|
|
41
|
-
# CONTEXT
|
|
42
|
-
Here is the list of properties that require the user's input, along with their describing
|
|
43
|
-
metadata:
|
|
44
|
-
|
|
45
|
-
${this.generatePropertiesDescription(input)}
|
|
46
|
-
|
|
47
|
-
# INSTRUCTIONS
|
|
48
|
-
1. Based on the properties listed in "CONTEXT", generate a prompt that outlines the details
|
|
49
|
-
for each property.
|
|
50
|
-
2. Present the prompt to the user and instruct the user to provide their input.
|
|
51
|
-
3. **IMPORTANT:** YOU MUST NOW WAIT for the user to provide a follow-up response to your prompt.
|
|
52
|
-
1. You CANNOT PROCEED FROM THIS STEP until the user has provided THEIR OWN INPUT VALUE.
|
|
53
|
-
4. Follow the the "Post-Tool-Invocation" instructions below, to return the user's
|
|
54
|
-
response to the orchestrator for further processing.
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Creates a "prompt-friendly" description of the properties requiring input, for inclusion
|
|
59
|
-
* in the prompt to the LLM.
|
|
60
|
-
* @param input The input to the tool, containing the properties requiring input
|
|
61
|
-
* @returns A "prompt-friendly" description of the properties requiring input
|
|
62
|
-
*/
|
|
63
|
-
generatePropertiesDescription(input) {
|
|
64
|
-
return input.propertiesRequiringInput
|
|
65
|
-
.map(property => `- Property Name: ${property.propertyName}\n- Friendly Name: ${property.friendlyName}\n- Description: ${property.description}`)
|
|
66
|
-
.join('\n\n');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../src/tools/utilities/getInput/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAA+C,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,OAAO,YAAa,SAAQ,oBAA0C;IAC1E,YAAY,MAAiB,EAAE,MAAc,EAAE,kBAA0B,EAAE,MAAe;QACxF,KAAK,CAAC,MAAM,EAAE,sBAAsB,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAC5F,CAAC;IAEM,aAAa,GAAG,KAAK,EAAE,KAA4B,EAAE,EAAE;QAC5D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC;YAC5D,OAAO,IAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YACvF,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,UAAU,SAAS,CAAC,OAAO,EAAE;qBACpC;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEM,8BAA8B,CAAC,KAA4B;QACjE,OAAO;;;;;;;;;;;;;EAaT,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC;;;;;;;;;;CAU1C,CAAC;IACA,CAAC;IAED;;;;;OAKG;IACK,6BAA6B,CAAC,KAA4B;QAChE,OAAO,KAAK,CAAC,wBAAwB;aAClC,GAAG,CACF,QAAQ,CAAC,EAAE,CACT,oBAAoB,QAAQ,CAAC,YAAY,sBAAsB,QAAQ,CAAC,YAAY,oBAAoB,QAAQ,CAAC,WAAW,EAAE,CACjI;aACA,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Logger } from '../../../logging/logger.js';
|
|
3
|
-
import { InputExtractionTool } from './tool.js';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for creating an Input Extraction Tool
|
|
6
|
-
*/
|
|
7
|
-
export interface InputExtractionToolOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The tool ID to use for the input extraction tool
|
|
10
|
-
*/
|
|
11
|
-
toolId: string;
|
|
12
|
-
/**
|
|
13
|
-
* Orchestrator tool ID that this tool reports back to
|
|
14
|
-
* @required
|
|
15
|
-
*/
|
|
16
|
-
orchestratorToolId: string;
|
|
17
|
-
/**
|
|
18
|
-
* Optional logger instance for tool operations
|
|
19
|
-
*/
|
|
20
|
-
logger?: Logger;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Factory function to create an Input Extraction Tool with configurable tool ID
|
|
24
|
-
*
|
|
25
|
-
* @param server - The MCP server instance
|
|
26
|
-
* @param options - Configuration options for the tool
|
|
27
|
-
* @returns A configured Input Extraction Tool instance ready for registration
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // Simple case - single MCP server
|
|
31
|
-
* const inputExtractionTool = createInputExtractionTool(server, {
|
|
32
|
-
* toolId: 'magen-input-extraction',
|
|
33
|
-
* orchestratorToolId: 'my-orchestrator',
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* // Multi-server environment - avoid collisions
|
|
38
|
-
* const inputExtractionTool = createInputExtractionTool(server, {
|
|
39
|
-
* toolId: 'mobile-magen-input-extraction',
|
|
40
|
-
* orchestratorToolId: 'mobile-orchestrator',
|
|
41
|
-
* });
|
|
42
|
-
*/
|
|
43
|
-
export declare function createInputExtractionTool(server: McpServer, options: InputExtractionToolOptions): InputExtractionTool;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025, salesforce.com, inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
|
-
*/
|
|
7
|
-
import { InputExtractionTool } from './tool.js';
|
|
8
|
-
/**
|
|
9
|
-
* Factory function to create an Input Extraction Tool with configurable tool ID
|
|
10
|
-
*
|
|
11
|
-
* @param server - The MCP server instance
|
|
12
|
-
* @param options - Configuration options for the tool
|
|
13
|
-
* @returns A configured Input Extraction Tool instance ready for registration
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // Simple case - single MCP server
|
|
17
|
-
* const inputExtractionTool = createInputExtractionTool(server, {
|
|
18
|
-
* toolId: 'magen-input-extraction',
|
|
19
|
-
* orchestratorToolId: 'my-orchestrator',
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Multi-server environment - avoid collisions
|
|
24
|
-
* const inputExtractionTool = createInputExtractionTool(server, {
|
|
25
|
-
* toolId: 'mobile-magen-input-extraction',
|
|
26
|
-
* orchestratorToolId: 'mobile-orchestrator',
|
|
27
|
-
* });
|
|
28
|
-
*/
|
|
29
|
-
export function createInputExtractionTool(server, options) {
|
|
30
|
-
return new InputExtractionTool(server, options.toolId, options.orchestratorToolId, options.logger);
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/tools/utilities/inputExtraction/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAuBhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAiB,EACjB,OAAmC;IAEnC,OAAO,IAAI,mBAAmB,CAC5B,MAAM,EACN,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,kBAAkB,EAC1B,OAAO,CAAC,MAAM,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tools/utilities/inputExtraction/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|