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まで生成可能にした。 --- src/Agent.Core/Ollama/OllamaModels.cs | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Agent.Core/Ollama/OllamaModels.cs (limited to 'src/Agent.Core/Ollama/OllamaModels.cs') diff --git a/src/Agent.Core/Ollama/OllamaModels.cs b/src/Agent.Core/Ollama/OllamaModels.cs new file mode 100644 index 0000000..823a178 --- /dev/null +++ b/src/Agent.Core/Ollama/OllamaModels.cs @@ -0,0 +1,46 @@ +using System.Text.Json.Serialization; +using System.Text.Json; +using Agent.Core.Tools; + +namespace Agent.Core.Ollama; + +public sealed record OllamaMessage( + [property: JsonPropertyName("role")] string Role, + [property: JsonPropertyName("content")] string Content, + [property: JsonPropertyName("images"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] IReadOnlyList? Images = null, + [property: JsonPropertyName("tool_name"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] string? ToolName = null, + [property: JsonPropertyName("tool_calls"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] IReadOnlyList? ToolCalls = null); + +public sealed record OllamaToolCall([property: JsonPropertyName("function")] OllamaFunctionCall Function); +public sealed record OllamaFunctionCall( + [property: JsonPropertyName("name")] string Name, + [property: JsonPropertyName("arguments")] JsonElement Arguments); + +public sealed record OllamaToolDefinition( + [property: JsonPropertyName("type")] string Type, + [property: JsonPropertyName("function")] OllamaFunctionDefinition Function); +public sealed record OllamaFunctionDefinition( + [property: JsonPropertyName("name")] string Name, + [property: JsonPropertyName("description")] string Description, + [property: JsonPropertyName("parameters")] JsonElement Parameters); + +public sealed class OllamaChatRequest +{ + [JsonPropertyName("model")] public required string Model { get; init; } + [JsonPropertyName("messages")] public required IReadOnlyList Messages { get; init; } + [JsonPropertyName("stream")] public bool Stream { get; init; } + [JsonPropertyName("think")] public bool Think { get; init; } + [JsonPropertyName("keep_alive")] public required string KeepAlive { get; init; } + [JsonPropertyName("options")] public required IReadOnlyDictionary Options { get; init; } + [JsonPropertyName("tools"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public IReadOnlyList? Tools { get; init; } +} + +public sealed class OllamaChatResponse +{ + [JsonPropertyName("message")] public OllamaMessage? Message { get; init; } + [JsonPropertyName("prompt_eval_count")] public long PromptEvalCount { get; init; } + [JsonPropertyName("eval_count")] public long EvalCount { get; init; } + [JsonPropertyName("error")] public string? Error { get; init; } +} + +public sealed record OllamaResult(string Content, long InputTokens, long OutputTokens, IReadOnlyList? ToolCalls = null); -- cgit v1.2.3