Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .claude/skills/tryagi-openai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dnx tryAGI.OpenAI.CLI <group> --help

| Group | Operations | Summary |
|-------|-----------:|---------|
| `agent` | 37 | |
| `agent` | 47 | |
| `assistant` | 18 | Build Assistants that can call models and use tools. |
| `audio` | 10 | Turn audio into text or text into audio. |
| `audit-log` | 1 | List user actions and configuration changes within this organization. |
Expand Down
10 changes: 10 additions & 0 deletions .claude/skills/tryagi-openai/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ Full per-command reference derived from the OpenAPI spec. For the short overview
| Command | Route | Description |
|---------|-------|-------------|
| `create-agent` | `POST /agents` | Create an agent |
| `create-agent-automation` | `POST /agents/automations` | Create an automation |
| `create-agent-automation-invocation` | `POST /agents/automations/{automation_id}/invocations` | Invoke an automation |
| `create-agent-environment` | `POST /agents/environments` | Create an agent environment |
| `create-agent-environment-file` | `POST /agents/environments/{environment_id}/files` | Write an agent environment file |
| `create-agent-environment-template` | `POST /agents/environments/templates` | Create an agent environment template |
| `create-agent-session` | `POST /agents/sessions` | Create an agent session |
| `create-agent-session-events` | `POST /agents/sessions/{session_id}/events` | Create agent session input events |
| `delete-agent` | `DELETE /agents/{agent_id}` | Delete an agent |
| `delete-agent-automation` | `DELETE /agents/automations/{automation_id}` | Delete an automation |
| `delete-agent-environment-template` | `DELETE /agents/environments/templates/{environment_template_id}` | Delete an agent environment template |
| `delete-agent-session` | `DELETE /agents/sessions/{session_id}` | Delete an agent session |
| `delete-agent-session-artifact` | `DELETE /agents/sessions/{session_id}/artifacts/{artifact_id}` | Delete an agent session artifact |
| `get-agent-automation` | `GET /agents/automations/{automation_id}` | Get an automation |
| `get-agent-automation-invocation` | `GET /agents/automations/{automation_id}/invocations/{invocation_id}` | Get an automation invocation |
| `list-agent-automation-invocations` | `GET /agents/automations/{automation_id}/invocations` | List automation invocations |
| `list-agent-automations` | `GET /agents/automations` | List automations |
| `list-agent-environment-files` | `GET /agents/environments/{environment_id}/files` | List agent environment files |
| `list-agent-environment-templates` | `GET /agents/environments/templates` | List agent environment templates |
| `list-agent-environments` | `GET /agents/environments` | List agent environments |
Expand All @@ -31,6 +38,8 @@ Full per-command reference derived from the OpenAPI spec. For the short overview
| `list-agent-session-turns` | `GET /agents/sessions/{session_id}/turns` | List agent session turns |
| `list-agent-sessions` | `GET /agents/sessions` | List agent sessions |
| `list-agents` | `GET /agents` | List agents |
| `pause-agent-automation` | `POST /agents/automations/{automation_id}/pause` | Pause an automation |
| `resume-agent-automation` | `POST /agents/automations/{automation_id}/resume` | Resume an automation |
| `retrieve-agent` | `GET /agents/{agent_id}` | Retrieve an agent |
| `retrieve-agent-environment` | `GET /agents/environments/{environment_id}` | Retrieve an agent environment |
| `retrieve-agent-environment-template` | `GET /agents/environments/templates/{environment_template_id}` | Retrieve an agent environment template |
Expand All @@ -41,6 +50,7 @@ Full per-command reference derived from the OpenAPI spec. For the short overview
| `retrieve-agent-session-subagent-turn` | `GET /agents/sessions/{session_id}/subagents/{subagent_id}/turns/{turn_id}` | Retrieve a subagent turn |
| `retrieve-agent-session-turn` | `GET /agents/sessions/{session_id}/turns/{turn_id}` | Retrieve an agent session turn |
| `update-agent` | `POST /agents/{agent_id}` | Update an agent |
| `update-agent-automation` | `POST /agents/automations/{automation_id}` | Update an automation |
| `update-agent-environment-template` | `POST /agents/environments/templates/{environment_template_id}` | Update an agent environment template |
| `update-agent-session` | `POST /agents/sessions/{session_id}` | Update an agent session |

Expand Down
123 changes: 60 additions & 63 deletions src/libs/tryAGI.OpenAI.CLI/GeneratedApi/CliRuntime.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@ public static Command Create()
{
var command = new Command(@"agents", @"Agents endpoint commands.");
command.Subcommands.Add(AgentsCreateAgentCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentAutomationCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentAutomationInvocationCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentEnvironmentCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentEnvironmentFileCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentEnvironmentTemplateCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentSessionCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentSessionAsStreamCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentSessionEventsCommandApiCommand.Create());
command.Subcommands.Add(AgentsDeleteAgentCommandApiCommand.Create());
command.Subcommands.Add(AgentsDeleteAgentAutomationCommandApiCommand.Create());
command.Subcommands.Add(AgentsDeleteAgentEnvironmentTemplateCommandApiCommand.Create());
command.Subcommands.Add(AgentsDeleteAgentSessionCommandApiCommand.Create());
command.Subcommands.Add(AgentsDeleteAgentSessionArtifactCommandApiCommand.Create());
command.Subcommands.Add(AgentsGetAgentAutomationCommandApiCommand.Create());
command.Subcommands.Add(AgentsGetAgentAutomationInvocationCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentAutomationInvocationsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentAutomationsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentEnvironmentFilesCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentEnvironmentTemplatesCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentEnvironmentsCommandApiCommand.Create());
Expand All @@ -37,6 +44,8 @@ public static Command Create()
command.Subcommands.Add(AgentsListAgentSessionTurnsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentSessionsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentsCommandApiCommand.Create());
command.Subcommands.Add(AgentsPauseAgentAutomationCommandApiCommand.Create());
command.Subcommands.Add(AgentsResumeAgentAutomationCommandApiCommand.Create());
command.Subcommands.Add(AgentsRetrieveAgentCommandApiCommand.Create());
command.Subcommands.Add(AgentsRetrieveAgentEnvironmentCommandApiCommand.Create());
command.Subcommands.Add(AgentsRetrieveAgentEnvironmentTemplateCommandApiCommand.Create());
Expand All @@ -47,6 +56,7 @@ public static Command Create()
command.Subcommands.Add(AgentsRetrieveAgentSessionSubagentTurnCommandApiCommand.Create());
command.Subcommands.Add(AgentsRetrieveAgentSessionTurnCommandApiCommand.Create());
command.Subcommands.Add(AgentsUpdateAgentCommandApiCommand.Create());
command.Subcommands.Add(AgentsUpdateAgentAutomationCommandApiCommand.Create());
command.Subcommands.Add(AgentsUpdateAgentEnvironmentTemplateCommandApiCommand.Create());
command.Subcommands.Add(AgentsUpdateAgentSessionCommandApiCommand.Create());
CustomizeCommand(ref command);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class AgentsCreateAgentAutomationCommandApiCommand
{

private static Option<string?> Input { get; } = new(@"--input")
{
Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.",
};

private static Option<string?> RequestJson { get; } = new(@"--request-json")
{
Description = "Request body as JSON.",
Hidden = true,
};

private static Option<string?> RequestFile { get; } = new(@"--request-file")
{
Description = "Path to a JSON request file, or '-' for stdin.",
Hidden = true,
};

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.AutomationResource 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::tryAGI.OpenAI.AutomationResource value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"create-agent-automation", @"Create an automation
Saves an active automation without invoking it immediately.");

command.Options.Add(Input);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
command.Validators.Add(result =>
{
var hasInput = result.GetResult(Input) is not null;
var hasRequestJson = result.GetResult(RequestJson) is not null;
var hasRequestFile = result.GetResult(RequestFile) is not null;
var specifiedCount = (hasInput ? 1 : 0) + (hasRequestJson ? 1 : 0) + (hasRequestFile ? 1 : 0);
if (specifiedCount != 1)
{
result.AddError(@"Specify exactly one of --input, --request-json, or --request-file.");
}
});

command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{

var request = await CliRuntime.ReadRequestAsync<global::tryAGI.OpenAI.CreateAutomationParams>(
parseResult,
Input,
RequestJson,
RequestFile,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.Agents.CreateAgentAutomationAsync(

request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);


await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class AgentsCreateAgentAutomationInvocationCommandApiCommand
{
private static Argument<string> AutomationId { get; } = new(
name: @"automation-id")
{
Description = @"",
};
private static Option<bool> Wait { get; } = new("--wait")
{
Description = "Poll the generated wait helper until the resource reaches a terminal state.",
};

private static Option<string> PollInterval { get; } = new("--poll-interval")
{
Description = "Polling interval, for example 250ms, 2s, 30m, or 01:00:00.",
DefaultValueFactory = _ => "2s",
};

private static Option<string> WaitTimeout { get; } = new("--wait-timeout")
{
Description = "Maximum time to wait before timing out, for example 30m or 00:30:00.",
DefaultValueFactory = _ => "30m",
};

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.AutomationInvocationResource 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::tryAGI.OpenAI.AutomationInvocationResource value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"create-agent-automation-invocation", @"Invoke an automation
Queues a manual delivery without changing the saved schedule.");
command.Arguments.Add(AutomationId);

command.Options.Add(Wait);
command.Options.Add(PollInterval);
command.Options.Add(WaitTimeout);
command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var automationId = parseResult.GetRequiredValue(AutomationId); var wait = parseResult.GetValue(Wait);
var pollInterval = wait ? CliRuntime.ParseDuration(parseResult.GetRequiredValue(PollInterval), PollInterval.Name) : default;
var waitTimeout = wait ? CliRuntime.ParseDuration(parseResult.GetRequiredValue(WaitTimeout), WaitTimeout.Name) : default;
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);

if (wait)
{
var createResponse = await client.Agents.CreateAgentAutomationInvocationAsync(
automationId: automationId,
cancellationToken: cancellationToken).ConfigureAwait(false);
var resourceId = global::System.Convert.ToString(
createResponse.Id,
global::System.Globalization.CultureInfo.InvariantCulture);
if (string.IsNullOrWhiteSpace(resourceId))
{
throw new CliException("The create response did not contain a job id.");
}

var waitResponse = await CliRuntime.PollUntilTerminalAsync(
fetchAsync: token => client.Agents.GetAgentAutomationInvocationAsync(
automationId: automationId,
invocationId: resourceId,
cancellationToken: token),
pollInterval: pollInterval,
waitTimeout: waitTimeout,
context: global::tryAGI.OpenAI.SourceGenerationContext.Default,
cancellationToken: cancellationToken).ConfigureAwait(false);
await CliRuntime.WriteResponseAsync(
parseResult,
waitResponse,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
cancellationToken: cancellationToken).ConfigureAwait(false);
return;
}

var response = await client.Agents.CreateAgentAutomationInvocationAsync(
automationId: automationId,
cancellationToken: cancellationToken).ConfigureAwait(false);


await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Loading
Loading