@vibecheckai/cli 3.5.0 → 3.5.1
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/bin/registry.js +174 -449
- package/bin/runners/cli-utils.js +33 -2
- package/bin/runners/context/generators/cursor.js +2 -49
- package/bin/runners/context/generators/mcp.js +13 -15
- package/bin/runners/context/proof-context.js +1 -248
- package/bin/runners/lib/analysis-core.js +180 -198
- package/bin/runners/lib/analyzers.js +241 -2212
- package/bin/runners/lib/cli-output.js +210 -242
- package/bin/runners/lib/detectors-v2.js +785 -547
- package/bin/runners/lib/entitlements-v2.js +431 -161
- package/bin/runners/lib/error-handler.js +9 -16
- package/bin/runners/lib/global-flags.js +0 -37
- package/bin/runners/lib/html-proof-report.js +700 -350
- package/bin/runners/lib/missions/plan.js +6 -46
- package/bin/runners/lib/missions/templates.js +0 -232
- package/bin/runners/lib/route-truth.js +322 -1167
- package/bin/runners/lib/scan-output.js +467 -493
- package/bin/runners/lib/ship-output.js +27 -280
- package/bin/runners/lib/terminal-ui.js +700 -310
- package/bin/runners/lib/truth.js +321 -1004
- package/bin/runners/lib/unified-output.js +158 -162
- package/bin/runners/lib/upsell.js +204 -104
- package/bin/runners/runAIAgent.js +10 -5
- package/bin/runners/runAllowlist.js +324 -0
- package/bin/runners/runAuth.js +94 -344
- package/bin/runners/runCheckpoint.js +45 -43
- package/bin/runners/runContext.js +24 -139
- package/bin/runners/runDoctor.js +101 -136
- package/bin/runners/runEvidencePack.js +219 -0
- package/bin/runners/runFix.js +71 -82
- package/bin/runners/runGuard.js +119 -606
- package/bin/runners/runInit.js +60 -22
- package/bin/runners/runInstall.js +281 -0
- package/bin/runners/runLabs.js +341 -0
- package/bin/runners/runMcp.js +62 -139
- package/bin/runners/runPolish.js +83 -282
- package/bin/runners/runPromptFirewall.js +12 -5
- package/bin/runners/runProve.js +58 -33
- package/bin/runners/runReality.js +58 -81
- package/bin/runners/runReport.js +7 -34
- package/bin/runners/runRuntime.js +8 -5
- package/bin/runners/runScan.js +844 -219
- package/bin/runners/runShip.js +59 -721
- package/bin/runners/runValidate.js +11 -24
- package/bin/runners/runWatch.js +76 -131
- package/bin/vibecheck.js +69 -295
- package/mcp-server/ARCHITECTURE.md +339 -0
- package/mcp-server/__tests__/cache.test.ts +313 -0
- package/mcp-server/__tests__/executor.test.ts +239 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.cache/webpack/cache.pack +1 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.next/server/chunk.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.turbo/cache.json +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.venv/lib/env.py +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/dist/bundle.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/package.json +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/src/app.ts +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/venv/lib/config.py +4 -0
- package/mcp-server/__tests__/ids.test.ts +345 -0
- package/mcp-server/__tests__/integration/tools.test.ts +410 -0
- package/mcp-server/__tests__/registry.test.ts +365 -0
- package/mcp-server/__tests__/sandbox.test.ts +323 -0
- package/mcp-server/__tests__/schemas.test.ts +372 -0
- package/mcp-server/benchmarks/run-benchmarks.ts +304 -0
- package/mcp-server/examples/doctor.request.json +14 -0
- package/mcp-server/examples/doctor.response.json +53 -0
- package/mcp-server/examples/error.response.json +15 -0
- package/mcp-server/examples/scan.request.json +14 -0
- package/mcp-server/examples/scan.response.json +108 -0
- package/mcp-server/handlers/tool-handler.ts +671 -0
- package/mcp-server/index-v1.js +698 -0
- package/mcp-server/index-v3.ts +293 -0
- package/mcp-server/index.js +1080 -1757
- package/mcp-server/index.old.js +4137 -0
- package/mcp-server/lib/cache.ts +341 -0
- package/mcp-server/lib/errors.ts +346 -0
- package/mcp-server/lib/executor.ts +792 -0
- package/mcp-server/lib/ids.ts +238 -0
- package/mcp-server/lib/logger.ts +368 -0
- package/mcp-server/lib/metrics.ts +365 -0
- package/mcp-server/lib/sandbox.ts +337 -0
- package/mcp-server/lib/validator.ts +229 -0
- package/mcp-server/package-lock.json +165 -0
- package/mcp-server/package.json +32 -7
- package/mcp-server/premium-tools.js +2 -2
- package/mcp-server/registry/tools.json +476 -0
- package/mcp-server/schemas/error-envelope.schema.json +125 -0
- package/mcp-server/schemas/finding.schema.json +167 -0
- package/mcp-server/schemas/report-artifact.schema.json +88 -0
- package/mcp-server/schemas/run-request.schema.json +75 -0
- package/mcp-server/schemas/verdict.schema.json +168 -0
- package/mcp-server/tier-auth.d.ts +71 -0
- package/mcp-server/tier-auth.js +371 -183
- package/mcp-server/truth-context.js +90 -131
- package/mcp-server/truth-firewall-tools.js +1000 -1611
- package/mcp-server/tsconfig.json +34 -0
- package/mcp-server/vibecheck-tools.js +2 -2
- package/mcp-server/vitest.config.ts +16 -0
- package/package.json +3 -4
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +0 -474
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +0 -488
- package/bin/runners/lib/agent-firewall/change-packet/schema.json +0 -228
- package/bin/runners/lib/agent-firewall/change-packet/store.js +0 -200
- package/bin/runners/lib/agent-firewall/claims/claim-types.js +0 -21
- package/bin/runners/lib/agent-firewall/claims/extractor.js +0 -303
- package/bin/runners/lib/agent-firewall/claims/patterns.js +0 -24
- package/bin/runners/lib/agent-firewall/critic/index.js +0 -151
- package/bin/runners/lib/agent-firewall/critic/judge.js +0 -432
- package/bin/runners/lib/agent-firewall/critic/prompts.js +0 -305
- package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +0 -88
- package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +0 -75
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +0 -127
- package/bin/runners/lib/agent-firewall/evidence/resolver.js +0 -102
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +0 -213
- package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +0 -145
- package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +0 -19
- package/bin/runners/lib/agent-firewall/fs-hook/installer.js +0 -87
- package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +0 -184
- package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +0 -163
- package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +0 -107
- package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +0 -68
- package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +0 -66
- package/bin/runners/lib/agent-firewall/interceptor/base.js +0 -304
- package/bin/runners/lib/agent-firewall/interceptor/cursor.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/vscode.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +0 -34
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +0 -465
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +0 -604
- package/bin/runners/lib/agent-firewall/lawbook/index.js +0 -304
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +0 -514
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +0 -420
- package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
- package/bin/runners/lib/agent-firewall/logger.js +0 -141
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +0 -90
- package/bin/runners/lib/agent-firewall/policy/engine.js +0 -103
- package/bin/runners/lib/agent-firewall/policy/loader.js +0 -451
- package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +0 -86
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +0 -162
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +0 -189
- package/bin/runners/lib/agent-firewall/policy/rules/scope.js +0 -93
- package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +0 -57
- package/bin/runners/lib/agent-firewall/policy/schema.json +0 -183
- package/bin/runners/lib/agent-firewall/policy/verdict.js +0 -54
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +0 -394
- package/bin/runners/lib/agent-firewall/proposal/index.js +0 -212
- package/bin/runners/lib/agent-firewall/proposal/schema.js +0 -251
- package/bin/runners/lib/agent-firewall/proposal/validator.js +0 -386
- package/bin/runners/lib/agent-firewall/reality/index.js +0 -332
- package/bin/runners/lib/agent-firewall/reality/state.js +0 -625
- package/bin/runners/lib/agent-firewall/reality/watcher.js +0 -322
- package/bin/runners/lib/agent-firewall/risk/index.js +0 -173
- package/bin/runners/lib/agent-firewall/risk/scorer.js +0 -328
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +0 -321
- package/bin/runners/lib/agent-firewall/risk/vectors.js +0 -421
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +0 -472
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +0 -346
- package/bin/runners/lib/agent-firewall/simulator/index.js +0 -181
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +0 -380
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +0 -661
- package/bin/runners/lib/agent-firewall/time-machine/index.js +0 -267
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +0 -436
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +0 -490
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +0 -530
- package/bin/runners/lib/agent-firewall/truthpack/index.js +0 -67
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +0 -137
- package/bin/runners/lib/agent-firewall/unblock/planner.js +0 -337
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +0 -118
- package/bin/runners/lib/api-client.js +0 -269
- package/bin/runners/lib/audit-logger.js +0 -532
- package/bin/runners/lib/authority/authorities/architecture.js +0 -364
- package/bin/runners/lib/authority/authorities/compliance.js +0 -341
- package/bin/runners/lib/authority/authorities/human.js +0 -343
- package/bin/runners/lib/authority/authorities/quality.js +0 -420
- package/bin/runners/lib/authority/authorities/security.js +0 -228
- package/bin/runners/lib/authority/index.js +0 -293
- package/bin/runners/lib/authority-badge.js +0 -425
- package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
- package/bin/runners/lib/cli-charts.js +0 -368
- package/bin/runners/lib/cli-config-display.js +0 -405
- package/bin/runners/lib/cli-demo.js +0 -275
- package/bin/runners/lib/cli-errors.js +0 -438
- package/bin/runners/lib/cli-help-formatter.js +0 -439
- package/bin/runners/lib/cli-interactive-menu.js +0 -509
- package/bin/runners/lib/cli-prompts.js +0 -441
- package/bin/runners/lib/cli-scan-cards.js +0 -362
- package/bin/runners/lib/compliance-reporter.js +0 -710
- package/bin/runners/lib/conductor/index.js +0 -671
- package/bin/runners/lib/easy/README.md +0 -123
- package/bin/runners/lib/easy/index.js +0 -140
- package/bin/runners/lib/easy/interactive-wizard.js +0 -788
- package/bin/runners/lib/easy/one-click-firewall.js +0 -564
- package/bin/runners/lib/easy/zero-config-reality.js +0 -714
- package/bin/runners/lib/engines/accessibility-engine.js +0 -390
- package/bin/runners/lib/engines/api-consistency-engine.js +0 -467
- package/bin/runners/lib/engines/ast-cache.js +0 -99
- package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
- package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
- package/bin/runners/lib/engines/code-quality-engine.js +0 -255
- package/bin/runners/lib/engines/confidence-scoring.js +0 -276
- package/bin/runners/lib/engines/console-logs-engine.js +0 -115
- package/bin/runners/lib/engines/context-detection.js +0 -264
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +0 -533
- package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
- package/bin/runners/lib/engines/dead-code-engine.js +0 -198
- package/bin/runners/lib/engines/deprecated-api-engine.js +0 -226
- package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
- package/bin/runners/lib/engines/empty-catch-engine.js +0 -260
- package/bin/runners/lib/engines/env-variables-engine.js +0 -458
- package/bin/runners/lib/engines/error-handling-engine.js +0 -437
- package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
- package/bin/runners/lib/engines/file-filter.js +0 -131
- package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
- package/bin/runners/lib/engines/framework-detection.js +0 -508
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +0 -251
- package/bin/runners/lib/engines/import-order-engine.js +0 -429
- package/bin/runners/lib/engines/mock-data-engine.js +0 -315
- package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
- package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
- package/bin/runners/lib/engines/orchestrator.js +0 -334
- package/bin/runners/lib/engines/parallel-processor.js +0 -71
- package/bin/runners/lib/engines/performance-issues-engine.js +0 -405
- package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +0 -571
- package/bin/runners/lib/engines/todo-fixme-engine.js +0 -115
- package/bin/runners/lib/engines/type-aware-engine.js +0 -376
- package/bin/runners/lib/engines/unsafe-regex-engine.js +0 -225
- package/bin/runners/lib/engines/vibecheck-engines/README.md +0 -53
- package/bin/runners/lib/engines/vibecheck-engines/index.js +0 -124
- package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +0 -439
- package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
- package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
- package/bin/runners/lib/engines/vibecheck-engines/package.json +0 -13
- package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
- package/bin/runners/lib/enhanced-features/index.js +0 -305
- package/bin/runners/lib/enhanced-output.js +0 -631
- package/bin/runners/lib/enterprise.js +0 -300
- package/bin/runners/lib/exit-codes.js +0 -275
- package/bin/runners/lib/fingerprint.js +0 -377
- package/bin/runners/lib/firewall/command-validator.js +0 -351
- package/bin/runners/lib/firewall/config.js +0 -341
- package/bin/runners/lib/firewall/content-validator.js +0 -519
- package/bin/runners/lib/firewall/index.js +0 -101
- package/bin/runners/lib/firewall/path-validator.js +0 -256
- package/bin/runners/lib/help-formatter.js +0 -413
- package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
- package/bin/runners/lib/logger.js +0 -38
- package/bin/runners/lib/mcp-utils.js +0 -425
- package/bin/runners/lib/output/index.js +0 -1022
- package/bin/runners/lib/policy-engine.js +0 -652
- package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
- package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
- package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
- package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
- package/bin/runners/lib/polish/autofix/index.js +0 -200
- package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
- package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
- package/bin/runners/lib/polish/backend-checks.js +0 -148
- package/bin/runners/lib/polish/documentation-checks.js +0 -111
- package/bin/runners/lib/polish/frontend-checks.js +0 -168
- package/bin/runners/lib/polish/index.js +0 -71
- package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
- package/bin/runners/lib/polish/library-detection.js +0 -175
- package/bin/runners/lib/polish/performance-checks.js +0 -100
- package/bin/runners/lib/polish/security-checks.js +0 -148
- package/bin/runners/lib/polish/utils.js +0 -203
- package/bin/runners/lib/prompt-builder.js +0 -540
- package/bin/runners/lib/proof-certificate.js +0 -634
- package/bin/runners/lib/reality/accessibility-audit.js +0 -946
- package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
- package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
- package/bin/runners/lib/reality/performance-tracker.js +0 -1077
- package/bin/runners/lib/reality/scenario-generator.js +0 -1404
- package/bin/runners/lib/reality/visual-regression.js +0 -852
- package/bin/runners/lib/reality-profiler.js +0 -717
- package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
- package/bin/runners/lib/review/ai-code-review.js +0 -832
- package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
- package/bin/runners/lib/sbom-generator.js +0 -641
- package/bin/runners/lib/scan-output-enhanced.js +0 -512
- package/bin/runners/lib/security/owasp-scanner.js +0 -939
- package/bin/runners/lib/ship-output-enterprise.js +0 -239
- package/bin/runners/lib/unified-cli-output.js +0 -777
- package/bin/runners/lib/validators/contract-validator.js +0 -283
- package/bin/runners/lib/validators/dead-export-detector.js +0 -279
- package/bin/runners/lib/validators/dep-audit.js +0 -245
- package/bin/runners/lib/validators/env-validator.js +0 -319
- package/bin/runners/lib/validators/index.js +0 -120
- package/bin/runners/lib/validators/license-checker.js +0 -252
- package/bin/runners/lib/validators/route-validator.js +0 -290
- package/bin/runners/runAgent.d.ts +0 -5
- package/bin/runners/runAgent.js +0 -164
- package/bin/runners/runApprove.js +0 -1233
- package/bin/runners/runAuthority.js +0 -528
- package/bin/runners/runClassify.js +0 -862
- package/bin/runners/runConductor.js +0 -772
- package/bin/runners/runContainer.js +0 -366
- package/bin/runners/runContext.d.ts +0 -4
- package/bin/runners/runEasy.js +0 -410
- package/bin/runners/runFirewall.d.ts +0 -5
- package/bin/runners/runFirewall.js +0 -137
- package/bin/runners/runFirewallHook.d.ts +0 -5
- package/bin/runners/runFirewallHook.js +0 -59
- package/bin/runners/runIaC.js +0 -372
- package/bin/runners/runPolish.d.ts +0 -4
- package/bin/runners/runProof.zip +0 -0
- package/bin/runners/runTruth.d.ts +0 -5
- package/bin/runners/runTruth.js +0 -104
- package/bin/runners/runVibe.js +0 -791
- package/mcp-server/HARDENING_SUMMARY.md +0 -299
- package/mcp-server/agent-firewall-interceptor.js +0 -500
- package/mcp-server/authority-tools.js +0 -569
- package/mcp-server/conductor/conflict-resolver.js +0 -588
- package/mcp-server/conductor/execution-planner.js +0 -544
- package/mcp-server/conductor/index.js +0 -377
- package/mcp-server/conductor/lock-manager.js +0 -615
- package/mcp-server/conductor/request-queue.js +0 -550
- package/mcp-server/conductor/session-manager.js +0 -500
- package/mcp-server/conductor/tools.js +0 -510
- package/mcp-server/lib/api-client.cjs +0 -13
- package/mcp-server/lib/logger.cjs +0 -30
- package/mcp-server/logger.js +0 -173
- package/mcp-server/tools-v3.js +0 -1039
- package/mcp-server/tools.js +0 -495
- package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
package/mcp-server/tier-auth.js
CHANGED
|
@@ -1,286 +1,474 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP Server Tier Authentication
|
|
2
|
+
* MCP Server Tier Authentication & Authorization
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* - PRO ($69/mo): Fix, Prove & Enforce
|
|
4
|
+
* Provides tier checking for MCP tools.
|
|
5
|
+
* Uses @vibecheck/core tier-config.json as source of truth.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
* - Agent Conductor (multi-agent coordination)
|
|
11
|
-
* - Agent Firewall (enforce mode)
|
|
7
|
+
* SECURITY: Tier is ALWAYS fetched from /v1/me endpoint.
|
|
8
|
+
* NEVER parse tier from API key prefix - that's a bypass vulnerability.
|
|
12
9
|
*/
|
|
13
10
|
|
|
14
11
|
import fs from "fs/promises";
|
|
15
12
|
import path from "path";
|
|
16
13
|
import os from "os";
|
|
14
|
+
import { fileURLToPath } from "url";
|
|
17
15
|
|
|
18
16
|
// ============================================================================
|
|
19
|
-
//
|
|
17
|
+
// TIER DEFINITIONS - IMPORTED FROM @vibecheck/core (SINGLE SOURCE OF TRUTH)
|
|
20
18
|
// ============================================================================
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
|
|
20
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
|
|
22
|
+
// Load canonical tier config
|
|
23
|
+
let CANONICAL_TIER_CONFIG;
|
|
24
|
+
try {
|
|
25
|
+
// Try to load from monorepo relative path
|
|
26
|
+
const configPath = path.resolve(__dirname, "../packages/core/src/tier-config.json");
|
|
27
|
+
const configData = await fs.readFile(configPath, "utf-8");
|
|
28
|
+
CANONICAL_TIER_CONFIG = JSON.parse(configData);
|
|
29
|
+
} catch {
|
|
30
|
+
// Fallback: minimal inline config (should not happen in production)
|
|
31
|
+
console.warn("[vibecheck-mcp] Could not load canonical tier config, using minimal fallback");
|
|
32
|
+
CANONICAL_TIER_CONFIG = {
|
|
33
|
+
TIER_CONFIG: {
|
|
34
|
+
free: { id: "free", name: "Free", price: 0 },
|
|
35
|
+
starter: { id: "starter", name: "Starter", price: 29 },
|
|
36
|
+
pro: { id: "pro", name: "Pro", price: 99 },
|
|
37
|
+
compliance: { id: "compliance", name: "Compliance", price: 199 },
|
|
38
|
+
enterprise: { id: "enterprise", name: "Enterprise", price: 499 },
|
|
39
|
+
unlimited: { id: "unlimited", name: "Unlimited", price: 0 },
|
|
40
|
+
},
|
|
41
|
+
TIER_ORDER: ["free", "starter", "pro", "compliance", "enterprise", "unlimited"],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const TIER_ORDER = CANONICAL_TIER_CONFIG.TIER_ORDER || ['free', 'starter', 'pro', 'compliance', 'enterprise', 'unlimited'];
|
|
46
|
+
|
|
47
|
+
// MCP-specific rate limits per tier
|
|
48
|
+
const MCP_RATE_LIMITS = {
|
|
49
|
+
free: 10,
|
|
50
|
+
starter: 60,
|
|
51
|
+
pro: -1,
|
|
52
|
+
compliance: -1,
|
|
53
|
+
enterprise: -1,
|
|
54
|
+
unlimited: -1,
|
|
24
55
|
};
|
|
25
56
|
|
|
57
|
+
// Build TIERS object from canonical config
|
|
58
|
+
export const TIERS = {};
|
|
59
|
+
TIER_ORDER.forEach((tierId, index) => {
|
|
60
|
+
const config = CANONICAL_TIER_CONFIG.TIER_CONFIG[tierId];
|
|
61
|
+
TIERS[tierId] = {
|
|
62
|
+
name: config?.name?.toUpperCase() || tierId.toUpperCase(),
|
|
63
|
+
price: config?.price || 0,
|
|
64
|
+
order: index,
|
|
65
|
+
mcpRateLimit: MCP_RATE_LIMITS[tierId] ?? -1,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
26
69
|
// ============================================================================
|
|
27
|
-
//
|
|
70
|
+
// FEATURE -> TIER MAPPING (defines minimum tier for each feature)
|
|
71
|
+
// Must match CLI entitlements and @vibecheck/core
|
|
28
72
|
// ============================================================================
|
|
29
73
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* PRO TOOLS (8 Core + Authority + Conductor + Firewall) - Fix, Prove & Enforce
|
|
51
|
-
*/
|
|
52
|
-
export const PRO_TOOLS = [
|
|
53
|
-
// Core PRO tools
|
|
54
|
-
'vibecheck.ship',
|
|
55
|
-
'vibecheck.fix',
|
|
56
|
-
'vibecheck.prove',
|
|
57
|
-
'vibecheck.gate',
|
|
58
|
-
'vibecheck.badge',
|
|
59
|
-
'vibecheck.reality',
|
|
60
|
-
'vibecheck.ai_test',
|
|
61
|
-
'vibecheck.share',
|
|
74
|
+
const FEATURE_TIER_MAP = {
|
|
75
|
+
// FREE features
|
|
76
|
+
'scan': 'free',
|
|
77
|
+
'ship': 'free',
|
|
78
|
+
'ship.static': 'free',
|
|
79
|
+
'init': 'free',
|
|
80
|
+
'init.local': 'free',
|
|
81
|
+
'doctor': 'free',
|
|
82
|
+
'status': 'free',
|
|
83
|
+
'ctx': 'free',
|
|
84
|
+
'guard': 'free',
|
|
85
|
+
'context': 'free',
|
|
86
|
+
'fix': 'free',
|
|
87
|
+
'fix.plan_only': 'free',
|
|
88
|
+
'reality': 'free',
|
|
89
|
+
'reality.preview': 'free',
|
|
90
|
+
'report': 'free',
|
|
91
|
+
'report.html_md': 'free',
|
|
92
|
+
'mcp.help_only': 'free',
|
|
62
93
|
|
|
63
|
-
//
|
|
64
|
-
'
|
|
65
|
-
'
|
|
94
|
+
// STARTER features
|
|
95
|
+
'init.connect': 'starter',
|
|
96
|
+
'scan.autofix': 'starter',
|
|
97
|
+
'gate': 'starter',
|
|
98
|
+
'pr': 'starter',
|
|
99
|
+
'badge': 'starter',
|
|
100
|
+
'ship.full': 'starter',
|
|
101
|
+
'reality.basic': 'starter',
|
|
102
|
+
'report.sarif_csv': 'starter',
|
|
103
|
+
'mcp': 'starter',
|
|
104
|
+
'mcp.read_only': 'starter',
|
|
66
105
|
|
|
67
|
-
//
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
106
|
+
// PRO features
|
|
107
|
+
'prove': 'pro',
|
|
108
|
+
'fix.apply_patches': 'pro',
|
|
109
|
+
'fix.loop': 'pro',
|
|
110
|
+
'reality.full': 'pro',
|
|
111
|
+
'reality.advanced_auth_boundary': 'pro',
|
|
112
|
+
'replay': 'pro',
|
|
113
|
+
'share': 'pro',
|
|
114
|
+
'ai-test': 'pro',
|
|
115
|
+
'permissions': 'pro',
|
|
116
|
+
'graph': 'pro',
|
|
117
|
+
'mcp.full': 'pro',
|
|
118
|
+
'checkpoint.hallucination': 'pro',
|
|
73
119
|
|
|
74
|
-
//
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export const ALL_TOOLS = [...FREE_TOOLS, ...PRO_TOOLS];
|
|
120
|
+
// COMPLIANCE features
|
|
121
|
+
'report.compliance_packs': 'compliance',
|
|
122
|
+
'scan:compliance': 'compliance',
|
|
123
|
+
};
|
|
80
124
|
|
|
81
125
|
// ============================================================================
|
|
82
|
-
//
|
|
126
|
+
// CACHE
|
|
83
127
|
// ============================================================================
|
|
84
|
-
const tierCache = new Map();
|
|
85
|
-
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
86
128
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
129
|
+
let cachedMeResponse = null;
|
|
130
|
+
let cacheExpiry = 0;
|
|
131
|
+
const CACHE_TTL = 300000; // 5 minutes
|
|
132
|
+
|
|
133
|
+
function getCached() {
|
|
134
|
+
if (cachedMeResponse && Date.now() < cacheExpiry) {
|
|
135
|
+
return cachedMeResponse;
|
|
136
|
+
}
|
|
137
|
+
cachedMeResponse = null;
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function setCache(data) {
|
|
142
|
+
cachedMeResponse = data;
|
|
143
|
+
cacheExpiry = Date.now() + CACHE_TTL;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function clearTierCache() {
|
|
147
|
+
cachedMeResponse = null;
|
|
148
|
+
cacheExpiry = 0;
|
|
90
149
|
}
|
|
91
150
|
|
|
92
151
|
// ============================================================================
|
|
93
|
-
//
|
|
152
|
+
// CONFIG LOADING
|
|
94
153
|
// ============================================================================
|
|
95
154
|
|
|
96
|
-
|
|
97
|
-
|
|
155
|
+
async function loadUserConfig() {
|
|
156
|
+
try {
|
|
157
|
+
const configPath = path.join(os.homedir(), '.vibecheck', 'credentials.json');
|
|
158
|
+
const configData = await fs.readFile(configPath, 'utf-8');
|
|
159
|
+
return JSON.parse(configData);
|
|
160
|
+
} catch {
|
|
98
161
|
return null;
|
|
99
162
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function getApiUrl() {
|
|
166
|
+
return process.env.VIBECHECK_API_URL || 'https://api.vibecheckai.dev';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ============================================================================
|
|
170
|
+
// FETCH TIER FROM /v1/me (SERVER-AUTHORITATIVE)
|
|
171
|
+
// ============================================================================
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Fetch tier from /v1/me endpoint
|
|
175
|
+
*
|
|
176
|
+
* SECURITY: This is the ONLY way to determine tier.
|
|
177
|
+
* Never parse tier from API key prefix.
|
|
178
|
+
*/
|
|
179
|
+
async function fetchTierFromServer(apiKey) {
|
|
180
|
+
// Check cache first
|
|
181
|
+
const cached = getCached();
|
|
182
|
+
if (cached) {
|
|
183
|
+
return cached;
|
|
108
184
|
}
|
|
185
|
+
|
|
186
|
+
if (!apiKey) {
|
|
187
|
+
return { tier: 'free', features: [], authenticated: false };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const apiUrl = getApiUrl();
|
|
109
191
|
|
|
110
|
-
// Validate with API
|
|
111
192
|
try {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
193
|
+
const controller = new AbortController();
|
|
194
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
195
|
+
|
|
196
|
+
const response = await fetch(`${apiUrl}/api/v1/me`, {
|
|
197
|
+
method: 'GET',
|
|
198
|
+
headers: {
|
|
199
|
+
'Content-Type': 'application/json',
|
|
200
|
+
'X-API-Key': apiKey,
|
|
201
|
+
},
|
|
202
|
+
signal: controller.signal,
|
|
115
203
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
204
|
+
|
|
205
|
+
clearTimeout(timeoutId);
|
|
206
|
+
|
|
207
|
+
if (response.ok) {
|
|
208
|
+
const data = await response.json();
|
|
209
|
+
if (data.tier && TIER_ORDER.includes(data.tier)) {
|
|
210
|
+
setCache(data);
|
|
211
|
+
return data;
|
|
212
|
+
}
|
|
119
213
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Any paid plan = pro
|
|
125
|
-
const tier = (plan === 'free') ? 'free' : 'pro';
|
|
126
|
-
|
|
127
|
-
tierCache.set(keyHash, { tier, expiresAt: now + CACHE_TTL });
|
|
128
|
-
return tier;
|
|
129
|
-
|
|
130
|
-
} catch {
|
|
131
|
-
// Network error - check stale cache
|
|
132
|
-
if (cached) return cached.tier;
|
|
133
|
-
return null;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
// Network error - SECURITY: default to free tier
|
|
216
|
+
console.warn('[vibecheck-mcp] API unavailable, using free tier');
|
|
134
217
|
}
|
|
218
|
+
|
|
219
|
+
// Default to free tier on any error
|
|
220
|
+
return { tier: 'free', features: [], authenticated: false };
|
|
135
221
|
}
|
|
136
222
|
|
|
137
223
|
// ============================================================================
|
|
138
|
-
//
|
|
224
|
+
// TIER COMPARISON
|
|
139
225
|
// ============================================================================
|
|
140
226
|
|
|
141
|
-
|
|
142
|
-
|
|
227
|
+
function tierMeetsMinimum(current, required) {
|
|
228
|
+
const currentIndex = TIER_ORDER.indexOf(current);
|
|
229
|
+
const requiredIndex = TIER_ORDER.indexOf(required);
|
|
230
|
+
return currentIndex >= requiredIndex;
|
|
143
231
|
}
|
|
144
232
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// FREE can access FREE tools
|
|
150
|
-
return FREE_TOOLS.includes(toolName);
|
|
151
|
-
}
|
|
233
|
+
// ============================================================================
|
|
234
|
+
// PUBLIC API
|
|
235
|
+
// ============================================================================
|
|
152
236
|
|
|
153
237
|
/**
|
|
154
|
-
*
|
|
155
|
-
* - FREE: observe (log only)
|
|
156
|
-
* - PRO: enforce (block violations)
|
|
238
|
+
* Check if user has access to a specific feature
|
|
157
239
|
*/
|
|
158
|
-
export function
|
|
159
|
-
|
|
240
|
+
export async function checkFeatureAccess(featureName, providedApiKey = null) {
|
|
241
|
+
const userConfig = await loadUserConfig();
|
|
242
|
+
const apiKey = providedApiKey || userConfig?.apiKey;
|
|
243
|
+
|
|
244
|
+
// Fetch tier from server
|
|
245
|
+
const meData = await fetchTierFromServer(apiKey);
|
|
246
|
+
const currentTier = meData.tier || 'free';
|
|
247
|
+
const currentTierConfig = TIERS[currentTier] || TIERS.free;
|
|
248
|
+
|
|
249
|
+
// Get required tier for this feature
|
|
250
|
+
const requiredTier = FEATURE_TIER_MAP[featureName] || 'pro'; // Default to pro for unknown features
|
|
251
|
+
const requiredTierConfig = TIERS[requiredTier] || TIERS.pro;
|
|
252
|
+
|
|
253
|
+
// Check if current tier meets requirement
|
|
254
|
+
const hasAccess = tierMeetsMinimum(currentTier, requiredTier);
|
|
255
|
+
|
|
256
|
+
if (!hasAccess) {
|
|
257
|
+
return {
|
|
258
|
+
hasAccess: false,
|
|
259
|
+
tier: currentTier,
|
|
260
|
+
requiredTier,
|
|
261
|
+
reason: `${featureName} requires ${requiredTierConfig.name} tier ($${requiredTierConfig.price}/mo) or higher. Current tier: ${currentTierConfig.name}`,
|
|
262
|
+
upgradeUrl: 'https://vibecheckai.dev/pricing'
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
hasAccess: true,
|
|
268
|
+
tier: currentTier,
|
|
269
|
+
reason: 'Access granted'
|
|
270
|
+
};
|
|
160
271
|
}
|
|
161
272
|
|
|
162
273
|
/**
|
|
163
|
-
*
|
|
274
|
+
* Middleware for MCP tool handlers
|
|
164
275
|
*/
|
|
165
|
-
export function
|
|
166
|
-
return
|
|
276
|
+
export function withTierCheck(featureName, handler) {
|
|
277
|
+
return async (args) => {
|
|
278
|
+
const access = await checkFeatureAccess(featureName, args?.apiKey);
|
|
279
|
+
|
|
280
|
+
if (!access.hasAccess) {
|
|
281
|
+
return {
|
|
282
|
+
content: [{
|
|
283
|
+
type: "text",
|
|
284
|
+
text: `🚫 UPGRADE REQUIRED\n\n${access.reason}\n\nUpgrade at: ${access.upgradeUrl}`
|
|
285
|
+
}],
|
|
286
|
+
isError: true
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
args._tier = access.tier;
|
|
291
|
+
return handler(args);
|
|
292
|
+
};
|
|
167
293
|
}
|
|
168
294
|
|
|
169
295
|
/**
|
|
170
|
-
* Check if user
|
|
296
|
+
* Check if user has access to a specific MCP tool
|
|
171
297
|
*/
|
|
172
|
-
export function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
298
|
+
export async function checkMcpToolAccess(toolName, providedApiKey = null) {
|
|
299
|
+
const userConfig = await loadUserConfig();
|
|
300
|
+
const apiKey = providedApiKey || userConfig?.apiKey;
|
|
301
|
+
|
|
302
|
+
// Fetch tier from server
|
|
303
|
+
const meData = await fetchTierFromServer(apiKey);
|
|
304
|
+
const currentTier = meData.tier || 'free';
|
|
305
|
+
|
|
306
|
+
// Unlimited and compliance have full access
|
|
307
|
+
if (currentTier === 'unlimited' || currentTier === 'compliance' || currentTier === 'enterprise') {
|
|
178
308
|
return {
|
|
179
|
-
hasAccess:
|
|
180
|
-
tier:
|
|
181
|
-
reason:
|
|
182
|
-
? 'Access granted (free tool)'
|
|
183
|
-
: 'This tool requires Pro. Set API key with `vibecheck login`.',
|
|
309
|
+
hasAccess: true,
|
|
310
|
+
tier: currentTier,
|
|
311
|
+
reason: 'Full MCP access'
|
|
184
312
|
};
|
|
185
313
|
}
|
|
186
314
|
|
|
187
|
-
|
|
315
|
+
// For now, allow all MCP tools for pro tier
|
|
316
|
+
// Individual tool gating can be added later if needed
|
|
317
|
+
if (currentTier === 'pro') {
|
|
318
|
+
return {
|
|
319
|
+
hasAccess: true,
|
|
320
|
+
tier: currentTier,
|
|
321
|
+
reason: 'Pro MCP access'
|
|
322
|
+
};
|
|
323
|
+
}
|
|
188
324
|
|
|
189
|
-
|
|
325
|
+
// Starter has limited MCP access (read-only tools)
|
|
326
|
+
if (currentTier === 'starter') {
|
|
327
|
+
// Allow read-only tools
|
|
328
|
+
const readOnlyTools = [
|
|
329
|
+
'vibecheck.ctx',
|
|
330
|
+
'vibecheck.scan',
|
|
331
|
+
'vibecheck.ship',
|
|
332
|
+
'vibecheck.get_truthpack',
|
|
333
|
+
'vibecheck.validate_claim',
|
|
334
|
+
'vibecheck.search_evidence',
|
|
335
|
+
];
|
|
336
|
+
|
|
337
|
+
if (readOnlyTools.includes(toolName)) {
|
|
338
|
+
return {
|
|
339
|
+
hasAccess: true,
|
|
340
|
+
tier: currentTier,
|
|
341
|
+
reason: 'Starter read-only access'
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
190
345
|
return {
|
|
191
346
|
hasAccess: false,
|
|
192
|
-
tier:
|
|
193
|
-
|
|
347
|
+
tier: currentTier,
|
|
348
|
+
requiredTier: 'pro',
|
|
349
|
+
reason: `${toolName} requires PRO tier ($99/mo). Current: STARTER`,
|
|
350
|
+
upgradeUrl: 'https://vibecheckai.dev/pricing'
|
|
194
351
|
};
|
|
195
352
|
}
|
|
196
353
|
|
|
197
|
-
|
|
354
|
+
// Free tier has very limited MCP access
|
|
355
|
+
const freeTools = [
|
|
356
|
+
'vibecheck.get_truthpack',
|
|
357
|
+
'vibecheck.validate_claim',
|
|
358
|
+
'vibecheck.search_evidence',
|
|
359
|
+
];
|
|
360
|
+
|
|
361
|
+
if (freeTools.includes(toolName)) {
|
|
362
|
+
return {
|
|
363
|
+
hasAccess: true,
|
|
364
|
+
tier: 'free',
|
|
365
|
+
reason: 'Free tier access'
|
|
366
|
+
};
|
|
367
|
+
}
|
|
198
368
|
|
|
199
369
|
return {
|
|
200
|
-
hasAccess,
|
|
201
|
-
tier,
|
|
202
|
-
|
|
203
|
-
reason:
|
|
204
|
-
|
|
205
|
-
: `${toolName} requires Pro ($69/mo). Upgrade at https://vibecheckai.dev/pricing`,
|
|
370
|
+
hasAccess: false,
|
|
371
|
+
tier: 'free',
|
|
372
|
+
requiredTier: 'starter',
|
|
373
|
+
reason: `${toolName} requires STARTER tier ($29/mo) or higher. Current: FREE`,
|
|
374
|
+
upgradeUrl: 'https://vibecheckai.dev/pricing'
|
|
206
375
|
};
|
|
207
376
|
}
|
|
208
377
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
export function withTierCheck(toolName, handler) {
|
|
378
|
+
/**
|
|
379
|
+
* Middleware for MCP tool handlers with tool-specific checking
|
|
380
|
+
*/
|
|
381
|
+
export function withMcpToolCheck(toolName, handler) {
|
|
214
382
|
return async (args) => {
|
|
215
|
-
const access = await
|
|
383
|
+
const access = await checkMcpToolAccess(toolName, args?.apiKey);
|
|
216
384
|
|
|
217
385
|
if (!access.hasAccess) {
|
|
218
386
|
return {
|
|
219
387
|
content: [{
|
|
220
388
|
type: "text",
|
|
221
|
-
text:
|
|
389
|
+
text: `🚫 UPGRADE REQUIRED\n\n${access.reason}\n\nUpgrade at: ${access.upgradeUrl}`
|
|
222
390
|
}],
|
|
223
391
|
isError: true
|
|
224
392
|
};
|
|
225
393
|
}
|
|
226
394
|
|
|
227
395
|
args._tier = access.tier;
|
|
228
|
-
args._firewallMode = access.firewallMode;
|
|
229
396
|
return handler(args);
|
|
230
397
|
};
|
|
231
398
|
}
|
|
232
399
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
async function loadUserConfig() {
|
|
238
|
-
try {
|
|
239
|
-
const configPath = path.join(os.homedir(), '.vibecheck', 'credentials.json');
|
|
240
|
-
const data = await fs.readFile(configPath, 'utf-8');
|
|
241
|
-
return JSON.parse(data);
|
|
242
|
-
} catch {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Get current user info
|
|
402
|
+
*/
|
|
247
403
|
export async function getUserInfo() {
|
|
248
404
|
const config = await loadUserConfig();
|
|
249
|
-
|
|
250
405
|
if (!config?.apiKey) {
|
|
251
406
|
return {
|
|
252
407
|
authenticated: false,
|
|
253
408
|
tier: 'free',
|
|
254
|
-
|
|
255
|
-
firewallMode: 'observe',
|
|
409
|
+
message: 'Not authenticated. Run: vibecheck auth --key YOUR_API_KEY'
|
|
256
410
|
};
|
|
257
411
|
}
|
|
258
412
|
|
|
259
|
-
const
|
|
413
|
+
const meData = await fetchTierFromServer(config.apiKey);
|
|
414
|
+
const tier = meData.tier || 'free';
|
|
415
|
+
const tierConfig = TIERS[tier] || TIERS.free;
|
|
260
416
|
|
|
261
417
|
return {
|
|
262
|
-
authenticated:
|
|
263
|
-
tier
|
|
418
|
+
authenticated: meData.authenticated || false,
|
|
419
|
+
tier,
|
|
420
|
+
tierName: tierConfig.name,
|
|
264
421
|
email: config.email,
|
|
265
|
-
|
|
266
|
-
firewallMode: getFirewallMode(tier || 'free'),
|
|
422
|
+
authenticatedAt: config.authenticatedAt,
|
|
267
423
|
};
|
|
268
424
|
}
|
|
269
425
|
|
|
270
|
-
|
|
271
|
-
|
|
426
|
+
/**
|
|
427
|
+
* Get list of MCP tools available for current tier
|
|
428
|
+
*/
|
|
429
|
+
export async function getAvailableMcpTools(providedApiKey = null) {
|
|
430
|
+
const userConfig = await loadUserConfig();
|
|
431
|
+
const apiKey = providedApiKey || userConfig?.apiKey;
|
|
432
|
+
|
|
433
|
+
const meData = await fetchTierFromServer(apiKey);
|
|
434
|
+
const currentTier = meData.tier || 'free';
|
|
435
|
+
|
|
436
|
+
// Return tools based on tier
|
|
437
|
+
if (currentTier === 'unlimited' || currentTier === 'compliance' || currentTier === 'enterprise') {
|
|
438
|
+
return { tier: currentTier, tools: ['*'], unlimited: true };
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (currentTier === 'pro') {
|
|
442
|
+
return {
|
|
443
|
+
tier: currentTier,
|
|
444
|
+
tools: ['*'], // Pro has full MCP access
|
|
445
|
+
unlimited: true
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (currentTier === 'starter') {
|
|
450
|
+
return {
|
|
451
|
+
tier: currentTier,
|
|
452
|
+
tools: [
|
|
453
|
+
'vibecheck.ctx',
|
|
454
|
+
'vibecheck.scan',
|
|
455
|
+
'vibecheck.ship',
|
|
456
|
+
'vibecheck.get_truthpack',
|
|
457
|
+
'vibecheck.validate_claim',
|
|
458
|
+
'vibecheck.search_evidence',
|
|
459
|
+
],
|
|
460
|
+
unlimited: false
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Free tier
|
|
272
465
|
return {
|
|
273
|
-
tier:
|
|
274
|
-
tools:
|
|
275
|
-
|
|
466
|
+
tier: 'free',
|
|
467
|
+
tools: [
|
|
468
|
+
'vibecheck.get_truthpack',
|
|
469
|
+
'vibecheck.validate_claim',
|
|
470
|
+
'vibecheck.search_evidence',
|
|
471
|
+
],
|
|
472
|
+
unlimited: false
|
|
276
473
|
};
|
|
277
474
|
}
|
|
278
|
-
|
|
279
|
-
// Legacy exports for backward compatibility
|
|
280
|
-
export async function getFeatureAccessStatus(featureName, apiKey) {
|
|
281
|
-
return getMcpToolAccess(featureName, apiKey);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export function withMcpToolCheck(toolName, handler) {
|
|
285
|
-
return withTierCheck(toolName, handler);
|
|
286
|
-
}
|