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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Add provider-hosted MSP control-plane mode
rcourtmand90352ea8948
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 8d872ae649..e635840a82 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -231,32 +231,62 @@ or other self-hosted uncapped continuity plans.tenant-runtime capacity/log retention configuration, or checkout gatingthrough `internal/cloudcp/config.go` and`internal/cloudcp/public_cloud_signup_handlers.go`- Public MSP self-serve signup is the operator-account front door for the same+ Public MSP signup is the Pulse-operated account front door for the sameboundary and lives in `internal/cloudcp/public_msp_signup_handlers.go`.- Starter is the only public self-serve MSP checkout tier; Growth, Scale, and- Enterprise remain request-based even when their Stripe prices are configured- for assisted/operator-controlled workflows. MSP price configuration+ Starter is the only tier that may expose checkout when the MSP rollout gate+ is deliberately opened; Growth, Scale, and Enterprise remain request-based+ even when their Stripe prices are configured for assisted/operator-controlled+ workflows. MSP price configuration(`CP_MSP_STARTER_PRICE_ID`, `CP_MSP_GROWTH_PRICE_ID`,`CP_MSP_SCALE_PRICE_ID`) is still validated in `internal/cloudcp/config.go`against the canonical `msp_starter`, `msp_growth`, and `msp_scale` plan- versions. Public MSP pricing covers provider-hosted central deployments:- the MSP runs the Pulse instance in their own cloud or infrastructure while- Pulse Account owns licensing, account access, and client-workspace- management. The canonical provider workspace limits are 5 client workspaces- for Starter, 15 for Growth, and 40 for Scale; the canonical public monthly- prices are $149, $249, and $399 respectively. Public copy may publish all- three prices, but must keep Starter as the only self-serve checkout path and- describe Growth and Scale as request-assisted access rather than implying- immediate self-serve provisioning. Larger providers belong to- Enterprise/custom terms. Pulse-hosted MSP is not part of the default public- launch motion and must remain request-only until tenant isolation, ingest,- reporting, operations, and support load are proven. Design-partner discounts- do not create a public tier or change runtime limits: a qualified MSP lead- may receive assisted Growth access at the Starter price for a limited 6-12- month field-feedback window, with up to 15 client workspaces and no- self-serve checkout exposure. The MSP signup routes stay gated behind the- same `PublicCloudSignupEnabled` flag as the individual cloud signup front- door.+ versions. The canonical MSP product model is one provider account managing+ many isolated client workspaces. A client workspace is the hard monitoring+ boundary: agent credentials, ingest, dashboards, alert routes, reports,+ users, audit state, and tenant-local runtime data belong to the client+ workspace, not to a shared provider monitoring namespace. The MSP account+ portal is the provider control plane and handoff surface; it must not become+ a cross-client monitoring console or mint tenant-local agent credentials.+ Public MSP pricing covers the isolated-client MSP product model, not a+ promise that a provider-hosted stack is already self-serve. Provider-hosted+ MSP is the intended default launch direction because the MSP runs the+ control-plane/runtime stack in their own cloud or infrastructure, but it is+ gated on a packaged provider artifact that a technical MSP can actually+ operate. That artifact must deliberately remove the SaaS billing/public+ signup plane and keep only the provider essentials: client-workspace roster,+ per-client runtime provisioning, account-to-workspace handoff, provider+ access management, and workspace-bound install tokens. Pulse-hosted MSP is+ the same isolated-client workspace model operated by Pulse, but it is not+ part of the default public launch motion and must remain request-only until+ tenant isolation, ingest, reporting, operations, and support load are proven.+ The provider-hosted implementation mode is+ `CP_CONTROL_PLANE_MODE=provider_hosted_msp`. In that mode the control plane+ is Stripe-free by construction: it must not register Stripe webhook or portal+ billing routes, must reject Stripe API keys, Stripe webhook secrets, MSP+ Stripe price IDs, and public signup enablement, and must enforce the MSP+ client-workspace cap from `CP_PROVIDER_MSP_PLAN_VERSION` using the canonical+ `msp_starter`, `msp_growth`, and `msp_scale` plan versions. Provider-hosted+ portal bootstrap/accounts may have no hosted billing record, and that absence+ must remove Pulse-hosted Billing navigation, support actions, and role copy+ rather than exposing dead Billing controls.+ Shared-process multi-tenant mode (`PULSE_MULTI_TENANT_ENABLED` plus+ `FeatureMultiTenant`) remains an Enterprise/internal-organization capability;+ it is not the canonical MSP route for separate customer businesses and must+ not leak MSP terminology, controls, prompts, or setup requirements into+ ordinary self-hosted Pulse.+ The canonical provider workspace limits are 5 client workspaces for Starter,+ 15 for Growth, and 40 for Scale; the canonical public monthly prices are+ $149, $249, and $399 respectively. Public copy may publish all three prices,+ but must keep Starter as gated checkout rather than a general self-serve+ provider-hosted purchase path, and describe Growth and Scale as+ request-assisted access rather than implying immediate self-serve+ provisioning. Larger providers belong to Enterprise/custom terms.+ Design-partner discounts do not create a public tier or change runtime+ limits: a qualified MSP lead may receive assisted Growth access at the+ Starter price for a limited 6-12 month field-feedback window, with up to 15+ client workspaces and no self-serve checkout exposure. The MSP signup routes+ stay gated behind the same `PublicCloudSignupEnabled` flag as the individual+ cloud signup front door.Checkout metadata produced by the MSP front door must mark`account_kind=msp`, `signup_source=public_msp_signup`, and`checkout_billing_mode=immediate` so provisioning seeds an operator@@ -767,13 +797,15 @@ boundary: hosted Cloud/MSP checkout events may provision tenants, whileself-hosted landing purchases are acknowledged and ignored rather thancreating hosted containers or Stripe account mappings.-The hosted MSP offering now has a public self-serve front door alongside the+The Pulse-operated MSP account path has a gated public front door alongside theindividual cloud signup page. `internal/cloudcp/public_msp_signup_handlers.go`serves `/cloud/msp/signup`, `/cloud/msp/signup/complete`, and`/api/public/msp/signup`, all gated behind the same `PublicCloudSignupEnabled`flag as `/cloud/signup`, so the MSP front door stays dark until an operator-explicitly enables public signup. MSP Starter is the only tier served through-public self-serve checkout, and it is offered only when+explicitly enables public signup. This path is not the provider-hosted MSP+artifact; it is the Pulse-operated checkout/account entry point that proves the+provider-account/client-workspace model. MSP Starter is the only tier that may+be served through gated checkout, and it is offered only when`CP_MSP_STARTER_PRICE_ID` is configured. Growth, Scale, Enterprise, manualpilots, and discounts belong in request-based or operator-controlledStripe/customer-support workflows rather than the public front door. The signup@@ -781,7 +813,7 @@ page renders an explicit "Starter self-serve signup is not open yet" notice whenthe Starter price is not configured rather than offering an unbacked checkout.Checkout sessions started from this front door carry `account_kind=msp`,`signup_source=public_msp_signup`, and `checkout_billing_mode=immediate`-metadata and do not set Stripe `trial_period_days`; MSP self-serve checkout is+metadata and do not set Stripe `trial_period_days`; any opened checkout ispaid-first. The provisioner reads that billing-mode metadata so the initialStripe account mapping is stored as active instead of trial before subscriptionwebhooks catch up.diff --git a/internal/cloudcp/account/tenant_handlers.go b/internal/cloudcp/account/tenant_handlers.goindex e1cd9492ec..8da2656df9 100644--- a/internal/cloudcp/account/tenant_handlers.go+++ b/internal/cloudcp/account/tenant_handlers.go@@ -33,6 +33,11 @@ type ownerAwareWorkspaceProvisioner interface {ProvisionWorkspaceForOwner(ctx context.Context, accountID, displayName, ownerEmail string) (*registry.Tenant, error)}+type WorkspaceLimitPolicy struct {+ ProviderHostedMSP bool+ ProviderMSPPlanVersion string+}+// HandleListTenants lists all tenants for an account.// Route: GET /api/accounts/{account_id}/tenantsfunc HandleListTenants(reg *registry.TenantRegistry) http.HandlerFunc {@@ -79,6 +84,10 @@ type createTenantRequest struct {// HandleCreateTenant creates a new tenant under an account.// Route: POST /api/accounts/{account_id}/tenantsfunc HandleCreateTenant(reg *registry.TenantRegistry, provisioner WorkspaceProvisioner) http.HandlerFunc {+ return HandleCreateTenantWithWorkspaceLimitPolicy(reg, provisioner, WorkspaceLimitPolicy{})+}++func HandleCreateTenantWithWorkspaceLimitPolicy(reg *registry.TenantRegistry, provisioner WorkspaceProvisioner, workspaceLimitPolicy WorkspaceLimitPolicy) http.HandlerFunc {return func(w http.ResponseWriter, r *http.Request) {if r.Method != http.MethodPost {http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)@@ -145,7 +154,7 @@ func HandleCreateTenant(reg *registry.TenantRegistry, provisioner WorkspaceProvimu.Lock()limitErr, tenant, provisionErr := func() (*workspaceLimitError, *registry.Tenant, error) {defer mu.Unlock()- if le := enforceWorkspaceLimit(reg, a, accountID); le != nil {+ if le := enforceWorkspaceLimit(reg, a, accountID, workspaceLimitPolicy); le != nil {return le, nil, nil}ownerEmail := strings.ToLower(strings.TrimSpace(r.Header.Get("X-User-Email")))@@ -223,7 +232,7 @@ type workspaceLimitError struct {// enforceWorkspaceLimit checks whether the account is allowed to create// another workspace. Returns nil if creation is allowed, or a// workspaceLimitError if blocked.-func enforceWorkspaceLimit(reg *registry.TenantRegistry, account *registry.Account, accountID string) *workspaceLimitError {+func enforceWorkspaceLimit(reg *registry.TenantRegistry, account *registry.Account, accountID string, policy WorkspaceLimitPolicy) *workspaceLimitError {// Look up the account's Stripe billing record to determine plan version.sa, err := reg.GetStripeAccount(accountID)if err != nil {@@ -234,27 +243,48 @@ func enforceWorkspaceLimit(reg *registry.TenantRegistry, account *registry.AccoustatusCode: http.StatusInternalServerError,}}+ planVersion := ""+ usingProviderHostedPlan := falseif sa == nil {- // No Stripe account → no subscription → cannot create workspaces.- return &workspaceLimitError{- reason: "no_billing_record",- message: "account has no active subscription",- statusCode: http.StatusForbidden,+ if policy.ProviderHostedMSP && account != nil && account.Kind == registry.AccountKindMSP {+ planVersion = pkglicensing.CanonicalizePlanVersion(policy.ProviderMSPPlanVersion)+ usingProviderHostedPlan = true+ if strings.TrimSpace(planVersion) == "" {+ return &workspaceLimitError{+ reason: "provider_msp_plan_missing",+ message: "provider MSP plan is not configured",+ statusCode: http.StatusForbidden,+ }+ }+ } else {+ // No Stripe account → no subscription → cannot create workspaces.+ return &workspaceLimitError{+ reason: "no_billing_record",+ message: "account has no active subscription",+ statusCode: http.StatusForbidden,+ }}+ } else {+ // Reject workspace creation for canceled subscriptions.+ if strings.EqualFold(sa.SubscriptionState, "canceled") {+ return &workspaceLimitError{+ reason: "subscription_canceled",+ message: "cannot create workspaces on a canceled subscription",+ statusCode: http.StatusForbidden,+ }+ }+ planVersion = pkglicensing.CanonicalizePlanVersion(sa.PlanVersion)}- // Reject workspace creation for canceled subscriptions.- if strings.EqualFold(sa.SubscriptionState, "canceled") {+ // Determine workspace limit from plan version.+ limit, known := pkglicensing.WorkspaceLimitForPlan(planVersion)+ if !known && usingProviderHostedPlan {return &workspaceLimitError{- reason: "subscription_canceled",- message: "cannot create workspaces on a canceled subscription",+ reason: "provider_msp_plan_unknown",+ message: fmt.Sprintf("provider MSP plan %q has no workspace limit", planVersion),statusCode: http.StatusForbidden,}}-- // Determine workspace limit from plan version.- planVersion := pkglicensing.CanonicalizePlanVersion(sa.PlanVersion)- limit, known := pkglicensing.WorkspaceLimitForPlan(planVersion)if !known {// Unknown plan → fail-closed with safe default.limit = pkglicensing.UnknownPlanDefaultWorkspaceLimitdiff --git a/internal/cloudcp/account/tenant_handlers_test.go b/internal/cloudcp/account/tenant_handlers_test.goindex 96bdc325fb..307d623fd4 100644--- a/internal/cloudcp/account/tenant_handlers_test.go+++ b/internal/cloudcp/account/tenant_handlers_test.go@@ -24,7 +24,11 @@ import (func newTestTenantMux(t *testing.T, reg *registry.TenantRegistry, tenantsDir string) (*http.ServeMux, *cpstripe.Provisioner) {t.Helper()+ return newTestTenantMuxWithWorkspaceLimitPolicy(t, reg, tenantsDir, WorkspaceLimitPolicy{})+}+func newTestTenantMuxWithWorkspaceLimitPolicy(t *testing.T, reg *registry.TenantRegistry, tenantsDir string, policy WorkspaceLimitPolicy, opts ...cpstripe.ProvisionerOption) (*http.ServeMux, *cpstripe.Provisioner) {+ t.Helper()mux := http.NewServeMux()publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)if err != nil {@@ -42,9 +46,14 @@ func newTestTenantMux(t *testing.T, reg *registry.TenantRegistry, tenantsDir strtrue,cpstripe.WithTrialActivationPrivateKey(base64.StdEncoding.EncodeToString(privateKey)),)+ for _, opt := range opts {+ if opt != nil {+ opt(provisioner)+ }+ }listTenants := HandleListTenants(reg)- createTenant := HandleCreateTenant(reg, provisioner)+ createTenant := HandleCreateTenantWithWorkspaceLimitPolicy(reg, provisioner, policy)updateTenant := HandleUpdateTenant(reg)deleteTenant := HandleDeleteTenant(reg, provisioner)@@ -361,6 +370,55 @@ func TestCreateWorkspace_BlockedWhenNoBillingRecord(t *testing.T) {}}+func TestCreateWorkspace_ProviderHostedMSPAllowsNoBillingRecord(t *testing.T) {+ reg := newTestRegistry(t)+ tenantsDir := t.TempDir()+ mux, _ := newTestTenantMuxWithWorkspaceLimitPolicy(+ t,+ reg,+ tenantsDir,+ WorkspaceLimitPolicy{ProviderHostedMSP: true, ProviderMSPPlanVersion: "msp_growth"},+ cpstripe.WithDefaultMSPPlanVersion("msp_growth"),+ )++ accountID, err := registry.GenerateAccountID()+ if err != nil {+ t.Fatal(err)+ }+ if err := reg.CreateAccount(®istry.Account{ID: accountID, Kind: registry.AccountKindMSP, DisplayName: "Provider MSP"}); err != nil {+ t.Fatal(err)+ }+ // Deliberately NOT creating a StripeAccount: provider-hosted MSP mode uses+ // the local MSP plan as the workspace-limit source.++ body := `{"display_name":"Acme Dental"}`+ req := httptest.NewRequest(http.MethodPost, "/api/accounts/"+accountID+"/tenants", bytes.NewBufferString(body))+ rec := doRequest(t, mux, req)++ if rec.Code != http.StatusCreated {+ t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusCreated, rec.Body.String())+ }+ var got registry.Tenant+ if err := json.Unmarshal(rec.Body.Bytes(), &got); err != nil {+ t.Fatalf("decode response: %v", err)+ }+ if got.PlanVersion != "msp_growth" {+ t.Fatalf("workspace PlanVersion = %q, want msp_growth", got.PlanVersion)+ }++ store := config.NewFileBillingStore(filepath.Join(tenantsDir, got.ID))+ bs, err := store.GetBillingState("default")+ if err != nil {+ t.Fatalf("GetBillingState: %v", err)+ }+ if bs == nil {+ t.Fatal("billing state is nil")+ }+ if bs.PlanVersion != "msp_growth" {+ t.Fatalf("billing PlanVersion = %q, want msp_growth", bs.PlanVersion)+ }+}+func TestCreateWorkspace_MSPStarterLimitEnforced(t *testing.T) {reg := newTestRegistry(t)tenantsDir := t.TempDir()diff --git a/internal/cloudcp/config.go b/internal/cloudcp/config.goindex a6c38e6eb7..e1d5e8b5a0 100644--- a/internal/cloudcp/config.go+++ b/internal/cloudcp/config.go@@ -15,10 +15,20 @@ import (pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing")+// ControlPlaneMode selects the business/runtime shape exposed by cloudcp.+type ControlPlaneMode string++const (+ ControlPlaneModePulseHosted ControlPlaneMode = "pulse_hosted"+ ControlPlaneModeProviderHostedMSP ControlPlaneMode = "provider_hosted_msp"+ defaultProviderHostedMSPPlanVersion = "msp_starter"+)+// CPConfig holds all configuration for the control plane.type CPConfig struct {DataDir stringEnvironment string+ ControlPlaneMode ControlPlaneModeBindAddress stringPort intAdminKey string@@ -58,6 +68,7 @@ type CPConfig struct {CloudMSPStarterPriceID string // MSP Starter tier price ID (optional)CloudMSPGrowthPriceID string // MSP Growth tier price ID (optional)CloudMSPScalePriceID string // MSP Scale tier price ID (optional)+ ProviderMSPPlanVersion string // Local provider-hosted MSP workspace limit planLicenseServerURL stringLicenseAdminToken stringTrialActivationPrivateKey string@@ -78,6 +89,14 @@ func (c *CPConfig) ControlPlaneDir() string {return filepath.Join(c.DataDir, "control-plane")}+func (c *CPConfig) IsProviderHostedMSP() bool {+ return c != nil && c.ControlPlaneMode == ControlPlaneModeProviderHostedMSP+}++func (c *CPConfig) UsesStripeBilling() bool {+ return c != nil && !c.IsProviderHostedMSP()+}+// LoadConfig loads control plane configuration from environment variables.// A .env file is loaded if present but not required.func LoadConfig() (*CPConfig, error) {@@ -86,6 +105,7 @@ func LoadConfig() (*CPConfig, error) {dataDir := envOrDefault("CP_DATA_DIR", "/data")environment := normalizeCPEnvironment(envOrDefault("CP_ENV", "production"))+ controlPlaneMode := normalizeControlPlaneMode(envOrDefault("CP_CONTROL_PLANE_MODE", string(ControlPlaneModePulseHosted)))port, err := envOrDefaultInt("CP_PORT", 8443)if err != nil {return nil, err@@ -150,6 +170,7 @@ func LoadConfig() (*CPConfig, error) {cfg := &CPConfig{DataDir: dataDir,Environment: environment,+ ControlPlaneMode: controlPlaneMode,BindAddress: envOrDefault("CP_BIND_ADDRESS", "0.0.0.0"),Port: port,AdminKey: strings.TrimSpace(os.Getenv("CP_ADMIN_KEY")),@@ -189,6 +210,7 @@ func LoadConfig() (*CPConfig, error) {CloudMSPStarterPriceID: strings.TrimSpace(os.Getenv("CP_MSP_STARTER_PRICE_ID")),CloudMSPGrowthPriceID: strings.TrimSpace(os.Getenv("CP_MSP_GROWTH_PRICE_ID")),CloudMSPScalePriceID: strings.TrimSpace(os.Getenv("CP_MSP_SCALE_PRICE_ID")),+ ProviderMSPPlanVersion: pkglicensing.CanonicalizePlanVersion(envOrDefault("CP_PROVIDER_MSP_PLAN_VERSION", defaultProviderHostedMSPPlanVersion)),LicenseServerURL: envOrDefault("PULSE_LICENSE_SERVER_URL", "https://license.pulserelay.pro"),LicenseAdminToken: strings.TrimSpace(os.Getenv("PULSE_LICENSE_ADMIN_TOKEN")),TrialActivationPrivateKey: strings.TrimSpace(os.Getenv("CP_TRIAL_ACTIVATION_PRIVATE_KEY")),@@ -231,7 +253,7 @@ func (c *CPConfig) validate() error {if c.BaseURL == "" {missing = append(missing, "CP_BASE_URL")}- if c.StripeWebhookSecret == "" {+ if c.UsesStripeBilling() && c.StripeWebhookSecret == "" {missing = append(missing, "STRIPE_WEBHOOK_SECRET")}if len(missing) > 0 {@@ -274,9 +296,35 @@ func (c *CPConfig) validate() error {if c.Environment != "development" && c.Environment != "staging" && c.Environment != "production" {return fmt.Errorf("CP_ENV must be one of development, staging, production (got %q)", c.Environment)}+ if c.ControlPlaneMode != ControlPlaneModePulseHosted && c.ControlPlaneMode != ControlPlaneModeProviderHostedMSP {+ return fmt.Errorf("CP_CONTROL_PLANE_MODE must be one of %s, %s (got %q)", ControlPlaneModePulseHosted, ControlPlaneModeProviderHostedMSP, c.ControlPlaneMode)+ }if c.Environment == "production" && c.AllowDockerlessProvisioning {return fmt.Errorf("CP_ALLOW_DOCKERLESS_PROVISIONING must be false in production")}+ if c.IsProviderHostedMSP() {+ if strings.TrimSpace(c.StripeWebhookSecret) != "" {+ return fmt.Errorf("STRIPE_WEBHOOK_SECRET must not be configured when CP_CONTROL_PLANE_MODE=%s", ControlPlaneModeProviderHostedMSP)+ }+ if strings.TrimSpace(c.StripeAPIKey) != "" {+ return fmt.Errorf("STRIPE_API_KEY must not be configured when CP_CONTROL_PLANE_MODE=%s", ControlPlaneModeProviderHostedMSP)+ }+ if c.PublicCloudSignupEnabled {+ return fmt.Errorf("CP_PUBLIC_CLOUD_SIGNUP_ENABLED must be false when CP_CONTROL_PLANE_MODE=%s", ControlPlaneModeProviderHostedMSP)+ }+ if strings.TrimSpace(c.CloudMSPStarterPriceID) != "" || strings.TrimSpace(c.CloudMSPGrowthPriceID) != "" || strings.TrimSpace(c.CloudMSPScalePriceID) != "" {+ return fmt.Errorf("CP_MSP_*_PRICE_ID must not be configured when CP_CONTROL_PLANE_MODE=%s", ControlPlaneModeProviderHostedMSP)+ }+ if strings.TrimSpace(c.TrialActivationPrivateKey) == "" {+ return fmt.Errorf("CP_TRIAL_ACTIVATION_PRIVATE_KEY is required when CP_CONTROL_PLANE_MODE=%s", ControlPlaneModeProviderHostedMSP)+ }+ if !strings.HasPrefix(strings.ToLower(c.ProviderMSPPlanVersion), "msp_") {+ return fmt.Errorf("CP_PROVIDER_MSP_PLAN_VERSION must be a canonical MSP plan version, got %q", c.ProviderMSPPlanVersion)+ }+ if _, known := pkglicensing.WorkspaceLimitForPlan(c.ProviderMSPPlanVersion); !known {+ return fmt.Errorf("CP_PROVIDER_MSP_PLAN_VERSION must have a known workspace limit, got %q", c.ProviderMSPPlanVersion)+ }+ }if c.StorageGuardrailsEnabled {if strings.TrimSpace(c.StorageRootPath) == "" {return fmt.Errorf("CP_STORAGE_ROOT_PATH is required when CP_STORAGE_GUARDRAILS_ENABLED=true")@@ -402,6 +450,17 @@ func normalizeCPEnvironment(raw string) string {}}+func normalizeControlPlaneMode(raw string) ControlPlaneMode {+ switch strings.ToLower(strings.TrimSpace(raw)) {+ case "", "pulse_hosted", "pulse-hosted", "pulse_cloud", "pulse-cloud", "cloud":+ return ControlPlaneModePulseHosted+ case "provider_hosted_msp", "provider-hosted-msp", "provider_msp", "provider-msp", "msp_provider", "msp-provider":+ return ControlPlaneModeProviderHostedMSP+ default:+ return ControlPlaneMode(strings.ToLower(strings.TrimSpace(raw)))+ }+}+func stripeSecretKeyMode(raw string) string {key := strings.TrimSpace(raw)switch {diff --git a/internal/cloudcp/config_test.go b/internal/cloudcp/config_test.goindex fc84b96551..11cfe94caa 100644--- a/internal/cloudcp/config_test.go+++ b/internal/cloudcp/config_test.go@@ -443,6 +443,102 @@ func TestLoadConfig_AllowsMissingTrialSignupPriceWhenPublicCloudSignupDisabled(t}}+func setProviderHostedMSPEnv(t *testing.T) {+ t.Helper()+ t.Setenv("CP_ADMIN_KEY", "test-key")+ t.Setenv("CP_BASE_URL", "https://msp.example.com")+ t.Setenv("CP_ENV", "development")+ t.Setenv("CP_CONTROL_PLANE_MODE", "provider_hosted_msp")+ t.Setenv("CP_REQUIRE_EMAIL_PROVIDER", "false")+ t.Setenv("STRIPE_WEBHOOK_SECRET", "")+ t.Setenv("STRIPE_API_KEY", "")+ t.Setenv("CP_PUBLIC_CLOUD_SIGNUP_ENABLED", "false")+ t.Setenv("CP_MSP_STARTER_PRICE_ID", "")+ t.Setenv("CP_MSP_GROWTH_PRICE_ID", "")+ t.Setenv("CP_MSP_SCALE_PRICE_ID", "")+ setTrialSigningEnv(t)+}++func TestLoadConfig_ProviderHostedMSPDoesNotRequireStripe(t *testing.T) {+ setProviderHostedMSPEnv(t)++ cfg, err := LoadConfig()+ if err != nil {+ t.Fatalf("LoadConfig: %v", err)+ }+ if cfg.ControlPlaneMode != ControlPlaneModeProviderHostedMSP {+ t.Fatalf("ControlPlaneMode = %q, want %q", cfg.ControlPlaneMode, ControlPlaneModeProviderHostedMSP)+ }+ if cfg.UsesStripeBilling() {+ t.Fatal("UsesStripeBilling = true, want false")+ }+ if cfg.ProviderMSPPlanVersion != "msp_starter" {+ t.Fatalf("ProviderMSPPlanVersion = %q, want msp_starter", cfg.ProviderMSPPlanVersion)+ }+}++func TestLoadConfig_ProviderHostedMSPRejectsStripeConfig(t *testing.T) {+ for _, tc := range []struct {+ name string+ key string+ val string+ }{+ {name: "webhook_secret", key: "STRIPE_WEBHOOK_SECRET", val: "whsec_test"},+ {name: "api_key", key: "STRIPE_API_KEY", val: "sk_test_123"},+ {name: "msp_price", key: "CP_MSP_STARTER_PRICE_ID", val: "price_1T5kgTBrHBocJIGHjOs15LI2"},+ } {+ t.Run(tc.name, func(t *testing.T) {+ setProviderHostedMSPEnv(t)+ t.Setenv(tc.key, tc.val)++ _, err := LoadConfig()+ if err == nil {+ t.Fatalf("expected error when %s is configured", tc.key)+ }+ if !strings.Contains(err.Error(), "must not be configured") {+ t.Fatalf("unexpected error: %v", err)+ }+ })+ }+}++func TestLoadConfig_ProviderHostedMSPRejectsPublicSignup(t *testing.T) {+ setProviderHostedMSPEnv(t)+ t.Setenv("CP_PUBLIC_CLOUD_SIGNUP_ENABLED", "true")++ _, err := LoadConfig()+ if err == nil {+ t.Fatal("expected error when public signup is enabled in provider-hosted MSP mode")+ }+ if !strings.Contains(err.Error(), "CP_PUBLIC_CLOUD_SIGNUP_ENABLED must be false") {+ t.Fatalf("unexpected error: %v", err)+ }+}++func TestLoadConfig_ProviderHostedMSPRejectsInvalidPlan(t *testing.T) {+ for _, tc := range []struct {+ name string+ plan string+ want string+ }{+ {name: "non_msp", plan: "cloud_starter", want: "canonical MSP plan"},+ {name: "unknown_msp", plan: "msp_unknown", want: "known workspace limit"},+ } {+ t.Run(tc.name, func(t *testing.T) {+ setProviderHostedMSPEnv(t)+ t.Setenv("CP_PROVIDER_MSP_PLAN_VERSION", tc.plan)++ _, err := LoadConfig()+ if err == nil {+ t.Fatalf("expected error for CP_PROVIDER_MSP_PLAN_VERSION=%q", tc.plan)+ }+ if !strings.Contains(err.Error(), tc.want) {+ t.Fatalf("unexpected error: %v", err)+ }+ })+ }+}+func TestLoadConfig_RequiresTrialSignupPriceWhenPublicCloudSignupEnabled(t *testing.T) {setRequiredCPEnv(t)setTrialSigningEnv(t)diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.jsonindex c8bb345878..efc9a72b50 100644--- a/internal/cloudcp/portal/dist/build_manifest.json+++ b/internal/cloudcp/portal/dist/build_manifest.json@@ -1,5 +1,5 @@{- "source_hash": "dc3aa37a68d30708d2f82b9da0da70470a2b2b3611223a477becaaf4aa2db381",+ "source_hash": "bfcf712f4cd6abf9afa7c37c920c53fc8456b8143eff121c3f75e800e5ab378e","build_inputs": ["package.json","tsconfig.json",diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.jsindex 1cae20c1a3..145b297e7b 100644--- a/internal/cloudcp/portal/dist/portal_app.js+++ b/internal/cloudcp/portal/dist/portal_app.js@@ -20,13 +20,22 @@return role || "Member";}}- function portalRoleCapabilityCopy(role, clientLanguage = false) {+ function portalRoleCapabilityCopy(role, clientLanguage = false, hasBilling = true) {switch (normalizePortalRole(role)) {case "owner":+ if (!hasBilling) {+ return clientLanguage ? "Full account control, including access control and client control." : "Full account control, including access control and workspace control.";+ }return clientLanguage ? "Full account control, including billing, access control, and client control." : "Full account control, including billing, access control, and workspace control.";case "admin":+ if (!hasBilling) {+ return clientLanguage ? "Can manage clients and account access." : "Can manage workspaces and account access.";+ }return clientLanguage ? "Can manage clients and billing for this account." : "Can manage workspaces and billing for this account.";case "tech":+ if (!hasBilling) {+ return clientLanguage ? "Can manage clients without access ownership." : "Can manage workspaces without access ownership.";+ }return clientLanguage ? "Can manage clients without billing ownership." : "Can manage workspaces without billing ownership.";case "read_only":return clientLanguage ? "Can review client status without making control-plane changes." : "Can review workspace status without making control-plane changes.";@@ -133,7 +142,7 @@case "ready":return "Open the workspace when you need to work inside this client boundary.";case "install_agents":- return "Install the first agent from this workspace so client data lands in the right boundary.";+ return "Install the first agent from this workspace so client data lands in the isolated workspace boundary.";case "configure_outputs":return "Configure alert routing and reports before treating the client workspace as ready.";case "review":@@ -143,7 +152,7 @@}}function workspaceIdentityCopy(workspace) {- return "Client boundary: " + workspace.display_name + ". Hostnames can repeat across clients; this workspace keeps agents, alerts, and reports scoped to this client.";+ return "Client workspace boundary: " + workspace.display_name + ". Hostnames can repeat across clients because agents, alerts, and reports stay scoped to this workspace.";}function workspaceSetupDiagnostics(workspace) {var setup = workspaceSetupState(workspace);@@ -204,7 +213,7 @@if (setup === "install_agents") {return {title: "Install the first agent",- description: "Start inside this client workspace so the first reporting token and future hostnames stay scoped to the client.",+ description: "Start inside this isolated client workspace so the first reporting token and future hostnames stay scoped to the client.",primaryAction: "install",primaryLabel: "Install agents",diagnostics: workspaceSetupDiagnostics(workspace)@@ -629,7 +638,7 @@group.appendChild(btn);return group;}- function renderAccessMemberRow(accountID, member, isOwner, canManage, activeJob, clientLanguage) {+ function renderAccessMemberRow(accountID, member, isOwner, canManage, activeJob, clientLanguage, hasBilling) {var showActionColumn = canManage && activeJob === "remove";var row = document.createElement("div");row.className = "access-member-row" + (showActionColumn ? "" : " access-member-row-readonly");@@ -654,7 +663,7 @@identity.appendChild(topline);var caption = document.createElement("div");caption.className = "access-member-caption";- caption.textContent = (member.state || "active") === "pending" ? "Invitation pending acceptance." : portalRoleCapabilityCopy(member.role, clientLanguage);+ caption.textContent = (member.state || "active") === "pending" ? "Invitation pending acceptance." : portalRoleCapabilityCopy(member.role, clientLanguage, hasBilling);identity.appendChild(caption);row.appendChild(identity);row.appendChild(renderAccessRoleControl(accountID, member, isOwner, canManage, activeJob));@@ -680,7 +689,7 @@spinner.hidden = !entry.createWorkspace.pending;}}- function renderAccessSection(accountID, entry) {+ function renderAccessSection(accountID, entry, hasBilling = true) {var section = getElement("access-section-" + accountID);var roster = getElement("access-list-" + accountID);if (!section || !roster) return;@@ -750,7 +759,7 @@renderAccessRosterHead(roster, activeJob, canManage);for (var i = 0; i < entry.accessQuery.data.length; i += 1) {var member = entry.accessQuery.data[i];- roster.appendChild(renderAccessMemberRow(accountID, member, isOwner, canManage, activeJob, clientLanguage));+ roster.appendChild(renderAccessMemberRow(accountID, member, isOwner, canManage, activeJob, clientLanguage, hasBilling));}}function renderAccountUI(accountState, accounts, accountAPIBasePath = "") {@@ -767,7 +776,7 @@}renderAddWorkspaceSection(accountID, entry);if (account) renderWorkspaceManagement(account, entry, accountAPIBasePath);- renderAccessSection(accountID, entry);+ renderAccessSection(accountID, entry, account ? account.has_billing === true : true);}}@@ -2598,17 +2607,28 @@function setupNeededWorkspaceChipLabel(count, clientLanguage = false) {return count === 1 ? "1 " + workspaceEntityName(clientLanguage) + " in setup" : String(count) + " " + workspaceEntityName(clientLanguage, true) + " in setup";}- function supportRunbookPathCopy(hasHostedAccounts2, hostedViewOnly, showSelfHostedCommercial, clientLanguage = false) {+ function supportRunbookPathCopy(hasHostedAccounts2, hostedViewOnly, showSelfHostedCommercial, hasHostedBilling, clientLanguage = false) {var primarySection = clientLanguage ? "Clients" : "Workspaces";if (!hasHostedAccounts2) return "Billing, licenses, refunds, or privacy.";if (hostedViewOnly) {- return showSelfHostedCommercial ? primarySection + ", Access review, owner/admin handoff, hosted billing, licenses, refunds, or privacy." : primarySection + ", Access review, owner/admin handoff, or hosted billing.";+ if (showSelfHostedCommercial && hasHostedBilling) return primarySection + ", Access review, owner/admin handoff, hosted billing, licenses, refunds, or privacy.";+ if (showSelfHostedCommercial) return primarySection + ", Access review, owner/admin handoff, licenses, refunds, or privacy.";+ if (hasHostedBilling) return primarySection + ", Access review, owner/admin handoff, or hosted billing.";+ return primarySection + ", Access review, or owner/admin handoff.";}- return showSelfHostedCommercial ? primarySection + ", Access, hosted billing, licenses, refunds, or privacy." : primarySection + ", Access, or hosted billing.";+ if (showSelfHostedCommercial && hasHostedBilling) return primarySection + ", Access, hosted billing, licenses, refunds, or privacy.";+ if (showSelfHostedCommercial) return primarySection + ", Access, licenses, refunds, or privacy.";+ if (hasHostedBilling) return primarySection + ", Access, or hosted billing.";+ return primarySection + " or Access.";}function hasHostedAccounts(accounts) {return accounts.length > 0;}+ function hasHostedBillingAccounts(accounts) {+ return accounts.some(function(account) {+ return account.has_billing === true;+ });+ }function hasSelfHostedCommercial(bootstrap) {var accounts = Array.isArray(bootstrap.accounts) ? bootstrap.accounts : [];return bootstrap.has_self_hosted_commercial === true || !hasHostedAccounts(accounts);@@ -2738,18 +2758,13 @@var accounts = Array.isArray(bootstrap.accounts) ? bootstrap.accounts : [];var hosted = hasHostedAccounts(accounts);var showSelfHostedCommercial = hasSelfHostedCommercial(bootstrap);- var hostedBillingCount = 0;- for (var i = 0; i < accounts.length; i += 1) {- if (accounts[i].has_billing) {- hostedBillingCount += 1;- }- }+ var hasHostedBilling = hasHostedBillingAccounts(accounts);var sections = [];if (hosted) {sections.push({ section: "workspaces", title: accountsUseClientLanguage(accounts) ? "Clients" : "Workspaces" });sections.push({ section: "access", title: "Access" });}- if (hostedBillingCount > 0 || showSelfHostedCommercial) {+ if (hasHostedBilling || showSelfHostedCommercial) {sections.push({ section: "billing", title: "Billing" });}return sections;@@ -3044,7 +3059,7 @@});if (!templateAccount || !templateAccount.setup_templates || !templateAccount.setup_templates.length) return "";var template = templateAccount.setup_templates[0];- return '<section class="workspace-template-panel" aria-label="Provider setup template"><details class="workspace-template-details"><summary class="workspace-template-summary"><span class="workspace-template-summary-title">' + escapeHTML(template.title || "Provider setup template") + '</span><span class="workspace-template-summary-meta">' + escapeHTML(templateAccount.name) + '</span></summary><p class="workspace-template-intro">Use the same onboarding shape for each client, then finish the tenant-owned configuration inside that client workspace.</p><div class="workspace-template-grid"><div><strong>Agent naming</strong><span>' + escapeHTML(template.agent_naming) + "</span></div><div><strong>Alert routing</strong><span>" + escapeHTML(template.alert_routing) + "</span></div><div><strong>Reports</strong><span>" + escapeHTML(template.reporting) + "</span></div><div><strong>Access</strong><span>" + escapeHTML(template.access) + "</span></div></div></details></section>";+ return '<section class="workspace-template-panel" aria-label="Provider setup template"><details class="workspace-template-details"><summary class="workspace-template-summary"><span class="workspace-template-summary-title">' + escapeHTML(template.title || "Provider setup template") + '</span><span class="workspace-template-summary-meta">' + escapeHTML(templateAccount.name) + '</span></summary><p class="workspace-template-intro">Use the same onboarding shape for each client, then finish the workspace-owned configuration inside that isolated client boundary.</p><div class="workspace-template-grid"><div><strong>Agent naming</strong><span>' + escapeHTML(template.agent_naming) + "</span></div><div><strong>Alert routing</strong><span>" + escapeHTML(template.alert_routing) + "</span></div><div><strong>Reports</strong><span>" + escapeHTML(template.reporting) + "</span></div><div><strong>Access</strong><span>" + escapeHTML(template.access) + "</span></div></div></details></section>";}function renderWorkspaceSetupQueue(entries, accountAPIBasePath, clientLanguage = false) {var setupNeeded = setupNeededWorkspaceEntries(entries);@@ -3068,7 +3083,7 @@if (!canManageAnyWorkspace) {return clientLanguage ? "Review client health here and open ready clients. An owner or admin must handle onboarding and client changes." : "Review hosted workspace health here and open ready workspaces. An owner or admin must handle setup and workspace changes.";}- return clientLanguage ? "Review clients here, use Client onboarding for setup, and keep destructive client actions separate from daily monitoring." : "Review client workspaces here, use the setup checklist for onboarding, and keep destructive workspace actions separate from daily workspace work.";+ return clientLanguage ? "Review clients here, use Client onboarding for setup, and keep destructive client actions separate from daily monitoring. Each client remains an isolated workspace." : "Review client workspaces here, use the setup checklist for onboarding, and keep destructive workspace actions separate from daily workspace work.";}function renderWorkspaceSummarySection(context) {var accounts = Array.isArray(context.bootstrap.accounts) ? context.bootstrap.accounts : [];@@ -3096,7 +3111,8 @@var readyCount = countReadyWorkspaces(workspaces);var attentionCount = attentionWorkspaces(workspaces).length;var suspendedCount = countWorkspacesByState(workspaces, "suspended");- var workspaceListSummary = account.can_manage ? clientLanguage ? "Open a client to work inside its workspace boundary, or use Client onboarding to finish setup." : "Open a workspace to work in it, or use Setup checklist when onboarding a client." : "Open a workspace here. An owner or admin must create or change hosted workspaces.";+ var workspaceListSummary = account.can_manage ? clientLanguage ? "Open a client to work inside its isolated workspace boundary, or use Client onboarding to finish setup." : "Open a workspace to work in it, or use Setup checklist when onboarding a client." : "Open a workspace here. An owner or admin must create or change hosted workspaces.";+ var workspaceManagementEmptyNote = account.has_billing ? "Access changes stay in Access. Billing changes stay in Billing." : clientLanguage ? "Access changes stay in Access. Client runtime changes stay inside the client workspace." : "Access changes stay in Access. Workspace runtime changes stay inside the workspace.";var workspaceManagement = "";var addWorkspaceForm = "";var workspaceHeaderActions = "";@@ -3107,7 +3123,7 @@if (account.kind === "msp") {addWorkspaceForm = '<div class="add-workspace-form" id="add-ws-form-' + escapeAttr(account.id) + '"><label for="ws-name-' + escapeAttr(account.id) + '">' + escapeHTML(clientLanguage ? "Client name" : "Workspace name (for example, a client name)") + '</label><input type="text" id="ws-name-' + escapeAttr(account.id) + '" placeholder="Acme Corp" maxlength="80" autocomplete="off"><div class="form-actions"><button type="button" class="btn-primary" data-action="create-workspace" data-account-id="' + escapeAttr(account.id) + '">' + escapeHTML(addEntityLabel) + '</button><button type="button" class="btn-secondary" data-action="toggle-add-workspace" data-account-id="' + escapeAttr(account.id) + '">Cancel</button><div class="spinner" id="ws-spinner-' + escapeAttr(account.id) + '" hidden></div></div></div>';}- workspaceManagement = '<section class="workspace-management-panel workspace-management-panel-idle" id="workspace-management-' + escapeAttr(account.id) + '" hidden><div class="workspace-management-header"><div><h3>' + escapeHTML(onboardingLabel) + "</h3><p>" + escapeHTML(clientLanguage ? "Finish setup while each client keeps a separate workspace boundary." : "Finish the client setup steps without mixing client data across workspaces.") + '</p></div><button type="button" class="btn-secondary btn-compact" id="workspace-management-close-' + escapeAttr(account.id) + '" data-action="clear-workspace-selection" data-account-id="' + escapeAttr(account.id) + '">Close panel</button></div><div class="workspace-management-empty" id="workspace-management-empty-' + escapeAttr(account.id) + '"><div class="workspace-management-empty-shell"><div class="workspace-management-empty-actions-card"><div class="workspace-management-empty-actions-copy"><h4>' + escapeHTML(clientLanguage ? "Add a client" : "Create a workspace") + "</h4><p>" + escapeHTML(clientLanguage ? "Create the hosted workspace boundary for a customer." : "Add a new hosted workspace for a customer or operating boundary.") + "</p></div>" + addWorkspaceForm + '</div><div class="workspace-management-empty-note">Access changes stay in Access. Billing changes stay in Billing.</div></div></div><div class="workspace-management-content" id="workspace-management-content-' + escapeAttr(account.id) + '" hidden><div class="workspace-management-meta" id="workspace-management-meta-' + escapeAttr(account.id) + '"></div><h4 id="workspace-management-title-' + escapeAttr(account.id) + '"></h4><p class="workspace-management-summary" id="workspace-management-summary-' + escapeAttr(account.id) + '"></p><div class="workspace-management-facts"><div class="workspace-management-fact"><span>Health</span><strong id="workspace-management-health-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Setup</span><strong id="workspace-management-setup-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Agents</span><strong id="workspace-management-agents-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Alert routes</span><strong id="workspace-management-alerts-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Report schedules</span><strong id="workspace-management-reports-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Created</span><strong id="workspace-management-created-' + escapeAttr(account.id) + '"></strong></div></div><div class="workspace-management-guidance" id="workspace-management-guidance-' + escapeAttr(account.id) + '"></div><div class="workspace-management-identity" id="workspace-management-identity-' + escapeAttr(account.id) + '"></div><div class="workspace-setup-guide" aria-label="' + escapeAttr(clientLanguage ? "Guided client onboarding" : "Guided workspace setup") + '"><div class="workspace-setup-guide-copy"><span>Current step</span><h4 id="workspace-management-guide-title-' + escapeAttr(account.id) + '"></h4><p id="workspace-management-guide-description-' + escapeAttr(account.id) + '"></p><ul id="workspace-management-guide-diagnostics-' + escapeAttr(account.id) + '"></ul></div><form method="POST" id="workspace-management-primary-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-primary btn-compact" id="workspace-management-primary-' + escapeAttr(account.id) + '">Continue setup</button></form></div><div class="workspace-setup-checklist" aria-label="' + escapeAttr(clientLanguage ? "Client onboarding checklist" : "Workspace setup checklist") + '"><div class="workspace-setup-step workspace-setup-step-created"><span class="workspace-setup-status" id="workspace-management-check-created-' + escapeAttr(account.id) + '"></span><div><strong>' + escapeHTML(clientLanguage ? "Client added" : "Workspace created") + "</strong><span>" + escapeHTML(clientLanguage ? "A separate workspace boundary keeps this client isolated." : "This client has a separate account boundary.") + '</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-install-' + escapeAttr(account.id) + '"></span><div><strong>Install the first agent</strong><span>Use the workspace-bound install path so data lands in this client.</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-alerts-' + escapeAttr(account.id) + '"></span><div><strong>Configure alert routes</strong><span>Keep notifications scoped to this client.</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-reports-' + escapeAttr(account.id) + '"></span><div><strong>Schedule reports</strong><span>Send client performance reports from this workspace.</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-access-' + escapeAttr(account.id) + '"></span><div><strong>Review access</strong><span>Invite provider staff or client users from Access.</span></div></div></div><div class="workspace-management-next-steps" id="workspace-management-next-steps-' + escapeAttr(account.id) + '"><div class="workspace-next-step"><div><strong>' + escapeHTML(openEntityLabel) + "</strong><span>" + escapeHTML(clientLanguage ? "Work inside this client workspace boundary." : "Work inside this client boundary.") + '</span></div><form method="POST" id="workspace-management-open-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-primary btn-compact" id="workspace-management-open-' + escapeAttr(account.id) + '">' + escapeHTML(openEntityLabel) + '</button></form></div><div class="workspace-next-step"><div><strong>Install agents</strong><span>Open the workspace-bound install commands.</span></div><form method="POST" id="workspace-management-install-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-secondary btn-compact" id="workspace-management-install-' + escapeAttr(account.id) + '">Install agents</button></form></div><div class="workspace-next-step workspace-next-step-readonly"><div><strong>Alerts and reports</strong><span>Alerts and performance reports stay inside the client workspace.</span></div><form method="POST" id="workspace-management-reporting-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-secondary btn-compact" id="workspace-management-reporting-' + escapeAttr(account.id) + '">Open reports</button></form></div><div class="workspace-next-step workspace-next-step-readonly"><div><strong>Access</strong><span>Invite people or adjust roles from the account access boundary.</span></div><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Open Access</button></div></div><div class="workspace-management-actions"><button type="button" class="btn-danger" id="workspace-management-action-' + escapeAttr(account.id) + '" data-action="workspace-action" data-account-id="' + escapeAttr(account.id) + '">' + escapeHTML(clientLanguage ? "Manage client" : "Manage workspace") + "</button></div></div></section>";+ workspaceManagement = '<section class="workspace-management-panel workspace-management-panel-idle" id="workspace-management-' + escapeAttr(account.id) + '" hidden><div class="workspace-management-header"><div><h3>' + escapeHTML(onboardingLabel) + "</h3><p>" + escapeHTML(clientLanguage ? "Finish setup while each client keeps a separate workspace boundary." : "Finish the client setup steps without mixing client data across workspaces.") + '</p></div><button type="button" class="btn-secondary btn-compact" id="workspace-management-close-' + escapeAttr(account.id) + '" data-action="clear-workspace-selection" data-account-id="' + escapeAttr(account.id) + '">Close panel</button></div><div class="workspace-management-empty" id="workspace-management-empty-' + escapeAttr(account.id) + '"><div class="workspace-management-empty-shell"><div class="workspace-management-empty-actions-card"><div class="workspace-management-empty-actions-copy"><h4>' + escapeHTML(clientLanguage ? "Add a client" : "Create a workspace") + "</h4><p>" + escapeHTML(clientLanguage ? "Create an isolated client workspace for a customer." : "Add a new hosted workspace for a customer or operating boundary.") + "</p></div>" + addWorkspaceForm + '</div><div class="workspace-management-empty-note">' + escapeHTML(workspaceManagementEmptyNote) + '</div></div></div><div class="workspace-management-content" id="workspace-management-content-' + escapeAttr(account.id) + '" hidden><div class="workspace-management-meta" id="workspace-management-meta-' + escapeAttr(account.id) + '"></div><h4 id="workspace-management-title-' + escapeAttr(account.id) + '"></h4><p class="workspace-management-summary" id="workspace-management-summary-' + escapeAttr(account.id) + '"></p><div class="workspace-management-facts"><div class="workspace-management-fact"><span>Health</span><strong id="workspace-management-health-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Setup</span><strong id="workspace-management-setup-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Agents</span><strong id="workspace-management-agents-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Alert routes</span><strong id="workspace-management-alerts-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Report schedules</span><strong id="workspace-management-reports-' + escapeAttr(account.id) + '"></strong></div><div class="workspace-management-fact"><span>Created</span><strong id="workspace-management-created-' + escapeAttr(account.id) + '"></strong></div></div><div class="workspace-management-guidance" id="workspace-management-guidance-' + escapeAttr(account.id) + '"></div><div class="workspace-management-identity" id="workspace-management-identity-' + escapeAttr(account.id) + '"></div><div class="workspace-setup-guide" aria-label="' + escapeAttr(clientLanguage ? "Guided client onboarding" : "Guided workspace setup") + '"><div class="workspace-setup-guide-copy"><span>Current step</span><h4 id="workspace-management-guide-title-' + escapeAttr(account.id) + '"></h4><p id="workspace-management-guide-description-' + escapeAttr(account.id) + '"></p><ul id="workspace-management-guide-diagnostics-' + escapeAttr(account.id) + '"></ul></div><form method="POST" id="workspace-management-primary-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-primary btn-compact" id="workspace-management-primary-' + escapeAttr(account.id) + '">Continue setup</button></form></div><div class="workspace-setup-checklist" aria-label="' + escapeAttr(clientLanguage ? "Client onboarding checklist" : "Workspace setup checklist") + '"><div class="workspace-setup-step workspace-setup-step-created"><span class="workspace-setup-status" id="workspace-management-check-created-' + escapeAttr(account.id) + '"></span><div><strong>' + escapeHTML(clientLanguage ? "Client added" : "Workspace created") + "</strong><span>" + escapeHTML(clientLanguage ? "A separate workspace boundary keeps this client isolated." : "This client has a separate workspace boundary.") + '</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-install-' + escapeAttr(account.id) + '"></span><div><strong>Install the first agent</strong><span>Use the workspace-bound install path so data lands in this client.</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-alerts-' + escapeAttr(account.id) + '"></span><div><strong>Configure alert routes</strong><span>Keep notifications scoped to this client.</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-reports-' + escapeAttr(account.id) + '"></span><div><strong>Schedule reports</strong><span>Send client performance reports from this workspace.</span></div></div><div class="workspace-setup-step"><span class="workspace-setup-status" id="workspace-management-check-access-' + escapeAttr(account.id) + '"></span><div><strong>Review access</strong><span>Invite provider staff or client users from Access.</span></div></div></div><div class="workspace-management-next-steps" id="workspace-management-next-steps-' + escapeAttr(account.id) + '"><div class="workspace-next-step"><div><strong>' + escapeHTML(openEntityLabel) + "</strong><span>" + escapeHTML(clientLanguage ? "Work inside this client workspace boundary." : "Work inside this client boundary.") + '</span></div><form method="POST" id="workspace-management-open-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-primary btn-compact" id="workspace-management-open-' + escapeAttr(account.id) + '">' + escapeHTML(openEntityLabel) + '</button></form></div><div class="workspace-next-step"><div><strong>Install agents</strong><span>Open the workspace-bound install commands.</span></div><form method="POST" id="workspace-management-install-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-secondary btn-compact" id="workspace-management-install-' + escapeAttr(account.id) + '">Install agents</button></form></div><div class="workspace-next-step workspace-next-step-readonly"><div><strong>Alerts and reports</strong><span>Alerts and performance reports stay inside the client workspace.</span></div><form method="POST" id="workspace-management-reporting-form-' + escapeAttr(account.id) + '"><button type="submit" class="btn-secondary btn-compact" id="workspace-management-reporting-' + escapeAttr(account.id) + '">Open reports</button></form></div><div class="workspace-next-step workspace-next-step-readonly"><div><strong>Access</strong><span>Invite people or adjust roles from the account access boundary.</span></div><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Open Access</button></div></div><div class="workspace-management-actions"><button type="button" class="btn-danger" id="workspace-management-action-' + escapeAttr(account.id) + '" data-action="workspace-action" data-account-id="' + escapeAttr(account.id) + '">' + escapeHTML(clientLanguage ? "Manage client" : "Manage workspace") + "</button></div></div></section>";}var workspaceHTML = workspaces.length ? '<div class="workspace-list-wrap" id="' + escapeAttr(workspaceListAnchorID(account.id)) + '">' + (workspaceHeaderActions ? '<div class="workspace-list-toolbar">' + workspaceHeaderActions + "</div>" : "") + '<div class="workspace-list-head"><span>' + escapeHTML(clientLanguage ? "Client" : "Workspace") + '</span><span>Setup</span><span>Health</span><span>Actions</span></div><div class="workspace-list">' + workspaces.map(function(workspace) {return renderWorkspaceCard(account, workspace, accountAPIBasePath);@@ -3118,13 +3134,14 @@}function renderAccountAccessSection(account) {var clientLanguage = accountUsesClientLanguage(account);+ var hasBilling = account.has_billing === true;var accessRoleCopy = {- admin: clientLanguage ? "Client control, billing, and roster management." : "Workspace control, billing, and roster management.",- tech: clientLanguage ? "Client control without billing or roster ownership." : "Workspace control without billing or roster ownership.",+ admin: hasBilling ? clientLanguage ? "Client control, billing, and roster management." : "Workspace control, billing, and roster management." : clientLanguage ? "Client control and roster management." : "Workspace control and roster management.",+ tech: hasBilling ? clientLanguage ? "Client control without billing or roster ownership." : "Workspace control without billing or roster ownership." : clientLanguage ? "Client control without roster ownership." : "Workspace control without roster ownership.",readOnly: clientLanguage ? "Review client status without control-plane changes." : "Review access without control-plane changes."};var accessTaskStrip = account.can_manage ? '<div class="access-task-strip"><button type="button" class="access-task-button" id="access-task-invite-' + escapeAttr(account.id) + '" data-action="set-access-job" data-account-id="' + escapeAttr(account.id) + '" data-access-job="invite">Invite people</button><button type="button" class="access-task-button" id="access-task-change_role-' + escapeAttr(account.id) + '" data-action="set-access-job" data-account-id="' + escapeAttr(account.id) + '" data-access-job="change_role">Change roles</button><button type="button" class="access-task-button" id="access-task-remove-' + escapeAttr(account.id) + '" data-action="set-access-job" data-account-id="' + escapeAttr(account.id) + '" data-access-job="remove">Remove access</button></div>' : renderSectionContextChips(["View roster", "Owner or admin required"]);- var accessRoleGuide = '<div class="access-policy-panel"><div class="access-panel-heading"><h4>' + (account.can_manage ? "Choose the smallest role" : "Role meanings") + "</h4><p>" + (account.can_manage ? "Match each person to the narrowest role that still lets them do the job they own." : "Use these role meanings to understand what each person on this roster can do.") + '</p></div><div class="access-policy-list"><div class="access-policy-row"><strong>Owner</strong><span>Full account, billing, and access control.</span></div><div class="access-policy-row"><strong>Admin</strong><span>' + escapeHTML(accessRoleCopy.admin) + '</span></div><div class="access-policy-row"><strong>Tech</strong><span>' + escapeHTML(accessRoleCopy.tech) + '</span></div><div class="access-policy-row"><strong>Read-only</strong><span>' + escapeHTML(accessRoleCopy.readOnly) + "</span></div></div></div>";+ var accessRoleGuide = '<div class="access-policy-panel"><div class="access-panel-heading"><h4>' + (account.can_manage ? "Choose the smallest role" : "Role meanings") + "</h4><p>" + (account.can_manage ? "Match each person to the narrowest role that still lets them do the job they own." : "Use these role meanings to understand what each person on this roster can do.") + '</p></div><div class="access-policy-list"><div class="access-policy-row"><strong>Owner</strong><span>' + escapeHTML(hasBilling ? "Full account, billing, and access control." : "Full account and access control.") + '</span></div><div class="access-policy-row"><strong>Admin</strong><span>' + escapeHTML(accessRoleCopy.admin) + '</span></div><div class="access-policy-row"><strong>Tech</strong><span>' + escapeHTML(accessRoleCopy.tech) + '</span></div><div class="access-policy-row"><strong>Read-only</strong><span>' + escapeHTML(accessRoleCopy.readOnly) + "</span></div></div></div>";var accessInvitePanel = account.can_manage ? '<div class="access-invite-panel"><div class="access-panel-heading"><h4>Invite people</h4><p>Add one person with the minimum role they need on this account.</p></div><div class="access-invite"><div><label for="invite-email-' + escapeAttr(account.id) + '">Email</label><input type="email" id="invite-email-' + escapeAttr(account.id) + '" placeholder="[email protected]" autocomplete="off"></div><div><label for="invite-role-' + escapeAttr(account.id) + '">Role</label><select id="invite-role-' + escapeAttr(account.id) + '"><option value="admin">Admin</option><option value="tech">Tech</option><option value="read_only">Read-only</option></select></div><button type="button" class="btn-primary btn-compact" data-action="invite-member" data-account-id="' + escapeAttr(account.id) + '">Invite</button></div></div>' : "";var accessChangeRolePanel = '<div class="access-job-note-panel"><div class="access-panel-heading"><h4>Change roles on the roster</h4><p>Use the role column in the roster to change one person at a time. Keep each person on the smallest role they need.</p></div></div>' + accessRoleGuide;var accessRemovePanel = '<div class="access-job-note-panel"><div class="access-panel-heading"><h4>Remove stale access</h4><p>Use removal only when this person should no longer be on this hosted account. Owners may still be protected when they are the last owner.</p></div><div class="access-remove-points"><div class="access-remove-point"><strong>Pick the exact person</strong><span>Use the roster to remove one account member at a time.</span></div><div class="access-remove-point"><strong>Keep current owners safe</strong><span>The last owner cannot be removed until another owner exists.</span></div></div></div>';@@ -3154,6 +3171,7 @@var clientLanguage = accountsUseClientLanguage(accounts);var primarySectionLabel = clientLanguage ? "Clients" : "Workspaces";var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);+ var hasBillingSection = hasHostedBillingAccounts(accounts) || showSelfHostedCommercial;var supportEmail = context.bootstrap.support_email || "";var canManageHostedTasks = false;for (var i = 0; i < accounts.length; i += 1) {@@ -3163,9 +3181,9 @@}}var hostedViewOnly = isHosted && !canManageHostedTasks;- var retryCopy = isHosted ? hostedViewOnly ? "Review " + primarySectionLabel + " or Access first. If billing is involved, hand it to an owner or admin before you escalate." : "Retry the same " + primarySectionLabel + ", Access, or Billing step before you escalate." : "Retry the same Billing step before you escalate.";- var supportActions = isHosted ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="workspaces">' + escapeHTML(primarySectionLabel) + '</button><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Access</button><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>' : '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>';- return '<section class="portal-support-panel"><p>Use Support only after the self-service path fails. Retry the same step before you escalate.</p><div class="portal-support-simple"><div class="portal-support-simple-card"><div class="portal-support-simple-list"><div class="portal-support-simple-row"><strong>Try first</strong><span>' + escapeHTML(retryCopy) + '</span></div><div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, clientLanguage)) + '</span></div><div class="portal-support-simple-row"><strong>Include</strong><span>Account, email, and the exact action that failed.</span></div></div><div class="portal-support-simple-actions">' + supportActions + '<a class="portal-support-link" href="mailto:' + escapeAttr(supportEmail) + '">' + escapeHTML(supportEmail) + "</a></div></div></div></section>";+ var retryCopy = isHosted ? hostedViewOnly ? hasBillingSection ? "Review " + primarySectionLabel + " or Access first. If billing is involved, hand it to an owner or admin before you escalate." : "Review " + primarySectionLabel + " or Access first. If account ownership is involved, hand it to an owner or admin before you escalate." : "Retry the same " + primarySectionLabel + (hasBillingSection ? ", Access, or Billing" : " or Access") + " step before you escalate." : "Retry the same Billing step before you escalate.";+ var supportActions = isHosted ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="workspaces">' + escapeHTML(primarySectionLabel) + '</button><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Access</button>' + (hasBillingSection ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>' : "") : '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>';+ return '<section class="portal-support-panel"><p>Use Support only after the self-service path fails. Retry the same step before you escalate.</p><div class="portal-support-simple"><div class="portal-support-simple-card"><div class="portal-support-simple-list"><div class="portal-support-simple-row"><strong>Try first</strong><span>' + escapeHTML(retryCopy) + '</span></div><div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, hasHostedBillingAccounts(accounts), clientLanguage)) + '</span></div><div class="portal-support-simple-row"><strong>Include</strong><span>Account, email, and the exact action that failed.</span></div></div><div class="portal-support-simple-actions">' + supportActions + '<a class="portal-support-link" href="mailto:' + escapeAttr(supportEmail) + '">' + escapeHTML(supportEmail) + "</a></div></div></div></section>";}function renderHeaderHTML(context) {if (context.bootstrap.authenticated) {@@ -3179,15 +3197,16 @@function renderAuthenticatedPortalHTML(context) {var accounts = Array.isArray(context.bootstrap.accounts) ? context.bootstrap.accounts : [];var hosted = hasHostedAccounts(accounts);+ var hasHostedBilling = hasHostedBillingAccounts(accounts);var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);var showSelfHostedUpgradeHandoff = context.billingState.openBillingPanelID === "upgrade-billing-panel" || !!normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey) || !!String(context.billingState.upgradePortalHandoffID || "").trim();var showSelfHostedBillingShell = showSelfHostedCommercial || showSelfHostedUpgradeHandoff;+ var showBillingPanel = hasHostedBilling || showSelfHostedBillingShell;var shellSections = visibleShellSections(context.bootstrap);var preferredSection = context.activeSection || preferredPortalShellSection(context.bootstrap);var activeSection = shellSections.some(function(entry) {return entry.section === preferredSection;}) ? preferredSection : shellSections[0] ? shellSections[0].section : "billing";- var billingNote = hosted ? showSelfHostedCommercial ? "Hosted billing by account. Self-hosted purchases stay separate below." : "Hosted billing by account." : "Self-hosted subscriptions, licenses, refunds, and privacy requests.";var selfHostedBillingEscalationCopy = hosted ? "Escalate with the same hosted billing action or self-hosted path and the exact failed step." : "Escalate with the same self-hosted billing path and the exact failed step.";var workspacesContent = accounts.length ? accounts.map(function(account) {return '<section class="account-surface">' + renderAccountSurfaceHeader(account, accounts.length > 1) + renderAccountWorkspaceSection(account, context.accountAPIBasePath) + "</section>";@@ -3225,7 +3244,7 @@'<div class="subsection"><div id="data-export-root"></div></div><div class="subsection"><div id="data-delete-root"></div></div><div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + "</a>.</div>");}- return '<div class="portal-shell" data-shell-section="' + activeSection + '"><div class="portal-shell-main">' + renderIdentityBar(accounts, showSelfHostedCommercial) + renderTabBar(context.bootstrap, activeSection) + (hosted ? '<section class="portal-content-panel portal-content-panel-workspaces">' + workspaceSummaryContent + workspacesContent + '</section><section class="portal-content-panel portal-content-panel-access">' + accessContent + "</section>" : "") + '<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' + (hosted ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : "") + (showSelfHostedBillingShell ? '<div class="billing-shell billing-shell-idle"><div class="billing-shell-main"><div class="billing-shell-main-head"><h3>Self-hosted billing</h3><p>' + escapeHTML(selfHostedBillingLeadCopy) + '</p></div><div class="billing-action-list">' + selfHostedBillingActionsHTML + '</div><div class="billing-inline-support"><h4>Support</h4><p>' + selfHostedBillingEscalationCopy + '</p><div class="billing-inline-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></div><div class="billing-shell-detail" id="billing-detail-shell" hidden>' + selfHostedBillingPanelsHTML + "</div></div>" : "") + '</section><section class="portal-content-panel portal-content-panel-support">' + renderSupportSection(context) + "</section></div></div>";+ return '<div class="portal-shell" data-shell-section="' + activeSection + '"><div class="portal-shell-main">' + renderIdentityBar(accounts, showSelfHostedCommercial) + renderTabBar(context.bootstrap, activeSection) + (hosted ? '<section class="portal-content-panel portal-content-panel-workspaces">' + workspaceSummaryContent + workspacesContent + '</section><section class="portal-content-panel portal-content-panel-access">' + accessContent + "</section>" : "") + (showBillingPanel ? '<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' + (hosted && hasHostedBilling ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : "") + (showSelfHostedBillingShell ? '<div class="billing-shell billing-shell-idle"><div class="billing-shell-main"><div class="billing-shell-main-head"><h3>Self-hosted billing</h3><p>' + escapeHTML(selfHostedBillingLeadCopy) + '</p></div><div class="billing-action-list">' + selfHostedBillingActionsHTML + '</div><div class="billing-inline-support"><h4>Support</h4><p>' + selfHostedBillingEscalationCopy + '</p><div class="billing-inline-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></div><div class="billing-shell-detail" id="billing-detail-shell" hidden>' + selfHostedBillingPanelsHTML + "</div></div>" : "") + "</section>" : "") + '<section class="portal-content-panel portal-content-panel-support">' + renderSupportSection(context) + "</section></div></div>";}function renderAuthScopeRow(title, copy) {return '<article class="portal-auth-scope-row"><h3>' + escapeHTML(title) + "</h3><p>" + escapeHTML(copy) + "</p></article>";diff --git a/internal/cloudcp/portal/frontend/dev.mjs b/internal/cloudcp/portal/frontend/dev.mjsindex 147ed1fbff..00bb1db320 100644--- a/internal/cloudcp/portal/frontend/dev.mjs+++ b/internal/cloudcp/portal/frontend/dev.mjs@@ -9,7 +9,7 @@ import { createPortalBuildOptions, frontendRoot } from './build_config.mjs';const scenarioCookieName = 'pulse_portal_preview_scenario';const previewHost = process.env.PULSE_PORTAL_PREVIEW_HOST || '127.0.0.1';const previewPort = Number(process.env.PULSE_PORTAL_PREVIEW_PORT || '8765');-const previewScenarios = ['managed', 'readonly', 'selfhosted', 'empty', 'onboarding', 'mixed'];+const previewScenarios = ['managed', 'readonly', 'selfhosted', 'empty', 'provider', 'onboarding', 'mixed'];const previewFaviconSVG = fs.readFileSync(path.join(frontendRoot, '..', '..', 'favicon.svg'), 'utf8');const previewFaviconHref = '/favicon.svg?v=' + createHash('sha256').update(previewFaviconSVG).digest('hex').slice(0, 16);@@ -134,6 +134,28 @@ function buildScenarioTemplate(name) {};}+ if (name === 'provider') {+ return {+ ...base,+ signup_path: '',+ accounts: [{+ id: 'acct_provider',+ name: 'Provider MSP',+ kind: 'msp',+ kind_label: 'MSP',+ role: 'owner',+ can_manage: true,+ has_billing: false,+ setup_templates: standardSetupTemplates(),+ workspaces: [],+ members: [+ { email: '[email protected]', role: 'owner', user_id: 'u_owner' },+ { email: '[email protected]', role: 'tech', user_id: 'u_helpdesk' },+ ],+ }],+ };+ }+if (name === 'onboarding') {return {...base,@@ -1283,6 +1305,7 @@ server.listen(previewPort, previewHost, function() {console.log('[portal-preview] readonly -> http://' + previewHost + ':' + String(previewPort) + '/?scenario=readonly');console.log('[portal-preview] selfhosted -> http://' + previewHost + ':' + String(previewPort) + '/?scenario=selfhosted');console.log('[portal-preview] empty -> http://' + previewHost + ':' + String(previewPort) + '/?scenario=empty');+ console.log('[portal-preview] provider -> http://' + previewHost + ':' + String(previewPort) + '/?scenario=provider');console.log('[portal-preview] mixed -> http://' + previewHost + ':' + String(previewPort) + '/?scenario=mixed');});diff --git a/internal/cloudcp/portal/frontend/src/account_roles.ts b/internal/cloudcp/portal/frontend/src/account_roles.tsindex dda38cc76a..02815ae3ab 100644--- a/internal/cloudcp/portal/frontend/src/account_roles.ts+++ b/internal/cloudcp/portal/frontend/src/account_roles.ts@@ -20,17 +20,32 @@ export function portalRoleLabel(role: string): string {}}-export function portalRoleCapabilityCopy(role: string, clientLanguage = false): string {+export function portalRoleCapabilityCopy(role: string, clientLanguage = false, hasBilling = true): string {switch (normalizePortalRole(role)) {case 'owner':+ if (!hasBilling) {+ return clientLanguage+ ? 'Full account control, including access control and client control.'+ : 'Full account control, including access control and workspace control.';+ }return clientLanguage? 'Full account control, including billing, access control, and client control.': 'Full account control, including billing, access control, and workspace control.';case 'admin':+ if (!hasBilling) {+ return clientLanguage+ ? 'Can manage clients and account access.'+ : 'Can manage workspaces and account access.';+ }return clientLanguage? 'Can manage clients and billing for this account.': 'Can manage workspaces and billing for this account.';case 'tech':+ if (!hasBilling) {+ return clientLanguage+ ? 'Can manage clients without access ownership.'+ : 'Can manage workspaces without access ownership.';+ }return clientLanguage? 'Can manage clients without billing ownership.': 'Can manage workspaces without billing ownership.';diff --git a/internal/cloudcp/portal/frontend/src/account_view.test.ts b/internal/cloudcp/portal/frontend/src/account_view.test.tsindex acc7303490..85e5e349fc 100644--- a/internal/cloudcp/portal/frontend/src/account_view.test.ts+++ b/internal/cloudcp/portal/frontend/src/account_view.test.ts@@ -282,6 +282,35 @@ describe('account view', function() {expect(document.getElementById('access-list-acct_1')?.textContent).not.toContain('Can manage workspaces');});+ it('omits billing capability copy when an MSP account has no billing surface', function() {+ document.body.innerHTML =+ '<div id="access-section-acct_1" class="access-section" data-actor-role="owner" data-can-manage="true" data-client-language="true">' ++ '<div id="access-stats-acct_1"></div>' ++ '<div id="access-list-acct_1"></div>' ++ '</div>';++ renderAccessSection(+ 'acct_1',+ createEntry({+ accessVisible: true,+ accessQuery: {+ status: 'ready',+ error: '',+ data: [+ { email: '[email protected]', role: 'owner', user_id: 'u1' },+ { email: '[email protected]', role: 'tech', user_id: 'u2' },+ ],+ },+ }),+ false+ );++ var text = document.getElementById('access-list-acct_1')?.textContent || '';+ expect(text).toContain('Full account control, including access control and client control.');+ expect(text).toContain('Can manage clients without access ownership.');+ expect(text).not.toContain('billing');+ });+it('renders access roster as view-only when the account is not manageable', function() {document.body.innerHTML ='<div id="access-section-acct_1" class="access-section" data-actor-role="tech" data-can-manage="false">' +diff --git a/internal/cloudcp/portal/frontend/src/account_view.ts b/internal/cloudcp/portal/frontend/src/account_view.tsindex 7abd25d926..718b8ed227 100644--- a/internal/cloudcp/portal/frontend/src/account_view.ts+++ b/internal/cloudcp/portal/frontend/src/account_view.ts@@ -397,7 +397,7 @@ function renderAccessMemberAction(accountID: string, member: PortalAccessMember,return group;}-function renderAccessMemberRow(accountID: string, member: PortalAccessMember, isOwner: boolean, canManage: boolean, activeJob: PortalAccessJob, clientLanguage: boolean): HTMLElement {+function renderAccessMemberRow(accountID: string, member: PortalAccessMember, isOwner: boolean, canManage: boolean, activeJob: PortalAccessJob, clientLanguage: boolean, hasBilling: boolean): HTMLElement {var showActionColumn = canManage && activeJob === 'remove';var row = document.createElement('div');row.className = 'access-member-row' + (showActionColumn ? '' : ' access-member-row-readonly');@@ -431,7 +431,7 @@ function renderAccessMemberRow(accountID: string, member: PortalAccessMember, iscaption.className = 'access-member-caption';caption.textContent = (member.state || 'active') === 'pending'? 'Invitation pending acceptance.'- : portalRoleCapabilityCopy(member.role, clientLanguage);+ : portalRoleCapabilityCopy(member.role, clientLanguage, hasBilling);identity.appendChild(caption);row.appendChild(identity);@@ -470,7 +470,7 @@ export function renderAddWorkspaceSection(accountID: string, entry: PortalAccoun}}-export function renderAccessSection(accountID: string, entry: PortalAccountUIEntry): void {+export function renderAccessSection(accountID: string, entry: PortalAccountUIEntry, hasBilling = true): void {var section = getElement<HTMLElement>('access-section-' + accountID);var roster = getElement<HTMLElement>('access-list-' + accountID);if (!section || !roster) return;@@ -545,7 +545,7 @@ export function renderAccessSection(accountID: string, entry: PortalAccountUIEntrenderAccessRosterHead(roster, activeJob, canManage);for (var i = 0; i < entry.accessQuery.data.length; i += 1) {var member = entry.accessQuery.data[i];- roster.appendChild(renderAccessMemberRow(accountID, member, isOwner, canManage, activeJob, clientLanguage));+ roster.appendChild(renderAccessMemberRow(accountID, member, isOwner, canManage, activeJob, clientLanguage, hasBilling));}}@@ -563,6 +563,6 @@ export function renderAccountUI(accountState: PortalAccountState, accounts: Port}renderAddWorkspaceSection(accountID, entry);if (account) renderWorkspaceManagement(account, entry, accountAPIBasePath);- renderAccessSection(accountID, entry);+ renderAccessSection(accountID, entry, account ? account.has_billing === true : true);}}diff --git a/internal/cloudcp/portal/frontend/src/shell_view.test.ts b/internal/cloudcp/portal/frontend/src/shell_view.test.tsindex 4b97091f4f..5641ea1e77 100644--- a/internal/cloudcp/portal/frontend/src/shell_view.test.ts+++ b/internal/cloudcp/portal/frontend/src/shell_view.test.ts@@ -276,6 +276,41 @@ describe('shell view', function() {expect(html).not.toContain('data-shell-section="overview"');});+ it('omits hosted billing surfaces for provider-hosted MSP accounts without billing records', function() {+ var html = renderAuthenticatedPortalHTML(+ createContext({+ bootstrap: createBootstrap({+ accounts: [+ {+ id: 'acct_provider',+ name: 'Provider MSP',+ kind: 'msp',+ kind_label: 'MSP',+ role: 'owner',+ can_manage: true,+ has_billing: false,+ members: [],+ workspaces: [],+ },+ ],+ }),+ })+ );++ expect(html).toContain('data-shell-section="workspaces">Clients</button>');+ expect(html).toContain('data-shell-section="access">Access</button>');+ expect(html).toContain('data-shell-section="support">Support</button>');+ expect(html).not.toContain('data-shell-section="billing"');+ expect(html).not.toContain('id="billing-section"');+ expect(html).not.toContain('hosted billing');+ expect(html).not.toContain('Full account, billing, and access control.');+ expect(html).not.toContain('without billing');+ expect(html).not.toContain('Billing changes stay in Billing.');+ expect(html).toContain('Access changes stay in Access. Client runtime changes stay inside the client workspace.');+ expect(html).toContain('Retry the same Clients or Access step before you escalate.');+ expect(html).toContain('Clients or Access.');+ });+it('defaults the authenticated hosted shell to workspaces', function() {var html = renderAuthenticatedPortalHTML(createContext({diff --git a/internal/cloudcp/portal/frontend/src/shell_view.ts b/internal/cloudcp/portal/frontend/src/shell_view.tsindex 0023af4b7f..5cce90ad65 100644--- a/internal/cloudcp/portal/frontend/src/shell_view.ts+++ b/internal/cloudcp/portal/frontend/src/shell_view.ts@@ -134,43 +134,31 @@ function setupNeededWorkspaceChipLabel(count: number, clientLanguage = false): s-function supportLeadCopy(hasHostedAccounts: boolean, hostedViewOnly: boolean, showSelfHostedCommercial: boolean, clientLanguage = false): string {- var primarySection = clientLanguage ? 'Clients' : 'Workspaces';- if (!hasHostedAccounts) return 'Use Support only after Billing fails.';- if (hostedViewOnly) {- return showSelfHostedCommercial- ? 'Use Support only after ' + primarySection + ', Access review, owner/admin handoff, or Billing fails.'- : 'Use Support only after ' + primarySection + ', Access review, owner/admin handoff, or hosted Billing fails.';- }- return showSelfHostedCommercial- ? 'Use Support only after ' + primarySection + ', Access, or Billing fails.'- : 'Use Support only after ' + primarySection + ', Access, or hosted Billing fails.';-}--function supportRunbookPathCopy(hasHostedAccounts: boolean, hostedViewOnly: boolean, showSelfHostedCommercial: boolean, clientLanguage = false): string {+function supportRunbookPathCopy(hasHostedAccounts: boolean, hostedViewOnly: boolean, showSelfHostedCommercial: boolean, hasHostedBilling: boolean, clientLanguage = false): string {var primarySection = clientLanguage ? 'Clients' : 'Workspaces';if (!hasHostedAccounts) return 'Billing, licenses, refunds, or privacy.';if (hostedViewOnly) {- return showSelfHostedCommercial- ? primarySection + ', Access review, owner/admin handoff, hosted billing, licenses, refunds, or privacy.'- : primarySection + ', Access review, owner/admin handoff, or hosted billing.';+ if (showSelfHostedCommercial && hasHostedBilling) return primarySection + ', Access review, owner/admin handoff, hosted billing, licenses, refunds, or privacy.';+ if (showSelfHostedCommercial) return primarySection + ', Access review, owner/admin handoff, licenses, refunds, or privacy.';+ if (hasHostedBilling) return primarySection + ', Access review, owner/admin handoff, or hosted billing.';+ return primarySection + ', Access review, or owner/admin handoff.';}- return showSelfHostedCommercial- ? primarySection + ', Access, hosted billing, licenses, refunds, or privacy.'- : primarySection + ', Access, or hosted billing.';-}--function supportRunbookAccountCopy(hasHostedAccounts: boolean, showSelfHostedCommercial: boolean): string {- if (!hasHostedAccounts) return 'Commercial billing email used for the self-hosted purchase.';- return showSelfHostedCommercial- ? 'Hosted account and workspace when relevant, or billing email for self-hosted work.'- : 'Hosted account and workspace, or hosted billing account.';+ if (showSelfHostedCommercial && hasHostedBilling) return primarySection + ', Access, hosted billing, licenses, refunds, or privacy.';+ if (showSelfHostedCommercial) return primarySection + ', Access, licenses, refunds, or privacy.';+ if (hasHostedBilling) return primarySection + ', Access, or hosted billing.';+ return primarySection + ' or Access.';}function hasHostedAccounts(accounts: PortalAccountSummary[]): boolean {return accounts.length > 0;}+function hasHostedBillingAccounts(accounts: PortalAccountSummary[]): boolean {+ return accounts.some(function(account) {+ return account.has_billing === true;+ });+}+function hasSelfHostedCommercial(bootstrap: PortalBootstrapData): boolean {var accounts = Array.isArray(bootstrap.accounts) ? bootstrap.accounts : [];return bootstrap.has_self_hosted_commercial === true || !hasHostedAccounts(accounts);@@ -404,19 +392,14 @@ function primaryShellSections(bootstrap: PortalBootstrapData): ShellNavEntry[] {var accounts = Array.isArray(bootstrap.accounts) ? bootstrap.accounts : [];var hosted = hasHostedAccounts(accounts);var showSelfHostedCommercial = hasSelfHostedCommercial(bootstrap);- var hostedBillingCount = 0;- for (var i = 0; i < accounts.length; i += 1) {- if (accounts[i].has_billing) {- hostedBillingCount += 1;- }- }+ var hasHostedBilling = hasHostedBillingAccounts(accounts);var sections: ShellNavEntry[] = [];if (hosted) {sections.push({ section: 'workspaces', title: accountsUseClientLanguage(accounts) ? 'Clients' : 'Workspaces' });sections.push({ section: 'access', title: 'Access' });}- if (hostedBillingCount > 0 || showSelfHostedCommercial) {+ if (hasHostedBilling || showSelfHostedCommercial) {sections.push({ section: 'billing', title: 'Billing' });}return sections;@@ -889,7 +872,7 @@ function renderProviderSetupTemplates(accounts: PortalAccountSummary[]): string'<span class="workspace-template-summary-title">' + escapeHTML(template.title || 'Provider setup template') + '</span>' +'<span class="workspace-template-summary-meta">' + escapeHTML(templateAccount.name) + '</span>' +'</summary>' +- '<p class="workspace-template-intro">Use the same onboarding shape for each client, then finish the tenant-owned configuration inside that client workspace.</p>' ++ '<p class="workspace-template-intro">Use the same onboarding shape for each client, then finish the workspace-owned configuration inside that isolated client boundary.</p>' +'<div class="workspace-template-grid">' +'<div><strong>Agent naming</strong><span>' + escapeHTML(template.agent_naming) + '</span></div>' +'<div><strong>Alert routing</strong><span>' + escapeHTML(template.alert_routing) + '</span></div>' +@@ -963,7 +946,7 @@ function workspaceSectionHeaderCopy(accounts: PortalAccountSummary[], entries: W: 'Review hosted workspace health here and open ready workspaces. An owner or admin must handle setup and workspace changes.';}return clientLanguage- ? 'Review clients here, use Client onboarding for setup, and keep destructive client actions separate from daily monitoring.'+ ? 'Review clients here, use Client onboarding for setup, and keep destructive client actions separate from daily monitoring. Each client remains an isolated workspace.': 'Review client workspaces here, use the setup checklist for onboarding, and keep destructive workspace actions separate from daily workspace work.';}@@ -1040,8 +1023,13 @@ function renderAccountWorkspaceSection(account: PortalAccountSummary, accountAPIvar attentionCount = attentionWorkspaces(workspaces).length;var suspendedCount = countWorkspacesByState(workspaces, 'suspended');var workspaceListSummary = account.can_manage- ? (clientLanguage ? 'Open a client to work inside its workspace boundary, or use Client onboarding to finish setup.' : 'Open a workspace to work in it, or use Setup checklist when onboarding a client.')+ ? (clientLanguage ? 'Open a client to work inside its isolated workspace boundary, or use Client onboarding to finish setup.' : 'Open a workspace to work in it, or use Setup checklist when onboarding a client.'): 'Open a workspace here. An owner or admin must create or change hosted workspaces.';+ var workspaceManagementEmptyNote = account.has_billing+ ? 'Access changes stay in Access. Billing changes stay in Billing.'+ : (clientLanguage+ ? 'Access changes stay in Access. Client runtime changes stay inside the client workspace.'+ : 'Access changes stay in Access. Workspace runtime changes stay inside the workspace.');var workspaceManagement = '';var addWorkspaceForm = '';var workspaceHeaderActions = '';@@ -1099,11 +1087,11 @@ function renderAccountWorkspaceSection(account: PortalAccountSummary, accountAPI'<div class="workspace-management-empty-actions-card">' +'<div class="workspace-management-empty-actions-copy">' +'<h4>' + escapeHTML(clientLanguage ? 'Add a client' : 'Create a workspace') + '</h4>' +- '<p>' + escapeHTML(clientLanguage ? 'Create the hosted workspace boundary for a customer.' : 'Add a new hosted workspace for a customer or operating boundary.') + '</p>' ++ '<p>' + escapeHTML(clientLanguage ? 'Create an isolated client workspace for a customer.' : 'Add a new hosted workspace for a customer or operating boundary.') + '</p>' +'</div>' +addWorkspaceForm +'</div>' +- '<div class="workspace-management-empty-note">Access changes stay in Access. Billing changes stay in Billing.</div>' ++ '<div class="workspace-management-empty-note">' + escapeHTML(workspaceManagementEmptyNote) + '</div>' +'</div>' +'</div>' +'<div class="workspace-management-content" id="workspace-management-content-' +@@ -1174,7 +1162,7 @@ function renderAccountWorkspaceSection(account: PortalAccountSummary, accountAPI'<div class="workspace-setup-checklist" aria-label="' + escapeAttr(clientLanguage ? 'Client onboarding checklist' : 'Workspace setup checklist') + '">' +'<div class="workspace-setup-step workspace-setup-step-created">' +'<span class="workspace-setup-status" id="workspace-management-check-created-' + escapeAttr(account.id) + '"></span>' +- '<div><strong>' + escapeHTML(clientLanguage ? 'Client added' : 'Workspace created') + '</strong><span>' + escapeHTML(clientLanguage ? 'A separate workspace boundary keeps this client isolated.' : 'This client has a separate account boundary.') + '</span></div>' ++ '<div><strong>' + escapeHTML(clientLanguage ? 'Client added' : 'Workspace created') + '</strong><span>' + escapeHTML(clientLanguage ? 'A separate workspace boundary keeps this client isolated.' : 'This client has a separate workspace boundary.') + '</span></div>' +'</div>' +'<div class="workspace-setup-step">' +'<span class="workspace-setup-status" id="workspace-management-check-install-' + escapeAttr(account.id) + '"></span>' +@@ -1284,9 +1272,14 @@ function renderAccountWorkspaceSection(account: PortalAccountSummary, accountAPIfunction renderAccountAccessSection(account: PortalAccountSummary): string {var clientLanguage = accountUsesClientLanguage(account);+ var hasBilling = account.has_billing === true;var accessRoleCopy = {- admin: clientLanguage ? 'Client control, billing, and roster management.' : 'Workspace control, billing, and roster management.',- tech: clientLanguage ? 'Client control without billing or roster ownership.' : 'Workspace control without billing or roster ownership.',+ admin: hasBilling+ ? (clientLanguage ? 'Client control, billing, and roster management.' : 'Workspace control, billing, and roster management.')+ : (clientLanguage ? 'Client control and roster management.' : 'Workspace control and roster management.'),+ tech: hasBilling+ ? (clientLanguage ? 'Client control without billing or roster ownership.' : 'Workspace control without billing or roster ownership.')+ : (clientLanguage ? 'Client control without roster ownership.' : 'Workspace control without roster ownership.'),readOnly: clientLanguage ? 'Review client status without control-plane changes.' : 'Review access without control-plane changes.',};var accessTaskStrip = account.can_manage@@ -1307,7 +1300,7 @@ function renderAccountAccessSection(account: PortalAccountSummary): string {: 'Use these role meanings to understand what each person on this roster can do.') + '</p>' +'</div>' +'<div class="access-policy-list">' +- '<div class="access-policy-row"><strong>Owner</strong><span>Full account, billing, and access control.</span></div>' ++ '<div class="access-policy-row"><strong>Owner</strong><span>' + escapeHTML(hasBilling ? 'Full account, billing, and access control.' : 'Full account and access control.') + '</span></div>' +'<div class="access-policy-row"><strong>Admin</strong><span>' + escapeHTML(accessRoleCopy.admin) + '</span></div>' +'<div class="access-policy-row"><strong>Tech</strong><span>' + escapeHTML(accessRoleCopy.tech) + '</span></div>' +'<div class="access-policy-row"><strong>Read-only</strong><span>' + escapeHTML(accessRoleCopy.readOnly) + '</span></div>' +@@ -1489,6 +1482,7 @@ function renderSupportSection(context: ShellViewContext): string {var clientLanguage = accountsUseClientLanguage(accounts);var primarySectionLabel = clientLanguage ? 'Clients' : 'Workspaces';var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);+ var hasBillingSection = hasHostedBillingAccounts(accounts) || showSelfHostedCommercial;var supportEmail = context.bootstrap.support_email || '';var canManageHostedTasks = false;for (var i = 0; i < accounts.length; i += 1) {@@ -1501,15 +1495,19 @@ function renderSupportSection(context: ShellViewContext): string {var retryCopy = isHosted? (hostedViewOnly- ? 'Review ' + primarySectionLabel + ' or Access first. If billing is involved, hand it to an owner or admin before you escalate.'- : 'Retry the same ' + primarySectionLabel + ', Access, or Billing step before you escalate.'+ ? (+ hasBillingSection+ ? 'Review ' + primarySectionLabel + ' or Access first. If billing is involved, hand it to an owner or admin before you escalate.'+ : 'Review ' + primarySectionLabel + ' or Access first. If account ownership is involved, hand it to an owner or admin before you escalate.'+ )+ : 'Retry the same ' + primarySectionLabel + (hasBillingSection ? ', Access, or Billing' : ' or Access') + ' step before you escalate.'): 'Retry the same Billing step before you escalate.';var supportActions = isHosted? ('<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="workspaces">' + escapeHTML(primarySectionLabel) + '</button>' +'<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Access</button>' +- '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>'+ (hasBillingSection ? '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>' : '')): '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Billing</button>';return (@@ -1519,7 +1517,7 @@ function renderSupportSection(context: ShellViewContext): string {'<div class="portal-support-simple-card">' +'<div class="portal-support-simple-list">' +'<div class="portal-support-simple-row"><strong>Try first</strong><span>' + escapeHTML(retryCopy) + '</span></div>' +- '<div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, clientLanguage)) + '</span></div>' ++ '<div class="portal-support-simple-row"><strong>Scope</strong><span>' + escapeHTML(supportRunbookPathCopy(isHosted, hostedViewOnly, showSelfHostedCommercial, hasHostedBillingAccounts(accounts), clientLanguage)) + '</span></div>' +'<div class="portal-support-simple-row"><strong>Include</strong><span>Account, email, and the exact action that failed.</span></div>' +'</div>' +'<div class="portal-support-simple-actions">' +@@ -1550,12 +1548,14 @@ export function renderHeaderHTML(context: ShellViewContext): string {export function renderAuthenticatedPortalHTML(context: ShellViewContext): string {var accounts = Array.isArray(context.bootstrap.accounts) ? context.bootstrap.accounts : [];var hosted = hasHostedAccounts(accounts);+ var hasHostedBilling = hasHostedBillingAccounts(accounts);var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);var showSelfHostedUpgradeHandoff =context.billingState.openBillingPanelID === 'upgrade-billing-panel' ||!!normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey) ||!!String(context.billingState.upgradePortalHandoffID || '').trim();var showSelfHostedBillingShell = showSelfHostedCommercial || showSelfHostedUpgradeHandoff;+ var showBillingPanel = hasHostedBilling || showSelfHostedBillingShell;var shellSections = visibleShellSections(context.bootstrap);var preferredSection = context.activeSection || preferredPortalShellSection(context.bootstrap);var activeSection = shellSections.some(function(entry) {@@ -1563,11 +1563,6 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string})? preferredSection: (shellSections[0] ? shellSections[0].section : 'billing');- var billingNote = hosted- ? (showSelfHostedCommercial- ? 'Hosted billing by account. Self-hosted purchases stay separate below.'- : 'Hosted billing by account.')- : 'Self-hosted subscriptions, licenses, refunds, and privacy requests.';var selfHostedBillingEscalationCopy = hosted? 'Escalate with the same hosted billing action or self-hosted path and the exact failed step.': 'Escalate with the same self-hosted billing path and the exact failed step.';@@ -1654,8 +1649,9 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string'</section>'): '') +- '<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' +- (hosted ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : '') ++ (showBillingPanel+ ? '<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' ++ (hosted && hasHostedBilling ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : '') +(showSelfHostedBillingShell? ('<div class="billing-shell billing-shell-idle">' +'<div class="billing-shell-main">' +@@ -1680,7 +1676,8 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string'<div class="billing-shell-detail" id="billing-detail-shell" hidden>' + selfHostedBillingPanelsHTML + '</div>' +'</div>'): '') +- '</section>' ++ '</section>'+ : '') +'<section class="portal-content-panel portal-content-panel-support">' +renderSupportSection(context) +'</section>' +diff --git a/internal/cloudcp/portal/frontend/src/workspace_presentation.test.ts b/internal/cloudcp/portal/frontend/src/workspace_presentation.test.tsindex ce95a2a5b0..1a81f5bf9c 100644--- a/internal/cloudcp/portal/frontend/src/workspace_presentation.test.ts+++ b/internal/cloudcp/portal/frontend/src/workspace_presentation.test.ts@@ -65,7 +65,7 @@ describe('workspace presentation', function() {expect(workspaceSetupState(createWorkspace())).toBe('setup_path');expect(workspaceSetupLabel(createWorkspace())).toBe('Setup path');expect(workspaceRowNote(createWorkspace())).toBe('Setup path ready');- expect(workspaceSetupNextStep(createWorkspace({ setup_status: 'install_agents' }))).toBe('Install the first agent from this workspace so client data lands in the right boundary.');+ expect(workspaceSetupNextStep(createWorkspace({ setup_status: 'install_agents' }))).toBe('Install the first agent from this workspace so client data lands in the isolated workspace boundary.');expect(workspaceSetupState(createWorkspace({ agent_count: 0 }))).toBe('install_agents');expect(workspaceSetupState(createWorkspace({ setup_status: 'setup_path', agent_count: 0 }))).toBe('install_agents');expect(workspaceSetupState(createWorkspace({ agent_count: 1, alert_route_count: 0, report_schedule_count: 0 }))).toBe('configure_outputs');diff --git a/internal/cloudcp/portal/frontend/src/workspace_presentation.ts b/internal/cloudcp/portal/frontend/src/workspace_presentation.tsindex 3a4954a8d8..44d5e9ae87 100644--- a/internal/cloudcp/portal/frontend/src/workspace_presentation.ts+++ b/internal/cloudcp/portal/frontend/src/workspace_presentation.ts@@ -133,7 +133,7 @@ export function workspaceSetupNextStep(workspace: PortalWorkspaceSummary): strincase 'ready':return 'Open the workspace when you need to work inside this client boundary.';case 'install_agents':- return 'Install the first agent from this workspace so client data lands in the right boundary.';+ return 'Install the first agent from this workspace so client data lands in the isolated workspace boundary.';case 'configure_outputs':return 'Configure alert routing and reports before treating the client workspace as ready.';case 'review':@@ -144,7 +144,7 @@ export function workspaceSetupNextStep(workspace: PortalWorkspaceSummary): strin}export function workspaceIdentityCopy(workspace: PortalWorkspaceSummary): string {- return 'Client boundary: ' + workspace.display_name + '. Hostnames can repeat across clients; this workspace keeps agents, alerts, and reports scoped to this client.';+ return 'Client workspace boundary: ' + workspace.display_name + '. Hostnames can repeat across clients because agents, alerts, and reports stay scoped to this workspace.';}export function workspaceSetupDiagnostics(workspace: PortalWorkspaceSummary): string[] {@@ -216,7 +216,7 @@ export function workspaceSetupGuide(workspace: PortalWorkspaceSummary): Workspacif (setup === 'install_agents') {return {title: 'Install the first agent',- description: 'Start inside this client workspace so the first reporting token and future hostnames stay scoped to the client.',+ description: 'Start inside this isolated client workspace so the first reporting token and future hostnames stay scoped to the client.',primaryAction: 'install',primaryLabel: 'Install agents',diagnostics: workspaceSetupDiagnostics(workspace),diff --git a/internal/cloudcp/routes.go b/internal/cloudcp/routes.goindex 4ae4b9136b..15ff67dbdd 100644--- a/internal/cloudcp/routes.go+++ b/internal/cloudcp/routes.go@@ -32,12 +32,22 @@ type Deps struct {}func publicCloudSignupPath(cfg *CPConfig) string {+ if cfg != nil && cfg.IsProviderHostedMSP() {+ return ""+ }if cfg != nil && cfg.PublicCloudSignupEnabled {return portal.PortalSignupPath}return ""}+func providerMSPPlanVersion(cfg *CPConfig) string {+ if cfg == nil || strings.TrimSpace(cfg.ProviderMSPPlanVersion) == "" {+ return defaultProviderHostedMSPPlanVersion+ }+ return cfg.ProviderMSPPlanVersion+}+// RegisterRoutes wires all HTTP handlers onto the given ServeMux.func RegisterRoutes(mux *http.ServeMux, deps *Deps) {webhookLimiter := NewCPRateLimiter(deps.Config.WebhookRateLimitPerMinute, time.Minute)@@ -124,10 +134,13 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {deps.Config.AllowDockerlessProvisioning,cpstripe.WithHostedEntitlementService(hostedEntitlements),cpstripe.WithTrialActivationPrivateKey(deps.Config.TrialActivationPrivateKey),+ cpstripe.WithDefaultMSPPlanVersion(providerMSPPlanVersion(deps.Config)),)}- webhookHandler := cpstripe.NewWebhookHandler(deps.Config.StripeWebhookSecret, provisioner)- mux.Handle("/api/stripe/webhook", webhookLimiter.Middleware(webhookHandler))+ if deps.Config.UsesStripeBilling() {+ webhookHandler := cpstripe.NewWebhookHandler(deps.Config.StripeWebhookSecret, provisioner)+ mux.Handle("/api/stripe/webhook", webhookLimiter.Middleware(webhookHandler))+ }// Magic link verification (public, token-authenticated)baseDomain := baseDomainFromURL(deps.Config.BaseURL)@@ -153,7 +166,7 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {mux.Handle("/cloud/signup/complete", publicSignupLimiter.Middleware(http.HandlerFunc(publicCloudSignupHandlers.HandleSignupComplete)))mux.Handle("/api/public/signup", publicSignupLimiter.Middleware(http.HandlerFunc(publicCloudSignupHandlers.HandlePublicSignup)))- // Pulse Cloud for MSPs self-serve signup. Registered under the same+ // Pulse Cloud for MSPs gated signup. Registered under the same// public-signup gate; stays inert (renders an unavailable state) until// an MSP tier price ID is configured in CP env.mux.Handle("/cloud/msp/signup", publicSignupLimiter.Middleware(http.HandlerFunc(publicCloudSignupHandlers.HandleMSPSignupPage)))@@ -214,7 +227,12 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {// Workspace management (session + account-membership authenticated)listTenants := account.HandleListTenants(deps.Registry)- createTenant := account.HandleCreateTenant(deps.Registry, provisioner)+ workspaceLimitPolicy := account.WorkspaceLimitPolicy{}+ if deps.Config.IsProviderHostedMSP() {+ workspaceLimitPolicy.ProviderHostedMSP = true+ workspaceLimitPolicy.ProviderMSPPlanVersion = providerMSPPlanVersion(deps.Config)+ }+ createTenant := account.HandleCreateTenantWithWorkspaceLimitPolicy(deps.Registry, provisioner, workspaceLimitPolicy)updateTenant := account.HandleUpdateTenant(deps.Registry)deleteTenant := account.HandleDeleteTenant(deps.Registry, provisioner)@@ -251,12 +269,14 @@ func RegisterRoutes(mux *http.ServeMux, deps *Deps) {mux.Handle(portal.PortalDashboardPath, portalAPILimiter.Middleware(accountSessionAuth(accountIDFromPortalRequest, portal.HandlePortalDashboardWithSetupFacts(deps.Registry, portalSetupFacts))))mux.Handle(portal.PortalWorkspacePath, portalAPILimiter.Middleware(accountSessionAuth(accountIDFromPortalRequest, portal.HandlePortalWorkspaceDetail(deps.Registry))))- // Stripe Customer Portal redirect (session + account-membership authenticated)- billingCfg := portal.BillingPortalConfig{- StripeAPIKey: deps.Config.StripeAPIKey,- ReturnURL: buildCPURL(deps.Config.BaseURL, portal.PortalPagePath, nil),+ if deps.Config.UsesStripeBilling() {+ // Stripe Customer Portal redirect (session + account-membership authenticated)+ billingCfg := portal.BillingPortalConfig{+ StripeAPIKey: deps.Config.StripeAPIKey,+ ReturnURL: buildCPURL(deps.Config.BaseURL, portal.PortalPagePath, nil),+ }+ mux.Handle(portal.PortalBillingPath, portalAPILimiter.Middleware(accountSessionAuth(accountIDFromPortalRequest, portal.HandleBillingPortalRedirect(deps.Registry, billingCfg))))}- mux.Handle(portal.PortalBillingPath, portalAPILimiter.Middleware(accountSessionAuth(accountIDFromPortalRequest, portal.HandleBillingPortalRedirect(deps.Registry, billingCfg))))mux.Handle(portal.PortalCommercialProxyPath, portalAPILimiter.Middleware(sessionAuth(portal.HandleCommercialProxy(portal.CommercialProxyConfig{BaseURL: deps.Config.LicenseServerURL,}))))diff --git a/internal/cloudcp/routes_test.go b/internal/cloudcp/routes_test.goindex 3c1bddd078..067c3bcc36 100644--- a/internal/cloudcp/routes_test.go+++ b/internal/cloudcp/routes_test.go@@ -333,3 +333,46 @@ func TestRegisterRoutes_PublicCloudSignupRoutesDisabledByDefault(t *testing.T) {t.Fatalf("POST /api/public/magic-link/request status=%d, want %d", publicMagicLinkRec.Code, http.StatusOK)}}++func TestRegisterRoutes_ProviderHostedMSPDisablesPulseHostedBillingRoutes(t *testing.T) {+ dir := t.TempDir()+ reg, err := registry.NewTenantRegistry(dir)+ if err != nil {+ t.Fatalf("NewTenantRegistry: %v", err)+ }+ t.Cleanup(func() { _ = reg.Close() })++ mux := http.NewServeMux()+ RegisterRoutes(mux, &Deps{+ Config: &CPConfig{+ DataDir: dir,+ AdminKey: "test-admin-key",+ BaseURL: "https://msp.example.com",+ ControlPlaneMode: ControlPlaneModeProviderHostedMSP,+ PublicCloudSignupEnabled: true,+ ProviderMSPPlanVersion: "msp_growth",+ },+ Registry: reg,+ Version: "test",+ })++ for _, tc := range []struct {+ method string+ path string+ }{+ {method: http.MethodPost, path: "/api/stripe/webhook"},+ {method: http.MethodGet, path: "/api/portal/billing"},+ {method: http.MethodGet, path: "/signup"},+ {method: http.MethodGet, path: "/cloud/signup"},+ {method: http.MethodPost, path: "/api/public/signup"},+ {method: http.MethodGet, path: "/cloud/msp/signup"},+ {method: http.MethodPost, path: "/api/public/msp/signup"},+ } {+ req := httptest.NewRequest(tc.method, tc.path, nil)+ rec := httptest.NewRecorder()+ mux.ServeHTTP(rec, req)+ if rec.Code != http.StatusNotFound {+ t.Fatalf("%s %s status=%d, want %d", tc.method, tc.path, rec.Code, http.StatusNotFound)+ }+ }+}diff --git a/internal/cloudcp/stripe/msp_lifecycle_integration_test.go b/internal/cloudcp/stripe/msp_lifecycle_integration_test.goindex 6401794494..868bce8363 100644--- a/internal/cloudcp/stripe/msp_lifecycle_integration_test.go+++ b/internal/cloudcp/stripe/msp_lifecycle_integration_test.go@@ -846,6 +846,47 @@ func TestMSPLifecycle_PlanVersionFallback(t *testing.T) {assertNoRetiredMonitoredSystemLimit(t, bs.Limits)}+func TestMSPLifecycle_ConfiguredPlanVersionFallback(t *testing.T) {+ reg := newStripeTestRegistry(t)+ tenantsDir := t.TempDir()+ provisioner := newTestProvisioner(t, reg, tenantsDir, nil, true, WithDefaultMSPPlanVersion("msp_growth"))++ accountID, err := registry.GenerateAccountID()+ if err != nil {+ t.Fatal(err)+ }+ if err := reg.CreateAccount(®istry.Account{+ ID: accountID,+ Kind: registry.AccountKindMSP,+ DisplayName: "Provider Hosted MSP",+ }); err != nil {+ t.Fatalf("CreateAccount: %v", err)+ }++ // No StripeAccount created: provider-hosted MSP mode uses the configured+ // local MSP plan as the fallback entitlement/workspace-limit source.+ ws, err := provisioner.ProvisionWorkspace(context.Background(), accountID, "Client")+ if err != nil {+ t.Fatalf("ProvisionWorkspace: %v", err)+ }+ if ws.PlanVersion != "msp_growth" {+ t.Fatalf("workspace.PlanVersion = %q, want %q", ws.PlanVersion, "msp_growth")+ }++ store := config.NewFileBillingStore(provisioner.tenantDataDir(ws.ID))+ bs, err := store.GetBillingState("default")+ if err != nil {+ t.Fatalf("GetBillingState: %v", err)+ }+ if bs == nil {+ t.Fatal("billing state is nil")+ }+ if bs.PlanVersion != "msp_growth" {+ t.Fatalf("billing.PlanVersion = %q, want %q", bs.PlanVersion, "msp_growth")+ }+ assertNoRetiredMonitoredSystemLimit(t, bs.Limits)+}+// ─── Test helpers ──────────────────────────────────────────────────────────func newMemberMux(reg *registry.TenantRegistry) *http.ServeMux {diff --git a/internal/cloudcp/stripe/provisioner.go b/internal/cloudcp/stripe/provisioner.goindex 2cf70d05bb..3d658abb09 100644--- a/internal/cloudcp/stripe/provisioner.go+++ b/internal/cloudcp/stripe/provisioner.go@@ -38,6 +38,7 @@ type Provisioner struct {emailFrom stringtrialActivationPrivateKey stringhostedEntitlements *entitlements.Service+ defaultMSPPlanVersion stringchownFile func(string, int, int) erroradmissionCheck AdmissionCheck}@@ -73,6 +74,18 @@ func WithHostedEntitlementService(service *entitlements.Service) ProvisionerOpti}}+func WithDefaultMSPPlanVersion(planVersion string) ProvisionerOption {+ return func(p *Provisioner) {+ if p == nil {+ return+ }+ planVersion = canonicalizeProvisionedPlanVersion(planVersion)+ if planVersion != "" {+ p.defaultMSPPlanVersion = planVersion+ }+ }+}+type provisioningCleanupState struct {tenantID stringtenantDataDir string@@ -83,15 +96,16 @@ type provisioningCleanupState struct {// NewProvisioner creates a Provisioner.func NewProvisioner(reg *registry.TenantRegistry, tenantsDir string, dockerMgr *docker.Manager, magicLinks *cpauth.Service, baseURL string, emailSender cpemail.Sender, emailFrom string, allowDockerless bool, opts ...ProvisionerOption) *Provisioner {p := &Provisioner{- registry: reg,- tenantsDir: tenantsDir,- docker: dockerMgr,- magicLinks: magicLinks,- baseURL: baseURL,- allowDockerless: allowDockerless,- emailSender: emailSender,- emailFrom: strings.TrimSpace(emailFrom),- chownFile: os.Chown,+ registry: reg,+ tenantsDir: tenantsDir,+ docker: dockerMgr,+ magicLinks: magicLinks,+ baseURL: baseURL,+ allowDockerless: allowDockerless,+ emailSender: emailSender,+ emailFrom: strings.TrimSpace(emailFrom),+ defaultMSPPlanVersion: "msp_starter",+ chownFile: os.Chown,}for _, opt := range opts {if opt != nil {@@ -937,12 +951,15 @@ func (p *Provisioner) ProvisionWorkspaceForOwner(ctx context.Context, accountID,// Look up the account's actual plan version from its Stripe billing record.// Fail on DB errors (consistent with enforceWorkspaceLimit). Fall back to- // msp_starter (lowest MSP tier) only when no billing record exists.+ // the configured local MSP plan only when no billing record exists.sa, saErr := p.registry.GetStripeAccount(accountID)if saErr != nil {return nil, fmt.Errorf("look up billing record for account %s: %w", accountID, saErr)}- planVersion := "msp_starter"+ planVersion := canonicalizeProvisionedPlanVersion(p.defaultMSPPlanVersion)+ if planVersion == "" {+ planVersion = "msp_starter"+ }if sa != nil && strings.TrimSpace(sa.PlanVersion) != "" {planVersion = canonicalizeProvisionedPlanVersion(sa.PlanVersion)} else {diff --git a/internal/cloudcp/stripe/provisioner_rollback_test.go b/internal/cloudcp/stripe/provisioner_rollback_test.goindex 53937f45dc..feeb3c3877 100644--- a/internal/cloudcp/stripe/provisioner_rollback_test.go+++ b/internal/cloudcp/stripe/provisioner_rollback_test.go@@ -47,13 +47,15 @@ func newFailingDockerManager(t *testing.T) *docker.Manager {return mgr}-func newTestProvisioner(t *testing.T, reg *registry.TenantRegistry, tenantsDir string, dockerMgr *docker.Manager, allowDockerless bool) *Provisioner {+func newTestProvisioner(t *testing.T, reg *registry.TenantRegistry, tenantsDir string, dockerMgr *docker.Manager, allowDockerless bool, opts ...ProvisionerOption) *Provisioner {t.Helper()publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)if err != nil {t.Fatalf("GenerateKey: %v", err)}t.Setenv("PULSE_TRIAL_ACTIVATION_PUBLIC_KEY", base64.StdEncoding.EncodeToString(publicKey))+ provisionerOpts := []ProvisionerOption{WithTrialActivationPrivateKey(base64.StdEncoding.EncodeToString(privateKey))}+ provisionerOpts = append(provisionerOpts, opts...)return NewProvisioner(reg,tenantsDir,@@ -63,7 +65,7 @@ func newTestProvisioner(t *testing.T, reg *registry.TenantRegistry, tenantsDir snil,"",allowDockerless,- WithTrialActivationPrivateKey(base64.StdEncoding.EncodeToString(privateKey)),+ provisionerOpts...,)}