@salesforce/magen-mcp-workflow 0.0.1

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 (134) hide show
  1. package/README.md +168 -0
  2. package/dist/checkpointing/index.d.ts +3 -0
  3. package/dist/checkpointing/index.js +10 -0
  4. package/dist/checkpointing/index.js.map +1 -0
  5. package/dist/checkpointing/jsonCheckpointer.d.ts +19 -0
  6. package/dist/checkpointing/jsonCheckpointer.js +164 -0
  7. package/dist/checkpointing/jsonCheckpointer.js.map +1 -0
  8. package/dist/checkpointing/statePersistence.d.ts +26 -0
  9. package/dist/checkpointing/statePersistence.js +117 -0
  10. package/dist/checkpointing/statePersistence.js.map +1 -0
  11. package/dist/checkpointing/workflowStateManager.d.ts +99 -0
  12. package/dist/checkpointing/workflowStateManager.js +206 -0
  13. package/dist/checkpointing/workflowStateManager.js.map +1 -0
  14. package/dist/common/fileSystem.d.ts +113 -0
  15. package/dist/common/fileSystem.js +62 -0
  16. package/dist/common/fileSystem.js.map +1 -0
  17. package/dist/common/metadata.d.ts +93 -0
  18. package/dist/common/metadata.js +40 -0
  19. package/dist/common/metadata.js.map +1 -0
  20. package/dist/common/propertyMetadata.d.ts +58 -0
  21. package/dist/common/propertyMetadata.js +8 -0
  22. package/dist/common/propertyMetadata.js.map +1 -0
  23. package/dist/common/types.d.ts +16 -0
  24. package/dist/common/types.js +8 -0
  25. package/dist/common/types.js.map +1 -0
  26. package/dist/index.d.ts +15 -0
  27. package/dist/index.js +37 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/logging/logger.d.ts +56 -0
  30. package/dist/logging/logger.js +113 -0
  31. package/dist/logging/logger.js.map +1 -0
  32. package/dist/nodes/abstractBaseNode.d.ts +27 -0
  33. package/dist/nodes/abstractBaseNode.js +34 -0
  34. package/dist/nodes/abstractBaseNode.js.map +1 -0
  35. package/dist/nodes/abstractToolNode.d.ts +32 -0
  36. package/dist/nodes/abstractToolNode.js +44 -0
  37. package/dist/nodes/abstractToolNode.js.map +1 -0
  38. package/dist/nodes/getUserInput/factory.d.ts +42 -0
  39. package/dist/nodes/getUserInput/factory.js +64 -0
  40. package/dist/nodes/getUserInput/factory.js.map +1 -0
  41. package/dist/nodes/getUserInput/index.d.ts +2 -0
  42. package/dist/nodes/getUserInput/index.js +3 -0
  43. package/dist/nodes/getUserInput/index.js.map +1 -0
  44. package/dist/nodes/getUserInput/node.d.ts +68 -0
  45. package/dist/nodes/getUserInput/node.js +41 -0
  46. package/dist/nodes/getUserInput/node.js.map +1 -0
  47. package/dist/nodes/index.d.ts +5 -0
  48. package/dist/nodes/index.js +12 -0
  49. package/dist/nodes/index.js.map +1 -0
  50. package/dist/nodes/toolExecutor.d.ts +22 -0
  51. package/dist/nodes/toolExecutor.js +19 -0
  52. package/dist/nodes/toolExecutor.js.map +1 -0
  53. package/dist/nodes/userInputExtraction/factory.d.ts +42 -0
  54. package/dist/nodes/userInputExtraction/factory.js +55 -0
  55. package/dist/nodes/userInputExtraction/factory.js.map +1 -0
  56. package/dist/nodes/userInputExtraction/index.d.ts +2 -0
  57. package/dist/nodes/userInputExtraction/index.js +3 -0
  58. package/dist/nodes/userInputExtraction/index.js.map +1 -0
  59. package/dist/nodes/userInputExtraction/node.d.ts +60 -0
  60. package/dist/nodes/userInputExtraction/node.js +24 -0
  61. package/dist/nodes/userInputExtraction/node.js.map +1 -0
  62. package/dist/routers/checkPropertiesFulfilledRouter.d.ts +74 -0
  63. package/dist/routers/checkPropertiesFulfilledRouter.js +106 -0
  64. package/dist/routers/checkPropertiesFulfilledRouter.js.map +1 -0
  65. package/dist/routers/index.d.ts +1 -0
  66. package/dist/routers/index.js +8 -0
  67. package/dist/routers/index.js.map +1 -0
  68. package/dist/services/abstractService.d.ts +71 -0
  69. package/dist/services/abstractService.js +83 -0
  70. package/dist/services/abstractService.js.map +1 -0
  71. package/dist/services/getInputService.d.ts +43 -0
  72. package/dist/services/getInputService.js +48 -0
  73. package/dist/services/getInputService.js.map +1 -0
  74. package/dist/services/index.d.ts +3 -0
  75. package/dist/services/index.js +10 -0
  76. package/dist/services/index.js.map +1 -0
  77. package/dist/services/inputExtractionService.d.ts +46 -0
  78. package/dist/services/inputExtractionService.js +133 -0
  79. package/dist/services/inputExtractionService.js.map +1 -0
  80. package/dist/storage/wellKnownDirectory.d.ts +79 -0
  81. package/dist/storage/wellKnownDirectory.js +121 -0
  82. package/dist/storage/wellKnownDirectory.js.map +1 -0
  83. package/dist/tools/base/abstractTool.d.ts +61 -0
  84. package/dist/tools/base/abstractTool.js +87 -0
  85. package/dist/tools/base/abstractTool.js.map +1 -0
  86. package/dist/tools/base/abstractWorkflowTool.d.ts +34 -0
  87. package/dist/tools/base/abstractWorkflowTool.js +94 -0
  88. package/dist/tools/base/abstractWorkflowTool.js.map +1 -0
  89. package/dist/tools/base/index.d.ts +2 -0
  90. package/dist/tools/base/index.js +9 -0
  91. package/dist/tools/base/index.js.map +1 -0
  92. package/dist/tools/orchestrator/config.d.ts +55 -0
  93. package/dist/tools/orchestrator/config.js +8 -0
  94. package/dist/tools/orchestrator/config.js.map +1 -0
  95. package/dist/tools/orchestrator/index.d.ts +3 -0
  96. package/dist/tools/orchestrator/index.js +9 -0
  97. package/dist/tools/orchestrator/index.js.map +1 -0
  98. package/dist/tools/orchestrator/metadata.d.ts +55 -0
  99. package/dist/tools/orchestrator/metadata.js +49 -0
  100. package/dist/tools/orchestrator/metadata.js.map +1 -0
  101. package/dist/tools/orchestrator/orchestratorTool.d.ts +39 -0
  102. package/dist/tools/orchestrator/orchestratorTool.js +186 -0
  103. package/dist/tools/orchestrator/orchestratorTool.js.map +1 -0
  104. package/dist/tools/utilities/getInput/factory.d.ts +43 -0
  105. package/dist/tools/utilities/getInput/factory.js +32 -0
  106. package/dist/tools/utilities/getInput/factory.js.map +1 -0
  107. package/dist/tools/utilities/getInput/index.d.ts +3 -0
  108. package/dist/tools/utilities/getInput/index.js +10 -0
  109. package/dist/tools/utilities/getInput/index.js.map +1 -0
  110. package/dist/tools/utilities/getInput/metadata.d.ts +78 -0
  111. package/dist/tools/utilities/getInput/metadata.js +43 -0
  112. package/dist/tools/utilities/getInput/metadata.js.map +1 -0
  113. package/dist/tools/utilities/getInput/tool.d.ts +89 -0
  114. package/dist/tools/utilities/getInput/tool.js +69 -0
  115. package/dist/tools/utilities/getInput/tool.js.map +1 -0
  116. package/dist/tools/utilities/index.d.ts +2 -0
  117. package/dist/tools/utilities/index.js +9 -0
  118. package/dist/tools/utilities/index.js.map +1 -0
  119. package/dist/tools/utilities/inputExtraction/factory.d.ts +43 -0
  120. package/dist/tools/utilities/inputExtraction/factory.js +32 -0
  121. package/dist/tools/utilities/inputExtraction/factory.js.map +1 -0
  122. package/dist/tools/utilities/inputExtraction/index.d.ts +3 -0
  123. package/dist/tools/utilities/inputExtraction/index.js +10 -0
  124. package/dist/tools/utilities/inputExtraction/index.js.map +1 -0
  125. package/dist/tools/utilities/inputExtraction/metadata.d.ts +66 -0
  126. package/dist/tools/utilities/inputExtraction/metadata.js +52 -0
  127. package/dist/tools/utilities/inputExtraction/metadata.js.map +1 -0
  128. package/dist/tools/utilities/inputExtraction/tool.d.ts +82 -0
  129. package/dist/tools/utilities/inputExtraction/tool.js +71 -0
  130. package/dist/tools/utilities/inputExtraction/tool.js.map +1 -0
  131. package/dist/utils/toolExecutionUtils.d.ts +55 -0
  132. package/dist/utils/toolExecutionUtils.js +70 -0
  133. package/dist/utils/toolExecutionUtils.js.map +1 -0
  134. package/package.json +42 -0
@@ -0,0 +1,78 @@
1
+ import { z } from 'zod';
2
+ import { WorkflowToolMetadata } from '../../../common/metadata.js';
3
+ /**
4
+ * Get Input Tool Input Schema
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
+ export declare const GET_INPUT_WORKFLOW_RESULT_SCHEMA: z.ZodObject<{
61
+ userUtterance: z.ZodUnknown;
62
+ }, "strip", z.ZodTypeAny, {
63
+ userUtterance?: unknown;
64
+ }, {
65
+ userUtterance?: unknown;
66
+ }>;
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;
@@ -0,0 +1,43 @@
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 { z } from 'zod';
8
+ import { WORKFLOW_TOOL_BASE_INPUT_SCHEMA, MCP_WORKFLOW_TOOL_OUTPUT_SCHEMA, } from '../../../common/metadata.js';
9
+ /**
10
+ * Get Input Tool Input Schema
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
+ export const GET_INPUT_WORKFLOW_RESULT_SCHEMA = z.object({
25
+ userUtterance: z.unknown().describe("The user's response to the question"),
26
+ });
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
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +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;AACxB,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,GAEhC,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC7D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACtE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CACpE,CAAC;KACD,QAAQ,CACP,+FAA+F,CAChG,CAAC;AAEJ,MAAM,CAAC,MAAM,+BAA+B,GAAG,+BAA+B,CAAC,MAAM,CAAC;IACpF,wBAAwB,EAAE,CAAC;SACxB,KAAK,CAAC,yBAAyB,CAAC;SAChC,QAAQ,CAAC,kEAAkE,CAAC;CAChF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;CAC3E,CAAC,CAAC;AAYH;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,OAAO;QACL,MAAM;QACN,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,6EAA6E;QAC1F,WAAW,EAAE,+BAA+B;QAC5C,YAAY,EAAE,+BAA+B;QAC7C,YAAY,EAAE,gCAAgC;KACtC,CAAC;AACb,CAAC"}
@@ -0,0 +1,89 @@
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
+ }
@@ -0,0 +1,69 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export * from './getInput/index.js';
2
+ export * from './inputExtraction/index.js';
@@ -0,0 +1,9 @@
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
+ export * from './getInput/index.js';
8
+ export * from './inputExtraction/index.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,43 @@
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;
@@ -0,0 +1,32 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export * from './tool.js';
2
+ export * from './metadata.js';
3
+ export * from './factory.js';
@@ -0,0 +1,10 @@
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
+ export * from './tool.js';
8
+ export * from './metadata.js';
9
+ export * from './factory.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod';
2
+ import { WorkflowToolMetadata } from '../../../common/metadata.js';
3
+ /**
4
+ * Input Extraction Tool Input Schema
5
+ */
6
+ export declare const INPUT_EXTRACTION_WORKFLOW_INPUT_SCHEMA: z.ZodObject<{
7
+ workflowStateData: z.ZodObject<{
8
+ thread_id: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ thread_id: string;
11
+ }, {
12
+ thread_id: string;
13
+ }>;
14
+ } & {
15
+ userUtterance: z.ZodUnknown;
16
+ propertiesToExtract: z.ZodArray<z.ZodObject<{
17
+ propertyName: z.ZodString;
18
+ description: z.ZodString;
19
+ }, "strip", z.ZodTypeAny, {
20
+ description: string;
21
+ propertyName: string;
22
+ }, {
23
+ description: string;
24
+ propertyName: string;
25
+ }>, "many">;
26
+ resultSchema: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ workflowStateData: {
29
+ thread_id: string;
30
+ };
31
+ resultSchema: string;
32
+ propertiesToExtract: {
33
+ description: string;
34
+ propertyName: string;
35
+ }[];
36
+ userUtterance?: unknown;
37
+ }, {
38
+ workflowStateData: {
39
+ thread_id: string;
40
+ };
41
+ resultSchema: string;
42
+ propertiesToExtract: {
43
+ description: string;
44
+ propertyName: string;
45
+ }[];
46
+ userUtterance?: unknown;
47
+ }>;
48
+ export declare const INPUT_EXTRACTION_WORKFLOW_RESULT_SCHEMA: z.ZodObject<{
49
+ resultSchema: z.ZodString;
50
+ }, "strip", z.ZodTypeAny, {
51
+ resultSchema: string;
52
+ }, {
53
+ resultSchema: string;
54
+ }>;
55
+ export type InputExtractionWorkflowInput = z.infer<typeof INPUT_EXTRACTION_WORKFLOW_INPUT_SCHEMA>;
56
+ /**
57
+ * Input Extraction Tool Metadata Type
58
+ */
59
+ export type InputExtractionToolMetadata = WorkflowToolMetadata<typeof INPUT_EXTRACTION_WORKFLOW_INPUT_SCHEMA, typeof INPUT_EXTRACTION_WORKFLOW_RESULT_SCHEMA>;
60
+ /**
61
+ * Factory function to create Input Extraction Tool metadata with a dynamic tool ID
62
+ *
63
+ * @param toolId - The unique identifier for the tool (e.g., 'magen-input-extraction', 'mobile-magen-input-extraction')
64
+ * @returns Tool metadata object for Input Extraction Tool
65
+ */
66
+ export declare function createInputExtractionMetadata(toolId: string): InputExtractionToolMetadata;
@@ -0,0 +1,52 @@
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 { z } from 'zod';
8
+ import { WORKFLOW_TOOL_BASE_INPUT_SCHEMA, MCP_WORKFLOW_TOOL_OUTPUT_SCHEMA, } from '../../../common/metadata.js';
9
+ /**
10
+ * Input Extraction Tool Input Schema
11
+ */
12
+ export const INPUT_EXTRACTION_WORKFLOW_INPUT_SCHEMA = WORKFLOW_TOOL_BASE_INPUT_SCHEMA.extend({
13
+ userUtterance: z
14
+ .unknown()
15
+ .describe('Raw user input - can be text, structured data, or any format describing their request'),
16
+ propertiesToExtract: z
17
+ .array(z
18
+ .object({
19
+ propertyName: z.string().describe('The name of the property'),
20
+ description: z.string().describe('The description of the property'),
21
+ })
22
+ .describe('The name of the property and its description to correlate with the user input'))
23
+ .describe('The array of properties to extract from the user input'),
24
+ resultSchema: z
25
+ .string()
26
+ .describe('The JSON schema definining the extracted properties structure, as a string'),
27
+ });
28
+ // NOTE: This is a nominal definition, as the actual schema is dynamic, and needs to come
29
+ // through the input schema. Having this defined is an artifact of needing to reconsider
30
+ // our design for schema representation in our server tools.
31
+ export const INPUT_EXTRACTION_WORKFLOW_RESULT_SCHEMA = z.object({
32
+ resultSchema: z
33
+ .string()
34
+ .describe('The JSON schema definining the extracted properties structure, as a string'),
35
+ });
36
+ /**
37
+ * Factory function to create Input Extraction Tool metadata with a dynamic tool ID
38
+ *
39
+ * @param toolId - The unique identifier for the tool (e.g., 'magen-input-extraction', 'mobile-magen-input-extraction')
40
+ * @returns Tool metadata object for Input Extraction Tool
41
+ */
42
+ export function createInputExtractionMetadata(toolId) {
43
+ return {
44
+ toolId,
45
+ title: 'Input Extraction',
46
+ description: 'Parses user input and extracts structured project properties',
47
+ inputSchema: INPUT_EXTRACTION_WORKFLOW_INPUT_SCHEMA,
48
+ outputSchema: MCP_WORKFLOW_TOOL_OUTPUT_SCHEMA,
49
+ resultSchema: INPUT_EXTRACTION_WORKFLOW_RESULT_SCHEMA,
50
+ };
51
+ }
52
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../../src/tools/utilities/inputExtraction/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,GAEhC,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,+BAA+B,CAAC,MAAM,CAAC;IAC3F,aAAa,EAAE,CAAC;SACb,OAAO,EAAE;SACT,QAAQ,CACP,uFAAuF,CACxF;IACH,mBAAmB,EAAE,CAAC;SACnB,KAAK,CACJ,CAAC;SACE,MAAM,CAAC;QACN,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QAC7D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;KACpE,CAAC;SACD,QAAQ,CAAC,+EAA+E,CAAC,CAC7F;SACA,QAAQ,CAAC,wDAAwD,CAAC;IACrE,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CAAC,4EAA4E,CAAC;CAC1F,CAAC,CAAC;AAEH,yFAAyF;AACzF,wFAAwF;AACxF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9D,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CAAC,4EAA4E,CAAC;CAC1F,CAAC,CAAC;AAYH;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,MAAc;IAC1D,OAAO;QACL,MAAM;QACN,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,8DAA8D;QAC3E,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,+BAA+B;QAC7C,YAAY,EAAE,uCAAuC;KAC7C,CAAC;AACb,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { Logger } from '../../../logging/logger.js';
3
+ import { InputExtractionWorkflowInput, InputExtractionToolMetadata } from './metadata.js';
4
+ import { AbstractWorkflowTool } from '../../base/abstractWorkflowTool.js';
5
+ export declare class InputExtractionTool extends AbstractWorkflowTool<InputExtractionToolMetadata> {
6
+ constructor(server: McpServer, toolId: string, orchestratorToolId: string, logger?: Logger);
7
+ handleRequest: (input: InputExtractionWorkflowInput) => 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 generateInputExtractionGuidance;
82
+ }