Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix: normalize custom OpenAI-compatible API URLs (#1067)

rcourtman6019e3e77e64
diff --git a/frontend-modern/src/components/AI/AIChat.tsx b/frontend-modern/src/components/AI/AIChat.tsx
index afb1d2faa1..20a85e15d2 100644
--- a/frontend-modern/src/components/AI/AIChat.tsx
+++ b/frontend-modern/src/components/AI/AIChat.tsx
@@ -1,5 +1,7 @@
import { Component, Show, createSignal, For, createEffect, createMemo, onMount, Switch, Match } from 'solid-js';
import { AIAPI } from '@/api/ai';
+import Sparkles from 'lucide-solid/icons/sparkles';
+import ExternalLink from 'lucide-solid/icons/external-link';
import { getPatrolStatus, type PatrolStatus } from '@/api/patrol';
import { notificationStore } from '@/stores/notifications';
import { logger } from '@/utils/logger';
@@ -1050,9 +1052,8 @@ export const AIChat: Component<AIChatProps> = (props) => {
return (
<div
- class={`group relative px-3 py-2 flex items-start gap-2 hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer ${
- isCurrentSession() ? 'bg-purple-50 dark:bg-purple-900/20' : ''
- }`}
+ class={`group relative px-3 py-2 flex items-start gap-2 hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer ${isCurrentSession() ? 'bg-purple-50 dark:bg-purple-900/20' : ''
+ }`}
onClick={() => {
if (!isCurrentSession()) {
aiChatStore.switchSession(session.id);
@@ -1062,11 +1063,10 @@ export const AIChat: Component<AIChatProps> = (props) => {
>
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2">
- <span class={`text-sm font-medium truncate ${
- isCurrentSession()
- ? 'text-purple-700 dark:text-purple-300'
- : 'text-gray-900 dark:text-gray-100'
- }`}>
+ <span class={`text-sm font-medium truncate ${isCurrentSession()
+ ? 'text-purple-700 dark:text-purple-300'
+ : 'text-gray-900 dark:text-gray-100'
+ }`}>
{session.title || 'Untitled conversation'}
</span>
<Show when={isCurrentSession()}>
@@ -1152,41 +1152,41 @@ export const AIChat: Component<AIChatProps> = (props) => {
<div class="flex-1 overflow-y-auto p-4 space-y-4">
{/* AI Patrol upgrade prompt - shows after first message for free users */}
<Show when={showUpgradePrompt()}>
- <div class="relative flex items-start gap-3 p-3 rounded-lg bg-gradient-to-r from-purple-50 to-indigo-50 dark:from-purple-900/20 dark:to-indigo-900/20 border border-purple-200 dark:border-purple-800">
- <div class="flex-shrink-0 w-8 h-8 rounded-full bg-purple-100 dark:bg-purple-800 flex items-center justify-center">
- <svg class="w-4 h-4 text-purple-600 dark:text-purple-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
- </svg>
- </div>
- <div class="flex-1 min-w-0">
- <p class="text-sm font-medium text-gray-900 dark:text-gray-100">
- Want AI to patrol automatically?
- </p>
- <p class="text-xs text-gray-600 dark:text-gray-400 mt-0.5">
- AI Patrol monitors your infrastructure 24/7 and surfaces issues before they become outages.
- </p>
- <a
- href={patrolStatus()?.upgrade_url || 'https://pulserelay.pro'}
- target="_blank"
- rel="noopener noreferrer"
- class="inline-flex items-center gap-1 mt-2 text-xs font-medium text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300"
+ <div class="mb-4 relative overflow-hidden group">
+ <div class="absolute inset-0 bg-gradient-to-r from-purple-500/10 to-indigo-500/10 opacity-50 group-hover:opacity-100 transition-opacity"></div>
+ <div class="relative flex items-start gap-4 p-4 bg-white dark:bg-gray-800/50 border border-purple-200 dark:border-purple-900/50 rounded-2xl shadow-lg backdrop-blur-sm">
+ <div class="p-2.5 bg-gradient-to-br from-purple-500 to-indigo-600 rounded-xl shadow-md transform group-hover:scale-110 transition-transform duration-500">
+ <Sparkles class="w-4 h-4 text-white" />
+ </div>
+ <div class="flex-1 min-w-0">
+ <div class="flex items-center gap-2">
+ <p class="text-sm font-bold text-gray-900 dark:text-white">Autopilot your Ops</p>
+ <span class="px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider bg-purple-100 dark:bg-purple-900/50 text-purple-600 dark:text-purple-400 rounded">Pro</span>
+ </div>
+ <p class="text-xs text-gray-600 dark:text-gray-400 mt-1 leading-relaxed">
+ AI Patrol monitors your infrastructure 24/7 and surfaces issues before they become outages.
+ </p>
+ <a
+ href={patrolStatus()?.upgrade_url || 'https://pulse.sh/pro'}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="inline-flex items-center gap-1.5 mt-2.5 text-xs font-bold text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 transition-colors group/link"
+ >
+ Enable AI Patrol
+ <ExternalLink class="w-3 h-3 transform group-hover/link:translate-x-0.5 group-hover/link:-translate-y-0.5 transition-transform" />
+ </a>
+ </div>
+ <button
+ type="button"
+ onClick={() => setUpgradePromptDismissed(true)}
+ class="flex-shrink-0 p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-all"
+ title="Dismiss"
>
- Learn about Pulse Pro
- <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
- </a>
+ </button>
</div>
- <button
- type="button"
- onClick={() => setUpgradePromptDismissed(true)}
- class="flex-shrink-0 p-1 rounded hover:bg-purple-200 dark:hover:bg-purple-800 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors"
- title="Dismiss"
- >
- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
- </svg>
- </button>
</div>
</Show>
diff --git a/frontend-modern/src/components/Kubernetes/KubernetesClusters.tsx b/frontend-modern/src/components/Kubernetes/KubernetesClusters.tsx
index ec0268ade8..8b608a92e6 100644
--- a/frontend-modern/src/components/Kubernetes/KubernetesClusters.tsx
+++ b/frontend-modern/src/components/Kubernetes/KubernetesClusters.tsx
@@ -1,6 +1,8 @@
import type { Component } from 'solid-js';
import { For, Show, createMemo, createSignal, createEffect, onMount } from 'solid-js';
import { AIAPI } from '@/api/ai';
+import Sparkles from 'lucide-solid/icons/sparkles';
+import ExternalLink from 'lucide-solid/icons/external-link';
import { LicenseAPI, type LicenseFeatureStatus } from '@/api/license';
import { usePersistentSignal } from '@/hooks/usePersistentSignal';
import { useDebouncedValue } from '@/hooks/useDebouncedValue';
@@ -213,7 +215,7 @@ export const KubernetesClusters: Component<KubernetesClustersProps> = (props) =>
const kubernetesAiEnabled = createMemo(() => licenseFeatures()?.features?.kubernetes_ai === true);
const aiConfigured = createMemo(() => aiSettings()?.configured === true);
- const upgradeUrl = createMemo(() => licenseFeatures()?.upgrade_url || 'https://pulserelay.pro');
+ const upgradeUrl = createMemo(() => licenseFeatures()?.upgrade_url || 'https://pulse.sh/pro');
const clustersForAnalysis = createMemo(() => props.clusters ?? []);
@@ -554,13 +556,16 @@ export const KubernetesClusters: Component<KubernetesClustersProps> = (props) =>
<Show when={clustersForAnalysis().length > 0}>
<Card padding="sm">
<div class="flex flex-col gap-3">
- <div class="flex flex-wrap items-start justify-between gap-3">
- <div>
- <div class="text-sm font-semibold text-gray-900 dark:text-gray-100">
- Kubernetes AI Analysis
+ <div class="flex flex-wrap items-start justify-between gap-4">
+ <div class="flex-1 min-w-[300px]">
+ <div class="flex items-center gap-2">
+ <div class="text-sm font-bold text-gray-900 dark:text-gray-100 flex items-center gap-2">
+ Kubernetes AI Analysis
+ <span class="px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-400 rounded-md">Enterprise</span>
+ </div>
</div>
- <div class="text-xs text-gray-500 dark:text-gray-400">
- Generate a health summary and next actions for a cluster.
+ <div class="text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed">
+ Generate deep health insights and actionable remediation for your clusters using Pulse's advanced AI engine.
</div>
</div>
<Show when={!licenseLoading() && !kubernetesAiEnabled()}>
@@ -568,23 +573,44 @@ export const KubernetesClusters: Component<KubernetesClustersProps> = (props) =>
href={upgradeUrl()}
target="_blank"
rel="noreferrer"
- class="inline-flex items-center gap-1 text-xs font-medium text-blue-600 dark:text-blue-300 hover:text-blue-700 dark:hover:text-blue-200"
+ class="inline-flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-blue-600 to-indigo-600 text-white rounded-xl hover:from-blue-700 hover:to-indigo-700 transition-all shadow-md text-xs font-bold"
>
- Upgrade to Pro
+ Get Pulse Pro
+ <ExternalLink class="w-3 h-3" />
</a>
</Show>
</div>
<Show when={licenseLoading() || aiLoading()}>
- <div class="text-xs text-gray-500 dark:text-gray-400 flex items-center gap-2">
- <span class="h-3 w-3 border-2 border-current border-t-transparent rounded-full animate-spin" />
- Loading AI and license status...
+ <div class="flex items-center gap-3 p-4 bg-blue-50/50 dark:bg-blue-900/20 rounded-xl border border-blue-100 dark:border-blue-800 animate-pulse">
+ <div class="h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin" />
+ <span class="text-xs font-medium text-blue-700 dark:text-blue-300">Synchronizing AI & License...</span>
</div>
</Show>
<Show when={!licenseLoading() && !kubernetesAiEnabled()}>
- <div class="text-sm text-gray-600 dark:text-gray-300">
- Kubernetes AI analysis requires Pulse Pro.
+ <div class="relative overflow-hidden p-6 rounded-2xl bg-gradient-to-br from-indigo-50 to-blue-50 dark:from-indigo-950/40 dark:to-blue-950/40 border border-indigo-100 dark:border-indigo-800 shadow-xl group">
+ <div class="absolute top-0 right-0 p-8 opacity-10 group-hover:scale-110 transition-transform duration-700">
+ <Sparkles class="w-32 h-32 text-indigo-600" />
+ </div>
+ <div class="relative flex flex-col items-center text-center max-w-lg mx-auto">
+ <div class="p-3 bg-white dark:bg-gray-800 rounded-2xl shadow-lg mb-4">
+ <Sparkles class="w-8 h-8 text-indigo-500" />
+ </div>
+ <h4 class="text-lg font-bold text-gray-900 dark:text-white mb-2">Power up your Kubernetes Fleet</h4>
+ <p class="text-sm text-gray-600 dark:text-gray-400 mb-6 leading-relaxed">
+ Pulse Pro brings advanced AI-driven diagnostics to your Kubernetes clusters. Identify bottlenecks, security risks, and configuration drift in seconds.
+ </p>
+ <a
+ href={upgradeUrl()}
+ target="_blank"
+ rel="noreferrer"
+ class="inline-flex items-center gap-2.5 px-6 py-2.5 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transform hover:scale-105 active:scale-95 transition-all shadow-lg font-bold text-sm"
+ >
+ Unlock Kubernetes AI
+ <ExternalLink class="w-4 h-4" />
+ </a>
+ </div>
</div>
</Show>
diff --git a/frontend-modern/src/components/Settings/AISettings.tsx b/frontend-modern/src/components/Settings/AISettings.tsx
index 61b3efb69e..df30d5b786 100644
--- a/frontend-modern/src/components/Settings/AISettings.tsx
+++ b/frontend-modern/src/components/Settings/AISettings.tsx
@@ -8,6 +8,8 @@ import { formField, labelClass, controlClass } from '@/components/shared/Form';
import { notificationStore } from '@/stores/notifications';
import { logger } from '@/utils/logger';
import { AIAPI } from '@/api/ai';
+import Sparkles from 'lucide-solid/icons/sparkles';
+import ExternalLink from 'lucide-solid/icons/external-link';
import { isEnterprise, loadLicenseStatus } from '@/stores/license';
import type { AISettings as AISettingsType, AIProvider, AuthMethod } from '@/types/ai';
@@ -1174,7 +1176,7 @@ export const AISettings: Component = () => {
</span>
</Show>
<Show when={autoFixLocked()}>
- <span class="px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-gradient-to-r from-indigo-500 to-purple-500 text-white rounded-md shadow-sm">
+ <span class="px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-gradient-to-r from-indigo-600 via-purple-600 to-blue-600 text-white rounded-md shadow-md shadow-indigo-500/20 ring-1 ring-white/20">
Enterprise
</span>
</Show>
@@ -1188,10 +1190,11 @@ export const AISettings: Component = () => {
<strong>⚠️ Legal Disclaimer:</strong> AI models can hallucinate. You are responsible for any damage caused by autonomous actions. See <a href="https://github.com/rcourtman/Pulse/blob/main/TERMS.md" target="_blank" class="underline">Terms of Service</a>.
</div>
<Show when={autoFixLocked()}>
- <p class="text-[10px] text-indigo-600 dark:text-indigo-400 mt-1">
- Pulse Enterprise required for autonomous mode.{' '}
+ <p class="text-[10px] text-indigo-600 dark:text-indigo-400 mt-2 flex items-center gap-1.5 p-2 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg border border-indigo-100 dark:border-indigo-800">
+ <Sparkles class="w-3 h-3" />
+ Pulse Enterprise required for autonomous mode.
<a
- class="underline decoration-dotted font-semibold"
+ class="ml-auto px-2 py-0.5 bg-indigo-600 text-white rounded hover:bg-indigo-700 transition shadow-sm font-semibold"
href="https://pulse.sh/pro"
target="_blank"
rel="noreferrer"
@@ -1270,7 +1273,7 @@ export const AISettings: Component = () => {
Alert-Triggered Analysis
<span class="px-1 py-0.5 text-[9px] font-medium bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300 rounded">Efficient</span>
<Show when={alertAnalysisLocked()}>
- <span class="px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-gradient-to-r from-indigo-500 to-purple-500 text-white rounded-md shadow-sm">
+ <span class="px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-gradient-to-r from-indigo-600 via-purple-600 to-blue-600 text-white rounded-md shadow-md shadow-indigo-500/20 ring-1 ring-white/20">
Enterprise
</span>
</Show>
@@ -1329,10 +1332,11 @@ export const AISettings: Component = () => {
</Show>
</div>
<Show when={autoFixLocked()}>
- <p class="text-[10px] text-indigo-600 dark:text-indigo-400 mt-1">
- Pulse Enterprise required for auto-fix.{' '}
+ <p class="text-[10px] text-indigo-600 dark:text-indigo-400 mt-2 flex items-center gap-1.5 p-2 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg border border-indigo-100 dark:border-indigo-800">
+ <Sparkles class="w-3 h-3" />
+ Pulse Enterprise required for auto-fix.
<a
- class="underline decoration-dotted font-semibold"
+ class="ml-auto px-2 py-0.5 bg-indigo-600 text-white rounded hover:bg-indigo-700 transition shadow-sm font-semibold"
href="https://pulse.sh/pro"
target="_blank"
rel="noreferrer"
diff --git a/frontend-modern/src/components/Settings/AuditLogPanel.tsx b/frontend-modern/src/components/Settings/AuditLogPanel.tsx
index 118b543792..cca5b804fd 100644
--- a/frontend-modern/src/components/Settings/AuditLogPanel.tsx
+++ b/frontend-modern/src/components/Settings/AuditLogPanel.tsx
@@ -507,25 +507,34 @@ export default function AuditLogPanel() {
{/* OSS Notice / Upgrade CTA */}
<Show when={!isEnterprise() && !loading()}>
- <div class="flex items-start gap-4 p-5 bg-gradient-to-br from-indigo-50 to-purple-50 dark:from-indigo-900/20 dark:to-purple-900/20 border border-indigo-100 dark:border-indigo-800/50 rounded-xl shadow-sm">
- <div class="p-2 bg-indigo-100 dark:bg-indigo-900/50 rounded-lg">
- <Sparkles class="w-5 h-5 text-indigo-600 dark:text-indigo-400" />
- </div>
- <div class="flex-1">
- <h3 class="font-bold text-indigo-900 dark:text-indigo-100">Unlock Enterprise Audit Logging</h3>
- <p class="text-sm text-indigo-800/80 dark:text-indigo-200/80 mt-1 leading-relaxed">
- Upgrade to Pulse Enterprise for persistent, searchable audit logs and cryptographically signed event verification.
- Ensure compliance and security for your mission-critical infrastructure.
- </p>
- <div class="mt-4 flex flex-wrap gap-3">
+ <div class="relative overflow-hidden group">
+ <div class="absolute inset-0 bg-gradient-to-r from-indigo-500/10 via-purple-500/10 to-blue-500/10 opacity-50 group-hover:opacity-100 transition-opacity"></div>
+ <div class="relative flex flex-col md:flex-row items-center gap-6 p-8 bg-white dark:bg-gray-800/50 border border-indigo-100 dark:border-indigo-900/50 rounded-2xl shadow-xl backdrop-blur-sm">
+ <div class="p-4 bg-gradient-to-br from-indigo-600 to-purple-600 rounded-2xl shadow-lg transform group-hover:scale-110 transition-transform duration-500">
+ <Sparkles class="w-8 h-8 text-white" />
+ </div>
+ <div class="flex-1 text-center md:text-left">
+ <h3 class="text-xl font-bold text-gray-900 dark:text-white flex items-center justify-center md:justify-start gap-2">
+ Unlock Enterprise Audit Logging
+ <span class="px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 rounded-md">PRO Feature</span>
+ </h3>
+ <p class="text-sm text-gray-600 dark:text-gray-400 mt-2 leading-relaxed max-w-2xl">
+ Upgrade to Pulse Enterprise for persistent, searchable audit logs and cryptographically signed event verification.
+ Ensure high-level compliance, security, and accountability for your mission-critical infrastructure.
+ </p>
+ </div>
+ <div class="flex flex-col gap-3 min-w-[200px]">
<a
href="https://pulse.sh/pro"
target="_blank"
- class="inline-flex items-center gap-2 px-4 py-2 text-sm font-semibold bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition-all shadow-md shadow-indigo-200 dark:shadow-none"
+ class="inline-flex items-center justify-center gap-2 px-6 py-3 text-sm font-bold bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 hover:shadow-indigo-500/25 hover:shadow-lg transform active:scale-95 transition-all shadow-md"
>
- View Enterprise Plans
+ Get Enterprise
<ExternalLink class="w-4 h-4" />
</a>
+ <p class="text-[10px] text-center text-gray-500 dark:text-gray-500 italic">
+ Pricing starts at $1.50/node
+ </p>
</div>
</div>
</div>
diff --git a/frontend-modern/src/components/Settings/OIDCPanel.tsx b/frontend-modern/src/components/Settings/OIDCPanel.tsx
index a37225fe25..7f6664561f 100644
--- a/frontend-modern/src/components/Settings/OIDCPanel.tsx
+++ b/frontend-modern/src/components/Settings/OIDCPanel.tsx
@@ -275,24 +275,28 @@ export const OIDCPanel: Component<Props> = (props) => {
</div>
</div>
<Show when={!isEnterprise() && !loading()}>
- <div class="mx-6 mt-6 p-4 bg-gradient-to-br from-indigo-50 to-purple-50 dark:from-indigo-900/20 dark:to-purple-900/20 border border-indigo-100 dark:border-indigo-800/50 rounded-xl">
- <div class="flex items-start gap-4">
- <div class="p-2 bg-indigo-100 dark:bg-indigo-900/50 rounded-lg">
- <Sparkles class="w-4 h-4 text-indigo-600 dark:text-indigo-400" />
+ <div class="mx-6 mt-6 relative overflow-hidden group">
+ <div class="absolute inset-0 bg-gradient-to-r from-indigo-500/10 via-purple-500/10 to-blue-500/10 opacity-50 group-hover:opacity-100 transition-opacity"></div>
+ <div class="relative flex items-start gap-4 p-6 bg-white dark:bg-gray-800/50 border border-indigo-100 dark:border-indigo-900/50 rounded-2xl shadow-xl backdrop-blur-sm">
+ <div class="p-3 bg-gradient-to-br from-indigo-600 to-purple-600 rounded-xl shadow-lg transform group-hover:scale-110 transition-transform duration-500">
+ <Sparkles class="w-5 h-5 text-white" />
</div>
<div class="flex-1">
- <h4 class="text-sm font-bold text-indigo-900 dark:text-indigo-100">Enterprise Feature</h4>
- <p class="text-xs text-indigo-800/80 dark:text-indigo-200/80 mt-1">
+ <h4 class="text-sm font-bold text-gray-900 dark:text-white flex items-center gap-2">
+ Enterprise Feature
+ <span class="px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 rounded">SSO</span>
+ </h4>
+ <p class="text-xs text-gray-600 dark:text-gray-400 mt-1 leading-relaxed">
OIDC integration is an Enterprise-only feature. Upgrade your license to enable seamless Single Sign-On for your team.
</p>
<div class="mt-3">
<a
href="https://pulse.sh/pro"
target="_blank"
- class="inline-flex items-center gap-1.5 text-xs font-semibold text-indigo-600 dark:text-indigo-400 hover:underline"
+ class="inline-flex items-center gap-1.5 text-xs font-bold text-indigo-600 dark:text-indigo-400 hover:text-indigo-700 dark:hover:text-indigo-300 transition-colors group/link"
>
Learn about Enterprise
- <ExternalLink class="w-3 h-3" />
+ <ExternalLink class="w-3 h-3 transform group-hover/link:translate-x-0.5 group-hover/link:-translate-y-0.5 transition-transform" />
</a>
</div>
</div>
diff --git a/frontend-modern/src/components/Settings/ProLicensePanel.tsx b/frontend-modern/src/components/Settings/ProLicensePanel.tsx
index 9d1c0d40ce..6bb6c0286b 100644
--- a/frontend-modern/src/components/Settings/ProLicensePanel.tsx
+++ b/frontend-modern/src/components/Settings/ProLicensePanel.tsx
@@ -5,7 +5,7 @@ import { notificationStore } from '@/stores/notifications';
import { LicenseAPI, type LicenseStatus } from '@/api/license';
import RefreshCw from 'lucide-solid/icons/refresh-cw';
-const PULSE_PRO_URL = 'https://pulserelay.pro';
+const PULSE_PRO_URL = 'https://pulse.sh/pro';
const TIER_LABELS: Record<string, string> = {
free: 'Free',
diff --git a/frontend-modern/src/components/shared/AIImpactTimelinePanel.tsx b/frontend-modern/src/components/shared/AIImpactTimelinePanel.tsx
index 86613158f9..8db43ab830 100644
--- a/frontend-modern/src/components/shared/AIImpactTimelinePanel.tsx
+++ b/frontend-modern/src/components/shared/AIImpactTimelinePanel.tsx
@@ -3,7 +3,7 @@ import { AIAPI } from '@/api/ai';
import { logger } from '@/utils/logger';
import type { RemediationRecord, RemediationStats } from '@/types/aiIntelligence';
-const DEFAULT_UPGRADE_URL = 'https://pulserelay.pro';
+const DEFAULT_UPGRADE_URL = 'https://pulse.sh/pro';
export const AIImpactTimelinePanel: Component<{ hours?: number; showWhenEmpty?: boolean }> = (props) => {
const [remediations, setRemediations] = createSignal<RemediationRecord[]>([]);
diff --git a/frontend-modern/src/components/shared/AIInsightsPanel.tsx b/frontend-modern/src/components/shared/AIInsightsPanel.tsx
index 9f416f9cf0..33bd2b87fd 100644
--- a/frontend-modern/src/components/shared/AIInsightsPanel.tsx
+++ b/frontend-modern/src/components/shared/AIInsightsPanel.tsx
@@ -14,7 +14,7 @@ export const AIInsightsPanel: Component<{ resourceId?: string; showWhenEmpty?: b
const [expanded, setExpanded] = createSignal(false);
const [locked, setLocked] = createSignal(false);
const [lockedCount, setLockedCount] = createSignal(0);
- const [upgradeUrl, setUpgradeUrl] = createSignal('https://pulserelay.pro');
+ const [upgradeUrl, setUpgradeUrl] = createSignal('https://pulse.sh/pro');
const [error, setError] = createSignal('');
const showWhenEmpty = () => Boolean(props.showWhenEmpty);
@@ -28,7 +28,7 @@ export const AIInsightsPanel: Component<{ resourceId?: string; showWhenEmpty?: b
]);
const licenseLocked = Boolean(predResp.license_required || corrResp.license_required);
setLocked(licenseLocked);
- setUpgradeUrl(predResp.upgrade_url || corrResp.upgrade_url || 'https://pulserelay.pro');
+ setUpgradeUrl(predResp.upgrade_url || corrResp.upgrade_url || 'https://pulse.sh/pro');
if (licenseLocked) {
const predCount = predResp.count || 0;
const corrCount = corrResp.count || 0;
diff --git a/frontend-modern/src/components/shared/AIOverviewTable.tsx b/frontend-modern/src/components/shared/AIOverviewTable.tsx
index a4134e7252..a7731ee45e 100644
--- a/frontend-modern/src/components/shared/AIOverviewTable.tsx
+++ b/frontend-modern/src/components/shared/AIOverviewTable.tsx
@@ -3,7 +3,7 @@ import { AIAPI } from '@/api/ai';
import { logger } from '@/utils/logger';
import type { FailurePrediction, InfrastructureChange, RemediationRecord, RemediationStats, AnomalyReport } from '@/types/aiIntelligence';
-const DEFAULT_UPGRADE_URL = 'https://pulserelay.pro';
+const DEFAULT_UPGRADE_URL = 'https://pulse.sh/pro';
interface InsightRow {
id: string;
diff --git a/frontend-modern/src/components/shared/AIRecentChangesPanel.tsx b/frontend-modern/src/components/shared/AIRecentChangesPanel.tsx
index 3c971041a2..8d11268ca7 100644
--- a/frontend-modern/src/components/shared/AIRecentChangesPanel.tsx
+++ b/frontend-modern/src/components/shared/AIRecentChangesPanel.tsx
@@ -3,7 +3,7 @@ import { AIAPI } from '@/api/ai';
import { logger } from '@/utils/logger';
import type { InfrastructureChange } from '@/types/aiIntelligence';
-const DEFAULT_UPGRADE_URL = 'https://pulserelay.pro';
+const DEFAULT_UPGRADE_URL = 'https://pulse.sh/pro';
export const AIRecentChangesPanel: Component<{ hours?: number; showWhenEmpty?: boolean }> = (props) => {
const [changes, setChanges] = createSignal<InfrastructureChange[]>([]);
diff --git a/frontend-modern/src/pages/Alerts.tsx b/frontend-modern/src/pages/Alerts.tsx
index 12ea82b212..8bb3fdcc80 100644
--- a/frontend-modern/src/pages/Alerts.tsx
+++ b/frontend-modern/src/pages/Alerts.tsx
@@ -35,6 +35,8 @@ import Send from 'lucide-solid/icons/send';
import Calendar from 'lucide-solid/icons/calendar';
import { getPatrolStatus, getFindings, getFindingsHistory, getPatrolRunHistory, forcePatrol, subscribeToPatrolStream, dismissFinding, suppressFinding, resolveFinding, clearAllFindings, getSuppressionRules, addSuppressionRule, deleteSuppressionRule, type Finding, type PatrolStatus, type PatrolRunRecord, type SuppressionRule, severityColors, formatTimestamp, categoryLabels } from '@/api/patrol';
import { aiChatStore } from '@/stores/aiChat';
+import Sparkles from 'lucide-solid/icons/sparkles';
+import ExternalLink from 'lucide-solid/icons/external-link';
type AlertTab = 'overview' | 'thresholds' | 'destinations' | 'schedule' | 'history';
@@ -2281,7 +2283,7 @@ function OverviewTab(props: {
if (!status) return false;
return !status.features?.['ai_alerts'];
});
- const aiAlertsUpgradeURL = createMemo(() => licenseFeatures()?.upgrade_url || 'https://pulserelay.pro');
+ const aiAlertsUpgradeURL = createMemo(() => licenseFeatures()?.upgrade_url || 'https://pulse.sh/pro');
// Live streaming state for running patrol
const [expandedLiveStream, setExpandedLiveStream] = createSignal(false);
// Track streaming blocks for sequential display (like AI chat)
@@ -2294,7 +2296,7 @@ function OverviewTab(props: {
const [currentThinking, setCurrentThinking] = createSignal('');
let liveStreamUnsubscribe: (() => void) | null = null;
const patrolRequiresLicense = createMemo(() => patrolStatus()?.license_required === true);
- const patrolUpgradeURL = createMemo(() => patrolStatus()?.upgrade_url || 'https://pulserelay.pro');
+ const patrolUpgradeURL = createMemo(() => patrolStatus()?.upgrade_url || 'https://pulse.sh/pro');
const patrolLicenseNote = createMemo(() => {
if (!patrolRequiresLicense()) return '';
const status = patrolStatus()?.license_status;
@@ -2818,23 +2820,28 @@ function OverviewTab(props: {
</div>
<Show when={patrolRequiresLicense()}>
- <div class="mb-4 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3">
- <div class="flex items-start gap-3">
- <svg class="w-4 h-4 text-amber-600 dark:text-amber-300 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 11V7a4 4 0 00-8 0v4m12 0a2 2 0 012 2v6a2 2 0 01-2 2H8a2 2 0 01-2-2v-6a2 2 0 012-2h8z" />
- </svg>
+ <div class="mb-4 relative overflow-hidden group">
+ <div class="absolute inset-0 bg-gradient-to-r from-amber-500/10 to-orange-500/10 opacity-50 group-hover:opacity-100 transition-opacity"></div>
+ <div class="relative flex items-start gap-3 p-4 bg-white dark:bg-gray-800/50 border border-amber-200 dark:border-amber-900/50 rounded-xl shadow-lg backdrop-blur-sm">
+ <div class="p-2 bg-gradient-to-br from-amber-400 to-orange-500 rounded-lg shadow-md">
+ <Sparkles class="w-4 h-4 text-white" />
+ </div>
<div class="flex-1">
- <p class="text-sm font-medium text-amber-800 dark:text-amber-200">Pulse Pro required</p>
- <p class="text-xs text-amber-700 dark:text-amber-300 mt-1">
+ <div class="flex items-center gap-2">
+ <p class="text-sm font-bold text-gray-900 dark:text-white">Pulse Pro Required</p>
+ <span class="px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider bg-amber-100 dark:bg-amber-900/50 text-amber-600 dark:text-amber-400 rounded">AI Patrol</span>
+ </div>
+ <p class="text-xs text-gray-600 dark:text-gray-400 mt-1 leading-relaxed">
{patrolLicenseNote() || 'AI Patrol insights require Pulse Pro.'}
</p>
<a
- class="inline-flex items-center gap-1 mt-2 text-xs font-medium text-amber-800 dark:text-amber-200 hover:underline"
+ class="inline-flex items-center gap-1.5 mt-2.5 text-xs font-bold text-amber-600 dark:text-amber-400 hover:text-amber-700 dark:hover:text-amber-300 transition-colors group/link"
href={patrolUpgradeURL()}
target="_blank"
rel="noreferrer"
>
- Upgrade to Pulse Pro
+ Upgrade to Pro
+ <ExternalLink class="w-3 h-3 transform group-hover/link:translate-x-0.5 group-hover/link:-translate-y-0.5 transition-transform" />
</a>
</div>
</div>
diff --git a/internal/ai/providers/openai.go b/internal/ai/providers/openai.go
index 3a841ac75f..1bbf6b79ef 100644
--- a/internal/ai/providers/openai.go
+++ b/internal/ai/providers/openai.go
@@ -34,6 +34,23 @@ type OpenAIClient struct {
func NewOpenAIClient(apiKey, model, baseURL string, timeout time.Duration) *OpenAIClient {
if baseURL == "" {
baseURL = openaiAPIURL
+ } else {
+ // Normalize baseURL: ensure it ends with /chat/completions for chat endpoint
+ // Users may provide URLs like "https://openrouter.ai/api/v1" which need the path appended
+ baseURL = strings.TrimSuffix(baseURL, "/")
+ if !strings.HasSuffix(baseURL, "/chat/completions") {
+ // If URL ends with /v1, append /chat/completions
+ // Otherwise append /v1/chat/completions
+ if strings.HasSuffix(baseURL, "/v1") {
+ baseURL = baseURL + "/chat/completions"
+ } else if strings.HasSuffix(baseURL, "/completions") {
+ // URL already has /completions, make it /chat/completions
+ baseURL = strings.TrimSuffix(baseURL, "/completions") + "/chat/completions"
+ } else {
+ // Assume it's a base URL, append full path
+ baseURL = baseURL + "/v1/chat/completions"
+ }
+ }
}
// Strip provider prefix if present - the model should be just the model name
if strings.HasPrefix(model, "openai:") {
@@ -488,11 +505,22 @@ func (c *OpenAIClient) modelsEndpoint() string {
return modelsURL
}
- base := u.Scheme + "://" + u.Host
+ // For custom endpoints, replace /chat/completions with /models in the path
+ // This preserves any custom path structure (e.g., /api/v1 for OpenRouter)
if c.isDeepSeek() {
- return base + "/models"
+ return u.Scheme + "://" + u.Host + "/models"
+ }
+
+ // Replace /chat/completions with /models to get the models endpoint
+ // baseURL is already normalized to end with /chat/completions
+ path := u.Path
+ if strings.HasSuffix(path, "/chat/completions") {
+ path = strings.TrimSuffix(path, "/chat/completions") + "/models"
+ } else {
+ // Fallback: strip path and use /v1/models
+ path = "/v1/models"
}
- return base + "/v1/models"
+ return u.Scheme + "://" + u.Host + path
}
// ListModels fetches available models from the OpenAI API
diff --git a/internal/ai/providers/openai_test.go b/internal/ai/providers/openai_test.go
index 16269b2799..1e5b109cd1 100644
--- a/internal/ai/providers/openai_test.go
+++ b/internal/ai/providers/openai_test.go
@@ -723,3 +723,102 @@ func TestOpenAIClient_ListModels_Error(t *testing.T) {
//
// For now, these tests would require actual API keys to run E2E tests,
// which should be done in a separate integration test suite.
+
+func TestNewOpenAIClient_URLNormalization(t *testing.T) {
+ tests := []struct {
+ name string
+ inputURL string
+ expectedURL string
+ modelsURL string
+ }{
+ {
+ name: "OpenRouter base URL",
+ inputURL: "https://openrouter.ai/api/v1",
+ expectedURL: "https://openrouter.ai/api/v1/chat/completions",
+ modelsURL: "https://openrouter.ai/api/v1/models",
+ },
+ {
+ name: "OpenRouter with trailing slash",
+ inputURL: "https://openrouter.ai/api/v1/",
+ expectedURL: "https://openrouter.ai/api/v1/chat/completions",
+ modelsURL: "https://openrouter.ai/api/v1/models",
+ },
+ {
+ name: "Full chat/completions URL unchanged",
+ inputURL: "https://api.example.com/v1/chat/completions",
+ expectedURL: "https://api.example.com/v1/chat/completions",
+ modelsURL: "https://api.example.com/v1/models",
+ },
+ {
+ name: "Base domain only",
+ inputURL: "https://api.example.com",
+ expectedURL: "https://api.example.com/v1/chat/completions",
+ modelsURL: "https://api.example.com/v1/models",
+ },
+ {
+ name: "Custom endpoint with completions",
+ inputURL: "https://custom.ai/completions",
+ expectedURL: "https://custom.ai/chat/completions",
+ modelsURL: "https://custom.ai/models",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ client := NewOpenAIClient("test-key", "gpt-4o", tt.inputURL, 0)
+ if client.baseURL != tt.expectedURL {
+ t.Errorf("baseURL = %q, want %q", client.baseURL, tt.expectedURL)
+ }
+ modelsEndpoint := client.modelsEndpoint()
+ if modelsEndpoint != tt.modelsURL {
+ t.Errorf("modelsEndpoint = %q, want %q", modelsEndpoint, tt.modelsURL)
+ }
+ })
+ }
+}
+
+func TestOpenAIClient_Chat_OpenRouterURL(t *testing.T) {
+ // Simulate OpenRouter with /api/v1 base URL
+ var gotPath string
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ gotPath = r.URL.Path
+ resp := mockOpenAIResponse{
+ ID: "chatcmpl-123",
+ Model: "openai/gpt-4o",
+ Choices: []struct {
+ Index int `json:"index"`
+ Message struct {
+ Role string `json:"role"`
+ Content string `json:"content"`
+ } `json:"message"`
+ FinishReason string `json:"finish_reason"`
+ }{
+ {Message: struct {
+ Role string `json:"role"`
+ Content string `json:"content"`
+ }{Role: "assistant", Content: "Hello from OpenRouter"}, FinishReason: "stop"},
+ },
+ }
+ json.NewEncoder(w).Encode(resp)
+ }))
+ defer server.Close()
+
+ // User provides OpenRouter-style URL without /chat/completions
+ client := NewOpenAIClient("test-key", "openai/gpt-4o", server.URL+"/api/v1", 0)
+
+ resp, err := client.Chat(context.Background(), ChatRequest{
+ Messages: []Message{{Role: "user", Content: "Hello"}},
+ })
+ if err != nil {
+ t.Fatalf("Chat: %v", err)
+ }
+
+ // Should correctly append /chat/completions to the path
+ if gotPath != "/api/v1/chat/completions" {
+ t.Errorf("path = %q, want /api/v1/chat/completions", gotPath)
+ }
+
+ if resp.Content != "Hello from OpenRouter" {
+ t.Errorf("content = %q, want 'Hello from OpenRouter'", resp.Content)
+ }
+}
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 4d1707e5e7..1f4249fd41 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -385,7 +385,7 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
"error": "license_required",
"message": "AI Auto-Fix requires Pulse Pro",
"feature": ai.FeatureAIAutoFix,
- "upgrade_url": "https://pulserelay.pro",
+ "upgrade_url": "https://pulse.sh/pro",
})
return
}
@@ -393,6 +393,18 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
}
if req.UseProactiveThresholds != nil {
+ // Proactive thresholds require Pro license with ai_patrol feature
+ if *req.UseProactiveThresholds && !h.aiService.HasLicenseFeature(ai.FeatureAIPatrol) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "Proactive Thresholds requires Pulse Pro",
+ "feature": ai.FeatureAIPatrol,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
settings.UseProactiveThresholds = *req.UseProactiveThresholds
}
@@ -409,7 +421,7 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
"error": "license_required",
"message": "Autonomous Mode requires Pulse Pro",
"feature": ai.FeatureAIAutoFix,
- "upgrade_url": "https://pulserelay.pro",
+ "upgrade_url": "https://pulse.sh/pro",
})
return
}
@@ -481,15 +493,44 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
http.Error(w, "patrol_interval_minutes cannot exceed 10080 (7 days)", http.StatusBadRequest)
return
}
+
+ // Enabling background patrol requires Pro license
+ if minutes > 0 && !h.aiService.HasLicenseFeature(ai.FeatureAIPatrol) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "Background AI Patrol requires Pulse Pro",
+ "feature": ai.FeatureAIPatrol,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
+
settings.PatrolIntervalMinutes = minutes
settings.PatrolSchedulePreset = "" // Clear preset when using custom minutes
} else if req.PatrolSchedulePreset != nil {
// Legacy preset support
preset := strings.ToLower(strings.TrimSpace(*req.PatrolSchedulePreset))
switch preset {
- case "15min", "1hr", "6hr", "12hr", "daily", "disabled":
+ case "15min", "1hr", "6hr", "12hr", "daily":
+ // Enabling background patrol requires Pro license
+ if !h.aiService.HasLicenseFeature(ai.FeatureAIPatrol) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "Background AI Patrol requires Pulse Pro",
+ "feature": ai.FeatureAIPatrol,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
settings.PatrolSchedulePreset = preset
settings.PatrolIntervalMinutes = config.PresetToMinutes(preset)
+ case "disabled":
+ settings.PatrolSchedulePreset = preset
+ settings.PatrolIntervalMinutes = 0
default:
http.Error(w, "Invalid patrol_schedule_preset. Must be '15min', '1hr', '6hr', '12hr', 'daily', or 'disabled'", http.StatusBadRequest)
return
@@ -506,6 +547,18 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
// Handle alert-triggered analysis toggle
if req.AlertTriggeredAnalysis != nil {
+ // Alert analysis requires Pro license with ai_alerts feature
+ if *req.AlertTriggeredAnalysis && !h.aiService.HasLicenseFeature(ai.FeatureAIAlerts) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "AI Alert Analysis requires Pulse Pro",
+ "feature": ai.FeatureAIAlerts,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
settings.AlertTriggeredAnalysis = *req.AlertTriggeredAnalysis
}
@@ -815,13 +868,48 @@ func (h *AISettingsHandler) HandleExecute(w http.ResponseWriter, r *http.Request
}
// Parse request
- r.Body = http.MaxBytesReader(w, r.Body, 64*1024) // 64KB max
+ r.Body = http.MaxBytesReader(w, r.Body, 64*1024)
+ bodyBytes, readErr := io.ReadAll(r.Body)
+ if readErr != nil {
+ log.Error().Err(readErr).Msg("Failed to read request body")
+ http.Error(w, "Invalid request body", http.StatusBadRequest)
+ return
+ }
+
var req AIExecuteRequest
- if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
+ if err := json.Unmarshal(bodyBytes, &req); err != nil {
http.Error(w, "Invalid request body", http.StatusBadRequest)
return
}
+ // Fine-grained license checks based on UseCase
+ useCase := strings.ToLower(strings.TrimSpace(req.UseCase))
+ if useCase == "autofix" || useCase == "remediation" {
+ if !h.aiService.HasLicenseFeature(ai.FeatureAIAutoFix) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "AI Auto-Fix requires Pulse Pro",
+ "feature": ai.FeatureAIAutoFix,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
+ } else if useCase == "patrol" {
+ if !h.aiService.HasLicenseFeature(ai.FeatureAIPatrol) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "AI Patrol reasoning requires Pulse Pro",
+ "feature": ai.FeatureAIPatrol,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
+ }
+
if strings.TrimSpace(req.Prompt) == "" {
http.Error(w, "Prompt is required", http.StatusBadRequest)
return
@@ -840,7 +928,6 @@ func (h *AISettingsHandler) HandleExecute(w http.ResponseWriter, r *http.Request
})
}
- useCase := strings.TrimSpace(req.UseCase)
if useCase == "" {
useCase = "chat"
}
@@ -981,6 +1068,34 @@ func (h *AISettingsHandler) HandleExecuteStream(w http.ResponseWriter, r *http.R
return
}
+ // Fine-grained license checks based on UseCase (before SSE headers)
+ useCase := strings.ToLower(strings.TrimSpace(req.UseCase))
+ if useCase == "autofix" || useCase == "remediation" {
+ if !h.aiService.HasLicenseFeature(ai.FeatureAIAutoFix) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "AI Auto-Fix requires Pulse Pro",
+ "feature": ai.FeatureAIAutoFix,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
+ } else if useCase == "patrol" {
+ if !h.aiService.HasLicenseFeature(ai.FeatureAIPatrol) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "AI Patrol reasoning requires Pulse Pro",
+ "feature": ai.FeatureAIPatrol,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
+ }
+
if strings.TrimSpace(req.Prompt) == "" {
http.Error(w, "Prompt is required", http.StatusBadRequest)
return
@@ -1106,7 +1221,6 @@ func (h *AISettingsHandler) HandleExecuteStream(w http.ResponseWriter, r *http.R
})
}
- useCase := strings.TrimSpace(req.UseCase)
if useCase == "" {
useCase = "chat"
}
@@ -1190,6 +1304,19 @@ func (h *AISettingsHandler) HandleRunCommand(w http.ResponseWriter, r *http.Requ
return
}
+ // Gated for AI Auto-Fix (Pro feature)
+ if !h.aiService.HasLicenseFeature(ai.FeatureAIAutoFix) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusPaymentRequired)
+ _ = json.NewEncoder(w).Encode(map[string]interface{}{
+ "error": "license_required",
+ "message": "AI Auto-Fix requires Pulse Pro",
+ "feature": ai.FeatureAIAutoFix,
+ "upgrade_url": "https://pulse.sh/pro",
+ })
+ return
+ }
+
// Parse request
r.Body = http.MaxBytesReader(w, r.Body, 16*1024)
bodyBytes, readErr := io.ReadAll(r.Body)
@@ -2171,7 +2298,7 @@ func (h *AISettingsHandler) HandleGetPatrolStatus(w http.ResponseWriter, r *http
LicenseStatus: licenseStatus,
}
if !hasPatrolFeature {
- response.UpgradeURL = "https://pulserelay.pro"
+ response.UpgradeURL = "https://pulse.sh/pro"
}
response.Summary.Critical = summary.Critical
response.Summary.Warning = summary.Warning
diff --git a/internal/api/ai_intelligence_handlers.go b/internal/api/ai_intelligence_handlers.go
index b1e4bcec23..60a5e993e3 100644
--- a/internal/api/ai_intelligence_handlers.go
+++ b/internal/api/ai_intelligence_handlers.go
@@ -11,7 +11,7 @@ import (
"github.com/rs/zerolog/log"
)
-const aiIntelligenceUpgradeURL = "https://pulserelay.pro"
+const aiIntelligenceUpgradeURL = "https://pulse.sh/pro"
// HandleGetPatterns returns detected failure patterns (GET /api/ai/intelligence/patterns)
func (h *AISettingsHandler) HandleGetPatterns(w http.ResponseWriter, r *http.Request) {
@@ -450,11 +450,20 @@ func (h *AISettingsHandler) HandleGetRemediations(w http.ResponseWriter, r *http
return
}
+ // Check for Pulse Pro license (soft-lock)
+ locked := !h.aiService.HasLicenseFeature(license.FeatureAIAutoFix)
+ if locked {
+ w.Header().Set("X-License-Required", "true")
+ w.Header().Set("X-License-Feature", license.FeatureAIAutoFix)
+ }
+
// AI must be enabled to return intelligence data
if !h.aiService.IsEnabled() {
if err := utils.WriteJSONResponse(w, map[string]interface{}{
- "remediations": []interface{}{},
- "message": "AI is not enabled",
+ "remediations": []interface{}{},
+ "message": "AI is not enabled",
+ "license_required": locked,
+ "upgrade_url": aiIntelligenceUpgradeURL,
}); err != nil {
log.Error().Err(err).Msg("Failed to write remediations response")
}
@@ -464,8 +473,10 @@ func (h *AISettingsHandler) HandleGetRemediations(w http.ResponseWriter, r *http
patrol := h.aiService.GetPatrolService()
if patrol == nil {
if err := utils.WriteJSONResponse(w, map[string]interface{}{
- "remediations": []interface{}{},
- "message": "Patrol service not initialized",
+ "remediations": []interface{}{},
+ "message": "Patrol service not initialized",
+ "license_required": locked,
+ "upgrade_url": aiIntelligenceUpgradeURL,
}); err != nil {
log.Error().Err(err).Msg("Failed to write remediations response")
}
@@ -475,8 +486,10 @@ func (h *AISettingsHandler) HandleGetRemediations(w http.ResponseWriter, r *http
remediationLog := patrol.GetRemediationLog()
if remediationLog == nil {
if err := utils.WriteJSONResponse(w, map[string]interface{}{
- "remediations": []interface{}{},
- "message": "Remediation log not initialized",
+ "remediations": []interface{}{},
+ "message": "Remediation log not initialized",
+ "license_required": locked,
+ "upgrade_url": aiIntelligenceUpgradeURL,
}); err != nil {
log.Error().Err(err).Msg("Failed to write remediations response")
}
@@ -542,12 +555,6 @@ func (h *AISettingsHandler) HandleGetRemediations(w http.ResponseWriter, r *http
})
}
- locked := !h.aiService.HasLicenseFeature(license.FeatureAIPatrol)
- if locked {
- w.Header().Set("X-License-Required", "true")
- w.Header().Set("X-License-Feature", license.FeatureAIPatrol)
- }
-
count := len(result)
if locked {
result = []map[string]interface{}{}
@@ -911,13 +918,19 @@ func (h *AISettingsHandler) HandleGetLearningStatus(w http.ResponseWriter, r *ht
message = "Baselines established and anomaly detection is active"
}
+ locked := !h.aiService.HasLicenseFeature(license.FeatureAIPatrol)
+ if locked {
+ w.Header().Set("X-License-Required", "true")
+ w.Header().Set("X-License-Feature", license.FeatureAIPatrol)
+ }
+
if err := utils.WriteJSONResponse(w, map[string]interface{}{
"resources_baselined": resourceCount,
"total_metrics": totalMetrics,
"metric_breakdown": metricCounts,
"status": status,
"message": message,
- "license_required": false,
+ "license_required": locked,
}); err != nil {
log.Error().Err(err).Msg("Failed to write learning status response")
}
diff --git a/internal/api/license_handlers.go b/internal/api/license_handlers.go
index 6471e0c3bc..27965c8119 100644
--- a/internal/api/license_handlers.go
+++ b/internal/api/license_handlers.go
@@ -93,7 +93,7 @@ func (h *LicenseHandlers) HandleLicenseFeatures(w http.ResponseWriter, r *http.R
license.FeatureUpdateAlerts: h.service.HasFeature(license.FeatureUpdateAlerts),
license.FeatureAgentProfiles: h.service.HasFeature(license.FeatureAgentProfiles),
},
- UpgradeURL: "https://pulserelay.pro",
+ UpgradeURL: "https://pulse.sh/pro",
}
w.Header().Set("Content-Type", "application/json")
@@ -219,7 +219,7 @@ func RequireLicenseFeature(service *license.Service, feature string, next http.H
"error": "license_required",
"message": err.Error(),
"feature": feature,
- "upgrade_url": "https://pulserelay.pro",
+ "upgrade_url": "https://pulse.sh/pro",
})
return
}
diff --git a/internal/api/router.go b/internal/api/router.go
index a4e6c468db..cba49d7fcc 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -1307,7 +1307,7 @@ func (r *Router) setupRoutes() {
"error": "license_required",
"message": err.Error(),
"feature": license.FeatureAIPatrol,
- "upgrade_url": "https://pulserelay.pro",
+ "upgrade_url": "https://pulse.sh/pro",
})
return
}
diff --git a/internal/hostagent/proxmox_setup.go b/internal/hostagent/proxmox_setup.go
index 3042fb1016..4e63411848 100644
--- a/internal/hostagent/proxmox_setup.go
+++ b/internal/hostagent/proxmox_setup.go
@@ -379,7 +379,10 @@ func (p *ProxmoxSetup) getHostURL(ptype string) string {
if out, err := exec.Command("hostname", "-I").Output(); err == nil {
ips := strings.Fields(string(out))
if len(ips) > 0 {
- bestIP := selectBestIP(ips)
+ // Get the IP that the system hostname currently resolves to
+ hostnameIP := p.getIPForHostname()
+
+ bestIP := selectBestIP(ips, hostnameIP)
if bestIP != "" {
return fmt.Sprintf("https://%s:%s", bestIP, port)
}
@@ -436,6 +439,30 @@ func (p *ProxmoxSetup) getIPThatReachesPulse() string {
return ""
}
+// getIPForHostname resolves the system hostname to an IP address.
+func (p *ProxmoxSetup) getIPForHostname() string {
+ hostname := p.hostname
+ if hostname == "" {
+ hostname, _ = os.Hostname()
+ }
+ if hostname == "" {
+ return ""
+ }
+
+ ips, err := net.LookupIP(hostname)
+ if err != nil {
+ p.logger.Debug().Err(err).Str("hostname", hostname).Msg("Could not resolve hostname IP")
+ return ""
+ }
+
+ for _, ip := range ips {
+ if ipv4 := ip.To4(); ipv4 != nil {
+ return ipv4.String()
+ }
+ }
+ return ""
+}
+
// isPrivateIP checks if an IP address is in a private range (RFC 1918).
func isPrivateIP(ip string) bool {
parsed := net.ParseIP(ip)
@@ -460,7 +487,8 @@ func isPrivateIP(ip string) bool {
// selectBestIP picks the most likely externally-reachable IP from a list.
// Prefers common LAN subnets (192.168.x.x, 10.x.x.x) and avoids internal
// cluster networks (like corosync's 172.20.x.x) and link-local addresses.
-func selectBestIP(ips []string) string {
+// If hostnameIP is provided and present in the list, it is given the highest priority.
+func selectBestIP(ips []string, hostnameIP string) string {
type scoredIP struct {
ip string
score int
@@ -480,6 +508,15 @@ func selectBestIP(ips []string) string {
}
score := scoreIPv4(ip)
+
+ // If this IP matches the system hostname, give it a significant bonus.
+ // A bonus of +40 ensures that a 172.16.x.x (score 50) match (50+40=90)
+ // correctly loses to a 192.168.x.x (score 100) interface if both are present.
+ // However, it correctly breaks ties between equal-scored ranges.
+ if hostnameIP != "" && ip == hostnameIP {
+ score += 40
+ }
+
if score > 0 {
candidates = append(candidates, scoredIP{ip: ip, score: score})
}
diff --git a/internal/hostagent/proxmox_setup_test.go b/internal/hostagent/proxmox_setup_test.go
index b273ae0068..a9ffcdf38e 100644
--- a/internal/hostagent/proxmox_setup_test.go
+++ b/internal/hostagent/proxmox_setup_test.go
@@ -8,82 +8,120 @@ import (
func TestSelectBestIP(t *testing.T) {
tests := []struct {
- name string
- ips []string
- expected string
+ name string
+ ips []string
+ hostnameIP string
+ expected string
}{
{
- name: "prefers 192.168.x.x over corosync 172.20.x.x",
- ips: []string{"172.20.0.80", "192.168.1.100"},
- expected: "192.168.1.100",
+ name: "prefers hostname IP matching 10.x range over 192.x range",
+ ips: []string{"10.0.0.1", "192.168.1.100"},
+ hostnameIP: "10.0.0.1",
+ expected: "10.0.0.1",
+ },
+ {
+ name: "prefers 192.168.x.x LAN over 172.20.x.x hostname match (Corosync)",
+ ips: []string{"172.20.0.1", "192.168.1.100"},
+ hostnameIP: "172.20.0.1",
+ expected: "192.168.1.100", // LAN (100) > Cluster (50 + 40 = 90)
+ },
+ {
+ name: "hostname breaks tie between equal subnets (e.g. two 10.x.x.x)",
+ ips: []string{"10.0.0.1", "10.0.0.2"},
+ hostnameIP: "10.0.0.2",
+ expected: "10.0.0.2", // (90 + 40) > 90
+ },
+ {
+ name: "falls back to score heuristic if no hostname IP match",
+ ips: []string{"10.0.0.1", "192.168.1.100"},
+ hostnameIP: "10.0.0.2", // Different IP
+ expected: "192.168.1.100",
+ },
+ {
+ name: "prefers 192.168.x.x over corosync 172.20.x.x (original behavior)",
+ ips: []string{"172.20.0.80", "192.168.1.100"},
+ hostnameIP: "",
+ expected: "192.168.1.100",
},
{
- name: "prefers 192.168.x.x even when listed second",
- ips: []string{"10.0.0.1", "192.168.0.1"},
- expected: "192.168.0.1",
+ name: "prefers 192.168.x.x even when listed second",
+ ips: []string{"10.0.0.1", "192.168.0.1"},
+ hostnameIP: "",
+ expected: "192.168.0.1",
},
{
- name: "prefers 10.x.x.x over 172.16-31.x.x",
- ips: []string{"172.20.0.1", "10.1.10.5"},
- expected: "10.1.10.5",
+ name: "prefers 10.x.x.x over 172.16-31.x.x",
+ ips: []string{"172.20.0.1", "10.1.10.5"},
+ hostnameIP: "",
+ expected: "10.1.10.5",
},
{
- name: "handles single IP",
- ips: []string{"192.168.1.1"},
- expected: "192.168.1.1",
+ name: "handles single IP",
+ ips: []string{"192.168.1.1"},
+ hostnameIP: "",
+ expected: "192.168.1.1",
},
{
- name: "skips loopback",
- ips: []string{"127.0.0.1", "192.168.1.1"},
- expected: "192.168.1.1",
+ name: "skips loopback",
+ ips: []string{"127.0.0.1", "192.168.1.1"},
+ hostnameIP: "",
+ expected: "192.168.1.1",
},
{
- name: "skips IPv6 loopback",
- ips: []string{"::1", "10.0.0.1"},
- expected: "10.0.0.1",
+ name: "skips IPv6 loopback",
+ ips: []string{"::1", "10.0.0.1"},
+ hostnameIP: "",
+ expected: "10.0.0.1",
},
{
- name: "skips link-local IPv6",
- ips: []string{"fe80::1", "192.168.1.1"},
- expected: "192.168.1.1",
+ name: "skips link-local IPv6",
+ ips: []string{"fe80::1", "192.168.1.1"},
+ hostnameIP: "",
+ expected: "192.168.1.1",
},
{
- name: "skips link-local IPv4",
- ips: []string{"169.254.1.1", "10.0.0.1"},
- expected: "10.0.0.1",
+ name: "skips link-local IPv4",
+ ips: []string{"169.254.1.1", "10.0.0.1"},
+ hostnameIP: "",
+ expected: "10.0.0.1",
},
{
- name: "returns corosync IP if only option",
- ips: []string{"127.0.0.1", "172.20.0.80"},
- expected: "172.20.0.80",
+ name: "returns corosync IP if only option",
+ ips: []string{"127.0.0.1", "172.20.0.80"},
+ hostnameIP: "",
+ expected: "172.20.0.80",
},
{
- name: "empty list returns empty",
- ips: []string{},
- expected: "",
+ name: "empty list returns empty",
+ ips: []string{},
+ hostnameIP: "",
+ expected: "",
},
{
- name: "only loopback returns empty",
- ips: []string{"127.0.0.1", "::1"},
- expected: "",
+ name: "only loopback returns empty",
+ ips: []string{"127.0.0.1", "::1"},
+ hostnameIP: "",
+ expected: "",
},
{
- name: "common 10.1.x.x LAN preferred over 172.x.x",
- ips: []string{"172.16.0.1", "10.1.10.50"},
- expected: "10.1.10.50",
+ name: "common 10.1.x.x LAN preferred over 172.x.x",
+ ips: []string{"172.16.0.1", "10.1.10.50"},
+ hostnameIP: "",
+ expected: "10.1.10.50",
},
{
- name: "prefers 10.0.x.x to 10.100.x.x (common ranges first)",
- ips: []string{"10.100.0.1", "10.0.0.1"},
- expected: "10.0.0.1",
+ name: "prefers 10.0.x.x to 10.100.x.x (common ranges first)",
+ ips: []string{"10.100.0.1", "10.0.0.1"},
+ hostnameIP: "",
+ expected: "10.0.0.1",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- result := selectBestIP(tt.ips)
+ result := selectBestIP(tt.ips, tt.hostnameIP)
if result != tt.expected {
- t.Errorf("selectBestIP(%v) = %q, want %q", tt.ips, result, tt.expected)
+ t.Errorf("selectBestIP(%v, %q) = %q, want %q", tt.ips, tt.hostnameIP, result, tt.expected)
}
})
}