@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,13 +1,23 @@
|
|
|
1
1
|
import { StateType, StateDefinition } from '@langchain/langgraph';
|
|
2
|
+
import type { WorkflowRunnableConfig } from '../common/graphConfig.js';
|
|
3
|
+
export type { WorkflowRunnableConfig } from '../common/graphConfig.js';
|
|
2
4
|
/**
|
|
3
5
|
* Base class for all workflow nodes
|
|
4
6
|
*
|
|
7
|
+
* LangGraph supports both sync and async node functions. This base class
|
|
8
|
+
* supports both patterns - nodes can return Partial<TState> synchronously
|
|
9
|
+
* or Promise<Partial<TState>> asynchronously.
|
|
10
|
+
*
|
|
11
|
+
* Nodes receive an optional second parameter `config` (RunnableConfig) that
|
|
12
|
+
* contains runtime context like progress reporters, thread IDs, etc. This
|
|
13
|
+
* is the proper way to access runtime dependencies without polluting state.
|
|
14
|
+
*
|
|
5
15
|
* @template TState - The state type for the workflow (defaults to StateType<StateDefinition>)
|
|
6
16
|
*
|
|
7
|
-
* Example:
|
|
17
|
+
* Example (sync):
|
|
8
18
|
* ```
|
|
9
19
|
* const MyWorkflowState = Annotation.Root({ count: Annotation<number> });
|
|
10
|
-
* type State = typeof MyWorkflowState.State;
|
|
20
|
+
* type State = typeof MyWorkflowState.State;
|
|
11
21
|
*
|
|
12
22
|
* class IncrementNode extends BaseNode<State> {
|
|
13
23
|
* constructor() {
|
|
@@ -19,9 +29,25 @@ import { StateType, StateDefinition } from '@langchain/langgraph';
|
|
|
19
29
|
* };
|
|
20
30
|
* }
|
|
21
31
|
* ```
|
|
32
|
+
*
|
|
33
|
+
* Example (async with config):
|
|
34
|
+
* ```
|
|
35
|
+
* class AsyncNode extends BaseNode<State> {
|
|
36
|
+
* constructor() {
|
|
37
|
+
* super('asyncNode');
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* execute = async (state: State, config?: WorkflowRunnableConfig) => {
|
|
41
|
+
* const progressReporter = config?.configurable?.progressReporter;
|
|
42
|
+
* progressReporter?.report(50, 100, 'Processing...');
|
|
43
|
+
* const result = await someAsyncOperation();
|
|
44
|
+
* return { data: result };
|
|
45
|
+
* };
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
22
48
|
*/
|
|
23
49
|
export declare abstract class BaseNode<TState extends StateType<StateDefinition>> {
|
|
24
50
|
readonly name: string;
|
|
25
51
|
constructor(name: string);
|
|
26
|
-
abstract execute: (state: TState) => Partial<TState
|
|
52
|
+
abstract execute: (state: TState, config?: WorkflowRunnableConfig) => Partial<TState> | Promise<Partial<TState>>;
|
|
27
53
|
}
|
|
@@ -7,12 +7,20 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Base class for all workflow nodes
|
|
9
9
|
*
|
|
10
|
+
* LangGraph supports both sync and async node functions. This base class
|
|
11
|
+
* supports both patterns - nodes can return Partial<TState> synchronously
|
|
12
|
+
* or Promise<Partial<TState>> asynchronously.
|
|
13
|
+
*
|
|
14
|
+
* Nodes receive an optional second parameter `config` (RunnableConfig) that
|
|
15
|
+
* contains runtime context like progress reporters, thread IDs, etc. This
|
|
16
|
+
* is the proper way to access runtime dependencies without polluting state.
|
|
17
|
+
*
|
|
10
18
|
* @template TState - The state type for the workflow (defaults to StateType<StateDefinition>)
|
|
11
19
|
*
|
|
12
|
-
* Example:
|
|
20
|
+
* Example (sync):
|
|
13
21
|
* ```
|
|
14
22
|
* const MyWorkflowState = Annotation.Root({ count: Annotation<number> });
|
|
15
|
-
* type State = typeof MyWorkflowState.State;
|
|
23
|
+
* type State = typeof MyWorkflowState.State;
|
|
16
24
|
*
|
|
17
25
|
* class IncrementNode extends BaseNode<State> {
|
|
18
26
|
* constructor() {
|
|
@@ -24,6 +32,22 @@
|
|
|
24
32
|
* };
|
|
25
33
|
* }
|
|
26
34
|
* ```
|
|
35
|
+
*
|
|
36
|
+
* Example (async with config):
|
|
37
|
+
* ```
|
|
38
|
+
* class AsyncNode extends BaseNode<State> {
|
|
39
|
+
* constructor() {
|
|
40
|
+
* super('asyncNode');
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* execute = async (state: State, config?: WorkflowRunnableConfig) => {
|
|
44
|
+
* const progressReporter = config?.configurable?.progressReporter;
|
|
45
|
+
* progressReporter?.report(50, 100, 'Processing...');
|
|
46
|
+
* const result = await someAsyncOperation();
|
|
47
|
+
* return { data: result };
|
|
48
|
+
* };
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
27
51
|
*/
|
|
28
52
|
export class BaseNode {
|
|
29
53
|
name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractBaseNode.js","sourceRoot":"","sources":["../../src/nodes/abstractBaseNode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"abstractBaseNode.js","sourceRoot":"","sources":["../../src/nodes/abstractBaseNode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,OAAgB,QAAQ;IACZ,IAAI,CAAS;IAE7B,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CAMF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { StateType, StateDefinition } from '@langchain/langgraph';
|
|
3
3
|
import { BaseNode } from './abstractBaseNode.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InterruptData } from '../common/metadata.js';
|
|
5
5
|
import { Logger } from '../logging/logger.js';
|
|
6
6
|
import { ToolExecutor } from './toolExecutor.js';
|
|
7
7
|
/**
|
|
@@ -23,10 +23,12 @@ export declare abstract class AbstractToolNode<TState extends StateType<StateDef
|
|
|
23
23
|
* This method uses the common toolExecutionUtils.executeToolWithLogging function
|
|
24
24
|
* to ensure consistent behavior across all tool invocations in the codebase.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* Supports both MCPToolInvocationData (delegate mode) and NodeGuidanceData (direct guidance mode).
|
|
27
|
+
*
|
|
28
|
+
* @param interruptData The interrupt data (MCPToolInvocationData or NodeGuidanceData) to pass to the tool executor
|
|
27
29
|
* @param resultSchema The schema to validate the result against
|
|
28
30
|
* @param validator Optional custom validator function
|
|
29
31
|
* @returns The validated result from the tool execution
|
|
30
32
|
*/
|
|
31
|
-
protected executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(
|
|
33
|
+
protected executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(interruptData: InterruptData<z.ZodObject<z.ZodRawShape>, TResultSchema>, resultSchema: TResultSchema, validator?: (result: unknown, schema: TResultSchema) => z.infer<TResultSchema>): z.infer<TResultSchema>;
|
|
32
34
|
}
|
|
@@ -32,13 +32,15 @@ export class AbstractToolNode extends BaseNode {
|
|
|
32
32
|
* This method uses the common toolExecutionUtils.executeToolWithLogging function
|
|
33
33
|
* to ensure consistent behavior across all tool invocations in the codebase.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
35
|
+
* Supports both MCPToolInvocationData (delegate mode) and NodeGuidanceData (direct guidance mode).
|
|
36
|
+
*
|
|
37
|
+
* @param interruptData The interrupt data (MCPToolInvocationData or NodeGuidanceData) to pass to the tool executor
|
|
36
38
|
* @param resultSchema The schema to validate the result against
|
|
37
39
|
* @param validator Optional custom validator function
|
|
38
40
|
* @returns The validated result from the tool execution
|
|
39
41
|
*/
|
|
40
|
-
executeToolWithLogging(
|
|
41
|
-
return executeToolWithLogging(this.toolExecutor, this.logger,
|
|
42
|
+
executeToolWithLogging(interruptData, resultSchema, validator) {
|
|
43
|
+
return executeToolWithLogging(this.toolExecutor, this.logger, interruptData, resultSchema, validator);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
//# sourceMappingURL=abstractToolNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractToolNode.js","sourceRoot":"","sources":["../../src/nodes/abstractToolNode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAU,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAgB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;GAIG;AACH,MAAM,OAAgB,gBAEpB,SAAQ,QAAgB;IACL,MAAM,CAAS;IACf,aAAa,CAAS;IACtB,YAAY,CAAe;IAE9C,YAAY,IAAY,EAAE,YAA2B,EAAE,MAAe;QACpE,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,aAAa,GAAG,gBAAgB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC7D,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
|
|
1
|
+
{"version":3,"file":"abstractToolNode.js","sourceRoot":"","sources":["../../src/nodes/abstractToolNode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAU,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAgB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;GAIG;AACH,MAAM,OAAgB,gBAEpB,SAAQ,QAAgB;IACL,MAAM,CAAS;IACf,aAAa,CAAS;IACtB,YAAY,CAAe;IAE9C,YAAY,IAAY,EAAE,YAA2B,EAAE,MAAe;QACpE,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,aAAa,GAAG,gBAAgB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC7D,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;;;;;;;;;;;;;;;OAeG;IACO,sBAAsB,CAC9B,aAAuE,EACvE,YAA2B,EAC3B,SAA8E;QAE9E,OAAO,sBAAsB,CAC3B,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,MAAM,EACX,aAAa,EACb,YAAY,EACZ,SAAS,CACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -56,9 +56,9 @@ export function createGetUserInputNode(options) {
|
|
|
56
56
|
isFulfilled: false,
|
|
57
57
|
reason: `Property '${propertyName}' is missing from the workflow state.`,
|
|
58
58
|
};
|
|
59
|
-
}, userInputProperty, } = options;
|
|
59
|
+
}, userInputProperty, nodeName = 'getUserInput', } = options;
|
|
60
60
|
// Create default service implementation if not provided
|
|
61
61
|
const service = getInputService ?? new GetInputService(toolId, toolExecutor, logger);
|
|
62
|
-
return new GetUserInputNode(service, requiredProperties, isPropertyFulfilled, userInputProperty);
|
|
62
|
+
return new GetUserInputNode(service, requiredProperties, isPropertyFulfilled, userInputProperty, nodeName);
|
|
63
63
|
}
|
|
64
64
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/nodes/getUserInput/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC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BAAqB,CAAC,kBAAkB,CAAC,EAClD,mBAAmB,GAAG,CAAC,KAAa,EAAE,YAAoB,EAA2B,EAAE;QACrF,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC1C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO;YACL,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,aAAa,YAAY,uCAAuC;SACzE,CAAC;IACJ,CAAC,EACD,iBAAiB,EACjB,QAAQ,GAAG,cAAc,GAC1B,GAAG,OAAO,CAAC;IAEZ,wDAAwD;IACxD,MAAM,OAAO,GACX,eAAe,IAAI,IAAI,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAEvE,OAAO,IAAI,gBAAgB,CACzB,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -56,13 +56,31 @@ export interface GetUserInputNodeOptions<TState extends StateType<StateDefinitio
|
|
|
56
56
|
*
|
|
57
57
|
*/
|
|
58
58
|
userInputProperty: keyof TState;
|
|
59
|
+
/**
|
|
60
|
+
* Custom name for the node (optional, defaults to 'getUserInput')
|
|
61
|
+
* Use this when you need multiple getUserInput nodes in the same graph
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
*
|
|
65
|
+
* // Create multiple input nodes with unique names
|
|
66
|
+
* const userInputNode = createGetUserInputNode({
|
|
67
|
+
* nodeName: 'getUserInput',
|
|
68
|
+
* ...
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* const androidSetupNode = createGetUserInputNode({
|
|
72
|
+
* nodeName: 'getAndroidSetup',
|
|
73
|
+
* ...
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
nodeName?: string;
|
|
59
77
|
}
|
|
60
78
|
export declare class GetUserInputNode<TState extends StateType<StateDefinition>> extends BaseNode<TState> {
|
|
61
79
|
private readonly getInputService;
|
|
62
80
|
private readonly requiredProperties;
|
|
63
81
|
private readonly isPropertyFulfilled;
|
|
64
82
|
private readonly userInputProperty;
|
|
65
|
-
constructor(getInputService: GetInputServiceProvider, requiredProperties: PropertyMetadataCollection, isPropertyFulfilled: IsPropertyFulfilled<TState>, userInputProperty: keyof TState);
|
|
83
|
+
constructor(getInputService: GetInputServiceProvider, requiredProperties: PropertyMetadataCollection, isPropertyFulfilled: IsPropertyFulfilled<TState>, userInputProperty: keyof TState, nodeName?: string);
|
|
66
84
|
execute: (state: TState) => Partial<TState>;
|
|
67
85
|
private getUnfulfilledProperties;
|
|
68
86
|
}
|
|
@@ -10,8 +10,8 @@ export class GetUserInputNode extends BaseNode {
|
|
|
10
10
|
requiredProperties;
|
|
11
11
|
isPropertyFulfilled;
|
|
12
12
|
userInputProperty;
|
|
13
|
-
constructor(getInputService, requiredProperties, isPropertyFulfilled, userInputProperty) {
|
|
14
|
-
super(
|
|
13
|
+
constructor(getInputService, requiredProperties, isPropertyFulfilled, userInputProperty, nodeName = 'getUserInput') {
|
|
14
|
+
super(nodeName);
|
|
15
15
|
this.getInputService = getInputService;
|
|
16
16
|
this.requiredProperties = requiredProperties;
|
|
17
17
|
this.isPropertyFulfilled = isPropertyFulfilled;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/nodes/getUserInput/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/nodes/getUserInput/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAqFlD,MAAM,OAAO,gBAA4D,SAAQ,QAAgB;IAE5E;IACA;IACA;IACA;IAJnB,Y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
|
/**
|
|
4
4
|
* Interface for tool execution mechanism.
|
|
5
5
|
* Abstracts the LangGraph interrupt mechanism to enable dependency injection and testing.
|
|
@@ -8,15 +8,16 @@ export interface ToolExecutor {
|
|
|
8
8
|
/**
|
|
9
9
|
* Executes a tool by invoking the underlying mechanism (e.g., LangGraph interrupt).
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param interruptData The interrupt data to pass to the execution mechanism.
|
|
12
|
+
* Can be either MCPToolInvocationData (delegate mode) or NodeGuidanceData (direct guidance mode).
|
|
12
13
|
* @returns The result from the tool execution (as unknown, to be validated by caller)
|
|
13
14
|
*/
|
|
14
|
-
execute(
|
|
15
|
+
execute(interruptData: InterruptData<z.ZodObject<z.ZodRawShape>, z.ZodObject<z.ZodRawShape>>): unknown;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Production implementation of ToolExecutor that uses LangGraph's interrupt mechanism.
|
|
18
19
|
* This is the default implementation used in production workflows.
|
|
19
20
|
*/
|
|
20
21
|
export declare class LangGraphToolExecutor implements ToolExecutor {
|
|
21
|
-
execute(
|
|
22
|
+
execute(interruptData: InterruptData<z.ZodObject<z.ZodRawShape>, z.ZodObject<z.ZodRawShape>>): unknown;
|
|
22
23
|
}
|
|
@@ -11,8 +11,8 @@ import { interrupt } from '@langchain/langgraph';
|
|
|
11
11
|
*/
|
|
12
12
|
/* c8 ignore start */
|
|
13
13
|
export class LangGraphToolExecutor {
|
|
14
|
-
execute(
|
|
15
|
-
return interrupt(
|
|
14
|
+
execute(interruptData) {
|
|
15
|
+
return interrupt(interruptData);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
/* c8 ignore stop */
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"toolExecutor.js","sourceRoot":"","sources":["../../src/nodes/toolExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAoBjD;;;GAGG;AACH,qBAAqB;AACrB,MAAM,OAAO,qBAAqB;IAChC,OAAO,CACL,aAAoF;QAEpF,OAAO,SAAS,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;CACF;AACD,oBAAoB"}
|
|
@@ -89,14 +89,14 @@ export class CheckPropertiesFulfilledRouter {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
if (unfulfilledProperties.length > 0) {
|
|
92
|
-
this.logger.debug(
|
|
92
|
+
this.logger.debug(`Properties not fulfilled, routing to ${this.propertiesUnfulfilledNodeName}`, {
|
|
93
93
|
unfulfilledProperties,
|
|
94
94
|
targetNode: this.propertiesUnfulfilledNodeName,
|
|
95
95
|
totalRequired: Object.keys(this.requiredProperties).length,
|
|
96
96
|
});
|
|
97
97
|
return this.propertiesUnfulfilledNodeName;
|
|
98
98
|
}
|
|
99
|
-
this.logger.debug(
|
|
99
|
+
this.logger.debug(`All properties fulfilled, routing to ${this.propertiesFulfilledNodeName}`, {
|
|
100
100
|
targetNode: this.propertiesFulfilledNodeName,
|
|
101
101
|
totalProperties: Object.keys(this.requiredProperties).length,
|
|
102
102
|
});
|
|
@@ -1 +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,
|
|
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,EAC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AAC,CAAC,MAAM;SAC7D,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
/**
|
|
@@ -29,9 +29,9 @@ import { ToolExecutor } from '../nodes/toolExecutor.js';
|
|
|
29
29
|
* }
|
|
30
30
|
*
|
|
31
31
|
* doSomething(input: string): ResultType {
|
|
32
|
-
* const
|
|
32
|
+
* const interruptData = { ... };
|
|
33
33
|
* return this.executeToolWithLogging(
|
|
34
|
-
*
|
|
34
|
+
* interruptData,
|
|
35
35
|
* MyToolResultSchema
|
|
36
36
|
* );
|
|
37
37
|
* }
|
|
@@ -59,7 +59,7 @@ export declare abstract class AbstractService {
|
|
|
59
59
|
* This method uses the common toolExecutionUtils.executeToolWithLogging function
|
|
60
60
|
* to ensure consistent behavior across all tool invocations in the codebase.
|
|
61
61
|
*
|
|
62
|
-
* @param
|
|
62
|
+
* @param interruptData - The interrupt data (MCPToolInvocationData or NodeGuidanceData)
|
|
63
63
|
* @param resultSchema - The schema to validate the result against
|
|
64
64
|
* @param validator - Optional custom validator function
|
|
65
65
|
* @returns The validated result from the tool execution
|
|
@@ -67,5 +67,5 @@ export declare abstract class AbstractService {
|
|
|
67
67
|
* @throws {z.ZodError} If the result does not match the schema (when using default validation)
|
|
68
68
|
* @throws {Error} If tool execution fails or custom validator throws
|
|
69
69
|
*/
|
|
70
|
-
protected executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(
|
|
70
|
+
protected executeToolWithLogging<TResultSchema extends z.ZodObject<z.ZodRawShape>>(interruptData: InterruptData<z.ZodObject<z.ZodRawShape>, TResultSchema>, resultSchema: TResultSchema, validator?: (result: unknown, schema: TResultSchema) => z.infer<TResultSchema>): z.infer<TResultSchema>;
|
|
71
71
|
}
|
|
@@ -34,9 +34,9 @@ import { executeToolWithLogging } from '../utils/toolExecutionUtils.js';
|
|
|
34
34
|
* }
|
|
35
35
|
*
|
|
36
36
|
* doSomething(input: string): ResultType {
|
|
37
|
-
* const
|
|
37
|
+
* const interruptData = { ... };
|
|
38
38
|
* return this.executeToolWithLogging(
|
|
39
|
-
*
|
|
39
|
+
* interruptData,
|
|
40
40
|
* MyToolResultSchema
|
|
41
41
|
* );
|
|
42
42
|
* }
|
|
@@ -68,7 +68,7 @@ export class AbstractService {
|
|
|
68
68
|
* This method uses the common toolExecutionUtils.executeToolWithLogging function
|
|
69
69
|
* to ensure consistent behavior across all tool invocations in the codebase.
|
|
70
70
|
*
|
|
71
|
-
* @param
|
|
71
|
+
* @param interruptData - The interrupt data (MCPToolInvocationData or NodeGuidanceData)
|
|
72
72
|
* @param resultSchema - The schema to validate the result against
|
|
73
73
|
* @param validator - Optional custom validator function
|
|
74
74
|
* @returns The validated result from the tool execution
|
|
@@ -76,8 +76,8 @@ export class AbstractService {
|
|
|
76
76
|
* @throws {z.ZodError} If the result does not match the schema (when using default validation)
|
|
77
77
|
* @throws {Error} If tool execution fails or custom validator throws
|
|
78
78
|
*/
|
|
79
|
-
executeToolWithLogging(
|
|
80
|
-
return executeToolWithLogging(this.toolExecutor, this.logger,
|
|
79
|
+
executeToolWithLogging(interruptData, resultSchema, validator) {
|
|
80
|
+
return executeToolWithLogging(this.toolExecutor, this.logger, interruptData, resultSchema, validator);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
//# sourceMappingURL=abstractService.js.map
|
|
@@ -1 +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,EAA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;;;;;;;;;;OAiBG;IACO,sBAAsB,CAC9B,aAAuE,EACvE,YAA2B,EAC3B,SAA8E;QAE9E,OAAO,sBAAsB,CAC3B,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,MAAM,EACX,aAAa,EACb,YAAY,EACZ,SAAS,CACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -27,8 +27,9 @@ export interface GetInputServiceProvider {
|
|
|
27
27
|
/**
|
|
28
28
|
* Service for getting user input for a given question.
|
|
29
29
|
*
|
|
30
|
-
* This service
|
|
31
|
-
*
|
|
30
|
+
* This service uses direct guidance mode (NodeGuidanceData) to have the orchestrator
|
|
31
|
+
* generate user input collection prompts directly, eliminating the need for an
|
|
32
|
+
* intermediate tool call.
|
|
32
33
|
*/
|
|
33
34
|
export declare class GetInputService extends AbstractService implements GetInputServiceProvider {
|
|
34
35
|
private readonly toolId;
|
|
@@ -40,4 +41,11 @@ export declare class GetInputService extends AbstractService implements GetInput
|
|
|
40
41
|
*/
|
|
41
42
|
constructor(toolId: string, toolExecutor?: ToolExecutor, logger?: Logger);
|
|
42
43
|
getInput(unfulfilledProperties: GetInputProperty[]): unknown;
|
|
44
|
+
/**
|
|
45
|
+
* Generates the task guidance for user input collection.
|
|
46
|
+
*
|
|
47
|
+
* @param properties - Array of properties requiring user input
|
|
48
|
+
* @returns The guidance prompt string
|
|
49
|
+
*/
|
|
50
|
+
private generateTaskGuidance;
|
|
43
51
|
}
|
|
@@ -5,12 +5,13 @@
|
|
|
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 { AbstractService } from './abstractService.js';
|
|
8
|
-
import {
|
|
8
|
+
import { GET_INPUT_WORKFLOW_RESULT_SCHEMA } from '../tools/utilities/index.js';
|
|
9
9
|
/**
|
|
10
10
|
* Service for getting user input for a given question.
|
|
11
11
|
*
|
|
12
|
-
* This service
|
|
13
|
-
*
|
|
12
|
+
* This service uses direct guidance mode (NodeGuidanceData) to have the orchestrator
|
|
13
|
+
* generate user input collection prompts directly, eliminating the need for an
|
|
14
|
+
* intermediate tool call.
|
|
14
15
|
*/
|
|
15
16
|
export class GetInputService extends AbstractService {
|
|
16
17
|
toolId;
|
|
@@ -28,21 +29,55 @@ export class GetInputService extends AbstractService {
|
|
|
28
29
|
this.logger.debug('Starting input request with properties', {
|
|
29
30
|
unfulfilledProperties,
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
// Build a concrete example based on the actual properties being requested
|
|
33
|
+
const exampleProperties = unfulfilledProperties.reduce((acc, prop) => {
|
|
34
|
+
acc[prop.propertyName] = `<user's ${prop.friendlyName} value>`;
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
37
|
+
// Create NodeGuidanceData for direct guidance mode
|
|
38
|
+
const nodeGuidanceData = {
|
|
39
|
+
nodeId: this.toolId,
|
|
40
|
+
taskGuidance: this.generateTaskGuidance(unfulfilledProperties),
|
|
41
|
+
resultSchema: GET_INPUT_WORKFLOW_RESULT_SCHEMA,
|
|
42
|
+
// Provide example to help LLM understand the expected userUtterance wrapper
|
|
43
|
+
exampleOutput: JSON.stringify({ userUtterance: exampleProperties }),
|
|
42
44
|
};
|
|
43
45
|
// Execute tool with logging and validation
|
|
44
|
-
const validatedResult = this.executeToolWithLogging(
|
|
46
|
+
const validatedResult = this.executeToolWithLogging(nodeGuidanceData, GET_INPUT_WORKFLOW_RESULT_SCHEMA);
|
|
45
47
|
return validatedResult.userUtterance;
|
|
46
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Generates the task guidance for user input collection.
|
|
51
|
+
*
|
|
52
|
+
* @param properties - Array of properties requiring user input
|
|
53
|
+
* @returns The guidance prompt string
|
|
54
|
+
*/
|
|
55
|
+
generateTaskGuidance(properties) {
|
|
56
|
+
const propertiesDescription = properties
|
|
57
|
+
.map(property => `- Property Name: ${property.propertyName}\n- Friendly Name: ${property.friendlyName}\n- Description: ${property.description}`)
|
|
58
|
+
.join('\n\n');
|
|
59
|
+
return `
|
|
60
|
+
# ROLE
|
|
61
|
+
You are an input gathering tool, responsible for explicitly requesting and gathering the
|
|
62
|
+
user's input for a set of unfulfilled properties.
|
|
63
|
+
|
|
64
|
+
# TASK
|
|
65
|
+
Your job is to provide a prompt to the user that outlines the details for a set of properties
|
|
66
|
+
that require the user's input. The prompt should be polite and conversational.
|
|
67
|
+
|
|
68
|
+
# CONTEXT
|
|
69
|
+
Here is the list of properties that require the user's input, along with their describing
|
|
70
|
+
metadata:
|
|
71
|
+
|
|
72
|
+
${propertiesDescription}
|
|
73
|
+
|
|
74
|
+
# INSTRUCTIONS
|
|
75
|
+
1. Based on the properties listed in "CONTEXT", generate a prompt that outlines the details
|
|
76
|
+
for each property.
|
|
77
|
+
2. Present the prompt to the user and instruct the user to provide their input.
|
|
78
|
+
3. **IMPORTANT:** YOU MUST NOW WAIT for the user to provide a follow-up response to your prompt.
|
|
79
|
+
1. You CANNOT PROCEED FROM THIS STEP until the user has provided THEIR OWN INPUT VALUE.
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
47
82
|
}
|
|
48
83
|
//# sourceMappingURL=getInputService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInputService.js","sourceRoot":"","sources":["../../src/services/getInputService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"getInputService.js","sourceRoot":"","sources":["../../src/services/getInputService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAgC/E;;;;;;GAMG;AACH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MAAM,CAAC,CAAC;QAEhB,OAAO;;;;;;;;;;;;;EAaT,qBAAqB;;;;;;;;CAQtB,CAAC;IACA,CAAC;CACF"}
|
|
@@ -26,8 +26,9 @@ export interface InputExtractionServiceProvider {
|
|
|
26
26
|
/**
|
|
27
27
|
* Service for extracting structured properties from user input.
|
|
28
28
|
*
|
|
29
|
-
* This service
|
|
30
|
-
*
|
|
29
|
+
* This service uses direct guidance mode (NodeGuidanceData) to have the orchestrator
|
|
30
|
+
* generate property extraction prompts directly, eliminating the need for an
|
|
31
|
+
* intermediate tool call.
|
|
31
32
|
*/
|
|
32
33
|
export declare class InputExtractionService extends AbstractService implements InputExtractionServiceProvider {
|
|
33
34
|
private readonly toolId;
|
|
@@ -43,4 +44,12 @@ export declare class InputExtractionService extends AbstractService implements I
|
|
|
43
44
|
private preparePropertiesForExtraction;
|
|
44
45
|
private preparePropertyResultsSchema;
|
|
45
46
|
private validateAndFilterResult;
|
|
47
|
+
/**
|
|
48
|
+
* Generates the task guidance for input extraction.
|
|
49
|
+
*
|
|
50
|
+
* @param userUtterance - The raw user input to analyze
|
|
51
|
+
* @param propertiesToExtract - Array of properties to extract
|
|
52
|
+
* @returns The guidance prompt string
|
|
53
|
+
*/
|
|
54
|
+
private generateTaskGuidance;
|
|
46
55
|
}
|