mergen-server 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +57 -0
- package/README.md +96 -0
- package/dist/__stubs__/calibration.js +471 -0
- package/dist/__stubs__/causal.js +601 -0
- package/dist/__stubs__/closed-source.js +150 -0
- package/dist/__stubs__/license.js +35 -0
- package/dist/__stubs__/plans.js +197 -0
- package/dist/app.js +467 -0
- package/dist/cli.js +250 -0
- package/dist/commands/agent-identity.js +79 -0
- package/dist/commands/gate.js +107 -0
- package/dist/commands/github.js +632 -0
- package/dist/commands/incident.js +644 -0
- package/dist/commands/policy.js +710 -0
- package/dist/commands/scan.js +243 -0
- package/dist/commands/setup.js +1218 -0
- package/dist/commands/shared.js +109 -0
- package/dist/commands/team.js +809 -0
- package/dist/datadog/blame-attribution.js +228 -0
- package/dist/datadog/client.js +159 -0
- package/dist/datadog/compactor.js +169 -0
- package/dist/datadog/fingerprinter.js +34 -0
- package/dist/datadog/incident-state.js +21 -0
- package/dist/datadog/line-matcher.js +56 -0
- package/dist/datadog/memory-store.js +399 -0
- package/dist/datadog/otel-trace.js +67 -0
- package/dist/index.js +505 -0
- package/dist/intelligence/action-risk.js +132 -0
- package/dist/intelligence/activity-feed.js +40 -0
- package/dist/intelligence/agent-identity.js +115 -0
- package/dist/intelligence/agent-pipeline.js +329 -0
- package/dist/intelligence/agent-profiles.js +81 -0
- package/dist/intelligence/ai-commit.js +16 -0
- package/dist/intelligence/approval-analytics.js +42 -0
- package/dist/intelligence/approval-events.js +5 -0
- package/dist/intelligence/arch-boundaries.js +94 -0
- package/dist/intelligence/arch-graph.js +117 -0
- package/dist/intelligence/autonomy.js +397 -0
- package/dist/intelligence/azure-broker.js +57 -0
- package/dist/intelligence/azure-proxy-sessions.js +49 -0
- package/dist/intelligence/baseline.js +1 -0
- package/dist/intelligence/behavior-baseline.js +134 -0
- package/dist/intelligence/billing.js +1 -0
- package/dist/intelligence/blast-radius.js +224 -0
- package/dist/intelligence/bypass.js +157 -0
- package/dist/intelligence/calibration-classifier.js +77 -0
- package/dist/intelligence/calibration-git-sync.js +74 -0
- package/dist/intelligence/calibration.js +1 -0
- package/dist/intelligence/cascade-detector.js +58 -0
- package/dist/intelligence/case-study-generator.js +126 -0
- package/dist/intelligence/causal-graph.js +126 -0
- package/dist/intelligence/causal.js +1 -0
- package/dist/intelligence/change-risk.js +102 -0
- package/dist/intelligence/compliance-report.js +134 -0
- package/dist/intelligence/confidence-report.js +85 -0
- package/dist/intelligence/corpus-to-policy.js +140 -0
- package/dist/intelligence/credential-broker.js +112 -0
- package/dist/intelligence/credential-misuse.js +39 -0
- package/dist/intelligence/debug-sessions.js +108 -0
- package/dist/intelligence/decision-escalation.js +36 -0
- package/dist/intelligence/decision-memory.js +47 -0
- package/dist/intelligence/decision-similarity.js +85 -0
- package/dist/intelligence/default-safety-tests.js +53 -0
- package/dist/intelligence/degradation-watcher.js +108 -0
- package/dist/intelligence/detector-plugins.js +70 -0
- package/dist/intelligence/detectors.js +1 -0
- package/dist/intelligence/device-auth.js +138 -0
- package/dist/intelligence/diff-size.js +42 -0
- package/dist/intelligence/ebpf-verify.js +45 -0
- package/dist/intelligence/enterprise-policy-engine.js +1122 -0
- package/dist/intelligence/error-fingerprint.js +1 -0
- package/dist/intelligence/execution-gate.js +100 -0
- package/dist/intelligence/execution-mode.js +22 -0
- package/dist/intelligence/gate-analytics.js +256 -0
- package/dist/intelligence/gate-decision.js +64 -0
- package/dist/intelligence/gcp-broker.js +50 -0
- package/dist/intelligence/git-adr-sync.js +207 -0
- package/dist/intelligence/hitl-hold.js +460 -0
- package/dist/intelligence/hypothesis-history.js +93 -0
- package/dist/intelligence/idp-identity.js +83 -0
- package/dist/intelligence/impl-critic.js +216 -0
- package/dist/intelligence/incident-autopilot.js +622 -0
- package/dist/intelligence/incident-replay.js +162 -0
- package/dist/intelligence/incident-result-cache.js +33 -0
- package/dist/intelligence/incident-similarity.js +58 -0
- package/dist/intelligence/infra-detectors.js +312 -0
- package/dist/intelligence/license.js +185 -0
- package/dist/intelligence/llm-spokesperson.js +62 -0
- package/dist/intelligence/mcp-prompts.js +320 -0
- package/dist/intelligence/mcp-resources.js +171 -0
- package/dist/intelligence/normalize.js +108 -0
- package/dist/intelligence/notifications.js +83 -0
- package/dist/intelligence/oidc-issuer.js +87 -0
- package/dist/intelligence/override-corpus.js +597 -0
- package/dist/intelligence/planning-gate.js +84 -0
- package/dist/intelligence/plans.js +223 -0
- package/dist/intelligence/platt-scaling.js +164 -0
- package/dist/intelligence/policy-proposals.js +84 -0
- package/dist/intelligence/policy-suggester.js +161 -0
- package/dist/intelligence/policy-sync.js +103 -0
- package/dist/intelligence/policy-test-runner.js +35 -0
- package/dist/intelligence/postmortem-parser.js +181 -0
- package/dist/intelligence/postmortem-retrieval.js +224 -0
- package/dist/intelligence/postmortem-store.js +596 -0
- package/dist/intelligence/pr-commenter.js +81 -0
- package/dist/intelligence/pr-policy-gate.js +38 -0
- package/dist/intelligence/pr-shadow-analyzer.js +229 -0
- package/dist/intelligence/process-tree.js +108 -0
- package/dist/intelligence/prompts.js +1 -0
- package/dist/intelligence/replay.js +38 -0
- package/dist/intelligence/repro-steps.js +1 -0
- package/dist/intelligence/resource-extractors.js +0 -0
- package/dist/intelligence/resource-file-context.js +138 -0
- package/dist/intelligence/risk-score.js +22 -0
- package/dist/intelligence/rollback.js +137 -0
- package/dist/intelligence/runbook-updater.js +143 -0
- package/dist/intelligence/sandbox.js +194 -0
- package/dist/intelligence/script-trust.js +104 -0
- package/dist/intelligence/session-metrics.js +67 -0
- package/dist/intelligence/session-threat-tracker.js +231 -0
- package/dist/intelligence/shadow-digest-cron.js +81 -0
- package/dist/intelligence/shadow-log.js +284 -0
- package/dist/intelligence/shell-ast.js +145 -0
- package/dist/intelligence/siem-forward.js +104 -0
- package/dist/intelligence/slack-digest.js +151 -0
- package/dist/intelligence/slack-override-loop.js +217 -0
- package/dist/intelligence/slack-routing.js +67 -0
- package/dist/intelligence/slack.js +900 -0
- package/dist/intelligence/sql-ast.js +31 -0
- package/dist/intelligence/team.js +1 -0
- package/dist/intelligence/telemetry.js +76 -0
- package/dist/intelligence/threshold-optimizer.js +75 -0
- package/dist/intelligence/token-budget.js +66 -0
- package/dist/intelligence/tool-guard.js +708 -0
- package/dist/intelligence/tool-manifest 2.js +74 -0
- package/dist/intelligence/tool-manifest.js +125 -0
- package/dist/intelligence/tools-analysis.js +857 -0
- package/dist/intelligence/tools-arch.js +152 -0
- package/dist/intelligence/tools-autonomy.js +495 -0
- package/dist/intelligence/tools-blast-radius.js +140 -0
- package/dist/intelligence/tools-browser.js +431 -0
- package/dist/intelligence/tools-change-timeline.js +154 -0
- package/dist/intelligence/tools-credentials.js +117 -0
- package/dist/intelligence/tools-datadog.js +233 -0
- package/dist/intelligence/tools-debug-sessions.js +209 -0
- package/dist/intelligence/tools-discovery.js +284 -0
- package/dist/intelligence/tools-infra.js +612 -0
- package/dist/intelligence/tools-intent.js +128 -0
- package/dist/intelligence/tools-memory.js +514 -0
- package/dist/intelligence/tools-runbook.js +951 -0
- package/dist/intelligence/tools-sessions.js +107 -0
- package/dist/intelligence/tools-state.js +232 -0
- package/dist/intelligence/tools-utility.js +430 -0
- package/dist/intelligence/tools-validate.js +215 -0
- package/dist/intelligence/tools.js +1 -0
- package/dist/intelligence/trace-context.js +11 -0
- package/dist/intelligence/unclassified-clusters.js +87 -0
- package/dist/intelligence/usage.js +195 -0
- package/dist/routes/active-authors.js +63 -0
- package/dist/routes/activity-feed.js +21 -0
- package/dist/routes/adr.js +117 -0
- package/dist/routes/agent-activity.js +184 -0
- package/dist/routes/agent-blunders.js +163 -0
- package/dist/routes/agents.js +175 -0
- package/dist/routes/api-keys.js +65 -0
- package/dist/routes/arch.js +75 -0
- package/dist/routes/audit-export.js +93 -0
- package/dist/routes/billing-dashboard.js +158 -0
- package/dist/routes/billing-outcome.js +77 -0
- package/dist/routes/calibration.js +305 -0
- package/dist/routes/ci-gate-history.js +20 -0
- package/dist/routes/ci-gate.js +232 -0
- package/dist/routes/ci.js +293 -0
- package/dist/routes/compliance-report.js +24 -0
- package/dist/routes/confidence.js +30 -0
- package/dist/routes/credentials.js +119 -0
- package/dist/routes/dashboard.js +1407 -0
- package/dist/routes/decision-memory.js +42 -0
- package/dist/routes/demo.js +844 -0
- package/dist/routes/device-auth-stub.js +173 -0
- package/dist/routes/explain-why.js +39 -0
- package/dist/routes/gate-analytics.js +213 -0
- package/dist/routes/gate.js +28 -0
- package/dist/routes/github-webhook.js +364 -0
- package/dist/routes/habituation.js +30 -0
- package/dist/routes/health-integrations.js +243 -0
- package/dist/routes/heartbeats.js +45 -0
- package/dist/routes/hitl.js +364 -0
- package/dist/routes/impact-report.js +645 -0
- package/dist/routes/incident-webhook.js +63 -0
- package/dist/routes/incidents.js +366 -0
- package/dist/routes/layers.js +62 -0
- package/dist/routes/license.js +187 -0
- package/dist/routes/oidc-issuer.js +30 -0
- package/dist/routes/onboarding.js +170 -0
- package/dist/routes/otel.js +67 -0
- package/dist/routes/otlp-receiver.js +179 -0
- package/dist/routes/overrides.js +241 -0
- package/dist/routes/pagerduty.js +258 -0
- package/dist/routes/policies.js +809 -0
- package/dist/routes/policy-nl.js +169 -0
- package/dist/routes/postmortem.js +102 -0
- package/dist/routes/pr-shadow.js +47 -0
- package/dist/routes/rbac.js +61 -0
- package/dist/routes/replay.js +17 -0
- package/dist/routes/risk-report.js +164 -0
- package/dist/routes/runbooks.js +125 -0
- package/dist/routes/safety-test.js +174 -0
- package/dist/routes/sdk.js +222 -0
- package/dist/routes/sensor.js +819 -0
- package/dist/routes/sentry.js +140 -0
- package/dist/routes/sessions.js +43 -0
- package/dist/routes/setup-ui.js +594 -0
- package/dist/routes/shadow-report.js +107 -0
- package/dist/routes/slack-routing.js +171 -0
- package/dist/routes/team-usage.js +71 -0
- package/dist/routes/telemetry.js +28 -0
- package/dist/routes/tenants.js +199 -0
- package/dist/routes/tickets.js +167 -0
- package/dist/routes/validate.js +13 -0
- package/dist/routes/war-room.js +113 -0
- package/dist/scripts/check-arch.js +22 -0
- package/dist/seeds/community-corpus.js +176 -0
- package/dist/seeds/corpus.js +1224 -0
- package/dist/sensor/action-ledger.js +327 -0
- package/dist/sensor/adr-store.js +140 -0
- package/dist/sensor/agent-blunder-store.js +370 -0
- package/dist/sensor/agent-context-store.js +225 -0
- package/dist/sensor/agent-memory-store.js +231 -0
- package/dist/sensor/audit-fetch.js +23 -0
- package/dist/sensor/audit-log.js +273 -0
- package/dist/sensor/buffer-schemas.js +225 -0
- package/dist/sensor/buffer.js +599 -0
- package/dist/sensor/bypass-tracker.js +93 -0
- package/dist/sensor/ci-gate-history.js +70 -0
- package/dist/sensor/cloud-auth.js +183 -0
- package/dist/sensor/commit-context-store.js +235 -0
- package/dist/sensor/docker-log-stream.js +164 -0
- package/dist/sensor/docker-monitor.js +122 -0
- package/dist/sensor/extended-buffer.js +46 -0
- package/dist/sensor/feedback-token.js +41 -0
- package/dist/sensor/file-lock.js +6 -0
- package/dist/sensor/fs-watcher.js +106 -0
- package/dist/sensor/gate-heartbeat.js +122 -0
- package/dist/sensor/git-suspect.js +136 -0
- package/dist/sensor/habituation-store.js +77 -0
- package/dist/sensor/heartbeat-monitor.js +133 -0
- package/dist/sensor/incident-store.js +340 -0
- package/dist/sensor/infra-normalizer.js +513 -0
- package/dist/sensor/ingest.js +339 -0
- package/dist/sensor/jest-reporter.js +52 -0
- package/dist/sensor/k8s-events.js +132 -0
- package/dist/sensor/layer2-store.js +111 -0
- package/dist/sensor/layer3-store.js +230 -0
- package/dist/sensor/layer4-store.js +147 -0
- package/dist/sensor/logger.js +13 -0
- package/dist/sensor/otel-exporter.js +161 -0
- package/dist/sensor/paths.js +71 -0
- package/dist/sensor/policy-history.js +147 -0
- package/dist/sensor/pr-shadow-store.js +83 -0
- package/dist/sensor/process-watcher.js +162 -0
- package/dist/sensor/rbac.js +92 -0
- package/dist/sensor/redact.js +114 -0
- package/dist/sensor/redis-store.js +191 -0
- package/dist/sensor/route-reachability.js +64 -0
- package/dist/sensor/security-utils.js +18 -0
- package/dist/sensor/service-graph.js +170 -0
- package/dist/sensor/service-topology.js +227 -0
- package/dist/sensor/session-history.js +74 -0
- package/dist/sensor/session-persist.js +38 -0
- package/dist/sensor/shadow-promote.js +122 -0
- package/dist/sensor/sourcemap.js +281 -0
- package/dist/sensor/sqlite-store.js +205 -0
- package/dist/sensor/sso.js +164 -0
- package/dist/sensor/vitest-reporter.js +65 -0
- package/dist/sensor/watcher.js +48 -0
- package/dist/storage/interfaces.js +0 -0
- package/dist/storage/pg/pg-action-ledger.js +138 -0
- package/dist/storage/pg/pg-approval-store.js +107 -0
- package/dist/storage/pg/pg-blunder-store.js +193 -0
- package/dist/storage/pg/pg-ci-gate-history.js +83 -0
- package/dist/storage/pg/pg-client.js +24 -0
- package/dist/storage/pg/pg-event-store.js +63 -0
- package/dist/storage/pg/pg-incident-store.js +190 -0
- package/dist/storage/pg/pg-migrations.js +26 -0
- package/dist/storage/pg/pg-override-corpus.js +447 -0
- package/dist/storage/pg/pg-shadow-log.js +129 -0
- package/dist/storage/sqlite/sqlite-action-ledger.js +18 -0
- package/dist/storage/sqlite/sqlite-approval-store.js +37 -0
- package/dist/storage/sqlite/sqlite-blunder-store.js +27 -0
- package/dist/storage/sqlite/sqlite-ci-gate-history.js +19 -0
- package/dist/storage/sqlite/sqlite-event-store.js +29 -0
- package/dist/storage/sqlite/sqlite-incident-store.js +34 -0
- package/dist/storage/sqlite/sqlite-override-corpus.js +75 -0
- package/dist/storage/sqlite/sqlite-shadow-log.js +36 -0
- package/dist/storage/store-factory.js +55 -0
- package/dist/storage/store-registry.js +31 -0
- package/dist/update-checker.js +107 -0
- package/dist/workers/autopilot-worker.js +28 -0
- package/dist/workers/notification-worker.js +28 -0
- package/dist/workers/queues.js +58 -0
- package/dist/workers/validation-worker.js +24 -0
- package/dist/workers/worker-registry.js +18 -0
- package/package.json +123 -0
- package/sdk/mergen-inject.js +260 -0
- package/sdk/node.js +313 -0
- package/sdk/vite-plugin.ts +57 -0
- package/sdk/webpack-plugin.js +106 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
const r = Router();
|
|
3
|
+
const noop = () => {
|
|
4
|
+
};
|
|
5
|
+
const noopAsync = () => Promise.resolve();
|
|
6
|
+
const billingRouter = r;
|
|
7
|
+
const teamRouter = r;
|
|
8
|
+
const initTeam = noopAsync;
|
|
9
|
+
const broadcastToTeam = noop;
|
|
10
|
+
const initUsage = noopAsync;
|
|
11
|
+
const flushOverageOnShutdown = noopAsync;
|
|
12
|
+
const initLicense = noopAsync;
|
|
13
|
+
const initTelemetry = noopAsync;
|
|
14
|
+
const maybeSendTelemetry = noopAsync;
|
|
15
|
+
const uploadCalibrationBatch = noopAsync;
|
|
16
|
+
const getActivePlanId = () => "free";
|
|
17
|
+
const getPlan = () => ({ bufferSize: 2e3, name: "free" });
|
|
18
|
+
const _PLAN_RANK = {
|
|
19
|
+
free: 0,
|
|
20
|
+
starter: 1,
|
|
21
|
+
solo_starter: 1,
|
|
22
|
+
team: 2,
|
|
23
|
+
solo_pro: 2,
|
|
24
|
+
platform: 3,
|
|
25
|
+
solo_power: 3,
|
|
26
|
+
enterprise: 4,
|
|
27
|
+
pay_as_you_go: 4
|
|
28
|
+
};
|
|
29
|
+
const _rank = (planId) => _PLAN_RANK[planId ?? ""] ?? 0;
|
|
30
|
+
const _minRankForGate = (gate) => gate === "free" || gate === "all" ? 0 : gate === "pro" ? 1 : _PLAN_RANK[gate] ?? 0;
|
|
31
|
+
const PLAN_ORDER = ["free", "starter", "team", "platform", "enterprise"];
|
|
32
|
+
const getPlanRank = (planId) => _rank(planId);
|
|
33
|
+
const planMeetsMin = (planId, minPlanId) => _rank(planId) >= _rank(minPlanId);
|
|
34
|
+
const minPlanForGate = (gate) => gate === "free" || gate === "all" ? "free" : gate === "pro" ? "starter" : gate;
|
|
35
|
+
const planAllowsGate = (planId, gate) => _rank(planId) >= _minRankForGate(gate);
|
|
36
|
+
const planHasCapability = (_planId, _cap) => false;
|
|
37
|
+
const planAllowsTier = (planId, tier) => planAllowsGate(planId, tier);
|
|
38
|
+
const getIncidentCount = () => 0;
|
|
39
|
+
const getUsageSnapshot = () => ({});
|
|
40
|
+
const recordExplainWhyFeedback = noopAsync;
|
|
41
|
+
const getTeamState = () => ({ members: [] });
|
|
42
|
+
const isTeamEnabled = () => false;
|
|
43
|
+
const getTelemetryState = () => ({ enabled: false, installId: "stub" });
|
|
44
|
+
const setTelemetryEnabled = noopAsync;
|
|
45
|
+
const registerTools = noop;
|
|
46
|
+
const toolCallCounts = {};
|
|
47
|
+
const lastMcpCallAt = null;
|
|
48
|
+
const firstAnalyzeAt = null;
|
|
49
|
+
const lastTimeToFirstAnalysisMs = null;
|
|
50
|
+
const hypothesisHistory = {
|
|
51
|
+
list: () => [],
|
|
52
|
+
latest: () => null,
|
|
53
|
+
clear: noop,
|
|
54
|
+
notifyError: noop,
|
|
55
|
+
add: noop,
|
|
56
|
+
size: () => 0,
|
|
57
|
+
_rebuildNowForTesting: noopAsync
|
|
58
|
+
};
|
|
59
|
+
const getStats = () => null;
|
|
60
|
+
const getRecords = () => [];
|
|
61
|
+
const recordVerdict = noop;
|
|
62
|
+
const getStatsForTag = () => null;
|
|
63
|
+
const listActiveSessions = () => [];
|
|
64
|
+
const SYSTEM_PROMPT = "";
|
|
65
|
+
const analyzeCommit = noopAsync;
|
|
66
|
+
const postPRComment = noopAsync;
|
|
67
|
+
const analyzePRShadow = noopAsync;
|
|
68
|
+
const getSessionMetrics = () => ({});
|
|
69
|
+
const getUnclassified = () => [];
|
|
70
|
+
const slackRoutingRouter = r;
|
|
71
|
+
const getLicenseState = () => ({});
|
|
72
|
+
const activateKey = (_key) => Promise.resolve({});
|
|
73
|
+
const deactivateKey = noopAsync;
|
|
74
|
+
const planFromVariantId = (_v) => "free";
|
|
75
|
+
const PLANS = { free: { bufferSize: 2e3, name: "free", backendObservability: true } };
|
|
76
|
+
const consumeCredit = () => Promise.resolve({ allowed: true });
|
|
77
|
+
const consumeIncident = () => Promise.resolve({ allowed: true });
|
|
78
|
+
const recordExplainWhy = noop;
|
|
79
|
+
const _resetForTesting = noop;
|
|
80
|
+
const _setSleepForTesting = noop;
|
|
81
|
+
const computeAnomaly = () => Promise.resolve({ summary: "" });
|
|
82
|
+
const getAnomalousPatterns = () => Promise.resolve([]);
|
|
83
|
+
const computeErrorFrequency = (_logs) => [];
|
|
84
|
+
const computeNetworkFrequency = (_net) => [];
|
|
85
|
+
const normaliseMessage = (msg) => msg;
|
|
86
|
+
const scoreToConfidence = (score) => score >= 0.8 ? "high" : score >= 0.5 ? "medium" : "low";
|
|
87
|
+
const generateReproSteps = () => ({ confidence: "low", markdown: "", steps: [] });
|
|
88
|
+
export {
|
|
89
|
+
PLANS,
|
|
90
|
+
PLAN_ORDER,
|
|
91
|
+
SYSTEM_PROMPT,
|
|
92
|
+
_resetForTesting,
|
|
93
|
+
_setSleepForTesting,
|
|
94
|
+
activateKey,
|
|
95
|
+
analyzeCommit,
|
|
96
|
+
analyzePRShadow,
|
|
97
|
+
billingRouter,
|
|
98
|
+
broadcastToTeam,
|
|
99
|
+
computeAnomaly,
|
|
100
|
+
computeErrorFrequency,
|
|
101
|
+
computeNetworkFrequency,
|
|
102
|
+
consumeCredit,
|
|
103
|
+
consumeIncident,
|
|
104
|
+
deactivateKey,
|
|
105
|
+
firstAnalyzeAt,
|
|
106
|
+
flushOverageOnShutdown,
|
|
107
|
+
generateReproSteps,
|
|
108
|
+
getActivePlanId,
|
|
109
|
+
getAnomalousPatterns,
|
|
110
|
+
getIncidentCount,
|
|
111
|
+
getLicenseState,
|
|
112
|
+
getPlan,
|
|
113
|
+
getPlanRank,
|
|
114
|
+
getRecords,
|
|
115
|
+
getSessionMetrics,
|
|
116
|
+
getStats,
|
|
117
|
+
getStatsForTag,
|
|
118
|
+
getTeamState,
|
|
119
|
+
getTelemetryState,
|
|
120
|
+
getUnclassified,
|
|
121
|
+
getUsageSnapshot,
|
|
122
|
+
hypothesisHistory,
|
|
123
|
+
initLicense,
|
|
124
|
+
initTeam,
|
|
125
|
+
initTelemetry,
|
|
126
|
+
initUsage,
|
|
127
|
+
isTeamEnabled,
|
|
128
|
+
lastMcpCallAt,
|
|
129
|
+
lastTimeToFirstAnalysisMs,
|
|
130
|
+
listActiveSessions,
|
|
131
|
+
maybeSendTelemetry,
|
|
132
|
+
minPlanForGate,
|
|
133
|
+
normaliseMessage,
|
|
134
|
+
planAllowsGate,
|
|
135
|
+
planAllowsTier,
|
|
136
|
+
planFromVariantId,
|
|
137
|
+
planHasCapability,
|
|
138
|
+
planMeetsMin,
|
|
139
|
+
postPRComment,
|
|
140
|
+
recordExplainWhy,
|
|
141
|
+
recordExplainWhyFeedback,
|
|
142
|
+
recordVerdict,
|
|
143
|
+
registerTools,
|
|
144
|
+
scoreToConfidence,
|
|
145
|
+
setTelemetryEnabled,
|
|
146
|
+
slackRoutingRouter,
|
|
147
|
+
teamRouter,
|
|
148
|
+
toolCallCounts,
|
|
149
|
+
uploadCalibrationBatch
|
|
150
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PLANS } from "./plans.js";
|
|
2
|
+
let _state = null;
|
|
3
|
+
function getLicenseState() {
|
|
4
|
+
return _state;
|
|
5
|
+
}
|
|
6
|
+
function getActivePlanId() {
|
|
7
|
+
return _state?.planId ?? "free";
|
|
8
|
+
}
|
|
9
|
+
async function initLicense() {
|
|
10
|
+
}
|
|
11
|
+
async function activateKey(key) {
|
|
12
|
+
const planId = planFromVariantId(void 0);
|
|
13
|
+
_state = { key, planId, validatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
14
|
+
return { activated: true, planId };
|
|
15
|
+
}
|
|
16
|
+
async function deactivateKey() {
|
|
17
|
+
_state = null;
|
|
18
|
+
}
|
|
19
|
+
const VARIANT_PLAN_MAP = process.env.MERGEN_LS_VARIANT_MAP ? JSON.parse(process.env.MERGEN_LS_VARIANT_MAP) : {};
|
|
20
|
+
function planFromVariantId(variantId) {
|
|
21
|
+
if (variantId == null || variantId === "" || variantId === 0) return "free";
|
|
22
|
+
const mapped = VARIANT_PLAN_MAP[String(variantId)];
|
|
23
|
+
return mapped && PLANS[mapped] ? mapped : "free";
|
|
24
|
+
}
|
|
25
|
+
async function revalidateLicense() {
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
activateKey,
|
|
29
|
+
deactivateKey,
|
|
30
|
+
getActivePlanId,
|
|
31
|
+
getLicenseState,
|
|
32
|
+
initLicense,
|
|
33
|
+
planFromVariantId,
|
|
34
|
+
revalidateLicense
|
|
35
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
const NO_CAPS = {
|
|
2
|
+
hitlApproval: false,
|
|
3
|
+
overrideCorpusEnforce: false,
|
|
4
|
+
ciGate: false,
|
|
5
|
+
credentialBrokering: false,
|
|
6
|
+
agentIam: false
|
|
7
|
+
};
|
|
8
|
+
const CANONICAL_PLANS = {
|
|
9
|
+
free: {
|
|
10
|
+
id: "free",
|
|
11
|
+
name: "Free (OSS)",
|
|
12
|
+
rank: 0,
|
|
13
|
+
tagline: "Local-first logs and traces for developers",
|
|
14
|
+
seats: "1 developer",
|
|
15
|
+
maxServices: 1,
|
|
16
|
+
bufferSize: 2e3,
|
|
17
|
+
backendObservability: false,
|
|
18
|
+
analyzeCreditsPerMonth: 10,
|
|
19
|
+
overageCentsPerCredit: 0,
|
|
20
|
+
seatCap: 1,
|
|
21
|
+
overageCentsPerSeat: 0,
|
|
22
|
+
includedToolCallsPerMonth: 1e3,
|
|
23
|
+
overageCentsPerThousandToolCalls: 0,
|
|
24
|
+
capabilities: { ...NO_CAPS },
|
|
25
|
+
ctaUrl: "https://mergen.app/pricing",
|
|
26
|
+
priceDescription: "Free forever"
|
|
27
|
+
},
|
|
28
|
+
starter: {
|
|
29
|
+
id: "starter",
|
|
30
|
+
name: "Starter",
|
|
31
|
+
rank: 1,
|
|
32
|
+
tagline: "Shared policies, workspace collaboration, and safety for small AI teams",
|
|
33
|
+
seats: "5 included seats (+$15 / additional seat)",
|
|
34
|
+
maxServices: 5,
|
|
35
|
+
bufferSize: 1e4,
|
|
36
|
+
backendObservability: true,
|
|
37
|
+
analyzeCreditsPerMonth: 500,
|
|
38
|
+
overageCentsPerCredit: 10,
|
|
39
|
+
seatCap: 5,
|
|
40
|
+
overageCentsPerSeat: 1500,
|
|
41
|
+
includedToolCallsPerMonth: 1e4,
|
|
42
|
+
overageCentsPerThousandToolCalls: 500,
|
|
43
|
+
capabilities: { ...NO_CAPS, overrideCorpusEnforce: true, credentialBrokering: true },
|
|
44
|
+
ctaUrl: "https://mergen.app/pricing#starter",
|
|
45
|
+
priceDescription: "$79 / month founding price ($149 regular)"
|
|
46
|
+
},
|
|
47
|
+
team: {
|
|
48
|
+
id: "team",
|
|
49
|
+
name: "Team",
|
|
50
|
+
rank: 2,
|
|
51
|
+
tagline: "Slack approvals, RBAC, CI/CD gates, and runtime visualization for scaling companies",
|
|
52
|
+
seats: "20 included seats (+$20 / additional seat)",
|
|
53
|
+
maxServices: 25,
|
|
54
|
+
bufferSize: 5e4,
|
|
55
|
+
backendObservability: true,
|
|
56
|
+
analyzeCreditsPerMonth: 1e3,
|
|
57
|
+
overageCentsPerCredit: 5,
|
|
58
|
+
seatCap: 20,
|
|
59
|
+
overageCentsPerSeat: 2e3,
|
|
60
|
+
includedToolCallsPerMonth: 1e5,
|
|
61
|
+
overageCentsPerThousandToolCalls: 500,
|
|
62
|
+
capabilities: { hitlApproval: true, overrideCorpusEnforce: true, ciGate: true, credentialBrokering: true, agentIam: false },
|
|
63
|
+
ctaUrl: "https://mergen.app/pricing#team",
|
|
64
|
+
priceDescription: "$399 / month founding price ($499 regular)"
|
|
65
|
+
},
|
|
66
|
+
platform: {
|
|
67
|
+
id: "platform",
|
|
68
|
+
name: "Platform",
|
|
69
|
+
rank: 3,
|
|
70
|
+
tagline: "Unlimited scale on top of Team\u2019s governance primitives",
|
|
71
|
+
seats: "Unlimited",
|
|
72
|
+
maxServices: Infinity,
|
|
73
|
+
bufferSize: 2e5,
|
|
74
|
+
backendObservability: true,
|
|
75
|
+
analyzeCreditsPerMonth: 5e3,
|
|
76
|
+
overageCentsPerCredit: 2,
|
|
77
|
+
seatCap: Infinity,
|
|
78
|
+
overageCentsPerSeat: 0,
|
|
79
|
+
includedToolCallsPerMonth: 25e4,
|
|
80
|
+
overageCentsPerThousandToolCalls: 600,
|
|
81
|
+
capabilities: { hitlApproval: true, overrideCorpusEnforce: true, ciGate: true, credentialBrokering: true, agentIam: false },
|
|
82
|
+
ctaUrl: "https://mergen.app/pricing#platform",
|
|
83
|
+
priceDescription: "$10,000 / month base"
|
|
84
|
+
},
|
|
85
|
+
enterprise: {
|
|
86
|
+
id: "enterprise",
|
|
87
|
+
name: "Enterprise",
|
|
88
|
+
rank: 4,
|
|
89
|
+
tagline: "VPC deployment, SSO/IAM federation, and strict policy engine for regulated environments",
|
|
90
|
+
seats: "Custom",
|
|
91
|
+
maxServices: Infinity,
|
|
92
|
+
bufferSize: 1e6,
|
|
93
|
+
backendObservability: true,
|
|
94
|
+
analyzeCreditsPerMonth: 0,
|
|
95
|
+
overageCentsPerCredit: 0,
|
|
96
|
+
seatCap: Infinity,
|
|
97
|
+
overageCentsPerSeat: 0,
|
|
98
|
+
includedToolCallsPerMonth: 0,
|
|
99
|
+
overageCentsPerThousandToolCalls: 0,
|
|
100
|
+
capabilities: { hitlApproval: true, overrideCorpusEnforce: true, ciGate: true, credentialBrokering: true, agentIam: true },
|
|
101
|
+
ctaUrl: "https://mergen.app/pricing#enterprise",
|
|
102
|
+
priceDescription: "Custom ACV ($100K+ / year)"
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const PLAN_ORDER = ["free", "starter", "team", "platform", "enterprise"];
|
|
106
|
+
const LEGACY_ALIASES = {
|
|
107
|
+
solo_starter: "starter",
|
|
108
|
+
solo_pro: "team",
|
|
109
|
+
solo_power: "platform",
|
|
110
|
+
pay_as_you_go: "enterprise"
|
|
111
|
+
};
|
|
112
|
+
function buildPlans() {
|
|
113
|
+
const all = { ...CANONICAL_PLANS };
|
|
114
|
+
for (const [aliasId, canonicalId] of Object.entries(LEGACY_ALIASES)) {
|
|
115
|
+
const base = CANONICAL_PLANS[canonicalId];
|
|
116
|
+
all[aliasId] = { ...base, capabilities: { ...base.capabilities }, id: aliasId, name: `${base.name} (Legacy)` };
|
|
117
|
+
}
|
|
118
|
+
return all;
|
|
119
|
+
}
|
|
120
|
+
const PLANS = buildPlans();
|
|
121
|
+
function getPlan(planId) {
|
|
122
|
+
return PLANS[planId ?? ""] ?? PLANS["free"];
|
|
123
|
+
}
|
|
124
|
+
function getPlanRank(planId) {
|
|
125
|
+
return getPlan(planId).rank;
|
|
126
|
+
}
|
|
127
|
+
function planMeetsMin(planId, minPlanId) {
|
|
128
|
+
return getPlanRank(planId) >= getPlanRank(minPlanId);
|
|
129
|
+
}
|
|
130
|
+
function planHasCapability(planId, cap) {
|
|
131
|
+
return getPlan(planId).capabilities[cap] === true;
|
|
132
|
+
}
|
|
133
|
+
const LOWEST_PAID_PLAN = "starter";
|
|
134
|
+
function minPlanForGate(gate) {
|
|
135
|
+
if (gate === "free" || gate === "all") return "free";
|
|
136
|
+
if (gate === "pro") return LOWEST_PAID_PLAN;
|
|
137
|
+
return PLANS[gate] ? gate : "free";
|
|
138
|
+
}
|
|
139
|
+
function planAllowsGate(planId, gate) {
|
|
140
|
+
return planMeetsMin(planId, minPlanForGate(gate));
|
|
141
|
+
}
|
|
142
|
+
function planAllowsTier(planId, tier) {
|
|
143
|
+
return planAllowsGate(planId, tier);
|
|
144
|
+
}
|
|
145
|
+
function estimateToolCallOverageCents(planId, toolCallsThisMonth) {
|
|
146
|
+
const plan = getPlan(planId);
|
|
147
|
+
const included = plan.includedToolCallsPerMonth;
|
|
148
|
+
const rate = plan.overageCentsPerThousandToolCalls;
|
|
149
|
+
if (included === 0 || rate === 0) return 0;
|
|
150
|
+
const overage = Math.max(0, toolCallsThisMonth - included);
|
|
151
|
+
return Math.ceil(overage / 1e3 * rate);
|
|
152
|
+
}
|
|
153
|
+
function estimateSeatOverageCents(planId, activeSeats) {
|
|
154
|
+
const plan = getPlan(planId);
|
|
155
|
+
const cap = plan.seatCap;
|
|
156
|
+
const rate = plan.overageCentsPerSeat;
|
|
157
|
+
if (!isFinite(cap) || rate === 0) return 0;
|
|
158
|
+
return Math.max(0, activeSeats - cap) * rate;
|
|
159
|
+
}
|
|
160
|
+
const CAPABILITY_LABELS = {
|
|
161
|
+
hitlApproval: "HITL approve/deny holds",
|
|
162
|
+
overrideCorpusEnforce: "Override-corpus enforcement (BLOCK/HOLD)",
|
|
163
|
+
ciGate: "CI/CD blast-radius gate",
|
|
164
|
+
credentialBrokering: "Ephemeral multi-cloud credential brokering",
|
|
165
|
+
agentIam: "Agent IAM: SSO federation + enterprise credential governance"
|
|
166
|
+
};
|
|
167
|
+
const CAPABILITY_KEYS = Object.keys(CAPABILITY_LABELS);
|
|
168
|
+
function describeEntitlement(planId) {
|
|
169
|
+
const plan = getPlan(planId);
|
|
170
|
+
const unlocked = CAPABILITY_KEYS.filter((cap) => plan.capabilities[cap]).map((cap) => CAPABILITY_LABELS[cap]);
|
|
171
|
+
const nextPlanId = PLAN_ORDER.find((id) => PLANS[id].rank === plan.rank + 1);
|
|
172
|
+
const upgradeLines = [];
|
|
173
|
+
if (nextPlanId) {
|
|
174
|
+
const next = getPlan(nextPlanId);
|
|
175
|
+
const newlyUnlocked = CAPABILITY_KEYS.filter((cap) => next.capabilities[cap] && !plan.capabilities[cap]).map((cap) => CAPABILITY_LABELS[cap]);
|
|
176
|
+
const suffix = newlyUnlocked.length > 0 ? ` \u2014 unlocks ${newlyUnlocked.join(", ")}` : "";
|
|
177
|
+
upgradeLines.push(
|
|
178
|
+
`> **Upgrade to ${next.name}** (${next.priceDescription})${suffix}`,
|
|
179
|
+
`> ${next.ctaUrl}`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return { unlocked, upgradeLines };
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
PLANS,
|
|
186
|
+
PLAN_ORDER,
|
|
187
|
+
describeEntitlement,
|
|
188
|
+
estimateSeatOverageCents,
|
|
189
|
+
estimateToolCallOverageCents,
|
|
190
|
+
getPlan,
|
|
191
|
+
getPlanRank,
|
|
192
|
+
minPlanForGate,
|
|
193
|
+
planAllowsGate,
|
|
194
|
+
planAllowsTier,
|
|
195
|
+
planHasCapability,
|
|
196
|
+
planMeetsMin
|
|
197
|
+
};
|