Documentation
¶
Index ¶
- type APIKey
- type APIKeyCreated
- type APIKeyID
- type APIKeySummary
- type Brain
- type ComposeBody
- type ComposeRequest
- type ComposeResponse
- type ComposeSource
- type ComposeSourceKind
- type ContentType
- type ContentVersion
- type CreateAPIKeyRequest
- type CreateWorkspaceRequest
- type EffectiveState
- type EntityID
- type LayerOverride
- type ListAPIKeys
- type ListBrains
- type ListPersonas
- type ListRules
- type ListSouls
- type ListVersions
- type ListWorkspaces
- type ModelPrefs
- type Persona
- type Procedure
- type RenameWorkspaceRequest
- type Rule
- type RuleEntry
- type ScopeType
- type SetStateRequest
- type Skill
- type SkillRef
- type SkillScope
- type Slug
- type Soul
- type StateResponse
- type StatusResponse
- type TokenEstimate
- type UpsertBrainRequest
- type UpsertPersonaRequest
- type UpsertProcedureRequest
- type UpsertRuleRequest
- type UpsertSkillRequest
- type UpsertSoulRequest
- type ValidationError
- type VersionSummary
- type Workspace
- type WorkspaceID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
ID APIKeyID `json:"id"`
WorkspaceID WorkspaceID `json:"workspace_id"`
Name string `json:"name"`
KeyPrefix string `json:"key_prefix"`
// KeyHash is the internal lookup value. It must never cross the
// wire — handlers marshal APIKey directly, so the json:"-" tag is
// the only guard. See apikey_test.go's golden test.
KeyHash string `json:"-"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type APIKeyCreated ¶
APIKeyCreated is the one-time response from creating an API key. Plaintext is the full token and is never returned again.
type APIKeySummary ¶
type APIKeySummary struct {
ID APIKeyID `json:"id"`
WorkspaceID WorkspaceID `json:"workspace_id"`
Name string `json:"name"`
KeyPrefix string `json:"key_prefix"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type Brain ¶
type Brain struct {
ID EntityID `json:"id"`
WorkspaceID WorkspaceID `json:"workspace_id"`
Slug Slug `json:"slug"`
SoulSlug Slug `json:"soul_slug"`
PersonaSlug Slug `json:"persona_slug"`
RuleSlugs []Slug `json:"rule_slugs"`
ProcedureSlug Slug `json:"procedure_slug,omitempty"`
SkillSlugs []Slug `json:"skill_slugs,omitempty"`
ModelPrefs *ModelPrefs `json:"model_prefs,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ComposeBody ¶
type ComposeBody struct {
Source ComposeSource `json:"source"`
ModelPrefs *ModelPrefs `json:"model_prefs,omitempty"`
ProjectSlug Slug `json:"project_slug,omitempty"`
Task string `json:"task,omitempty"`
}
ComposeBody is the body of POST /api/v1/compose. Mirrors ComposeRequest minus workspace_id — the workspace comes from auth, never from the body. Project in the body acts as a fallback when the corresponding header is absent.
type ComposeRequest ¶
type ComposeRequest struct {
WorkspaceID WorkspaceID `json:"workspace_id"`
Source ComposeSource `json:"source"`
ModelPrefs *ModelPrefs `json:"model_prefs,omitempty"`
ProjectSlug Slug `json:"project_slug,omitempty"`
Task string `json:"task,omitempty"`
}
type ComposeResponse ¶
type ComposeResponse struct {
Prompt string `json:"prompt"`
Soul Slug `json:"soul"`
Persona Slug `json:"persona"`
Brain Slug `json:"brain"`
Rules []Slug `json:"rules"`
Procedure Slug `json:"procedure,omitempty"`
Skills []SkillRef `json:"skills,omitempty"`
ModelPrefs *ModelPrefs `json:"model_prefs,omitempty"`
TokenEstimate TokenEstimate `json:"token_estimate"`
Warnings []string `json:"warnings"`
}
type ComposeSource ¶
type ComposeSource struct {
Kind ComposeSourceKind `json:"kind"`
BrainSlug Slug `json:"brain_slug,omitempty"`
PersonaSlug Slug `json:"persona_slug,omitempty"`
RuleSlugs []Slug `json:"rule_slugs,omitempty"`
}
ComposeSource is a discriminated union — brain, persona, and state resolution are mutually exclusive. The Kind field selects the variant.
RuleSlugs is meaningful only when Kind == ComposeFromPersona. When set, it overrides both the state-derived rule chain and the persona's BundledRules so an ad-hoc caller (today: `brainjar shell --persona X --rules a,b`) can pin an exact rule list without touching state.
type ComposeSourceKind ¶
type ComposeSourceKind string
const ( ComposeFromBrain ComposeSourceKind = "brain" ComposeFromPersona ComposeSourceKind = "persona" ComposeFromState ComposeSourceKind = "state" )
type ContentType ¶
type ContentType string
const ( ContentTypeSoul ContentType = "soul" ContentTypePersona ContentType = "persona" ContentTypeRule ContentType = "rule" ContentTypeProcedure ContentType = "procedure" ContentTypeSkill ContentType = "skill" )
type ContentVersion ¶
type ContentVersion struct {
ID EntityID `json:"id"`
ContentType ContentType `json:"content_type"`
WorkspaceID WorkspaceID `json:"workspace_id"`
Slug Slug `json:"slug"`
Version int `json:"version"`
Content string `json:"content,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ContentVersion is a historical snapshot of a content entity. Stores hold old versions only — the current version lives in the live entity table. For rules, Content is empty and Metadata holds the entries as JSON.
type CreateAPIKeyRequest ¶
type CreateAPIKeyRequest struct {
Name string `json:"name"`
}
CreateAPIKeyRequest is the body of POST /api/v1/api-keys.
type CreateWorkspaceRequest ¶
type CreateWorkspaceRequest struct {
Name string `json:"name"`
}
CreateWorkspaceRequest is the body of POST /api/v1/workspaces.
type EffectiveState ¶
type EffectiveState struct {
Soul string `json:"soul"`
Persona string `json:"persona"`
Procedure string `json:"procedure,omitempty"`
Rules []string `json:"rules"`
Skills []string `json:"skills"`
}
EffectiveState is the resolved state after merging all applicable layers.
type LayerOverride ¶
type LayerOverride struct {
WorkspaceID WorkspaceID `json:"workspace_id"`
ScopeType ScopeType `json:"scope_type"`
ReferenceID string `json:"reference_id"`
SoulSlug *string `json:"soul_slug,omitempty"`
PersonaSlug *string `json:"persona_slug,omitempty"`
ProcedureSlug *string `json:"procedure_slug,omitempty"`
RulesToAdd []string `json:"rules_to_add"`
RulesToRemove []string `json:"rules_to_remove"`
SkillSlugsToAdd []string `json:"skill_slugs_to_add"`
SkillSlugsToRemove []string `json:"skill_slugs_to_remove"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
LayerOverride is a single row in the precedence chain, keyed by (WorkspaceID, ScopeType, ReferenceID). Three-way semantics for single-valued fields via *string:
- nil = absent (no opinion, NULL in SQL)
- &"" = inherit (clear override, empty string in SQL)
- &"cto" = set (value in SQL)
type ListAPIKeys ¶
type ListAPIKeys struct {
APIKeys []APIKeySummary `json:"api_keys"`
}
type ListBrains ¶
type ListBrains struct {
Brains []Brain `json:"brains"`
}
type ListPersonas ¶
type ListPersonas struct {
Personas []Persona `json:"personas"`
}
type ListVersions ¶
type ListVersions struct {
Versions []VersionSummary `json:"versions"`
}
type ListWorkspaces ¶
type ListWorkspaces struct {
Workspaces []Workspace `json:"workspaces"`
}
type ModelPrefs ¶
type ModelPrefs struct {
Platform string `json:"platform,omitempty"`
Model string `json:"model,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
PlatformExtras map[string]any `json:"platform_extras,omitempty"`
}
ModelPrefs controls how a brain should be instantiated. All fields are optional — omitted fields inherit runtime defaults. Only platform-agnostic fields are first-class. Provider-specific params live in PlatformExtras.
Platform pins a brain to a specific adapter (claude/codex/cursor) so the brain composes against that platform's catalog regardless of the active context, and orchestrators know which runtime to spawn. Unset means the brain has no opinion and falls back to the caller's active context.
ModelPrefs is attached to Brain as the default, but ComposeRequest can supply a per-call override and ComposeResponse echoes the resolved value.
func (*ModelPrefs) IsZero ¶
func (m *ModelPrefs) IsZero() bool
IsZero returns true when no preferences are set.
type RenameWorkspaceRequest ¶
type RenameWorkspaceRequest struct {
Name string `json:"name"`
}
RenameWorkspaceRequest is the body of PATCH /api/v1/workspaces/{id}.
type SetStateRequest ¶
type SetStateRequest struct {
SoulSlug *string `json:"soul_slug,omitempty"`
PersonaSlug *string `json:"persona_slug,omitempty"`
ProcedureSlug *string `json:"procedure_slug,omitempty"`
RulesToAdd []string `json:"rules_to_add,omitempty"`
RulesToRemove []string `json:"rules_to_remove,omitempty"`
SkillSlugsToAdd []string `json:"skill_slugs_to_add,omitempty"`
SkillSlugsToRemove []string `json:"skill_slugs_to_remove,omitempty"`
}
SetStateRequest is the body of PUT /api/v1/state. The target scope is derived from tool args (project > workspace), not from the body. Server-owned fields (workspace_id, scope_type, reference_id, timestamps) never appear here. Slug pointer semantics match LayerOverride: nil = absent, &"" = clear, &"foo" = set.
type Skill ¶ added in v0.6.0
type Skill struct {
ID EntityID `json:"id"`
WorkspaceID WorkspaceID `json:"workspace_id"`
Slug Slug `json:"slug"`
Description string `json:"description"`
Body string `json:"body"`
Triggers []string `json:"triggers"`
Version int `json:"version"`
Scope SkillScope `json:"scope"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Skill is an emitted, executable artifact alongside soul/persona/rule/ procedure/brain. The body + frontmatter ship to the active platform's skills directory on `brainjar sync`; the agent runtime decides which skill to load on each turn via description match.
Triggers is an optional list of additional matching hints the runtime may use beyond Description. Version is author-asserted (not a row count); callers bump it to invalidate cached copies in the runtime.
type SkillRef ¶ added in v0.6.0
type SkillRef struct {
Slug Slug `json:"slug"`
Description string `json:"description"`
Version int `json:"version"`
Scope SkillScope `json:"scope"`
}
SkillRef is a thin reference returned by ComposeResponse.Skills — callers know which skills the brain expects to be loaded by the runtime without inlining bodies into the prompt.
type SkillScope ¶ added in v0.6.0
type SkillScope string
SkillScope selects where a skill's SKILL.md is emitted on `brainjar sync`. Mirrors the same project-vs-user split that brainjar's shipped guides use:
- SkillScopeProject — `<projectRoot>/.claude/skills/<slug>/SKILL.md`. Loaded only by Claude Code sessions inside that project. Use for skills that only make sense in this codebase.
- SkillScopeUser — `~/.claude/skills/<slug>/SKILL.md`. Loaded by every Claude Code session globally. Use for organizational skills (refund policy, incident response, etc.) that apply across every project the user works in.
const ( SkillScopeProject SkillScope = "project" SkillScopeUser SkillScope = "user" )
func ParseSkillScope ¶ added in v0.6.0
func ParseSkillScope(s string) (SkillScope, error)
ParseSkillScope validates a raw scope string. Returns the typed scope on success; otherwise a bare-message error callers wrap with their own field prefix (CLI: "--scope", MCP: "scope"). Hoisted from the CLI/app/MCP boundaries so all three reject the same set.
type Slug ¶
type Slug string
type StateResponse ¶
type StateResponse struct {
Effective *EffectiveState `json:"effective"`
Layers []LayerOverride `json:"layers"`
}
StateResponse is returned by GET/PUT /api/v1/state. The layers slice includes every applicable scope in precedence order (workspace first).
type StatusResponse ¶
type StatusResponse struct {
WorkspaceID WorkspaceID `json:"workspace_id"`
Effective *EffectiveState `json:"effective"`
Layers []LayerOverride `json:"layers"`
}
StatusResponse is a workspace-level summary: effective state and the full layer chain. Unlike GET /state (which is scope-aware), this is always workspace scope — a dashboard overview.
type TokenEstimate ¶
type UpsertBrainRequest ¶
type UpsertBrainRequest struct {
SoulSlug Slug `json:"soul_slug"`
PersonaSlug Slug `json:"persona_slug"`
RuleSlugs []Slug `json:"rule_slugs"`
ProcedureSlug Slug `json:"procedure_slug,omitempty"`
SkillSlugs []Slug `json:"skill_slugs,omitempty"`
ModelPrefs *ModelPrefs `json:"model_prefs,omitempty"`
}
UpsertBrainRequest is the body of PUT /api/v1/brains/{slug}.
type UpsertPersonaRequest ¶
type UpsertPersonaRequest struct {
Content string `json:"content"`
BundledRules []Slug `json:"bundled_rules"`
}
UpsertPersonaRequest is the body of PUT /api/v1/personas/{slug}.
type UpsertProcedureRequest ¶ added in v0.6.0
type UpsertProcedureRequest struct {
Content string `json:"content"`
}
UpsertProcedureRequest is the body of PUT /api/v1/procedures/{slug}.
type UpsertRuleRequest ¶
type UpsertRuleRequest struct {
Entries []RuleEntry `json:"entries"`
}
UpsertRuleRequest is the body of PUT /api/v1/rules/{slug}.
type UpsertSkillRequest ¶ added in v0.6.0
type UpsertSkillRequest struct {
Description string `json:"description"`
Body string `json:"body"`
Triggers []string `json:"triggers,omitempty"`
Version int `json:"version,omitempty"`
Scope SkillScope `json:"scope"`
}
UpsertSkillRequest is the body of PUT /api/v1/skills/{slug}.
type UpsertSoulRequest ¶
type UpsertSoulRequest struct {
Content string `json:"content"`
}
UpsertSoulRequest is the body of PUT /api/v1/souls/{slug}. The slug is taken from the path, the workspace from auth — neither appears here.
type ValidationError ¶
type ValidationError struct {
Message string
}
ValidationError is returned when input fails validation.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type VersionSummary ¶
type WorkspaceID ¶
type WorkspaceID string