@http-forge/core 0.5.3 → 0.6.0
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 +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +282 -280
- package/dist/index.mjs +283 -281
- package/dist/infrastructure/collection/collection-service.d.ts +2 -0
- package/dist/infrastructure/execution/collection-request-executor-interfaces.d.ts +13 -2
- package/dist/runtime/mcp-collection-utils.d.ts +22 -0
- package/dist/runtime/mcp-dispatcher.d.ts +47 -0
- package/dist/runtime/mcp-run-store.d.ts +43 -0
- package/dist/runtime/mcp-tool-builder.d.ts +29 -0
- package/dist/runtime/mcp-tool-schemas.d.ts +30 -0
- package/dist/types/collection.d.ts +14 -1
- package/dist/types/environment-config.d.ts +11 -0
- package/package.json +1 -1
|
@@ -82,6 +82,8 @@ export declare class CollectionService implements ICollectionService {
|
|
|
82
82
|
renameRequest(collectionId: string, requestId: string, newName: string): Promise<boolean>;
|
|
83
83
|
moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
|
|
84
84
|
reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
|
|
85
|
+
getRequestScript(collectionId: string, requestId: string, phase: 'pre-request' | 'post-response'): string | undefined;
|
|
86
|
+
setRequestScript(collectionId: string, requestId: string, phase: 'pre-request' | 'post-response', source: string): Promise<boolean>;
|
|
85
87
|
private findItemById;
|
|
86
88
|
private copyDirRecursive;
|
|
87
89
|
private deleteItemById;
|
|
@@ -9,9 +9,20 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { ExecutionRequest, ExecutionResult } from '../../types/types';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Identifies the origin of a console output batch.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export interface ConsoleOutputSource {
|
|
15
|
+
/** Name of the request that produced the output. */
|
|
16
|
+
requestName: string;
|
|
17
|
+
/** Script phase that produced the output. */
|
|
18
|
+
phase: 'pre-request' | 'post-response' | 'error';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Console output streaming callback.
|
|
22
|
+
* @param output - The log lines produced by the script.
|
|
23
|
+
* @param source - Where the output came from (request name + phase).
|
|
24
|
+
*/
|
|
25
|
+
export type ConsoleOutputCallback = (output: string[], source: ConsoleOutputSource) => void;
|
|
15
26
|
/**
|
|
16
27
|
* Collection Request Executor Interface
|
|
17
28
|
*
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection traversal utilities shared by the MCP tool-list builder and the
|
|
3
|
+
* generic tool dispatcher.
|
|
4
|
+
*
|
|
5
|
+
* Imported by both the embedded core runtime and the VS Code extension via
|
|
6
|
+
* @http-forge/core, so keeping this module free of Node.js platform
|
|
7
|
+
* dependencies is important.
|
|
8
|
+
*/
|
|
9
|
+
import type { Collection, CollectionItem, CollectionRequestItem } from '../types/collection';
|
|
10
|
+
export interface FlatRequest {
|
|
11
|
+
request: CollectionRequestItem;
|
|
12
|
+
folderPath: string;
|
|
13
|
+
}
|
|
14
|
+
/** Flatten all requests in a collection into a list with their folder paths. */
|
|
15
|
+
export declare function flattenRequests(collection: Collection, items?: CollectionItem[], folderPath?: string): FlatRequest[];
|
|
16
|
+
/** Enumerate every folder path in a collection along with its recursive request count. */
|
|
17
|
+
export declare function enumerateFolders(collection: Collection, items?: CollectionItem[], prefix?: string): Array<{
|
|
18
|
+
folderPath: string;
|
|
19
|
+
requestCount: number;
|
|
20
|
+
}>;
|
|
21
|
+
/** Recursively count request items in an item list. */
|
|
22
|
+
export declare function countRequests(items: CollectionItem[]): number;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Generic Tool Dispatcher
|
|
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.
|
|
7
|
+
*
|
|
8
|
+
* The four run-* tools (run_request, run_folder, run_collection, run_suite)
|
|
9
|
+
* use different execution back-ends in each server and are therefore delegated
|
|
10
|
+
* 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
|
+
import type { ITestSuiteService } from '../infrastructure/test-suite/interfaces';
|
|
16
|
+
import type { Collection, ICollectionService } from '../types/collection';
|
|
17
|
+
import type { IEnvironmentConfigService } from '../types/environment-config';
|
|
18
|
+
import type { McpRunStore } from './mcp-run-store';
|
|
19
|
+
import { type GenericToolName } from './mcp-tool-schemas';
|
|
20
|
+
export interface McpDispatchServices {
|
|
21
|
+
collection: ICollectionService;
|
|
22
|
+
testSuite: ITestSuiteService;
|
|
23
|
+
environmentConfig: IEnvironmentConfigService;
|
|
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
|
+
/** Tools that write to disk and should bust the MCP tool-list cache after execution. */
|
|
37
|
+
export declare const CACHE_BUSTING_TOOLS: Set<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Dispatch one generic (argument-selected) MCP tool.
|
|
40
|
+
*
|
|
41
|
+
* @param tool The tool name constant from GENERIC_TOOL_NAMES.
|
|
42
|
+
* @param args Raw arguments object from the MCP tools/call payload.
|
|
43
|
+
* @param services Live service instances from either server's DI container.
|
|
44
|
+
* @param runStore The caller's McpRunStore instance (each server owns one).
|
|
45
|
+
* @param callbacks Implementation-specific run-* execution callbacks.
|
|
46
|
+
*/
|
|
47
|
+
export declare function dispatchGenericTool(tool: GenericToolName, args: Record<string, unknown>, services: McpDispatchServices, runStore: McpRunStore, callbacks: McpRunCallbacks): Promise<unknown>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Async Run Store
|
|
3
|
+
*
|
|
4
|
+
* Shared in-memory store for async run records. Both the embedded core runtime
|
|
5
|
+
* and the VS Code extension MCP server import this class so the record shape
|
|
6
|
+
* and helper operations stay identical and there is only one implementation
|
|
7
|
+
* to maintain.
|
|
8
|
+
*/
|
|
9
|
+
export interface McpRunRecord {
|
|
10
|
+
id: string;
|
|
11
|
+
status: 'running' | 'completed' | 'failed';
|
|
12
|
+
suiteName: string;
|
|
13
|
+
startedAt: number;
|
|
14
|
+
completedAt?: number;
|
|
15
|
+
progress: {
|
|
16
|
+
completed: number;
|
|
17
|
+
total: number;
|
|
18
|
+
};
|
|
19
|
+
summary: {
|
|
20
|
+
passed: number;
|
|
21
|
+
failed: number;
|
|
22
|
+
total: number;
|
|
23
|
+
allPassed: boolean;
|
|
24
|
+
};
|
|
25
|
+
failedRequests: object[];
|
|
26
|
+
allResults: object[];
|
|
27
|
+
reportPath: string | null;
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class McpRunStore {
|
|
31
|
+
private readonly store;
|
|
32
|
+
newId(): string;
|
|
33
|
+
/** Allocate a new record, register it, and return it. */
|
|
34
|
+
create(label: string, totalRequests: number): McpRunRecord;
|
|
35
|
+
get(id: string): McpRunRecord | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Return the record for the supplied run id, throwing a descriptive error if
|
|
38
|
+
* the id is missing, not a string, or has expired.
|
|
39
|
+
*/
|
|
40
|
+
require(runId: unknown): McpRunRecord;
|
|
41
|
+
/** Remove records older than the TTL. Called automatically before each create(). */
|
|
42
|
+
prune(): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool List Builder
|
|
3
|
+
*
|
|
4
|
+
* Single implementation of the tools/list response builder shared by both the
|
|
5
|
+
* embedded core runtime and the VS Code extension's McpToolRegistry.
|
|
6
|
+
*
|
|
7
|
+
* Also exports cursor pagination helpers used by both HTTP servers.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpConfig } from '../infrastructure/config';
|
|
10
|
+
import type { TestSuite } from '../infrastructure/test-suite/interfaces';
|
|
11
|
+
import type { Collection } from '../types/collection';
|
|
12
|
+
export interface McpTool {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
inputSchema: object;
|
|
16
|
+
}
|
|
17
|
+
/** Remove tools that share an identical name, keeping the first occurrence. */
|
|
18
|
+
export declare function dedupeToolsByName(tools: McpTool[]): McpTool[];
|
|
19
|
+
/** Encode a numeric offset as an opaque base64url cursor string. */
|
|
20
|
+
export declare function encodeCursor(offset: number): string;
|
|
21
|
+
/** Decode a cursor produced by encodeCursor; returns 0 for any invalid/absent value. */
|
|
22
|
+
export declare function decodeCursor(cursor: string | undefined): number;
|
|
23
|
+
/**
|
|
24
|
+
* Build the full tools/list payload from pre-filtered collections and suites.
|
|
25
|
+
*
|
|
26
|
+
* The caller is responsible for applying exclusion filters before passing the
|
|
27
|
+
* arrays here. This function is pure — it reads no disk state.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildMcpToolList(collections: Collection[], suites: TestSuite[], config: McpConfig): McpTool[];
|
|
@@ -196,6 +196,36 @@ export declare const GENERIC_TOOL_NAMES: {
|
|
|
196
196
|
readonly getFailedRequests: "get_failed_requests";
|
|
197
197
|
readonly getRequestResult: "get_request_result";
|
|
198
198
|
readonly setVariable: "set_variable";
|
|
199
|
+
readonly createCollection: "create_collection";
|
|
200
|
+
readonly renameCollection: "rename_collection";
|
|
201
|
+
readonly deleteCollection: "delete_collection";
|
|
202
|
+
readonly duplicateCollection: "duplicate_collection";
|
|
203
|
+
readonly createFolder: "create_folder";
|
|
204
|
+
readonly deleteFolder: "delete_folder";
|
|
205
|
+
readonly createRequest: "create_request";
|
|
206
|
+
readonly updateRequest: "update_request";
|
|
207
|
+
readonly deleteRequest: "delete_request";
|
|
208
|
+
readonly getRequestScript: "get_request_script";
|
|
209
|
+
readonly setRequestScript: "set_request_script";
|
|
210
|
+
readonly reorderCollectionItems: "reorder_collection_items";
|
|
211
|
+
readonly listSuites: "list_suites";
|
|
212
|
+
readonly getSuite: "get_suite";
|
|
213
|
+
readonly createSuite: "create_suite";
|
|
214
|
+
readonly updateSuiteConfig: "update_suite_config";
|
|
215
|
+
readonly addSuiteRequests: "add_suite_requests";
|
|
216
|
+
readonly removeSuiteRequest: "remove_suite_request";
|
|
217
|
+
readonly reorderSuiteRequests: "reorder_suite_requests";
|
|
218
|
+
readonly duplicateSuite: "duplicate_suite";
|
|
219
|
+
readonly deleteSuite: "delete_suite";
|
|
220
|
+
readonly listEnvironments: "list_environments";
|
|
221
|
+
readonly getEnvironmentVariables: "get_environment_variables";
|
|
222
|
+
readonly selectEnvironment: "select_environment";
|
|
223
|
+
readonly createEnvironment: "create_environment";
|
|
224
|
+
readonly deleteEnvironment: "delete_environment";
|
|
225
|
+
readonly setEnvironmentVariable: "set_environment_variable";
|
|
226
|
+
readonly unsetEnvironmentVariable: "unset_environment_variable";
|
|
227
|
+
readonly setGlobalVariable: "set_global_variable";
|
|
228
|
+
readonly getGlobals: "get_globals";
|
|
199
229
|
};
|
|
200
230
|
export type GenericToolName = (typeof GENERIC_TOOL_NAMES)[keyof typeof GENERIC_TOOL_NAMES];
|
|
201
231
|
interface GenericToolDef {
|
|
@@ -105,6 +105,19 @@ export interface ICollectionVariableManager {
|
|
|
105
105
|
clearCollectionVariables(collectionId: string): void;
|
|
106
106
|
getCollectionVariableLocals(collectionId: string): Record<string, string>;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Collection ordering operations
|
|
110
|
+
*/
|
|
111
|
+
export interface IOrderingManager {
|
|
112
|
+
reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Request script read/write operations
|
|
116
|
+
*/
|
|
117
|
+
export interface IScriptManager {
|
|
118
|
+
getRequestScript(collectionId: string, requestId: string, phase: 'pre-request' | 'post-response'): string | undefined;
|
|
119
|
+
setRequestScript(collectionId: string, requestId: string, phase: 'pre-request' | 'post-response', source: string): Promise<boolean>;
|
|
120
|
+
}
|
|
108
121
|
/**
|
|
109
122
|
* Collection import/export operations
|
|
110
123
|
*/
|
|
@@ -116,7 +129,7 @@ export interface ICollectionImportExport {
|
|
|
116
129
|
/**
|
|
117
130
|
* Full collection service interface
|
|
118
131
|
*/
|
|
119
|
-
export interface ICollectionService extends ICollectionReader, ICollectionWriter, IRequestManager, IFolderManager, ICollectionVariableManager, ICollectionImportExport {
|
|
132
|
+
export interface ICollectionService extends ICollectionReader, ICollectionWriter, IRequestManager, IFolderManager, IOrderingManager, IScriptManager, ICollectionVariableManager, ICollectionImportExport {
|
|
120
133
|
dispose(): void;
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
@@ -116,6 +116,17 @@ export interface IVariableManager {
|
|
|
116
116
|
export interface IEnvironmentConfigService extends IEnvironmentConfigReader, IEnvironmentConfigWriter, IEnvironmentSelector, IVariableResolver, IVariableManager {
|
|
117
117
|
loadConfigs(): void;
|
|
118
118
|
exportEnvironmentsToFolder(outDir: string, mergeGlobals?: boolean): void;
|
|
119
|
+
/** List all environments with their variables (values included). */
|
|
120
|
+
getAllEnvironments(): Array<{
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
active: boolean;
|
|
124
|
+
variables: Record<string, string>;
|
|
125
|
+
}>;
|
|
126
|
+
/** Create a new environment file. */
|
|
127
|
+
createEnvironment(name: string): Promise<void>;
|
|
128
|
+
/** Delete an environment file permanently. */
|
|
129
|
+
deleteEnvironment(id: string): Promise<void>;
|
|
119
130
|
/** Read a single secret variable from SecretStorage. */
|
|
120
131
|
getSecretVariable(envName: string, key: string): Promise<string | undefined>;
|
|
121
132
|
/** Store a secret variable value in SecretStorage. */
|
package/package.json
CHANGED