agenttools

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agenttools holds the actions AI agents and the efc CLI take on Elastic Fruit Cloud. Every action calls the CloudService API through the generated Connect client, so the server checks the caller like any other API request. Requests leave tenant_id empty, the server uses the tenant of the API token. Inputs and outputs are plain structs that encode to JSON.

Index

Constants

View Source
const (
	NextStepInstallApp        = "install_app"
	NextStepEnableRepository  = "enable_repository"
	NextStepCheckRepository   = "check_repository"
	NextStepNoJobsObservedYet = "no_jobs_observed_yet"
	NextStepReady             = "ready"
)

Next step codes of Status, checked in this order.

View Source
const DefaultAPIURL = "https://elastic-fruit.strrl.cloud"

DefaultAPIURL is the Elastic Fruit Cloud API used when EFC_API_URL is not set.

View Source
const RunsOnLabel = "elastic-fruit"

RunsOnLabel is the runs-on label that sends a workflow job to Elastic Fruit Cloud.

Variables

This section is empty.

Functions

func ErrorText

func ErrorText(err error) string

ErrorText describes an error for an agent or a user. An API error shows only its code and the message of the server, the cause is not guessed: permission_denied can come from the token scope or from the tenant.

func Version

func Version() string

Version returns the version of the efc tools: the release version, the module version when another program builds them in, or "dev".

Types

type AvailableRepository

type AvailableRepository struct {
	ID             int64  `json:"id"`
	FullName       string `json:"full_name"`
	InstallationID int64  `json:"installation_id"`
	AccountLogin   string `json:"account_login"`
	Private        bool   `json:"private"`
	Archived       bool   `json:"archived"`
	Enabled        bool   `json:"enabled"`
}

AvailableRepository is one repository a GitHub App installation of the tenant can see.

type AvailableRepositoryList

type AvailableRepositoryList struct {
	Repositories []AvailableRepository `json:"repositories"`
}

AvailableRepositoryList is the repositories the installations of the tenant can see.

type DisabledRepository

type DisabledRepository struct {
	FullName string `json:"full_name"`
	Disabled bool   `json:"disabled"`
}

DisabledRepository is the answer to disabling a repository.

type EnabledRepository

type EnabledRepository struct {
	Repository Repository `json:"repository"`
	RunsOn     string     `json:"runs_on"`
	Message    string     `json:"message"`
}

EnabledRepository is the answer to enabling a repository.

type InstallLink struct {
	URL              string   `json:"url"`
	ExpiresInSeconds int      `json:"expires_in_seconds"`
	Instructions     []string `json:"instructions"`
}

InstallLink is the GitHub page where a person installs the GitHub App for the tenant.

type Installation

type Installation struct {
	InstallationID      int64  `json:"installation_id"`
	AccountLogin        string `json:"account_login"`
	AccountType         string `json:"account_type"`
	RepositorySelection string `json:"repository_selection"`
	Suspended           bool   `json:"suspended"`
}

Installation is one GitHub account the GitHub App is installed on for the tenant.

type Job

type Job struct {
	ID            string `json:"id"`
	Repository    string `json:"repository"`
	DisplayName   string `json:"display_name"`
	WorkflowRunID int64  `json:"workflow_run_id"`
	WorkflowRef   string `json:"workflow_ref"`
	EventName     string `json:"event_name"`
	// Result is succeeded, failed, canceled, lost or running.
	Result       string `json:"result"`
	QueuedAt     string `json:"queued_at,omitempty"`
	StartedAt    string `json:"started_at"`
	FinishedAt   string `json:"finished_at,omitempty"`
	RunnerName   string `json:"runner_name"`
	AgentName    string `json:"agent_name"`
	GitHubRunURL string `json:"github_run_url,omitempty"`
}

Job is one job of the tenant.

type JobDetail

type JobDetail struct {
	Job             Job            `json:"job"`
	Labels          []string       `json:"labels"`
	RunnerState     string         `json:"runner_state,omitempty"`
	RunnerEndReason string         `json:"runner_end_reason,omitempty"`
	Samples         SamplesSummary `json:"samples_summary"`
	LogsHint        LogsHint       `json:"logs_hint"`
}

JobDetail is one job with a summary of its resource samples.

type JobFilter

type JobFilter struct {
	// Repository is owner/name.
	Repository    string
	WorkflowRunID int64
	Result        string
	// Page starts at 1 and is only used without WorkflowRunID and Result.
	Page int
}

JobFilter picks the jobs of a job list. Zero values do not filter.

type JobList

type JobList struct {
	Jobs    []Job  `json:"jobs"`
	HasMore bool   `json:"has_more"`
	Message string `json:"message,omitempty"`
}

JobList is one page of jobs, newest first.

type JobLogs

type JobLogs struct {
	// Status is ready, log_not_ready, permission_not_approved,
	// repository_not_accessible or job_not_located.
	Status              string `json:"status"`
	Message             string `json:"message,omitempty"`
	Log                 string `json:"log,omitempty"`
	Truncated           bool   `json:"truncated"`
	LogSizeBytes        int64  `json:"log_size_bytes"`
	GitHubWorkflowJobID int64  `json:"github_workflow_job_id,omitempty"`
	GitHubRunURL        string `json:"github_run_url,omitempty"`
	GitHubJobURL        string `json:"github_job_url,omitempty"`
	LogCommand          string `json:"log_command,omitempty"`
}

JobLogs is the end of the GitHub log of one job, or why it cannot be read.

type LogsHint

type LogsHint struct {
	Text         string `json:"text"`
	GitHubRunURL string `json:"github_run_url,omitempty"`
	Command      string `json:"command,omitempty"`
}

LogsHint says where the log of a job is.

type NextStep

type NextStep struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

NextStep says what to do next, based only on what the server reports.

type Quota

type Quota struct {
	MaxRepositories      int32 `json:"max_repositories"`
	RepositoriesEnabled  int32 `json:"repositories_enabled"`
	MaxConcurrentRunners int32 `json:"max_concurrent_runners"`
	RunnersAllocated     int32 `json:"runners_allocated"`
	PoolMinutesMonthly   int32 `json:"pool_minutes_monthly"`
	PoolMinutesUsed      int32 `json:"pool_minutes_used"`
	MaxPoolRunners       int32 `json:"max_pool_runners"`
	PoolRunnersAllocated int32 `json:"pool_runners_allocated"`
	MaxAgents            int32 `json:"max_agents"`
	AgentsUsed           int32 `json:"agents_used"`
}

Quota is the free tier limits of the tenant next to the current use.

type Repository

type Repository struct {
	ID       int64  `json:"id"`
	FullName string `json:"full_name"`
	Private  bool   `json:"private"`
	Archived bool   `json:"archived"`
	// Status is one of paused, problem, setting_up, pool_minutes_used_up or ready.
	Status        string         `json:"status"`
	Problem       string         `json:"problem,omitempty"`
	LastJob       *RepositoryJob `json:"last_job,omitempty"`
	JobsLast7Days int32          `json:"jobs_last_7_days"`
}

Repository is one enabled repository of the tenant.

type RepositoryJob

type RepositoryJob struct {
	ID         string `json:"id"`
	Result     string `json:"result"`
	StartedAt  string `json:"started_at"`
	FinishedAt string `json:"finished_at,omitempty"`
}

RepositoryJob is the newest job of a repository.

type RepositoryList

type RepositoryList struct {
	Repositories []Repository `json:"repositories"`
}

RepositoryList is the enabled repositories of the tenant.

type SamplesSummary

type SamplesSummary struct {
	Count              int     `json:"count"`
	MaxCPUPercent      float64 `json:"max_cpu_percent"`
	MaxMemoryUsedBytes int64   `json:"max_memory_used_bytes"`
	MaxDiskUsedBytes   int64   `json:"max_disk_used_bytes"`
	FirstRecordedAt    string  `json:"first_recorded_at,omitempty"`
	LastRecordedAt     string  `json:"last_recorded_at,omitempty"`
}

SamplesSummary sums up the resource samples of a job.

type ServiceInfo

type ServiceInfo struct {
	Version   string `json:"version"`
	PublicURL string `json:"public_url"`
}

ServiceInfo is the version and public URL of the server.

type Status

type Status struct {
	PublicURL           string         `json:"public_url"`
	Version             string         `json:"version"`
	Quota               Quota          `json:"quota"`
	Installations       []Installation `json:"installations"`
	EnabledRepositories []Repository   `json:"enabled_repositories"`
	JobsRunning         int32          `json:"jobs_running"`
	JobsLast7Days       int32          `json:"jobs_last_7_days"`
	HasJobs             bool           `json:"has_jobs"`
	NextStep            NextStep       `json:"next_step"`
}

Status is the setup state of the tenant of the token.

type Tools

type Tools struct {
	// contains filtered or unexported fields
}

Tools runs the agent actions with one API client.

func New

New returns the agent actions that call the API through client.

func (*Tools) AvailableRepositories

func (t *Tools) AvailableRepositories(ctx context.Context, account string) (AvailableRepositoryList, error)

AvailableRepositories lists the repositories the GitHub App installations of the tenant can see. A non empty account keeps only that GitHub account.

func (*Tools) DisableRepository

func (t *Tools) DisableRepository(ctx context.Context, fullName string) (DisabledRepository, error)

DisableRepository disables the enabled repository named owner/name. It needs an admin token. Job history stays.

func (*Tools) EnableRepository

func (t *Tools) EnableRepository(ctx context.Context, fullName string) (EnabledRepository, error)

EnableRepository enables the repository named owner/name. It needs an admin token. The repository must be visible to an installation of the tenant.

func (t *Tools) InstallLink(ctx context.Context) (InstallLink, error)

InstallLink returns the GitHub App install link for the tenant. Only a person can finish the install: the link is for a person to click.

func (*Tools) Job

func (t *Tools) Job(ctx context.Context, jobID string) (JobDetail, error)

Job reads one job with its resource samples and where its log is.

func (*Tools) JobLogs

func (t *Tools) JobLogs(ctx context.Context, jobID string, maxBytes int32) (JobLogs, error)

JobLogs reads the end of the GitHub log of one job. maxBytes 0 lets the server pick its default of 32768 bytes, it allows at most 1048576.

func (*Tools) Jobs

func (t *Tools) Jobs(ctx context.Context, filter JobFilter) (JobList, error)

Jobs lists jobs of the tenant, newest first. Without run or result filter it returns one page from the server. With one, it reads up to maxScannedJobPages pages and returns the jobs that match.

func (*Tools) Repositories

func (t *Tools) Repositories(ctx context.Context) (RepositoryList, error)

Repositories lists the enabled repositories of the tenant.

func (*Tools) ServiceInfo

func (t *Tools) ServiceInfo(ctx context.Context) (ServiceInfo, error)

ServiceInfo reads the version and public URL of the server. It needs no token.

func (*Tools) Status

func (t *Tools) Status(ctx context.Context) (Status, error)

Status reads the installations, enabled repositories, counts and quota of the tenant.

func (*Tools) Usage

func (t *Tools) Usage(ctx context.Context, days int32) (Usage, error)

Usage reads the usage of the last days, today included. days 0 means 30, the server allows 1 to 366.

type Usage

type Usage struct {
	// From and To are the first and last UTC day of the report as 2026-01-31, both included.
	From   string      `json:"from"`
	To     string      `json:"to"`
	Totals UsageTotals `json:"totals"`
	Rows   []UsageRow  `json:"rows"`
}

Usage is the daily usage of the tenant per repository, with totals.

type UsageRow

type UsageRow struct {
	Day               string `json:"day"`
	Repository        string `json:"repository"`
	JobCount          int32  `json:"job_count"`
	SucceededCount    int32  `json:"succeeded_count"`
	FailedCount       int32  `json:"failed_count"`
	OtherCount        int32  `json:"other_count"`
	JobSeconds        int64  `json:"job_seconds"`
	RunnerSeconds     int64  `json:"runner_seconds"`
	PoolRunnerSeconds int64  `json:"pool_runner_seconds"`
}

UsageRow is the usage of one repository on one UTC day.

type UsageTotals

type UsageTotals struct {
	JobCount          int32 `json:"job_count"`
	SucceededCount    int32 `json:"succeeded_count"`
	FailedCount       int32 `json:"failed_count"`
	OtherCount        int32 `json:"other_count"`
	JobSeconds        int64 `json:"job_seconds"`
	RunnerSeconds     int64 `json:"runner_seconds"`
	PoolRunnerSeconds int64 `json:"pool_runner_seconds"`
}

UsageTotals sums up the rows of a usage report.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL