@vexyo/core 0.1.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/LICENSE +202 -0
- package/README.md +11 -0
- package/dist/index.d.ts +400 -0
- package/dist/index.js +1406 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @vexyo/core
|
|
2
|
+
|
|
3
|
+
Conformance and regression engine for [vexyo](https://github.com/vexyohq/vexyo) — testing Model
|
|
4
|
+
Context Protocol (MCP) servers.
|
|
5
|
+
|
|
6
|
+
Defines the `Rule` abstraction, the `Runner` (which owns the connection lifecycle over stdio and
|
|
7
|
+
Streamable HTTP), the `RunResult` contract that reporters consume, and the golden-set regression
|
|
8
|
+
engine (record + drift detection with deterministic, Prettier-stable goldens). Built on the
|
|
9
|
+
official `@modelcontextprotocol/sdk`.
|
|
10
|
+
|
|
11
|
+
Part of the [vexyo](https://github.com/vexyohq/vexyo) monorepo. Apache-2.0.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { Implementation, ServerCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The public result contract consumed by every reporter.
|
|
7
|
+
*
|
|
8
|
+
* CLAUDE.md hard rule #7: reporters consume `RunResult` only; breaking this
|
|
9
|
+
* shape is a semver-major event. Keep it stable and additive.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* MCP spec versions this harness knows about. A run targets exactly one
|
|
13
|
+
* (CLAUDE.md hard rule #2 — spec versions never mix). Only the stable version
|
|
14
|
+
* is wired up today; `2026-07-28` is a scaffolding slot for the RC.
|
|
15
|
+
*/
|
|
16
|
+
type SpecVersion = '2025-11-25' | '2026-07-28';
|
|
17
|
+
/** The stable spec version this build fully supports. */
|
|
18
|
+
declare const STABLE_SPEC_VERSION: SpecVersion;
|
|
19
|
+
type Severity = 'error' | 'warning' | 'info';
|
|
20
|
+
type Category = 'initialization' | 'discovery' | 'error-semantics' | 'transport' | 'security' | 'regression';
|
|
21
|
+
/**
|
|
22
|
+
* Outcome of running one rule:
|
|
23
|
+
* - `pass` — rule ran and produced no findings.
|
|
24
|
+
* - `fail` — rule produced at least one `error`-severity finding.
|
|
25
|
+
* - `warn` — rule produced findings, but none above `warning`/`info` severity.
|
|
26
|
+
* - `skip` — rule was not applicable (e.g. capability not advertised).
|
|
27
|
+
* - `error` — rule threw unexpectedly (server crash or harness bug).
|
|
28
|
+
*/
|
|
29
|
+
type RuleStatus = 'pass' | 'fail' | 'warn' | 'skip' | 'error';
|
|
30
|
+
/** A single problem detected by a rule. A rule with zero findings passed. */
|
|
31
|
+
interface Finding {
|
|
32
|
+
ruleId: string;
|
|
33
|
+
severity: Severity;
|
|
34
|
+
/** What is wrong. */
|
|
35
|
+
message: string;
|
|
36
|
+
/** What to do next (CLAUDE.md: every user-facing failure states the fix). */
|
|
37
|
+
remediation: string;
|
|
38
|
+
/** Spec section citation, e.g. "Base Protocol §Lifecycle". */
|
|
39
|
+
specRef: string;
|
|
40
|
+
/** Optional machine-readable context (offending payload, error, etc.). */
|
|
41
|
+
detail?: unknown;
|
|
42
|
+
}
|
|
43
|
+
interface RuleResult {
|
|
44
|
+
ruleId: string;
|
|
45
|
+
title: string;
|
|
46
|
+
category: Category;
|
|
47
|
+
severity: Severity;
|
|
48
|
+
specVersion: SpecVersion;
|
|
49
|
+
/** Spec section citation for this rule, surfaced by reporters. */
|
|
50
|
+
specRef: string;
|
|
51
|
+
status: RuleStatus;
|
|
52
|
+
/**
|
|
53
|
+
* Why the rule was skipped. A skip means either "not applicable" (capability
|
|
54
|
+
* absent) or "a prerequisite is unavailable" (e.g. `tools/list` failed, so
|
|
55
|
+
* rules that consume it skip rather than cascade errors).
|
|
56
|
+
*/
|
|
57
|
+
skipReason?: string;
|
|
58
|
+
findings: Finding[];
|
|
59
|
+
durationMs: number;
|
|
60
|
+
}
|
|
61
|
+
interface RunTarget {
|
|
62
|
+
transport: 'stdio' | 'http';
|
|
63
|
+
/** Human-readable description of what we connected to. */
|
|
64
|
+
description: string;
|
|
65
|
+
}
|
|
66
|
+
interface RunSummary {
|
|
67
|
+
pass: number;
|
|
68
|
+
fail: number;
|
|
69
|
+
warn: number;
|
|
70
|
+
skip: number;
|
|
71
|
+
error: number;
|
|
72
|
+
total: number;
|
|
73
|
+
}
|
|
74
|
+
interface RunResult {
|
|
75
|
+
specVersion: SpecVersion;
|
|
76
|
+
target: RunTarget;
|
|
77
|
+
/** ISO-8601 timestamps. */
|
|
78
|
+
startedAt: string;
|
|
79
|
+
finishedAt: string;
|
|
80
|
+
results: RuleResult[];
|
|
81
|
+
summary: RunSummary;
|
|
82
|
+
/** 0 = pass, 1 = findings at/above threshold, 2 = harness/config error. */
|
|
83
|
+
exitCode: 0 | 1 | 2;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Which transport a connection uses, plus transport-specific facts rules may inspect. */
|
|
87
|
+
type TransportInfo = {
|
|
88
|
+
kind: 'stdio';
|
|
89
|
+
} | {
|
|
90
|
+
kind: 'http';
|
|
91
|
+
sessionId?: string;
|
|
92
|
+
};
|
|
93
|
+
/** How to spawn a stdio MCP server under test. */
|
|
94
|
+
interface StdioTargetConfig {
|
|
95
|
+
command: string;
|
|
96
|
+
args?: string[];
|
|
97
|
+
cwd?: string;
|
|
98
|
+
env?: Record<string, string>;
|
|
99
|
+
}
|
|
100
|
+
/** How to reach a running Streamable HTTP MCP server. */
|
|
101
|
+
interface HttpTargetConfig {
|
|
102
|
+
url: string;
|
|
103
|
+
headers?: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
/** A connection target: exactly one transport (CLAUDE.md hard rule #2 spirit). */
|
|
106
|
+
type ConnectTarget = {
|
|
107
|
+
transport: 'stdio';
|
|
108
|
+
stdio: StdioTargetConfig;
|
|
109
|
+
} | {
|
|
110
|
+
transport: 'http';
|
|
111
|
+
http: HttpTargetConfig;
|
|
112
|
+
};
|
|
113
|
+
interface ConnectedClient {
|
|
114
|
+
client: Client;
|
|
115
|
+
transport: TransportInfo;
|
|
116
|
+
/** Closes the client connection (and, for stdio, the spawned server process). */
|
|
117
|
+
close: () => Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Everything a rule needs to make its assessment. The runner owns the
|
|
122
|
+
* connection lifecycle; a rule never spawns processes or manages sockets
|
|
123
|
+
* (CLAUDE.md hard rule #1 + architecture note).
|
|
124
|
+
*/
|
|
125
|
+
interface RuleContext {
|
|
126
|
+
/** Connected MCP client (handshake already completed). */
|
|
127
|
+
readonly client: Client;
|
|
128
|
+
/** Server identity captured during initialization. */
|
|
129
|
+
readonly serverInfo: Implementation | undefined;
|
|
130
|
+
/** Capabilities the server advertised during negotiation. */
|
|
131
|
+
readonly capabilities: ServerCapabilities | undefined;
|
|
132
|
+
/** The transport in use, plus transport-specific facts (e.g. HTTP session id). */
|
|
133
|
+
readonly transport: TransportInfo;
|
|
134
|
+
readonly specVersion: SpecVersion;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A rule is a pure, declarative conformance check. It returns the findings it
|
|
138
|
+
* detected; an empty array means the server passed. Applicability is signalled
|
|
139
|
+
* by throwing {@link SkipRule}.
|
|
140
|
+
*/
|
|
141
|
+
interface Rule {
|
|
142
|
+
readonly id: string;
|
|
143
|
+
/** Exactly one spec version (CLAUDE.md hard rule #2). */
|
|
144
|
+
readonly specVersion: SpecVersion;
|
|
145
|
+
readonly category: Category;
|
|
146
|
+
readonly severity: Severity;
|
|
147
|
+
readonly title: string;
|
|
148
|
+
/** Spec section citation surfaced to users, e.g. "Base Protocol §Lifecycle". */
|
|
149
|
+
readonly specRef: string;
|
|
150
|
+
run(ctx: RuleContext): Promise<Finding[]>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Thrown by a rule to declare itself not applicable to this server (e.g. the
|
|
154
|
+
* relevant capability was never advertised). The runner records a `skip`
|
|
155
|
+
* rather than a pass or fail.
|
|
156
|
+
*/
|
|
157
|
+
declare class SkipRule extends Error {
|
|
158
|
+
readonly reason: string;
|
|
159
|
+
constructor(reason: string);
|
|
160
|
+
}
|
|
161
|
+
/** Build a {@link Finding}, prefilling identity fields from the rule. */
|
|
162
|
+
declare function finding(rule: Pick<Rule, 'id' | 'severity' | 'specRef'>, message: string, remediation: string, detail?: unknown): Finding;
|
|
163
|
+
|
|
164
|
+
/** Rules that target the given spec version, in registration order. */
|
|
165
|
+
declare function rulesForSpecVersion(version: SpecVersion): Rule[];
|
|
166
|
+
/** The full catalog (all versions) — used for introspection/tests. */
|
|
167
|
+
declare function allRules(): readonly Rule[];
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Spawn the target server over stdio and complete the MCP handshake using the
|
|
171
|
+
* official SDK (CLAUDE.md hard rule #1). Over stdio the client transport owns
|
|
172
|
+
* the spawned process, so `close()` also terminates the server. Callers must
|
|
173
|
+
* always `close()` the returned handle to avoid leaking the child process.
|
|
174
|
+
*/
|
|
175
|
+
declare function connectStdio(target: StdioTargetConfig): Promise<ConnectedClient>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Connect to a running Streamable HTTP MCP server and complete the handshake
|
|
179
|
+
* using the official SDK. The server is not ours to manage — over HTTP the
|
|
180
|
+
* runner owns only the connection: `connect()` performs initialize (and the SDK
|
|
181
|
+
* captures the `Mcp-Session-Id` the server issues), `close()` ends the session
|
|
182
|
+
* (the SDK sends the terminating `DELETE`). Rules never touch the session or
|
|
183
|
+
* HTTP verbs; the negotiated session id is surfaced via {@link ConnectedClient.transport}.
|
|
184
|
+
*/
|
|
185
|
+
declare function connectHttp(target: HttpTargetConfig): Promise<ConnectedClient>;
|
|
186
|
+
|
|
187
|
+
/** Connect to a target over whichever transport it declares. */
|
|
188
|
+
declare function connectTarget(target: ConnectTarget): Promise<ConnectedClient>;
|
|
189
|
+
|
|
190
|
+
interface RunSuiteOptions {
|
|
191
|
+
specVersion: SpecVersion;
|
|
192
|
+
target: ConnectTarget;
|
|
193
|
+
/** Severity at/above which findings cause a non-zero exit. Default `error`. */
|
|
194
|
+
failOn?: Severity;
|
|
195
|
+
/**
|
|
196
|
+
* Optional extra checks run against the *same* connection after the
|
|
197
|
+
* conformance rules (e.g. regression drift). Their results are appended.
|
|
198
|
+
*/
|
|
199
|
+
extraChecks?: (ctx: RuleContext) => Promise<RuleResult[]>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Connect to the target server, run every rule for the requested spec version
|
|
203
|
+
* (plus any extra checks), and assemble a {@link RunResult}. Connection/
|
|
204
|
+
* handshake failures throw (the CLI maps them to exit code 2); per-rule
|
|
205
|
+
* failures are captured as findings.
|
|
206
|
+
*/
|
|
207
|
+
declare function runSuite(opts: RunSuiteOptions): Promise<RunResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Run a set of rules against an already-connected context. Extracted from
|
|
210
|
+
* {@link runSuite} so rule-outcome handling is unit-testable without a live
|
|
211
|
+
* server connection.
|
|
212
|
+
*/
|
|
213
|
+
declare function runRules(ctx: RuleContext, rules: readonly Rule[]): Promise<RuleResult[]>;
|
|
214
|
+
declare function summarizeResults(results: RuleResult[]): RunSummary;
|
|
215
|
+
/**
|
|
216
|
+
* Exit 1 if any rule errored, or any finding is at/above the `failOn` severity;
|
|
217
|
+
* otherwise 0. Harness/config errors (exit 2) surface as thrown exceptions.
|
|
218
|
+
*/
|
|
219
|
+
declare function computeExitCode(results: RuleResult[], failOn: Severity): 0 | 1;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Normalizers collapse volatile values (timestamps, ids, paths) to stable
|
|
223
|
+
* placeholders so a re-recorded golden matches. Both `record` and the
|
|
224
|
+
* regression comparison run the *same* pipeline, so a normalized field can
|
|
225
|
+
* never register as drift.
|
|
226
|
+
*/
|
|
227
|
+
type NormalizerFn = (value: unknown) => unknown;
|
|
228
|
+
/** A normalizer is either a builtin name or an inline `{ name, apply }` object. */
|
|
229
|
+
interface NormalizerObject {
|
|
230
|
+
name: string;
|
|
231
|
+
apply: NormalizerFn;
|
|
232
|
+
}
|
|
233
|
+
type NormalizerRef = string | NormalizerObject;
|
|
234
|
+
declare const BUILTIN_NORMALIZER_NAMES: readonly string[];
|
|
235
|
+
declare function normalizerName(ref: NormalizerRef): string;
|
|
236
|
+
/** Apply a normalizer pipeline (in order) to a value. */
|
|
237
|
+
declare function applyNormalizers(value: unknown, refs: readonly NormalizerRef[]): unknown;
|
|
238
|
+
/**
|
|
239
|
+
* Given a changed field's before/after, return builtin normalizer names that
|
|
240
|
+
* would collapse it — i.e. whose pattern matches BOTH sides. This is what turns
|
|
241
|
+
* a noisy diff into "add this normalizer" guidance instead of blind re-record
|
|
242
|
+
* (CLAUDE.md hard rule #6).
|
|
243
|
+
*/
|
|
244
|
+
declare function suggestNormalizer(before: unknown, after: unknown): string[];
|
|
245
|
+
|
|
246
|
+
/** One recorded invocation of a tool: a case name plus the arguments to send. */
|
|
247
|
+
interface GoldenCaseSpec {
|
|
248
|
+
case: string;
|
|
249
|
+
arguments: Record<string, unknown>;
|
|
250
|
+
}
|
|
251
|
+
/** Recording plan for a single tool (explicit opt-in — see `record`). */
|
|
252
|
+
interface GoldenToolSpec {
|
|
253
|
+
cases: GoldenCaseSpec[];
|
|
254
|
+
/** Overrides the default normalizers for this tool. */
|
|
255
|
+
normalizers?: NormalizerRef[];
|
|
256
|
+
}
|
|
257
|
+
/** The regression engine's view of the config (built by the CLI from zod). */
|
|
258
|
+
interface GoldenConfig {
|
|
259
|
+
specVersion: string;
|
|
260
|
+
defaultNormalizers: NormalizerRef[];
|
|
261
|
+
/** Tools to record/compare, keyed by tool name. Empty = record nothing. */
|
|
262
|
+
tools: Record<string, GoldenToolSpec>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Golden-file format contract. This becomes public the moment a user commits a
|
|
267
|
+
* golden, so it is versioned: bump {@link GOLDEN_FORMAT_VERSION} to evolve the
|
|
268
|
+
* shape, and readers reject a mismatched version with a clear error rather than
|
|
269
|
+
* silently misinterpreting old goldens.
|
|
270
|
+
*/
|
|
271
|
+
declare const GOLDEN_FORMAT_VERSION = 1;
|
|
272
|
+
declare const GoldenManifestSchema: z.ZodObject<{
|
|
273
|
+
formatVersion: z.ZodLiteral<1>;
|
|
274
|
+
specVersion: z.ZodString;
|
|
275
|
+
server: z.ZodObject<{
|
|
276
|
+
name: z.ZodString;
|
|
277
|
+
version: z.ZodString;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
tools: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
280
|
+
resources: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
281
|
+
prompts: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
282
|
+
}, z.core.$strip>;
|
|
283
|
+
type GoldenManifest = z.infer<typeof GoldenManifestSchema>;
|
|
284
|
+
declare const GoldenCaseSchema: z.ZodObject<{
|
|
285
|
+
case: z.ZodString;
|
|
286
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
287
|
+
normalizers: z.ZodArray<z.ZodString>;
|
|
288
|
+
result: z.ZodUnknown;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
type GoldenCase = z.infer<typeof GoldenCaseSchema>;
|
|
291
|
+
declare const GoldenRecordingSchema: z.ZodObject<{
|
|
292
|
+
formatVersion: z.ZodLiteral<1>;
|
|
293
|
+
tool: z.ZodString;
|
|
294
|
+
cases: z.ZodArray<z.ZodObject<{
|
|
295
|
+
case: z.ZodString;
|
|
296
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
297
|
+
normalizers: z.ZodArray<z.ZodString>;
|
|
298
|
+
result: z.ZodUnknown;
|
|
299
|
+
}, z.core.$strip>>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
type GoldenRecording = z.infer<typeof GoldenRecordingSchema>;
|
|
302
|
+
/** The full committed golden set: one manifest + one recording file per tool. */
|
|
303
|
+
interface GoldenSet {
|
|
304
|
+
manifest: GoldenManifest;
|
|
305
|
+
recordings: GoldenRecording[];
|
|
306
|
+
}
|
|
307
|
+
declare const FieldDiffSchema: z.ZodObject<{
|
|
308
|
+
path: z.ZodString;
|
|
309
|
+
before: z.ZodOptional<z.ZodUnknown>;
|
|
310
|
+
after: z.ZodOptional<z.ZodUnknown>;
|
|
311
|
+
}, z.core.$strip>;
|
|
312
|
+
type FieldDiff = z.infer<typeof FieldDiffSchema>;
|
|
313
|
+
type RegressionKind = 'schema' | 'behavioral' | 'coverage';
|
|
314
|
+
declare const RegressionDetailSchema: z.ZodObject<{
|
|
315
|
+
kind: z.ZodEnum<{
|
|
316
|
+
schema: "schema";
|
|
317
|
+
behavioral: "behavioral";
|
|
318
|
+
coverage: "coverage";
|
|
319
|
+
}>;
|
|
320
|
+
target: z.ZodObject<{
|
|
321
|
+
type: z.ZodEnum<{
|
|
322
|
+
tool: "tool";
|
|
323
|
+
resource: "resource";
|
|
324
|
+
prompt: "prompt";
|
|
325
|
+
}>;
|
|
326
|
+
name: z.ZodString;
|
|
327
|
+
case: z.ZodOptional<z.ZodString>;
|
|
328
|
+
}, z.core.$strip>;
|
|
329
|
+
change: z.ZodEnum<{
|
|
330
|
+
added: "added";
|
|
331
|
+
removed: "removed";
|
|
332
|
+
changed: "changed";
|
|
333
|
+
}>;
|
|
334
|
+
before: z.ZodOptional<z.ZodUnknown>;
|
|
335
|
+
after: z.ZodOptional<z.ZodUnknown>;
|
|
336
|
+
fieldDiffs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
337
|
+
path: z.ZodString;
|
|
338
|
+
before: z.ZodOptional<z.ZodUnknown>;
|
|
339
|
+
after: z.ZodOptional<z.ZodUnknown>;
|
|
340
|
+
}, z.core.$strip>>>;
|
|
341
|
+
suggestedNormalizers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
342
|
+
}, z.core.$strip>;
|
|
343
|
+
type RegressionDetail = z.infer<typeof RegressionDetailSchema>;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Capture a golden set from a connected server: a schema manifest (always safe —
|
|
347
|
+
* read-only list calls) plus behavioral recordings for the explicitly-configured
|
|
348
|
+
* tools only. A tool absent from `cfg.tools` is never invoked (opt-in per
|
|
349
|
+
* CLAUDE.md side-effect safety).
|
|
350
|
+
*/
|
|
351
|
+
declare function recordGoldens(client: Client, cfg: GoldenConfig): Promise<GoldenSet>;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Compare the server's current behavior against a committed golden set and
|
|
355
|
+
* return one {@link RuleResult} per drift (plus a `pass` per matching case).
|
|
356
|
+
* Three drift classes, each with its own severity:
|
|
357
|
+
* - schema (error): a definition changed
|
|
358
|
+
* - behavioral (error): a recorded call's normalized output changed
|
|
359
|
+
* - coverage (error/warn): a golden's target was removed / a live target has no golden
|
|
360
|
+
*/
|
|
361
|
+
declare function runRegression(client: Client, golden: GoldenSet, cfg: GoldenConfig): Promise<RuleResult[]>;
|
|
362
|
+
|
|
363
|
+
/** Raised for missing/malformed/version-mismatched golden files (exit 2). */
|
|
364
|
+
declare class GoldenError extends Error {
|
|
365
|
+
constructor(message: string, cause?: unknown);
|
|
366
|
+
}
|
|
367
|
+
/** Write the golden set as `manifest.json` + `recordings/<tool>.json`, deterministically. */
|
|
368
|
+
declare function writeGoldenSet(dir: string, set: GoldenSet): Promise<string[]>;
|
|
369
|
+
/** Read and validate a golden set. Throws {@link GoldenError} with a clear message. */
|
|
370
|
+
declare function readGoldenSet(dir: string): Promise<GoldenSet>;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* The single choke-point for golden-file determinism. Every golden is written
|
|
374
|
+
* through {@link stableStringify}, which recursively sorts object keys and emits
|
|
375
|
+
* JSON that is a **fixed point of Prettier** (2-space indent, trailing newline):
|
|
376
|
+
* running `prettier --check` on a freshly written golden makes no changes. This
|
|
377
|
+
* matters because users commit goldens into repos that run Prettier — our output
|
|
378
|
+
* must survive that byte-identically, not get reformatted on the next commit.
|
|
379
|
+
*
|
|
380
|
+
* The rule mirrors Prettier's JSON printer (with the default `objectWrap:
|
|
381
|
+
* "preserve"`): a container is printed on one line if that flat form fits within
|
|
382
|
+
* the print width at its column, otherwise it breaks one entry per line. Objects
|
|
383
|
+
* use `{ ... }` (inner spaces); arrays use `[...]`; a broken array of only
|
|
384
|
+
* numbers is packed ("fill") the way Prettier packs number lists.
|
|
385
|
+
*/
|
|
386
|
+
/** Deterministic, Prettier-stable JSON: sorted keys, 2-space indent, trailing newline. */
|
|
387
|
+
declare function stableStringify(value: unknown): string;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* The single source of truth for the product name (CLAUDE.md: "the name lives
|
|
391
|
+
* in one constant pending final branding"). Rename here only.
|
|
392
|
+
*/
|
|
393
|
+
declare const BRAND: {
|
|
394
|
+
/** Display name of the product. */
|
|
395
|
+
readonly name: "vexyo";
|
|
396
|
+
/** CLI command / binary name. */
|
|
397
|
+
readonly bin: "vexyo";
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export { BRAND, BUILTIN_NORMALIZER_NAMES, type Category, type ConnectTarget, type ConnectedClient, type FieldDiff, type Finding, GOLDEN_FORMAT_VERSION, type GoldenCase, type GoldenCaseSpec, type GoldenConfig, GoldenError, type GoldenManifest, GoldenManifestSchema, type GoldenRecording, GoldenRecordingSchema, type GoldenSet, type GoldenToolSpec, type HttpTargetConfig, type NormalizerFn, type NormalizerObject, type NormalizerRef, type RegressionDetail, RegressionDetailSchema, type RegressionKind, type Rule, type RuleContext, type RuleResult, type RuleStatus, type RunResult, type RunSuiteOptions, type RunSummary, type RunTarget, STABLE_SPEC_VERSION, type Severity, SkipRule, type SpecVersion, type StdioTargetConfig, type TransportInfo, allRules, applyNormalizers, computeExitCode, connectHttp, connectStdio, connectTarget, finding, normalizerName, readGoldenSet, recordGoldens, rulesForSpecVersion, runRegression, runRules, runSuite, stableStringify, suggestNormalizer, summarizeResults, writeGoldenSet };
|