Documentation
¶
Index ¶
- func CheckQuota(cli string, model string) float64
- func GetCLIQuota(ctx context.Context, cli string) (map[string][]types.ModelUsage, error)
- func GetModelContextWindow(cli, model string) int
- func GetQuota(ctx context.Context) (map[string][]types.ModelUsage, error)
- func GetRegisteredCLIs() []string
- func GetSandboxSpec(cli string) types.SandboxSpec
- func GetSupportedCLIsAndModels() map[string][]string
- func HasModelVariant(cli, model string) bool
- func IsKnownModel(cli, model string) bool
- func LookupContextWindow(model string) (limit int, known bool)
- func MatchesModel(cli, model, known string) bool
- func ModelCandidates(cli, model string) []string
- func SetAccountUsageProvider(p AccountUsageProvider)
- func SetClients(c map[string]types.CLIClient)
- func SetQueryRunner(r QueryRunner)
- func ValidateAgySetup() error
- func ValidateClaudeSetup() error
- func ValidateOpencodeSetup() error
- func ValidateSimplestSetup() error
- type AccountUsage
- type AccountUsageProvider
- type FakeClient
- func (c *FakeClient) AuthDirectory(home string) string
- func (c *FakeClient) AuthFiles(home string) []string
- func (c *FakeClient) ExtraArgs() []string
- func (c *FakeClient) ExtraEnv(home string) map[string]string
- func (c *FakeClient) Models(ctx context.Context, opts types.UsageOptions) ([]string, error)
- func (c *FakeClient) MountDirectories(home string) []string
- func (c *FakeClient) Prompt(ctx context.Context, prompt string, opts types.PromptOptions) (*types.PromptResult, error)
- func (c *FakeClient) SkillsMountPath(home string) string
- func (c *FakeClient) SystemPromptHeader() string
- func (c *FakeClient) SystemPromptPeerHeader() string
- func (c *FakeClient) Usage(ctx context.Context, opts types.UsageOptions) ([]types.ModelUsage, error)
- type QueryRunner
- type QuotaCheck
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckQuota ¶
CheckQuota returns the headline remaining quota fraction of a target.
func GetCLIQuota ¶
GetCLIQuota returns the quota of a single CLI keyed by its name, without the sandbox query runner. It backs `aw usage --cli`.
func GetModelContextWindow ¶
GetModelContextWindow resolves the context window for a model given the CLI type. It iterates through ModelCandidates(cli, model) and returns the first known limit. For simplest, the user's simplest config is consulted (same source as `aw models`) so custom models pick up their configured contextWindow without hardcoding. If none are known, it returns types.DefaultContextWindow (1M).
func GetRegisteredCLIs ¶
func GetRegisteredCLIs() []string
GetRegisteredCLIs returns all registered CLI names.
func GetSandboxSpec ¶
func GetSandboxSpec(cli string) types.SandboxSpec
GetSandboxSpec returns the SandboxSpec for the given CLI if implemented, or nil.
func HasModelVariant ¶
HasModelVariant reports whether the model string carries a recognized variant (thinking level) suffix for the given CLI.
func IsKnownModel ¶
IsKnownModel reports whether the model is cataloged for the given CLI, accounting for variant suffixes (e.g. "zai-coding-plan/glm-5.3/low" or "gemini-3.7-flash-low"). For simplest, models defined in the user's simplest config (provider/id or bare id) are also considered known, because the simplest runtime uses model.ContextWindow from that config instead of the hardcoded table.
func LookupContextWindow ¶
LookupContextWindow delegates directly to types.LookupContextWindow.
func MatchesModel ¶
MatchesModel reports whether the requested model matches a known model name, accounting for opencode/agy/simplest variant suffixes (e.g. "provider/model/low" or "gemini-3.7-flash-low" matches the known model "provider/model" or "gemini-3.7-flash").
func ModelCandidates ¶
ModelCandidates returns the model names that the requested model string should be matched against, most specific first. For opencode, agy, and simplest, a model with a variant suffix also matches its base model name.
func SetAccountUsageProvider ¶
func SetAccountUsageProvider(p AccountUsageProvider)
SetAccountUsageProvider makes CheckTarget consider every account of a CLI instead of only the first one. Passing nil restores the plain query.
func SetClients ¶
SetClients overrides the CLI clients. Passing nil restores the defaults.
func SetQueryRunner ¶
func SetQueryRunner(r QueryRunner)
SetQueryRunner makes models and usage queries go through r instead of invoking the vendor CLIs in-process. Vendor CLIs (agy, claude) implement these queries with non-interactive prompts, which can fire their hooks, so the host sets a runner that confines them to the sandbox. Passing nil restores in-process queries.
func ValidateAgySetup ¶
func ValidateAgySetup() error
ValidateAgySetup verifies that agy is correctly set up on the runner. It passes if at least one account under accounts.Root() has an antigravity-oauth-token, or else (legacy) if ~/.gemini/antigravity-cli/antigravity-oauth-token exists.
func ValidateClaudeSetup ¶
func ValidateClaudeSetup() error
ValidateClaudeSetup verifies that claude is correctly set up on the runner. It passes if at least one account under accounts.Root() has a .credentials.json, or else (legacy) if ~/.claude/.credentials.json exists.
func ValidateOpencodeSetup ¶
func ValidateOpencodeSetup() error
ValidateOpencodeSetup verifies that opencode is correctly set up on the user's system. It checks if opencode.aw.yaml exists and has auth/env keys (or opencode.LoadEnv() has any key), or if ~/.local/share/opencode/opencode.db exists.
func ValidateSimplestSetup ¶
func ValidateSimplestSetup() error
ValidateSimplestSetup verifies that simplest is correctly set up on the user's system. It checks $SIMPLEST_KEY_PATH, $SIMPLEST_CONFIG_PATH, ~/.config/simplest/key.yaml, ~/.simplest/key.yaml, etc. If a config file is present, it validates that it can be parsed and loaded. If no config file is present, it checks for fallback environment variables (GEMINI_API_KEY / OPENAI_API_KEY).
Types ¶
type AccountUsage ¶
type AccountUsage struct {
Account string
Usages []types.ModelUsage
}
AccountUsage is the quota one account reported for its CLI.
type AccountUsageProvider ¶
type AccountUsageProvider func(ctx context.Context, cli string) (accounts []AccountUsage, ok bool)
AccountUsageProvider returns the quota of every account of a CLI that answered within ctx. ok is false when the CLI has no multi-account setup to consider (fewer than two accounts, or an account override), in which case the plain query is used.
type FakeClient ¶
type FakeClient struct {
UsageFunc func(ctx context.Context, opts types.UsageOptions) ([]types.ModelUsage, error)
ModelsFunc func(ctx context.Context, opts types.UsageOptions) ([]string, error)
PromptFunc func(ctx context.Context, prompt string, opts types.PromptOptions) (*types.PromptResult, error)
SystemPromptHeaderFunc func() string
SystemPromptPeerHeaderFunc func() string
SkillsMountPathFunc func(home string) string
MountDirectoriesFunc func(home string) []string
AuthDirectoryFunc func(home string) string
AuthFilesFunc func(home string) []string
ExtraArgsFunc func() []string
}
FakeClient implements types.CLIClient and types.SandboxSpec for testing purposes.
func NewFakeClient ¶
func NewFakeClient() *FakeClient
NewFakeClient returns a new instance of FakeClient.
func (*FakeClient) AuthDirectory ¶
func (c *FakeClient) AuthDirectory(home string) string
func (*FakeClient) AuthFiles ¶
func (c *FakeClient) AuthFiles(home string) []string
func (*FakeClient) ExtraArgs ¶
func (c *FakeClient) ExtraArgs() []string
func (*FakeClient) Models ¶
func (c *FakeClient) Models(ctx context.Context, opts types.UsageOptions) ([]string, error)
Models implements types.CLIClient.Models.
func (*FakeClient) MountDirectories ¶
func (c *FakeClient) MountDirectories(home string) []string
func (*FakeClient) Prompt ¶
func (c *FakeClient) Prompt(ctx context.Context, prompt string, opts types.PromptOptions) (*types.PromptResult, error)
Prompt implements types.CLIClient.Prompt.
func (*FakeClient) SkillsMountPath ¶
func (c *FakeClient) SkillsMountPath(home string) string
func (*FakeClient) SystemPromptHeader ¶
func (c *FakeClient) SystemPromptHeader() string
func (*FakeClient) SystemPromptPeerHeader ¶
func (c *FakeClient) SystemPromptPeerHeader() string
func (*FakeClient) Usage ¶
func (c *FakeClient) Usage(ctx context.Context, opts types.UsageOptions) ([]types.ModelUsage, error)
Usage implements types.CLIClient.Usage.
type QueryRunner ¶
QueryRunner runs `aw <args...>` somewhere safe (e.g. inside the agent sandbox) and returns its stdout.
type QuotaCheck ¶
type QuotaCheck struct {
// Remaining is the headline fraction of quota left; 0 when the query
// failed or the model has no entry.
Remaining float64
// Usable is the quota policy verdict of the account the query ran on,
// nil when no policy applied (callers then apply their own threshold).
Usable *bool
// Reason explains an unusable verdict.
Reason string
}
QuotaCheck is the quota state of one (cli, model) target.
func CheckTarget ¶
func CheckTarget(cli string, model string) QuotaCheck
CheckTarget queries the quota of a (cli, model) target.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agy provides programmatic interaction helpers for the agy CLI tool.
|
Package agy provides programmatic interaction helpers for the agy CLI tool. |
|
cmd
|
|
|
aw
command
|
|
|
Package common implements the AW_AGENTS.md contract shared between the Asgard host and the aw dispatcher running inside the sandbox.
|
Package common implements the AW_AGENTS.md contract shared between the Asgard host and the aw dispatcher running inside the sandbox. |
|
Package inject carries a user message from the host into a running `aw claude` / `aw agy` process inside the agent sandbox.
|
Package inject carries a user message from the host into a running `aw claude` / `aw agy` process inside the agent sandbox. |