api

package
v0.7.19 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package api hosts the /internal HTTP surface used by runner subprocesses to fetch their context, request scoped secrets, stream events, and finalize. No human-facing endpoints live here — that's P3's job.

Index

Constants

View Source
const DefaultAutoPauseAfter int32 = 5

DefaultAutoPauseAfter is the global default threshold for consecutive scheduled-run failures before a schedule is auto-paused. Per-schedule overrides from cronfoundry.yaml take precedence.

Variables

This section is empty.

Functions

func ClaimsFromContext

func ClaimsFromContext(ctx context.Context) token.RunClaims

ClaimsFromContext returns the verified run claims attached by the requireBearer middleware. Zero value if the middleware wasn't applied.

func NewServer

func NewServer(addr string, deps Deps) *http.Server

NewServer builds an *http.Server with all handlers registered under /internal/*. Bind the returned server to a localhost address (default in `cronfoundry serve` is 127.0.0.1:8080).

func RegisterRoutes

func RegisterRoutes(mux *http.ServeMux, deps Deps)

RegisterRoutes registers all /internal/* routes on mux. The caller is responsible for the /healthz route and http.Server construction.

Types

type Deps

type Deps struct {
	Pool          *pgxpool.Pool
	Signer        *token.Signer
	Secrets       server.SecretStore
	Installations *github.InstallationCache
	RunnerAPIKey  string // optional; when set, X-Runner-Key is accepted on /internal routes
}

Deps bundles everything a handler might need. Passed once at server construction; each handler type embeds a reference to it.

type RunContext

type RunContext struct {
	RunID           string          `json:"run_id"`
	OrgID           string          `json:"org_id"`
	ScheduleName    string          `json:"schedule_name"`
	SkillPath       string          `json:"skill_path"`
	SkillSha        string          `json:"skill_sha"`
	Repo            string          `json:"repo"` // "owner/name"
	RepoID          string          `json:"repo_id"`
	DefaultBranch   string          `json:"default_branch"`
	InstallationID  int64           `json:"installation_id"`
	Provider        string          `json:"provider"`
	Model           string          `json:"model"`
	TimeoutSec      int32           `json:"timeout_sec"`
	LLMSecretRef    *string         `json:"llm_secret_ref,omitempty"`
	LLMEndpoint     *string         `json:"llm_endpoint,omitempty"`
	LLMDeployment   *string         `json:"llm_deployment,omitempty"`
	Destinations    json.RawMessage `json:"destinations"`
	Writeback       json.RawMessage `json:"writeback,omitempty"`
	Env             json.RawMessage `json:"env"`
	FrontmatterJSON json.RawMessage `json:"frontmatter"`
	MCPEnv          json.RawMessage `json:"mcp_env,omitempty"`
	MaxTurns        *int32          `json:"max_turns,omitempty"`
	// SecretManifest lists the names of secrets this run is allowed to fetch;
	// derived from destinations/env/llm_secret_ref/mcp_env.
	SecretManifest []string `json:"secret_manifest"`
}

RunContext is the JSON returned to the runner. Field names are snake_case to match the rest of the /internal surface.

Jump to

Keyboard shortcuts

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