functions

package
v0.0.0-...-4ae6852 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: AGPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const FunctionsCPUHeader = "X-Gram-Functions-Cpu"
View Source
const FunctionsExecutionTimeHeader = "X-Gram-Functions-Execution-Time"
View Source
const FunctionsMemoryHeader = "X-Gram-Functions-Memory"

Variables

This section is empty.

Functions

func IsSupportedRuntime

func IsSupportedRuntime(runtime string) bool

func TokenV1

func TokenV1(enc *encryption.Client, req TokenRequestV1) (string, error)

Types

type CallToolPayload

type CallToolPayload struct {
	ToolName    string            `json:"name"`
	Input       json.RawMessage   `json:"input"`
	Environment map[string]string `json:"environment,omitempty,omitzero"`
}

type Deployer

type Deployer interface {
	Deploy(context.Context, RunnerDeployRequest) (*RunnerDeployResult, error)
}

type FlyRunner

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

func NewFlyRunner

func NewFlyRunner(
	logger *slog.Logger,
	tracerProvider trace.TracerProvider,
	db *pgxpool.Pool,
	assetStorage assets.BlobStore,
	imageSelector ImageSelector,
	encryption *encryption.Client,
	o FlyRunnerOptions,
) *FlyRunner

func (*FlyRunner) Deploy

func (f *FlyRunner) Deploy(ctx context.Context, req RunnerDeployRequest) (res *RunnerDeployResult, err error)

func (*FlyRunner) ReadResource

func (f *FlyRunner) ReadResource(ctx context.Context, req RunnerResourceReadRequest) (httpreq *http.Request, err error)

func (*FlyRunner) ToolCall

func (f *FlyRunner) ToolCall(ctx context.Context, req RunnerToolCallRequest) (httpreq *http.Request, err error)

type FlyRunnerOptions

type FlyRunnerOptions struct {
	ServiceName    string
	ServiceVersion string

	FlyTokens          *tokens.Tokens
	FlyAPIURL          string
	FlyMachinesBaseURL string
	DefaultFlyOrg      string
	DefaultFlyRegion   string
}

type ImageRequest

type ImageRequest struct {
	ProjectID    uuid.UUID
	DeploymentID uuid.UUID
	FunctionID   uuid.UUID

	Runtime Runtime
	Version RunnerVersion
}

type ImageSelector

type ImageSelector interface {
	Select(ctx context.Context, req ImageRequest) (string, error)
}

type LocalRunner

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

func NewLocalRunner

func NewLocalRunner(codeRoot *os.Root) *LocalRunner

func (*LocalRunner) Deploy

func (*LocalRunner) ReadResource

func (l *LocalRunner) ReadResource(ctx context.Context, readReq RunnerResourceReadRequest) (*http.Request, error)

func (*LocalRunner) ToolCall

func (l *LocalRunner) ToolCall(ctx context.Context, call RunnerToolCallRequest) (*http.Request, error)

type Manifest

type Manifest struct {
	Version string
	V0      *ManifestV0
}

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(data []byte) error

type ManifestResourceV0

type ManifestResourceV0 struct {
	Name        string                                  `json:"name"`
	URI         string                                  `json:"uri"`
	Description string                                  `json:"description"`
	MimeType    *string                                 `json:"mimeType,omitempty"`
	Title       *string                                 `json:"title,omitempty"`
	Variables   map[string]*ManifestVariableAttributeV0 `json:"variables"`
	Meta        map[string]string                       `json:"meta"`
}

type ManifestToolV0

type ManifestToolV0 struct {
	Name        string                                  `json:"name"`
	Description string                                  `json:"description"`
	InputSchema json.RawMessage                         `json:"inputSchema"`
	Variables   map[string]*ManifestVariableAttributeV0 `json:"variables"`
	Meta        map[string]string                       `json:"meta"`
}

type ManifestV0

type ManifestV0 struct {
	Version   string               `json:"version"`
	Tools     []ManifestToolV0     `json:"tools"`
	Resources []ManifestResourceV0 `json:"resources"`
}

type ManifestVariableAttributeV0

type ManifestVariableAttributeV0 struct {
	Description *string `json:"description"`
}

type Orchestrator

type Orchestrator interface {
	Deployer
	ToolCaller
}

type ProcessError

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

func (*ProcessError) Error

func (e *ProcessError) Error() string

func (*ProcessError) Reason

func (e *ProcessError) Reason() string

func (*ProcessError) Unwrap

func (e *ProcessError) Unwrap() error

type ReadResourcePayload

type ReadResourcePayload struct {
	URI         string            `json:"uri"`
	Input       json.RawMessage   `json:"input"`
	Environment map[string]string `json:"environment,omitempty,omitzero"`
}

type RunnerAsset

type RunnerAsset struct {
	AssetURL *url.URL

	GuestPath string
	// Mode is a string representation of file mode, e.g. 0444
	Mode uint32

	SHA256Sum string
}

type RunnerBaseRequest

type RunnerBaseRequest struct {
	InvocationID uuid.UUID

	OrganizationID    string
	OrganizationSlug  string
	ProjectID         uuid.UUID
	ProjectSlug       string
	DeploymentID      uuid.UUID
	FunctionsID       uuid.UUID
	FunctionsAccessID uuid.UUID

	Input       json.RawMessage
	Environment map[string]string
}

type RunnerDeployRequest

type RunnerDeployRequest struct {
	Version RunnerVersion

	ProjectID    uuid.UUID
	DeploymentID uuid.UUID
	FunctionID   uuid.UUID
	AccessID     uuid.UUID

	Runtime Runtime
	Assets  []RunnerAsset

	BearerSecret string
}

type RunnerDeployResult

type RunnerDeployResult struct {
	URN       urn.FunctionRunner
	PublicURL *url.URL
	Version   RunnerVersion
	Provider  string
	Region    string
	Scale     int
}

type RunnerDestroyRequest

type RunnerDestroyRequest struct {
	ProjectID    uuid.UUID
	DeploymentID uuid.UUID
	FunctionsID  uuid.UUID
}

type RunnerImageRequest

type RunnerImageRequest struct {
	ProjectID    uuid.UUID
	DeploymentID uuid.UUID
	FunctionsID  uuid.UUID

	Runtime Runtime
}

type RunnerResourceReadRequest

type RunnerResourceReadRequest struct {
	RunnerBaseRequest

	ResourceURN  urn.Resource
	ResourceURI  string
	ResourceName string
}

type RunnerToolCallRequest

type RunnerToolCallRequest struct {
	RunnerBaseRequest

	ToolURN  urn.Tool
	ToolName string
}

type RunnerVersion

type RunnerVersion string

type Runtime

type Runtime string
const (
	RuntimeNodeJS22  Runtime = "nodejs:22"
	RuntimePython312 Runtime = "python:3.12"
)

func (Runtime) OCITag

func (r Runtime) OCITag() string

type Runtimes

type Runtimes map[Runtime]struct{}

func SupportedRuntimes

func SupportedRuntimes() Runtimes

func (Runtimes) String

func (r Runtimes) String() string

type TemplateImageSelector

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

func NewTemplateImageSelector

func NewTemplateImageSelector(tpl string) (*TemplateImageSelector, error)

func (*TemplateImageSelector) Select

type TokenRequestV1

type TokenRequestV1 struct {
	ID  string `json:"id"`
	Exp int64  `json:"exp"`
}

type ToolCaller

type ToolCaller interface {
	ToolCall(context.Context, RunnerToolCallRequest) (*http.Request, error)
	ReadResource(context.Context, RunnerResourceReadRequest) (*http.Request, error)
}

type ToolExtractor

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

func NewToolExtractor

func NewToolExtractor(logger *slog.Logger, db *pgxpool.Pool, assetStorage assets.BlobStore) *ToolExtractor

func (*ToolExtractor) Do

type ToolExtractorResult

type ToolExtractorResult struct {
	ManifestVersion string
	NumTools        int
}

type ToolExtractorTask

type ToolExtractorTask struct {
	ProjectID    uuid.UUID
	DeploymentID uuid.UUID
	AttachmentID uuid.UUID
	Attachment   *types.DeploymentFunctions
	AssetURL     *url.URL
	ProjectSlug  string
	OrgSlug      string

	OnToolSkipped func(err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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