@http-forge/core 0.6.35 → 0.6.36-beta.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 +51 -0
- package/dist/__tests__/api-discovery/golden-utils.d.ts +10 -0
- package/dist/index.d.ts +49 -22
- package/dist/index.js +456 -480
- package/dist/index.mjs +456 -480
- package/dist/infrastructure/ai/ai-context.d.ts +109 -0
- package/dist/infrastructure/ai/ai-provider.d.ts +1 -1
- package/dist/infrastructure/ai/ai-utils.d.ts +38 -0
- package/dist/infrastructure/ai/http-providers.d.ts +34 -0
- package/dist/infrastructure/api-discovery/analyzer/component-analyzer.d.ts +60 -0
- package/dist/infrastructure/api-discovery/analyzer/express-component-analyzer.d.ts +14 -0
- package/dist/infrastructure/api-discovery/analyzer/fastify-component-analyzer.d.ts +14 -0
- package/dist/infrastructure/api-discovery/analyzer/index.d.ts +11 -0
- package/dist/infrastructure/api-discovery/analyzer/lambda-component-analyzer.d.ts +18 -0
- package/dist/infrastructure/api-discovery/api-discovery-service.d.ts +49 -0
- package/dist/infrastructure/api-discovery/auth-validation.d.ts +34 -0
- package/dist/infrastructure/api-discovery/drift-engine.d.ts +139 -0
- package/dist/infrastructure/api-discovery/fastapi/fastapi-discovery-provider.d.ts +19 -0
- package/dist/infrastructure/api-discovery/fastapi/fastapi-parser.d.ts +60 -0
- package/dist/infrastructure/api-discovery/framework-detector.d.ts +8 -0
- package/dist/infrastructure/api-discovery/index.d.ts +29 -0
- package/dist/infrastructure/api-discovery/path-utils.d.ts +17 -0
- package/dist/infrastructure/api-discovery/project-name.d.ts +2 -0
- package/dist/infrastructure/api-discovery/provider.d.ts +29 -0
- package/dist/infrastructure/api-discovery/providers/express-discovery-provider.d.ts +13 -0
- package/dist/infrastructure/api-discovery/providers/fastify-discovery-provider.d.ts +13 -0
- package/dist/infrastructure/api-discovery/providers/lambda-discovery-provider.d.ts +19 -0
- package/dist/infrastructure/api-discovery/providers/nest-discovery-provider.d.ts +12 -0
- package/dist/infrastructure/api-discovery/seed-loader.d.ts +11 -0
- package/dist/infrastructure/api-discovery/source-files.d.ts +1 -0
- package/dist/infrastructure/api-discovery/spring/controller-visitor.d.ts +141 -0
- package/dist/infrastructure/api-discovery/spring/endpoint-parser.d.ts +51 -0
- package/dist/infrastructure/api-discovery/spring/file-utils.d.ts +28 -0
- package/dist/infrastructure/api-discovery/spring/model.d.ts +84 -0
- package/dist/infrastructure/api-discovery/spring/schema-generator.d.ts +65 -0
- package/dist/infrastructure/api-discovery/spring/spring-discovery-provider.d.ts +30 -0
- package/dist/infrastructure/api-discovery/spring/spring-types.d.ts +27 -0
- package/dist/infrastructure/api-discovery/test-generator.d.ts +69 -0
- package/dist/infrastructure/api-discovery/types.d.ts +154 -0
- package/dist/infrastructure/api-discovery/workflow-discovery.d.ts +55 -0
- package/dist/infrastructure/architect/api-architect-service.d.ts +85 -0
- package/dist/infrastructure/architect/architect-prompt.d.ts +22 -0
- package/dist/infrastructure/architect/collection-to-endpoints.d.ts +13 -0
- package/dist/infrastructure/architect/index.d.ts +10 -0
- package/dist/infrastructure/collection/collection-service.d.ts +1 -5
- package/dist/infrastructure/collection/json-collection-loader.d.ts +0 -8
- package/dist/infrastructure/cookie/cookie-service.d.ts +2 -13
- package/dist/infrastructure/cookie/cookie-utils.d.ts +5 -0
- package/dist/infrastructure/docs/index.d.ts +5 -0
- package/dist/infrastructure/docs/release-notes.d.ts +51 -0
- package/dist/infrastructure/environment/environment-config-service.d.ts +0 -1
- package/dist/infrastructure/environment/variable-interpolator.d.ts +9 -0
- package/dist/infrastructure/http/header-utils.d.ts +13 -0
- package/dist/infrastructure/http/http-request-service.d.ts +3 -3
- package/dist/infrastructure/http/interceptor-chain.d.ts +35 -16
- package/dist/infrastructure/http/native-http-client.d.ts +0 -10
- package/dist/infrastructure/openapi/interfaces.d.ts +14 -0
- package/dist/infrastructure/openapi/openapi-exporter.d.ts +11 -91
- package/dist/infrastructure/openapi/openapi-importer.d.ts +19 -0
- package/dist/infrastructure/openapi/openapi-operation-builder.d.ts +36 -0
- package/dist/infrastructure/openapi/openapi-schema-merger.d.ts +33 -0
- package/dist/infrastructure/openapi/openapi-spec-writer.d.ts +27 -0
- package/dist/infrastructure/openapi/openapi-utils.d.ts +62 -0
- package/dist/infrastructure/parsers/har-parser.d.ts +63 -0
- package/dist/infrastructure/parsers/index.d.ts +2 -0
- package/dist/infrastructure/review/index.d.ts +5 -0
- package/dist/infrastructure/review/review-engine.d.ts +95 -0
- package/dist/infrastructure/script/crypto-js-compat.d.ts +123 -0
- package/dist/infrastructure/script/request-object-factory.d.ts +54 -0
- package/dist/infrastructure/script/request-script-session.d.ts +0 -5
- package/dist/infrastructure/script/script-executor.d.ts +4 -33
- package/dist/infrastructure/script/script-factories.d.ts +13 -0
- package/dist/infrastructure/script/variable-scopes.d.ts +101 -0
- package/dist/infrastructure/test-suite/interfaces.d.ts +6 -0
- package/dist/runtime/collection-traversal.d.ts +32 -0
- package/dist/runtime/direct-execution.d.ts +7 -0
- package/dist/runtime/execution-helpers.d.ts +30 -0
- package/dist/runtime/mcp-dispatcher.d.ts +10 -34
- package/dist/runtime/mcp-handlers/ai.d.ts +6 -0
- package/dist/runtime/mcp-handlers/collection.d.ts +5 -0
- package/dist/runtime/mcp-handlers/discovery.d.ts +12 -0
- package/dist/runtime/mcp-handlers/environment-management.d.ts +6 -0
- package/dist/runtime/mcp-handlers/environment.d.ts +5 -0
- package/dist/runtime/mcp-handlers/execution.d.ts +6 -0
- package/dist/runtime/mcp-handlers/helpers.d.ts +43 -0
- package/dist/runtime/mcp-handlers/inspection.d.ts +5 -0
- package/dist/runtime/mcp-handlers/registry.d.ts +12 -0
- package/dist/runtime/mcp-handlers/request.d.ts +5 -0
- package/dist/runtime/mcp-handlers/review.d.ts +10 -0
- package/dist/runtime/mcp-handlers/run-status.d.ts +5 -0
- package/dist/runtime/mcp-handlers/suite.d.ts +6 -0
- package/dist/runtime/mcp-handlers/types.d.ts +59 -0
- package/dist/runtime/mcp-prompts.d.ts +16 -2
- package/dist/runtime/mcp-tool-schemas.d.ts +8 -0
- package/dist/runtime/suite-executor.d.ts +20 -0
- package/dist/types/types.d.ts +0 -9
- package/dist/utils/env-hints.d.ts +17 -0
- package/package.json +16 -6
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This is the main entry point for script execution.
|
|
9
9
|
* It configures the VM sandbox and delegates session management to RequestScriptSession.
|
|
10
|
+
*
|
|
11
|
+
* CryptoJS compatibility lives in ./crypto-js-compat
|
|
12
|
+
* Variable scopes live in ./variable-scopes
|
|
10
13
|
*/
|
|
11
14
|
import { IHttpRequestService } from '../http/interfaces';
|
|
12
15
|
import { SecretResolverRegistry } from '../secrets/secret-resolver-registry';
|
|
@@ -25,6 +28,7 @@ export declare class ScriptExecutor implements IScriptExecutor {
|
|
|
25
28
|
private readonly scopeMode;
|
|
26
29
|
private readonly scriptTimeoutMs;
|
|
27
30
|
private readonly moduleLoader;
|
|
31
|
+
private readonly variableScopes;
|
|
28
32
|
constructor(httpService?: IHttpRequestService | undefined, modulePaths?: string[], secretRegistry?: SecretResolverRegistry | undefined, scopeMode?: 'shared' | 'isolated', scriptTimeoutMs?: number);
|
|
29
33
|
/**
|
|
30
34
|
* Create a request execution session
|
|
@@ -45,39 +49,6 @@ export declare class ScriptExecutor implements IScriptExecutor {
|
|
|
45
49
|
* Used by RequestScriptSession for pre-request and test scripts
|
|
46
50
|
*/
|
|
47
51
|
private createCommonContext;
|
|
48
|
-
/** Prefix marking a JSON-serialized non-string value */
|
|
49
|
-
private static readonly JSON_TYPE_MARKER;
|
|
50
|
-
/**
|
|
51
|
-
* Serialize a value for storage. Non-string values are JSON-stringified with a type marker.
|
|
52
|
-
* `undefined` is stored explicitly (JSON.stringify(undefined) yields JS undefined, which would
|
|
53
|
-
* corrupt the marker into the literal "undefined"). It round-trips back to undefined and renders
|
|
54
|
-
* empty, matching Postman (a variable set to undefined resolves to an empty string).
|
|
55
|
-
*/
|
|
56
|
-
private serializeValue;
|
|
57
|
-
/**
|
|
58
|
-
* Deserialize a stored value. Values with the type marker are JSON-parsed back to native types.
|
|
59
|
-
* Values without the marker (plain strings) are returned as-is.
|
|
60
|
-
*/
|
|
61
|
-
private deserializeValue;
|
|
62
|
-
/**
|
|
63
|
-
* Create a basic variable scope with get/set/has/unset/clear/toObject
|
|
64
|
-
*/
|
|
65
|
-
private createVariableScope;
|
|
66
|
-
/**
|
|
67
|
-
* Create the globals scope with change callbacks.
|
|
68
|
-
* Globals are a special, environment-agnostic variable layer, so they are
|
|
69
|
-
* persisted live through the same push-callback mechanism as environment
|
|
70
|
-
* variables (see createEnvironmentScope) rather than a post-hoc diff.
|
|
71
|
-
*/
|
|
72
|
-
private createGlobalsScope;
|
|
73
|
-
/**
|
|
74
|
-
* Create merged variable scope (Postman-style cascading lookup)
|
|
75
|
-
*/
|
|
76
|
-
private createMergedVariableScope;
|
|
77
|
-
/**
|
|
78
|
-
* Create environment variable scope with change callbacks
|
|
79
|
-
*/
|
|
80
|
-
private createEnvironmentScope;
|
|
81
52
|
/**
|
|
82
53
|
* Create the Postman-compatible pm.vault namespace.
|
|
83
54
|
* Reads are backed by HTTP Forge's secret provider system using the same
|
|
@@ -99,6 +99,19 @@ export interface CookieList extends Array<PostmanCookie> {
|
|
|
99
99
|
count(): number;
|
|
100
100
|
idx(index: number): PostmanCookie | undefined;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a Postman-compatible Url object that wraps a plain URL string.
|
|
104
|
+
*
|
|
105
|
+
* Behaves like a string (via toString/valueOf/Symbol.toPrimitive) so that:
|
|
106
|
+
* - `pm.request.url + '/path'` works
|
|
107
|
+
* - `pm.request.url.toString()` works
|
|
108
|
+
* - Template literals `${pm.request.url}` work
|
|
109
|
+
*
|
|
110
|
+
* Also exposes Postman SDK Url methods:
|
|
111
|
+
* - getHost(), getPath(), getPathWithQuery(), getQueryString()
|
|
112
|
+
* - query (URLSearchParams-like with toObject())
|
|
113
|
+
*/
|
|
114
|
+
export declare function createPostmanUrl(rawUrl: string): any;
|
|
102
115
|
export declare function createCookieList(cookies: Cookie[]): CookieList;
|
|
103
116
|
/**
|
|
104
117
|
* Create response object with helper methods for script context.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable Scopes
|
|
3
|
+
*
|
|
4
|
+
* Single Responsibility: Build the Postman-compatible variable scope objects
|
|
5
|
+
* used inside the script sandbox (variables, globals, environment, collection,
|
|
6
|
+
* merged cascade) with typed serialization and {{...}} replaceIn resolution.
|
|
7
|
+
*/
|
|
8
|
+
import { CommonScriptContext } from './interfaces';
|
|
9
|
+
/**
|
|
10
|
+
* Factory for Postman-compatible variable scopes.
|
|
11
|
+
*
|
|
12
|
+
* Stateless aside from serialization helpers; instances are created once per
|
|
13
|
+
* ScriptExecutor and shared across request sessions.
|
|
14
|
+
*/
|
|
15
|
+
export declare class VariableScopeFactory {
|
|
16
|
+
/**
|
|
17
|
+
* Serialize a value for storage. Non-string values are JSON-stringified with a type marker.
|
|
18
|
+
* `undefined` is stored explicitly (JSON.stringify(undefined) yields JS undefined, which would
|
|
19
|
+
* corrupt the marker into the literal "undefined"). It round-trips back to undefined and renders
|
|
20
|
+
* empty, matching Postman (a variable set to undefined resolves to an empty string).
|
|
21
|
+
*/
|
|
22
|
+
serializeValue(value: any): string;
|
|
23
|
+
/**
|
|
24
|
+
* Deserialize a stored value. Values with the type marker are JSON-parsed back to native types.
|
|
25
|
+
* Values without the marker (plain strings) are returned as-is.
|
|
26
|
+
*/
|
|
27
|
+
deserializeValue(value: string | undefined): any;
|
|
28
|
+
/**
|
|
29
|
+
* Create a basic variable scope with get/set/has/unset/clear/toObject
|
|
30
|
+
*/
|
|
31
|
+
createVariableScope(store: Record<string, string>): {
|
|
32
|
+
get: (key: string) => any;
|
|
33
|
+
set: (key: string, value: any) => void;
|
|
34
|
+
has(key: string): boolean;
|
|
35
|
+
unset(key: string): void;
|
|
36
|
+
clear(): void;
|
|
37
|
+
toObject(): {
|
|
38
|
+
[x: string]: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Create the globals scope with change callbacks.
|
|
43
|
+
* Globals are a special, environment-agnostic variable layer, so they are
|
|
44
|
+
* persisted live through the same push-callback mechanism as environment
|
|
45
|
+
* variables (see createEnvironmentScope) rather than a post-hoc diff.
|
|
46
|
+
*/
|
|
47
|
+
createGlobalsScope(store: Record<string, string>, onChange: CommonScriptContext['onGlobalsChange']): {
|
|
48
|
+
get: (key: string) => any;
|
|
49
|
+
set: (key: string, value: any) => void;
|
|
50
|
+
has(key: string): boolean;
|
|
51
|
+
unset(key: string): void;
|
|
52
|
+
clear(): void;
|
|
53
|
+
toObject(): {
|
|
54
|
+
[x: string]: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Create merged variable scope (Postman-style cascading lookup)
|
|
59
|
+
*/
|
|
60
|
+
createMergedVariableScope(variables: Record<string, string>, environmentVariables: Record<string, string>, collectionVariables: Record<string, string>, globals: Record<string, string>, iterationData?: Record<string, any>): {
|
|
61
|
+
get: (key: string) => any;
|
|
62
|
+
set: (key: string, value: any) => void;
|
|
63
|
+
has(key: string): boolean;
|
|
64
|
+
unset(key: string): void;
|
|
65
|
+
clear(): void;
|
|
66
|
+
toObject(): {
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
};
|
|
69
|
+
toLocalObject(): {
|
|
70
|
+
[x: string]: any;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Postman-compatible replaceIn method
|
|
74
|
+
* 5-step resolution pipeline:
|
|
75
|
+
* 1. $dynamic variables
|
|
76
|
+
* 2. Filter chains
|
|
77
|
+
* 3. Simple variable lookup
|
|
78
|
+
* 4. JavaScript expressions
|
|
79
|
+
* 5. Return original {{...}} if nothing matched
|
|
80
|
+
*
|
|
81
|
+
* Nested references (a variable whose value itself contains {{...}})
|
|
82
|
+
* are resolved recursively by repeating the pass until the string
|
|
83
|
+
* stabilizes or the depth cap is hit (guards against reference cycles).
|
|
84
|
+
*/
|
|
85
|
+
replaceIn(str: string): string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Create environment variable scope with change callbacks
|
|
89
|
+
*/
|
|
90
|
+
createEnvironmentScope(environmentVariables: Record<string, string>, environmentName: string | undefined, onChange: CommonScriptContext['onEnvironmentChange'], isNewSignature: boolean): {
|
|
91
|
+
name: string;
|
|
92
|
+
get: (key: string) => any;
|
|
93
|
+
set: (key: string, value: any) => void;
|
|
94
|
+
has(key: string): boolean;
|
|
95
|
+
unset(key: string): void;
|
|
96
|
+
clear(): void;
|
|
97
|
+
toObject(): {
|
|
98
|
+
[x: string]: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -42,6 +42,8 @@ export interface SuiteFlowNodeBase {
|
|
|
42
42
|
export interface SuiteRequestNode extends SuiteFlowNodeBase {
|
|
43
43
|
type: 'request';
|
|
44
44
|
request: SuiteRequest;
|
|
45
|
+
/** Inline post-response script executed after the request completes. */
|
|
46
|
+
postResponseScript?: string[];
|
|
45
47
|
}
|
|
46
48
|
export interface SuiteBlockNode extends SuiteFlowNodeBase {
|
|
47
49
|
type: 'block';
|
|
@@ -154,6 +156,10 @@ export interface TestSuite {
|
|
|
154
156
|
config: SuiteConfig;
|
|
155
157
|
/** Whether this is a temporary suite (not saved) */
|
|
156
158
|
isTemporary?: boolean;
|
|
159
|
+
/** Phase 2a/2b drift hook: true when generated from discovery, not hand-written */
|
|
160
|
+
ai_generated?: boolean;
|
|
161
|
+
/** Phase 2a/2b drift hook: endpoint ids this suite was derived from */
|
|
162
|
+
derived_from?: string[];
|
|
157
163
|
/** Creation timestamp */
|
|
158
164
|
createdAt: number;
|
|
159
165
|
/** Last update timestamp */
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure collection traversal helpers for direct execution.
|
|
3
|
+
*
|
|
4
|
+
* Walking a collection tree to find/flatten requests and resolving folder
|
|
5
|
+
* paths into id-safe slugs. No side effects, no service dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import type { Collection, CollectionItem, CollectionRequestItem } from '../types/collection';
|
|
8
|
+
import type { RequestAuth, RequestScripts } from '../types/types';
|
|
9
|
+
export declare function findRequestInCollection(collection: Collection, requestId: string, items?: CollectionItem[], folderChain?: RequestScripts[], authChain?: RequestAuth[], folderNameChain?: string[]): {
|
|
10
|
+
request: CollectionRequestItem;
|
|
11
|
+
folderScriptsChain: RequestScripts[];
|
|
12
|
+
folderAuthChain: RequestAuth[];
|
|
13
|
+
folderPath: string;
|
|
14
|
+
} | undefined;
|
|
15
|
+
export declare function flattenCollection(collection: Collection, items?: CollectionItem[], folderChain?: RequestScripts[], folderNameChain?: string[]): Array<{
|
|
16
|
+
request: CollectionRequestItem;
|
|
17
|
+
folderScriptsChain: RequestScripts[];
|
|
18
|
+
folderPath: string;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Filter flattened collection requests to those under a folder path.
|
|
22
|
+
*
|
|
23
|
+
* @param flat - flattened requests with slash-separated `folderPath`
|
|
24
|
+
* @param folderPath - target folder path (folder names joined by '/'); when
|
|
25
|
+
* omitted or empty, the input is returned unchanged
|
|
26
|
+
* @param recursive - include requests in nested subfolders (default: true)
|
|
27
|
+
*/
|
|
28
|
+
export declare function filterByFolderPath<T extends {
|
|
29
|
+
folderPath: string;
|
|
30
|
+
}>(flat: T[], folderPath?: string, recursive?: boolean): T[];
|
|
31
|
+
/** Convert a folder path into a filesystem/id-safe slug. */
|
|
32
|
+
export declare function slugifyFolderPath(folderPath: string): string;
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* Execute requests, collections, and suites without requiring MCP server.
|
|
5
5
|
* Uses shared execution logic from core executors.
|
|
6
6
|
*
|
|
7
|
+
* This module is intentionally thin: it holds only the public entry points
|
|
8
|
+
* (`runRequest` / `runCollection` / `runFolder` / `runSuite`) plus the
|
|
9
|
+
* collection/folder resolution glue. The heavy lifting lives in:
|
|
10
|
+
* - `suite-executor.ts` — the suite node-graph flow engine
|
|
11
|
+
* - `execution-helpers.ts` — request conversion, overrides, auth, redaction
|
|
12
|
+
* - `collection-traversal.ts` — collection tree walking
|
|
13
|
+
*
|
|
7
14
|
* Used by:
|
|
8
15
|
* - CLI commands (run-request, run-collection, run-suite)
|
|
9
16
|
* - Third-party Node apps that want to execute HTTP Forge collections programmatically
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for direct execution.
|
|
3
|
+
*
|
|
4
|
+
* Small, cohesive utilities used by both the public entry points
|
|
5
|
+
* (`direct-execution.ts`) and the suite flow engine (`suite-executor.ts`):
|
|
6
|
+
* env-flag parsing, request conversion, override application, auth
|
|
7
|
+
* inheritance, redaction wrappers, and container disposal.
|
|
8
|
+
*/
|
|
9
|
+
import type { ServiceContainer } from '../di/service-container';
|
|
10
|
+
import type { CollectionRequest } from '../types/collection';
|
|
11
|
+
import type { ExecutionRequest, RequestAuth } from '../types/types';
|
|
12
|
+
export declare function disposeContainerResources(container: ServiceContainer): void;
|
|
13
|
+
export declare function isEnabled(value: string | undefined): boolean;
|
|
14
|
+
export declare function shouldEnforceMaxRequests(): boolean;
|
|
15
|
+
export declare function getDirectMaxRequestsLimit(): number;
|
|
16
|
+
export declare function shouldGenerateReports(include: string[], reporters?: string[]): boolean;
|
|
17
|
+
export declare function tryParseJson(val: unknown): unknown;
|
|
18
|
+
export declare function getRedactedResponseHeaders(headers: Record<string, string | string[]> | undefined): Record<string, string | string[]>;
|
|
19
|
+
export declare function getRedactedCookies(cookies: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}> | undefined): Array<{
|
|
23
|
+
name?: string;
|
|
24
|
+
value?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function sanitizeIdPart(value: string): string;
|
|
27
|
+
export declare function toExecutionRequest(req: CollectionRequest): ExecutionRequest;
|
|
28
|
+
export declare function applyOverrides(base: ExecutionRequest, args: Record<string, unknown>): ExecutionRequest;
|
|
29
|
+
export declare function toStringRecord(input?: Record<string, unknown>): Record<string, string>;
|
|
30
|
+
export declare function resolveInheritedAuth(requestAuth: RequestAuth | undefined, folderAuthChain: RequestAuth[], collectionAuth: RequestAuth | undefined): RequestAuth | undefined;
|
|
@@ -1,47 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP Generic Tool Dispatcher
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Entry point for all argument-based ("generic") tool handlers, shared
|
|
5
|
+
* between the embedded core runtime and the VS Code extension's McpExecutor.
|
|
6
|
+
*
|
|
7
|
+
* The actual implementation of each tool lives in `mcp-handlers/*`, one
|
|
8
|
+
* handler per tool (or per related group), assembled in a registry. This
|
|
9
|
+
* module is deliberately thin: it resolves the collection snapshot once,
|
|
10
|
+
* looks up the handler, and delegates.
|
|
7
11
|
*
|
|
8
12
|
* The four run-* tools (run_request, run_folder, run_collection, run_suite)
|
|
9
13
|
* use different execution back-ends in each server and are therefore delegated
|
|
10
14
|
* to `McpRunCallbacks` supplied by the caller rather than implemented here.
|
|
11
|
-
*
|
|
12
|
-
* All other generic tools (inspection, environment, async-run polling) are
|
|
13
|
-
* handled fully inside this module.
|
|
14
15
|
*/
|
|
15
|
-
import
|
|
16
|
-
import type { Collection, ICollectionService } from '../types/collection';
|
|
17
|
-
import type { IEnvironmentConfigService } from '../types/environment-config';
|
|
16
|
+
import { McpDispatchServices, McpRunCallbacks } from './mcp-handlers/types';
|
|
18
17
|
import type { McpRunStore } from './mcp-run-store';
|
|
19
18
|
import { type GenericToolName } from './mcp-tool-schemas';
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
testSuite: ITestSuiteService;
|
|
23
|
-
environmentConfig: IEnvironmentConfigService;
|
|
24
|
-
/** Absolute path to the workspace folder — used by AI-native tools. */
|
|
25
|
-
workspaceFolder?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Callbacks for the four execution tools that differ between server
|
|
29
|
-
* implementations. The extension uses CollectionRequestExecutor + executeSuite;
|
|
30
|
-
* the core runtime uses the direct-execution functions.
|
|
31
|
-
*/
|
|
32
|
-
export interface McpRunCallbacks {
|
|
33
|
-
runRequest: (col: Collection, requestId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
34
|
-
runFolder: (col: Collection, folderPath: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
35
|
-
runCollection: (col: Collection, args: Record<string, unknown>) => Promise<unknown>;
|
|
36
|
-
runSuite: (suiteId: string, suiteName: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Post-process a run result before returning it to the AI:
|
|
40
|
-
* - truncates `result.body` (run_request)
|
|
41
|
-
* - truncates `result.failedRequests[N].body` (run_collection / run_folder / run_suite / get_run_summary)
|
|
42
|
-
* No-op when `include` contains `'fullBody'` or when the result has no body fields.
|
|
43
|
-
*/
|
|
44
|
-
export declare function applyMcpBodyTruncation(result: unknown, include: string[]): unknown;
|
|
19
|
+
export type { McpDispatchServices, McpRunCallbacks } from './mcp-handlers/types';
|
|
20
|
+
export { applyMcpBodyTruncation, MCP_MAX_BODY_CHARS } from './mcp-handlers/helpers';
|
|
45
21
|
/** Tools that write to disk and should bust the MCP tool-list cache after execution. */
|
|
46
22
|
export declare const CACHE_BUSTING_TOOLS: Set<string>;
|
|
47
23
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API discovery tool handlers.
|
|
3
|
+
*
|
|
4
|
+
* Bridges source-code discovery (Phase 1) into the MCP runtime: a discovered
|
|
5
|
+
* endpoint becomes a working HTTP Forge request with NO OpenAPI involved and a
|
|
6
|
+
* provenance label pointing at the source location it was derived from.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpToolHandler } from './types';
|
|
9
|
+
import type { JsonSchema } from '../../infrastructure/api-discovery';
|
|
10
|
+
export declare const discoveryHandlers: McpToolHandler[];
|
|
11
|
+
/** Build a minimal JSON example from a JSON Schema (recursive). */
|
|
12
|
+
export declare function schemaToExample(schema: JsonSchema | undefined): unknown;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution tool handlers — delegate run_request / run_folder / run_collection
|
|
3
|
+
* / run_suite to the caller-supplied callbacks, then apply MCP-layer truncation.
|
|
4
|
+
*/
|
|
5
|
+
import type { McpToolHandler } from './types';
|
|
6
|
+
export declare const executionHandlers: McpToolHandler[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for MCP generic tool handlers.
|
|
3
|
+
*
|
|
4
|
+
* These were lifted out of the original monolithic dispatcher so that every
|
|
5
|
+
* tool handler can reuse them without duplicating logic.
|
|
6
|
+
*/
|
|
7
|
+
import type { Collection, CollectionFolderItem, CollectionItem, CollectionRequestItem } from '../../types/collection';
|
|
8
|
+
import type { McpDispatchServices } from './types';
|
|
9
|
+
export { decodeFolderPath, enumerateFolders, flattenRequests, normalizeFolderInput } from '../mcp-collection-utils';
|
|
10
|
+
/** Build a "Bad request" error used across all tool handlers. */
|
|
11
|
+
export declare function badRequest(msg: string): Error;
|
|
12
|
+
/** Resolve a collection by id, exact name, case-insensitive name, or substring. */
|
|
13
|
+
export declare function resolveCollectionByLabel(label: unknown, collections: Collection[]): Collection;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a request inside a collection by id, exact name, or case-insensitive
|
|
16
|
+
* name/substring.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveRequestByLabel(label: unknown, col: Collection): CollectionRequestItem;
|
|
19
|
+
/**
|
|
20
|
+
* Find a folder item in a collection tree by its ID.
|
|
21
|
+
*
|
|
22
|
+
* Uses the folder ID (from enumerateFolders) rather than splitting the
|
|
23
|
+
* slash-separated path string — this correctly handles folder names that
|
|
24
|
+
* contain '/' characters, which would otherwise be indistinguishable from
|
|
25
|
+
* path separators.
|
|
26
|
+
*/
|
|
27
|
+
export declare function findFolderById(items: CollectionItem[], folderId: string): CollectionFolderItem | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a test suite by id or by exact / case-insensitive name.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveSuiteByLabel(label: unknown, services: McpDispatchServices): Promise<import('../../infrastructure/test-suite/interfaces').TestSuite>;
|
|
32
|
+
/**
|
|
33
|
+
* Flatten a collection tree into request items, re-exported from the
|
|
34
|
+
* collection utils so handlers can rely on one import site.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MCP_MAX_BODY_CHARS = 4096;
|
|
37
|
+
/**
|
|
38
|
+
* Post-process a run result before returning it to the AI:
|
|
39
|
+
* - truncates `result.body` (run_request)
|
|
40
|
+
* - truncates `result.failedRequests[N].body` (run_collection / run_folder / run_suite / get_run_summary)
|
|
41
|
+
* No-op when `include` contains `'fullBody'` or when the result has no body fields.
|
|
42
|
+
*/
|
|
43
|
+
export declare function applyMcpBodyTruncation(result: unknown, include: string[]): unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP generic tool registry.
|
|
3
|
+
*
|
|
4
|
+
* Assembles every tool handler into a name→handler map. This is the
|
|
5
|
+
* Open/Closed extension point: adding a new tool means registering a new
|
|
6
|
+
* handler here — never editing the dispatcher or existing handlers.
|
|
7
|
+
*/
|
|
8
|
+
import { GenericToolName } from '../mcp-tool-schemas';
|
|
9
|
+
import { McpToolHandler } from './types';
|
|
10
|
+
export declare const GENERIC_TOOL_REGISTRY: ReadonlyMap<GenericToolName, McpToolHandler>;
|
|
11
|
+
/** Every tool name this registry knows how to dispatch. */
|
|
12
|
+
export declare const REGISTERED_TOOL_NAMES: ReadonlySet<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Review tool handlers (Phase 3, Layer 7).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic-first: the rule engine runs over the suite + run-results and
|
|
5
|
+
* produces a structured ReviewReport. An optional AI provider then enriches
|
|
6
|
+
* the findings with prioritized prose — the rules NEVER depend on the LLM
|
|
7
|
+
* (that would make the gate non-deterministic and CI-unusable).
|
|
8
|
+
*/
|
|
9
|
+
import type { McpToolHandler } from './types';
|
|
10
|
+
export declare const reviewHandlers: McpToolHandler[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Generic Tool Handler Contracts
|
|
3
|
+
*
|
|
4
|
+
* Each generic ("argument-selected") MCP tool is implemented by one
|
|
5
|
+
* `McpToolHandler`. A registry maps tool names to handlers, so adding a
|
|
6
|
+
* new tool means adding a handler — never editing a shared dispatcher.
|
|
7
|
+
*/
|
|
8
|
+
import type { Collection } from '../../types/collection';
|
|
9
|
+
import type { McpRunStore } from '../mcp-run-store';
|
|
10
|
+
import type { GenericToolName } from '../mcp-tool-schemas';
|
|
11
|
+
/** Services injected into every tool handler. */
|
|
12
|
+
export interface McpDispatchServices {
|
|
13
|
+
collection: import('../../types/collection').ICollectionService;
|
|
14
|
+
testSuite: import('../../infrastructure/test-suite/interfaces').ITestSuiteService;
|
|
15
|
+
environmentConfig: import('../../types/environment-config').IEnvironmentConfigService;
|
|
16
|
+
/** Absolute path to the workspace folder — used by AI-native tools. */
|
|
17
|
+
workspaceFolder?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional AI provider. When supplied, AI-flavoured tools (e.g. assertion
|
|
20
|
+
* suggestion, failure explanation) call a real LLM and fall back to their
|
|
21
|
+
* built-in heuristics when absent or on provider errors.
|
|
22
|
+
*/
|
|
23
|
+
aiProvider?: import('../../infrastructure/ai/ai-provider').IAiProvider;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Callbacks for the four execution tools that differ between server
|
|
27
|
+
* implementations. The extension uses CollectionRequestExecutor + executeSuite;
|
|
28
|
+
* the core runtime uses the direct-execution functions.
|
|
29
|
+
*/
|
|
30
|
+
export interface McpRunCallbacks {
|
|
31
|
+
runRequest: (col: Collection, requestId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
32
|
+
runFolder: (col: Collection, folderPath: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
33
|
+
runCollection: (col: Collection, args: Record<string, unknown>) => Promise<unknown>;
|
|
34
|
+
runSuite: (suiteId: string, suiteName: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
35
|
+
}
|
|
36
|
+
/** Everything a tool handler needs to do its job. */
|
|
37
|
+
export interface McpToolContext {
|
|
38
|
+
/** The tool name constant from GENERIC_TOOL_NAMES. */
|
|
39
|
+
tool: GenericToolName;
|
|
40
|
+
/** Raw arguments object from the MCP tools/call payload. */
|
|
41
|
+
args: Record<string, unknown>;
|
|
42
|
+
/** Live service instances from either server's DI container. */
|
|
43
|
+
services: McpDispatchServices;
|
|
44
|
+
/** The caller's McpRunStore instance (each server owns one). */
|
|
45
|
+
runStore: McpRunStore;
|
|
46
|
+
/** Implementation-specific run-* execution callbacks. */
|
|
47
|
+
callbacks: McpRunCallbacks;
|
|
48
|
+
/** Snapshot of all collections (resolved once per dispatch). */
|
|
49
|
+
collections: Collection[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A single tool handler. `toolNames` is the set of tool names this handler
|
|
53
|
+
* implements (a handler may implement more than one, e.g. analyze_coverage
|
|
54
|
+
* and ai_analyze_coverage share behaviour).
|
|
55
|
+
*/
|
|
56
|
+
export interface McpToolHandler {
|
|
57
|
+
readonly toolNames: GenericToolName[];
|
|
58
|
+
handle(ctx: McpToolContext): Promise<unknown> | unknown;
|
|
59
|
+
}
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* review-collection — structural review of a collection
|
|
13
13
|
*/
|
|
14
14
|
import type { ICollectionService } from '../types/collection';
|
|
15
|
-
import type {
|
|
15
|
+
import type { ReviewReport } from '../infrastructure/review';
|
|
16
|
+
import type { TestSuite } from '../infrastructure/test-suite/interfaces';
|
|
17
|
+
import type { McpRunRecord, McpRunStore } from './mcp-run-store';
|
|
16
18
|
export interface McpPromptArg {
|
|
17
19
|
name: string;
|
|
18
20
|
description: string;
|
|
@@ -35,5 +37,17 @@ export interface PromptResult {
|
|
|
35
37
|
description: string;
|
|
36
38
|
messages: PromptMessage[];
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Build the LLM-enrichment prompt for the review_suite tool.
|
|
42
|
+
*
|
|
43
|
+
* Rules-first: the deterministic findings are always the source of truth; the
|
|
44
|
+
* LLM only prioritizes them and adds actionable prose. Passing the findings in
|
|
45
|
+
* keeps the model honest (it cannot invent severity) and keeps the gate CI-safe.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildReviewSuitePrompt(input: {
|
|
48
|
+
rec: McpRunRecord;
|
|
49
|
+
suite?: TestSuite;
|
|
50
|
+
report: ReviewReport;
|
|
51
|
+
}): Promise<string>;
|
|
52
|
+
export declare function buildPromptResult(name: string, args: Record<string, string>, collectionService: ICollectionService, runStore: McpRunStore, workspaceFolder?: string): Promise<PromptResult>;
|
|
39
53
|
export {};
|
|
@@ -219,6 +219,13 @@ export declare const GENERIC_TOOL_NAMES: {
|
|
|
219
219
|
readonly createRequest: "create_request";
|
|
220
220
|
readonly updateRequest: "update_request";
|
|
221
221
|
readonly deleteRequest: "delete_request";
|
|
222
|
+
readonly createRequestFromEndpoint: "create_request_from_endpoint";
|
|
223
|
+
readonly generateTestSuite: "generate_test_suite";
|
|
224
|
+
readonly suggestWorkflow: "suggest_workflow";
|
|
225
|
+
readonly generateWorkflow: "generate_workflow";
|
|
226
|
+
readonly checkDrift: "check_drift";
|
|
227
|
+
readonly proposeUpdate: "propose_update";
|
|
228
|
+
readonly reviewSuite: "review_suite";
|
|
222
229
|
readonly getRequestScript: "get_request_script";
|
|
223
230
|
readonly setRequestScript: "set_request_script";
|
|
224
231
|
readonly reorderCollectionItems: "reorder_collection_items";
|
|
@@ -258,6 +265,7 @@ export declare const GENERIC_TOOL_NAMES: {
|
|
|
258
265
|
readonly analyzeCoverage: "analyze_coverage";
|
|
259
266
|
readonly aiAnalyzeCoverage: "ai_analyze_coverage";
|
|
260
267
|
readonly generateRequestFromIntent: "generate_request_from_intent";
|
|
268
|
+
readonly designApiFromIntent: "design_api_from_intent";
|
|
261
269
|
readonly validateAgainstSpec: "validate_against_spec";
|
|
262
270
|
readonly generateScenarios: "generate_scenarios";
|
|
263
271
|
readonly healAssertions: "heal_assertions";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suite flow engine for direct execution.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the node-graph interpreter used to execute a test suite
|
|
5
|
+
* (or a collection replayed as a suite): conditional/loop/switch nodes,
|
|
6
|
+
* request execution, pre/post scripts, per-iteration concurrency, result
|
|
7
|
+
* persistence, and report generation.
|
|
8
|
+
*/
|
|
9
|
+
import type { ServiceContainer } from '../di/service-container';
|
|
10
|
+
/**
|
|
11
|
+
* Executes a suite node graph against a resolved service container.
|
|
12
|
+
*
|
|
13
|
+
* The whole flow engine lives here so the public entry points in
|
|
14
|
+
* `direct-execution.ts` stay thin. One instance is scoped to one run.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SuiteExecutor {
|
|
17
|
+
private readonly container;
|
|
18
|
+
constructor(container: ServiceContainer);
|
|
19
|
+
execute(suite: any, args: Record<string, unknown>, source: 'suite' | 'collection'): Promise<unknown>;
|
|
20
|
+
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -280,15 +280,6 @@ export interface ExecutionVariables {
|
|
|
280
280
|
globals?: Record<string, string>;
|
|
281
281
|
environmentVariables?: Record<string, string>;
|
|
282
282
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Environment configuration
|
|
285
|
-
*/
|
|
286
|
-
export interface Environment {
|
|
287
|
-
name: string;
|
|
288
|
-
description?: string;
|
|
289
|
-
variables: Record<string, string>;
|
|
290
|
-
headers?: Record<string, string>;
|
|
291
|
-
}
|
|
292
283
|
/**
|
|
293
284
|
* Context available to scripts during execution
|
|
294
285
|
*/
|