Skip to content

Report usage on licence verify and gate File Search trial on a key - #1466

Merged
helpcodeai merged 4 commits into
mainfrom
feat/licence-usage-report
Nov 3, 2026
Merged

helpcodeai merged 4 commits into
mainfrom
feat/licence-usage-report

Conversation

@helpcodeai

@helpcodeai helpcodeai commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Self-hosted is sold as Community (free, up to 3 active users) and Enterprise. To see which Community instances outgrow Community, and to get more of them registered:

  1. Usage report on licence verification (self-hosted only). GET /api/license/verify now also carries activeUsers, connectors, mcpServers and version. Never sent from Cloud. LICENSE_USAGE_REPORT=false turns it off. If counting fails, verification goes out without the counts.
  2. File Search trial needs a registered licence key on Community. A new trial opens File Search only while a licence key is registered (any plan, the free Community key from Settings → License included).
  3. Cloud verification names the workspace. On Cloud, verifyLicense(key, organizationId) sends organizationId, so the licence site (website PR chore(deps): bump next from 16.3.0 to 16.3.1 in the next group across 1 directory #485) can refuse a self-hosted licence that is not bound to that workspace. Its error (This licence is for a self-hosted AnythingMCP instance. On AnythingMCP Cloud, choose a Cloud plan on the License page.) reaches the user through setLicenseKey.

Changes

  • license/usage-report.ts (new): opt-out check, the instance-wide counts, and countActiveSeats. EditionService.countSeats now calls countActiveSeats, so the reported activeUsers is exactly the seat count behind the Community limit. That is a one-line change under ee/, authorised by the owner.
  • LicenseService.verifyLicense: on self-hosted it adds the usage params. On Cloud it adds organizationId when it has one; self-hosted never sends it. The key stays in the params as before. The verify call has never sent the instance id; activation and registration still do.
  • Cloud callers now pass the workspace: setLicenseKey (licence page activation), the periodic reverifyPaidLicenses, refreshLicense, the trial-extension re-verify, and LicenseReleaseService.assertNoLiveSubscription. GET /api/license/verify from the app (the controller) already passed it.
  • File Search gating:
    • The self-hosted "File Search trial" is the shared 30-day Enterprise trial (business_trial_ends_at). An admin starts it explicitly, and the first-run "company use" onboarding starts it too.
    • Gating that whole trial would also block the Enterprise/SSO evaluation and break onboarding. So the gate covers File Search only.
    • EditionService.startTrial now also writes the site setting file_search_trial_needs_key=true (the second ee/ line).
    • FileSearchAccessService (self-hosted, no paid key):
      • Trial unused, no key: locked, trialAvailable:false, keyRequired:'to_start'.
      • Trial running with the marker and no key: locked, keyRequired:'during_trial'.
      • Trial running with no marker (started before this release): File Search stays open until the trial ends.
      • Starter, Team, Business and Enterprise keys: unchanged.
      • Cloud: unchanged.
    • The 403 keeps code file_search_locked and now also carries keyRequired.
  • Self-hosted File Search text when the trial has ended now reads "File Search continues with AnythingMCP Enterprise (https://anythingmcp.com/contact?plan=enterprise)" instead of "Activate a licence". The Cloud text ("continues with a paid plan") is unchanged; both are asserted in the spec. The other File Search messages say "upgrade" without naming a plan and are shared with Cloud, so they are left as they are.
  • Frontend: the File Search LockedCard shows "Register a free Community key under Settings → License to start the 30-day File Search trial." in en/de/it, with a primary link to /settings/license. The Settings → License page is untouched.
  • Docs: LICENSE_USAGE_REPORT is in the env table and in .env.example. The "License Verification" section of docs/deployment.md lists exactly what is sent. docs/connectors/file-search.md has the key rule. docs/license-faq.md is untouched.

Cloud behaviour: no usage counts. Verify sends organizationId. File Search is unchanged.
Self-hosted behaviour: verify sends the usage counts unless opted out, and never organizationId. On Community, File Search needs a registered key for trials started from this release. Trials already running and paid keys are unchanged. Code mode, seat limits and plan features are unchanged.

Type

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Performance improvement
  • Other (describe below)

Testing

  • Added/updated unit tests
  • Tested manually (describe steps below)
  • No tests needed (explain why)

New tests:

  • license/license-verify-params.spec.ts:
    • Counts are sent on self-hosted, with the edition seat query.
    • No counts on Cloud.
    • No counts with LICENSE_USAGE_REPORT=false.
    • Verification still works when counting throws.
    • On Cloud, setLicenseKey sends organizationId and surfaces the site's self-hosted-licence error.
    • Self-hosted never sends organizationId.
  • file-search-access.service.spec.ts:
    • No key: a new trial is blocked (keyRequired:'to_start', 403 body).
    • A Community key allows it.
    • A trial started under the rule without a key stays locked.
    • A trial that was already running keeps File Search.
    • Paid keys and Cloud are unchanged.
  • edition.service.spec.ts: startTrial writes the marker.
  • trial-extension.controller.spec.ts: the re-verify now passes the workspace.

Commands (Node 25.2.1, after npm ci and npx prisma generate in the worktree):

Directory Command Result
packages/backend npm run lint 0 errors, 11 warnings (existing, none in touched files); no --fix changes
packages/backend npx tsc --noEmit -p tsconfig.json passes
packages/backend npm test -- --maxWorkers=4 991 suites passed, 6 skipped; 30382 tests passed, 1811 skipped
packages/frontend npm run lint 0 errors, 49 warnings (existing)
packages/frontend npx tsc --noEmit -p tsconfig.json passes

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • I have updated documentation (if applicable)
  • All existing tests pass (npm test)
  • This PR has a descriptive title

Related Issues

Relates to website PR #485 (organizationId on /api/license/verify).

Notes for review:

  • The Settings → License edition card still offers the Enterprise trial without a key. Its footnote "No payment details, no email" is still true for SSO and users, but not for File Search. That page is being changed in a parallel PR, so it is left as is here.
  • The licence site must accept or ignore the new query params (activeUsers, connectors, mcpServers, version).

Self-hosted licence verification now sends active users, connector and
MCP server counts and the app version (opt out with
LICENSE_USAGE_REPORT=false; never on Cloud). On Community, a trial
started from this release opens File Search only with a registered
licence key, the free Community key included; running trials keep it.
Cloud verification now names the workspace (organizationId) so the
licence site can refuse a self-hosted key.
@helpcodeai
helpcodeai enabled auto-merge (squash) November 3, 2026 07:57
@helpcodeai
helpcodeai merged commit 3b33167 into main Nov 3, 2026
14 checks passed
@helpcodeai
helpcodeai deleted the feat/licence-usage-report branch November 3, 2026 08:13
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant