Commit Graph
18 Commits
Author SHA1 Message Date
MelekiandClaude Opus 4.8 17ba4840dd Hide subagent stream events in the CLI parser
When a panel member spawned a subagent via the Agent tool, the Claude CLI
emitted the subagent's internal steps as separate top-level messages
carrying parent_tool_use_id: tool_use blocks arrived as type:"assistant"
(no handler → dropped) and the matching tool_result as type:"user", which
created a nameless, label-less collapsible box in the frontend — both in
the live stream and in the persisted history (same segment source).

Skip any top-level event with a non-empty parent_tool_use_id at the single
stream JSON parser, so subagent internals never become CliStreamEvents.
This covers worker and panel-member paths at once. The Agent tool call
itself (parent_tool_use_id=null) stays visible, and the final result event
— which aggregates subagent tokens — carries no parent_tool_use_id, so the
token balance is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 17:47:41 +02:00
MelekiandClaude Opus 4.8 2501096e19 Fix MoA single-round and writable read-only panel members
Two bugs surfaced when driving the composite toggle (off→plan→fusion→moa)
in an all-CLI setup (no API keys):

1. MoA ran only 1 round instead of the configured 2. cycleCompositeMode
   fired the multiModelMode PATCH un-serialized and sendMessage did not
   await it, so a message sent right after toggling loaded the session
   before 'moa' was committed → the backend read the prior 'fusion' value
   → 1 round. Persisted totalLayers in the DB confirmed fusion (1) for all
   post-toggle chains. Serialize mode PATCHes into a promise chain (last
   click wins, in order) and await it in sendMessage/sendMessageDirect.

2. A read-only panel member could still write files. ClaudeCliService
   hard-coded --permission-mode acceptEdits, which auto-accepts Write/Edit
   regardless of --allowed-tools, so a member running with planMode=true
   (tools limited to Read/Glob/Grep) could still call write_file. Use
   'plan' when planMode is set; this also closes the same latent hole for
   regular plan-mode users on the shared CLI path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 16:55:25 +02:00
MelekiandClaude Opus 4.8 fe18fc324e Set CLI child working directory to the workspace
The Claude CLI child process inherited the gott server's CWD because
CreateCliStartInfo never set WorkingDirectory. On Linux systemd usually
sets WorkingDirectory= to the workspace, so it worked by accident; on
Windows the service starts from its install directory, so the CLI's own
built-in tools resolved relative patterns (e.g. Glob "Sources/**")
against the wrong directory and returned "No files found", while
absolute paths still worked. --add-dir only grants access, it does not
set the CWD.

Thread the workspace through ChatStreamingAsync -> RunCliStreamingAsync
-> CreateCliStartInfo and set psi.WorkingDirectory (guarded by
Directory.Exists). GetStatusAsync stays without a CWD.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 08:07:31 +02:00
MelekiandClaude Opus 4.7 3f913f14b5 Add per-agent reasoning effort
Opus 4.5+ and Sonnet 4.6+ support a new "effort" knob that controls how
much budget the model spends on thinking and tool calls. Plumb it through
end to end so each agent can pick its own level.

Storage & shape:
- New TEXT column agents.effort (default '') added via TryAddColumn.
- AgentRecord.Effort + INSERT/UPDATE in DatabaseService.Agents.cs.
- ChatContext.Effort + SubAgentContext.Effort so the value travels with the
  request alongside model and tool settings.

Agent editor:
- Effort dropdown above git-commit behavior in the agent form (low/medium/
  high/xhigh/max plus empty = "use default"). Always visible; on OpenAI
  providers the value is sent but silently ignored.
- agent-page.js load/save and AgentEndpoint create/update wired up.

Anthropic API path:
- StreamChat and RunNonStreamingToolLoop add output_config: { effort } when
  effort is set and not "high" – empty/null/"high" means "omit and let the
  API pick its default".
- Sub-agents (preparer/review/finalizer) get the parameter through
  RunAgentChat so each step uses its own agent's effort.

Anthropic CLI path:
- ClaudeCliService.ChatStreamingAsync takes an effort parameter and exports
  CLAUDE_CODE_EFFORT_LEVEL on the spawned process. Env-var beats the
  --effort flag because it also covers "max" and "ultracode".
- StreamChatViaCli, ChatNonStreamingViaCli, RunSubAgentViaCli, and the
  ChatEndpoint anthropic branches all hand the value through.

ARCHITECTURE.md / ARCHITECTURE_QUICK.md updated with the new field.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 21:33:32 +02:00
Meleki 1ece62ce8c feat(cache): 1h-Prompt-Cache-TTL für API und Claude CLI
Anthropic hat Anfang März 2026 die Default-Cache-TTL stillschweigend
von 1h auf 5min gesenkt. Bei Sessions mit Pausen >5min wird der Cache
jedes Mal neu geschrieben (teuer). Dieser Commit aktiviert die
extended 1h-TTL über beide Pfade.

API-Pfad (AnthropicService):
- Beta-Header "extended-cache-ttl-2025-04-11" hinzugefügt
- Falsches Top-Level cache_control (Root-Level wurde ignoriert) entfernt
- Neue Helper ApplyCacheControlToLast() setzt cache_control idempotent
  auf das letzte Element via JSON-Roundtrip zu Dictionary
- 2 Cache-Breakpoints pro Iteration:
  * Letztes Tool (cached gesamten Tool-Block)
  * Letzter System-Prompt-Block (cached System-Prompt)
- Sub-Agent-Loop (Preparer/Review/Finalizer): String-System-Prompt wird
  bei Bedarf in Block-Form mit cache_control konvertiert

CLI-Pfad (ClaudeCliService):
- Env-Var ENABLE_PROMPT_CACHING_1H=1 für jeden CLI-Child-Prozess gesetzt
  (offizieller Opt-in seit Claude CLI 2.1.108, gilt für API-Key,
  Bedrock, Vertex, Foundry)
2026-05-13 06:46:26 +02:00
MelekiandClaude Opus 4.7 e87d7c4eec feat(debug): Encoding-Diagnose für Claude CLI (opt-in via Env-Var)
Aktivierung: Umgebungsvariable GOTT_CLI_DEBUG_BYTES=1

Im Debug-Modus wird ein TeeReadStream zwischengeschaltet, der alle rohen Bytes
vom Claude-CLI-Prozess in eine .bin-Datei schreibt (vor dem UTF-8-Decode).
Zusätzlich wird jedes Vorkommen von U+FFFD im decoded Output mit Position,
Kontext und FFFD-Counter in eine .log-Datei protokolliert.

Logs landen in data/cli-debug/cli-stdout-{timestamp}.{bin,log}.

So können wir das intermittierende �-Problem auf Windows beweisbar einkreisen:
- Wenn .bin valide UTF-8-Bytes enthält aber .log FFFD-Treffer hat → unser Decoder
- Wenn .bin bereits invalide Bytes (CP1252) enthält → Claude-CLI/Node ist schuld
- Wenn .bin bereits EF BF BD enthält → Anthropic-Server schickt schon kaputt

Im Default-Modus (Env-Var nicht gesetzt) bleibt der ursprüngliche Default-Reader
aktiv – kein zusätzlicher Disk-IO im Normalbetrieb.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 16:29:22 +02:00
MelekiandClaude Opus 4.7 01346a952e Revert: UTF-8-Encoding-Fixes für Claude CLI auf Windows
Setzt die folgenden Commits zurück, da sie das Problem nicht behoben haben:
- e75c437 fix(encoding): UTF-8 prozess-global + 16-KB-StreamReader für CLI-Output
- bfd550e fix: UTF-8-Encoding gehärtet (SSE-Reader + CLI-Workspace)
- 32aad7f fix: UTF-8-Encoding für Claude CLI auf Windows erzwingen

Trotz cmd.exe-Wrapper mit chcp 65001, explizitem UTF-8-StreamReader (16 KB Buffer,
ohne BOM-Detection), Console.OutputEncoding global auf UTF-8 und LANG/LC_ALL/
PYTHONIOENCODING-Env-Vars treten weiterhin Replacement-Chars (�) für Umlaute
und Em-Dashes auf Windows auf. Der Bug muss separat per Diagnose-Logging
nachgestellt werden.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 16:27:16 +02:00
MelekiandClaude Opus 4.7 e75c4370fd fix(encoding): UTF-8 prozess-global + 16-KB-StreamReader für CLI-Output
Zwei zusätzliche Härtungen gegen intermittierende �-Replacement-Chars
(Umlaute, Em-Dash) im CLI-Output unter Windows:

- Program.cs: Auf Windows Console.OutputEncoding/InputEncoding = UTF-8
  setzen. Wirkt prozess-global via Win32 SetConsoleOutputCP/SetConsoleCP
  und wird von direkt gestarteten Child-Prozessen geerbt – ergänzt den
  bestehenden chcp-65001-cmd-Wrapper. In try/catch, falls als Windows-
  Dienst ohne Console gestartet.
- ClaudeCliService.cs: stdout-Lesen mit eigenem StreamReader (16-KB-
  Buffer, explizit UTF-8 ohne BOM-Detection) statt Default-Reader (1 KB).
  Verhindert, dass bei gefragmentierten Pipe-Reads Multi-Byte-UTF-8-
  Sequenzen über Buffer-Grenzen aufgesplittet werden und der Decoder
  den State verliert.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 16:12:24 +02:00
MelekiandClaude Opus 4.7 bfd550e090 fix: UTF-8-Encoding gehärtet (SSE-Reader + CLI-Workspace)
- AnthropicService.Streaming.cs + OpenAiService.cs: SSE-StreamReader nutzt
  jetzt expliziten UTF-8-Encoder mit 16-KB-Buffer (statt default 1 KB) und
  ohne BOM-Detection. Verhindert intermittierende Replacement-Chars (�),
  die entstehen können, wenn Multi-Byte-UTF-8-Sequenzen ungünstig über die
  Read-Boundary eines NetworkStreams gesplittet werden.
- ClaudeCliService.cs: cmd.exe-Wrapper jetzt mit /D (AutoRun-Skripte aus
  Registry deaktivieren) und WorkingDirectory wird auf den Session-Workspace
  gesetzt. Vorher erbte der Child-Prozess das CWD von gott (bei Windows-
  Diensten C:\WINDOWS\system32).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 12:08:56 +02:00
MelekiandClaude Opus 4.7 32aad7feef fix: UTF-8-Encoding für Claude CLI auf Windows erzwingen
Auf Windows kam es sporadisch zu Replacement-Chars (�) für Umlaute
und Em-Dash, weil claude.exe Output mit CP1252/CP850 schreiben konnte.
Lösung: CLI über cmd.exe wrappen und Codepage 65001 (UTF-8) erzwingen,
zusätzlich LANG/LC_ALL/PYTHONIOENCODING auf UTF-8 setzen.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 11:32:45 +02:00
MelekiandClaude Opus 4.6 be6d33691a fix: CLI-Prozess bei Abbruch zuverlässig beenden (Kill on Cancel)
Process.Dispose() gibt nur den Handle frei, killt aber nicht den Prozess.
Jetzt wird per CancellationToken.Register() der gesamte Prozessbaum
(entireProcessTree: true) sofort beendet wenn der User auf Stoppen klickt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 11:52:41 +01:00
MelekiandClaude Opus 4.6 1101bb83a0 fix: CLI-Pfad-Suche für Windows-Dienst verbessern + CLAUDE_CLI_PATH
- CLAUDE_CLI_PATH Umgebungsvariable als höchste Priorität bei CLI-Suche
- CreateCliStartInfo() Helper dedupliziert ProcessStartInfo-Erstellung
- .cmd-Wrapper-Logik entfernt (nicht benötigt)
- PATH-Suche priorisiert .exe für Windows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 17:33:16 +01:00
MelekiandClaude Opus 4.6 500c00f948 feat: Unity MCP-Server Integration pro Session
Sessions können jetzt einen Unity MCP-Server (URL + Token) konfigurieren.
Die CLI erhält automatisch die MCP-Config mit korrektem Transport-Typ
(URL-basierte Erkennung: /sse → SSE, sonst HTTP für streamableHttp).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 18:34:47 +01:00
MelekiandClaude Opus 4.6 f3069cedf7 fix: CLI-Zugriff auf Temp-Bilder auch ohne Workspace
Read-Tool wird jetzt immer erlaubt (nicht nur mit Workspace), und
/tmp/gott-cli-images/ wird als --add-dir hinzugefügt, damit gesendete
Bilder von der CLI gelesen werden können.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 16:53:59 +01:00
MelekiandClaude Opus 4.6 3e0a69e7a4 feat: MCP-Tools ask_user_choice + memory_read/write/list, Text-Marker entfernt
MCP-Server erweitert um ask_user_choice (Long-Poll), memory_read, memory_write
und memory_list Tools. MCP-Config wird jetzt immer generiert (nicht nur bei
Remote-Verbindung). InternalEndpoint um PendingChoices + choice-respond Endpoint
ergänzt. Frontend differenziert CLI-Modus (choice-respond API) vs. API-Modus.
Gesamter :::ASK_USER_CHOICE::: Text-Marker-Mechanismus aus ClaudeCliService,
AnthropicService, markdown.js und stream-ui.js entfernt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 09:54:30 +01:00
MelekiandClaude Opus 4.6 3b068a7866 feat: MCP-Server für remote_execute + Inline-Choice-UI
- Python MCP-Server (stdio, JSON-RPC 2.0) für remote_execute via Claude CLI
- Interner API-Endpoint /api/internal/remote-execute mit Token-Auth
- MCP-Config wird automatisch generiert wenn Remote-Verbindung vorhanden
- Auth-Middleware: /api/internal/ von Auth ausgenommen
- Frontend: :::ASK_USER_CHOICE::: Blöcke als interaktive Buttons rendern
- Streaming: Unvollständige Choice-Blöcke werden während des Streams versteckt
- tool-ui.js: MCP-Tool-Namen generisch normalisieren (mcp__server__tool → tool)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 09:00:50 +01:00
MelekiandClaude Opus 4.6 6d16d00290 feat: CLI-Streaming – korrekte Tool-Darstellung, Reihenfolge und Error-Handling
- Tool-Namen/Inputs von CLI-Konvention auf gott-Konvention mappen (Edit→edit_file, file_path→path etc.)
- Text vor Tool-Use in DB flushen für korrekte Reihenfolge (statt alles am Ende als Blob)
- lineBuffer in ClaudeCliService vor Tool-Start und bei Text-Block-Ende flushen
- ToolResult-Events parsen und in DB speichern (CLI sendet diese als type:"user" Messages)
- Errors in DB speichern und als SSE-Event senden
- Bild-Attachments als Temp-Dateien für CLI bereitstellen (Read-Tool kann sie lesen)
- Frontend: tool_result Handler, Tool-Name-Normalisierung, appendToolResult()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 06:48:10 +01:00
MelekiandClaude Opus 4.6 4af9430466 feat: Claude CLI Pfad mit ask_user_choice, Plan-Modus und Tool-Konfiguration
- ClaudeCliService: Marker-basierte ask_user_choice Erkennung im Stream-Parser
- AnthropicService: StreamChatViaCli mit allowUserChoice, planMode, webSearch
- BuildHistoryContext erweitert für tool_use/tool_result (Choice-Antworten)
- Tool-Use Records werden in DB persistiert (Poll-Kompatibilität)
- CLI Tools konfigurierbar: Workspace/Plan-Modus/WebSearch/kein Workspace
- OAuth DB-Felder für zukünftige Token-Verwaltung

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 22:25:39 +01:00