From b07b41cd435991cd254957af79055080c85b346e Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sun, 9 Aug 2026 21:08:20 +0900 Subject: feat: AI Agent Sandbox MCP Server v1を実装 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifications、Design、ImplementationPlanの優先順位を整理し、単一Task実行モデル、typed option優先、設定可能なresource上限、local Ollamaを必須とするRelease Gateを文書化。 .NET 10/C# 14の5 production project、3 test project、E2E Clientを構築。typed YAML、en/ja locale、fixed/user prompt、stdioおよびloopback限定Streamable HTTP、agent_run/agent_status、Session、Ollama text/tool/Vision、TaskGraphとtoken accountingを実装。 Windows sandboxとしてfixed AppContainer、canonical/reparse検査、能力別ACL、path+SHA-256 executable approval、child-process restriction、Job Object、task journal、atomic file transaction、crash recoveryを実装。WFPのIPv4/IPv6 default denyとexact allow、dynamic session、temporary loopback exemption、管理者/BFE診断を追加。 Security/Recovery test、MCP/Ollama integration test、stdio/HTTP Operational E2E、Release Bundle生成・checksum・manifest・fresh extraction検査を追加。Requirement TraceabilityとPhase 0〜11の進捗、初回セットアップ可能なREADMEを整備。 Debug/Release/publish/objをrepository rootのbuild/へ集約し、旧project-local bin/objへの依存を除去。artifacts/とbuild/をGit管理外に設定し、clean checkoutでもsolution buildからE2E Clientまで生成可能にした。 --- .../Diagnostics/WindowsPlatformCheck.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs (limited to 'src/Agent.Windows/Diagnostics') diff --git a/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs b/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs new file mode 100644 index 0000000..b8ca0ae --- /dev/null +++ b/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs @@ -0,0 +1,50 @@ +using System.ComponentModel; +using System.Security.Principal; +using Agent.Windows.Network; +using Agent.Windows.Security; + +namespace Agent.Windows.Diagnostics; + +public sealed record WindowsPlatformCheckResult( + bool IsAdministrator, + bool BfeEngineOpen, + bool WfpWriteTransaction, + bool WfpFilterAddDelete, + int? ErrorCode, + string? ErrorOperation) +{ + public bool Success => IsAdministrator && BfeEngineOpen && WfpWriteTransaction && WfpFilterAddDelete; +} + +public static class WindowsPlatformCheck +{ + public static WindowsPlatformCheckResult Run() + { + using WindowsIdentity identity = WindowsIdentity.GetCurrent(); + bool administrator = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator); + bool open = false; + bool transaction = false; + bool filters = false; + try + { + AppContainerProfile profile = AppContainerProfile.EnsureFixed(); + using WfpDynamicSession session = WfpDynamicSession.Open(); + open = true; + session.ProbeWriteTransaction(); + transaction = true; + IReadOnlyList ids = session.ApplyDefaultBlock(profile.Sid); + if (ids.Count != 2 || ids.Any(static id => id == 0)) throw new InvalidOperationException("WFP probe did not create both IPv4 and IPv6 filters."); + session.RemovePolicy(); + filters = true; + return new(administrator, open, transaction, filters, null, null); + } + catch (Win32Exception ex) + { + return new(administrator, open, transaction, filters, ex.NativeErrorCode, ex.Message); + } + catch (Exception ex) when (ex is UnauthorizedAccessException or InvalidOperationException or IOException) + { + return new(administrator, open, transaction, filters, ex.HResult, ex.Message); + } + } +} -- cgit v1.2.3