core

package
v0.1.71 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDurationSeconds = 365 * 24 * 60 * 60 // 31,536,000 seconds

MaxDurationSeconds is the maximum allowed duration in seconds (1 year). This prevents integer overflow attacks with absurdly large timeout values.

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 SentryDSN = ""

SentryDSN is the default Sentry DSN for the CLI

View Source
var UPDATE_CLI_DOC_URL = "https://docs.blaxel.ai/cli-reference/introduction#update"

Functions

func BuildServerEnvWarning added in v0.1.65

func BuildServerEnvWarning(language string, resourceType string) string

BuildServerEnvWarning returns a formatted warning message with language-specific sample code for using HOST and PORT environment variables.

func CaptureException added in v0.1.62

func CaptureException(err error)

CaptureException captures an error and sends it to Sentry

func CheckForUpdates

func CheckForUpdates(currentVersion string)

func CheckServerEnvUsage added in v0.1.65

func CheckServerEnvUsage(folder string, language string) bool

CheckServerEnvUsage scans project files to check if the code uses HOST/PORT or BL_SERVER_HOST/BL_SERVER_PORT environment variables. Returns true if any of these patterns are found in the code.

func CleanTemplate added in v0.1.34

func CleanTemplate(dir string)

func ClearBlaxelTomlWarning added in v0.1.62

func ClearBlaxelTomlWarning()

ClearBlaxelTomlWarning clears the blaxel.toml warning

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 ConvertRuntimeTimeouts added in v0.1.71

func ConvertRuntimeTimeouts(runtime map[string]interface{}) error

ConvertRuntimeTimeouts converts human-readable timeout values in a runtime config to seconds. This modifies the runtime map in place, converting string timeout values to integers.

func ConvertTriggersTimeouts added in v0.1.71

func ConvertTriggersTimeouts(triggers *[]map[string]interface{}) error

ConvertTriggersTimeouts converts human-readable timeout values in triggers config to seconds. This modifies the triggers slice in place, converting string timeout values to integers.

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 Exit added in v0.1.62

func Exit(code int)

Exit captures to Sentry and exits with the given code

func ExitWithError added in v0.1.62

func ExitWithError(err error)

ExitWithError captures the error to Sentry and exits with code 1

func ExitWithMessage added in v0.1.62

func ExitWithMessage(msg string)

ExitWithMessage captures a message to Sentry and exits with code 1

func FlushSentry added in v0.1.62

func FlushSentry(timeout time.Duration)

FlushSentry flushes buffered events before the program exits

func GetAppURL

func GetAppURL() string

func GetBaseURL

func GetBaseURL() string

func GetBlaxelTomlWarning added in v0.1.62

func GetBlaxelTomlWarning() string

GetBlaxelTomlWarning returns any warning from parsing blaxel.toml

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 GetDeployDocURL added in v0.1.65

func GetDeployDocURL(resourceType string) string

GetDeployDocURL returns the documentation URL for deploying a specific resource type

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 InitSentry added in v0.1.62

func InitSentry(cfg SentryConfig) error

InitSentry initializes the Sentry SDK with the given configuration

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 ParseDuration added in v0.1.71

func ParseDuration(duration string) (time.Duration, error)

ParseDuration parses a human-readable duration string and returns a time.Duration. Supported formats: "30s", "5m", "1h", "2d", "1w" (seconds, minutes, hours, days, weeks) Also accepts plain integers (interpreted as seconds). Maximum allowed duration is 1 year to prevent overflow.

func ParseDurationToSeconds added in v0.1.71

func ParseDurationToSeconds(duration string) (int, error)

ParseDurationToSeconds parses a human-readable duration string and returns the number of seconds. Supported formats: "30s", "5m", "1h", "2d", "1w" (seconds, minutes, hours, days, weeks) Also accepts plain integers (interpreted as seconds). Returns the value in seconds and any error encountered. Maximum allowed duration is 1 year (31,536,000 seconds) to prevent overflow.

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 PrintInfoWithCommand added in v0.1.70

func PrintInfoWithCommand(message string, command string)

PrintInfoWithCommand prints an info message followed by a command in white

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 RecoverWithSentry added in v0.1.62

func RecoverWithSentry()

RecoverWithSentry recovers from a panic and sends it to Sentry Usage: defer core.RecoverWithSentry()

func RegisterCommand

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

RegisterCommand allows commands to register themselves

func RunAgentAppCreation added in v0.1.65

func RunAgentAppCreation(dirArg string, templateName string, noTTY bool)

RunAgentAppCreation is a reusable wrapper that executes the agent creation flow. It can be called by both the dedicated command and the unified `bl new` command.

func RunInstallationWithTea added in v0.1.34

func RunInstallationWithTea(t Template, opts TemplateOptions) error

RunInstallationWithTea runs the installation process with Bubble Tea UI

func RunJobCreation added in v0.1.65

func RunJobCreation(dirArg string, templateName string, noTTY bool)

RunJobCreation is a reusable wrapper that executes the job creation flow.

func RunMCPCreation added in v0.1.65

func RunMCPCreation(dirArg string, templateName string, noTTY bool)

RunMCPCreation is a reusable wrapper that executes the MCP server creation flow.

func RunSandboxCreation added in v0.1.65

func RunSandboxCreation(dirArg string, templateName string, noTTY bool)

RunSandboxCreation is a reusable wrapper that executes the sandbox creation flow.

func RunVolumeTemplateCreation added in v0.1.65

func RunVolumeTemplateCreation(dirArg string, templateName string, noTTY bool)

RunVolumeTemplateCreation is a reusable wrapper that executes the volume template creation flow.

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 SetSentryTag added in v0.1.62

func SetSentryTag(key, value string)

SetSentryTag sets a tag on the current scope

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 Field added in v0.1.62

type Field struct {
	Key     string
	Value   string
	Special string
}

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{}
	Fields   []Field // ordered slice of fields - e.g., {Key: "STATUS", Value: "status"}
}

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 SentryConfig added in v0.1.62

type SentryConfig struct {
	DSN     string
	Release string
}

SentryConfig holds the configuration for Sentry initialization

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