@vitemcp/server 1.9.7 → 1.9.9

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 (39) hide show
  1. package/README.md +15 -3
  2. package/dist/{OAuthProvider-BaPwgWny.d.cts → OAuthProvider-Dt3F-oDh.d.cts} +54 -0
  3. package/dist/{OAuthProvider-BaPwgWny.d.ts → OAuthProvider-Dt3F-oDh.d.ts} +54 -0
  4. package/dist/ViteMCP.cjs +4 -4
  5. package/dist/ViteMCP.d.cts +3 -3
  6. package/dist/ViteMCP.d.ts +3 -3
  7. package/dist/ViteMCP.js +3 -3
  8. package/dist/auth/index.cjs +2 -2
  9. package/dist/auth/index.d.cts +10 -2
  10. package/dist/auth/index.d.ts +10 -2
  11. package/dist/auth/index.js +1 -1
  12. package/dist/bin/vitemcp.cjs +7 -1
  13. package/dist/bin/vitemcp.cjs.map +1 -1
  14. package/dist/bin/vitemcp.js +7 -1
  15. package/dist/bin/vitemcp.js.map +1 -1
  16. package/dist/{chunk-R7AFGJBR.cjs → chunk-2FAJF3V6.cjs} +146 -48
  17. package/dist/chunk-2FAJF3V6.cjs.map +1 -0
  18. package/dist/{chunk-ZVA6Y7EO.cjs → chunk-DURXYPPR.cjs} +4 -2
  19. package/dist/chunk-DURXYPPR.cjs.map +1 -0
  20. package/dist/{chunk-NSHLX6PZ.cjs → chunk-PNWCRGJY.cjs} +215 -48
  21. package/dist/chunk-PNWCRGJY.cjs.map +1 -0
  22. package/dist/{chunk-XQI4HYU6.js → chunk-TYR2KJIV.js} +4 -2
  23. package/dist/{chunk-XQI4HYU6.js.map → chunk-TYR2KJIV.js.map} +1 -1
  24. package/dist/{chunk-FAONEXUK.js → chunk-UVKIOOZA.js} +118 -20
  25. package/dist/chunk-UVKIOOZA.js.map +1 -0
  26. package/dist/{chunk-WXZQZWBE.js → chunk-ZVK5GKEO.js} +215 -48
  27. package/dist/chunk-ZVK5GKEO.js.map +1 -0
  28. package/dist/edge/index.cjs +5 -5
  29. package/dist/edge/index.js +1 -1
  30. package/dist/openapi/index.cjs +13 -13
  31. package/dist/openapi/index.d.cts +1 -1
  32. package/dist/openapi/index.d.ts +1 -1
  33. package/dist/openapi/index.js +3 -3
  34. package/package.json +1 -1
  35. package/dist/chunk-FAONEXUK.js.map +0 -1
  36. package/dist/chunk-NSHLX6PZ.cjs.map +0 -1
  37. package/dist/chunk-R7AFGJBR.cjs.map +0 -1
  38. package/dist/chunk-WXZQZWBE.js.map +0 -1
  39. package/dist/chunk-ZVA6Y7EO.cjs.map +0 -1
package/README.md CHANGED
@@ -264,9 +264,15 @@ are still validated by the library itself, so a `v.transform()` reaches
264
264
  `execute` and a `v.check()` is enforced even though JSON Schema can express
265
265
  neither. Converted input schemas get `additionalProperties: false` on every
266
266
  object, except where a record or rest schema (`v.record()`,
267
- `v.objectWithRest()`) describes the extra keys; converted output schemas are
268
- left as they are. A tool whose schema cannot be converted at all is left out of
269
- the server and reported through the logger.
267
+ `v.objectWithRest()`) describes the extra keys, or where the keys are declared
268
+ in the branches of a `v.union()`, `v.variant()` or `v.intersect()`, or behind
269
+ the `$ref` a `v.lazy()` becomes; converted output schemas are left as they
270
+ are. A tool whose schema cannot be converted at all is left out of the server
271
+ and reported through the logger.
272
+
273
+ A plain JSON Schema is validated in the dialect its `$schema` declares —
274
+ 2020-12, 2019-09, draft-07 or draft-06 — and as 2020-12 when it declares none,
275
+ which is how MCP clients read it.
270
276
 
271
277
  Unlike the schema libraries above, a plain JSON Schema carries no TypeScript
272
278
  types, so `execute` receives `unknown` arguments. Cast or narrow them yourself.
@@ -1618,6 +1624,10 @@ server.addTool({
1618
1624
  });
1619
1625
  ```
1620
1626
 
1627
+ A second argument, `new UserError(message, extras)`, is sent as the error's
1628
+ `structuredContent` — for a tool with an `outputSchema`, only when it matches
1629
+ the schema, since clients may check it against the schema even on an error.
1630
+
1621
1631
  ### Progress
1622
1632
 
1623
1633
  Tools can report progress by calling `reportProgress` in the context object:
@@ -1659,6 +1669,8 @@ await reportProgress({
1659
1669
 
1660
1670
  Progress notifications are only emitted when the client opts in by supplying a `progressToken` on the tool call; otherwise `reportProgress` is a no-op. `notifications/progress` is part of the specification, so this is the portable way to send incremental updates during a long-running tool call.
1661
1671
 
1672
+ `reportProgress` and `log` are no-ops as well once the call has ended — answered, cancelled, or past its `timeoutMs` — so work still running after its caller stopped waiting sends nothing for a request that is gone.
1673
+
1662
1674
  ### Health-check Endpoint
1663
1675
 
1664
1676
  When you run ViteMCP with the `httpStream` transport you can optionally expose a
@@ -24,6 +24,11 @@ interface ClientIdMetadataOptions {
24
24
  declare const DEFAULT_ACCESS_TOKEN_TTL = 3600;
25
25
  declare const DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = 31536000;
26
26
  declare const DEFAULT_REFRESH_TOKEN_TTL = 2592000;
27
+ /**
28
+ * The token endpoint authentication methods the proxy can verify, and so the
29
+ * only ones a client may register with.
30
+ */
31
+ declare const TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_basic", "client_secret_post", "none"];
27
32
  declare const DEFAULT_AUTHORIZATION_CODE_TTL = 300;
28
33
  declare const DEFAULT_TRANSACTION_TTL = 600;
29
34
  /**
@@ -386,6 +391,17 @@ interface ProxyDCRClient {
386
391
  * Registration.
387
392
  */
388
393
  source?: "cimd";
394
+ /**
395
+ * How the client authenticates at the token endpoint, as it registered.
396
+ * `"none"` is a public client: it is issued no secret and must use S256
397
+ * PKCE. Either secret method obliges it to authenticate on every token
398
+ * request.
399
+ *
400
+ * Absent on registrations written before this was recorded, when every
401
+ * client was issued a secret whatever it asked for. Those are treated as
402
+ * public clients that may still authenticate with that secret.
403
+ */
404
+ tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
389
405
  }
390
406
  /**
391
407
  * OAuth refresh token request
@@ -397,11 +413,23 @@ interface RefreshRequest {
397
413
  refresh_token: string;
398
414
  scope?: string;
399
415
  }
416
+ /**
417
+ * Token endpoint authentication methods a Dynamic Client Registration may ask
418
+ * for (RFC 7591 §2).
419
+ */
420
+ type TokenEndpointAuthMethod = (typeof TOKEN_ENDPOINT_AUTH_METHODS)[number];
400
421
  /**
401
422
  * Token mapping for JWT swap pattern
402
423
  * Maps JTI to upstream token reference
403
424
  */
404
425
  interface TokenMapping {
426
+ /**
427
+ * Whether the client authenticated with its secret when this token was
428
+ * issued. A refresh token issued that way is only redeemed by a client that
429
+ * authenticates again; otherwise omitting the secret would turn it back into
430
+ * a bearer token.
431
+ */
432
+ clientAuthenticated?: boolean;
405
433
  clientId: string;
406
434
  /** Creation timestamp */
407
435
  createdAt: Date;
@@ -595,6 +623,20 @@ declare class OAuthProxy {
595
623
  * RFC 7591 Dynamic Client Registration
596
624
  */
597
625
  registerClient(request: DCRRequest): Promise<DCRResponse>;
626
+ /**
627
+ * RFC 6749 §2.3 / §3.2.1: identify the client behind a token request and,
628
+ * when it presents a secret, authenticate it.
629
+ *
630
+ * A client registered with a secret method must present its secret. A
631
+ * public client must not present one: it was issued none. A registration
632
+ * that predates recorded auth methods may do either — it was issued a
633
+ * secret whatever it asked for — and is treated as unauthenticated when it
634
+ * leaves it out, which the grants then hold it to.
635
+ *
636
+ * Throws `invalid_client` on any failure. Nothing here touches grant state,
637
+ * so a caller that fails cannot spend a code or refresh token.
638
+ */
639
+ private authenticateClient;
598
640
  /**
599
641
  * Calculate access token TTL from upstream tokens
600
642
  */
@@ -716,6 +758,12 @@ declare class OAuthProxy {
716
758
  * GitHub Apps return URL-encoded format, most providers return JSON
717
759
  */
718
760
  private parseTokenResponse;
761
+ /**
762
+ * Storage key for the client binding of a passthrough-mode upstream refresh
763
+ * token. Keyed by its hash: storage keys are not encrypted, and the token
764
+ * itself is a live upstream credential.
765
+ */
766
+ private passthroughRefreshKey;
719
767
  /**
720
768
  * Redirect to upstream OAuth provider
721
769
  */
@@ -742,6 +790,12 @@ declare class OAuthProxy {
742
790
  * `expiresAt`.
743
791
  */
744
792
  private restoreMapping;
793
+ /**
794
+ * Record which client a passthrough-mode upstream refresh token was handed
795
+ * to. It lives as long as the upstream says the token does, or as the
796
+ * configured refresh-token lifetime when it does not say.
797
+ */
798
+ private savePassthroughRefreshBinding;
745
799
  /**
746
800
  * Start periodic cleanup of expired transactions and codes
747
801
  */
@@ -24,6 +24,11 @@ interface ClientIdMetadataOptions {
24
24
  declare const DEFAULT_ACCESS_TOKEN_TTL = 3600;
25
25
  declare const DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = 31536000;
26
26
  declare const DEFAULT_REFRESH_TOKEN_TTL = 2592000;
27
+ /**
28
+ * The token endpoint authentication methods the proxy can verify, and so the
29
+ * only ones a client may register with.
30
+ */
31
+ declare const TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_basic", "client_secret_post", "none"];
27
32
  declare const DEFAULT_AUTHORIZATION_CODE_TTL = 300;
28
33
  declare const DEFAULT_TRANSACTION_TTL = 600;
29
34
  /**
@@ -386,6 +391,17 @@ interface ProxyDCRClient {
386
391
  * Registration.
387
392
  */
388
393
  source?: "cimd";
394
+ /**
395
+ * How the client authenticates at the token endpoint, as it registered.
396
+ * `"none"` is a public client: it is issued no secret and must use S256
397
+ * PKCE. Either secret method obliges it to authenticate on every token
398
+ * request.
399
+ *
400
+ * Absent on registrations written before this was recorded, when every
401
+ * client was issued a secret whatever it asked for. Those are treated as
402
+ * public clients that may still authenticate with that secret.
403
+ */
404
+ tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
389
405
  }
390
406
  /**
391
407
  * OAuth refresh token request
@@ -397,11 +413,23 @@ interface RefreshRequest {
397
413
  refresh_token: string;
398
414
  scope?: string;
399
415
  }
416
+ /**
417
+ * Token endpoint authentication methods a Dynamic Client Registration may ask
418
+ * for (RFC 7591 §2).
419
+ */
420
+ type TokenEndpointAuthMethod = (typeof TOKEN_ENDPOINT_AUTH_METHODS)[number];
400
421
  /**
401
422
  * Token mapping for JWT swap pattern
402
423
  * Maps JTI to upstream token reference
403
424
  */
404
425
  interface TokenMapping {
426
+ /**
427
+ * Whether the client authenticated with its secret when this token was
428
+ * issued. A refresh token issued that way is only redeemed by a client that
429
+ * authenticates again; otherwise omitting the secret would turn it back into
430
+ * a bearer token.
431
+ */
432
+ clientAuthenticated?: boolean;
405
433
  clientId: string;
406
434
  /** Creation timestamp */
407
435
  createdAt: Date;
@@ -595,6 +623,20 @@ declare class OAuthProxy {
595
623
  * RFC 7591 Dynamic Client Registration
596
624
  */
597
625
  registerClient(request: DCRRequest): Promise<DCRResponse>;
626
+ /**
627
+ * RFC 6749 §2.3 / §3.2.1: identify the client behind a token request and,
628
+ * when it presents a secret, authenticate it.
629
+ *
630
+ * A client registered with a secret method must present its secret. A
631
+ * public client must not present one: it was issued none. A registration
632
+ * that predates recorded auth methods may do either — it was issued a
633
+ * secret whatever it asked for — and is treated as unauthenticated when it
634
+ * leaves it out, which the grants then hold it to.
635
+ *
636
+ * Throws `invalid_client` on any failure. Nothing here touches grant state,
637
+ * so a caller that fails cannot spend a code or refresh token.
638
+ */
639
+ private authenticateClient;
598
640
  /**
599
641
  * Calculate access token TTL from upstream tokens
600
642
  */
@@ -716,6 +758,12 @@ declare class OAuthProxy {
716
758
  * GitHub Apps return URL-encoded format, most providers return JSON
717
759
  */
718
760
  private parseTokenResponse;
761
+ /**
762
+ * Storage key for the client binding of a passthrough-mode upstream refresh
763
+ * token. Keyed by its hash: storage keys are not encrypted, and the token
764
+ * itself is a live upstream credential.
765
+ */
766
+ private passthroughRefreshKey;
719
767
  /**
720
768
  * Redirect to upstream OAuth provider
721
769
  */
@@ -742,6 +790,12 @@ declare class OAuthProxy {
742
790
  * `expiresAt`.
743
791
  */
744
792
  private restoreMapping;
793
+ /**
794
+ * Record which client a passthrough-mode upstream refresh token was handed
795
+ * to. It lives as long as the upstream says the token does, or as the
796
+ * configured refresh-token lifetime when it does not say.
797
+ */
798
+ private savePassthroughRefreshBinding;
745
799
  /**
746
800
  * Start periodic cleanup of expired transactions and codes
747
801
  */
package/dist/ViteMCP.cjs CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkR7AFGJBRcjs = require('./chunk-R7AFGJBR.cjs');
13
+ var _chunk2FAJF3V6cjs = require('./chunk-2FAJF3V6.cjs');
14
14
 
15
15
 
16
16
 
@@ -25,8 +25,8 @@ var _chunkR7AFGJBRcjs = require('./chunk-R7AFGJBR.cjs');
25
25
 
26
26
 
27
27
 
28
- var _chunkNSHLX6PZcjs = require('./chunk-NSHLX6PZ.cjs');
29
- require('./chunk-ZVA6Y7EO.cjs');
28
+ var _chunkPNWCRGJYcjs = require('./chunk-PNWCRGJY.cjs');
29
+ require('./chunk-DURXYPPR.cjs');
30
30
 
31
31
 
32
32
 
@@ -52,5 +52,5 @@ require('./chunk-ZVA6Y7EO.cjs');
52
52
 
53
53
 
54
54
 
55
- exports.AuthProvider = _chunkNSHLX6PZcjs.AuthProvider; exports.AzureProvider = _chunkNSHLX6PZcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkR7AFGJBRcjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkNSHLX6PZcjs.GitHubProvider; exports.GoogleProvider = _chunkNSHLX6PZcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkR7AFGJBRcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkNSHLX6PZcjs.OAuthProvider; exports.OAuthProxy = _chunkNSHLX6PZcjs.OAuthProxy; exports.OAuthProxyError = _chunkNSHLX6PZcjs.OAuthProxyError; exports.ServerState = _chunkR7AFGJBRcjs.ServerState; exports.UnexpectedStateError = _chunkR7AFGJBRcjs.UnexpectedStateError; exports.UserError = _chunkR7AFGJBRcjs.UserError; exports.ViteMCP = _chunkR7AFGJBRcjs.ViteMCP; exports.ViteMCPError = _chunkR7AFGJBRcjs.ViteMCPError; exports.audioContent = _chunkR7AFGJBRcjs.audioContent; exports.delay = _chunkR7AFGJBRcjs.delay; exports.getAuthSession = _chunkNSHLX6PZcjs.getAuthSession; exports.imageContent = _chunkR7AFGJBRcjs.imageContent; exports.jsonSchemaAdapter = _chunkR7AFGJBRcjs.jsonSchemaAdapter; exports.requireAll = _chunkNSHLX6PZcjs.requireAll; exports.requireAny = _chunkNSHLX6PZcjs.requireAny; exports.requireAuth = _chunkNSHLX6PZcjs.requireAuth; exports.requireRole = _chunkNSHLX6PZcjs.requireRole; exports.requireScopes = _chunkNSHLX6PZcjs.requireScopes;
55
+ exports.AuthProvider = _chunkPNWCRGJYcjs.AuthProvider; exports.AzureProvider = _chunkPNWCRGJYcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunk2FAJF3V6cjs.DiscoveryDocumentCache; exports.GitHubProvider = _chunkPNWCRGJYcjs.GitHubProvider; exports.GoogleProvider = _chunkPNWCRGJYcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunk2FAJF3V6cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkPNWCRGJYcjs.OAuthProvider; exports.OAuthProxy = _chunkPNWCRGJYcjs.OAuthProxy; exports.OAuthProxyError = _chunkPNWCRGJYcjs.OAuthProxyError; exports.ServerState = _chunk2FAJF3V6cjs.ServerState; exports.UnexpectedStateError = _chunk2FAJF3V6cjs.UnexpectedStateError; exports.UserError = _chunk2FAJF3V6cjs.UserError; exports.ViteMCP = _chunk2FAJF3V6cjs.ViteMCP; exports.ViteMCPError = _chunk2FAJF3V6cjs.ViteMCPError; exports.audioContent = _chunk2FAJF3V6cjs.audioContent; exports.delay = _chunk2FAJF3V6cjs.delay; exports.getAuthSession = _chunkPNWCRGJYcjs.getAuthSession; exports.imageContent = _chunk2FAJF3V6cjs.imageContent; exports.jsonSchemaAdapter = _chunk2FAJF3V6cjs.jsonSchemaAdapter; exports.requireAll = _chunkPNWCRGJYcjs.requireAll; exports.requireAny = _chunkPNWCRGJYcjs.requireAny; exports.requireAuth = _chunkPNWCRGJYcjs.requireAuth; exports.requireRole = _chunkPNWCRGJYcjs.requireRole; exports.requireScopes = _chunkPNWCRGJYcjs.requireScopes;
56
56
  //# sourceMappingURL=ViteMCP.cjs.map
@@ -4,8 +4,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Hono } from 'hono';
5
5
  import { cors } from 'hono/cors';
6
6
  export { setTimeout as delay } from 'timers/promises';
7
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BaPwgWny.cjs';
8
- export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-BaPwgWny.cjs';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-Dt3F-oDh.cjs';
8
+ export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-Dt3F-oDh.cjs';
9
9
 
10
10
  declare class DiscoveryDocumentCache {
11
11
  #private;
@@ -46,7 +46,7 @@ declare class DiscoveryDocumentCache {
46
46
  type JsonSchemaObject = {
47
47
  [key: string]: unknown;
48
48
  $schema?: string;
49
- additionalProperties?: boolean;
49
+ additionalProperties?: boolean | Record<string, unknown>;
50
50
  properties?: Record<string, unknown>;
51
51
  required?: string[];
52
52
  type: string;
package/dist/ViteMCP.d.ts CHANGED
@@ -4,8 +4,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Hono } from 'hono';
5
5
  import { cors } from 'hono/cors';
6
6
  export { setTimeout as delay } from 'timers/promises';
7
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BaPwgWny.js';
8
- export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-BaPwgWny.js';
7
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-Dt3F-oDh.js';
8
+ export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, p as OAuthProxyError, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-Dt3F-oDh.js';
9
9
 
10
10
  declare class DiscoveryDocumentCache {
11
11
  #private;
@@ -46,7 +46,7 @@ declare class DiscoveryDocumentCache {
46
46
  type JsonSchemaObject = {
47
47
  [key: string]: unknown;
48
48
  $schema?: string;
49
- additionalProperties?: boolean;
49
+ additionalProperties?: boolean | Record<string, unknown>;
50
50
  properties?: Record<string, unknown>;
51
51
  required?: string[];
52
52
  type: string;
package/dist/ViteMCP.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  delay,
11
11
  imageContent,
12
12
  jsonSchemaAdapter
13
- } from "./chunk-FAONEXUK.js";
13
+ } from "./chunk-UVKIOOZA.js";
14
14
  import {
15
15
  AuthProvider,
16
16
  AzureProvider,
@@ -25,8 +25,8 @@ import {
25
25
  requireAuth,
26
26
  requireRole,
27
27
  requireScopes
28
- } from "./chunk-WXZQZWBE.js";
29
- import "./chunk-XQI4HYU6.js";
28
+ } from "./chunk-ZVK5GKEO.js";
29
+ import "./chunk-TYR2KJIV.js";
30
30
  export {
31
31
  AuthProvider,
32
32
  AzureProvider,
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkNSHLX6PZcjs = require('../chunk-NSHLX6PZ.cjs');
27
+ var _chunkPNWCRGJYcjs = require('../chunk-PNWCRGJY.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunkNSHLX6PZcjs = require('../chunk-NSHLX6PZ.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunkNSHLX6PZcjs.AuthProvider; exports.AzureProvider = _chunkNSHLX6PZcjs.AzureProvider; exports.ConsentManager = _chunkNSHLX6PZcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkNSHLX6PZcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkNSHLX6PZcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkNSHLX6PZcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkNSHLX6PZcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkNSHLX6PZcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkNSHLX6PZcjs.DiskStore; exports.EncryptedTokenStorage = _chunkNSHLX6PZcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkNSHLX6PZcjs.GitHubProvider; exports.GoogleProvider = _chunkNSHLX6PZcjs.GoogleProvider; exports.JWKSVerifier = _chunkNSHLX6PZcjs.JWKSVerifier; exports.JWTIssuer = _chunkNSHLX6PZcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkNSHLX6PZcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkNSHLX6PZcjs.OAuthProvider; exports.OAuthProxy = _chunkNSHLX6PZcjs.OAuthProxy; exports.OAuthProxyError = _chunkNSHLX6PZcjs.OAuthProxyError; exports.PKCEUtils = _chunkNSHLX6PZcjs.PKCEUtils; exports.getAuthSession = _chunkNSHLX6PZcjs.getAuthSession; exports.requireAll = _chunkNSHLX6PZcjs.requireAll; exports.requireAny = _chunkNSHLX6PZcjs.requireAny; exports.requireAuth = _chunkNSHLX6PZcjs.requireAuth; exports.requireRole = _chunkNSHLX6PZcjs.requireRole; exports.requireScopes = _chunkNSHLX6PZcjs.requireScopes;
54
+ exports.AuthProvider = _chunkPNWCRGJYcjs.AuthProvider; exports.AzureProvider = _chunkPNWCRGJYcjs.AzureProvider; exports.ConsentManager = _chunkPNWCRGJYcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkPNWCRGJYcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkPNWCRGJYcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkPNWCRGJYcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkPNWCRGJYcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkPNWCRGJYcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkPNWCRGJYcjs.DiskStore; exports.EncryptedTokenStorage = _chunkPNWCRGJYcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkPNWCRGJYcjs.GitHubProvider; exports.GoogleProvider = _chunkPNWCRGJYcjs.GoogleProvider; exports.JWKSVerifier = _chunkPNWCRGJYcjs.JWKSVerifier; exports.JWTIssuer = _chunkPNWCRGJYcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkPNWCRGJYcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkPNWCRGJYcjs.OAuthProvider; exports.OAuthProxy = _chunkPNWCRGJYcjs.OAuthProxy; exports.OAuthProxyError = _chunkPNWCRGJYcjs.OAuthProxyError; exports.PKCEUtils = _chunkPNWCRGJYcjs.PKCEUtils; exports.getAuthSession = _chunkPNWCRGJYcjs.getAuthSession; exports.requireAll = _chunkPNWCRGJYcjs.requireAll; exports.requireAny = _chunkPNWCRGJYcjs.requireAny; exports.requireAuth = _chunkPNWCRGJYcjs.requireAuth; exports.requireRole = _chunkPNWCRGJYcjs.requireRole; exports.requireScopes = _chunkPNWCRGJYcjs.requireScopes;
55
55
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
- import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BaPwgWny.cjs';
2
- export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-BaPwgWny.cjs';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-Dt3F-oDh.cjs';
2
+ export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-Dt3F-oDh.cjs';
3
3
 
4
4
  /**
5
5
  * Consent Management
@@ -154,6 +154,14 @@ interface JWTClaims {
154
154
  jti: string;
155
155
  /** Scopes */
156
156
  scope: string[];
157
+ /**
158
+ * Which kind of token this is. Access and refresh tokens share a signing
159
+ * key, audience and claim set, so without this either one verifies as the
160
+ * other: an access token — sent on every request — could be redeemed for a
161
+ * refresh token, and a refresh token presented as a bearer credential.
162
+ * Absent from tokens issued before it existed; those are refused as both.
163
+ */
164
+ token_use?: "access" | "refresh";
157
165
  }
158
166
  /**
159
167
  * JWT Issuer configuration
@@ -1,5 +1,5 @@
1
- import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BaPwgWny.js';
2
- export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-BaPwgWny.js';
1
+ import { q as OAuthTransaction, C as ConsentData, T as TokenStorage, s as TokenVerifier, t as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-Dt3F-oDh.js';
2
+ export { A as AuthProvider, j as AuthProviderConfig, z as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, B as ClientCode, u as ClientIdMetadataOptions, E as CustomClaimsPassthroughConfig, F as DCRClientMetadata, H as DCRRequest, I as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, v as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, w as DEFAULT_AUTHORIZATION_CODE_TTL, x as DEFAULT_REFRESH_TOKEN_TTL, y as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, J as OAuthError, d as OAuthProvider, K as OAuthProviderConfig, a as OAuthProxy, L as OAuthProxyConfig, p as OAuthProxyError, O as OAuthSession, M as ProxyDCRClient, R as RefreshRequest, S as SessionAuth, N as TokenMapping, Q as TokenRequest, U as TokenResponse, V as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-Dt3F-oDh.js';
3
3
 
4
4
  /**
5
5
  * Consent Management
@@ -154,6 +154,14 @@ interface JWTClaims {
154
154
  jti: string;
155
155
  /** Scopes */
156
156
  scope: string[];
157
+ /**
158
+ * Which kind of token this is. Access and refresh tokens share a signing
159
+ * key, audience and claim set, so without this either one verifies as the
160
+ * other: an access token — sent on every request — could be redeemed for a
161
+ * refresh token, and a refresh token presented as a bearer credential.
162
+ * Absent from tokens issued before it existed; those are refused as both.
163
+ */
164
+ token_use?: "access" | "refresh";
157
165
  }
158
166
  /**
159
167
  * JWT Issuer configuration
@@ -24,7 +24,7 @@ import {
24
24
  requireAuth,
25
25
  requireRole,
26
26
  requireScopes
27
- } from "../chunk-WXZQZWBE.js";
27
+ } from "../chunk-ZVK5GKEO.js";
28
28
  export {
29
29
  AuthProvider,
30
30
  AzureProvider,
@@ -88,7 +88,13 @@ var STANDALONE_COMPILER_OPTIONS = {
88
88
  skipLibCheck: true,
89
89
  target: "es2022"
90
90
  };
91
- var PROJECT_OVERRIDES = { composite: false, incremental: false };
91
+ var PROJECT_OVERRIDES = {
92
+ composite: false,
93
+ declarationMap: false,
94
+ emitDeclarationOnly: false,
95
+ incremental: false,
96
+ isolatedDeclarations: false
97
+ };
92
98
  var buildStructureCheckCommand = (file, execPath = process.execPath) => [
93
99
  execPath,
94
100
  "-e",
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/server/server/dist/bin/vitemcp.cjs","../../src/bin/vitemcp.ts","../../src/bin/devCommand.ts","../../src/bin/validateCommand.ts"],"names":["yargs"],"mappings":"AAAA;AACA;AACA;ACAA,8BAAsB;AACtB,uCAAuC;AACvC,wBAAuB;AACvB,4BAAqB;AACrB,4EAAkB;AAClB,wCAAwB;ADExB;AACA;AEqBO,IAAM,gBAAA,EAAkB,KAAA;AAWxB,IAAM,eAAA,EAAiB,CAAC,IAAA,EAAA,GAC7B,IAAA,CAAK,SAAA;AAAA,EACH;AAAA,IACE,UAAA,EAAY;AAAA,MACV,CAAC,eAAe,CAAA,EAAG;AAAA,QACjB,IAAA,EAAM,CAAC,KAAA,EAAO,IAAI,CAAA;AAAA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A;AAGD;AACC,EAAA;AACA,EAAA;AACCA,EAAAA;AACC,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACH,EAAA;AAEA,EAAA;AACE,IAAA;AACE,MAAA;AAAY,QAAA;AACF,QAAA;AAET,MAAA;AACH,IAAA;AACE,MAAA;AAAQ,QAAA;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGD;AACC,EAAA;AACA,EAAA;AACCA,EAAAA;AACC,IAAA;AAEI,MAAA;AACA,MAAA;AACA,MAAA;AAGD,IAAA;AACC,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACL,EAAA;AAEA,EAAA;AACE,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AAEA,MAAA;AACE,QAAA;AACA,QAAA;AACF,MAAA;AAEA,MAAA;AAEA,MAAA;AAEA,MAAA;AACE,QAAA;AAEA,QAAA;AAEA,QAAA;AACE,UAAA;AAAyB,QAAA;AAG3B,QAAA;AACF,MAAA;AAEA,MAAA;AAEA,MAAA;AAEA,MAAA;AAAoE,QAAA;AAEnE,MAAA;AAED,MAAA;AAIE,QAAA;AAEA,QAAA;AACE,UAAA;AAAoB,QAAA;AAEpB,UAAA;AACA,UAAA;AAAQ,YAAA;AACN,UAAA;AACF,QAAA;AAGF,QAAA;AACF,MAAA;AAEA,MAAA;AAAQ,QAAA;AAER,MAAA;AACF,IAAA;AACE,MAAA;AAAQ,QAAA;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGI","file":"/home/runner/work/server/server/dist/bin/vitemcp.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { execa } from \"execa\";\nimport { mkdtemp, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { buildDevCommand, buildDevConfig } from \"./devCommand.js\";\nimport {\n buildStructureCheckCommand,\n formatCommandFailure,\n runTypeCheck,\n} from \"./validateCommand.js\";\n\nawait yargs(hideBin(process.argv))\n .scriptName(\"vitemcp\")\n .command(\n \"dev <file>\",\n \"Start a development server\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"args\", {\n describe:\n \"JSON arguments passed to the tool (requires --tool), e.g. '{\\\"a\\\":1}'\",\n type: \"string\",\n })\n\n .option(\"tool\", {\n alias: \"t\",\n describe:\n \"Call a tool non-interactively instead of launching the inspector\",\n type: \"string\",\n })\n\n .option(\"watch\", {\n alias: \"w\",\n default: false,\n describe: \"Watch for file changes and restart server\",\n type: \"boolean\",\n })\n\n .option(\"verbose\", {\n alias: \"v\",\n default: false,\n describe: \"Enable verbose logging\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n let configDir: string | undefined;\n\n try {\n if (argv.args !== undefined && !argv.tool) {\n console.error(\"[ViteMCP Error] --args requires --tool\");\n process.exitCode = 1;\n return;\n }\n\n if (argv.tool && argv.watch) {\n console.warn(\n \"[ViteMCP] --watch is ignored when calling a tool with --tool: the server runs for a single call.\",\n );\n }\n\n let configPath: string | undefined;\n\n if (argv.tool) {\n configDir = await mkdtemp(join(tmpdir(), \"vitemcp-dev-\"));\n configPath = join(configDir, \"mcp-cli.json\");\n await writeFile(configPath, buildDevConfig(argv.file), \"utf8\");\n }\n\n const [command, ...commandArgs] = buildDevCommand({\n configPath,\n file: argv.file,\n tool: argv.tool,\n toolArgs: argv.args,\n watch: argv.watch,\n });\n\n if (argv.verbose) {\n console.log(\n `[ViteMCP] Starting server: ${[command, ...commandArgs].join(\" \")}`,\n );\n console.log(`[ViteMCP] File: ${argv.file}`);\n console.log(\n `[ViteMCP] Watch mode: ${argv.watch ? \"enabled\" : \"disabled\"}`,\n );\n\n if (argv.tool) {\n console.log(`[ViteMCP] Tool: ${argv.tool}`);\n }\n }\n\n await execa(command, commandArgs, {\n stderr: \"inherit\",\n stdin: \"inherit\",\n stdout: \"inherit\",\n });\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to start development server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n if (argv.verbose && error instanceof Error && error.stack) {\n console.error(\"[ViteMCP Debug] Stack trace:\", error.stack);\n }\n\n // Not process.exit(): that would skip the `finally` block below and\n // leak the temporary config directory on every failed tool call.\n process.exitCode = 1;\n } finally {\n if (configDir) {\n await rm(configDir, { force: true, recursive: true });\n }\n }\n },\n )\n\n .command(\n \"inspect <file>\",\n \"Inspect a server file\",\n (yargs) => {\n return yargs.positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n });\n },\n\n async (argv) => {\n try {\n await execa({\n stderr: \"inherit\",\n stdout: \"inherit\",\n })`npx @modelcontextprotocol/inspector npx tsx ${argv.file}`;\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to inspect server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .command(\n \"validate <file>\",\n \"Validate a ViteMCP server file for syntax and basic structure\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"strict\", {\n alias: \"s\",\n default: false,\n describe: \"Enable strict validation (type checking)\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n try {\n const { existsSync } = await import(\"fs\");\n const { resolve } = await import(\"path\");\n const filePath = resolve(argv.file);\n\n if (!existsSync(filePath)) {\n console.error(`[ViteMCP Error] File not found: ${filePath}`);\n process.exit(1);\n }\n\n console.log(`[ViteMCP] Validating server file: ${filePath}`);\n\n const typeCheck = await runTypeCheck(filePath, argv.strict);\n\n if (typeCheck.failed) {\n console.error(\"[ViteMCP] ✗ TypeScript compilation failed\");\n\n const diagnostics = formatCommandFailure(typeCheck);\n\n if (diagnostics) {\n console.error(diagnostics);\n }\n\n process.exit(1);\n }\n\n console.log(\"[ViteMCP] ✓ TypeScript compilation successful\");\n\n const [structureCommand, ...structureArgs] =\n buildStructureCheckCommand(filePath);\n const structureCheck = await execa(structureCommand, structureArgs, {\n reject: false,\n });\n\n if (structureCheck.failed) {\n // The child explains the failure on stderr, which execa captures.\n // Without replaying it the user only ever sees the generic hint, even\n // when their server file has an error they could act on.\n const reason = formatCommandFailure(structureCheck);\n\n if (reason) {\n console.error(reason);\n } else {\n console.error(\"[ViteMCP] ✗ Server structure validation failed\");\n console.error(\n \"Make sure the file properly imports and uses ViteMCP\",\n );\n }\n\n process.exit(1);\n }\n\n console.log(\n \"[ViteMCP] ✓ All validations passed! Server file looks good.\",\n );\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Validation failed:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .help()\n .parseAsync();\n","export type DevCommandOptions = {\n /**\n * Path to a temporary mcp-cli config file that registers the dev server.\n * Only used in non-interactive mode (when `tool` is set).\n */\n configPath?: string;\n /**\n * Path to the server file to run.\n */\n file: string;\n /**\n * Name of the tool to call non-interactively. When omitted, the dev\n * command launches the interactive mcp-cli inspector instead.\n */\n tool?: string;\n /**\n * JSON string of arguments forwarded to the tool via mcp-cli `--args`.\n * Only used in non-interactive mode.\n */\n toolArgs?: string;\n /**\n * Watch the file for changes and restart the server. Only used in\n * interactive mode; a non-interactive call runs the server once.\n */\n watch?: boolean;\n};\n\n/**\n * The server name registered in the generated mcp-cli config. mcp-cli\n * addresses non-interactive targets as `<server-name>:<tool>`.\n */\nexport const DEV_SERVER_NAME = \"dev\";\n\n/**\n * Build the JSON config that registers the dev server with mcp-cli so it can\n * be invoked non-interactively. mcp-cli's non-interactive mode resolves the\n * server by name from a config file's `mcpServers` map, so an inline command\n * cannot be passed directly alongside `call-tool`.\n *\n * The server is never started in watch mode here: a non-interactive call\n * connects, calls one tool, and exits, so there is nothing to restart into.\n */\nexport const buildDevConfig = (file: string): string =>\n JSON.stringify(\n {\n mcpServers: {\n [DEV_SERVER_NAME]: {\n args: [\"tsx\", file],\n command: \"npx\",\n },\n },\n },\n null,\n 2,\n );\n\n/**\n * Build the argv that the dev command runs.\n *\n * This is an argv array rather than a shell string so that nothing has to be\n * quoted: file paths, tool names and JSON `--args` are passed to the child\n * process verbatim. Quoting through a shell would be wrong on Windows, where\n * cmd.exe treats single quotes as literal characters rather than as quoting.\n *\n * - Without `tool`: launches the interactive @wong2/mcp-cli inspector\n * against an inline `npx tsx <file>` server (existing behaviour).\n * - With `tool`: runs @wong2/mcp-cli in non-interactive mode against a\n * generated config file, calling the named tool and forwarding `--args`.\n */\nexport const buildDevCommand = (\n options: DevCommandOptions,\n): [string, ...string[]] => {\n const { configPath, file, tool, toolArgs, watch = false } = options;\n\n if (tool) {\n if (!configPath) {\n throw new Error(\n \"configPath is required when calling a tool non-interactively\",\n );\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"-c\",\n configPath,\n \"call-tool\",\n `${DEV_SERVER_NAME}:${tool}`,\n ...(toolArgs === undefined ? [] : [\"--args\", toolArgs]),\n ];\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"npx\",\n \"tsx\",\n ...(watch ? [\"--watch\"] : []),\n file,\n ];\n};\n","import { randomUUID } from \"crypto\";\nimport { execa } from \"execa\";\nimport { existsSync } from \"fs\";\nimport { rm, writeFile } from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\n/**\n * The script `vitemcp validate` runs to check that a server file loads.\n *\n * The file arrives as `process.argv[1]` rather than being spliced into this\n * source. Spliced into a string literal, a Windows path loses its backslashes\n * to the child's own parser (`C:\\Users\\dev\\server.ts` reaches the import as\n * `C:Usersdevserver.ts`), and a quote or `#` in any path breaks the import —\n * each reported to the user as a problem with their file.\n *\n * It exits as soon as the import settles, once its verdict is flushed. A\n * server file normally starts its transport on load, which would otherwise\n * keep this process, and the command waiting on it, alive forever.\n */\nexport const STRUCTURE_CHECK_SCRIPT = `\n(async () => {\n let failure;\n\n try {\n await import(\"@vitemcp/server\");\n await import(process.argv[1]);\n } catch (error) {\n failure = error instanceof Error ? error.message : String(error);\n }\n\n if (failure === undefined) {\n process.stdout.write(\n \"[ViteMCP] ✓ Server structure validation passed\\\\n\",\n () => process.exit(0),\n );\n } else {\n process.stderr.write(\n \"[ViteMCP] ✗ Server structure validation failed: \" + failure + \"\\\\n\",\n () => process.exit(1),\n );\n }\n})();\n`;\n\n/**\n * Compiler options for a file with no `tsconfig.json` above it. The compiler's\n * own defaults target ES5, which rejects top-level await and the `#private`\n * members in `@vitemcp/server`'s declarations, so no server file could pass.\n */\nconst STANDALONE_COMPILER_OPTIONS = {\n allowImportingTsExtensions: true,\n module: \"esnext\",\n moduleResolution: \"bundler\",\n skipLibCheck: true,\n target: \"es2022\",\n};\n\n/**\n * What the throwaway config overrides in the project's own. `composite`\n * demands that every file the server imports be listed as a root, and only the\n * server file is; `incremental` writes a `.tsbuildinfo` named after the\n * throwaway config into the project.\n */\nconst PROJECT_OVERRIDES = { composite: false, incremental: false };\n\n/**\n * Build the argv for the structure check.\n *\n * An argv array rather than a shell string, as in `buildDevCommand`, so nothing\n * has to be quoted. The file is converted to a `file:` URL here, so the child\n * imports it as given and never has to build the URL itself; and the child is\n * the Node binary running this CLI, so no PATH lookup is involved.\n */\nexport const buildStructureCheckCommand = (\n file: string,\n execPath: string = process.execPath,\n): [string, ...string[]] => [\n execPath,\n \"-e\",\n STRUCTURE_CHECK_SCRIPT,\n pathToFileURL(file).href,\n];\n\n/**\n * Build the argv for the type check. An argv array for the same reason as the\n * structure check: through a shell, a path containing a space reaches `tsc` as\n * several root files.\n */\nexport const buildTypeCheckCommand = (\n config: string,\n strict = false,\n): [string, ...string[]] => [\n \"npx\",\n \"tsc\",\n \"--noEmit\",\n \"--project\",\n config,\n ...(strict ? [\"--strict\"] : []),\n];\n\n/**\n * Build the throwaway config that type-checks one file.\n *\n * `tsc` ignores `tsconfig.json` whenever a file is named on its command line\n * and falls back to defaults no server file passes, so the file is named in a\n * config that extends the project's own instead. `include: []` keeps an\n * inherited `include` from pulling the rest of the project in.\n */\nexport const buildTypeCheckConfig = (file: string, tsconfig?: string): string =>\n JSON.stringify(\n tsconfig\n ? {\n compilerOptions: PROJECT_OVERRIDES,\n extends: tsconfig,\n files: [file],\n include: [],\n }\n : {\n compilerOptions: STANDALONE_COMPILER_OPTIONS,\n files: [file],\n include: [],\n },\n null,\n 2,\n );\n\n/**\n * The `tsconfig.json` that governs a file in `dir`: the nearest one at or above\n * it, which is also the one an editor checks the file against.\n */\nexport const findTsconfig = (dir: string): string | undefined => {\n for (let current = dir; ; current = dirname(current)) {\n const candidate = join(current, \"tsconfig.json\");\n\n if (existsSync(candidate)) {\n return candidate;\n }\n\n if (dirname(current) === current) {\n return undefined;\n }\n }\n};\n\n/**\n * The output of a failed check, for replaying to the user.\n *\n * `tsc` writes its diagnostics to stdout, and only a failure to launch it\n * reaches stderr, so reading stderr alone reported every real type error with\n * no detail. The structure check explains itself on stderr.\n */\nexport const formatCommandFailure = (result: {\n stderr?: unknown;\n stdout?: unknown;\n}): string =>\n [result.stderr, result.stdout]\n .map((output) => (typeof output === \"string\" ? output.trim() : \"\"))\n .filter(Boolean)\n .join(\"\\n\");\n\n/**\n * Type-check `file` under the compiler options of the project it belongs to.\n *\n * The throwaway config is written beside the project's own rather than to the\n * OS temp directory, because the compiler resolves type packages — the `types`\n * option and every visible `@types` package — from the config's directory. It\n * is removed before this returns, so a caller may exit straight away.\n */\nexport const runTypeCheck = async (file: string, strict = false) => {\n const tsconfig = findTsconfig(dirname(file));\n const config = join(\n dirname(tsconfig ?? file),\n `tsconfig.vitemcp-validate-${randomUUID()}.json`,\n );\n\n await writeFile(config, buildTypeCheckConfig(file, tsconfig), {\n flag: \"wx\",\n });\n\n try {\n const [command, ...args] = buildTypeCheckCommand(config, strict);\n\n return await execa(command, args, { reject: false });\n } finally {\n await rm(config, { force: true });\n }\n};\n"]}
1
+ {"version":3,"sources":["/home/runner/work/server/server/dist/bin/vitemcp.cjs","../../src/bin/vitemcp.ts","../../src/bin/devCommand.ts","../../src/bin/validateCommand.ts"],"names":["yargs"],"mappings":"AAAA;AACA;AACA;ACAA,8BAAsB;AACtB,uCAAuC;AACvC,wBAAuB;AACvB,4BAAqB;AACrB,4EAAkB;AAClB,wCAAwB;ADExB;AACA;AEqBO,IAAM,gBAAA,EAAkB,KAAA;AAWxB,IAAM,eAAA,EAAiB,CAAC,IAAA,EAAA,GAC7B,IAAA,CAAK,SAAA;AAAA,EACH;AAAA,IACE,UAAA,EAAY;AAAA,MACV,CAAC,eAAe,CAAA,EAAG;AAAA,QACjB,IAAA,EAAM,CAAC,KAAA,EAAO,IAAI,CAAA;AAAA,QAClB,OAAA,EAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA;AAeK,IAAM,gBAAA,EAAkB,CAC7B,OAAA,EAAA,GAC0B;AAC1B,EAAA,MAAM,EAAE,UAAA,EAAY,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,MAAA,EAAQ,MAAM,EAAA,EAAI,OAAA;AAE5D,EAAA,GAAA,CAAI,IAAA,EAAM;AACR,IAAA,GAAA,CAAI,CAAC,UAAA,EAAY;AACf,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,MACF,CAAA;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACL,KAAA;AAAA,MACA,gBAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,WAAA;AAAA,MACA,CAAA,EAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAEA,EAAA;AACE,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACI,IAAA;AACJ,IAAA;AACF,EAAA;AACF;AFjDO;AACA;AGpDP;AACA;AACA;AACA;AACA;AACA;AAea;AAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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;AAIE,QAAA;AAEA,QAAA;AACE,UAAA;AAAoB,QAAA;AAEpB,UAAA;AACA,UAAA;AAAQ,YAAA;AACN,UAAA;AACF,QAAA;AAGF,QAAA;AACF,MAAA;AAEA,MAAA;AAAQ,QAAA;AAER,MAAA;AACF,IAAA;AACE,MAAA;AAAQ,QAAA;AACN,QAAA;AAEF,MAAA;AAEA,MAAA;AACF,IAAA;AACF,EAAA;AAGI","file":"/home/runner/work/server/server/dist/bin/vitemcp.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { execa } from \"execa\";\nimport { mkdtemp, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { buildDevCommand, buildDevConfig } from \"./devCommand.js\";\nimport {\n buildStructureCheckCommand,\n formatCommandFailure,\n runTypeCheck,\n} from \"./validateCommand.js\";\n\nawait yargs(hideBin(process.argv))\n .scriptName(\"vitemcp\")\n .command(\n \"dev <file>\",\n \"Start a development server\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"args\", {\n describe:\n \"JSON arguments passed to the tool (requires --tool), e.g. '{\\\"a\\\":1}'\",\n type: \"string\",\n })\n\n .option(\"tool\", {\n alias: \"t\",\n describe:\n \"Call a tool non-interactively instead of launching the inspector\",\n type: \"string\",\n })\n\n .option(\"watch\", {\n alias: \"w\",\n default: false,\n describe: \"Watch for file changes and restart server\",\n type: \"boolean\",\n })\n\n .option(\"verbose\", {\n alias: \"v\",\n default: false,\n describe: \"Enable verbose logging\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n let configDir: string | undefined;\n\n try {\n if (argv.args !== undefined && !argv.tool) {\n console.error(\"[ViteMCP Error] --args requires --tool\");\n process.exitCode = 1;\n return;\n }\n\n if (argv.tool && argv.watch) {\n console.warn(\n \"[ViteMCP] --watch is ignored when calling a tool with --tool: the server runs for a single call.\",\n );\n }\n\n let configPath: string | undefined;\n\n if (argv.tool) {\n configDir = await mkdtemp(join(tmpdir(), \"vitemcp-dev-\"));\n configPath = join(configDir, \"mcp-cli.json\");\n await writeFile(configPath, buildDevConfig(argv.file), \"utf8\");\n }\n\n const [command, ...commandArgs] = buildDevCommand({\n configPath,\n file: argv.file,\n tool: argv.tool,\n toolArgs: argv.args,\n watch: argv.watch,\n });\n\n if (argv.verbose) {\n console.log(\n `[ViteMCP] Starting server: ${[command, ...commandArgs].join(\" \")}`,\n );\n console.log(`[ViteMCP] File: ${argv.file}`);\n console.log(\n `[ViteMCP] Watch mode: ${argv.watch ? \"enabled\" : \"disabled\"}`,\n );\n\n if (argv.tool) {\n console.log(`[ViteMCP] Tool: ${argv.tool}`);\n }\n }\n\n await execa(command, commandArgs, {\n stderr: \"inherit\",\n stdin: \"inherit\",\n stdout: \"inherit\",\n });\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to start development server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n if (argv.verbose && error instanceof Error && error.stack) {\n console.error(\"[ViteMCP Debug] Stack trace:\", error.stack);\n }\n\n // Not process.exit(): that would skip the `finally` block below and\n // leak the temporary config directory on every failed tool call.\n process.exitCode = 1;\n } finally {\n if (configDir) {\n await rm(configDir, { force: true, recursive: true });\n }\n }\n },\n )\n\n .command(\n \"inspect <file>\",\n \"Inspect a server file\",\n (yargs) => {\n return yargs.positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n });\n },\n\n async (argv) => {\n try {\n await execa({\n stderr: \"inherit\",\n stdout: \"inherit\",\n })`npx @modelcontextprotocol/inspector npx tsx ${argv.file}`;\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Failed to inspect server:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .command(\n \"validate <file>\",\n \"Validate a ViteMCP server file for syntax and basic structure\",\n (yargs) => {\n return yargs\n .positional(\"file\", {\n demandOption: true,\n describe: \"The path to the server file\",\n type: \"string\",\n })\n\n .option(\"strict\", {\n alias: \"s\",\n default: false,\n describe: \"Enable strict validation (type checking)\",\n type: \"boolean\",\n });\n },\n\n async (argv) => {\n try {\n const { existsSync } = await import(\"fs\");\n const { resolve } = await import(\"path\");\n const filePath = resolve(argv.file);\n\n if (!existsSync(filePath)) {\n console.error(`[ViteMCP Error] File not found: ${filePath}`);\n process.exit(1);\n }\n\n console.log(`[ViteMCP] Validating server file: ${filePath}`);\n\n const typeCheck = await runTypeCheck(filePath, argv.strict);\n\n if (typeCheck.failed) {\n console.error(\"[ViteMCP] ✗ TypeScript compilation failed\");\n\n const diagnostics = formatCommandFailure(typeCheck);\n\n if (diagnostics) {\n console.error(diagnostics);\n }\n\n process.exit(1);\n }\n\n console.log(\"[ViteMCP] ✓ TypeScript compilation successful\");\n\n const [structureCommand, ...structureArgs] =\n buildStructureCheckCommand(filePath);\n const structureCheck = await execa(structureCommand, structureArgs, {\n reject: false,\n });\n\n if (structureCheck.failed) {\n // The child explains the failure on stderr, which execa captures.\n // Without replaying it the user only ever sees the generic hint, even\n // when their server file has an error they could act on.\n const reason = formatCommandFailure(structureCheck);\n\n if (reason) {\n console.error(reason);\n } else {\n console.error(\"[ViteMCP] ✗ Server structure validation failed\");\n console.error(\n \"Make sure the file properly imports and uses ViteMCP\",\n );\n }\n\n process.exit(1);\n }\n\n console.log(\n \"[ViteMCP] ✓ All validations passed! Server file looks good.\",\n );\n } catch (error) {\n console.error(\n \"[ViteMCP Error] Validation failed:\",\n error instanceof Error ? error.message : String(error),\n );\n\n process.exit(1);\n }\n },\n )\n\n .help()\n .parseAsync();\n","export type DevCommandOptions = {\n /**\n * Path to a temporary mcp-cli config file that registers the dev server.\n * Only used in non-interactive mode (when `tool` is set).\n */\n configPath?: string;\n /**\n * Path to the server file to run.\n */\n file: string;\n /**\n * Name of the tool to call non-interactively. When omitted, the dev\n * command launches the interactive mcp-cli inspector instead.\n */\n tool?: string;\n /**\n * JSON string of arguments forwarded to the tool via mcp-cli `--args`.\n * Only used in non-interactive mode.\n */\n toolArgs?: string;\n /**\n * Watch the file for changes and restart the server. Only used in\n * interactive mode; a non-interactive call runs the server once.\n */\n watch?: boolean;\n};\n\n/**\n * The server name registered in the generated mcp-cli config. mcp-cli\n * addresses non-interactive targets as `<server-name>:<tool>`.\n */\nexport const DEV_SERVER_NAME = \"dev\";\n\n/**\n * Build the JSON config that registers the dev server with mcp-cli so it can\n * be invoked non-interactively. mcp-cli's non-interactive mode resolves the\n * server by name from a config file's `mcpServers` map, so an inline command\n * cannot be passed directly alongside `call-tool`.\n *\n * The server is never started in watch mode here: a non-interactive call\n * connects, calls one tool, and exits, so there is nothing to restart into.\n */\nexport const buildDevConfig = (file: string): string =>\n JSON.stringify(\n {\n mcpServers: {\n [DEV_SERVER_NAME]: {\n args: [\"tsx\", file],\n command: \"npx\",\n },\n },\n },\n null,\n 2,\n );\n\n/**\n * Build the argv that the dev command runs.\n *\n * This is an argv array rather than a shell string so that nothing has to be\n * quoted: file paths, tool names and JSON `--args` are passed to the child\n * process verbatim. Quoting through a shell would be wrong on Windows, where\n * cmd.exe treats single quotes as literal characters rather than as quoting.\n *\n * - Without `tool`: launches the interactive @wong2/mcp-cli inspector\n * against an inline `npx tsx <file>` server (existing behaviour).\n * - With `tool`: runs @wong2/mcp-cli in non-interactive mode against a\n * generated config file, calling the named tool and forwarding `--args`.\n */\nexport const buildDevCommand = (\n options: DevCommandOptions,\n): [string, ...string[]] => {\n const { configPath, file, tool, toolArgs, watch = false } = options;\n\n if (tool) {\n if (!configPath) {\n throw new Error(\n \"configPath is required when calling a tool non-interactively\",\n );\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"-c\",\n configPath,\n \"call-tool\",\n `${DEV_SERVER_NAME}:${tool}`,\n ...(toolArgs === undefined ? [] : [\"--args\", toolArgs]),\n ];\n }\n\n return [\n \"npx\",\n \"@wong2/mcp-cli\",\n \"npx\",\n \"tsx\",\n ...(watch ? [\"--watch\"] : []),\n file,\n ];\n};\n","import { randomUUID } from \"crypto\";\nimport { execa } from \"execa\";\nimport { existsSync } from \"fs\";\nimport { rm, writeFile } from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\n/**\n * The script `vitemcp validate` runs to check that a server file loads.\n *\n * The file arrives as `process.argv[1]` rather than being spliced into this\n * source. Spliced into a string literal, a Windows path loses its backslashes\n * to the child's own parser (`C:\\Users\\dev\\server.ts` reaches the import as\n * `C:Usersdevserver.ts`), and a quote or `#` in any path breaks the import —\n * each reported to the user as a problem with their file.\n *\n * It exits as soon as the import settles, once its verdict is flushed. A\n * server file normally starts its transport on load, which would otherwise\n * keep this process, and the command waiting on it, alive forever.\n */\nexport const STRUCTURE_CHECK_SCRIPT = `\n(async () => {\n let failure;\n\n try {\n await import(\"@vitemcp/server\");\n await import(process.argv[1]);\n } catch (error) {\n failure = error instanceof Error ? error.message : String(error);\n }\n\n if (failure === undefined) {\n process.stdout.write(\n \"[ViteMCP] ✓ Server structure validation passed\\\\n\",\n () => process.exit(0),\n );\n } else {\n process.stderr.write(\n \"[ViteMCP] ✗ Server structure validation failed: \" + failure + \"\\\\n\",\n () => process.exit(1),\n );\n }\n})();\n`;\n\n/**\n * Compiler options for a file with no `tsconfig.json` above it. The compiler's\n * own defaults target ES5, which rejects top-level await and the `#private`\n * members in `@vitemcp/server`'s declarations, so no server file could pass.\n */\nconst STANDALONE_COMPILER_OPTIONS = {\n allowImportingTsExtensions: true,\n module: \"esnext\",\n moduleResolution: \"bundler\",\n skipLibCheck: true,\n target: \"es2022\",\n};\n\n/**\n * What the throwaway config overrides in the project's own. `composite`\n * demands that every file the server imports be listed as a root, and only the\n * server file is; `incremental` writes a `.tsbuildinfo` named after the\n * throwaway config into the project.\n *\n * `composite` also implies `declaration`, which `declarationMap`,\n * `emitDeclarationOnly` and `isolatedDeclarations` each require, so a composite\n * project may set them without it — and with `composite` off, its check failed\n * with TS5069. Nothing is emitted, so they are switched off as well.\n */\nconst PROJECT_OVERRIDES = {\n composite: false,\n declarationMap: false,\n emitDeclarationOnly: false,\n incremental: false,\n isolatedDeclarations: false,\n};\n\n/**\n * Build the argv for the structure check.\n *\n * An argv array rather than a shell string, as in `buildDevCommand`, so nothing\n * has to be quoted. The file is converted to a `file:` URL here, so the child\n * imports it as given and never has to build the URL itself; and the child is\n * the Node binary running this CLI, so no PATH lookup is involved.\n */\nexport const buildStructureCheckCommand = (\n file: string,\n execPath: string = process.execPath,\n): [string, ...string[]] => [\n execPath,\n \"-e\",\n STRUCTURE_CHECK_SCRIPT,\n pathToFileURL(file).href,\n];\n\n/**\n * Build the argv for the type check. An argv array for the same reason as the\n * structure check: through a shell, a path containing a space reaches `tsc` as\n * several root files.\n */\nexport const buildTypeCheckCommand = (\n config: string,\n strict = false,\n): [string, ...string[]] => [\n \"npx\",\n \"tsc\",\n \"--noEmit\",\n \"--project\",\n config,\n ...(strict ? [\"--strict\"] : []),\n];\n\n/**\n * Build the throwaway config that type-checks one file.\n *\n * `tsc` ignores `tsconfig.json` whenever a file is named on its command line\n * and falls back to defaults no server file passes, so the file is named in a\n * config that extends the project's own instead. `include: []` keeps an\n * inherited `include` from pulling the rest of the project in.\n */\nexport const buildTypeCheckConfig = (file: string, tsconfig?: string): string =>\n JSON.stringify(\n tsconfig\n ? {\n compilerOptions: PROJECT_OVERRIDES,\n extends: tsconfig,\n files: [file],\n include: [],\n }\n : {\n compilerOptions: STANDALONE_COMPILER_OPTIONS,\n files: [file],\n include: [],\n },\n null,\n 2,\n );\n\n/**\n * The `tsconfig.json` that governs a file in `dir`: the nearest one at or above\n * it, which is also the one an editor checks the file against.\n */\nexport const findTsconfig = (dir: string): string | undefined => {\n for (let current = dir; ; current = dirname(current)) {\n const candidate = join(current, \"tsconfig.json\");\n\n if (existsSync(candidate)) {\n return candidate;\n }\n\n if (dirname(current) === current) {\n return undefined;\n }\n }\n};\n\n/**\n * The output of a failed check, for replaying to the user.\n *\n * `tsc` writes its diagnostics to stdout, and only a failure to launch it\n * reaches stderr, so reading stderr alone reported every real type error with\n * no detail. The structure check explains itself on stderr.\n */\nexport const formatCommandFailure = (result: {\n stderr?: unknown;\n stdout?: unknown;\n}): string =>\n [result.stderr, result.stdout]\n .map((output) => (typeof output === \"string\" ? output.trim() : \"\"))\n .filter(Boolean)\n .join(\"\\n\");\n\n/**\n * Type-check `file` under the compiler options of the project it belongs to.\n *\n * The throwaway config is written beside the project's own rather than to the\n * OS temp directory, because the compiler resolves type packages — the `types`\n * option and every visible `@types` package — from the config's directory. It\n * is removed before this returns, so a caller may exit straight away.\n */\nexport const runTypeCheck = async (file: string, strict = false) => {\n const tsconfig = findTsconfig(dirname(file));\n const config = join(\n dirname(tsconfig ?? file),\n `tsconfig.vitemcp-validate-${randomUUID()}.json`,\n );\n\n await writeFile(config, buildTypeCheckConfig(file, tsconfig), {\n flag: \"wx\",\n });\n\n try {\n const [command, ...args] = buildTypeCheckCommand(config, strict);\n\n return await execa(command, args, { reject: false });\n } finally {\n await rm(config, { force: true });\n }\n};\n"]}
@@ -88,7 +88,13 @@ var STANDALONE_COMPILER_OPTIONS = {
88
88
  skipLibCheck: true,
89
89
  target: "es2022"
90
90
  };
91
- var PROJECT_OVERRIDES = { composite: false, incremental: false };
91
+ var PROJECT_OVERRIDES = {
92
+ composite: false,
93
+ declarationMap: false,
94
+ emitDeclarationOnly: false,
95
+ incremental: false,
96
+ isolatedDeclarations: false
97
+ };
92
98
  var buildStructureCheckCommand = (file, execPath = process.execPath) => [
93
99
  execPath,
94
100
  "-e",