@http-forge/core 0.4.7 → 0.4.8
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 +29 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +196 -196
- package/dist/index.mjs +196 -196
- package/dist/infrastructure/auth/oauth2-token-manager.d.ts +1 -1
- package/dist/infrastructure/script/interfaces.d.ts +1 -0
- package/dist/infrastructure/script/request-script-session.d.ts +13 -0
- package/dist/infrastructure/script/script-factories.d.ts +1 -0
- package/dist/runtime/mcp-tool-name.d.ts +46 -0
- package/dist/runtime/mcp-tool-schemas.d.ts +170 -0
- package/package.json +1 -1
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* is injected via IExternalBrowserService and ISecretStore interfaces.
|
|
15
15
|
*/
|
|
16
16
|
import { IEnvironmentConfigService } from '../../types/environment-config';
|
|
17
|
-
import { IHttpRequestService } from '../http/interfaces';
|
|
18
17
|
import { IExternalBrowserService, ISecretStore } from '../../types/platform';
|
|
19
18
|
import { OAuth2Config } from '../../types/types';
|
|
19
|
+
import { IHttpRequestService } from '../http/interfaces';
|
|
20
20
|
import { IOAuth2TokenManager, TokenCacheKey, TokenInfo } from './interfaces';
|
|
21
21
|
export declare class OAuth2TokenManager implements IOAuth2TokenManager {
|
|
22
22
|
private readonly secretStore;
|
|
@@ -49,6 +49,7 @@ export interface ResponseContext {
|
|
|
49
49
|
status: number;
|
|
50
50
|
statusText: string;
|
|
51
51
|
headers: Record<string, string>;
|
|
52
|
+
/** Raw response body string (Postman-compatible). Parse on demand via response.json(). */
|
|
52
53
|
body: any;
|
|
53
54
|
cookies?: Record<string, string>;
|
|
54
55
|
responseTime?: number;
|
|
@@ -64,6 +64,19 @@ export declare class RequestScriptSession implements IRequestScriptSession {
|
|
|
64
64
|
* Maps HTTP Forge body types to Postman modes for script API compatibility
|
|
65
65
|
*/
|
|
66
66
|
private createRequestObject;
|
|
67
|
+
/**
|
|
68
|
+
* Inject the legacy (pre-`pm.*`) Postman/Newman sandbox globals into the VM context.
|
|
69
|
+
*
|
|
70
|
+
* Older Postman scripts (and many Newman-exported collections) rely on bare globals
|
|
71
|
+
* that the modern `pm.*` sandbox no longer injects. Evaluating them (e.g. `request.name`,
|
|
72
|
+
* `responseCode.code`, `tv4.validate(...)`) otherwise throws `ReferenceError`.
|
|
73
|
+
*
|
|
74
|
+
* Available in BOTH phases: `request`, `environment`, `globals`, `data`, `iteration`.
|
|
75
|
+
* Available in the TEST phase only: `responseBody`, `responseCode`, `responseHeaders`,
|
|
76
|
+
* `responseTime`, `responseCookies`, `tests`, plus `postman.getResponseHeader()` /
|
|
77
|
+
* `postman.getResponseCookie()`.
|
|
78
|
+
*/
|
|
79
|
+
private injectLegacyGlobals;
|
|
67
80
|
/**
|
|
68
81
|
* Execute pre-request scripts in the shared session
|
|
69
82
|
*/
|
|
@@ -22,6 +22,7 @@ export interface ScriptResponse {
|
|
|
22
22
|
code: number;
|
|
23
23
|
statusText: string;
|
|
24
24
|
headers: Record<string, string>;
|
|
25
|
+
/** Raw response body string (Postman-compatible). Use json() to parse, text() for the string. */
|
|
25
26
|
body: any;
|
|
26
27
|
cookies: Record<string, string>;
|
|
27
28
|
responseTime?: number;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP tool-name encoding / decoding.
|
|
3
|
+
*
|
|
4
|
+
* MCP tool names must stay under Anthropic's 128-character limit. HTTP Forge
|
|
5
|
+
* IDs embed the human-readable entity name (up to ~100 chars each), so a raw
|
|
6
|
+
* tool name like `request__<collectionId>__<requestId>` can exceed 240 chars
|
|
7
|
+
* and be rejected by the model provider.
|
|
8
|
+
*
|
|
9
|
+
* To stay short we put a deterministic short hash token (not the raw ID) in the
|
|
10
|
+
* tool name, and resolve a call back to the real entity by hashing the current
|
|
11
|
+
* collections / requests / folders / suites and matching. A raw-value fallback
|
|
12
|
+
* keeps any previously-listed long names working after the upgrade.
|
|
13
|
+
*
|
|
14
|
+
* IDs are NOT changed — they remain the stable external references used by
|
|
15
|
+
* suites, result filenames, and history. Only the tool *name* is shortened.
|
|
16
|
+
*
|
|
17
|
+
* The model selects a tool by its *description* (which still contains the
|
|
18
|
+
* human-readable names), so an opaque short name does not affect tool choice.
|
|
19
|
+
*/
|
|
20
|
+
/** Deterministic short token for an ID or folder path (12 hex chars). */
|
|
21
|
+
export declare function mcpToolToken(value: string): string;
|
|
22
|
+
export type McpToolKind = 'request' | 'collection' | 'folder' | 'suite';
|
|
23
|
+
export declare function buildRequestToolName(prefix: string, collectionId: string, requestId: string): string;
|
|
24
|
+
export declare function buildCollectionToolName(prefix: string, collectionId: string): string;
|
|
25
|
+
export declare function buildFolderToolName(prefix: string, collectionId: string, folderPath: string): string;
|
|
26
|
+
export declare function buildSuiteToolName(prefix: string, suiteId: string): string;
|
|
27
|
+
export interface ParsedMcpToolName {
|
|
28
|
+
kind: McpToolKind;
|
|
29
|
+
tokens: string[];
|
|
30
|
+
}
|
|
31
|
+
/** Parse a tool name (prefix already stripped) into its kind + token segments. */
|
|
32
|
+
export declare function parseMcpToolName(name: string): ParsedMcpToolName;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a token back to one of `candidates` by matching its hash token, or
|
|
35
|
+
* (legacy fallback) the raw candidate value itself.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveToken(token: string, candidates: readonly string[]): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a folder token to a folder path. Adds a base64url legacy fallback for
|
|
40
|
+
* folder tool names emitted before hashing (which embedded base64url(path)).
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveFolderToken(token: string, folderPaths: readonly string[]): string | undefined;
|
|
43
|
+
export declare function buildRequestToolDescription(method: string, requestName: string, collectionName: string, folderPath: string): string;
|
|
44
|
+
export declare function buildCollectionToolDescription(collectionName: string, requestCount: number): string;
|
|
45
|
+
export declare function buildFolderToolDescription(folderPath: string, collectionName: string, requestCount: number): string;
|
|
46
|
+
export declare function buildSuiteToolDescription(suiteName: string, requestCount: number, iterations: number): string;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP tool input schemas.
|
|
3
|
+
*
|
|
4
|
+
* Both MCP server implementations (the embeddable core runtime and the VS Code
|
|
5
|
+
* extension) expose the same tools, so they must advertise identical input
|
|
6
|
+
* schemas. Keeping these in one place prevents the two sides from drifting
|
|
7
|
+
* (e.g. the extension previously omitted `iterations`/`delay`/`include` for
|
|
8
|
+
* collection and folder runs even though its executor supported them).
|
|
9
|
+
*/
|
|
10
|
+
export declare const REQUEST_INPUT_SCHEMA: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly properties: {
|
|
13
|
+
readonly environment: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly description: "Environment name to use (defaults to the currently selected environment)";
|
|
16
|
+
};
|
|
17
|
+
readonly variables: {
|
|
18
|
+
readonly type: "object";
|
|
19
|
+
readonly description: "Extra variables to inject — merged with environment variables, {{name}} syntax";
|
|
20
|
+
readonly additionalProperties: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly headers: {
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
readonly description: "Override or add request headers";
|
|
27
|
+
readonly additionalProperties: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly query: {
|
|
32
|
+
readonly type: "object";
|
|
33
|
+
readonly description: "Override query parameters";
|
|
34
|
+
readonly additionalProperties: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly body: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly description: "Replace the request body (JSON string). Omit to use the saved body.";
|
|
41
|
+
};
|
|
42
|
+
readonly include: {
|
|
43
|
+
readonly type: "array";
|
|
44
|
+
readonly items: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly enum: readonly ["headers", "cookies", "tests", "consoleOutput", "report"];
|
|
47
|
+
};
|
|
48
|
+
readonly description: "Extra fields to include in the response (default: status, ok, body, allPassed)";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const COLLECTION_INPUT_SCHEMA: {
|
|
53
|
+
readonly type: "object";
|
|
54
|
+
readonly properties: {
|
|
55
|
+
readonly environment: {
|
|
56
|
+
readonly type: "string";
|
|
57
|
+
readonly description: "Environment name to use";
|
|
58
|
+
};
|
|
59
|
+
readonly variables: {
|
|
60
|
+
readonly type: "object";
|
|
61
|
+
readonly description: "Extra variables injected into every request";
|
|
62
|
+
readonly additionalProperties: {
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
readonly iterations: {
|
|
67
|
+
readonly type: "number";
|
|
68
|
+
readonly description: "Number of iterations (default: 1)";
|
|
69
|
+
};
|
|
70
|
+
readonly stopOnError: {
|
|
71
|
+
readonly type: "boolean";
|
|
72
|
+
readonly description: "Stop on first failure";
|
|
73
|
+
};
|
|
74
|
+
readonly delay: {
|
|
75
|
+
readonly type: "number";
|
|
76
|
+
readonly description: "Delay between requests in ms";
|
|
77
|
+
};
|
|
78
|
+
readonly include: {
|
|
79
|
+
readonly type: "array";
|
|
80
|
+
readonly items: {
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
readonly enum: readonly ["perRequest", "failedOnly", "consoleOutput", "report"];
|
|
83
|
+
};
|
|
84
|
+
readonly description: "Result detail level";
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export declare const FOLDER_INPUT_SCHEMA: {
|
|
89
|
+
readonly type: "object";
|
|
90
|
+
readonly properties: {
|
|
91
|
+
readonly environment: {
|
|
92
|
+
readonly type: "string";
|
|
93
|
+
readonly description: "Environment name to use";
|
|
94
|
+
};
|
|
95
|
+
readonly variables: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly description: "Extra variables injected into every request";
|
|
98
|
+
readonly additionalProperties: {
|
|
99
|
+
readonly type: "string";
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
readonly iterations: {
|
|
103
|
+
readonly type: "number";
|
|
104
|
+
readonly description: "Number of iterations (default: 1)";
|
|
105
|
+
};
|
|
106
|
+
readonly stopOnError: {
|
|
107
|
+
readonly type: "boolean";
|
|
108
|
+
readonly description: "Stop on first failure";
|
|
109
|
+
};
|
|
110
|
+
readonly delay: {
|
|
111
|
+
readonly type: "number";
|
|
112
|
+
readonly description: "Delay between requests in ms";
|
|
113
|
+
};
|
|
114
|
+
readonly recursive: {
|
|
115
|
+
readonly type: "boolean";
|
|
116
|
+
readonly description: "Include requests in nested subfolders (default: true)";
|
|
117
|
+
};
|
|
118
|
+
readonly include: {
|
|
119
|
+
readonly type: "array";
|
|
120
|
+
readonly items: {
|
|
121
|
+
readonly type: "string";
|
|
122
|
+
readonly enum: readonly ["perRequest", "failedOnly", "consoleOutput", "report"];
|
|
123
|
+
};
|
|
124
|
+
readonly description: "Result detail level";
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export declare const SUITE_INPUT_SCHEMA: {
|
|
129
|
+
readonly type: "object";
|
|
130
|
+
readonly properties: {
|
|
131
|
+
readonly environment: {
|
|
132
|
+
readonly type: "string";
|
|
133
|
+
readonly description: "Environment name to use";
|
|
134
|
+
};
|
|
135
|
+
readonly iterations: {
|
|
136
|
+
readonly type: "number";
|
|
137
|
+
readonly description: "Number of iterations (overrides suite default)";
|
|
138
|
+
};
|
|
139
|
+
readonly stopOnError: {
|
|
140
|
+
readonly type: "boolean";
|
|
141
|
+
readonly description: "Stop on first failure";
|
|
142
|
+
};
|
|
143
|
+
readonly delay: {
|
|
144
|
+
readonly type: "number";
|
|
145
|
+
readonly description: "Delay between requests in ms";
|
|
146
|
+
};
|
|
147
|
+
readonly variables: {
|
|
148
|
+
readonly type: "object";
|
|
149
|
+
readonly description: "Extra variables injected into every request";
|
|
150
|
+
readonly additionalProperties: {
|
|
151
|
+
readonly type: "string";
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
readonly requestFilter: {
|
|
155
|
+
readonly type: "array";
|
|
156
|
+
readonly items: {
|
|
157
|
+
readonly type: "string";
|
|
158
|
+
};
|
|
159
|
+
readonly description: "Run only requests whose names match one of these strings (case-insensitive)";
|
|
160
|
+
};
|
|
161
|
+
readonly include: {
|
|
162
|
+
readonly type: "array";
|
|
163
|
+
readonly items: {
|
|
164
|
+
readonly type: "string";
|
|
165
|
+
readonly enum: readonly ["perRequest", "failedOnly", "consoleOutput", "report"];
|
|
166
|
+
};
|
|
167
|
+
readonly description: "Result detail level (default: summary + failedRequests)";
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
package/package.json
CHANGED