forked from admin/VolcanicAgenticCore
Claude Code 2.1.287 loads cc-plugin-* built-ins regardless of --setting-sources, which tripped the fail-closed init check. Disable every known built-in in --settings, and when init lists only built-ins that slipped through, disable them process-wide and replay the request once. Other plugins still fail closed.
46 lines
2.4 KiB
C#
46 lines
2.4 KiB
C#
namespace Volcanic.AgenticCore.Extensions.ClaudeCode;
|
|
|
|
/// <summary>A typed failure of the Claude Code transport. <see cref="Code"/> is stable and machine-readable.</summary>
|
|
public sealed class ClaudeCodeException(string code, string message, bool retryable = false, bool loginRequired = false) : Exception(message)
|
|
{
|
|
public string Code { get; } = code;
|
|
|
|
/// <summary>True when repeating the request from the unchanged context can succeed (a mid-stream interruption).</summary>
|
|
public bool Retryable { get; } = retryable;
|
|
|
|
/// <summary>True when the CLI's subscription session expired and <c>claude auth login</c> would clear the failure.</summary>
|
|
public bool LoginRequired { get; } = loginRequired;
|
|
|
|
/// <summary>
|
|
/// Built-in plugins Claude Code loaded although the request didn't expect them (and nothing else unexpected); the
|
|
/// provider disables them and replays the request once.
|
|
/// </summary>
|
|
public IReadOnlyList<string> UnexpectedBuiltinPlugins { get; init; } = [];
|
|
|
|
/// <summary>
|
|
/// The message the provider publishes: <c>[code] message</c>, except that a context overflow keeps its
|
|
/// <c>context_length_exceeded:</c> prefix intact because the core's retry policy keys on it.
|
|
/// </summary>
|
|
public string FormatForUser() => Code == Codes.ContextOverflow ? Message : $"[{Code}] {Message}";
|
|
|
|
public static class Codes
|
|
{
|
|
public const string ExecutableMissing = "executable_missing";
|
|
public const string Auth = "auth";
|
|
public const string ProtocolInit = "protocol_init";
|
|
public const string ProtocolStream = "protocol_stream";
|
|
public const string McpStartup = "mcp_startup";
|
|
public const string McpExecution = "mcp_execution";
|
|
public const string ToolUnknown = "tool_unknown";
|
|
public const string StreamInterrupted = "stream_interrupted";
|
|
public const string WorkingDirectory = "working_directory";
|
|
public const string ProcessExit = "process_exit";
|
|
public const string Timeout = "timeout";
|
|
public const string ContextOverflow = "context_overflow";
|
|
/// <summary>The context or tool declarations handed to the provider had a shape it cannot serialise.</summary>
|
|
public const string ContentShape = "content_shape";
|
|
/// <summary>An image could not be attached (type, encoding, size, count or path).</summary>
|
|
public const string Image = "image";
|
|
}
|
|
}
|