Files
nexus/backend/Data/OpenClawConnectionProfile.cs
AzuTear f5552218bc
CI - Build & Test / Backend (.NET) (push) Successful in 42s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 2m46s
CI - Build & Test / Security Check (push) Successful in 3s
CI - Build & Test / Deploy Nexus (push) Successful in 56s
feat: ship agent-first mission control v0.2.57
2026-07-31 22:39:47 +02:00

77 lines
2.3 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Nexus.Api.Models;
namespace Nexus.Api.Data;
/// <summary>
/// Secret-free metadata for Nexus' one active OpenClaw connection.
/// Device private keys, device tokens, bootstrap tokens and provider credentials
/// are intentionally outside this entity.
/// </summary>
[Table("OpenClawConnectionProfiles")]
public sealed class OpenClawConnectionProfile
{
public const string PrimaryProfileId = "primary";
[Key]
[MaxLength(40)]
public string ProfileId { get; set; } = PrimaryProfileId;
[MaxLength(2048)]
public required string Endpoint { get; set; }
[MaxLength(80)]
public required string DiscoverySource { get; set; }
[MaxLength(120)]
public string? RequiredVersion { get; set; }
[MaxLength(128)]
public string? TlsCertificateFingerprint { get; set; }
[MaxLength(40)]
public string AdoptionState { get; set; } = OpenClawAdoptionStates.None;
public bool ManagementEnabled { get; set; }
[MaxLength(128)]
public string? CapabilityHash { get; set; }
[MaxLength(240)]
public string? DeviceId { get; set; }
public int Revision { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset? LastProbedAt { get; set; }
public DateTimeOffset? LastVerifiedAt { get; set; }
public DateTimeOffset? AdoptedAt { get; set; }
}
/// <summary>
/// Kept next to the entity so the root integration only has to apply this
/// configuration from NexusDbContext.OnModelCreating.
/// </summary>
public sealed class OpenClawConnectionProfileConfiguration
: IEntityTypeConfiguration<OpenClawConnectionProfile>
{
public void Configure(EntityTypeBuilder<OpenClawConnectionProfile> entity)
{
entity.ToTable(
"OpenClawConnectionProfiles",
table => table.HasCheckConstraint(
"CK_OpenClawConnectionProfiles_Primary",
"\"ProfileId\" = 'primary'"));
entity.HasKey(profile => profile.ProfileId);
entity.Property(profile => profile.Revision).IsConcurrencyToken();
}
}