mock-mcp 0.3.0 → 0.5.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.
Files changed (44) hide show
  1. package/README.md +217 -128
  2. package/dist/adapter/index.cjs +712 -0
  3. package/dist/adapter/index.d.cts +55 -0
  4. package/dist/adapter/index.d.ts +55 -0
  5. package/dist/adapter/index.js +672 -0
  6. package/dist/client/connect.cjs +913 -0
  7. package/dist/client/connect.d.cts +211 -0
  8. package/dist/client/connect.d.ts +209 -6
  9. package/dist/client/connect.js +867 -10
  10. package/dist/client/index.cjs +914 -0
  11. package/dist/client/index.d.cts +4 -0
  12. package/dist/client/index.d.ts +4 -2
  13. package/dist/client/index.js +873 -2
  14. package/dist/daemon/index.cjs +667 -0
  15. package/dist/daemon/index.d.cts +62 -0
  16. package/dist/daemon/index.d.ts +62 -0
  17. package/dist/daemon/index.js +628 -0
  18. package/dist/discovery-Dc2LdF8q.d.cts +105 -0
  19. package/dist/discovery-Dc2LdF8q.d.ts +105 -0
  20. package/dist/index.cjs +2238 -0
  21. package/dist/index.d.cts +472 -0
  22. package/dist/index.d.ts +472 -10
  23. package/dist/index.js +2185 -53
  24. package/dist/protocol-CiwaQFOt.d.ts +239 -0
  25. package/dist/protocol-xZu-wb0n.d.cts +239 -0
  26. package/dist/shared/index.cjs +386 -0
  27. package/dist/shared/index.d.cts +4 -0
  28. package/dist/shared/index.d.ts +4 -0
  29. package/dist/shared/index.js +310 -0
  30. package/dist/types-BKREdsyr.d.cts +32 -0
  31. package/dist/types-BKREdsyr.d.ts +32 -0
  32. package/package.json +44 -4
  33. package/dist/client/batch-mock-collector.d.ts +0 -87
  34. package/dist/client/batch-mock-collector.js +0 -223
  35. package/dist/client/util.d.ts +0 -1
  36. package/dist/client/util.js +0 -3
  37. package/dist/connect.cjs +0 -299
  38. package/dist/connect.d.cts +0 -95
  39. package/dist/server/index.d.ts +0 -1
  40. package/dist/server/index.js +0 -1
  41. package/dist/server/test-mock-mcp-server.d.ts +0 -73
  42. package/dist/server/test-mock-mcp-server.js +0 -392
  43. package/dist/types.d.ts +0 -42
  44. package/dist/types.js +0 -2
@@ -0,0 +1,239 @@
1
+ import { M as MockRequestDescriptor, a as MockResponseDescriptor } from './types-BKREdsyr.js';
2
+
3
+ /**
4
+ * Protocol definitions for mock-mcp Daemon communication.
5
+ *
6
+ * Defines message types for:
7
+ * - Test channel (WebSocket /test): Test process ↔ Daemon
8
+ * - Control channel (HTTP /control): Adapter ↔ Daemon (JSON-RPC)
9
+ */
10
+
11
+ declare const HELLO_TEST: "HELLO_TEST";
12
+ declare const HELLO_ACK: "HELLO_ACK";
13
+ declare const BATCH_MOCK_REQUEST: "BATCH_MOCK_REQUEST";
14
+ declare const BATCH_MOCK_RESULT: "BATCH_MOCK_RESULT";
15
+ declare const HEARTBEAT: "HEARTBEAT";
16
+ declare const HEARTBEAT_ACK: "HEARTBEAT_ACK";
17
+ declare const RPC_GET_STATUS: "getStatus";
18
+ declare const RPC_LIST_RUNS: "listRuns";
19
+ declare const RPC_CLAIM_NEXT_BATCH: "claimNextBatch";
20
+ declare const RPC_PROVIDE_BATCH: "provideBatch";
21
+ declare const RPC_RELEASE_BATCH: "releaseBatch";
22
+ declare const RPC_GET_BATCH: "getBatch";
23
+ /**
24
+ * HELLO message from test process to daemon.
25
+ * Must be the first message after WebSocket connection.
26
+ */
27
+ interface HelloTestMessage {
28
+ type: typeof HELLO_TEST;
29
+ token: string;
30
+ runId: string;
31
+ pid: number;
32
+ cwd: string;
33
+ testMeta?: {
34
+ testFile?: string;
35
+ testName?: string;
36
+ };
37
+ }
38
+ /**
39
+ * Acknowledgment of HELLO from daemon.
40
+ */
41
+ interface HelloAckMessage {
42
+ type: typeof HELLO_ACK;
43
+ runId: string;
44
+ }
45
+ /**
46
+ * Batch mock request from test process.
47
+ */
48
+ interface BatchMockRequestMessage {
49
+ type: typeof BATCH_MOCK_REQUEST;
50
+ runId: string;
51
+ requests: MockRequestDescriptor[];
52
+ }
53
+ /**
54
+ * Batch mock result from daemon to test process.
55
+ */
56
+ interface BatchMockResultMessage {
57
+ type: typeof BATCH_MOCK_RESULT;
58
+ batchId: string;
59
+ mocks: MockResponseDescriptor[];
60
+ }
61
+ /**
62
+ * Heartbeat from test process.
63
+ */
64
+ interface HeartbeatMessage {
65
+ type: typeof HEARTBEAT;
66
+ runId: string;
67
+ }
68
+ /**
69
+ * Heartbeat acknowledgment from daemon.
70
+ */
71
+ interface HeartbeatAckMessage {
72
+ type: typeof HEARTBEAT_ACK;
73
+ runId: string;
74
+ }
75
+ /**
76
+ * Union type for all test channel messages (from test process).
77
+ */
78
+ type TestChannelIncomingMessage = HelloTestMessage | BatchMockRequestMessage | HeartbeatMessage;
79
+ /**
80
+ * Union type for all test channel messages (from daemon).
81
+ */
82
+ type TestChannelOutgoingMessage = HelloAckMessage | BatchMockResultMessage | HeartbeatAckMessage;
83
+ /**
84
+ * JSON-RPC 2.0 request structure.
85
+ */
86
+ interface JsonRpcRequest {
87
+ jsonrpc: "2.0";
88
+ id: string | number;
89
+ method: string;
90
+ params?: Record<string, unknown>;
91
+ }
92
+ /**
93
+ * JSON-RPC 2.0 response structure.
94
+ */
95
+ interface JsonRpcResponse {
96
+ jsonrpc: "2.0";
97
+ id: string | number;
98
+ result?: unknown;
99
+ error?: JsonRpcError;
100
+ }
101
+ interface JsonRpcError {
102
+ code: number;
103
+ message: string;
104
+ data?: unknown;
105
+ }
106
+ declare const RPC_ERROR_PARSE = -32700;
107
+ declare const RPC_ERROR_INVALID_REQUEST = -32600;
108
+ declare const RPC_ERROR_METHOD_NOT_FOUND = -32601;
109
+ declare const RPC_ERROR_INVALID_PARAMS = -32602;
110
+ declare const RPC_ERROR_INTERNAL = -32603;
111
+ declare const RPC_ERROR_NOT_FOUND = -32000;
112
+ declare const RPC_ERROR_UNAUTHORIZED = -32001;
113
+ declare const RPC_ERROR_CONFLICT = -32002;
114
+ declare const RPC_ERROR_EXPIRED = -32003;
115
+ /**
116
+ * Parameters for claimNextBatch RPC.
117
+ */
118
+ interface ClaimNextBatchParams {
119
+ adapterId: string;
120
+ runId?: string;
121
+ leaseMs?: number;
122
+ }
123
+ /**
124
+ * Result of claimNextBatch RPC.
125
+ */
126
+ interface ClaimNextBatchResult {
127
+ batchId: string;
128
+ runId: string;
129
+ requests: MockRequestDescriptor[];
130
+ claimToken: string;
131
+ leaseUntil: number;
132
+ }
133
+ /**
134
+ * Parameters for provideBatch RPC.
135
+ */
136
+ interface ProvideBatchParams {
137
+ adapterId: string;
138
+ batchId: string;
139
+ claimToken: string;
140
+ mocks: MockResponseDescriptor[];
141
+ }
142
+ /**
143
+ * Result of provideBatch RPC.
144
+ */
145
+ interface ProvideBatchResult {
146
+ ok: boolean;
147
+ message?: string;
148
+ }
149
+ /**
150
+ * Parameters for releaseBatch RPC.
151
+ */
152
+ interface ReleaseBatchParams {
153
+ adapterId: string;
154
+ batchId: string;
155
+ claimToken: string;
156
+ reason?: string;
157
+ }
158
+ /**
159
+ * Parameters for getBatch RPC.
160
+ */
161
+ interface GetBatchParams {
162
+ batchId: string;
163
+ }
164
+ /**
165
+ * Result of getStatus RPC.
166
+ */
167
+ interface GetStatusResult {
168
+ version: string;
169
+ projectId: string;
170
+ projectRoot: string;
171
+ pid: number;
172
+ uptime: number;
173
+ runs: number;
174
+ pending: number;
175
+ claimed: number;
176
+ totalBatches: number;
177
+ }
178
+ /**
179
+ * Result of listRuns RPC.
180
+ */
181
+ interface ListRunsResult {
182
+ runs: RunInfo[];
183
+ }
184
+ interface RunInfo {
185
+ runId: string;
186
+ pid: number;
187
+ cwd: string;
188
+ startedAt: string;
189
+ lastSeen: number;
190
+ pendingBatches: number;
191
+ testMeta?: {
192
+ testFile?: string;
193
+ testName?: string;
194
+ };
195
+ }
196
+ /**
197
+ * Result of getBatch RPC.
198
+ */
199
+ interface GetBatchResult {
200
+ batchId: string;
201
+ runId: string;
202
+ requests: MockRequestDescriptor[];
203
+ status: BatchStatus;
204
+ createdAt: number;
205
+ claim?: {
206
+ adapterId: string;
207
+ leaseUntil: number;
208
+ };
209
+ }
210
+ type BatchStatus = "pending" | "claimed" | "fulfilled" | "expired";
211
+ interface RunRecord {
212
+ runId: string;
213
+ pid: number;
214
+ cwd: string;
215
+ startedAt: string;
216
+ lastSeen: number;
217
+ testMeta?: {
218
+ testFile?: string;
219
+ testName?: string;
220
+ };
221
+ }
222
+ interface BatchRecord {
223
+ batchId: string;
224
+ runId: string;
225
+ requests: MockRequestDescriptor[];
226
+ createdAt: number;
227
+ status: BatchStatus;
228
+ claim?: {
229
+ adapterId: string;
230
+ claimToken: string;
231
+ leaseUntil: number;
232
+ };
233
+ }
234
+ declare function isHelloTestMessage(msg: unknown): msg is HelloTestMessage;
235
+ declare function isBatchMockRequestMessage(msg: unknown): msg is BatchMockRequestMessage;
236
+ declare function isHeartbeatMessage(msg: unknown): msg is HeartbeatMessage;
237
+ declare function isJsonRpcRequest(msg: unknown): msg is JsonRpcRequest;
238
+
239
+ export { type HeartbeatMessage as A, BATCH_MOCK_REQUEST as B, type HeartbeatAckMessage as C, type TestChannelOutgoingMessage as D, type JsonRpcResponse as E, type JsonRpcError as F, type ClaimNextBatchParams as G, HELLO_TEST as H, type ClaimNextBatchResult as I, type JsonRpcRequest as J, type ProvideBatchResult as K, type ReleaseBatchParams as L, type GetBatchParams as M, type GetStatusResult as N, type ListRunsResult as O, type ProvideBatchParams as P, type RunInfo as Q, RPC_GET_STATUS as R, type GetBatchResult as S, type TestChannelIncomingMessage as T, type BatchStatus as U, type RunRecord as V, type BatchRecord as W, HELLO_ACK as a, BATCH_MOCK_RESULT as b, HEARTBEAT as c, HEARTBEAT_ACK as d, RPC_LIST_RUNS as e, RPC_CLAIM_NEXT_BATCH as f, RPC_PROVIDE_BATCH as g, RPC_RELEASE_BATCH as h, RPC_GET_BATCH as i, RPC_ERROR_PARSE as j, RPC_ERROR_INVALID_REQUEST as k, RPC_ERROR_METHOD_NOT_FOUND as l, RPC_ERROR_INVALID_PARAMS as m, RPC_ERROR_INTERNAL as n, RPC_ERROR_NOT_FOUND as o, RPC_ERROR_UNAUTHORIZED as p, RPC_ERROR_CONFLICT as q, RPC_ERROR_EXPIRED as r, isHelloTestMessage as s, isBatchMockRequestMessage as t, isHeartbeatMessage as u, isJsonRpcRequest as v, type HelloTestMessage as w, type HelloAckMessage as x, type BatchMockRequestMessage as y, type BatchMockResultMessage as z };
@@ -0,0 +1,239 @@
1
+ import { M as MockRequestDescriptor, a as MockResponseDescriptor } from './types-BKREdsyr.cjs';
2
+
3
+ /**
4
+ * Protocol definitions for mock-mcp Daemon communication.
5
+ *
6
+ * Defines message types for:
7
+ * - Test channel (WebSocket /test): Test process ↔ Daemon
8
+ * - Control channel (HTTP /control): Adapter ↔ Daemon (JSON-RPC)
9
+ */
10
+
11
+ declare const HELLO_TEST: "HELLO_TEST";
12
+ declare const HELLO_ACK: "HELLO_ACK";
13
+ declare const BATCH_MOCK_REQUEST: "BATCH_MOCK_REQUEST";
14
+ declare const BATCH_MOCK_RESULT: "BATCH_MOCK_RESULT";
15
+ declare const HEARTBEAT: "HEARTBEAT";
16
+ declare const HEARTBEAT_ACK: "HEARTBEAT_ACK";
17
+ declare const RPC_GET_STATUS: "getStatus";
18
+ declare const RPC_LIST_RUNS: "listRuns";
19
+ declare const RPC_CLAIM_NEXT_BATCH: "claimNextBatch";
20
+ declare const RPC_PROVIDE_BATCH: "provideBatch";
21
+ declare const RPC_RELEASE_BATCH: "releaseBatch";
22
+ declare const RPC_GET_BATCH: "getBatch";
23
+ /**
24
+ * HELLO message from test process to daemon.
25
+ * Must be the first message after WebSocket connection.
26
+ */
27
+ interface HelloTestMessage {
28
+ type: typeof HELLO_TEST;
29
+ token: string;
30
+ runId: string;
31
+ pid: number;
32
+ cwd: string;
33
+ testMeta?: {
34
+ testFile?: string;
35
+ testName?: string;
36
+ };
37
+ }
38
+ /**
39
+ * Acknowledgment of HELLO from daemon.
40
+ */
41
+ interface HelloAckMessage {
42
+ type: typeof HELLO_ACK;
43
+ runId: string;
44
+ }
45
+ /**
46
+ * Batch mock request from test process.
47
+ */
48
+ interface BatchMockRequestMessage {
49
+ type: typeof BATCH_MOCK_REQUEST;
50
+ runId: string;
51
+ requests: MockRequestDescriptor[];
52
+ }
53
+ /**
54
+ * Batch mock result from daemon to test process.
55
+ */
56
+ interface BatchMockResultMessage {
57
+ type: typeof BATCH_MOCK_RESULT;
58
+ batchId: string;
59
+ mocks: MockResponseDescriptor[];
60
+ }
61
+ /**
62
+ * Heartbeat from test process.
63
+ */
64
+ interface HeartbeatMessage {
65
+ type: typeof HEARTBEAT;
66
+ runId: string;
67
+ }
68
+ /**
69
+ * Heartbeat acknowledgment from daemon.
70
+ */
71
+ interface HeartbeatAckMessage {
72
+ type: typeof HEARTBEAT_ACK;
73
+ runId: string;
74
+ }
75
+ /**
76
+ * Union type for all test channel messages (from test process).
77
+ */
78
+ type TestChannelIncomingMessage = HelloTestMessage | BatchMockRequestMessage | HeartbeatMessage;
79
+ /**
80
+ * Union type for all test channel messages (from daemon).
81
+ */
82
+ type TestChannelOutgoingMessage = HelloAckMessage | BatchMockResultMessage | HeartbeatAckMessage;
83
+ /**
84
+ * JSON-RPC 2.0 request structure.
85
+ */
86
+ interface JsonRpcRequest {
87
+ jsonrpc: "2.0";
88
+ id: string | number;
89
+ method: string;
90
+ params?: Record<string, unknown>;
91
+ }
92
+ /**
93
+ * JSON-RPC 2.0 response structure.
94
+ */
95
+ interface JsonRpcResponse {
96
+ jsonrpc: "2.0";
97
+ id: string | number;
98
+ result?: unknown;
99
+ error?: JsonRpcError;
100
+ }
101
+ interface JsonRpcError {
102
+ code: number;
103
+ message: string;
104
+ data?: unknown;
105
+ }
106
+ declare const RPC_ERROR_PARSE = -32700;
107
+ declare const RPC_ERROR_INVALID_REQUEST = -32600;
108
+ declare const RPC_ERROR_METHOD_NOT_FOUND = -32601;
109
+ declare const RPC_ERROR_INVALID_PARAMS = -32602;
110
+ declare const RPC_ERROR_INTERNAL = -32603;
111
+ declare const RPC_ERROR_NOT_FOUND = -32000;
112
+ declare const RPC_ERROR_UNAUTHORIZED = -32001;
113
+ declare const RPC_ERROR_CONFLICT = -32002;
114
+ declare const RPC_ERROR_EXPIRED = -32003;
115
+ /**
116
+ * Parameters for claimNextBatch RPC.
117
+ */
118
+ interface ClaimNextBatchParams {
119
+ adapterId: string;
120
+ runId?: string;
121
+ leaseMs?: number;
122
+ }
123
+ /**
124
+ * Result of claimNextBatch RPC.
125
+ */
126
+ interface ClaimNextBatchResult {
127
+ batchId: string;
128
+ runId: string;
129
+ requests: MockRequestDescriptor[];
130
+ claimToken: string;
131
+ leaseUntil: number;
132
+ }
133
+ /**
134
+ * Parameters for provideBatch RPC.
135
+ */
136
+ interface ProvideBatchParams {
137
+ adapterId: string;
138
+ batchId: string;
139
+ claimToken: string;
140
+ mocks: MockResponseDescriptor[];
141
+ }
142
+ /**
143
+ * Result of provideBatch RPC.
144
+ */
145
+ interface ProvideBatchResult {
146
+ ok: boolean;
147
+ message?: string;
148
+ }
149
+ /**
150
+ * Parameters for releaseBatch RPC.
151
+ */
152
+ interface ReleaseBatchParams {
153
+ adapterId: string;
154
+ batchId: string;
155
+ claimToken: string;
156
+ reason?: string;
157
+ }
158
+ /**
159
+ * Parameters for getBatch RPC.
160
+ */
161
+ interface GetBatchParams {
162
+ batchId: string;
163
+ }
164
+ /**
165
+ * Result of getStatus RPC.
166
+ */
167
+ interface GetStatusResult {
168
+ version: string;
169
+ projectId: string;
170
+ projectRoot: string;
171
+ pid: number;
172
+ uptime: number;
173
+ runs: number;
174
+ pending: number;
175
+ claimed: number;
176
+ totalBatches: number;
177
+ }
178
+ /**
179
+ * Result of listRuns RPC.
180
+ */
181
+ interface ListRunsResult {
182
+ runs: RunInfo[];
183
+ }
184
+ interface RunInfo {
185
+ runId: string;
186
+ pid: number;
187
+ cwd: string;
188
+ startedAt: string;
189
+ lastSeen: number;
190
+ pendingBatches: number;
191
+ testMeta?: {
192
+ testFile?: string;
193
+ testName?: string;
194
+ };
195
+ }
196
+ /**
197
+ * Result of getBatch RPC.
198
+ */
199
+ interface GetBatchResult {
200
+ batchId: string;
201
+ runId: string;
202
+ requests: MockRequestDescriptor[];
203
+ status: BatchStatus;
204
+ createdAt: number;
205
+ claim?: {
206
+ adapterId: string;
207
+ leaseUntil: number;
208
+ };
209
+ }
210
+ type BatchStatus = "pending" | "claimed" | "fulfilled" | "expired";
211
+ interface RunRecord {
212
+ runId: string;
213
+ pid: number;
214
+ cwd: string;
215
+ startedAt: string;
216
+ lastSeen: number;
217
+ testMeta?: {
218
+ testFile?: string;
219
+ testName?: string;
220
+ };
221
+ }
222
+ interface BatchRecord {
223
+ batchId: string;
224
+ runId: string;
225
+ requests: MockRequestDescriptor[];
226
+ createdAt: number;
227
+ status: BatchStatus;
228
+ claim?: {
229
+ adapterId: string;
230
+ claimToken: string;
231
+ leaseUntil: number;
232
+ };
233
+ }
234
+ declare function isHelloTestMessage(msg: unknown): msg is HelloTestMessage;
235
+ declare function isBatchMockRequestMessage(msg: unknown): msg is BatchMockRequestMessage;
236
+ declare function isHeartbeatMessage(msg: unknown): msg is HeartbeatMessage;
237
+ declare function isJsonRpcRequest(msg: unknown): msg is JsonRpcRequest;
238
+
239
+ export { type HeartbeatMessage as A, BATCH_MOCK_REQUEST as B, type HeartbeatAckMessage as C, type TestChannelOutgoingMessage as D, type JsonRpcResponse as E, type JsonRpcError as F, type ClaimNextBatchParams as G, HELLO_TEST as H, type ClaimNextBatchResult as I, type JsonRpcRequest as J, type ProvideBatchResult as K, type ReleaseBatchParams as L, type GetBatchParams as M, type GetStatusResult as N, type ListRunsResult as O, type ProvideBatchParams as P, type RunInfo as Q, RPC_GET_STATUS as R, type GetBatchResult as S, type TestChannelIncomingMessage as T, type BatchStatus as U, type RunRecord as V, type BatchRecord as W, HELLO_ACK as a, BATCH_MOCK_RESULT as b, HEARTBEAT as c, HEARTBEAT_ACK as d, RPC_LIST_RUNS as e, RPC_CLAIM_NEXT_BATCH as f, RPC_PROVIDE_BATCH as g, RPC_RELEASE_BATCH as h, RPC_GET_BATCH as i, RPC_ERROR_PARSE as j, RPC_ERROR_INVALID_REQUEST as k, RPC_ERROR_METHOD_NOT_FOUND as l, RPC_ERROR_INVALID_PARAMS as m, RPC_ERROR_INTERNAL as n, RPC_ERROR_NOT_FOUND as o, RPC_ERROR_UNAUTHORIZED as p, RPC_ERROR_CONFLICT as q, RPC_ERROR_EXPIRED as r, isHelloTestMessage as s, isBatchMockRequestMessage as t, isHeartbeatMessage as u, isJsonRpcRequest as v, type HelloTestMessage as w, type HelloAckMessage as x, type BatchMockRequestMessage as y, type BatchMockResultMessage as z };