config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 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 config holds kōjō's two kinds of configuration.

Boot (this file) is the deployment config, kojo.yaml: what the process needs to start (database, public URL, secrets, sandbox driver). It changes with a redeploy.

Runtime (runtime.go) is the runtime config: skills, repos, schedules, model tiers, budgets, merge policy and RBAC. It lives in Postgres as versioned revisions, is edited from the dashboard and hot-reloaded.

Index

Constants

View Source
const (
	DriverSBX    = "sbx"
	DriverK8s    = "k8s"
	DriverE2B    = "e2b"
	DriverDocker = "docker"
	DriverFake   = "fake"
)

Sandbox driver names.

View Source
const (
	MergeDraftOnly = "draft_only"
	MergeAsk       = "ask"
	MergeAuto      = "auto_merge"
)

Merge policy modes.

View Source
const (
	RoleViewer    = "viewer"
	RoleSkillEdit = "skill:edit"
	RoleOperator  = "operator"
	RoleAdmin     = "admin"
)

Roles, weakest first.

View Source
const (
	// ObjModels is ModelSettings: tier to model mapping and budgets.
	ObjModels = "settings/models"
	// ObjMergePolicy is MergePolicy. A repository may override it.
	ObjMergePolicy = "settings/merge_policy"
	// ObjEgress is EgressLimits: what skills of a scope may reach and use.
	ObjEgress = "settings/egress"
	// ObjActivation is ActivationPolicy: the gate on activating a skill.
	ObjActivation = "settings/activation"
	// ObjSkillsSource is SkillsSourceSetting: dashboard or git.
	ObjSkillsSource = "settings/skills_source"
	// ObjRepos is Repos: which repositories are enabled.
	ObjRepos = "repos"
	// ObjRBAC is RBAC: users, roles and teams.
	ObjRBAC = "rbac"
	// ObjSchedules is Schedules: recurring jobs.
	ObjSchedules = "schedules"
	// ObjMemory is MemorySettings: what kōjō remembers and for whom. A
	// repository may override the learning switch.
	ObjMemory = "settings/memory"
	// ObjImprovement is ImprovementSettings: whether kōjō proposes changes
	// to the skills of a scope. Each scope has its own; a repository does
	// not inherit the org's.
	ObjImprovement = "settings/improvement"
	// ObjSkillPrefix prefixes a skill's object name: skill/fix-bug holds a
	// SkillFiles.
	ObjSkillPrefix = "skill/"
)

Day-2 config objects. Each is stored as revisions of (scope, object) and is what the dashboard edits. Org-wide objects live in the "org" scope; a repository overrides some of them in its own scope.

View Source
const (
	DefaultMaxRounds  = 3
	MaxFollowUpRounds = 20
)

Bounds of PRFollowUp.MaxRounds.

View Source
const (
	DefaultMinEvidence  = 3
	DefaultWindowDays   = 30
	DefaultCooldownDays = 7
)

Defaults of ImprovementSettings.

View Source
const DefaultApprovalTimeout = 2 * time.Hour

DefaultApprovalTimeout is how long a question of the merge policy waits for an answer when the policy does not say: half the default sandbox lifetime, so the change is still in its sandbox when the wait ends.

View Source
const MaxLinked = 8

MaxLinked bounds the linked repositories of one session: the ones its repository configures and the ones the request names.

View Source
const MinApprovalTimeout = time.Minute

MinApprovalTimeout is the shortest approval_timeout a policy may set.

Variables

View Source
var AutoEvents = []string{"issue_opened", "pr_opened", "pr_updated", "check_failed"}

AutoEvents are the forge events a repository can run a skill on without being mentioned.

CronParser parses the cron syntax schedules use.

View Source
var ErrUnchanged = errors.New("config: unchanged")

ErrUnchanged is returned by Put when the content equals the active one.

View Source
var ModelProviders = []string{"anthropic", "openai", "googleai", "openrouter", "ollama", "mock"}

ModelProviders lists the model providers the embedded gateway can call.

Roles lists every role, weakest first.

Functions

func DecodeObject

func DecodeObject(object string, content []byte) (any, error)

DecodeObject strictly decodes a config object's JSON into its type and validates it. Unknown objects are rejected.

func DefaultSensitivePaths

func DefaultSensitivePaths() []string

DefaultSensitivePaths are the globs that make a change high risk.

func HostAllowed

func HostAllowed(patterns []string, host string) bool

HostAllowed reports whether host matches one of the patterns.

func Interpolate

func Interpolate(raw []byte, env func(string) (string, bool)) ([]byte, error)

Interpolate replaces ${VAR} and ${VAR:-default} in the document's scalar values with values from env, and returns the resulting YAML. "$$" is a literal dollar. Every unset variable without a default is reported in one error.

Substitution happens on the parsed document, not on its text: a value is always one YAML scalar whatever it contains (a PEM key with newlines, a password with "#" or ": "), keys and comments are never touched, and a commented-out block does not demand its variables.

func LinkedName

func LinkedName(repo string) string

LinkedName is the directory a linked repository gets under .kojo/linked: the last segment of its forge/owner/name.

func ParseCron

func ParseCron(expr, tz string) (cron.Schedule, error)

ParseCron parses a schedule's cron expression in its time zone.

func RoleAtLeast

func RoleAtLeast(roles []string, min string) bool

RoleAtLeast reports whether any of roles grants at least min.

func ValidHostPattern

func ValidHostPattern(h string) error

ValidHostPattern accepts a hostname or "*.domain". Single-label names are hostnames too (a service name on a compose or cluster network). A bare "*" would turn deny-all into allow-all and is refused.

func ValidLinkedRepo

func ValidLinkedRepo(repo string) bool

ValidLinkedRepo reports whether repo can be a linked repository: a forge/owner/name whose segments are plain names.

Types

type APIToken

type APIToken struct {
	Name  string `yaml:"name" json:"name"`
	Token string `yaml:"token" json:"token"`
	// Role is viewer, skill:edit, operator or admin. Default operator.
	Role string `yaml:"role,omitempty" json:"role,omitempty"`
}

APIToken is a static bearer token.

type Activation

type Activation struct {
	RequireEval     bool    `yaml:"require_eval,omitempty" json:"require_eval,omitempty"`
	MinEvalPassRate float64 `yaml:"min_eval_pass_rate,omitempty" json:"min_eval_pass_rate,omitempty"`
}

Activation gates a skill going live.

type ActivationPolicy

type ActivationPolicy struct {
	RequireEval     bool    `json:"require_eval" yaml:"require_eval"`
	MinEvalPassRate float64 `json:"min_eval_pass_rate" yaml:"min_eval_pass_rate"`
	// RequireSecondReviewer refuses activation by the draft's own author.
	RequireSecondReviewer bool `json:"require_second_reviewer" yaml:"require_second_reviewer"`
}

ActivationPolicy gates a skill draft going live.

type ApplyResult

type ApplyResult struct {
	Scope    string `json:"scope"`
	Object   string `json:"object"`
	Revision string `json:"revision,omitempty"`
	Changed  bool   `json:"changed"`
}

ApplyResult says what Apply did to one object.

type Auth

type Auth struct {
	OIDC *OIDC `yaml:"oidc,omitempty" json:"oidc,omitempty"`
	// Tokens are static API tokens for the CLI, CI and MCP clients.
	Tokens []APIToken `yaml:"tokens,omitempty" json:"tokens,omitempty"`
	// Admins are the emails written to the rbac object with the admin role
	// on the first start against an empty database. After that, roles are
	// managed in the dashboard and a change here has no effect.
	Admins []string `yaml:"admins,omitempty" json:"admins,omitempty"`
	// SessionSecret signs the dashboard's session cookie. When empty a
	// random one is generated at start, which signs everyone out on restart
	// and does not work with more than one replica.
	SessionSecret string `yaml:"session_secret,omitempty" json:"session_secret,omitempty"`
}

Auth configures who may use the dashboard and the API.

type Boot

type Boot struct {
	// Dev turns on development mode: it allows the insecure sandbox drivers
	// (docker, fake), runc on Kubernetes and a dashboard without OIDC. kojo
	// doctor fails a production check while it is set.
	Dev      bool     `yaml:"dev,omitempty" json:"dev,omitempty"`
	Server   Server   `yaml:"server" json:"server"`
	Database Database `yaml:"database" json:"database"`
	Forges   Forges   `yaml:"forges,omitempty" json:"forges,omitempty"`
	Chat     Chat     `yaml:"chat,omitempty" json:"chat,omitempty"`
	Models   Models   `yaml:"models" json:"models"`
	Sandbox  Sandbox  `yaml:"sandbox" json:"sandbox"`
	// Defaults are initial values only: after install they are managed in
	// the dashboard and stored as config revisions.
	Defaults Defaults `yaml:"defaults,omitempty" json:"defaults,omitempty"`
	// Seed is only read on the first start against an empty database.
	Seed      Seed      `yaml:"seed,omitempty" json:"seed,omitempty"`
	Telemetry Telemetry `yaml:"telemetry,omitempty" json:"telemetry,omitempty"`
}

Boot is kojo.yaml.

func Load

func Load(path string) (*Boot, error)

Load reads kojo.yaml, expands ${VAR} references from the environment, applies defaults and validates. Unknown keys are errors.

func Parse

func Parse(raw []byte, env func(string) (string, bool)) (*Boot, error)

Parse is Load on bytes, with the environment passed in.

func (*Boot) ApplyDefaults

func (b *Boot) ApplyDefaults()

ApplyDefaults fills every unset field that has a default.

func (*Boot) ForgeNames

func (b *Boot) ForgeNames() []string

ForgeNames lists the configured forges.

func (*Boot) Redacted

func (b *Boot) Redacted() *Boot

Redacted returns a copy with every secret replaced, safe to print.

func (*Boot) Validate

func (b *Boot) Validate() error

Validate reports every problem at once.

type Budgets

type Budgets struct {
	PerSessionUSD float64 `yaml:"per_session_usd,omitempty" json:"per_session_usd,omitempty"`
	PerDayUSD     float64 `yaml:"per_day_usd,omitempty" json:"per_day_usd,omitempty"`
}

Budgets are spend caps. A session that reaches its own cap stops and delivers what it has with a report. The daily cap counts every session of the install over the last 24 hours, evals included: once it is reached, sessions that have not started wait, and running ones stop at their next model call.

type Chat

type Chat struct {
	Slack      *Slack      `yaml:"slack,omitempty" json:"slack,omitempty"`
	Teams      *Teams      `yaml:"teams,omitempty" json:"teams,omitempty"`
	Discord    *Discord    `yaml:"discord,omitempty" json:"discord,omitempty"`
	Mattermost *Mattermost `yaml:"mattermost,omitempty" json:"mattermost,omitempty"`
}

Chat are the chat surfaces.

type Database

type Database struct {
	URL      string `yaml:"url" json:"url"`
	MaxConns int    `yaml:"max_conns,omitempty" json:"max_conns,omitempty"`
}

Database is the Postgres connection. Postgres is the only hard dependency.

type Defaults

type Defaults struct {
	// MergePolicy is draft_only (default), ask or auto_merge.
	MergePolicy string `yaml:"merge_policy,omitempty" json:"merge_policy,omitempty"`
	// SkillsRepo is the shared repository of org-level skills, as
	// forge/owner/name. It is used when the org's skills are edited in git
	// (seed.skills_source.org).
	SkillsRepo string `yaml:"skills_repo,omitempty" json:"skills_repo,omitempty"`
}

Defaults seed the runtime settings.

type Discord

type Discord struct {
	// BotToken is the bot's token from the Discord developer portal.
	BotToken string `yaml:"bot_token" json:"bot_token"`
	// ApplicationID is the application the bot belongs to. When set, kojo
	// doctor checks that the token is that application's.
	ApplicationID string `yaml:"application_id,omitempty" json:"application_id,omitempty"`
	// GuildID is the ID of the server kōjō serves. Messages from other
	// servers are ignored, and a direct message is only taken from a
	// member of this server.
	GuildID string `yaml:"guild_id" json:"guild_id"`
	// Roles maps the ID of a role of that server to a kōjō role: viewer,
	// skill:edit, operator or admin. Discord gives a bot no email, so this
	// is how a sender gets a role; someone without a mapped role is
	// answered read-only. The server's own ID stands for @everyone.
	Roles map[string]string `yaml:"roles,omitempty" json:"roles,omitempty"`
	// Users maps a Discord user ID to the email of that person's entry in
	// the rbac object, for people whose roles are managed there. Those
	// roles add to the ones from Roles.
	Users map[string]string `yaml:"users,omitempty" json:"users,omitempty"`
	// APIURL overrides https://discord.com/api (a mock in tests).
	APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
}

Discord is the Discord bot. It holds a gateway connection, so it needs no public ingress.

type DockerDriver

type DockerDriver struct {
	// Binary is the docker CLI. Default "docker" on PATH.
	Binary string `yaml:"binary,omitempty" json:"binary,omitempty"`
	// Network is the Docker network sandboxes join. kōjō creates an internal
	// one (no route out except the proxy) when empty.
	Network string `yaml:"network,omitempty" json:"network,omitempty"`
}

DockerDriver runs sandboxes as plain containers. Development only.

type Duration

type Duration time.Duration

Duration is a time.Duration written as "30m" in YAML and JSON.

func (Duration) D

func (d Duration) D() time.Duration

D returns the time.Duration.

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText writes the duration as a string.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(b []byte) error

UnmarshalText parses "30m", "2h".

type E2BDriver

type E2BDriver struct {
	// APIKey authenticates to the service.
	APIKey string `yaml:"api_key" json:"api_key"`
	// APIURL is the service's control API. Default https://api.<domain>.
	APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
	// Domain is where sandboxes are reachable (<port>-<id>.<domain>).
	// Default e2b.app.
	Domain string `yaml:"domain,omitempty" json:"domain,omitempty"`
	// SandboxURL is one fixed URL for every sandbox, for a service whose
	// sandbox proxy routes by header instead of by host name (CubeSandbox
	// without a wildcard domain). Default: https://<port>-<id>.<domain>.
	SandboxURL string `yaml:"sandbox_url,omitempty" json:"sandbox_url,omitempty"`
	// Template is the sandbox template used when a skill's kit names no
	// image and sandbox.image is not set. On this driver a kit's image is a
	// template name or ID.
	Template string `yaml:"template,omitempty" json:"template,omitempty"`
}

E2BDriver runs sandboxes on an E2B-compatible service: E2B Cloud, a self-hosted E2B, or CubeSandbox. Each sandbox is a microVM the service runs; kōjō reaches it over the service's API. The service's sandboxes must be able to connect to kojo-proxy (sandbox.proxy.advertise_url): it is the only destination they are allowed.

type EgressLimits

type EgressLimits struct {
	// AllowedHosts are hostnames ("*.example.com" matches subdomains).
	AllowedHosts []string `json:"allowed_hosts" yaml:"allowed_hosts"`
	// AllowedCredentials are credential names: github, gitlab, forgejo.
	AllowedCredentials []string `json:"allowed_credentials" yaml:"allowed_credentials"`
}

EgressLimits bound what a skill's kit may ask for. Drafts cannot widen egress or add credentials beyond them; only an admin edits them.

func DefaultEgress

func DefaultEgress(forgeHosts []string) EgressLimits

DefaultEgress is the allowlist a new install starts with: the package registries and forges the built-in skills need.

func (EgressLimits) Validate

func (e EgressLimits) Validate() error

Validate checks host patterns.

type Export

type Export struct {
	Version int            `json:"version" yaml:"version"`
	Objects []ExportObject `json:"objects" yaml:"objects"`
}

Export is the full runtime config as a document: what `kojo config export` writes and `kojo config apply` reads.

type ExportObject

type ExportObject struct {
	Scope   string `json:"scope" yaml:"scope"`
	Object  string `json:"object" yaml:"object"`
	Content any    `json:"content" yaml:"content"`
}

ExportObject is one active config object.

type FollowUp

type FollowUp struct {
	// Skill is the skill to run on each repository.
	Skill string `json:"skill" yaml:"skill"`
	// Repos are the repositories to run it on, as forge/owner/name.
	Repos []string `json:"repos" yaml:"repos"`
}

FollowUp is work a merged pull request starts on other repositories.

type Forgejo

type Forgejo struct {
	BaseURL       string `yaml:"base_url" json:"base_url"`
	Token         string `yaml:"token" json:"token"`
	WebhookSecret string `yaml:"webhook_secret" json:"webhook_secret"`
}

Forgejo is a Forgejo or Gitea instance reached with an access token.

type Forges

type Forges struct {
	GitHub  *GitHub  `yaml:"github,omitempty" json:"github,omitempty"`
	GitLab  *GitLab  `yaml:"gitlab,omitempty" json:"gitlab,omitempty"`
	Forgejo *Forgejo `yaml:"forgejo,omitempty" json:"forgejo,omitempty"`
}

Forges are the code forges kōjō is connected to.

type GitHub

type GitHub struct {
	AppID string `yaml:"app_id" json:"app_id"`
	// PrivateKeyFile is the App's PEM private key. PrivateKey holds the PEM
	// itself instead (from an environment variable).
	PrivateKeyFile string `yaml:"private_key_file,omitempty" json:"private_key_file,omitempty"`
	PrivateKey     string `yaml:"private_key,omitempty" json:"private_key,omitempty"`
	WebhookSecret  string `yaml:"webhook_secret" json:"webhook_secret"`
	// BaseURL is the API root of a GitHub Enterprise Server
	// (https://ghe.example.com/api/v3). Empty means github.com.
	BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
}

GitHub is a GitHub App (github.com or Enterprise Server).

type GitLab

type GitLab struct {
	// BaseURL defaults to https://gitlab.com.
	BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
	Token   string `yaml:"token" json:"token"`
	// WebhookSecret is the webhook's secret token (X-Gitlab-Token).
	WebhookSecret string `yaml:"webhook_secret" json:"webhook_secret"`
}

GitLab is a GitLab instance reached with a project or group access token.

type Identity

type Identity struct {
	Email string `json:"email" yaml:"email"`
	// Logins are accounts as surface:id: github:alice, gitlab:alice,
	// forgejo:alice, slack:U02ABCDEF, token:alice-laptop (an API token's
	// name).
	Logins []string `json:"logins" yaml:"logins"`
}

Identity says that some accounts belong to the person with this email.

type ImprovementSettings

type ImprovementSettings struct {
	Enabled bool `json:"enabled" yaml:"enabled"`
	// Skills are the skills kōjō may propose changes to. Empty means every
	// skill the scope resolves.
	Skills []string `json:"skills,omitempty" yaml:"skills,omitempty"`
	// MinEvidence is how many pieces of evidence a proposal needs. Default
	// 3, and never less than 2: one data point is not a pattern.
	MinEvidence int `json:"min_evidence,omitempty" yaml:"min_evidence,omitempty"`
	// WindowDays is how far back evidence is read. Default 30.
	WindowDays int `json:"window_days,omitempty" yaml:"window_days,omitempty"`
	// CooldownDays is the least time between two proposals the periodic
	// check makes for one skill. Default 7.
	CooldownDays int `json:"cooldown_days,omitempty" yaml:"cooldown_days,omitempty"`
	// Notify is the chat channel told when a proposal is ready for review:
	// a channel ID, or surface:channel, as for a schedule.
	Notify string `json:"notify,omitempty" yaml:"notify,omitempty"`
}

ImprovementSettings turns self-improvement on for one scope: kōjō then proposes changes to that scope's skills from the evidence it gathers (the goal critic's rejections, lessons learned from reviews, pull requests closed unmerged or edited by a person). A proposal is a draft, measured by evals, that only a person can activate. It is off unless Enabled is set, because it spends model tokens and eval time. The org's object covers proposals for the org's skills, from every repository's evidence; a repository's object covers proposals for that repository alone. Only an admin edits it.

func (*ImprovementSettings) ApplyDefaults

func (i *ImprovementSettings) ApplyDefaults()

ApplyDefaults fills the unset numbers.

func (ImprovementSettings) Covers

func (i ImprovementSettings) Covers(skill string) bool

Covers reports whether the settings let kōjō propose for a skill.

func (ImprovementSettings) Validate

func (i ImprovementSettings) Validate() error

Validate checks the numbers and the skill names.

type K8sDriver

type K8sDriver struct {
	// Namespace sandboxes run in. Default: kōjō's own namespace.
	Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	// RuntimeClass is kata, gvisor, or a cluster-specific name.
	RuntimeClass string `yaml:"runtime_class,omitempty" json:"runtime_class,omitempty"`
	// WarmPoolSize is the number of pre-warmed pods per template.
	WarmPoolSize int `yaml:"warm_pool_size,omitempty" json:"warm_pool_size,omitempty"`
	// ProxyImage records the image of kojo-proxy. The binary does not read
	// it: the Helm chart deploys the proxy and writes its image here so the
	// rendered config says what runs.
	ProxyImage string `yaml:"proxy_image,omitempty" json:"proxy_image,omitempty"`
	// Kubeconfig is used outside a cluster. Empty means in-cluster config.
	Kubeconfig   string `yaml:"kubeconfig,omitempty" json:"kubeconfig,omitempty"`
	StorageClass string `yaml:"storage_class,omitempty" json:"storage_class,omitempty"`
	// UnschedulableTimeout is how long a sandbox pod may stay unschedulable
	// (no node has room for its requests) before creating the sandbox fails
	// with the scheduler's reason. It is the time a cluster autoscaler gets
	// to add a node. Default 2m. Starting a sandbox has 5 minutes in all, so
	// a longer value waits at most that long.
	UnschedulableTimeout Duration `yaml:"unschedulable_timeout,omitempty" json:"unschedulable_timeout,omitempty"`
}

K8sDriver is Kubernetes Agent Sandbox.

type Manager

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

Manager serves the day-2 config. It keeps the active revision of every object in memory, follows activations made on any replica (LISTEN/NOTIFY through store.WatchConfig) and hands sessions an immutable Snapshot, so a session in flight keeps the revisions it started with.

func NewManager

func NewManager(st store.Store, log *slog.Logger) *Manager

NewManager returns a manager over st. Call Load before using it.

func (*Manager) Active

func (m *Manager) Active(scope, object string) (store.Revision, bool)

Active returns the active revision of an object.

func (*Manager) ActiveAll

func (m *Manager) ActiveAll() []store.Revision

ActiveAll returns every active revision, sorted by scope and object.

func (*Manager) Apply

func (m *Manager) Apply(ctx context.Context, e *Export, author string, dryRun bool) ([]ApplyResult, error)

Apply loads an export: every object that differs from the active one becomes a new active revision. Everything is validated before anything is written. With dryRun nothing is written at all.

func (*Manager) Export

func (m *Manager) Export() (*Export, error)

Export returns every active object.

func (*Manager) Improvement

func (m *Manager) Improvement(scope string) ImprovementSettings

Improvement returns the self-improvement settings of one scope, with the defaults applied. Each scope has its own object: a repository does not inherit the org's, so turning it on for the org proposes for the org's skills only.

func (*Manager) ImprovementScopes

func (m *Manager) ImprovementScopes() []string

ImprovementScopes returns the scopes where self-improvement is turned on, sorted.

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load reads every active revision.

func (*Manager) Put

func (m *Manager) Put(ctx context.Context, scope, object string, value any, author, message string) (*store.Revision, error)

Put validates value as the given object, stores it as a new revision and activates it. It returns ErrUnchanged, and writes nothing, when the object already has exactly this content.

func (*Manager) PutRaw

func (m *Manager) PutRaw(ctx context.Context, scope, object string, content json.RawMessage, author, message string) (*store.Revision, error)

PutRaw is Put for content that is already JSON.

func (*Manager) Rollback

func (m *Manager) Rollback(ctx context.Context, revisionID, actor string) (*store.Revision, error)

Rollback activates an earlier revision of an object.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run applies config changes as they are activated, until ctx ends. This is the hot reload: no restart, no redeploy.

func (*Manager) Schedules

func (m *Manager) Schedules() []ScopedSchedule

Schedules returns every schedule of every scope.

func (*Manager) Seed

func (m *Manager) Seed(ctx context.Context, b *Boot, forgeHosts []string) error

Seed writes the initial day-2 state from kojo.yaml. It only creates objects that do not exist yet, so it is safe on every start: after the first one the dashboard owns these values.

func (*Manager) Skills

func (m *Manager) Skills(scope string) map[string]ScopedSkill

Skills returns the dashboard-managed skills of a scope, by name.

func (*Manager) Snapshot

func (m *Manager) Snapshot(repo string) *Snapshot

Snapshot resolves the config for a repository: its own overrides first, then the org's. An empty repo gives the org's config.

func (*Manager) SnapshotAt

func (m *Manager) SnapshotAt(ctx context.Context, repo string, revisions map[string]string) *Snapshot

SnapshotAt rebuilds the snapshot a session started with from the revision IDs it recorded, so a resumed session keeps its config even if the dashboard changed it meanwhile. Revisions that cannot be read fall back to the active ones.

func (*Manager) Subscribe

func (m *Manager) Subscribe(fn func(store.ConfigChange))

Subscribe registers fn to be called after a change has been applied. It must be called before Run.

type Mattermost

type Mattermost struct {
	// URL is the server's base URL (https://chat.example.com).
	URL string `yaml:"url" json:"url"`
	// Token is the bot account's access token.
	Token string `yaml:"token" json:"token"`
	// ActionSecret signs the buttons kōjō posts, so a click can be told
	// from a forged request. Generated at start when empty, which does not
	// survive a restart or work with several replicas.
	ActionSecret string `yaml:"action_secret,omitempty" json:"action_secret,omitempty"`
}

Mattermost is a bot account on a Mattermost server. It holds a WebSocket connection to the server; button clicks come back to <public_url>/mattermost/actions.

type MemorySettings

type MemorySettings struct {
	// LearnFromReviews turns learning from maintainer feedback on or off:
	// when on (the default), what a maintainer writes in a review of a pull
	// request kōjō opened is distilled into lessons, saved as team memory
	// of the repository. In a repository's scope it overrides the org's
	// value for that repository; unset there means "as the org".
	LearnFromReviews *bool `json:"learn_from_reviews,omitempty" yaml:"learn_from_reviews,omitempty"`
	// Personal turns per-person memory on or off (default on). When off,
	// sessions neither read nor save personal memories; the ones already
	// stored stay until their owners or an admin delete them. Read from the
	// org's object only.
	Personal *bool `json:"personal,omitempty" yaml:"personal,omitempty"`
	// Identities link a person's accounts on the forges and in chat to
	// their email, so their personal memory follows them from one surface
	// to another. Read from the org's object only.
	Identities []Identity `json:"identities,omitempty" yaml:"identities,omitempty"`
}

MemorySettings controls what kōjō remembers on its own and whose memory a request reads. Only an admin edits it.

func (MemorySettings) EmailOf

func (m MemorySettings) EmailOf(login string) string

EmailOf returns the email an account (surface:id) is linked to, or "". Account names compare without case, as forges do.

func (MemorySettings) Learns

func (m MemorySettings) Learns() bool

Learns reports whether lessons are learned from reviews.

func (MemorySettings) PersonalOn

func (m MemorySettings) PersonalOn() bool

PersonalOn reports whether per-person memory is in use.

func (MemorySettings) Validate

func (m MemorySettings) Validate() error

Validate checks the identity links: each names an email and accounts as surface:id, and no account belongs to two people.

type MergePolicy

type MergePolicy struct {
	// Inherit, in a repository's scope, means "no override": the org's
	// policy applies. It is how an override is taken back.
	Inherit bool `json:"inherit,omitempty" yaml:"inherit,omitempty"`
	// Mode is draft_only (default): always a draft pull request; ask: a
	// human approves in chat before the pull request is opened ready for
	// review; auto_merge: low-risk changes merge once required checks are
	// green, medium-risk ones ask, high-risk ones stay drafts.
	Mode string `json:"mode" yaml:"mode"`
	// TriggerPermission is the forge permission a user needs for a request
	// to cause write actions: read, triage, write (default), maintain or
	// admin. Requests from anyone else are answered read-only.
	TriggerPermission string `json:"trigger_permission,omitempty" yaml:"trigger_permission,omitempty"`
	// MergeMethod is merge, squash (default) or rebase.
	MergeMethod string `json:"merge_method,omitempty" yaml:"merge_method,omitempty"`
	// ApprovalTimeout is how long a question the policy asks in chat stays
	// open: "Open a pull request?" (ask) and "Merge this pull request?"
	// (auto_merge, medium risk). Without an answer by then, the change is
	// opened as a draft pull request, or the pull request stays open
	// without a merge. Default 2h, at least 1m. "Open a pull request?"
	// closes no later than 30 minutes before the session's sandbox expires
	// (sandbox.ttl), because the change is read from the sandbox when it is
	// published.
	ApprovalTimeout Duration   `json:"approval_timeout,omitempty" yaml:"approval_timeout,omitempty"`
	Risk            RiskPolicy `json:"risk,omitempty" yaml:"risk,omitempty"`
}

MergePolicy decides what happens to a change the factory produced.

func (*MergePolicy) ApplyDefaults

func (m *MergePolicy) ApplyDefaults()

ApplyDefaults fills a merge policy's unset fields.

func (MergePolicy) Validate

func (m MergePolicy) Validate() error

Validate checks the mode and thresholds.

type ModelRef

type ModelRef struct {
	// Provider is anthropic, openai, googleai, openrouter, ollama or mock.
	// Anything else (Bedrock, Azure, vLLM) is reached through the openai
	// provider's base_url or an external gateway.
	Provider string `yaml:"provider" json:"provider"`
	Model    string `yaml:"model" json:"model"`
}

ModelRef names a model on a provider.

type ModelSettings

type ModelSettings struct {
	Tiers   map[string]Tier `json:"tiers" yaml:"tiers"`
	Budgets Budgets         `json:"budgets" yaml:"budgets"`
}

ModelSettings maps tiers to models and caps spend.

func (ModelSettings) Validate

func (m ModelSettings) Validate() error

Validate checks tiers and budgets.

type Models

type Models struct {
	// Gateway is "embedded" (Genkit runs in the kōjō process and calls the
	// providers directly) or the base URL of an OpenAI-compatible gateway
	// such as hikyaku (http://hikyaku:8080/v1).
	Gateway string `yaml:"gateway,omitempty" json:"gateway,omitempty"`
	// GatewayAPIKey authenticates to an external gateway.
	GatewayAPIKey string `yaml:"gateway_api_key,omitempty" json:"gateway_api_key,omitempty"`
	// Tiers map a tier name (fast, strong) to a model. Initial values only:
	// managed in the dashboard after install.
	Tiers map[string]Tier `yaml:"tiers" json:"tiers"`
	// Budgets are initial values only.
	Budgets Budgets `yaml:"budgets,omitempty" json:"budgets,omitempty"`
	// Embedder is the embedding model of team memory. Without one, memory
	// search falls back to Postgres full-text search.
	Embedder  *ModelRef `yaml:"embedder,omitempty" json:"embedder,omitempty"`
	Providers Providers `yaml:"providers,omitempty" json:"providers,omitempty"`
	// Recordings is the directory of recorded responses the mock provider
	// replays. KOJO_LIVE_MODELS=1 ignores it and calls the real providers.
	Recordings string `yaml:"recordings,omitempty" json:"recordings,omitempty"`
}

Models is the model gateway.

type OIDC

type OIDC struct {
	Issuer       string   `yaml:"issuer" json:"issuer"`
	ClientID     string   `yaml:"client_id" json:"client_id"`
	ClientSecret string   `yaml:"client_secret,omitempty" json:"client_secret,omitempty"`
	Scopes       []string `yaml:"scopes,omitempty" json:"scopes,omitempty"`
	// AllowedDomains restricts sign-in to these email domains.
	AllowedDomains []string `yaml:"allowed_domains,omitempty" json:"allowed_domains,omitempty"`
}

OIDC is the identity provider of the dashboard.

type Ollama

type Ollama struct {
	// URL defaults to http://localhost:11434.
	URL string `yaml:"url,omitempty" json:"url,omitempty"`
}

Ollama is a local Ollama server, for air-gapped installs.

type OpenAI

type OpenAI struct {
	APIKey  string `yaml:"api_key,omitempty" json:"api_key,omitempty"`
	BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
}

OpenAI is OpenAI or any OpenAI-compatible server (vLLM, Azure, LiteLLM).

type PRFollowUp

type PRFollowUp struct {
	// Checks lets a failed check on one of kōjō's open pull requests start
	// a follow-up that tries to fix it. Nobody asked for that one, so it is
	// off unless the repository opts in, and it runs only while whoever
	// asked for the pull request still has the trigger permission.
	Checks bool `json:"checks,omitempty" yaml:"checks,omitempty"`
	// MaxRounds is how many follow-ups one pull request gets, counted
	// across sessions. 0 means DefaultMaxRounds.
	MaxRounds int `json:"max_rounds,omitempty" yaml:"max_rounds,omitempty"`
}

PRFollowUp is how kōjō continues its own pull requests in a repository.

func (PRFollowUp) Rounds

func (p PRFollowUp) Rounds() int

Rounds is the cap on follow-ups per pull request.

type Price

type Price struct {
	InputPerMTok  float64 `yaml:"input_per_mtok" json:"input_per_mtok"`
	OutputPerMTok float64 `yaml:"output_per_mtok" json:"output_per_mtok"`
}

Price is what a model costs, in USD per million tokens.

type ProviderKey

type ProviderKey struct {
	APIKey string `yaml:"api_key,omitempty" json:"api_key,omitempty"`
}

ProviderKey is a provider that only needs an API key.

type Providers

type Providers struct {
	Anthropic  ProviderKey `yaml:"anthropic,omitempty" json:"anthropic,omitempty"`
	OpenAI     OpenAI      `yaml:"openai,omitempty" json:"openai,omitempty"`
	GoogleAI   ProviderKey `yaml:"googleai,omitempty" json:"googleai,omitempty"`
	OpenRouter ProviderKey `yaml:"openrouter,omitempty" json:"openrouter,omitempty"`
	Ollama     Ollama      `yaml:"ollama,omitempty" json:"ollama,omitempty"`
}

Providers hold per-provider settings. API keys are read from here or from the provider's usual environment variable (ANTHROPIC_API_KEY, ...).

type ProxySettings

type ProxySettings struct {
	// Mode is embedded (the proxy runs in the kōjō process) or remote (a
	// separate `kojo proxy` deployment). Default: embedded, and remote for
	// the k8s driver.
	Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
	// Listen is the address sandboxes connect to. Default ":3128".
	Listen string `yaml:"listen,omitempty" json:"listen,omitempty"`
	// AdvertiseURL is the proxy's address as sandboxes see it
	// (http://kojo-proxy.kojo.svc:3128).
	AdvertiseURL string `yaml:"advertise_url,omitempty" json:"advertise_url,omitempty"`
	// AdminURL is the remote proxy's admin API (http://kojo-proxy:3129). It
	// is one replica, unless admin_discovery is dns.
	AdminURL string `yaml:"admin_url,omitempty" json:"admin_url,omitempty"`
	// AdminDiscovery is how kōjō finds the proxy's replicas. Empty: one
	// replica at admin_url, or the replicas of admin_urls. dns: every
	// address the host of admin_url resolves to is a replica, resolved again
	// every 5 seconds; on Kubernetes, a headless Service that publishes
	// replicas before they are ready, as the Helm chart's proxy-admin
	// Service does. Several replicas need ca_cert_file and ca_key_file.
	AdminDiscovery string `yaml:"admin_discovery,omitempty" json:"admin_discovery,omitempty"`
	// AdminURLs are the admin APIs of several replicas, instead of
	// admin_url, for replicas at fixed addresses.
	AdminURLs []string `yaml:"admin_urls,omitempty" json:"admin_urls,omitempty"`
	// SyncTimeout is how long a `kojo proxy` replica waits, after it
	// starts, for a kōjō server to send it the sandbox policies before it
	// reports ready on /readyz anyway. Until a kōjō server has synced it, a
	// replica is not ready and takes no sandbox traffic. Default 30s.
	SyncTimeout Duration `yaml:"sync_timeout,omitempty" json:"sync_timeout,omitempty"`
	// AdminListen is the address of the admin API in `kojo proxy`.
	// Default ":3129".
	AdminListen string `yaml:"admin_listen,omitempty" json:"admin_listen,omitempty"`
	// AdminToken authenticates the core to the admin API.
	AdminToken string `yaml:"admin_token,omitempty" json:"admin_token,omitempty"`
	// CACertFile and CAKeyFile hold the CA that signs the certificates of
	// hosts the proxy injects credentials on. Generated when empty.
	CACertFile string `yaml:"ca_cert_file,omitempty" json:"ca_cert_file,omitempty"`
	CAKeyFile  string `yaml:"ca_key_file,omitempty" json:"ca_key_file,omitempty"`
	// AllowPrivate lets sandboxes reach allowlisted hosts on loopback,
	// link-local and private addresses. It is off by default, which stops a
	// sandbox from using the proxy to reach the cluster's or the cloud's
	// internal services; turn it on for a forge on a private network.
	AllowPrivate bool `yaml:"allow_private,omitempty" json:"allow_private,omitempty"`
	// UpstreamCAFile holds extra root certificates (PEM) the proxy trusts
	// when it connects to a host it injects credentials on: a forge with a
	// private CA.
	UpstreamCAFile string `yaml:"upstream_ca_file,omitempty" json:"upstream_ca_file,omitempty"`
}

ProxySettings configure kojo-proxy.

type RBAC

type RBAC struct {
	// Users maps an email to its roles.
	Users map[string][]string `json:"users" yaml:"users"`
	Teams map[string]Team     `json:"teams,omitempty" yaml:"teams,omitempty"`
}

RBAC maps people to roles.

func (RBAC) RolesOf

func (r RBAC) RolesOf(email string) []string

RolesOf returns the roles of an email, directly and through teams.

func (RBAC) Validate

func (r RBAC) Validate() error

Validate checks emails and role names.

type RepoEntry

type RepoEntry struct {
	Enabled bool `json:"enabled" yaml:"enabled"`
	// Skills limits the repository to these skills. Empty means all.
	Skills []string `json:"skills,omitempty" yaml:"skills,omitempty"`
	// Auto runs a skill on a forge event without anyone mentioning kōjō:
	// issue_opened: triage, pr_opened: review-pr, pr_updated: review-pr,
	// check_failed: fix-bug. Empty means kōjō only acts when mentioned. A
	// skill that changes code only runs when whoever caused the event has
	// the repository's trigger permission: an outsider's pull request, or a
	// CI bot's failed check, never starts one.
	Auto map[string]string `json:"auto,omitempty" yaml:"auto,omitempty"`
	// AllowAutoMerge lets this repository use the auto_merge policy. Only
	// an admin sets it: a repository's own factory.yaml cannot opt itself in.
	AllowAutoMerge bool `json:"allow_auto_merge,omitempty" yaml:"allow_auto_merge,omitempty"`
	// OnMerge starts work on other repositories when a pull request is
	// merged in this one. Each entry runs its skill on each of its
	// repositories, with the merged pull request attached as the reference
	// repository "source": the way a change to one SDK is ported to the
	// others (skill port-sdk). The sessions may change code, as if an
	// operator had started them; a target that is not enabled is skipped.
	OnMerge []FollowUp `json:"on_merge,omitempty" yaml:"on_merge,omitempty"`
	// Linked are the other repositories of the same product, as
	// forge/owner/name: an API and its web client, a service and its SDKs.
	// Every session on this repository clones them next to the workspace
	// at .kojo/linked/<name> (<name> is the last path segment), may change
	// the ones the requester may change, and opens one pull request per
	// repository that changed. A linked repository that is not enabled is
	// left out. Only the repos object sets it: a repository's own
	// factory.yaml cannot give itself access to others.
	Linked []string `json:"linked,omitempty" yaml:"linked,omitempty"`
	// FollowUp says how kōjō continues its own pull requests here: a
	// mention on one adds commits to it instead of opening another pull
	// request, a failed check on one can too, and both stop after a number
	// of rounds.
	FollowUp *PRFollowUp `json:"follow_up,omitempty" yaml:"follow_up,omitempty"`
}

RepoEntry is one repository's switch.

func (RepoEntry) FollowUps

func (e RepoEntry) FollowUps() PRFollowUp

FollowUps is the repository's follow-up setting, the defaults when it has none.

type Repos

type Repos struct {
	Repos map[string]RepoEntry `json:"repos" yaml:"repos"`
}

Repos lists the repositories the factory works on.

type RiskPolicy

type RiskPolicy struct {
	// MaxChangedLines is the diff size at which size alone is high risk.
	// Default 400.
	MaxChangedLines int `json:"max_changed_lines,omitempty" yaml:"max_changed_lines,omitempty"`
	// SensitivePaths are globs that make a change high risk when touched.
	// Default: CI config, deployment manifests, migrations, auth code.
	SensitivePaths []string `json:"sensitive_paths,omitempty" yaml:"sensitive_paths,omitempty"`
	// LowBelow and HighAbove split the score into low, medium and high.
	// Defaults 0.3 and 0.6.
	LowBelow  float64 `json:"low_below,omitempty" yaml:"low_below,omitempty"`
	HighAbove float64 `json:"high_above,omitempty" yaml:"high_above,omitempty"`
	// Classifier adds a fast-tier model's opinion to the rules.
	Classifier bool `json:"classifier,omitempty" yaml:"classifier,omitempty"`
}

RiskPolicy holds the deterministic rules of the risk score.

type SBXDriver

type SBXDriver struct {
	// Binary is the sbx CLI. Default "sbx" on PATH.
	Binary string `yaml:"binary,omitempty" json:"binary,omitempty"`
	// KitsDir is where kōjō writes the kit it generates per skill.
	KitsDir string `yaml:"kits_dir,omitempty" json:"kits_dir,omitempty"`
}

SBXDriver is Docker Sandboxes: one microVM per session.

type Sandbox

type Sandbox struct {
	// Driver is sbx, k8s or e2b. docker and fake exist for development and
	// need dev: true.
	Driver string        `yaml:"driver" json:"driver"`
	SBX    SBXDriver     `yaml:"sbx,omitempty" json:"sbx,omitempty"`
	K8s    K8sDriver     `yaml:"k8s,omitempty" json:"k8s,omitempty"`
	E2B    E2BDriver     `yaml:"e2b,omitempty" json:"e2b,omitempty"`
	Docker DockerDriver  `yaml:"docker,omitempty" json:"docker,omitempty"`
	Proxy  ProxySettings `yaml:"proxy,omitempty" json:"proxy,omitempty"`
	// TTL is how long a sandbox may live. Default 4h. A question to open a
	// pull request (merge policy ask) closes no later than 30 minutes
	// before the sandbox that holds the change expires; without an answer
	// the change becomes a draft.
	TTL Duration `yaml:"ttl,omitempty" json:"ttl,omitempty"`
	// Image is the sandbox image of kits that name none. Default: the
	// kojo-toolchain image of this release.
	Image string `yaml:"image,omitempty" json:"image,omitempty"`
	// MaxResources is the most CPU, memory and disk any kit gets, in
	// Kubernetes quantity syntax ({cpu: "2", memory: 4Gi, disk: 20Gi}). A
	// kit that asks for more gets this much instead, and the driver logs
	// it; a kit that asks for less, or names no quantity, is unchanged.
	// It fits kits to smaller machines: the built-in kits ask for up to 8
	// CPUs and 16Gi. Empty: no cap. The docker driver also lowers a request
	// to what the Docker daemon has; the e2b driver sends no kit resources.
	MaxResources sandbox.Resources `yaml:"max_resources,omitempty" json:"max_resources,omitempty"`
}

Sandbox selects and wires the sandbox driver.

type Schedule

type Schedule struct {
	Name string `json:"name" yaml:"name"`
	// Cron is a five-field cron expression, or @daily, @hourly, @weekly.
	Cron string `json:"cron" yaml:"cron"`
	// Timezone is an IANA zone. Default UTC, whatever zone the server runs in.
	Timezone string `json:"timezone,omitempty" yaml:"timezone,omitempty"`
	// Skill is the skill to run.
	Skill string `json:"skill" yaml:"skill"`
	// Prompt is extra instruction for the run.
	Prompt string `json:"prompt,omitempty" yaml:"prompt,omitempty"`
	// Repos are the repositories an org-level schedule runs on. Empty means
	// every enabled repository. Ignored in a repository's own schedules.
	Repos []string `json:"repos,omitempty" yaml:"repos,omitempty"`
	// Notify is the chat channel that gets the result: a channel ID, or
	// surface:channel (mattermost:town-square) when several chat surfaces
	// are configured.
	Notify  string `json:"notify,omitempty" yaml:"notify,omitempty"`
	Enabled *bool  `json:"enabled,omitempty" yaml:"enabled,omitempty"`
}

Schedule is one recurring job.

func (Schedule) IsEnabled

func (s Schedule) IsEnabled() bool

IsEnabled reports whether the schedule runs. Unset means enabled.

type Schedules

type Schedules struct {
	Schedules []Schedule `json:"schedules" yaml:"schedules"`
}

Schedules is a list of recurring jobs.

func (Schedules) Validate

func (s Schedules) Validate() error

Validate checks names, cron expressions and time zones.

type ScopedSchedule

type ScopedSchedule struct {
	Scope string `json:"scope"`
	Schedule
}

ScopedSchedule is a schedule with the scope that defines it.

func (ScopedSchedule) Key

func (s ScopedSchedule) Key() string

Key identifies the schedule's run state.

type ScopedSkill

type ScopedSkill struct {
	Scope    string
	Name     string
	Revision string
	Files    map[string]string
	Deleted  bool
}

ScopedSkill is a dashboard-managed skill of one scope.

type Seed

type Seed struct {
	SkillsSource SkillsSource `yaml:"skills_source,omitempty" json:"skills_source,omitempty"`
	Activation   Activation   `yaml:"activation,omitempty" json:"activation,omitempty"`
}

Seed is the initial runtime config.

type Server

type Server struct {
	// PublicURL is how forges, Slack and browsers reach kōjō.
	PublicURL string `yaml:"public_url" json:"public_url"`
	// Listen is the address to bind. Default ":8080".
	Listen string `yaml:"listen,omitempty" json:"listen,omitempty"`
	// MetricsListen is the address /metrics is served on, apart from the
	// dashboard, the API and the webhooks, so that putting Listen on a
	// public network does not publish the metrics. "off" serves none.
	// Default "127.0.0.1:9090"; the Helm chart sets ":9090".
	MetricsListen string `yaml:"metrics_listen,omitempty" json:"metrics_listen,omitempty"`
	Auth          Auth   `yaml:"auth,omitempty" json:"auth,omitempty"`
	// Workers is how many sessions this replica runs at once. Default 4.
	Workers int `yaml:"workers,omitempty" json:"workers,omitempty"`
}

Server is the HTTP server: dashboard, API, webhooks and MCP.

type SkillFiles

type SkillFiles struct {
	// Files are the skill's files by name: SKILL.md, goals.yaml, kit.yaml.
	Files map[string]string `json:"files" yaml:"files"`
	// Deleted marks a skill removed from this scope: resolution falls
	// through to the next layer.
	Deleted bool `json:"deleted,omitempty" yaml:"deleted,omitempty"`
}

SkillFiles is the content of a skill/<name> object.

type SkillsSource

type SkillsSource struct {
	// Org is dashboard (default) or git.
	Org string `yaml:"org,omitempty" json:"org,omitempty"`
	// Repo is git (default) or dashboard.
	Repo string `yaml:"repo,omitempty" json:"repo,omitempty"`
}

SkillsSource says where each scope's skills are edited.

type SkillsSourceSetting

type SkillsSourceSetting struct {
	Org  string `json:"org" yaml:"org"`
	Repo string `json:"repo" yaml:"repo"`
	// SkillsRepo is the shared repository of org-level skills when Org is
	// git: forge/owner/name.
	SkillsRepo string `json:"skills_repo,omitempty" yaml:"skills_repo,omitempty"`
}

SkillsSourceSetting says where each scope's skills are edited: dashboard (Postgres is the source of truth) or git (the repository is).

type Slack

type Slack struct {
	// Mode is socket (no public ingress needed) or http. Default socket.
	Mode     string `yaml:"mode,omitempty" json:"mode,omitempty"`
	BotToken string `yaml:"bot_token" json:"bot_token"`
	// AppToken is the app-level token (xapp-...) Socket Mode needs.
	AppToken string `yaml:"app_token,omitempty" json:"app_token,omitempty"`
	// SigningSecret verifies requests in http mode.
	SigningSecret string `yaml:"signing_secret,omitempty" json:"signing_secret,omitempty"`
	// APIURL overrides https://slack.com/api/ (the Slack mock in dev stacks).
	APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
}

Slack is the Slack app.

type Snapshot

type Snapshot struct {
	Repo         string              `json:"repo,omitempty"`
	Models       ModelSettings       `json:"models"`
	MergePolicy  MergePolicy         `json:"merge_policy"`
	Egress       EgressLimits        `json:"egress"`
	Activation   ActivationPolicy    `json:"activation"`
	SkillsSource SkillsSourceSetting `json:"skills_source"`
	Repos        Repos               `json:"repos"`
	RBAC         RBAC                `json:"rbac"`
	Memory       MemorySettings      `json:"memory"`
	// Revisions are the revision IDs the snapshot was built from, by
	// "scope/object".
	Revisions map[string]string `json:"revisions"`
}

Snapshot is the config one session runs with.

func (*Snapshot) RepoEnabled

func (s *Snapshot) RepoEnabled(repo string) bool

RepoEnabled reports whether the factory works on repo.

func (*Snapshot) SkillAllowed

func (s *Snapshot) SkillAllowed(repo, skill string) bool

SkillAllowed reports whether a repository may use a skill.

type Team

type Team struct {
	Members []string `json:"members" yaml:"members"`
	Roles   []string `json:"roles" yaml:"roles"`
}

Team is a named group of users sharing roles.

type Teams

type Teams struct {
	// AppID is the bot's Microsoft App ID (the application's client ID).
	AppID string `yaml:"app_id" json:"app_id"`
	// AppPassword is the application's client secret.
	AppPassword string `yaml:"app_password" json:"app_password"`
	// TenantID is the Microsoft Entra tenant of a single-tenant bot
	// registration (its App Tenant ID): the bot gets its token from this
	// tenant and serves only this tenant's users. Empty means a
	// multi-tenant registration, which needs allowed_tenants.
	TenantID string `yaml:"tenant_id,omitempty" json:"tenant_id,omitempty"`
	// AllowedTenants are further tenants whose users may talk to the bot.
	// A multi-tenant registration has no tenant_id and must list its
	// tenants here: anyone can install a multi-tenant bot, and kōjō trusts
	// the email a tenant reports for a user.
	AllowedTenants []string `yaml:"allowed_tenants,omitempty" json:"allowed_tenants,omitempty"`
	// TextFormat is how messages are sent: extendedmarkdown (default;
	// headings, lists, code blocks and tables) or markdown, Teams' older
	// format, in which kōjō sends tables as code blocks.
	TextFormat string `yaml:"text_format,omitempty" json:"text_format,omitempty"`
	// ServiceURL is the Bot Connector endpoint for messages that answer
	// no incoming one, such as a schedule's notify. Default
	// https://smba.trafficmanager.net/teams/ (the public cloud). kōjō
	// sends the bot's token only to the Teams endpoints it knows and to
	// this host.
	ServiceURL string `yaml:"service_url,omitempty" json:"service_url,omitempty"`
	// LoginURL overrides https://login.microsoftonline.com, where the bot
	// gets its access token (sovereign clouds, a mock in tests).
	LoginURL string `yaml:"login_url,omitempty" json:"login_url,omitempty"`
	// TokenScope overrides https://api.botframework.com/.default.
	TokenScope string `yaml:"token_scope,omitempty" json:"token_scope,omitempty"`
	// OpenIDMetadataURL overrides
	// https://login.botframework.com/v1/.well-known/openidconfiguration,
	// the document that names the keys incoming requests are signed with.
	OpenIDMetadataURL string `yaml:"openid_metadata_url,omitempty" json:"openid_metadata_url,omitempty"`
}

Teams is the Microsoft Teams bot: an Azure Bot registration whose messaging endpoint is <public_url>/teams/messages.

type Telemetry

type Telemetry struct {
	// OTLPEndpoint is the OTLP/HTTP endpoint traces are exported to: a base
	// URL (http://collector:4318, which gets /v1/traces) or a full URL. The
	// standard OTEL_EXPORTER_OTLP_ENDPOINT variable works too.
	OTLPEndpoint string `yaml:"otlp_endpoint,omitempty" json:"otlp_endpoint,omitempty"`
	// ServiceName defaults to kojo.
	ServiceName string `yaml:"service_name,omitempty" json:"service_name,omitempty"`
}

Telemetry configures traces and metrics.

type Tier

type Tier struct {
	Provider string `yaml:"provider" json:"provider"`
	Model    string `yaml:"model" json:"model"`
	// Fallbacks are tried in order when the tier's model fails.
	Fallbacks []ModelRef `yaml:"fallbacks,omitempty" json:"fallbacks,omitempty"`
	// Price is what the model costs, in USD per million tokens. kōjō ships
	// no price table: without a price a tier's calls cost 0 and the USD
	// budgets cannot bound them (kojo doctor warns). The tier's fallbacks
	// are priced the same.
	Price *Price `yaml:"price,omitempty" json:"price,omitempty"`
	// RequestsPerMinute rate-limits the tier, per kōjō replica. Zero means
	// no limit.
	RequestsPerMinute int `yaml:"requests_per_minute,omitempty" json:"requests_per_minute,omitempty"`
}

Tier is one model tier.

Jump to

Keyboard shortcuts

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