Documentation
¶
Index ¶
- Constants
- Variables
- func AgentBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID) (agentkit.AgentID, error)
- func ChannelAgentBind(ctx context.Context, store agentkit.SessionStore, ws workspace.Service, ...) (agentkit.AgentID, error)
- func ChannelModelBind(ctx context.Context, store agentkit.SessionStore, entryKey agentkit.SessionID) (string, error)
- func GlobalAgentBind(ctx context.Context, ws workspace.Service) (agentkit.AgentID, error)
- func GlobalModelBind(ctx context.Context, ws workspace.Service, agentID agentkit.AgentID) (string, error)
- func GlobalModelBinds(ctx context.Context, ws workspace.Service) (map[string]string, error)
- func ModelBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID) (string, error)
- func ResolveAgentID(ctx context.Context, store agentkit.SessionStore, ws workspace.Service, ...) (effective, sessionBind, channelBind, globalBind agentkit.AgentID, err error)
- func ResolveEffectiveModel(ctx context.Context, store agentkit.SessionStore, ws workspace.Service, ...) (effective, sessionOverride, globalOverride string, err error)
- func ResolveSubagentModel(ctx context.Context, ws workspace.Service, parentAgentID agentkit.AgentID, ...) string
- func RuntimeStore(store agentkit.SessionStore) (agentkit.SessionRuntimeStore, error)
- func SetChannelAgentBind(ctx context.Context, store agentkit.SessionStore, ws workspace.Service, ...) error
- func SetChannelModelBind(ctx context.Context, store agentkit.SessionStore, entryKey agentkit.SessionID, ...) error
- func SetGlobalAgentBind(ctx context.Context, ws workspace.Service, agent agentkit.AgentID) error
- func SetGlobalModelBind(ctx context.Context, ws workspace.Service, agentID agentkit.AgentID, ...) error
- func SetSessionAgentBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID, ...) error
- func SetSessionModelBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID, ...) error
- func ValidateCwd(ctx context.Context, ws workspace.Service, path string) (string, error)
- type AgentBinding
- type BindStack
- func (s BindStack) Effective(ctx context.Context, store agentkit.SessionStore, kind Binding) (effective string, hits map[Level]string, err error)
- func (s BindStack) EffectiveWithLevel(ctx context.Context, store agentkit.SessionStore, kind Binding) (effective string, winner Level, hits map[Level]string, err error)
- func (s BindStack) Set(ctx context.Context, store agentkit.SessionStore, kind Binding, level Level, ...) error
- func (s BindStack) WithChannel(channel agentkit.SessionID) BindStack
- func (s BindStack) WithSession(session agentkit.SessionID) BindStack
- type Binding
- type ChannelRuntimeData
- type CwdBinding
- type GlobalRuntimeData
- type Level
- type ModelBinding
Constants ¶
const SubagentModelWildcardKey agentkit.AgentID = "sub:*"
SubagentModelWildcardKey is the global models key that applies to every in-process subagent without a more specific entry. Written by `/submodel * <model>`; it never affects the main agent.
Variables ¶
var Priority = []Level{LevelGlobal, LevelChannel, LevelThread, LevelUser, LevelSession}
Priority lists every level coarse-to-fine. Resolution walks it in reverse so finer scopes win. It is the single ordering shared by every binding kind (agent, model, …), replacing per-kind if-chains.
Functions ¶
func AgentBind ¶
func AgentBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID) (agentkit.AgentID, error)
AgentBind returns the per-session agent override, or "" when unset.
func ChannelAgentBind ¶ added in v0.4.18
func ChannelAgentBind(ctx context.Context, store agentkit.SessionStore, ws workspace.Service, entryKey agentkit.SessionID) (agentkit.AgentID, error)
ChannelAgentBind returns the channel default for entryKey (stable delivery / active-entry id). Falls back to legacy local:runtime.json when tenant-scoped.
func ChannelModelBind ¶ added in v0.4.35
func ChannelModelBind(ctx context.Context, store agentkit.SessionStore, entryKey agentkit.SessionID) (string, error)
ChannelModelBind returns the channel default model for entryKey, or "" when unset. Mirrors ChannelAgentBind so agent and model share the same level stack.
func GlobalAgentBind ¶
GlobalAgentBind returns the workspace-wide default agent id, or "" when unset.
func GlobalModelBind ¶
func GlobalModelBind(ctx context.Context, ws workspace.Service, agentID agentkit.AgentID) (string, error)
GlobalModelBind returns the global default model for agentID, or "" when unset.
func GlobalModelBinds ¶ added in v0.3.59
GlobalModelBinds returns every entry in global:runtime.json models, or nil when unset. Commands use it to list configured overrides.
func ModelBind ¶
func ModelBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID) (string, error)
ModelBind returns the per-session model override, or "" when unset.
func ResolveAgentID ¶
func ResolveAgentID( ctx context.Context, store agentkit.SessionStore, ws workspace.Service, sessionID agentkit.SessionID, entryKey agentkit.SessionID, eventAgent agentkit.AgentID, ) (effective, sessionBind, channelBind, globalBind agentkit.AgentID, err error)
ResolveAgentID applies the shared level stack (session, user, thread, channel, global), then an explicit event agent id. The bind results are the stored values at each legacy level (session/channel/global) so existing callers and renderers keep working; thread/user are surfaced only through BindStack.
func ResolveEffectiveModel ¶
func ResolveEffectiveModel( ctx context.Context, store agentkit.SessionStore, ws workspace.Service, sessionID agentkit.SessionID, agentID agentkit.AgentID, defaultModel string, ) (effective, sessionOverride, globalOverride string, err error)
ResolveEffectiveModel applies the shared level stack (session, user, thread, channel, global-per-agent), then defaultModel. Agent and model therefore use the identical level order and key computation; only the value/storage differ.
func ResolveSubagentModel ¶ added in v0.3.59
func ResolveSubagentModel( ctx context.Context, ws workspace.Service, parentAgentID agentkit.AgentID, childAgentID agentkit.AgentID, defModel string, ) string
ResolveSubagentModel resolves the model for an in-process subagent step.
Priority (definition author > explicit subagent config > general default > fallback):
- defModel — agents/<name>.md `model:` is a capability contract authored together with the prompt and modalities; runtime overrides never win.
- global models[<childAgentID>] — the explicit per-subagent config written by `/submodel <name> <model>`.
- global models[SubagentModelWildcardKey] — the all-subagents policy written by `/submodel * <model>`; main agent is unaffected.
- global models[<parentAgentID>] — the parent agent's `/model -g` choice, the general default specific keys refine.
defModel is also the final fallback when nothing else is set. Neither the child session's bind nor the parent conversation's session bind participate: per-delegation ids have no /model entry point, and the user's in-conversation /model targets the main agent only — subagent models are explicit config, not implicit inheritance.
func RuntimeStore ¶
func RuntimeStore(store agentkit.SessionStore) (agentkit.SessionRuntimeStore, error)
RuntimeStore returns the session runtime overlay capability when present.
func SetChannelAgentBind ¶ added in v0.4.18
func SetChannelAgentBind(ctx context.Context, store agentkit.SessionStore, ws workspace.Service, entryKey agentkit.SessionID, agent agentkit.AgentID) error
SetChannelAgentBind sets or clears the channel default for entryKey.
func SetChannelModelBind ¶ added in v0.4.35
func SetChannelModelBind(ctx context.Context, store agentkit.SessionStore, entryKey agentkit.SessionID, model string) error
SetChannelModelBind sets or clears the channel default model for entryKey.
func SetGlobalAgentBind ¶
SetGlobalAgentBind sets or clears the workspace-wide default agent id.
func SetGlobalModelBind ¶
func SetGlobalModelBind(ctx context.Context, ws workspace.Service, agentID agentkit.AgentID, model string) error
SetGlobalModelBind sets or clears the global default model for agentID.
func SetSessionAgentBind ¶
func SetSessionAgentBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID, agent agentkit.AgentID) error
SetSessionAgentBind sets or clears the per-session agent override.
func SetSessionModelBind ¶
func SetSessionModelBind(ctx context.Context, store agentkit.SessionStore, id agentkit.SessionID, model string) error
SetSessionModelBind sets or clears the per-session model override.
Types ¶
type AgentBinding ¶ added in v0.4.35
type AgentBinding struct{}
AgentBinding is the Binding for the default-agent override.
func (AgentBinding) Key ¶ added in v0.4.35
func (AgentBinding) Key() string
type BindStack ¶ added in v0.4.35
BindStack is the keys a single resolution reads across every level.
func StackFromContext ¶ added in v0.4.35
StackFromContext builds the level stack for the current turn: keys from rctx.BindKeysFromContext plus the workspace handle.
func (BindStack) Effective ¶ added in v0.4.35
func (s BindStack) Effective(ctx context.Context, store agentkit.SessionStore, kind Binding) (effective string, hits map[Level]string, err error)
Effective resolves value across Priority (fine wins), returning the winner and the raw hit at every level (named in the map so callers can render "session override / channel override / …" uniformly). A level whose key is empty (e.g. Thread on a non-topic delivery) is skipped, not treated as unset.
func (BindStack) EffectiveWithLevel ¶ added in v0.4.35
func (s BindStack) EffectiveWithLevel(ctx context.Context, store agentkit.SessionStore, kind Binding) (effective string, winner Level, hits map[Level]string, err error)
EffectiveWithLevel is Effective plus the winning level (LevelNone when nothing is set), so callers can report which scope actually won instead of guessing from a non-empty finer hit.
func (BindStack) Set ¶ added in v0.4.35
func (s BindStack) Set(ctx context.Context, store agentkit.SessionStore, kind Binding, level Level, value string) error
Set writes value at level, resolving the level's key from the stack.
func (BindStack) WithChannel ¶ added in v0.4.35
WithChannel overrides the channel key when non-empty (legacy callers pass an explicit entry key; the turn-derived channel key is kept otherwise).
type Binding ¶ added in v0.4.35
type Binding interface {
// Key is a stable identifier for the kind ("agent", "model"), used in
// messages and storage keys.
Key() string
// Read returns the value stored at level for key, or "" when unset.
Read(ctx context.Context, level Level, key agentkit.SessionID, ws workspace.Service, store agentkit.SessionStore) (string, error)
// Write stores value at level for key ("" clears).
Write(ctx context.Context, level Level, key agentkit.SessionID, ws workspace.Service, store agentkit.SessionStore, value string) error
}
Binding identifies one dynamic-override kind. Kinds share the level stack, the key computation (rctx.BindKeys) and the priority order; only the value type and per-kind storage differ.
type ChannelRuntimeData ¶ added in v0.4.18
ChannelRuntimeData holds channel-scoped dynamic overrides.
type CwdBinding ¶ added in v0.4.38
type CwdBinding struct{}
CwdBinding shares session/channel keys with the catalog commands. No global, thread or user override is exposed for cwd.
func (CwdBinding) Key ¶ added in v0.4.38
func (CwdBinding) Key() string
type GlobalRuntimeData ¶
type GlobalRuntimeData struct {
AgentID agentkit.AgentID `json:"agentId,omitempty"`
Models map[string]string `json:"models,omitempty"`
}
GlobalRuntimeData holds workspace-wide dynamic overrides.
type Level ¶ added in v0.4.35
type Level int
Level is one rung of the dynamic-binding stack, coarse to fine. Thread and User are mutually exclusive siblings: a delivery id carries :t: or :u:, not both, so at most one of them is ever present in a turn's BindKeys.
const LevelNone Level = -1
LevelNone marks "no level set a value".
func HitsFor ¶ added in v0.4.35
HitsFor renders non-empty hits in Priority order (fine first) for uniform "override" listings across binding kinds.
func ResolveModelBinding ¶ added in v0.4.35
func ResolveModelBinding( ctx context.Context, store agentkit.SessionStore, ws workspace.Service, sessionID agentkit.SessionID, agentID agentkit.AgentID, defaultModel string, ) (effective string, winner Level, hits map[Level]string, err error)
ResolveModelBinding is ResolveEffectiveModel plus the winning level and the full hit map, so the /model command can report which scope won rather than inferring it from a non-empty finer hit.
type ModelBinding ¶ added in v0.4.35
ModelBinding is the Binding for the per-session default-model override. The global level is per-agent (models[<agentId>] in the workspace runtime file), so it carries its own key handling.
func (ModelBinding) Key ¶ added in v0.4.35
func (ModelBinding) Key() string