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
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` | 35 | |
| `agent` | 37 | |
| `assistant` | 18 | Build Assistants that can call models and use tools. |
| `audio` | 9 | Turn audio into text or text into audio. |
| `audit-log` | 1 | List user actions and configuration changes within this organization. |
Expand Down
2 changes: 2 additions & 0 deletions .claude/skills/tryagi-openai/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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-environment` | `POST /agents/environments` | Create an agent environment |
| `create-agent-environment-file` | `POST /agents/environments/{environment_id}/files` | Create 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 |
Expand All @@ -17,6 +18,7 @@ Full per-command reference derived from the OpenAPI spec. For the short overview
| `delete-agent-session-artifact` | `DELETE /agents/sessions/{session_id}/artifacts/{artifact_id}` | Delete an agent session artifact |
| `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 |
| `list-agent-session-artifacts` | `GET /agents/sessions/{session_id}/artifacts` | List agent session artifacts |
| `list-agent-session-events` | `GET /agents/sessions/{session_id}/events` | Stream agent session events |
| `list-agent-session-items` | `GET /agents/sessions/{session_id}/items` | List agent session items |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static Command Create()
{
var command = new Command(@"agents", @"Agents endpoint commands.");
command.Subcommands.Add(AgentsCreateAgentCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentEnvironmentCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentEnvironmentFileCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentEnvironmentTemplateCommandApiCommand.Create());
command.Subcommands.Add(AgentsCreateAgentSessionCommandApiCommand.Create());
Expand All @@ -23,6 +24,7 @@ public static Command Create()
command.Subcommands.Add(AgentsDeleteAgentSessionArtifactCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentEnvironmentFilesCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentEnvironmentTemplatesCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentEnvironmentsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentSessionArtifactsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentSessionEventsCommandApiCommand.Create());
command.Subcommands.Add(AgentsListAgentSessionItemsCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class AgentsCreateAgentEnvironmentCommandApiCommand
{
private static Option<string?> IdempotencyKey { get; } = new(
name: @"--idempotency-key")
{
Description = @"Deduplicates creation for 24 hours within the authenticated organization, project, and creator. Retry the same JSON parameters with the same key to retrieve the original environment in its current state. Different parameters or an incomplete hosted creation return 409. Deleted environments are not recreated. After retention expires, the key may create a new environment. Without this header, each request creates a new environment.",
};

private static Option<global::tryAGI.OpenAI.CreateEnvironmentParamOpenaiHosted> Environment { get; } = new(
name: @"--environment")
{
Description = @"The required hosting type and its configuration.",
Required = true,
};

private static Option<global::System.Collections.Generic.IList<string>?> VaultIds { get; } = new(
name: @"--vault-ids")
{
Description = @"The IDs of up to 10 vaults made available to an OpenAI-hosted environment.",
};
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 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.PublicEnvironmentResource 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.PublicEnvironmentResource 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-environment", @"Create an agent environment
Creates an OpenAI-hosted environment before creating a session. Requires access to the prewarming beta.");
command.Options.Add(IdempotencyKey);
command.Options.Add(Environment);
command.Options.Add(VaultIds);
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 at most one of --input, --request-json, or --request-file.");
}
});
command.Options.Add(Wait);
command.Options.Add(PollInterval);
command.Options.Add(WaitTimeout);
command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync<global::tryAGI.OpenAI.CreateAgentEnvironmentParams>(
parseResult,
Input,
RequestJson,
RequestFile,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var idempotencyKey = parseResult.GetValue(IdempotencyKey);
var environment = parseResult.GetRequiredValue(Environment);
var vaultIds = CliRuntime.WasSpecified(parseResult, VaultIds) ? parseResult.GetValue(VaultIds) : (__requestBase is { } __VaultIdsBaseValue ? __VaultIdsBaseValue.VaultIds : default); 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.CreateAgentEnvironmentAsync(
idempotencyKey: idempotencyKey,
environment: environment,
vaultIds: vaultIds,
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.RetrieveAgentEnvironmentAsync(
environmentId: 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.CreateAgentEnvironmentAsync(
idempotencyKey: idempotencyKey,
environment: environment,
vaultIds: vaultIds,
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,102 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class AgentsListAgentEnvironmentsCommandApiCommand
{
private static Option<long?> Limit { get; } = new(
name: @"--limit")
{
Description = @"The maximum number of resources to return, between 1 and 100. Defaults to 20.",
};

private static Option<global::tryAGI.OpenAI.ListOrderParam?> Order { get; } = new(
name: @"--order")
{
Description = @"The order in which resources are returned. Defaults to `desc`.",
};

private static Option<string?> After { get; } = new(
name: @"--after")
{
Description = @"Return resources after this resource ID in the selected order.",
};

private static Option<global::tryAGI.OpenAI.EnvironmentTypeParam?> Type { get; } = new(
name: @"--type")
{
Description = @"The hosting type to list. Defaults to `openai_hosted`.",
};

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.AgentEnvironmentListResource 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.AgentEnvironmentListResource 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 ?? @"list-agent-environments", @"List agent environments
Lists OpenAI-hosted environments owned by the authenticated principal. Requires access to the prewarming beta.");
command.Options.Add(Limit);
command.Options.Add(Order);
command.Options.Add(After);
command.Options.Add(Type);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var limit = parseResult.GetValue(Limit);
var order = parseResult.GetValue(Order);
var after = parseResult.GetValue(After);
var type = parseResult.GetValue(Type);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.Agents.ListAgentEnvironmentsAsync(
limit: limit,
order: order,
after: after,
type: type,
cancellationToken: cancellationToken).ConfigureAwait(false);


if (!await CliRuntime.TryWriteOutputDirectoryAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
@"Data",
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
Expand Up @@ -17,7 +17,7 @@ internal static partial class DecisionsCreateDecisionCommandApiCommand
private static Option<global::tryAGI.OpenAI.DecisionInput> InputOption { get; } = new(
name: @"--input")
{
Description = @"The text or images to evaluate for every question. Provide a text string or user messages containing text and inline images. Images must be inline data URLs; at most 128 images are allowed across all messages in one request. External URLs, files, audio, tools, and item references are not supported.",
Description = @"The text or images to evaluate for every question. Provide a text string or user messages containing text and images. Images can be base64 data URLs or publicly accessible HTTP(S) URLs; at most 128 images are allowed across all messages in one request. Files, audio, tools, and item references are not supported.",
Required = true,
};

Expand Down Expand Up @@ -77,7 +77,7 @@ public static Command Create(string? commandName = null)
var command = new Command(commandName ?? @"create-decision", @"Create a decision
Use this endpoint to ask classification or scoring questions about the same input. You’ll get the answers back in the order you asked the questions.

For text, you can pass a string. You can also send user messages containing `input_text` and `input_image` parts, with up to 128 images per request. Images must be data URLs; external URLs and file IDs aren’t accepted. Other message roles, function calls, files, audio, and item references aren’t supported.
For text, you can pass a string. You can also send user messages containing `input_text` and `input_image` parts, with up to 128 images per request. Images can be base64 data URLs or publicly accessible HTTP(S) URLs. File IDs aren’t accepted. Other message roles, function calls, files, audio, and item references aren’t supported.

Sometimes a question returns a refusal instead of an answer. The result has type `refusal` and includes the question’s name, or `null` if you didn’t give it one.");
command.Options.Add(Model);
Expand Down
Loading
Loading