@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.
- package/README.md +168 -0
- package/dist/checkpointing/index.d.ts +3 -0
- package/dist/checkpointing/index.js +10 -0
- package/dist/checkpointing/index.js.map +1 -0
- package/dist/checkpointing/jsonCheckpointer.d.ts +19 -0
- package/dist/checkpointing/jsonCheckpointer.js +164 -0
- package/dist/checkpointing/jsonCheckpointer.js.map +1 -0
- package/dist/checkpointing/statePersistence.d.ts +26 -0
- package/dist/checkpointing/statePersistence.js +117 -0
- package/dist/checkpointing/statePersistence.js.map +1 -0
- package/dist/checkpointing/workflowStateManager.d.ts +99 -0
- package/dist/checkpointing/workflowStateManager.js +206 -0
- package/dist/checkpointing/workflowStateManager.js.map +1 -0
- package/dist/common/fileSystem.d.ts +113 -0
- package/dist/common/fileSystem.js +62 -0
- package/dist/common/fileSystem.js.map +1 -0
- package/dist/common/metadata.d.ts +93 -0
- package/dist/common/metadata.js +40 -0
- package/dist/common/metadata.js.map +1 -0
- package/dist/common/propertyMetadata.d.ts +58 -0
- package/dist/common/propertyMetadata.js +8 -0
- package/dist/common/propertyMetadata.js.map +1 -0
- package/dist/common/types.d.ts +16 -0
- package/dist/common/types.js +8 -0
- package/dist/common/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +56 -0
- package/dist/logging/logger.js +113 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/nodes/abstractBaseNode.d.ts +27 -0
- package/dist/nodes/abstractBaseNode.js +34 -0
- package/dist/nodes/abstractBaseNode.js.map +1 -0
- package/dist/nodes/abstractToolNode.d.ts +32 -0
- package/dist/nodes/abstractToolNode.js +44 -0
- package/dist/nodes/abstractToolNode.js.map +1 -0
- package/dist/nodes/getUserInput/factory.d.ts +42 -0
- package/dist/nodes/getUserInput/factory.js +64 -0
- package/dist/nodes/getUserInput/factory.js.map +1 -0
- package/dist/nodes/getUserInput/index.d.ts +2 -0
- package/dist/nodes/getUserInput/index.js +3 -0
- package/dist/nodes/getUserInput/index.js.map +1 -0
- package/dist/nodes/getUserInput/node.d.ts +68 -0
- package/dist/nodes/getUserInput/node.js +41 -0
- package/dist/nodes/getUserInput/node.js.map +1 -0
- package/dist/nodes/index.d.ts +5 -0
- package/dist/nodes/index.js +12 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/toolExecutor.d.ts +22 -0
- package/dist/nodes/toolExecutor.js +19 -0
- package/dist/nodes/toolExecutor.js.map +1 -0
- package/dist/nodes/userInputExtraction/factory.d.ts +42 -0
- package/dist/nodes/userInputExtraction/factory.js +55 -0
- package/dist/nodes/userInputExtraction/factory.js.map +1 -0
- package/dist/nodes/userInputExtraction/index.d.ts +2 -0
- package/dist/nodes/userInputExtraction/index.js +3 -0
- package/dist/nodes/userInputExtraction/index.js.map +1 -0
- package/dist/nodes/userInputExtraction/node.d.ts +60 -0
- package/dist/nodes/userInputExtraction/node.js +24 -0
- package/dist/nodes/userInputExtraction/node.js.map +1 -0
- package/dist/routers/checkPropertiesFulfilledRouter.d.ts +74 -0
- package/dist/routers/checkPropertiesFulfilledRouter.js +106 -0
- package/dist/routers/checkPropertiesFulfilledRouter.js.map +1 -0
- package/dist/routers/index.d.ts +1 -0
- package/dist/routers/index.js +8 -0
- package/dist/routers/index.js.map +1 -0
- package/dist/services/abstractService.d.ts +71 -0
- package/dist/services/abstractService.js +83 -0
- package/dist/services/abstractService.js.map +1 -0
- package/dist/services/getInputService.d.ts +43 -0
- package/dist/services/getInputService.js +48 -0
- package/dist/services/getInputService.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +10 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/inputExtractionService.d.ts +46 -0
- package/dist/services/inputExtractionService.js +133 -0
- package/dist/services/inputExtractionService.js.map +1 -0
- package/dist/storage/wellKnownDirectory.d.ts +79 -0
- package/dist/storage/wellKnownDirectory.js +121 -0
- package/dist/storage/wellKnownDirectory.js.map +1 -0
- package/dist/tools/base/abstractTool.d.ts +61 -0
- package/dist/tools/base/abstractTool.js +87 -0
- package/dist/tools/base/abstractTool.js.map +1 -0
- package/dist/tools/base/abstractWorkflowTool.d.ts +34 -0
- package/dist/tools/base/abstractWorkflowTool.js +94 -0
- package/dist/tools/base/abstractWorkflowTool.js.map +1 -0
- package/dist/tools/base/index.d.ts +2 -0
- package/dist/tools/base/index.js +9 -0
- package/dist/tools/base/index.js.map +1 -0
- package/dist/tools/orchestrator/config.d.ts +55 -0
- package/dist/tools/orchestrator/config.js +8 -0
- package/dist/tools/orchestrator/config.js.map +1 -0
- package/dist/tools/orchestrator/index.d.ts +3 -0
- package/dist/tools/orchestrator/index.js +9 -0
- package/dist/tools/orchestrator/index.js.map +1 -0
- package/dist/tools/orchestrator/metadata.d.ts +55 -0
- package/dist/tools/orchestrator/metadata.js +49 -0
- package/dist/tools/orchestrator/metadata.js.map +1 -0
- package/dist/tools/orchestrator/orchestratorTool.d.ts +39 -0
- package/dist/tools/orchestrator/orchestratorTool.js +186 -0
- package/dist/tools/orchestrator/orchestratorTool.js.map +1 -0
- package/dist/tools/utilities/getInput/factory.d.ts +43 -0
- package/dist/tools/utilities/getInput/factory.js +32 -0
- package/dist/tools/utilities/getInput/factory.js.map +1 -0
- package/dist/tools/utilities/getInput/index.d.ts +3 -0
- package/dist/tools/utilities/getInput/index.js +10 -0
- package/dist/tools/utilities/getInput/index.js.map +1 -0
- package/dist/tools/utilities/getInput/metadata.d.ts +78 -0
- package/dist/tools/utilities/getInput/metadata.js +43 -0
- package/dist/tools/utilities/getInput/metadata.js.map +1 -0
- package/dist/tools/utilities/getInput/tool.d.ts +89 -0
- package/dist/tools/utilities/getInput/tool.js +69 -0
- package/dist/tools/utilities/getInput/tool.js.map +1 -0
- package/dist/tools/utilities/index.d.ts +2 -0
- package/dist/tools/utilities/index.js +9 -0
- package/dist/tools/utilities/index.js.map +1 -0
- package/dist/tools/utilities/inputExtraction/factory.d.ts +43 -0
- package/dist/tools/utilities/inputExtraction/factory.js +32 -0
- package/dist/tools/utilities/inputExtraction/factory.js.map +1 -0
- package/dist/tools/utilities/inputExtraction/index.d.ts +3 -0
- package/dist/tools/utilities/inputExtraction/index.js +10 -0
- package/dist/tools/utilities/inputExtraction/index.js.map +1 -0
- package/dist/tools/utilities/inputExtraction/metadata.d.ts +66 -0
- package/dist/tools/utilities/inputExtraction/metadata.js +52 -0
- package/dist/tools/utilities/inputExtraction/metadata.js.map +1 -0
- package/dist/tools/utilities/inputExtraction/tool.d.ts +82 -0
- package/dist/tools/utilities/inputExtraction/tool.js +71 -0
- package/dist/tools/utilities/inputExtraction/tool.js.map +1 -0
- package/dist/utils/toolExecutionUtils.d.ts +55 -0
- package/dist/utils/toolExecutionUtils.js +70 -0
- package/dist/utils/toolExecutionUtils.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,19 @@
|
|
|
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 { interrupt } from '@langchain/langgraph';
|
|
8
|
+
/**
|
|
9
|
+
* Production implementation of ToolExecutor that uses LangGraph's interrupt mechanism.
|
|
10
|
+
* This is the default implementation used in production workflows.
|
|
11
|
+
*/
|
|
12
|
+
/* c8 ignore start */
|
|
13
|
+
export class LangGraphToolExecutor {
|
|
14
|
+
execute(toolInvocationData) {
|
|
15
|
+
return interrupt(toolInvocationData);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/* c8 ignore stop */
|
|
19
|
+
//# sourceMappingURL=toolExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolExecutor.js","sourceRoot":"","sources":["../../src/nodes/toolExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAiBjD;;;GAGG;AACH,qBAAqB;AACrB,MAAM,OAAO,qBAAqB;IAChC,OAAO,CAAC,kBAAqE;QAC3E,OAAO,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACvC,CAAC;CACF;AACD,oBAAoB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StateType, StateDefinition } from '@langchain/langgraph';
|
|
2
|
+
import { BaseNode } from '../abstractBaseNode.js';
|
|
3
|
+
import { UserInputExtractionNodeOptions } from './node.js';
|
|
4
|
+
/**
|
|
5
|
+
* Factory function to create a User Input Extraction Node
|
|
6
|
+
*
|
|
7
|
+
* This node extracts structured properties from user input using LLM-based
|
|
8
|
+
* natural language understanding. It takes raw user input and attempts to extract
|
|
9
|
+
* as many workflow properties as possible.
|
|
10
|
+
*
|
|
11
|
+
* @template TState - The state type for the workflow
|
|
12
|
+
* @param options - Configuration options for the node
|
|
13
|
+
* @returns A configured User Input Extraction Node instance
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const MyState = Annotation.Root({
|
|
18
|
+
* userInput: Annotation<unknown>,
|
|
19
|
+
* platform: Annotation<string>,
|
|
20
|
+
* projectName: Annotation<string>,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const properties = {
|
|
24
|
+
* platform: {
|
|
25
|
+
* zodType: z.enum(['iOS', 'Android']),
|
|
26
|
+
* description: 'Target platform',
|
|
27
|
+
* friendlyName: 'platform',
|
|
28
|
+
* },
|
|
29
|
+
* projectName: {
|
|
30
|
+
* zodType: z.string(),
|
|
31
|
+
* description: 'Project name',
|
|
32
|
+
* friendlyName: 'project name',
|
|
33
|
+
* },
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* const node = createUserInputExtractionNode({
|
|
37
|
+
* requiredProperties: properties,
|
|
38
|
+
* extractionService: myExtractionService,
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function createUserInputExtractionNode<TState extends StateType<StateDefinition>>(options: UserInputExtractionNodeOptions<TState>): BaseNode<TState>;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { LangGraphToolExecutor } from '../toolExecutor.js';
|
|
8
|
+
import { createComponentLogger } from '../../logging/logger.js';
|
|
9
|
+
import { InputExtractionService, } from '../../services/inputExtractionService.js';
|
|
10
|
+
import { UserInputExtractionNode } from './node.js';
|
|
11
|
+
/**
|
|
12
|
+
* Factory function to create a User Input Extraction Node
|
|
13
|
+
*
|
|
14
|
+
* This node extracts structured properties from user input using LLM-based
|
|
15
|
+
* natural language understanding. It takes raw user input and attempts to extract
|
|
16
|
+
* as many workflow properties as possible.
|
|
17
|
+
*
|
|
18
|
+
* @template TState - The state type for the workflow
|
|
19
|
+
* @param options - Configuration options for the node
|
|
20
|
+
* @returns A configured User Input Extraction Node instance
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const MyState = Annotation.Root({
|
|
25
|
+
* userInput: Annotation<unknown>,
|
|
26
|
+
* platform: Annotation<string>,
|
|
27
|
+
* projectName: Annotation<string>,
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const properties = {
|
|
31
|
+
* platform: {
|
|
32
|
+
* zodType: z.enum(['iOS', 'Android']),
|
|
33
|
+
* description: 'Target platform',
|
|
34
|
+
* friendlyName: 'platform',
|
|
35
|
+
* },
|
|
36
|
+
* projectName: {
|
|
37
|
+
* zodType: z.string(),
|
|
38
|
+
* description: 'Project name',
|
|
39
|
+
* friendlyName: 'project name',
|
|
40
|
+
* },
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* const node = createUserInputExtractionNode({
|
|
44
|
+
* requiredProperties: properties,
|
|
45
|
+
* extractionService: myExtractionService,
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function createUserInputExtractionNode(options) {
|
|
50
|
+
const { requiredProperties, toolId, extractionService, toolExecutor = new LangGraphToolExecutor(), logger = createComponentLogger('UserInputExtractionNode'), userInputProperty, } = options;
|
|
51
|
+
// Create default service implementation if not provided
|
|
52
|
+
const service = extractionService ?? new InputExtractionService(toolId, toolExecutor, logger);
|
|
53
|
+
return new UserInputExtractionNode(service, requiredProperties, userInputProperty);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/nodes/userInputExtraction/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,sBAAsB,GAEvB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAkC,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAA+C;IAE/C,MAAM,EACJ,kBAAkB,EAClB,MAAM,EACN,iBAAiB,EACjB,YAAY,GAAG,IAAI,qBAAqB,EAAE,EAC1C,MAAM,GAAG,qBAAqB,CAAC,yBAAyB,CAAC,EACzD,iBAAiB,GAClB,GAAG,OAAO,CAAC;IAEZ,wDAAwD;IACxD,MAAM,OAAO,GACX,iBAAiB,IAAI,IAAI,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAEhF,OAAO,IAAI,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nodes/userInputExtraction/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { StateType, StateDefinition } from '@langchain/langgraph';
|
|
2
|
+
import { BaseNode } from '../abstractBaseNode.js';
|
|
3
|
+
import { PropertyMetadataCollection } from '../../common/propertyMetadata.js';
|
|
4
|
+
import { ToolExecutor } from '../toolExecutor.js';
|
|
5
|
+
import { Logger } from '../../logging/logger.js';
|
|
6
|
+
import { InputExtractionServiceProvider } from '../../services/inputExtractionService.js';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for creating a User Input Extraction Node
|
|
9
|
+
*/
|
|
10
|
+
export interface UserInputExtractionNodeOptions<TState extends StateType<StateDefinition>> {
|
|
11
|
+
/**
|
|
12
|
+
* Collection of properties that must be collected from user
|
|
13
|
+
*/
|
|
14
|
+
requiredProperties: PropertyMetadataCollection;
|
|
15
|
+
/**
|
|
16
|
+
* Tool ID for the input extraction tool (e.g., 'magen-input-extraction', 'sfmobile-native-input-extraction')
|
|
17
|
+
* Required if extractionService is not provided
|
|
18
|
+
*/
|
|
19
|
+
toolId: string;
|
|
20
|
+
/**
|
|
21
|
+
* Service provider for property extraction (injectable for testing)
|
|
22
|
+
* If not provided, a default implementation will be created using toolId
|
|
23
|
+
*/
|
|
24
|
+
extractionService?: InputExtractionServiceProvider;
|
|
25
|
+
/**
|
|
26
|
+
* Tool executor for services (optional, defaults to LangGraphToolExecutor)
|
|
27
|
+
*/
|
|
28
|
+
toolExecutor?: ToolExecutor;
|
|
29
|
+
/**
|
|
30
|
+
* Logger instance (optional, defaults to component logger)
|
|
31
|
+
*/
|
|
32
|
+
logger?: Logger;
|
|
33
|
+
/**
|
|
34
|
+
* Property name in state that contains user input to extract from.
|
|
35
|
+
* Must be a valid property of TState.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
*
|
|
39
|
+
* // State has a 'userInput' property
|
|
40
|
+
* createUserInputExtractionNode({
|
|
41
|
+
* userInputProperty: 'userInput',
|
|
42
|
+
* ...
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // State has a 'currentUtterance' property
|
|
46
|
+
* createUserInputExtractionNode({
|
|
47
|
+
* userInputProperty: 'currentUtterance',
|
|
48
|
+
* ...
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
userInputProperty: keyof TState;
|
|
53
|
+
}
|
|
54
|
+
export declare class UserInputExtractionNode<TState extends StateType<StateDefinition>> extends BaseNode<TState> {
|
|
55
|
+
private readonly extractionService;
|
|
56
|
+
private readonly requiredProperties;
|
|
57
|
+
private readonly userInputProperty;
|
|
58
|
+
constructor(extractionService: InputExtractionServiceProvider, requiredProperties: PropertyMetadataCollection, userInputProperty: keyof TState);
|
|
59
|
+
execute: (state: TState) => Partial<TState>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { BaseNode } from '../abstractBaseNode.js';
|
|
8
|
+
export class UserInputExtractionNode extends BaseNode {
|
|
9
|
+
extractionService;
|
|
10
|
+
requiredProperties;
|
|
11
|
+
userInputProperty;
|
|
12
|
+
constructor(extractionService, requiredProperties, userInputProperty) {
|
|
13
|
+
super('userInputExtraction');
|
|
14
|
+
this.extractionService = extractionService;
|
|
15
|
+
this.requiredProperties = requiredProperties;
|
|
16
|
+
this.userInputProperty = userInputProperty;
|
|
17
|
+
}
|
|
18
|
+
execute = (state) => {
|
|
19
|
+
const userInput = state[this.userInputProperty];
|
|
20
|
+
const result = this.extractionService.extractProperties(userInput, this.requiredProperties);
|
|
21
|
+
return result.extractedProperties;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/nodes/userInputExtraction/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA2DlD,MAAM,OAAO,uBAEX,SAAQ,QAAgB;IAEL;IACA;IACA;IAHnB,YACmB,iBAAiD,EACjD,kBAA8C,EAC9C,iBAA+B;QAEhD,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAJZ,sBAAiB,GAAjB,iBAAiB,CAAgC;QACjD,uBAAkB,GAAlB,kBAAkB,CAA4B;QAC9C,sBAAiB,GAAjB,iBAAiB,CAAc;IAGlD,CAAC;IAED,OAAO,GAAG,CAAC,KAAa,EAAmB,EAAE;QAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC5F,OAAO,MAAM,CAAC,mBAAiD,CAAC;IAClE,CAAC,CAAC;CACH"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { StateType, StateDefinition } from '@langchain/langgraph';
|
|
2
|
+
import { PropertyMetadataCollection } from '../common/propertyMetadata.js';
|
|
3
|
+
import { Logger } from '../logging/logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Conditional router edge to check whether all required properties have been collected.
|
|
6
|
+
*
|
|
7
|
+
* This router evaluates the workflow state to determine if all properties specified
|
|
8
|
+
* in the required properties collection have been fulfilled (are truthy). Based on
|
|
9
|
+
* this evaluation, it routes to either a "fulfilled" or "unfulfilled" node.
|
|
10
|
+
*
|
|
11
|
+
* @template TState - The state type for the workflow
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const requiredProperties: PropertyMetadataCollection = {
|
|
16
|
+
* platform: {
|
|
17
|
+
* zodType: z.enum(['iOS', 'Android']),
|
|
18
|
+
* description: 'Target platform',
|
|
19
|
+
* friendlyName: 'platform',
|
|
20
|
+
* },
|
|
21
|
+
* projectName: {
|
|
22
|
+
* zodType: z.string(),
|
|
23
|
+
* description: 'Project name',
|
|
24
|
+
* friendlyName: 'project name',
|
|
25
|
+
* },
|
|
26
|
+
* };
|
|
27
|
+
*
|
|
28
|
+
* const router = new CheckPropertiesFulfilledRouter<State>(
|
|
29
|
+
* 'continueWorkflow', // Node to route to when all properties are fulfilled
|
|
30
|
+
* 'getUserInput', // Node to route to when properties are missing
|
|
31
|
+
* requiredProperties
|
|
32
|
+
* );
|
|
33
|
+
*
|
|
34
|
+
* // Use in LangGraph workflow
|
|
35
|
+
* workflow.addConditionalEdges('checkProperties', router.execute);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class CheckPropertiesFulfilledRouter<TState extends StateType<StateDefinition>> {
|
|
39
|
+
private readonly propertiesFulfilledNodeName;
|
|
40
|
+
private readonly propertiesUnfulfilledNodeName;
|
|
41
|
+
private readonly requiredProperties;
|
|
42
|
+
private readonly logger;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new CheckPropertiesFulfilledRouter.
|
|
45
|
+
*
|
|
46
|
+
* @param propertiesFulfilledNodeName - The name of the node to route to if all properties are fulfilled
|
|
47
|
+
* @param propertiesUnfulfilledNodeName - The name of the node to route to if any property is unfulfilled
|
|
48
|
+
* @param requiredProperties - Collection of properties that must be collected from user
|
|
49
|
+
* @param logger - Optional logger instance for debugging and monitoring routing decisions.
|
|
50
|
+
* If not provided, a default component logger will be created.
|
|
51
|
+
*/
|
|
52
|
+
constructor(propertiesFulfilledNodeName: string, propertiesUnfulfilledNodeName: string, requiredProperties: PropertyMetadataCollection, logger?: Logger);
|
|
53
|
+
/**
|
|
54
|
+
* Evaluates the state to determine the next node based on property fulfillment.
|
|
55
|
+
*
|
|
56
|
+
* This method checks each property in the required properties collection.
|
|
57
|
+
* If any property is missing or falsy, it routes to the unfulfilled node.
|
|
58
|
+
* Only if all properties are present and truthy does it route to the fulfilled node.
|
|
59
|
+
*
|
|
60
|
+
* @param state - The current workflow state
|
|
61
|
+
* @returns The name of the next node to route to
|
|
62
|
+
*/
|
|
63
|
+
execute: (state: TState) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Internal method to check property fulfillment status.
|
|
66
|
+
*
|
|
67
|
+
* Iterates through all required properties and checks if they exist
|
|
68
|
+
* and are truthy in the state object.
|
|
69
|
+
*
|
|
70
|
+
* @param state - The current workflow state
|
|
71
|
+
* @returns The name of the node to route to based on fulfillment status
|
|
72
|
+
*/
|
|
73
|
+
private getPropertyFulfillmentStatus;
|
|
74
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { createComponentLogger } from '../logging/logger.js';
|
|
8
|
+
/**
|
|
9
|
+
* Conditional router edge to check whether all required properties have been collected.
|
|
10
|
+
*
|
|
11
|
+
* This router evaluates the workflow state to determine if all properties specified
|
|
12
|
+
* in the required properties collection have been fulfilled (are truthy). Based on
|
|
13
|
+
* this evaluation, it routes to either a "fulfilled" or "unfulfilled" node.
|
|
14
|
+
*
|
|
15
|
+
* @template TState - The state type for the workflow
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const requiredProperties: PropertyMetadataCollection = {
|
|
20
|
+
* platform: {
|
|
21
|
+
* zodType: z.enum(['iOS', 'Android']),
|
|
22
|
+
* description: 'Target platform',
|
|
23
|
+
* friendlyName: 'platform',
|
|
24
|
+
* },
|
|
25
|
+
* projectName: {
|
|
26
|
+
* zodType: z.string(),
|
|
27
|
+
* description: 'Project name',
|
|
28
|
+
* friendlyName: 'project name',
|
|
29
|
+
* },
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* const router = new CheckPropertiesFulfilledRouter<State>(
|
|
33
|
+
* 'continueWorkflow', // Node to route to when all properties are fulfilled
|
|
34
|
+
* 'getUserInput', // Node to route to when properties are missing
|
|
35
|
+
* requiredProperties
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* // Use in LangGraph workflow
|
|
39
|
+
* workflow.addConditionalEdges('checkProperties', router.execute);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class CheckPropertiesFulfilledRouter {
|
|
43
|
+
propertiesFulfilledNodeName;
|
|
44
|
+
propertiesUnfulfilledNodeName;
|
|
45
|
+
requiredProperties;
|
|
46
|
+
logger;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new CheckPropertiesFulfilledRouter.
|
|
49
|
+
*
|
|
50
|
+
* @param propertiesFulfilledNodeName - The name of the node to route to if all properties are fulfilled
|
|
51
|
+
* @param propertiesUnfulfilledNodeName - The name of the node to route to if any property is unfulfilled
|
|
52
|
+
* @param requiredProperties - Collection of properties that must be collected from user
|
|
53
|
+
* @param logger - Optional logger instance for debugging and monitoring routing decisions.
|
|
54
|
+
* If not provided, a default component logger will be created.
|
|
55
|
+
*/
|
|
56
|
+
constructor(propertiesFulfilledNodeName, propertiesUnfulfilledNodeName, requiredProperties, logger) {
|
|
57
|
+
this.propertiesFulfilledNodeName = propertiesFulfilledNodeName;
|
|
58
|
+
this.propertiesUnfulfilledNodeName = propertiesUnfulfilledNodeName;
|
|
59
|
+
this.requiredProperties = requiredProperties;
|
|
60
|
+
this.logger = logger || createComponentLogger('CheckPropertiesFulfilledRouter');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Evaluates the state to determine the next node based on property fulfillment.
|
|
64
|
+
*
|
|
65
|
+
* This method checks each property in the required properties collection.
|
|
66
|
+
* If any property is missing or falsy, it routes to the unfulfilled node.
|
|
67
|
+
* Only if all properties are present and truthy does it route to the fulfilled node.
|
|
68
|
+
*
|
|
69
|
+
* @param state - The current workflow state
|
|
70
|
+
* @returns The name of the next node to route to
|
|
71
|
+
*/
|
|
72
|
+
execute = (state) => {
|
|
73
|
+
return this.getPropertyFulfillmentStatus(state);
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Internal method to check property fulfillment status.
|
|
77
|
+
*
|
|
78
|
+
* Iterates through all required properties and checks if they exist
|
|
79
|
+
* and are truthy in the state object.
|
|
80
|
+
*
|
|
81
|
+
* @param state - The current workflow state
|
|
82
|
+
* @returns The name of the node to route to based on fulfillment status
|
|
83
|
+
*/
|
|
84
|
+
getPropertyFulfillmentStatus(state) {
|
|
85
|
+
const unfulfilledProperties = [];
|
|
86
|
+
for (const propertyName of Object.keys(this.requiredProperties)) {
|
|
87
|
+
if (!state[propertyName]) {
|
|
88
|
+
unfulfilledProperties.push(propertyName);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (unfulfilledProperties.length > 0) {
|
|
92
|
+
this.logger.debug('Properties not fulfilled, routing to unfulfilled node', {
|
|
93
|
+
unfulfilledProperties,
|
|
94
|
+
targetNode: this.propertiesUnfulfilledNodeName,
|
|
95
|
+
totalRequired: Object.keys(this.requiredProperties).length,
|
|
96
|
+
});
|
|
97
|
+
return this.propertiesUnfulfilledNodeName;
|
|
98
|
+
}
|
|
99
|
+
this.logger.debug('All properties fulfilled, routing to fulfilled node', {
|
|
100
|
+
targetNode: this.propertiesFulfilledNodeName,
|
|
101
|
+
totalProperties: Object.keys(this.requiredProperties).length,
|
|
102
|
+
});
|
|
103
|
+
return this.propertiesFulfilledNodeName;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=checkPropertiesFulfilledRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkPropertiesFulfilledRouter.js","sourceRoot":"","sources":["../../src/routers/checkPropertiesFulfilledRouter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAU,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,8BAA8B;IACxB,2BAA2B,CAAS;IACpC,6BAA6B,CAAS;IACtC,kBAAkB,CAA6B;IAC/C,MAAM,CAAS;IAEhC;;;;;;;;OAQG;IACH,YACE,2BAAmC,EACnC,6BAAqC,EACrC,kBAA8C,EAC9C,MAAe;QAEf,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QAC/D,IAAI,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;QACnE,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,qBAAqB,CAAC,gCAAgC,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;;;;OASG;IACH,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE;QAClC,OAAO,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC;IAEF;;;;;;;;OAQG;IACK,4BAA4B,CAAC,KAAa;QAChD,MAAM,qBAAqB,GAAa,EAAE,CAAC;QAE3C,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,KAAK,CAAC,YAA4B,CAAC,EAAE,CAAC;gBACzC,qBAAqB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uDAAuD,EAAE;gBACzE,qBAAqB;gBACrB,UAAU,EAAE,IAAI,CAAC,6BAA6B;gBAC9C,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM;aAC3D,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,6BAA6B,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qDAAqD,EAAE;YACvE,UAAU,EAAE,IAAI,CAAC,2BAA2B;YAC5C,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM;SAC7D,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CheckPropertiesFulfilledRouter } from './checkPropertiesFulfilledRouter.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
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 { CheckPropertiesFulfilledRouter } from './checkPropertiesFulfilledRouter.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { MCPToolInvocationData } from '../common/metadata.js';
|
|
3
|
+
import { Logger } from '../logging/logger.js';
|
|
4
|
+
import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class for services that execute MCP tools.
|
|
7
|
+
*
|
|
8
|
+
* This class provides a standardized pattern for services that need to invoke
|
|
9
|
+
* MCP tools with proper logging, error handling, and result validation. It mirrors
|
|
10
|
+
* the functionality of AbstractToolNode but is designed for service-layer components
|
|
11
|
+
* that don't participate in the LangGraph workflow state machine.
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* - Dependency injection support for ToolExecutor and Logger
|
|
15
|
+
* - Automatic component naming and logger initialization
|
|
16
|
+
* - Common tool execution pattern with comprehensive logging
|
|
17
|
+
* - Result validation using Zod schemas
|
|
18
|
+
* - Optional custom validation logic
|
|
19
|
+
*
|
|
20
|
+
* Services that extend this class should:
|
|
21
|
+
* 1. Call super() in their constructor, optionally passing toolExecutor and logger
|
|
22
|
+
* 2. Use executeToolWithLogging() to invoke tools
|
|
23
|
+
* 3. Implement their business logic around the tool invocations
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* export class MyService extends AbstractService {
|
|
27
|
+
* constructor(toolExecutor?: ToolExecutor, logger?: Logger) {
|
|
28
|
+
* super('MyService', toolExecutor, logger);
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* doSomething(input: string): ResultType {
|
|
32
|
+
* const toolInvocationData = { ... };
|
|
33
|
+
* return this.executeToolWithLogging(
|
|
34
|
+
* toolInvocationData,
|
|
35
|
+
* MyToolResultSchema
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
export declare abstract class AbstractService {
|
|
41
|
+
protected readonly logger: Logger;
|
|
42
|
+
protected readonly componentName: string;
|
|
43
|
+
protected readonly toolExecutor: ToolExecutor;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new AbstractService.
|
|
46
|
+
*
|
|
47
|
+
* @param serviceName - Name of the service (used for logging and component identification)
|
|
48
|
+
* @param toolExecutor - Tool executor for invoking MCP tools (injectable for testing)
|
|
49
|
+
* @param logger - Logger instance (injectable for testing)
|
|
50
|
+
*/
|
|
51
|
+
constructor(serviceName: string, toolExecutor?: ToolExecutor, logger?: Logger);
|
|
52
|
+
/**
|
|
53
|
+
* Protected method to execute a tool with logging and validation.
|
|
54
|
+
*
|
|
55
|
+
* By default, results are validated using the provided Zod schema's parse method.
|
|
56
|
+
* Pass a custom validator function to implement additional validation logic or
|
|
57
|
+
* transformation of the result.
|
|
58
|
+
*
|
|
59
|
+
* This method uses the common toolExecutionUtils.executeToolWithLogging function
|
|
60
|
+
* to ensure consistent behavior across all tool invocations in the codebase.
|
|
61
|
+
*
|
|
62
|
+
* @param toolInvocationData - The tool invocation data to pass to the tool executor
|
|
63
|
+
* @param resultSchema - The schema to validate the result against
|
|
64
|
+
* @param validator - Optional custom validator function
|
|
65
|
+
* @returns The validated result from the tool execution
|
|
66
|
+
*
|
|
67
|
+
* @throws {z.ZodError} If the result does not match the schema (when using default validation)
|
|
68
|
+
* @throws {Error} If tool execution fails or custom validator throws
|
|
69
|
+
*/
|
|
70
|
+
protected executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(toolInvocationData: MCPToolInvocationData<z.ZodObject<z.ZodRawShape>>, resultSchema: TResultSchema, validator?: (result: unknown, schema: TResultSchema) => z.infer<TResultSchema>): z.infer<TResultSchema>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { createComponentLogger } from '../logging/logger.js';
|
|
8
|
+
import { LangGraphToolExecutor } from '../nodes/toolExecutor.js';
|
|
9
|
+
import { executeToolWithLogging } from '../utils/toolExecutionUtils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for services that execute MCP tools.
|
|
12
|
+
*
|
|
13
|
+
* This class provides a standardized pattern for services that need to invoke
|
|
14
|
+
* MCP tools with proper logging, error handling, and result validation. It mirrors
|
|
15
|
+
* the functionality of AbstractToolNode but is designed for service-layer components
|
|
16
|
+
* that don't participate in the LangGraph workflow state machine.
|
|
17
|
+
*
|
|
18
|
+
* Features:
|
|
19
|
+
* - Dependency injection support for ToolExecutor and Logger
|
|
20
|
+
* - Automatic component naming and logger initialization
|
|
21
|
+
* - Common tool execution pattern with comprehensive logging
|
|
22
|
+
* - Result validation using Zod schemas
|
|
23
|
+
* - Optional custom validation logic
|
|
24
|
+
*
|
|
25
|
+
* Services that extend this class should:
|
|
26
|
+
* 1. Call super() in their constructor, optionally passing toolExecutor and logger
|
|
27
|
+
* 2. Use executeToolWithLogging() to invoke tools
|
|
28
|
+
* 3. Implement their business logic around the tool invocations
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* export class MyService extends AbstractService {
|
|
32
|
+
* constructor(toolExecutor?: ToolExecutor, logger?: Logger) {
|
|
33
|
+
* super('MyService', toolExecutor, logger);
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* doSomething(input: string): ResultType {
|
|
37
|
+
* const toolInvocationData = { ... };
|
|
38
|
+
* return this.executeToolWithLogging(
|
|
39
|
+
* toolInvocationData,
|
|
40
|
+
* MyToolResultSchema
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
*/
|
|
45
|
+
export class AbstractService {
|
|
46
|
+
logger;
|
|
47
|
+
componentName;
|
|
48
|
+
toolExecutor;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new AbstractService.
|
|
51
|
+
*
|
|
52
|
+
* @param serviceName - Name of the service (used for logging and component identification)
|
|
53
|
+
* @param toolExecutor - Tool executor for invoking MCP tools (injectable for testing)
|
|
54
|
+
* @param logger - Logger instance (injectable for testing)
|
|
55
|
+
*/
|
|
56
|
+
constructor(serviceName, toolExecutor, logger) {
|
|
57
|
+
this.componentName = `Service:${serviceName}`;
|
|
58
|
+
this.logger = logger ?? createComponentLogger(this.componentName);
|
|
59
|
+
this.toolExecutor = toolExecutor ?? new LangGraphToolExecutor();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Protected method to execute a tool with logging and validation.
|
|
63
|
+
*
|
|
64
|
+
* By default, results are validated using the provided Zod schema's parse method.
|
|
65
|
+
* Pass a custom validator function to implement additional validation logic or
|
|
66
|
+
* transformation of the result.
|
|
67
|
+
*
|
|
68
|
+
* This method uses the common toolExecutionUtils.executeToolWithLogging function
|
|
69
|
+
* to ensure consistent behavior across all tool invocations in the codebase.
|
|
70
|
+
*
|
|
71
|
+
* @param toolInvocationData - The tool invocation data to pass to the tool executor
|
|
72
|
+
* @param resultSchema - The schema to validate the result against
|
|
73
|
+
* @param validator - Optional custom validator function
|
|
74
|
+
* @returns The validated result from the tool execution
|
|
75
|
+
*
|
|
76
|
+
* @throws {z.ZodError} If the result does not match the schema (when using default validation)
|
|
77
|
+
* @throws {Error} If tool execution fails or custom validator throws
|
|
78
|
+
*/
|
|
79
|
+
executeToolWithLogging(toolInvocationData, resultSchema, validator) {
|
|
80
|
+
return executeToolWithLogging(this.toolExecutor, this.logger, toolInvocationData, resultSchema, validator);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=abstractService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractService.js","sourceRoot":"","sources":["../../src/services/abstractService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAU,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAgB,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAgB,eAAe;IAChB,MAAM,CAAS;IACf,aAAa,CAAS;IACtB,YAAY,CAAe;IAE9C;;;;;;OAMG;IACH,YAAY,WAAmB,EAAE,YAA2B,EAAE,MAAe;QAC3E,IAAI,CAAC,aAAa,GAAG,WAAW,WAAW,EAAE,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,qBAAqB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClE,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,IAAI,qBAAqB,EAAE,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACO,sBAAsB,CAC9B,kBAAqE,EACrE,YAA2B,EAC3B,SAA8E;QAE9E,OAAO,sBAAsB,CAC3B,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,MAAM,EACX,kBAAkB,EAClB,YAAY,EACZ,SAAS,CACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
2
|
+
import { AbstractService } from './abstractService.js';
|
|
3
|
+
import { Logger } from '../logging/logger.js';
|
|
4
|
+
export interface GetInputProperty {
|
|
5
|
+
/** Property name to be collected */
|
|
6
|
+
readonly propertyName: string;
|
|
7
|
+
/** Human-readable name for display */
|
|
8
|
+
readonly friendlyName: string;
|
|
9
|
+
/** Detailed description for LLM-based extraction */
|
|
10
|
+
readonly description: string;
|
|
11
|
+
/** Optional reason why the property is unfulfilled */
|
|
12
|
+
readonly reason?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Provider interface for user input service.
|
|
16
|
+
* This interface allows for dependency injection and testing.
|
|
17
|
+
*/
|
|
18
|
+
export interface GetInputServiceProvider {
|
|
19
|
+
/**
|
|
20
|
+
* Solicits user input with a given question.
|
|
21
|
+
*
|
|
22
|
+
* @param question - The question to ask the user
|
|
23
|
+
* @returns The user's response (can be any type)
|
|
24
|
+
*/
|
|
25
|
+
getInput(unfulfilledProperties: GetInputProperty[]): unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Service for getting user input for a given question.
|
|
29
|
+
*
|
|
30
|
+
* This service extends AbstractService to leverage common tool execution
|
|
31
|
+
* patterns including standardized logging and result validation.
|
|
32
|
+
*/
|
|
33
|
+
export declare class GetInputService extends AbstractService implements GetInputServiceProvider {
|
|
34
|
+
private readonly toolId;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new GetInputService.
|
|
37
|
+
*
|
|
38
|
+
* @param toolExecutor - Tool executor for invoking the input tool (injectable for testing)
|
|
39
|
+
* @param logger - Logger instance (injectable for testing)
|
|
40
|
+
*/
|
|
41
|
+
constructor(toolId: string, toolExecutor?: ToolExecutor, logger?: Logger);
|
|
42
|
+
getInput(unfulfilledProperties: GetInputProperty[]): unknown;
|
|
43
|
+
}
|