fix(runner): substitute acceptEdits for haiku's silent auto-mode downgrade, fail permission-denial-only runs
This commit is contained in:
@@ -16,6 +16,7 @@ public sealed class StreamResult
|
||||
public string? ResultSubtype { get; set; }
|
||||
public string? TerminalReason { get; set; }
|
||||
public IReadOnlyList<string> Errors { get; set; } = Array.Empty<string>();
|
||||
public IReadOnlyList<string> PermissionDenials { get; set; } = Array.Empty<string>();
|
||||
}
|
||||
|
||||
public sealed class StreamAnalyzer
|
||||
@@ -31,6 +32,7 @@ public sealed class StreamAnalyzer
|
||||
private string? _resultSubtype;
|
||||
private string? _terminalReason;
|
||||
private readonly List<string> _errors = new();
|
||||
private readonly List<string> _permissionDenials = new();
|
||||
private const string BlockedPrefix = "CLAUDEDO_BLOCKED:";
|
||||
|
||||
public void ProcessLine(string ndjsonLine)
|
||||
@@ -65,6 +67,17 @@ public sealed class StreamAnalyzer
|
||||
&& !string.IsNullOrEmpty(errorText))
|
||||
_errors.Add(errorText);
|
||||
}
|
||||
// A CLI-level permission-mode failure (e.g. haiku silently downgrading
|
||||
// "auto" to the interactive "default") still reports is_error:false — the
|
||||
// denials only show up here, on the result event.
|
||||
if (root.TryGetProperty("permission_denials", out var denialsProp)
|
||||
&& denialsProp.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
foreach (var denial in denialsProp.EnumerateArray())
|
||||
if (denial.TryGetProperty("tool_name", out var toolNameProp)
|
||||
&& toolNameProp.GetString() is { } toolName && !string.IsNullOrEmpty(toolName))
|
||||
_permissionDenials.Add(toolName);
|
||||
}
|
||||
// Authoritative token totals live on the result event.
|
||||
if (root.TryGetProperty("usage", out var resultUsage))
|
||||
{
|
||||
@@ -107,6 +120,7 @@ public sealed class StreamAnalyzer
|
||||
ResultSubtype = _resultSubtype,
|
||||
TerminalReason = _terminalReason,
|
||||
Errors = _errors,
|
||||
PermissionDenials = _permissionDenials,
|
||||
};
|
||||
|
||||
private string? FallbackResult()
|
||||
|
||||
Reference in New Issue
Block a user