config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 21 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 (
	AlertSentry  = "sentry"
	AlertDatadog = "datadog"
)

Alert source names.

View Source
const (
	// AlertModeFix runs a session that may change code: the result is a
	// draft pull request.
	AlertModeFix = "fix"
	// AlertModeReport runs a read-only session: the result is a report.
	AlertModeReport = "report"
)

Modes of a repository's alert source.

View Source
const (
	DefaultAlertsPerDay = 10
	MaxAlertsPerDay     = 100
)

Bounds of an alert source's sessions a day.

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 (
	// ReportsOff makes no report for any session.
	ReportsOff = "off"
	// ReportsPublicRepos makes reports only for sessions on a repository
	// that was public when the session ran.
	ReportsPublicRepos = "public_repos"
	// ReportsAll makes reports for sessions on any repository, private
	// ones included: such a report is as private as its link.
	ReportsAll = "all"
)

Report modes.

View Source
const (
	DefaultReportTTL = 30 * 24 * time.Hour
	MinReportTTL     = time.Hour
	MaxReportTTL     = 365 * 24 * time.Hour
)

Bounds of a report link's lifetime.

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"
	// ObjPlan is PlanSettings: when a session writes a plan and waits for a
	// person's go-ahead before it changes code. A repository's object
	// replaces the org's.
	ObjPlan = "settings/plan"
	// 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 (
	// PlanOff: only a request that asks for a plan (the request's plan
	// flag, or the label on its issue or pull request) gets one.
	PlanOff = "off"
	// PlanSkills: also every session about to run one of the listed
	// skills.
	PlanSkills = "skills"
	// PlanAlways: also every session about to run a skill that changes
	// code.
	PlanAlways = "always"
)

Plan modes.

View Source
const (
	DefaultPlanLabel        = "kojo:plan"
	DefaultPlanMaxRevisions = 3
	// MaxPlanRevisions bounds max_revisions.
	MaxPlanRevisions = 10
)

Defaults of PlanSettings.

View Source
const (
	TrackerLinear = "linear"
	TrackerJira   = "jira"
	TrackerAsana  = "asana"
)

Tracker names.

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 DefaultDatadogSite = "datadoghq.com"

DefaultDatadogSite is the site when site is not set.

View Source
const DefaultSentryURL = "https://sentry.io"

DefaultSentryURL is where Sentry is when base_url is not set.

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 MaxRunningLimit = 10000

MaxRunningLimit bounds max_running: more than this many sessions at once is no limit at all.

View Source
const MinApprovalTimeout = time.Minute

MinApprovalTimeout is the shortest approval_timeout a policy may set.

View Source
const MinWebhookSecret = 32

MinWebhookSecret is the shortest Datadog webhook_secret kōjō takes, in bytes.

View Source
const ObjLimits = "settings/limits"

ObjLimits is Limits: spend limits and caps on running sessions per team, per repository and per trigger. It is read from the org's scope only, and only an admin changes it.

View Source
const ObjReports = "settings/reports"

ObjReports is ReportSettings: which sessions may have a shareable report. A repository's object overrides the org's, key by key.

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", "vertexai", "azure", "bedrock", "openrouter", "ollama", "mock"}

ModelProviders lists the model providers the embedded gateway can call.

ReportModes are the values of ReportSettings.Mode.

Roles lists every role, weakest first.

TriggerKinds are the triggers a limit can name: the kinds of request.

Functions

func DatadogSites added in v0.4.0

func DatadogSites() []string

DatadogSites lists Datadog's sites, sorted.

func DatadogTag added in v0.4.0

func DatadogTag(s string) bool

DatadogTag reports whether s has the shape kōjō takes for a Datadog service or environment, a tag's value: a letter, then letters, digits and _ - : . /, at most 200 characters. It has no space, control or format character.

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, an egress entry with or without a port, matches one of the patterns: the same port, or neither has one, and the same host or one under a "*.domain" pattern.

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 ProviderURL added in v0.2.0

func ProviderURL(raw string) error

ProviderURL checks a model provider's endpoint: an absolute URL with no query or fragment. Requests to it carry a credential, so https is required except on a loopback host (a local proxy or a test server). The model gateway applies it to an endpoint that comes from the environment.

func RevisionKey added in v0.4.0

func RevisionKey(scope, object string) string

RevisionKey is the key under which a snapshot's Revisions, and a session's, name the revision of one object in one scope.

func RoleAtLeast

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

RoleAtLeast reports whether any of roles grants at least min.

func SplitHostPattern added in v0.4.0

func SplitHostPattern(entry string) (host, port string, hasPort bool)

SplitHostPattern splits an egress entry into its host pattern and its port. hasPort is true when the entry has a ":", even with nothing after it, which ValidHostPattern refuses.

func ValidHostPattern

func ValidHostPattern(h string) error

ValidHostPattern accepts a hostname or "*.domain", with an optional ":port" (1 to 65535). Without a port an entry allows ports 443 and 80; any other port has to be named. 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 anyone who wrote the
	// draft: its author or anyone who edited it.
	RequireSecondReviewer bool `json:"require_second_reviewer" yaml:"require_second_reviewer"`
}

ActivationPolicy gates a skill draft going live.

type AlertSource added in v0.4.0

type AlertSource struct {
	// Source is sentry or datadog.
	Source string `json:"source" yaml:"source"`
	// Project is the project's slug on Sentry, or the service's name on
	// Datadog.
	Project string `json:"project" yaml:"project"`
	// Environment narrows the source to the alerts of one environment
	// (production). Empty takes every environment.
	Environment string `json:"environment,omitempty" yaml:"environment,omitempty"`
	// Skill is the skill each session runs. Empty lets the orchestrator
	// choose, which usually reproduces the error, then fixes it.
	Skill string `json:"skill,omitempty" yaml:"skill,omitempty"`
	// Mode is fix (the default: the session may change code, and its pull
	// request is always a draft) or report (a read-only session that
	// reports what it found).
	Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
	// Notify is the chat channel that gets each session's outcome: a
	// channel ID, or surface:channel. Empty leaves the outcome in the
	// dashboard.
	Notify string `json:"notify,omitempty" yaml:"notify,omitempty"`
	// MaxPerDay bounds the sessions this source starts in 24 hours: 1 to
	// 100, or 0 for the default of 10.
	MaxPerDay int `json:"max_per_day,omitempty" yaml:"max_per_day,omitempty"`
}

AlertSource names the alerts that are work on a repository: those of one project of a source, optionally of one environment.

func (AlertSource) MaxPerDayOrDefault added in v0.4.0

func (a AlertSource) MaxPerDayOrDefault() int

MaxPerDayOrDefault is the source's daily bound, 10 when unset.

func (AlertSource) ModeOrDefault added in v0.4.0

func (a AlertSource) ModeOrDefault() string

ModeOrDefault is the source's mode, fix when unset.

type Alerts added in v0.4.0

type Alerts struct {
	Sentry  *Sentry  `yaml:"sentry,omitempty" json:"sentry,omitempty"`
	Datadog *Datadog `yaml:"datadog,omitempty" json:"datadog,omitempty"`
}

Alerts are the sources of production alerts kōjō takes work from: an alert rule (a Sentry issue alert, a Datadog Error Tracking monitor) that fires for an error starts a session on the repository the repos object maps the error's project or service to (alerts), which reproduces the error and fixes it in a draft pull request.

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 Asana added in v0.3.0

type Asana struct {
	// Token is a personal access token of kōjō's Asana user, or a service
	// account's token.
	Token string `yaml:"token" json:"token"`
	// WebhookSecrets are the secrets of kōjō's webhooks, one per project
	// (Asana gives each webhook its own, once, when it is created; kojo
	// setup asana writes them to a file). A delivery signed with none of
	// them is refused.
	WebhookSecrets []string `yaml:"webhook_secrets,omitempty" json:"webhook_secrets,omitempty"`
	// Status moves a task to the section of that name in its project.
	Status TrackerStatus `yaml:"status,omitempty" json:"status,omitempty"`
	// Users maps an Asana user ID (gid) to the email of that person's entry
	// in the rbac object. Asana does not say whether the address it reports
	// was verified, so this is how a person gets a role; anyone else's
	// requests are read-only.
	Users map[string]string `yaml:"users,omitempty" json:"users,omitempty"`
	// APIURL overrides https://app.asana.com/api/1.0 (a mock in tests).
	APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
}

Asana is an Asana workspace, reached with the token of the Asana user or service account kōjō acts as. Webhooks come to <public_url>/webhooks/asana; kojo setup asana creates them.

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 Azure added in v0.2.0

type Azure struct {
	// Endpoint is the resource's endpoint, such as
	// https://acme.openai.azure.com (Azure OpenAI) or
	// https://acme.services.ai.azure.com (Microsoft Foundry). Default
	// AZURE_OPENAI_ENDPOINT.
	Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty"`
	// APIKey is a key of the resource. Default AZURE_OPENAI_API_KEY.
	// Without one, kōjō uses Entra ID.
	APIKey string `yaml:"api_key,omitempty" json:"api_key,omitempty"`
}

Azure is Azure OpenAI or Microsoft Foundry, through their OpenAI-compatible v1 API (<endpoint>/openai/v1/). With an API key kōjō sends it in the api-key header; without one it signs in with Microsoft Entra ID (DefaultAzureCredential: a service principal in the environment, AKS workload identity, a managed identity, or an Azure CLI login). A tier's model is the name of a deployment. The provider is loaded when an endpoint resolves.

type Bedrock added in v0.2.0

type Bedrock struct {
	// Region is the AWS region, such as us-east-1. Default AWS_REGION, then
	// AWS_DEFAULT_REGION.
	Region string `yaml:"region,omitempty" json:"region,omitempty"`
	// Profile names a profile of the shared AWS config files. Default
	// AWS_PROFILE, then the default profile.
	Profile string `yaml:"profile,omitempty" json:"profile,omitempty"`
	// Endpoint replaces the region's Bedrock Runtime endpoint, such as a VPC
	// interface endpoint.
	Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty"`
}

Bedrock is Amazon Bedrock, through its Converse API. Credentials come from the AWS SDK's default chain: environment variables, the shared config and credentials files, web identity (EKS IRSA), EKS Pod Identity and ECS task roles, and the EC2 instance role. There is no key in this file. The provider is loaded when a region resolves.

type Bitbucket added in v0.3.0

type Bitbucket struct {
	// Workspace is the workspace ID (slug) whose repositories kōjō lists.
	Workspace string `yaml:"workspace" json:"workspace"`
	// Token is an API token with scopes of the bot's Atlassian account.
	Token string `yaml:"token" json:"token"`
	// WebhookSecret is the secret of the repositories' webhooks
	// (X-Hub-Signature).
	WebhookSecret string `yaml:"webhook_secret" json:"webhook_secret"`
}

Bitbucket is Bitbucket Cloud reached with an API token of the account kōjō acts as.

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"`
	// Trackers are the issue trackers kōjō takes work from: Linear, Jira
	// Cloud and Asana.
	Trackers Trackers `yaml:"trackers,omitempty" json:"trackers,omitempty"`
	// Alerts are the sources of production alerts kōjō takes work from:
	// Sentry and Datadog Error Tracking.
	Alerts  Alerts  `yaml:"alerts,omitempty" json:"alerts,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 LoadProxy added in v0.4.0

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

LoadProxy reads the kojo.yaml of a standalone kojo-proxy (`kojo proxy`). The proxy reads sandbox.proxy and nothing else, so that is all the file needs and all that is checked: the Helm chart gives the proxy pods a file of their own, and with it none of kōjō's credentials (the database URL, the session secret, forge and model keys). A whole kojo.yaml is read as well. As with Load, unknown keys are errors and every ${VAR} the file names must be set.

func Parse

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

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

func ParseProxy added in v0.4.0

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

ParseProxy is LoadProxy on bytes, with the environment passed in.

func (*Boot) AlertSourceNames added in v0.4.0

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

AlertSourceNames lists the configured alert sources.

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) TrackerNames added in v0.3.0

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

TrackerNames lists the configured trackers.

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 is the size of the connection pool: 0 for pgx's default
	// (the larger of 4 and the number of CPUs), otherwise at least 2,
	// because a campaign update holds one connection while it uses another.
	MaxConns int `yaml:"max_conns,omitempty" json:"max_conns,omitempty"`
}

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

type Datadog added in v0.4.0

type Datadog struct {
	// Site is the organization's Datadog site: datadoghq.com (the
	// default), us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu,
	// ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com,
	// ddog-gov.com or us2.ddog-gov.com. The API is at api.<site>.
	Site string `yaml:"site,omitempty" json:"site,omitempty"`
	// APIKey is an API key of the organization, sent as DD-API-KEY.
	APIKey string `yaml:"api_key" json:"api_key"`
	// AppKey is an application key with the error_tracking_read
	// permission, sent as DD-APPLICATION-KEY. kōjō reads issues with it
	// and writes nothing.
	AppKey string `yaml:"app_key" json:"app_key"`
	// WebhookSecret is what the webhook sends in its
	// X-Kojo-Webhook-Secret header, at least 32 bytes. Datadog does not
	// sign webhooks: a delivery without this value is refused.
	WebhookSecret string `yaml:"webhook_secret" json:"webhook_secret"`
	// BaseURL replaces https://api.<site>, for a proxy or a test.
	BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
}

Datadog is a Datadog organization's Error Tracking, on one of Datadog's sites. An Error Tracking monitor notifies a webhook of Datadog's Webhooks integration, which sends <public_url>/webhooks/datadog the monitor's IDs and scope; kōjō reads the issue and its stack trace with the keys.

func (Datadog) APIURL added in v0.4.0

func (d Datadog) APIURL() string

APIURL is where kōjō calls Datadog's API: base_url, or https://api.<site>.

func (Datadog) AppURL added in v0.4.0

func (d Datadog) AppURL() string

AppURL is the address of the site's web app, where monitors are.

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). An
	// entry without a port allows 443 and 80; "host:8443" allows that port
	// only, and a kit has to name the same port to be inside it.
	AllowedHosts []string `json:"allowed_hosts" yaml:"allowed_hosts"`
	// AllowedCredentials are credential names: github, gitlab, forgejo,
	// bitbucket.
	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"`
	Bitbucket *Bitbucket `yaml:"bitbucket,omitempty" json:"bitbucket,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, bitbucket:<Atlassian account ID>, 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 Jira added in v0.3.0

type Jira struct {
	// BaseURL is the site's address, such as https://acme.atlassian.net.
	BaseURL string `yaml:"base_url" json:"base_url"`
	// Email is the address of kōjō's Atlassian account, which signs in
	// with APIToken.
	Email string `yaml:"email" json:"email"`
	// APIToken is an API token of that account (without scopes: a scoped
	// token only works through api.atlassian.com).
	APIToken string `yaml:"api_token" json:"api_token"`
	// WebhookSecret is the secret of the webhook (Jira settings, System,
	// WebHooks). Jira signs each delivery with it (X-Hub-Signature);
	// deliveries that are not signed with it are refused.
	WebhookSecret string `yaml:"webhook_secret" json:"webhook_secret"`
	// Labels start work when added to an issue, or when an issue is
	// created with one.
	Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
	// Status moves an issue through its workflow: the transition to the
	// status of that name is made.
	Status TrackerStatus `yaml:"status,omitempty" json:"status,omitempty"`
	// Users maps an Atlassian account ID to the email of that person's
	// entry in the rbac object. Jira gives a bot no email it can rely on,
	// so this is how a person gets a role; anyone else's requests are
	// read-only.
	Users map[string]string `yaml:"users,omitempty" json:"users,omitempty"`
}

Jira is a Jira Cloud site, reached with the API token of the Atlassian account kōjō acts as. Webhooks come to <public_url>/webhooks/jira.

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 Limit added in v0.3.0

type Limit struct {
	// PerDayUSD caps the cost of the model calls started in the last 24
	// hours, a rolling window like the install's per_day_usd.
	PerDayUSD float64 `json:"per_day_usd,omitempty" yaml:"per_day_usd,omitempty"`
	// PerMonthUSD caps the cost of the model calls started since the first
	// of the calendar month, 00:00 UTC.
	PerMonthUSD float64 `json:"per_month_usd,omitempty" yaml:"per_month_usd,omitempty"`
	// MaxRunning caps the sessions running at once. A queued session over
	// the cap stays queued, in its place, until one of them ends or waits.
	MaxRunning int `json:"max_running,omitempty" yaml:"max_running,omitempty"`
}

Limit is the limits of one team or one repository. Zero means no limit.

func (Limit) Empty added in v0.3.0

func (l Limit) Empty() bool

Empty reports whether the limit limits nothing.

func (Limit) Spends added in v0.3.0

func (l Limit) Spends() bool

Spends reports whether the limit has a spend limit.

type Limits added in v0.3.0

type Limits struct {
	// Teams are limits per team, by the team's name in rbac.
	Teams map[string]Limit `json:"teams,omitempty" yaml:"teams,omitempty"`
	// Repos are limits per repository, by forge/owner/name.
	Repos map[string]Limit `json:"repos,omitempty" yaml:"repos,omitempty"`
	// Triggers cap the running sessions of one trigger (the kind of request
	// that started them: eval, schedule, mention, ...), so that, for
	// example, an eval run cannot take every worker.
	Triggers map[string]TriggerLimit `json:"triggers,omitempty" yaml:"triggers,omitempty"`
}

Limits bound what each team and each repository may spend and how many of their sessions run at once, next to the install-wide budgets of settings/models. A repository belongs to the team whose rbac entry lists it (RBAC.TeamOf); a session counts against its repository, that repository's team, and the install. A session with no repository counts against the install only.

Limits are read when they are checked, not pinned to a session: a lower limit stops a running session at its next model call.

func (Limits) Caps added in v0.3.0

func (l Limits) Caps(r RBAC) store.Caps

Caps are the caps on running sessions, in the form the store's claim applies them: each repository's team comes from rbac.

func (Limits) Spends added in v0.3.0

func (l Limits) Spends() bool

Spends reports whether any team or repository has a spend limit.

func (Limits) Validate added in v0.3.0

func (l Limits) Validate() error

Validate checks the names and the numbers.

type Linear added in v0.3.0

type Linear struct {
	// APIKey is a personal API key of kōjō's Linear user (Settings,
	// Security & access). Tickets are assigned to and mentions name that
	// user.
	APIKey string `yaml:"api_key" json:"api_key"`
	// WebhookSecret is the signing secret Linear shows on the webhook's
	// page. Deliveries whose Linear-Signature does not verify are refused.
	WebhookSecret string `yaml:"webhook_secret" json:"webhook_secret"`
	// Labels start work when added to an issue, or when an issue is
	// created with one.
	Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
	// Status moves an issue through its team's workflow states, by name.
	Status TrackerStatus `yaml:"status,omitempty" json:"status,omitempty"`
	// Users maps a Linear user ID to the email of that person's entry in
	// the rbac object, for a person whose Linear address is not that one.
	// Everyone else is known by the email Linear reports.
	Users map[string]string `yaml:"users,omitempty" json:"users,omitempty"`
	// APIURL overrides https://api.linear.app/graphql (a mock in tests).
	APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
}

Linear is a Linear workspace, reached with the API key of the Linear user kōjō acts as. Webhooks come to <public_url>/webhooks/linear.

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) Limits added in v0.3.0

func (m *Manager) Limits() Limits

Limits returns the org's settings/limits: the limits in force now.

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) RBAC added in v0.3.0

func (m *Manager) RBAC() RBAC

RBAC returns the org's rbac object as it is now.

func (*Manager) Reports added in v0.3.0

func (m *Manager) Reports(repo string) ReportSettings

Reports returns the report settings of a repository: the org's object, with the repository's own keys over it. They are read live, not pinned to a session's revisions, so turning reports off applies to every link at once.

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, vertexai, azure, bedrock,
	// openrouter, ollama or mock. Anything else (vLLM, LiteLLM) is reached
	// through the openai provider's base_url or an external gateway.
	Provider string `yaml:"provider" json:"provider"`
	// Model is the provider's model ID. With azure it is the name of a
	// deployment, not of a model.
	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) BoundProblem added in v0.4.0

func (m ModelSettings) BoundProblem(tiers ...string) string

BoundProblem says why the per-session budget does not bound what a session costs when its model calls use the named tiers, or "" when it does. With no tier named, every tier settings/models defines is checked: a session the orchestrator runs may use any of them. A tier without a price costs 0, so no budget stops its calls.

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"`
	// TrustUnverifiedEmail accepts an ID token that has no email_verified
	// claim, for identity providers that never send it (Microsoft Entra ID
	// and AD FS among them). Without it, such a token is refused: a
	// provider that does not vouch for an address may let a person pick
	// anyone's, an admin's included. Turn it on only for a provider whose
	// addresses your organization assigns. A token whose email_verified is
	// false is refused either way.
	TrustUnverifiedEmail bool `yaml:"trust_unverified_email,omitempty" json:"trust_unverified_email,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, 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 PlanSettings added in v0.3.0

type PlanSettings struct {
	// Mode is off (default), skills or always.
	Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
	// Skills are the skills that need a plan in mode skills.
	Skills []string `json:"skills,omitempty" yaml:"skills,omitempty"`
	// Label on an issue or pull request asks for a plan whatever the mode.
	// Default kojo:plan.
	Label string `json:"label,omitempty" yaml:"label,omitempty"`
	// MaxRevisions bounds the revised plans one session writes on request.
	// Default 3; 0 means the default, and at most 10.
	MaxRevisions int `json:"max_revisions,omitempty" yaml:"max_revisions,omitempty"`
}

PlanSettings decides when a session writes a plan before it changes code and waits for a person's go-ahead. Whatever the mode, a request that asks for a plan gets one. Only a skill that can change the workspace is ever held back: a read-only session never waits.

func (PlanSettings) Covers added in v0.3.0

func (p PlanSettings) Covers(skill string) bool

Covers reports whether the mode asks for a plan before a skill that changes code.

func (PlanSettings) LabelName added in v0.3.0

func (p PlanSettings) LabelName() string

LabelName is the label that asks for a plan.

func (PlanSettings) Revisions added in v0.3.0

func (p PlanSettings) Revisions() int

Revisions is how many revised plans a session may write.

func (PlanSettings) Validate added in v0.3.0

func (p PlanSettings) Validate() error

Validate checks the mode, the skill names, the label and the bound.

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 is Gemini through the Gemini API, with an API key.
	GoogleAI ProviderKey `yaml:"googleai,omitempty" json:"googleai,omitempty"`
	// VertexAI is Gemini through Google Cloud's Vertex AI, with Google
	// Cloud credentials.
	VertexAI VertexAI `yaml:"vertexai,omitempty" json:"vertexai,omitempty"`
	// Azure is Azure OpenAI or Microsoft Foundry.
	Azure Azure `yaml:"azure,omitempty" json:"azure,omitempty"`
	// Bedrock is Amazon Bedrock.
	Bedrock    Bedrock     `yaml:"bedrock,omitempty" json:"bedrock,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 every allowlisted host 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. For a forge on a private network, name it in
	// PrivateHosts instead.
	AllowPrivate bool `yaml:"allow_private,omitempty" json:"allow_private,omitempty"`
	// PrivateHosts are the hostnames, or "*.domain" patterns, that may
	// resolve to loopback, link-local and private addresses: a forge or a
	// registry on a private network. Every other allowlisted host must still
	// resolve to public addresses only. A host here is reachable only when a
	// sandbox's allowlist names it too.
	PrivateHosts []string `yaml:"private_hosts,omitempty" json:"private_hosts,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"`
	// MaxConnsPerSandbox bounds what one sandbox has open through the proxy
	// at once: tunnels, intercepted connections and plain HTTP requests in
	// flight. One more gets HTTP 429, so one sandbox cannot take the
	// connections of the process the proxy runs in from the others.
	// Default 64.
	MaxConnsPerSandbox int `yaml:"max_conns_per_sandbox,omitempty" json:"max_conns_per_sandbox,omitempty"`
	// IdleTimeout closes a tunnel through which nothing has gone either way
	// for that long, and a sandbox's keep-alive connection to the proxy
	// that sends no request for that long. Default 5m.
	IdleTimeout Duration `yaml:"idle_timeout,omitempty" json:"idle_timeout,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) TeamOf added in v0.3.0

func (r RBAC) TeamOf(repo string) string

TeamOf returns the team that owns a repository, or "" when none does.

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"`
	// Tickets are the issue trackers' teams and projects whose tickets are
	// work on this repository (trackers.go). A ticket that matches the
	// sources of no repository, or of several, starts nothing: kōjō says
	// so on the ticket.
	Tickets []TicketSource `json:"tickets,omitempty" yaml:"tickets,omitempty"`
	// Alerts are the projects of production alert sources (Sentry projects,
	// Datadog services) whose errors are work on this repository
	// (alerts.go). An alert that matches
	// the sources of no repository, or of several, starts nothing.
	Alerts []AlertSource `json:"alerts,omitempty" yaml:"alerts,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 ReportSettings added in v0.3.0

type ReportSettings struct {
	// Mode is off, public_repos (the default: sessions on a public
	// repository only) or all (private repositories too).
	Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
	// TTL is how long a new link works: default 720h (30 days), at least
	// 1h, at most 8760h (a year). A link keeps the expiry it was made with.
	TTL Duration `json:"ttl,omitempty" yaml:"ttl,omitempty"`
}

ReportSettings decides which sessions may have a shareable report: a read-only, redacted page of the session that anyone with its link can open, without signing in. Pull request descriptions link it, and operators share it from the dashboard. Only an admin edits it.

func (ReportSettings) Lifetime added in v0.3.0

func (r ReportSettings) Lifetime() time.Duration

Lifetime is the TTL, the default when unset.

func (ReportSettings) ModeOrDefault added in v0.3.0

func (r ReportSettings) ModeOrDefault() string

ModeOrDefault is the mode, public_repos when unset.

func (ReportSettings) Validate added in v0.3.0

func (r ReportSettings) Validate() error

Validate checks the mode and the TTL.

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 Sentry added in v0.4.0

type Sentry struct {
	// BaseURL is Sentry's address: https://sentry.io (the default), a
	// region's (https://de.sentry.io), or a self-hosted install's.
	BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
	// Org is the organization's slug, as in its URLs. Alerts of another
	// organization are ignored.
	Org string `yaml:"org" json:"org"`
	// ClientSecret is the internal integration's Client Secret: Sentry
	// signs every webhook with it. Deliveries whose Sentry-Hook-Signature
	// does not verify are refused.
	ClientSecret string `yaml:"client_secret" json:"client_secret"`
	// Token is a token of the internal integration, with Issue & Event:
	// Read. kōjō reads an alert's issue with it (its status and counts).
	Token string `yaml:"token" json:"token"`
}

Sentry is a Sentry organization (sentry.io or self-hosted), reached through an internal integration of its own. Alert rules send their webhooks to <public_url>/webhooks/sentry.

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"`
	// NetworkPolicy says whether NetworkPolicies limit who reaches Postgres,
	// kojo-proxy's admin port and the metrics port. The Helm chart sets it
	// from networkPolicy.enabled, and `kojo doctor` warns when it is false.
	// Unset, kōjō does not know and doctor does not check.
	NetworkPolicy *bool `yaml:"network_policy,omitempty" json:"network_policy,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 the dashboard copy removed from this scope: resolution
	// uses the scope's git-backed skill of that name, if any, and otherwise
	// 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"`
	Plan         PlanSettings        `json:"plan"`
	// 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"`
	// Repos are the repositories the team owns, as forge/owner/name: their
	// sessions count against the team's limits in settings/limits. They do
	// not narrow the team's roles, which hold everywhere. A repository
	// belongs to one team at most.
	Repos []string `json:"repos,omitempty" yaml:"repos,omitempty"`
}

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 TicketSource added in v0.3.0

type TicketSource struct {
	// Tracker is linear, jira or asana.
	Tracker string `json:"tracker" yaml:"tracker"`
	// Team is a Linear team's key (ENG). Linear only.
	Team string `json:"team,omitempty" yaml:"team,omitempty"`
	// Project is a Linear project's name or ID, a Jira project's key
	// (PAY), or an Asana project's ID (the number in its URL).
	Project string `json:"project,omitempty" yaml:"project,omitempty"`
	// Label narrows the source to the tickets that carry this label (on
	// Asana, this tag): how two repositories share one team or project.
	Label string `json:"label,omitempty" yaml:"label,omitempty"`
}

TicketSource names the tickets of an issue tracker that are work on a repository: a Linear team or project, a Jira project, an Asana project, optionally narrowed to the tickets with one label.

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.

type TrackerStatus added in v0.3.0

type TrackerStatus struct {
	// Started is the status a ticket moves to when a session that may
	// change code is queued for it ("In Progress").
	Started string `yaml:"started,omitempty" json:"started,omitempty"`
	// Review is the status a ticket moves to when its session opens a pull
	// request ("In Review").
	Review string `yaml:"review,omitempty" json:"review,omitempty"`
}

TrackerStatus names the statuses a ticket is moved to as its session goes on. Each is off when empty, which is the default.

type Trackers added in v0.3.0

type Trackers struct {
	Linear *Linear `yaml:"linear,omitempty" json:"linear,omitempty"`
	Jira   *Jira   `yaml:"jira,omitempty" json:"jira,omitempty"`
	Asana  *Asana  `yaml:"asana,omitempty" json:"asana,omitempty"`
}

Trackers are the issue trackers kōjō takes work from: a ticket assigned to kōjō's account, a comment that mentions it, or a label added to a ticket starts a session on the repository the ticket maps to (the repos object's tickets), and the result is posted on the ticket.

type TriggerLimit added in v0.3.0

type TriggerLimit struct {
	MaxRunning int `json:"max_running" yaml:"max_running"`
}

TriggerLimit caps the running sessions of one trigger.

type VertexAI added in v0.2.0

type VertexAI struct {
	// Project is the Google Cloud project ID. Default GOOGLE_CLOUD_PROJECT.
	Project string `yaml:"project,omitempty" json:"project,omitempty"`
	// Location is a region (us-central1), a multi-region (us, eu) or global.
	// Default GOOGLE_CLOUD_LOCATION, then GOOGLE_CLOUD_REGION.
	Location string `yaml:"location,omitempty" json:"location,omitempty"`
	// BaseURL replaces the endpoint derived from the location, such as a
	// Private Service Connect endpoint. Requests keep the project and
	// location in their path.
	BaseURL string `yaml:"base_url,omitempty" json:"base_url,omitempty"`
}

VertexAI is Gemini on Vertex AI. It authenticates with Google's Application Default Credentials: the key file GOOGLE_APPLICATION_CREDENTIALS names, the gcloud login, or the metadata server (GKE Workload Identity, a VM's service account). The provider is loaded when a project and a location resolve.

Jump to

Keyboard shortcuts

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