From 882d4ec21dd3d9c5bada699bc180dadf2a028a59 Mon Sep 17 00:00:00 2001 From: Meleki Date: Fri, 27 Feb 2026 11:23:31 +0100 Subject: [PATCH] Add SessionEndpoint, update ChatEndpoint, update deploy script and project file, remove DEVY.md --- DEVY.md | 23 ----------------- Endpoints/ChatEndpoint.cs | 2 ++ Endpoints/SessionEndpoint.cs | 50 ++++++++++++++++++++++++++++++++++++ deploy.sh | 5 ++-- gott.csproj | 2 +- 5 files changed, 56 insertions(+), 26 deletions(-) delete mode 100644 DEVY.md diff --git a/DEVY.md b/DEVY.md deleted file mode 100644 index 0fc6888..0000000 --- a/DEVY.md +++ /dev/null @@ -1,23 +0,0 @@ -## Info - -- **.NET 10** without Nullable and Implicit Usings - -## Deployment - -- **Workspace:** `/home/node/.openclaw/workspace/projects/gott/` -- **Build & Deploy:** `bash deploy.sh` -- **WICHTIG:** Bei reinen Frontend-Änderungen (CSS/JS/HTML) IMMER auch `publish/wwwroot/` aktualisieren! - -## Git - -- **Push:** `git push` - -## Notizen - -**Commits:** NICHT nach jeder Nachricht committen - erst wenn Aufgabe abgeschlossen und User zufrieden ist. - -## REGELN (NIEMALS BRECHEN) - -- **NUR `bash deploy.sh` für Deployment.** NIEMALS `dotnet publish` direkt ausführen. Wenn deploy.sh nicht funktioniert → NACHFRAGEN! -- **NIEMALS Dateien in `publish/data/` manuell überschreiben oder manipulieren.** Das sind Live-Daten (Sessions, Users, History). Ein falscher Schreibvorgang = Datenverlust. -- **Keine Experimente am Live-System.** Wenn was nicht klappt, nicht "kreativ werden" sondern FRAGEN! \ No newline at end of file diff --git a/Endpoints/ChatEndpoint.cs b/Endpoints/ChatEndpoint.cs index 1f6c06f..3a69693 100644 --- a/Endpoints/ChatEndpoint.cs +++ b/Endpoints/ChatEndpoint.cs @@ -83,6 +83,8 @@ public static class ChatEndpoint if (!string.IsNullOrWhiteSpace(agent.Instructions)) promptParts.Add($"## Instructions\n{agent.Instructions}"); + if (!string.IsNullOrWhiteSpace(session.Workspace)) + promptParts.Add($"## Workspace\n{session.Workspace}"); if (!string.IsNullOrWhiteSpace(session.Context)) promptParts.Add($"## Kontext\n{session.Context}"); diff --git a/Endpoints/SessionEndpoint.cs b/Endpoints/SessionEndpoint.cs index 6c92749..8b7ff38 100644 --- a/Endpoints/SessionEndpoint.cs +++ b/Endpoints/SessionEndpoint.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using System.Text.Json; using System.Threading.Tasks; @@ -17,6 +18,7 @@ public static class SessionEndpoint app.MapPost("/api/sessions", HandleCreate); app.MapPut("/api/sessions/{sessionId}", HandleUpdate); app.MapDelete("/api/sessions/{sessionId}", HandleDelete); + app.MapGet("/api/sessions/{sessionId}/system-prompt", HandleSystemPrompt); } private static async Task HandleList(HttpContext ctx, DatabaseService db) @@ -81,4 +83,52 @@ public static class SessionEndpoint await db.DeleteSession(sessionId); ctx.Response.StatusCode = 204; } + + private static async Task HandleSystemPrompt(HttpContext ctx, DatabaseService db) + { + var sessionId = ctx.Request.RouteValues["sessionId"]?.ToString(); + if (string.IsNullOrEmpty(sessionId)) + { + ctx.Response.StatusCode = 400; + return; + } + + var session = await db.GetSession(sessionId); + if (session == null) + { + ctx.Response.StatusCode = 404; + return; + } + + if (string.IsNullOrEmpty(session.AgentId)) + { + ctx.Response.StatusCode = 400; + await ctx.Response.WriteAsJsonAsync(new { error = "Kein Agent ausgewählt" }); + return; + } + + var agent = await db.GetAgent(session.AgentId); + if (agent == null) + { + ctx.Response.StatusCode = 400; + await ctx.Response.WriteAsJsonAsync(new { error = "Agent nicht gefunden" }); + return; + } + + var promptParts = new List(); + promptParts.Add($"Du bist {agent.Name}."); + if (!string.IsNullOrWhiteSpace(agent.Persona)) + promptParts.Add($"## Persona\n{agent.Persona}"); + if (!string.IsNullOrWhiteSpace(agent.Instructions)) + promptParts.Add($"## Instructions\n{agent.Instructions}"); + if (!string.IsNullOrWhiteSpace(session.Workspace)) + promptParts.Add($"## Workspace\n{session.Workspace}"); + if (!string.IsNullOrWhiteSpace(session.Context)) + promptParts.Add($"## Kontext\n{session.Context}"); + + var systemPrompt = string.Join("\n\n", promptParts); + + ctx.Response.ContentType = "text/plain; charset=utf-8"; + await ctx.Response.WriteAsync(systemPrompt); + } } diff --git a/deploy.sh b/deploy.sh index 5faa24f..41c21e4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -6,6 +6,7 @@ _hostname=$(hostname) if [ "$_hostname" = "stein2" ]; then cd /home/node/.openclaw/workspace/projects/gott + systemctl stop gott elif [ "$_hostname" = "meleki" ]; then cd ~/.openclaw/workspace/projects/gott else @@ -19,9 +20,9 @@ dotnet publish -c Release -o publish cp wwwroot/index.html publish/wwwroot/index.html if [ "$_hostname" = "stein2" ]; then - systemctl restart gott + systemctl start gott elif [ "$_hostname" = "meleki" ]; then ssh -o ConnectTimeout=5 meleki@192.168.100.200 "nohup sudo systemctl restart gott > /dev/null 2>&1 &" fi -echo "Service restarted" +echo "OK" diff --git a/gott.csproj b/gott.csproj index 00bc08f..150f10f 100755 --- a/gott.csproj +++ b/gott.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 ASP0015;IDE0017;IDE0028;IDE0130;IDE0305;IDE1006;SYSLIB1045