Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Browserbase.CLI.Commands;

internal static partial class AgentRunsStopCommandApiCommand
{
private static Argument<string> RunId { get; } = new(
name: @"run-id")
{
Description = @"The run ID.",
};

private static string FormatResponse(ParseResult parseResult, global::Browserbase.AgentRun value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}

var hints = new Dictionary<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::Browserbase.AgentRun value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"agent-runs-stop", @"Stop a Run
Request that an in-progress run stop. The run winds down and transitions to `STOPPED`. Stopping a run that has already finished returns a conflict.");
command.Arguments.Add(RunId);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var runId = parseResult.GetRequiredValue(RunId);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.AgentRunsStopAsync(
runId: runId,
cancellationToken: cancellationToken).ConfigureAwait(false);


await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::Browserbase.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static Command Create()
command.Subcommands.Add(AgentRunsGetCommandApiCommand.Create());
command.Subcommands.Add(AgentRunsListCommandApiCommand.Create());
command.Subcommands.Add(AgentRunsMessagesCommandApiCommand.Create());
command.Subcommands.Add(AgentRunsStopCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateCommandApiCommand.Create());
command.Subcommands.Add(AgentsDeleteCommandApiCommand.Create());
command.Subcommands.Add(AgentsGetCommandApiCommand.Create());
Expand Down
Loading