summaryrefslogtreecommitdiff
path: root/src/Agent.App/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Agent.App/Program.cs')
-rw-r--r--src/Agent.App/Program.cs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/Agent.App/Program.cs b/src/Agent.App/Program.cs
index 7372a13..3de5b50 100644
--- a/src/Agent.App/Program.cs
+++ b/src/Agent.App/Program.cs
@@ -12,6 +12,7 @@ using Agent.Core.Tools;
using Agent.Windows.Recovery;
using Agent.Windows.Security;
using Agent.Windows.Tools;
+using Agent.Admin.Client;
namespace Agent.App;
@@ -46,24 +47,27 @@ internal static class Program
UserOnlyDirectory.Ensure(logDirectory);
using var log = new RollingFileLog(logDirectory, configuration.Logging.MaxFileBytes, configuration.Logging.RetainedFiles, configuration.Logging.Level);
log.Information(locale.Get("app.starting"));
- WindowsPlatformCheckResult servePlatform = WindowsPlatformCheck.Run();
+ string helperPath = Path.Combine(AppContext.BaseDirectory, "admin", "agent-mcp-admin.exe");
+ WindowsPlatformCheckResult servePlatform = WindowsPlatformCheck.Run(helperPath);
if (!servePlatform.Success)
{
string failure = locale.Format("app.preflight_failed", new Dictionary<string, object?>
{
["operation"] = servePlatform.ErrorOperation ?? "privilege/BFE/WFP probe",
["error_code"] = servePlatform.ErrorCode,
- ["administrator"] = servePlatform.IsAdministrator.ToString().ToLowerInvariant(),
+ ["platform"] = servePlatform.PlatformSupported.ToString().ToLowerInvariant(),
+ ["profile"] = servePlatform.ApplicationProfileAvailable.ToString().ToLowerInvariant(),
["bfe"] = servePlatform.BfeEngineOpen.ToString().ToLowerInvariant(),
- ["transaction"] = servePlatform.WfpWriteTransaction.ToString().ToLowerInvariant(),
- ["filters"] = servePlatform.WfpFilterAddDelete.ToString().ToLowerInvariant()
+ ["helper"] = servePlatform.HelperAvailable.ToString().ToLowerInvariant(),
+ ["version"] = servePlatform.HelperVersionCompatible.ToString().ToLowerInvariant()
});
log.Fatal(failure);
return 2;
}
var sessionStore = new SessionStore();
- InternalToolDispatcher toolDispatcher = CreateToolDispatcher(configuration, effectiveSandboxPolicy, logDirectory, sessionStore);
+ InternalToolDispatcher toolDispatcher = await CreateToolDispatcherAsync(configuration, effectiveSandboxPolicy, logDirectory,
+ sessionStore, new ElevatedNetworkSessionFactory(helperPath), CancellationToken.None).ConfigureAwait(false);
using var runtimeObserver = new JsonLinesRuntimeObserver(logDirectory, configuration.Logging.MaxFileBytes, configuration.Logging.RetainedFiles);
string taskStateDirectory = Path.Combine(baseDirectory, "state", "mcp-tasks");
UserOnlyDirectory.Ensure(taskStateDirectory);
@@ -163,6 +167,9 @@ internal static class Program
Console.Out.WriteLine("\n" + locale.Get(current ? "apply.no_changes" : "apply.replace_snapshot"));
ConfirmMutation(command.Yes, locale.Get("apply.prompt"));
+ // Application Profile creation is a normal-user, non-elevated configuration operation.
+ // Server startup remains read-only and only derives the fixed SID.
+ _ = AppContainerProfile.EnsureFixed();
UserOnlyDirectory.Ensure(logDirectory);
AppliedConfigurationDocument document = appliedConfiguration.Apply();
var audit = new JsonLinesSecurityAuditSink(Path.Combine(logDirectory, "audit.jsonl"));
@@ -214,14 +221,18 @@ internal static class Program
return previous is null ? "added" : previous == item ? "active" : "changed";
}
- private static InternalToolDispatcher CreateToolDispatcher(AgentConfiguration configuration, EffectiveSandboxPolicy effectiveSandboxPolicy, string logDirectory, SessionStore? sessionStore = null)
+ private static async Task<InternalToolDispatcher> CreateToolDispatcherAsync(AgentConfiguration configuration,
+ EffectiveSandboxPolicy effectiveSandboxPolicy, string logDirectory, SessionStore? sessionStore,
+ IElevatedNetworkSessionFactory elevatedNetwork, CancellationToken cancellationToken)
{
Directory.CreateDirectory(effectiveSandboxPolicy.JournalDirectory);
Directory.CreateDirectory(effectiveSandboxPolicy.BackupDirectory);
var audit = new JsonLinesSecurityAuditSink(Path.Combine(logDirectory, "audit.jsonl"));
- RecoveryResult recovery = new RecoveryManager(effectiveSandboxPolicy.JournalDirectory, audit).RecoverAll();
+ RecoveryResult recovery = await new RecoveryManager(effectiveSandboxPolicy.JournalDirectory, audit, elevatedNetwork)
+ .RecoverAllAsync(cancellationToken).ConfigureAwait(false);
if (!recovery.IsClean) throw new InvalidOperationException("Recovery did not reach a clean state: " + string.Join(" | ", recovery.Errors));
- var backend = new WindowsToolBackend(effectiveSandboxPolicy, audit, new TaskGraphToolHandler(configuration.Planner.MaxTasks, sessionStore));
+ var backend = new WindowsToolBackend(effectiveSandboxPolicy, audit,
+ new TaskGraphToolHandler(configuration.Planner.MaxTasks, sessionStore), elevatedNetwork);
var allowed = InternalToolCatalog.All.Select(static item => item.Name).ToHashSet(StringComparer.Ordinal);
return new InternalToolDispatcher(new DenyByDefaultPolicy(allowed), backend);
}