@http-forge/core 0.6.32 → 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.
Files changed (100) hide show
  1. package/README.md +51 -0
  2. package/dist/__tests__/api-discovery/golden-utils.d.ts +10 -0
  3. package/dist/index.d.ts +49 -22
  4. package/dist/index.js +456 -480
  5. package/dist/index.mjs +456 -480
  6. package/dist/infrastructure/ai/ai-context.d.ts +109 -0
  7. package/dist/infrastructure/ai/ai-provider.d.ts +1 -1
  8. package/dist/infrastructure/ai/ai-utils.d.ts +38 -0
  9. package/dist/infrastructure/ai/http-providers.d.ts +34 -0
  10. package/dist/infrastructure/api-discovery/analyzer/component-analyzer.d.ts +60 -0
  11. package/dist/infrastructure/api-discovery/analyzer/express-component-analyzer.d.ts +14 -0
  12. package/dist/infrastructure/api-discovery/analyzer/fastify-component-analyzer.d.ts +14 -0
  13. package/dist/infrastructure/api-discovery/analyzer/index.d.ts +11 -0
  14. package/dist/infrastructure/api-discovery/analyzer/lambda-component-analyzer.d.ts +18 -0
  15. package/dist/infrastructure/api-discovery/api-discovery-service.d.ts +49 -0
  16. package/dist/infrastructure/api-discovery/auth-validation.d.ts +34 -0
  17. package/dist/infrastructure/api-discovery/drift-engine.d.ts +139 -0
  18. package/dist/infrastructure/api-discovery/fastapi/fastapi-discovery-provider.d.ts +19 -0
  19. package/dist/infrastructure/api-discovery/fastapi/fastapi-parser.d.ts +60 -0
  20. package/dist/infrastructure/api-discovery/framework-detector.d.ts +8 -0
  21. package/dist/infrastructure/api-discovery/index.d.ts +29 -0
  22. package/dist/infrastructure/api-discovery/path-utils.d.ts +17 -0
  23. package/dist/infrastructure/api-discovery/project-name.d.ts +2 -0
  24. package/dist/infrastructure/api-discovery/provider.d.ts +29 -0
  25. package/dist/infrastructure/api-discovery/providers/express-discovery-provider.d.ts +13 -0
  26. package/dist/infrastructure/api-discovery/providers/fastify-discovery-provider.d.ts +13 -0
  27. package/dist/infrastructure/api-discovery/providers/lambda-discovery-provider.d.ts +19 -0
  28. package/dist/infrastructure/api-discovery/providers/nest-discovery-provider.d.ts +12 -0
  29. package/dist/infrastructure/api-discovery/seed-loader.d.ts +11 -0
  30. package/dist/infrastructure/api-discovery/source-files.d.ts +1 -0
  31. package/dist/infrastructure/api-discovery/spring/controller-visitor.d.ts +141 -0
  32. package/dist/infrastructure/api-discovery/spring/endpoint-parser.d.ts +51 -0
  33. package/dist/infrastructure/api-discovery/spring/file-utils.d.ts +28 -0
  34. package/dist/infrastructure/api-discovery/spring/model.d.ts +84 -0
  35. package/dist/infrastructure/api-discovery/spring/schema-generator.d.ts +65 -0
  36. package/dist/infrastructure/api-discovery/spring/spring-discovery-provider.d.ts +30 -0
  37. package/dist/infrastructure/api-discovery/spring/spring-types.d.ts +27 -0
  38. package/dist/infrastructure/api-discovery/test-generator.d.ts +69 -0
  39. package/dist/infrastructure/api-discovery/types.d.ts +154 -0
  40. package/dist/infrastructure/api-discovery/workflow-discovery.d.ts +55 -0
  41. package/dist/infrastructure/architect/api-architect-service.d.ts +85 -0
  42. package/dist/infrastructure/architect/architect-prompt.d.ts +22 -0
  43. package/dist/infrastructure/architect/collection-to-endpoints.d.ts +13 -0
  44. package/dist/infrastructure/architect/index.d.ts +10 -0
  45. package/dist/infrastructure/collection/collection-service.d.ts +1 -5
  46. package/dist/infrastructure/collection/json-collection-loader.d.ts +0 -8
  47. package/dist/infrastructure/cookie/cookie-service.d.ts +2 -13
  48. package/dist/infrastructure/cookie/cookie-utils.d.ts +5 -0
  49. package/dist/infrastructure/docs/index.d.ts +5 -0
  50. package/dist/infrastructure/docs/release-notes.d.ts +51 -0
  51. package/dist/infrastructure/environment/environment-config-service.d.ts +0 -1
  52. package/dist/infrastructure/environment/variable-interpolator.d.ts +9 -0
  53. package/dist/infrastructure/http/header-utils.d.ts +13 -0
  54. package/dist/infrastructure/http/http-request-service.d.ts +3 -3
  55. package/dist/infrastructure/http/interceptor-chain.d.ts +35 -16
  56. package/dist/infrastructure/http/native-http-client.d.ts +0 -10
  57. package/dist/infrastructure/openapi/interfaces.d.ts +14 -0
  58. package/dist/infrastructure/openapi/openapi-exporter.d.ts +11 -91
  59. package/dist/infrastructure/openapi/openapi-importer.d.ts +19 -0
  60. package/dist/infrastructure/openapi/openapi-operation-builder.d.ts +36 -0
  61. package/dist/infrastructure/openapi/openapi-schema-merger.d.ts +33 -0
  62. package/dist/infrastructure/openapi/openapi-spec-writer.d.ts +27 -0
  63. package/dist/infrastructure/openapi/openapi-utils.d.ts +62 -0
  64. package/dist/infrastructure/parsers/har-parser.d.ts +63 -0
  65. package/dist/infrastructure/parsers/index.d.ts +2 -0
  66. package/dist/infrastructure/review/index.d.ts +5 -0
  67. package/dist/infrastructure/review/review-engine.d.ts +95 -0
  68. package/dist/infrastructure/script/crypto-js-compat.d.ts +123 -0
  69. package/dist/infrastructure/script/request-object-factory.d.ts +54 -0
  70. package/dist/infrastructure/script/request-script-session.d.ts +0 -5
  71. package/dist/infrastructure/script/script-executor.d.ts +4 -33
  72. package/dist/infrastructure/script/script-factories.d.ts +13 -0
  73. package/dist/infrastructure/script/variable-scopes.d.ts +101 -0
  74. package/dist/infrastructure/test-suite/interfaces.d.ts +6 -0
  75. package/dist/infrastructure/test-suite/result-storage-service.d.ts +6 -1
  76. package/dist/infrastructure/test-suite/result-storage.d.ts +14 -1
  77. package/dist/runtime/collection-traversal.d.ts +32 -0
  78. package/dist/runtime/direct-execution.d.ts +7 -0
  79. package/dist/runtime/execution-helpers.d.ts +30 -0
  80. package/dist/runtime/mcp-dispatcher.d.ts +10 -34
  81. package/dist/runtime/mcp-handlers/ai.d.ts +6 -0
  82. package/dist/runtime/mcp-handlers/collection.d.ts +5 -0
  83. package/dist/runtime/mcp-handlers/discovery.d.ts +12 -0
  84. package/dist/runtime/mcp-handlers/environment-management.d.ts +6 -0
  85. package/dist/runtime/mcp-handlers/environment.d.ts +5 -0
  86. package/dist/runtime/mcp-handlers/execution.d.ts +6 -0
  87. package/dist/runtime/mcp-handlers/helpers.d.ts +43 -0
  88. package/dist/runtime/mcp-handlers/inspection.d.ts +5 -0
  89. package/dist/runtime/mcp-handlers/registry.d.ts +12 -0
  90. package/dist/runtime/mcp-handlers/request.d.ts +5 -0
  91. package/dist/runtime/mcp-handlers/review.d.ts +10 -0
  92. package/dist/runtime/mcp-handlers/run-status.d.ts +5 -0
  93. package/dist/runtime/mcp-handlers/suite.d.ts +6 -0
  94. package/dist/runtime/mcp-handlers/types.d.ts +59 -0
  95. package/dist/runtime/mcp-prompts.d.ts +16 -2
  96. package/dist/runtime/mcp-tool-schemas.d.ts +8 -0
  97. package/dist/runtime/suite-executor.d.ts +20 -0
  98. package/dist/types/types.d.ts +0 -9
  99. package/dist/utils/env-hints.d.ts +17 -0
  100. 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 */
@@ -35,7 +35,12 @@ export declare class ResultStorageService implements IResultStorageService {
35
35
  /**
36
36
  * Initialize a new run
37
37
  */
38
- initializeRun(suiteId: string, suiteName: string, environment: string, config: RunConfig): Promise<string>;
38
+ initializeRun(suiteId: string, suiteName: string, environment: string, config: RunConfig, metadata?: {
39
+ targetType?: 'suite' | 'collection' | 'folder';
40
+ targetName?: string;
41
+ collectionName?: string;
42
+ folderPath?: string;
43
+ }): Promise<string>;
39
44
  /**
40
45
  * Save a request result
41
46
  * Returns lightweight summary for UI
@@ -150,6 +150,14 @@ export interface RunManifest {
150
150
  suiteId: string;
151
151
  /** Suite name */
152
152
  suiteName: string;
153
+ /** What kind of target produced the run */
154
+ targetType?: 'suite' | 'collection' | 'folder';
155
+ /** Human-readable target label */
156
+ targetName?: string;
157
+ /** Collection name for collection/folder runs */
158
+ collectionName?: string;
159
+ /** Folder path for folder runs */
160
+ folderPath?: string;
153
161
  /** Environment used */
154
162
  environment: string;
155
163
  /** Run start time */
@@ -295,7 +303,12 @@ export interface IResultStorageService {
295
303
  /**
296
304
  * Initialize a new run
297
305
  */
298
- initializeRun(suiteId: string, suiteName: string, environment: string, config: RunConfig): Promise<string>;
306
+ initializeRun(suiteId: string, suiteName: string, environment: string, config: RunConfig, metadata?: {
307
+ targetType?: 'suite' | 'collection' | 'folder';
308
+ targetName?: string;
309
+ collectionName?: string;
310
+ folderPath?: string;
311
+ }): Promise<string>;
299
312
  /**
300
313
  * Save a request result
301
314
  * Returns lightweight summary for UI
@@ -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
- * Single implementation of all argument-based ("generic") tool handlers,
5
- * shared between the embedded core runtime and the VS Code extension's
6
- * McpExecutor.
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 type { ITestSuiteService } from '../infrastructure/test-suite/interfaces';
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 interface McpDispatchServices {
21
- collection: ICollectionService;
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,6 @@
1
+ /**
2
+ * AI-native tool handlers — scaffold/openapi, suggestions, coverage, and the
3
+ * "task" tools that instruct the calling LLM to take follow-up actions.
4
+ */
5
+ import type { McpToolHandler } from './types';
6
+ export declare const aiHandlers: McpToolHandler[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Collection and folder management tool handlers.
3
+ */
4
+ import type { McpToolHandler } from './types';
5
+ export declare const collectionHandlers: McpToolHandler[];
@@ -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
+ * Environment management tool handlers — list/create/delete environments and
3
+ * set/unset variables and globals.
4
+ */
5
+ import type { McpToolHandler } from './types';
6
+ export declare const environmentManagementHandlers: McpToolHandler[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Environment read/write tool handlers (get_environment, set_variable).
3
+ */
4
+ import type { McpToolHandler } from './types';
5
+ export declare const environmentHandlers: McpToolHandler[];
@@ -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,5 @@
1
+ /**
2
+ * Inspection tool handlers — list/search/read collections, folders, requests.
3
+ */
4
+ import type { McpToolHandler } from './types';
5
+ export declare const inspectionHandlers: McpToolHandler[];
@@ -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,5 @@
1
+ /**
2
+ * Request and script management tool handlers.
3
+ */
4
+ import type { McpToolHandler } from './types';
5
+ export declare const requestHandlers: McpToolHandler[];
@@ -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,5 @@
1
+ /**
2
+ * Async run polling tool handlers — inspect/cancel in-memory run records.
3
+ */
4
+ import type { McpToolHandler } from './types';
5
+ export declare const runStatusHandlers: McpToolHandler[];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Test-suite management tool handlers, including the flow-graph path helpers
3
+ * (parse/walk/resolve suite node graphs).
4
+ */
5
+ import type { McpToolHandler } from './types';
6
+ export declare const suiteHandlers: 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 { McpRunStore } from './mcp-run-store';
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
- export declare function buildPromptResult(name: string, args: Record<string, string>, collectionService: ICollectionService, runStore: McpRunStore): Promise<PromptResult>;
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";