@http-forge/core 0.6.35 → 0.6.36-beta.2

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 (101) 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 +50 -23
  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/config/config-service.d.ts +2 -1
  48. package/dist/infrastructure/config/config.interface.d.ts +17 -0
  49. package/dist/infrastructure/config/index.d.ts +1 -1
  50. package/dist/infrastructure/cookie/cookie-service.d.ts +2 -13
  51. package/dist/infrastructure/cookie/cookie-utils.d.ts +5 -0
  52. package/dist/infrastructure/docs/index.d.ts +5 -0
  53. package/dist/infrastructure/docs/release-notes.d.ts +51 -0
  54. package/dist/infrastructure/environment/environment-config-service.d.ts +0 -1
  55. package/dist/infrastructure/environment/variable-interpolator.d.ts +9 -0
  56. package/dist/infrastructure/http/header-utils.d.ts +13 -0
  57. package/dist/infrastructure/http/http-request-service.d.ts +3 -3
  58. package/dist/infrastructure/http/interceptor-chain.d.ts +35 -16
  59. package/dist/infrastructure/http/native-http-client.d.ts +0 -10
  60. package/dist/infrastructure/openapi/interfaces.d.ts +14 -0
  61. package/dist/infrastructure/openapi/openapi-exporter.d.ts +11 -91
  62. package/dist/infrastructure/openapi/openapi-importer.d.ts +19 -0
  63. package/dist/infrastructure/openapi/openapi-operation-builder.d.ts +36 -0
  64. package/dist/infrastructure/openapi/openapi-schema-merger.d.ts +33 -0
  65. package/dist/infrastructure/openapi/openapi-spec-writer.d.ts +27 -0
  66. package/dist/infrastructure/openapi/openapi-utils.d.ts +62 -0
  67. package/dist/infrastructure/parsers/har-parser.d.ts +63 -0
  68. package/dist/infrastructure/parsers/index.d.ts +2 -0
  69. package/dist/infrastructure/review/index.d.ts +5 -0
  70. package/dist/infrastructure/review/review-engine.d.ts +95 -0
  71. package/dist/infrastructure/script/crypto-js-compat.d.ts +123 -0
  72. package/dist/infrastructure/script/request-object-factory.d.ts +54 -0
  73. package/dist/infrastructure/script/request-script-session.d.ts +0 -5
  74. package/dist/infrastructure/script/script-executor.d.ts +4 -33
  75. package/dist/infrastructure/script/script-factories.d.ts +13 -0
  76. package/dist/infrastructure/script/variable-scopes.d.ts +101 -0
  77. package/dist/infrastructure/test-suite/interfaces.d.ts +6 -0
  78. package/dist/runtime/collection-traversal.d.ts +32 -0
  79. package/dist/runtime/direct-execution.d.ts +7 -0
  80. package/dist/runtime/execution-helpers.d.ts +30 -0
  81. package/dist/runtime/mcp-dispatcher.d.ts +10 -34
  82. package/dist/runtime/mcp-handlers/ai.d.ts +6 -0
  83. package/dist/runtime/mcp-handlers/collection.d.ts +5 -0
  84. package/dist/runtime/mcp-handlers/discovery.d.ts +12 -0
  85. package/dist/runtime/mcp-handlers/environment-management.d.ts +6 -0
  86. package/dist/runtime/mcp-handlers/environment.d.ts +5 -0
  87. package/dist/runtime/mcp-handlers/execution.d.ts +6 -0
  88. package/dist/runtime/mcp-handlers/helpers.d.ts +43 -0
  89. package/dist/runtime/mcp-handlers/inspection.d.ts +5 -0
  90. package/dist/runtime/mcp-handlers/registry.d.ts +12 -0
  91. package/dist/runtime/mcp-handlers/request.d.ts +5 -0
  92. package/dist/runtime/mcp-handlers/review.d.ts +10 -0
  93. package/dist/runtime/mcp-handlers/run-status.d.ts +5 -0
  94. package/dist/runtime/mcp-handlers/suite.d.ts +6 -0
  95. package/dist/runtime/mcp-handlers/types.d.ts +59 -0
  96. package/dist/runtime/mcp-prompts.d.ts +16 -2
  97. package/dist/runtime/mcp-tool-schemas.d.ts +8 -0
  98. package/dist/runtime/suite-executor.d.ts +20 -0
  99. package/dist/types/types.d.ts +0 -9
  100. package/dist/utils/env-hints.d.ts +17 -0
  101. package/package.json +16 -6
@@ -0,0 +1,123 @@
1
+ /**
2
+ * CryptoJS compatibility layer
3
+ *
4
+ * Single Responsibility: Provide a CryptoJS-compatible API surface for the
5
+ * script sandbox (hashes, HMACs, AES/DES/TripleDES ciphers, encodings, PBKDF2).
6
+ *
7
+ * Uses Node's crypto module underneath, with a WordArray representation that
8
+ * behaves like CryptoJS's intermediate data type.
9
+ */
10
+ /**
11
+ * CryptoJS-compatible WordArray representation.
12
+ *
13
+ * CryptoJS uses a custom WordArray type as intermediate data representation.
14
+ * We represent it as a tagged Buffer wrapper so all encrypt/decrypt flows work.
15
+ */
16
+ declare class CryptoWordArray {
17
+ private _buffer;
18
+ constructor(data: string | Buffer);
19
+ toString(encoder?: {
20
+ stringify: (wa: CryptoWordArray) => string;
21
+ }): string;
22
+ toBuffer(): Buffer;
23
+ /** Create from hex string */
24
+ static fromHex(hex: string): CryptoWordArray;
25
+ /** Create from base64 string */
26
+ static fromBase64(b64: string): CryptoWordArray;
27
+ /** Create from utf8 string */
28
+ static fromUtf8(str: string): CryptoWordArray;
29
+ }
30
+ /**
31
+ * CryptoJS Factory - Creates CryptoJS-compatible object
32
+ *
33
+ * Supports:
34
+ * - Hash: MD5, SHA1, SHA224, SHA256, SHA384, SHA512, SHA3, RIPEMD160
35
+ * - HMAC: HmacMD5, HmacSHA1, HmacSHA256, HmacSHA512
36
+ * - Encryption: AES, DES, TripleDES (passphrase and raw key modes)
37
+ * - Encoding: Base64, Hex, Utf8, Utf16, Latin1
38
+ * - Key derivation: PBKDF2
39
+ * - WordArray creation from lib.WordArray.create / lib.WordArray.random
40
+ */
41
+ export declare function createCryptoJS(): {
42
+ MD5: (message: string | CryptoWordArray) => CryptoWordArray;
43
+ SHA1: (message: string | CryptoWordArray) => CryptoWordArray;
44
+ SHA224: (message: string | CryptoWordArray) => CryptoWordArray;
45
+ SHA256: (message: string | CryptoWordArray) => CryptoWordArray;
46
+ SHA384: (message: string | CryptoWordArray) => CryptoWordArray;
47
+ SHA512: (message: string | CryptoWordArray) => CryptoWordArray;
48
+ SHA3: (message: string | CryptoWordArray) => CryptoWordArray;
49
+ RIPEMD160: (message: string | CryptoWordArray) => CryptoWordArray;
50
+ HmacMD5: (message: string | CryptoWordArray, key: string | CryptoWordArray) => CryptoWordArray;
51
+ HmacSHA1: (message: string | CryptoWordArray, key: string | CryptoWordArray) => CryptoWordArray;
52
+ HmacSHA256: (message: string | CryptoWordArray, key: string | CryptoWordArray) => CryptoWordArray;
53
+ HmacSHA512: (message: string | CryptoWordArray, key: string | CryptoWordArray) => CryptoWordArray;
54
+ AES: {
55
+ encrypt(message: string | CryptoWordArray, key: string | CryptoWordArray, options?: any): any;
56
+ decrypt(ciphertext: string | any, key: string | CryptoWordArray, options?: any): CryptoWordArray;
57
+ };
58
+ DES: {
59
+ encrypt(message: string | CryptoWordArray, key: string | CryptoWordArray, options?: any): any;
60
+ decrypt(ciphertext: string | any, key: string | CryptoWordArray, options?: any): CryptoWordArray;
61
+ };
62
+ TripleDES: {
63
+ encrypt(message: string | CryptoWordArray, key: string | CryptoWordArray, options?: any): any;
64
+ decrypt(ciphertext: string | any, key: string | CryptoWordArray, options?: any): CryptoWordArray;
65
+ };
66
+ PBKDF2(password: string | CryptoWordArray, salt: string | CryptoWordArray, cfg?: {
67
+ keySize?: number;
68
+ iterations?: number;
69
+ hasher?: any;
70
+ }): CryptoWordArray;
71
+ enc: {
72
+ Base64: {
73
+ stringify: (wa: CryptoWordArray) => string;
74
+ parse: (str: string) => CryptoWordArray;
75
+ };
76
+ Utf8: {
77
+ stringify: (wa: CryptoWordArray) => string;
78
+ parse: (str: string) => CryptoWordArray;
79
+ };
80
+ Hex: {
81
+ stringify: (wa: CryptoWordArray) => string;
82
+ parse: (str: string) => CryptoWordArray;
83
+ };
84
+ Latin1: {
85
+ stringify: (wa: CryptoWordArray) => string;
86
+ parse: (str: string) => CryptoWordArray;
87
+ };
88
+ Utf16: {
89
+ stringify: (wa: CryptoWordArray) => string;
90
+ parse: (str: string) => CryptoWordArray;
91
+ };
92
+ Utf16BE: {
93
+ stringify: (wa: CryptoWordArray) => string;
94
+ parse: (str: string) => CryptoWordArray;
95
+ };
96
+ };
97
+ lib: {
98
+ WordArray: {
99
+ create: (data?: any) => CryptoWordArray;
100
+ random: (nBytes: number) => CryptoWordArray;
101
+ };
102
+ };
103
+ pad: {
104
+ Pkcs7: {
105
+ _name: string;
106
+ };
107
+ NoPadding: {
108
+ _name: string;
109
+ };
110
+ ZeroPadding: {
111
+ _name: string;
112
+ };
113
+ };
114
+ mode: {
115
+ CBC: {
116
+ _name: string;
117
+ };
118
+ ECB: {
119
+ _name: string;
120
+ };
121
+ };
122
+ };
123
+ export {};
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Request Object Factory
3
+ *
4
+ * Single Responsibility: Build the Postman-compatible pm.request object proxy
5
+ * with getters/setters for modification tracking.
6
+ *
7
+ * Maps HTTP Forge body types to Postman modes for script API compatibility.
8
+ */
9
+ export declare function createRequestObject(modifiedRequest: any, context: any): {
10
+ url: any;
11
+ method: string;
12
+ headers: any;
13
+ body: any;
14
+ params: any;
15
+ query: any;
16
+ auth: any;
17
+ certificate: any;
18
+ description: any;
19
+ name: string;
20
+ readonly id: any;
21
+ disabled: boolean;
22
+ readonly messages: any;
23
+ readonly methodPath: any;
24
+ readonly metadata: any;
25
+ getHeaders(options?: any): Record<string, string>;
26
+ addQueryParams(params: any[] | string): void;
27
+ removeQueryParams(params: string | string[] | any[]): void;
28
+ authorizeUsing(type: string | any, options?: any): void;
29
+ clone(): {
30
+ url: any;
31
+ method: any;
32
+ headers: any;
33
+ body: any;
34
+ params: any;
35
+ query: any;
36
+ auth: any;
37
+ certificate: any;
38
+ description: any;
39
+ name: any;
40
+ id: any;
41
+ disabled: any;
42
+ metadata: any;
43
+ messages: any;
44
+ methodPath: any;
45
+ };
46
+ describe(content: string, type?: string): void;
47
+ setHeader(name: string, value: string): void;
48
+ addHeader(header: string | {
49
+ key: string;
50
+ value: string;
51
+ }, value?: string): void;
52
+ removeHeader(name: string): void;
53
+ setBody(content: any, bodyType?: string, rawFormat?: string): void;
54
+ };
@@ -59,11 +59,6 @@ export declare class RequestScriptSession implements IRequestScriptSession {
59
59
  * Create shared context object that will be augmented with response data later
60
60
  */
61
61
  private createSharedContext;
62
- /**
63
- * Create request object with getters/setters for modification tracking
64
- * Maps HTTP Forge body types to Postman modes for script API compatibility
65
- */
66
- private createRequestObject;
67
62
  /**
68
63
  * Inject the legacy (pre-`pm.*`) Postman/Newman sandbox globals into the VM context.
69
64
  *
@@ -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
- * 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[];