core

package
v0.1.61 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APP_URL = "https://app.blaxel.ai"
View Source
var BASE_URL = "https://api.blaxel.ai/v0"
View Source
var GITHUB_RELEASES_URL = "https://api.github.com/repos/blaxel-ai/toolkit/releases"
View Source
var REGISTRY_URL = "https://us.registry.blaxel.ai"
View Source
var RUN_URL = "https://run.blaxel.ai"
View Source
var UPDATE_CLI_DOC_URL = "https://docs.blaxel.ai/cli-reference/introduction#update"

Functions

func CheckForUpdates

func CheckForUpdates(currentVersion string)

func CleanTemplate added in v0.1.34

func CleanTemplate(dir string)

func CloneTemplateWithSpinner added in v0.1.34

func CloneTemplateWithSpinner(opts TemplateOptions, templates Templates, noTTY bool, errorPrefix string, spinnerTitle string) error

CloneTemplateWithSpinner clones a template with optional spinner based on noTTY flag

func DocCmd

func DocCmd() *cobra.Command

func EditBlaxelTomlInCurrentDir added in v0.1.34

func EditBlaxelTomlInCurrentDir(resourceType string, resourceName string, resourcePath string) error

editBlaxelTomlInCurrentDir checks if blaxel.toml exists in the current working directory and appends text to it. If the file doesn't exist, it returns without error.

func ErrorHandler

func ErrorHandler(request *http.Request, kind string, name string, body string) error

func Execute

func Execute(releaseVersion string, releaseCommit string, releaseDate string) error

func GetAppURL

func GetAppURL() string

func GetBaseURL

func GetBaseURL() string

func GetClient

func GetClient() *sdk.ClientWithResponses

GetClient returns the current client

func GetCommand

func GetCommand(name string) *cobra.Command

GetCommand returns a registered command

func GetCommandSecrets

func GetCommandSecrets() []string

func GetCommit

func GetCommit() string

func GetDate

func GetDate() string

func GetDependencyManager added in v0.1.34

func GetDependencyManager(language, directory string) (string, string)

GetDependencyManager returns the dependency manager and version for a given language

func GetEnvFiles

func GetEnvFiles() []string

func GetHuhTheme

func GetHuhTheme() *huh.Theme

getTheme returns a custom theme configuration for the CLI interface using the Dracula color scheme. It customizes various UI elements like buttons, text inputs, and selection indicators.

func GetOutputFormat

func GetOutputFormat() string

GetOutputFormat returns the current output format

func GetRegistryURL

func GetRegistryURL() string

func GetRunURL

func GetRunURL() string

func GetVerbose added in v0.1.57

func GetVerbose() bool

func GetVersion

func GetVersion() string

func GetWorkspace

func GetWorkspace() string

GetWorkspace returns the current workspace

func HasGoEntryFile added in v0.1.59

func HasGoEntryFile(directory string) bool

HasGoEntryFile checks if common Go entry files exist in the given directory

func HasPythonEntryFile added in v0.1.59

func HasPythonEntryFile(directory string) bool

HasPythonEntryFile checks if common Python entry files exist in the given directory

func HasTypeScriptEntryFile added in v0.1.59

func HasTypeScriptEntryFile(directory string) bool

HasTypeScriptEntryFile checks if common TypeScript/JavaScript entry files exist in the given directory or if package.json has a start script defined

func IsCIEnvironment added in v0.1.44

func IsCIEnvironment() bool

IsCIEnvironment returns true when running in a known CI environment. It checks common CI environment variables used by providers like GitHub and GitLab.

func IsInteractiveMode added in v0.1.44

func IsInteractiveMode() bool

func IsTerminalInteractive added in v0.1.44

func IsTerminalInteractive() bool

IsTerminalInteractive returns true if both stdin and stdout are terminals (TTY).

func IsVolumeTemplate added in v0.1.46

func IsVolumeTemplate(resourceType string) bool

func LoadCommandSecrets

func LoadCommandSecrets(commandSecrets []string)

func LookupSecret added in v0.1.33

func LookupSecret(name string) string

func ModuleLanguage

func ModuleLanguage(directory string) string

func Output

func Output(resource Resource, slices []interface{}, outputFormat string)

func Pluralize added in v0.1.44

func Pluralize(word string) string

Pluralize returns a basic English plural of a given singular noun

func Print added in v0.1.34

func Print(message string)

func PrintError added in v0.1.34

func PrintError(operation string, err error)

PrintError prints a formatted error message with colors

func PrintInfo added in v0.1.34

func PrintInfo(message string)

func PrintSuccess added in v0.1.34

func PrintSuccess(message string)

PrintSuccess prints a formatted success message with colors

func PrintWarning added in v0.1.34

func PrintWarning(message string)

PrintWarning prints a formatted warning message with colors

func PromptForDeploymentType added in v0.1.59

func PromptForDeploymentType() string

promptForDeploymentType prompts the user to select what they want to deploy when no blaxel.toml file is found

func ReadConfigToml

func ReadConfigToml(folder string, setDefaultType bool)

func ReadSecrets

func ReadSecrets(folder string, envFiles []string)

func RegisterCommand

func RegisterCommand(name string, cmdFunc func() *cobra.Command)

RegisterCommand allows commands to register themselves

func RunCreateFlow added in v0.1.39

func RunCreateFlow(
	dirArg string,
	templateNameFlag string,
	cfg CreateFlowConfig,
	promptFunc func(directory string, templates Templates) TemplateOptions,
	successFunc func(opts TemplateOptions),
)

RunCreateFlow centralizes the common steps for all create-* commands while preserving each command's specific behavior via the config and callbacks.

Parameters: - dirArg: optional directory argument provided on CLI - templateNameFlag: optional template name provided via --template - promptFunc: called to interactively collect TemplateOptions when needed - successFunc: called at the end to print any command-specific instructions

func RunInstallationWithTea added in v0.1.34

func RunInstallationWithTea(t Template, opts TemplateOptions) error

RunInstallationWithTea runs the installation process with Bubble Tea UI

func SeedCache

func SeedCache(cwd string) error

func SetCommandSecrets

func SetCommandSecrets(secrets []string)

func SetConfigType added in v0.1.59

func SetConfigType(t string)

SetConfigType sets the config type

func SetEnvs

func SetEnvs()

func SetInteractiveMode added in v0.1.44

func SetInteractiveMode(interactive bool)

func SetWorkspace

func SetWorkspace(ws string)

SetWorkspace sets the current workspace

func Slugify added in v0.1.39

func Slugify(s string) string

Slugify converts a string to a URL-safe slug format Example: "My Agent 123!" -> "my-agent-123"

Types

type CommandEnv

type CommandEnv map[string]string

func (*CommandEnv) AddClientEnv

func (c *CommandEnv) AddClientEnv()

func (*CommandEnv) Set

func (c *CommandEnv) Set(key, value string)

func (*CommandEnv) ToEnv

func (c *CommandEnv) ToEnv() []string

type Config

type Config struct {
	Name        string                    `toml:"name"`
	Workspace   string                    `toml:"workspace"`
	Type        string                    `toml:"type"`
	Protocol    string                    `toml:"protocol"`
	Functions   []string                  `toml:"functions"`
	Models      []string                  `toml:"models"`
	Agents      []string                  `toml:"agents"`
	Entrypoint  Entrypoints               `toml:"entrypoint"`
	Env         Envs                      `toml:"env"`
	Function    map[string]Package        `toml:"function"`
	Agent       map[string]Package        `toml:"agent"`
	Job         map[string]Package        `toml:"job"`
	SkipRoot    bool                      `toml:"skipRoot"`
	Runtime     *map[string]interface{}   `toml:"runtime"`
	Triggers    *[]map[string]interface{} `toml:"triggers"`
	Volumes     *[]map[string]interface{} `toml:"volumes,omitempty"`
	Policies    []string                  `toml:"policies,omitempty"`
	DefaultSize *int                      `toml:"defaultSize,omitempty"`
	Directory   string                    `toml:"directory,omitempty"`
	Region      string                    `toml:"region,omitempty"`
}

readConfigToml reads the config.toml file and upgrade config according to content

func GetConfig

func GetConfig() Config

type CreateFlowConfig added in v0.1.39

type CreateFlowConfig struct {
	// Template topic used to filter templates: e.g., "agent", "job", "mcp", "sandbox".
	TemplateType string
	// Non-interactive flag; true means skip TTY UI and use defaults.
	NoTTY bool
	// Name used for progress/error messages, like "Agent creation".
	ErrorPrefix string
	// One-line spinner title while cloning, like "Creating your blaxel agent app...".
	SpinnerTitle string
	// Optional: when set, append a section to blaxel.toml with this resource type (e.g., "agent" or "function").
	BlaxelTomlResourceType string
}

CreateFlowConfig captures the knobs that differ between create commands.

type Entrypoints

type Entrypoints struct {
	Production  string `toml:"prod"`
	Development string `toml:"dev"`
}

type Env

type Env struct {
	Name  string
	Value string
}

func GetEnvs

func GetEnvs() []Env

func GetSecrets

func GetSecrets() []Env

GetSecrets returns the current secrets

func GetUniqueEnvs

func GetUniqueEnvs() []Env

type Envs

type Envs map[string]string

type ErrorModel

type ErrorModel struct {
	Error string   `json:"error"`
	Code  int      `json:"code"`
	Stack []string `json:"stack"`
}

type IgnoreDir

type IgnoreDir struct {
	Folder string
	Skip   string
}

type IgnoreFile

type IgnoreFile struct {
	File string
	Skip string
}

type Model added in v0.1.34

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

Model holds the state of our installation UI

func NewInstallationModel added in v0.1.34

func NewInstallationModel() Model

NewInstallationModel creates a new installation progress model

func (*Model) CompleteStep added in v0.1.34

func (m *Model) CompleteStep(step int)

func (*Model) Done added in v0.1.34

func (m *Model) Done()

func (*Model) FailStep added in v0.1.34

func (m *Model) FailStep(step int, err error)

func (Model) Init added in v0.1.34

func (m Model) Init() tea.Cmd

Init is the first function called

func (*Model) StartStep added in v0.1.34

func (m *Model) StartStep(step int)

func (Model) Update added in v0.1.34

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the model

func (Model) View added in v0.1.34

func (m Model) View() string

View renders the UI

type NameRetriever

type NameRetriever struct {
	Metadata struct {
		Name string `yaml:"name"`
	} `yaml:"metadata"`
}

type Operations

type Operations struct {
	BaseURL     string
	RunURL      string
	AppURL      string
	RegistryURL string
}

func (*Operations) CliCommand

func (o *Operations) CliCommand(ctx context.Context, operationId string, fn interface{})

type Package

type Package struct {
	Path string `toml:"path"`
	Port int    `toml:"port,omitempty"`
	Type string `toml:"type,omitempty"`
}

type Resource

type Resource struct {
	Kind             string
	Short            string
	Plural           string
	Singular         string
	Aliases          []string
	SpecType         reflect.Type
	List             interface{}
	Get              interface{}
	Delete           interface{}
	Put              interface{}
	Post             interface{}
	AdditionalFields map[string]string // map[columnName]fieldPath - e.g., "STATUS": "status", "IMAGE": "spec.runtime.image"
}

func GetResources

func GetResources() []*Resource

GetResources returns the resources slice

func (*Resource) ListExec

func (r *Resource) ListExec() ([]interface{}, error)

ListExec method for Resource

func (*Resource) PostFn

func (r *Resource) PostFn(resourceName string, name string, resourceObject interface{}) interface{}

PostFn method for Resource - placeholder implementation

func (*Resource) PutFn

func (r *Resource) PutFn(resourceName string, name string, resourceObject interface{}) interface{}

PutFn method for Resource - placeholder implementation

type Result

type Result struct {
	ApiVersion string      `yaml:"apiVersion" json:"apiVersion"`
	Kind       string      `yaml:"kind" json:"kind"`
	Metadata   interface{} `yaml:"metadata" json:"metadata"`
	Spec       interface{} `yaml:"spec" json:"spec"`
	Status     string      `yaml:"status,omitempty" json:"status,omitempty"`
}

func GetResults

func GetResults(action string, filePath string, recursive bool) ([]Result, error)

GetResults is a public wrapper for getResults

func (*Result) ToString

func (r *Result) ToString() string

type ResultMetadata

type ResultMetadata struct {
	Workspace string
	Name      string
}

type Secrets

type Secrets []Env

readSecret from .env file at root of project

type Status added in v0.1.34

type Status int

Installation step statuses

const (
	StatusPending Status = iota
	StatusRunning
	StatusComplete
	StatusFailed
)

type Step added in v0.1.34

type Step struct {
	Title       string
	Description string
	Status      Status
}

Step represents an installation step

type Template

type Template struct {
	sdk.Template
	Language string
	Type     string
}

func (Template) Clone

func (t Template) Clone(opts TemplateOptions) error

type TemplateOptions

type TemplateOptions struct {
	Directory     string // Target directory for the new agent app
	ProjectName   string // Name of the project
	ProjectPrompt string // Description of the project
	Language      string // Language to use for the project
	TemplateName  string // Name of the template to use for the project
	Author        string // Author of the project
}

func CreateDefaultTemplateOptions

func CreateDefaultTemplateOptions(directory, templateName string, templates Templates) TemplateOptions

CreateDefaultTemplateOptions creates default options when template is specified via flag

func PromptTemplateOptions added in v0.1.39

func PromptTemplateOptions(directory string, templates Templates, resource string, includeLanguage bool, templateHeight int) TemplateOptions

PromptTemplateOptions presents a unified interactive form to collect TemplateOptions. It can optionally include a language selector and will always include a template selector. The name field is included only when directory is empty. resource is used in messages, e.g. "agent app", "job", "mcp server".

type Templates

type Templates []Template

func RetrieveTemplates

func RetrieveTemplates(templateType string) (Templates, error)

func RetrieveTemplatesWithSpinner added in v0.1.34

func RetrieveTemplatesWithSpinner(templateType string, noTTY bool, errorPrefix string) (Templates, error)

RetrieveTemplatesWithSpinner retrieves templates with optional spinner based on noTTY flag

func (Templates) FilterByLanguage

func (t Templates) FilterByLanguage(language string) Templates

func (Templates) Find

func (t Templates) Find(name string) (Template, error)

func (Templates) GetLanguages

func (t Templates) GetLanguages() []string

Jump to

Keyboard shortcuts

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