Fremde Laufzeiten: Claude Code und Befehl in der Sandbox, Egress-Proxy, Vorschlag statt Einsatz (#712)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7d6c2c9495
commit
367ea387f6
@@ -35,18 +35,29 @@ internal static class CommandLine
|
||||
/// Auswahldialog, ohne Fenster ist es ein Abbruch mit Meldung.</para>
|
||||
/// </summary>
|
||||
public static string? ReadInstancePath(IReadOnlyList<string>? args)
|
||||
=> ReadValue(args, InstanceArgument);
|
||||
|
||||
/// <summary>The value after <paramref name="option"/>, or <c>null</c>.</summary>
|
||||
public static string? ReadValue(IReadOnlyList<string>? args, string option)
|
||||
{
|
||||
if (args is null) return null;
|
||||
|
||||
for (var i = 0; i < args.Count - 1; i++)
|
||||
{
|
||||
if (string.Equals(args[i], InstanceArgument, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(args[i], option, StringComparison.OrdinalIgnoreCase))
|
||||
return args[i + 1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #712: The launcher in front of a program inside a sandbox — no application. Only as
|
||||
/// the first argument: everything after <c>--</c> belongs to the program.
|
||||
/// </summary>
|
||||
public static bool IsSandboxLaunch(IReadOnlyList<string>? args)
|
||||
=> args is { Count: > 0 } && args[0] == Core.Sandbox.SandboxLauncher.Argument;
|
||||
|
||||
/// <summary>#713: Only the stdio bridge to a running instance's MCP server — no application.</summary>
|
||||
public static bool IsMcpBridge(IReadOnlyList<string>? args)
|
||||
=> Has(args, Core.Mcp.McpStdioBridge.Argument);
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace ClawdDotNet.Desktop;
|
||||
|
||||
/// <summary>
|
||||
/// #713: <c>ClawdDotNet --mcp-bridge --instance <dir></c> — the instance's MCP server
|
||||
/// over stdio, for a runtime that starts its MCP servers as child processes.
|
||||
/// over stdio, for a runtime that starts its MCP servers as child processes. In a sandbox
|
||||
/// (#712), where there is no instance directory, <c>--socket <path></c> names the
|
||||
/// mounted MCP socket instead.
|
||||
///
|
||||
/// <para>No application is built here: no settings, no database, no engine. The bridge
|
||||
/// only carries messages to the running instance over its MCP socket; everything is
|
||||
@@ -19,10 +21,11 @@ internal static class McpBridgeRun
|
||||
|
||||
public static async Task<int> RunAsync(string[] args)
|
||||
{
|
||||
var socketPath = CommandLine.ReadValue(args, McpStdioBridge.SocketArgument);
|
||||
var instancePath = CommandLine.ReadInstancePath(args);
|
||||
if (string.IsNullOrWhiteSpace(instancePath) || !Directory.Exists(instancePath))
|
||||
if (socketPath is null && (string.IsNullOrWhiteSpace(instancePath) || !Directory.Exists(instancePath)))
|
||||
{
|
||||
await Console.Error.WriteLineAsync($"Expected {CommandLine.InstanceArgument} <instance directory>.");
|
||||
await Console.Error.WriteLineAsync($"Expected {CommandLine.InstanceArgument} <instance directory> or {McpStdioBridge.SocketArgument} <path>.");
|
||||
return ExitNoInstance;
|
||||
}
|
||||
|
||||
@@ -33,7 +36,9 @@ internal static class McpBridgeRun
|
||||
return ExitNoToken;
|
||||
}
|
||||
|
||||
using var client = InstanceEndpoint.CreateMcpClient(instancePath);
|
||||
using var client = socketPath is not null
|
||||
? InstanceEndpoint.CreateMcpClientForSocket(socketPath)
|
||||
: InstanceEndpoint.CreateMcpClient(instancePath!);
|
||||
using var stdin = new StreamReader(Console.OpenStandardInput());
|
||||
await using var stdout = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ internal static class Program
|
||||
/// ohne Bildschirmsitzung gäbe es keines (#528, Stufe 2).
|
||||
/// </remarks>
|
||||
public static int Main(string[] args)
|
||||
=> CommandLine.IsMcpBridge(args)
|
||||
=> CommandLine.IsSandboxLaunch(args)
|
||||
? Core.Sandbox.SandboxLauncher.RunAsync(args).GetAwaiter().GetResult()
|
||||
: CommandLine.IsMcpBridge(args)
|
||||
? McpBridgeRun.RunAsync(args).GetAwaiter().GetResult()
|
||||
: CommandLine.IsHeadless(args)
|
||||
? HeadlessRun.RunAsync(args).GetAwaiter().GetResult()
|
||||
|
||||
Reference in New Issue
Block a user