Documentation
¶
Overview ¶
Package workspace manages the discovery, loading, resolution, and rendering of declarative TaskSmith workspace configurations and resources.
Four-Tier Resource Resolution ¶
Resources are loaded and resolved across four hierarchical namespaces, listed from lowest to highest precedence:
- NamespaceSystem ("system"): Embedded builtin agents shipped with the binary alongside any additional io/fs.FS filesystems injected via WithBuiltinFS (such as builtin tool manifests).
- NamespaceUser ("user"): User-global resources discovered under the XDG configuration directory ($XDG_CONFIG_HOME/tasksmith/agents).
- NamespaceWorkspace ("workspace"): Workspace-wide resources located in the root .agents/ directory of a multi-project workspace.
- NamespaceLocal ("local"): Project-local resources located inside the active project's .agents/ directory.
When a workspace is opened at a directory belonging to a specific subproject, all resource lookups on its Catalog automatically scope resolution to that project so local overrides shadow workspace, user, and system definitions.
Isolated Environment Secret Layering ¶
Opening or reloading a workspace constructs an isolated in-memory environment map (Workspace.Env) without mutating the host process environment (os.Setenv). Environment files are layered in ascending order of precedence:
- User-global secrets ($XDG_CONFIG_HOME/tasksmith/.env).
- Ancestor .env files discovered while climbing toward WORKSPACE.md (such as a shared .env in a bare-repository worktree hub).
- Workspace root secrets (<RootDir>/.env).
- Working directory secrets (<CWD>/.env) when operating inside a subproject.
Index ¶
- Constants
- Variables
- func BuildPositionalArgs(argsDef []warp.Argument, args map[string]string) []string
- func ComputeExecutableFingerprint(dir string) (string, error)
- func CopyConfig(srcDir, dstDir string) error
- func EnsureBuiltinDir() (string, error)
- func EnsureGitignoreEntry(dir, entry string) error
- func FormatSkillScope(ns string) string
- func Initialize(ctx context.Context, dir string, opts InitOptions) ([]api.SkippedPresetAlias, error)
- func IsConfigured(dir string) bool
- func IsInitialized(dir string) bool
- func IsTrusted(dir string) (bool, bool, error)
- func MergeStringArgs(args map[string]string, globals map[string]any) map[string]any
- func MetadataPath(dir string) (string, error)
- func ParseThinking(thinking *warp.AgentThinking) *api.ThinkingSetting
- func Presets() []*warp.ModelProvider
- func ProviderAuthEnvNames(auth *warp.ProviderAuth) []string
- func ProviderAuthPrimaryEnv(auth *warp.ProviderAuth) string
- func RegisterMigration(action MigrationAction)
- func RevokeTrust(dir string) error
- func RunMigrations(ctx context.Context, dir string, runningVersion string) error
- func SaveTrustStore(store *TrustStore) error
- func ToAPIArguments(args []warp.Argument) []api.Argument
- func TrustFilePath() (string, error)
- func TrustFolder(dir string, scope TrustScope) error
- func WriteMetadata(dir string, meta Metadata) error
- type AgentSnapshot
- type AliasAssignment
- type AliasOwner
- type Catalog
- func (c *Catalog) AgentContext(name string) api.ContextBreakdown
- func (c *Catalog) AgentRenderGlobals(resolved *warp.ResolvedAgent) map[string]any
- func (c *Catalog) Agents() []AgentSnapshot
- func (c *Catalog) BuildDeferredToolsCatalog(resolved *warp.ResolvedAgent) *DeferredToolsCatalog
- func (c *Catalog) Commands() []CommandSnapshot
- func (c *Catalog) ConditionalTemplateRules(resolved *warp.ResolvedAgent) []templateRule
- func (c *Catalog) DefaultAgentName() string
- func (c *Catalog) DeniedMCPToolSnapshots() []ToolSnapshot
- func (c *Catalog) GetAgent(name string) (AgentSnapshot, bool)
- func (c *Catalog) GetCommand(name string) (CommandSnapshot, bool)
- func (c *Catalog) GetDecision(name string) (DecisionSnapshot, bool)
- func (c *Catalog) GetMCP(name string) (*warp.MCP, bool)
- func (c *Catalog) GetMCPSnapshot(name string) (MCPSnapshot, bool)
- func (c *Catalog) GetProvider(name string) (*warp.ModelProvider, bool)
- func (c *Catalog) GetRule(name string) (RuleSnapshot, bool)
- func (c *Catalog) GetSkill(name string) (SkillSnapshot, bool)
- func (c *Catalog) GetTool(name string) (*warp.Tool, bool)
- func (c *Catalog) GetToolSnapshot(name string) (ToolSnapshot, bool)
- func (c *Catalog) HasAllowedMCPResources() bool
- func (c *Catalog) HasConditionalRules(resolved *warp.ResolvedAgent) bool
- func (c *Catalog) IsMCPServerAvailable(name string) bool
- func (c *Catalog) IsToolAvailable(name string) bool
- func (c *Catalog) MCPServerForTool(t *warp.Tool) *warp.MCP
- func (c *Catalog) MCPSnapshots() []MCPSnapshot
- func (c *Catalog) MCPs() []*warp.MCP
- func (c *Catalog) PartitionAgentTools(resolved *warp.ResolvedAgent) ToolPartition
- func (c *Catalog) Plugins() []warp.WorkspacePlugin
- func (c *Catalog) Policies() *warp.Policies
- func (c *Catalog) Project() *warp.Project
- func (c *Catalog) Projects() []*warp.Project
- func (c *Catalog) Providers() []*warp.ModelProvider
- func (c *Catalog) Refresh() error
- func (c *Catalog) Registry() *warp.Registry
- func (c *Catalog) ResolveAgent(name string) (*warp.ResolvedAgent, error)
- func (c *Catalog) ResolveCommand(agentName, cmdRef string) (*warp.ResolvedCommand, error)
- func (c *Catalog) ResolveModel(role warp.ModelRole, explicit ...string) (*warp.ResolvedModel, bool)
- func (c *Catalog) ResolveModels(role warp.ModelRole, explicit ...string) []warp.ResolvedModel
- func (c *Catalog) Resolver() warp.Resolver
- func (c *Catalog) Rules() []RuleSnapshot
- func (c *Catalog) ScopeNamespace(b warp.BaseResource) string
- func (c *Catalog) SetDeniedMCPTools(def *warp.MCP, raw []*warp.Tool)
- func (c *Catalog) SetMCPResourceProbe(probe func() bool)
- func (c *Catalog) Skills() []SkillSnapshot
- func (c *Catalog) ToolNames() []string
- func (c *Catalog) ToolSnapshots() []ToolSnapshot
- func (c *Catalog) ToolStatuses(resolved *warp.ResolvedAgent) map[string]api.ToolStatus
- func (c *Catalog) Tools() []*warp.Tool
- func (c *Catalog) ToolsForSkill(agentName, skillRef string) ([]*warp.Tool, error)
- func (c *Catalog) Warnings() []string
- func (c *Catalog) WorkspaceSpec() *warp.Workspace
- type CommandSnapshot
- type DecisionSnapshot
- type DeferredMCPSummary
- type DeferredToolSummary
- type DeferredToolsCatalog
- type ExecutableConfigSummary
- type InitOptions
- type MCPService
- type MCPSnapshot
- type Metadata
- type MigrationAction
- type Option
- type ProviderModelEdit
- type ProviderRecord
- type ResourceRecord
- type RuleSnapshot
- type SkillSnapshot
- type ToolPartition
- type ToolSnapshot
- type TrustScope
- type TrustStore
- type TrustedFolder
- type Workspace
- func (w *Workspace) AliasAssignments() []AliasAssignment
- func (w *Workspace) AssignModelAliases(providerName, modelID string, aliases []string, defaultHere bool) error
- func (w *Workspace) CWD() string
- func (w *Workspace) Catalog() *Catalog
- func (w *Workspace) Env() map[string]string
- func (w *Workspace) FilterPresetAliases(provider, scope string, spec *warp.ModelProviderSpec, ...) []api.SkippedPresetAlias
- func (w *Workspace) IsRestricted() bool
- func (w *Workspace) IsSynthetic() bool
- func (w *Workspace) MCP() MCPService
- func (w *Workspace) MCPDef(name string) (*warp.MCP, bool)
- func (w *Workspace) MCPDefinitions() []*warp.MCP
- func (w *Workspace) MCPRecord(name string) (ResourceRecord, bool)
- func (w *Workspace) Name() string
- func (w *Workspace) PortablePath(targetPath string) string
- func (w *Workspace) PrepareReload(ctx context.Context) (*Workspace, func(), error)
- func (w *Workspace) ProviderRecord(name string) (ProviderRecord, bool)
- func (w *Workspace) ProviderRecords() []ProviderRecord
- func (w *Workspace) Reload(ctx context.Context) error
- func (w *Workspace) RenderOptions() warp.MCPRenderOptions
- func (w *Workspace) RootDir() string
- func (w *Workspace) SetMCPEnabled(name string, enabled bool) error
- func (w *Workspace) SetMCPService(srv MCPService)
- func (w *Workspace) SetProviderEnabled(name string, enabled bool) error
- func (w *Workspace) SetToolEnabled(name string, enabled bool) error
- func (w *Workspace) SetWorkspaceMCPExcluded(name string, excluded bool) error
- func (w *Workspace) SetWorkspaceToolExcluded(name string, excluded bool) error
- func (w *Workspace) SubprocessEnv() map[string]string
- func (w *Workspace) SyncMCPTools(def *warp.MCP, rawTools []*warp.Tool) error
- func (w *Workspace) ToolRecord(name string) (ResourceRecord, bool)
- func (w *Workspace) UpdateProviderModels(name string, models []ProviderModelEdit, defaultModel string, defaultSet bool) error
Constants ¶
const ( NamespaceSystem = warp.NamespaceSystem NamespaceUser = warp.NamespaceUser NamespaceWorkspace = warp.NamespaceWorkspace NamespaceLocal = warp.NamespaceLocal )
Namespace constants identifying the 4-tier resource resolution hierarchy.
const ( AgentNameMain = "main" AgentNameTitleGenerator = "title-generator" PermissionReviewerDecisionName = "permission-reviewer" )
Builtin agent and decision identifiers shipped in the system namespace.
const MaxListedMCPToolsPerServer = 15
MaxListedMCPToolsPerServer caps how many deferred tool names are listed for a single MCP server in the system prompt's <deferred_tools> directory.
const MaxRecommendedEagerTools = 20
MaxRecommendedEagerTools is the recommended maximum number of eager tools an agent should load on the first request. Agents resolving to more than this many eager tools emit a diagnostic advising the user to reduce spec.tools and rely on deferred loading via tool_search.
const ModelAliasInherit = warp.ModelAliasInherit
ModelAliasInherit is the TaskSmith-reserved model alias "@inherit". It never resolves through a provider manifest: the session layer resolves it to the delegating parent session's active model when a subagent is invoked.
const WorkspaceMetadataFile = "workspace.json"
WorkspaceMetadataFile is the name of the per-workspace metadata file.
const WorkspaceMetadataSchema = 1
WorkspaceMetadataSchema defines the current format version of workspace.json.
Variables ¶
var ErrMCPNotFound = errors.New("workspace: MCP server not found")
ErrMCPNotFound marks operations naming an MCP server the workspace does not declare.
var ErrManifestReadOnly = errors.New("workspace: manifest is read-only")
ErrManifestReadOnly marks a toggle attempt against a resource whose manifest is not writable on disk (built-in, embedded, or read-only). Such resources are excluded per repository through WORKSPACE.md policies instead.
var ErrNoSafePolicyEdit = errors.New("workspace: no safe policy edit")
ErrNoSafePolicyEdit reports that no automatic WORKSPACE.md edit can change a resource's availability, because a glob pattern would keep matching it.
var ErrProviderNotFound = errors.New("workspace: provider not found")
ErrProviderNotFound marks operations naming a provider the workspace does not declare in any tier.
var ErrProviderReadOnly = errors.New("workspace: provider manifest is read-only")
ErrProviderReadOnly marks a patch attempt against a provider whose manifest is not writable on disk (built-in or embedded resources).
var ErrToolNotFound = errors.New("workspace: tool not found")
ErrToolNotFound marks operations naming a tool the workspace does not declare.
var TierAliases = []string{"@fast", "@balanced", "@smart", "@flagship"}
TierAliases lists the standardized completion-model tier aliases TaskSmith recommends providers declare (fast, balanced, smart, flagship). Built-in provider presets assign each tier alias to a model; workspaces driven by custom providers may leave a tier unresolvable, which the catalog tolerates for built-in agents.
Functions ¶
func BuildPositionalArgs ¶
BuildPositionalArgs maps arguments into an ordered slice according to argsDef.
func ComputeExecutableFingerprint ¶
ComputeExecutableFingerprint calculates a SHA-256 hash over the contents of .agents/mcps/**, .agents/tools/**, and .agents/decisions/** to detect modifications after a pull.
func CopyConfig ¶
CopyConfig copies WORKSPACE.md, .agents/ (recursively), .env, and warp.lock (each if present) from srcDir into dstDir. It is used during bare-repository worktree promotion flows (C3a/C3b) to transfer workspace configuration into a newly created worktree.
func EnsureBuiltinDir ¶
func EnsureGitignoreEntry ¶
EnsureGitignoreEntry appends entry to <dir>/.gitignore under a secrets heading when it is not already listed, creating the file when missing.
func FormatSkillScope ¶
FormatSkillScope formats a namespace into its user-facing scope title.
func Initialize ¶
func Initialize(ctx context.Context, dir string, opts InitOptions) ([]api.SkippedPresetAlias, error)
Initialize initializes the workspace directory at dir according to opts. It records a setup.json sentinel in the XDG workspace data directory, writes any provided APIKey into <dir>/.env (ensuring .env is listed in .gitignore), and—unless opts.TrustOnly is true—writes WORKSPACE.md and .agents/providers/<provider>.yaml.
func IsConfigured ¶
IsConfigured reports whether dir contains a WORKSPACE.md file or a .agents directory.
func IsInitialized ¶
IsInitialized reports whether dir is already configured on disk (via WORKSPACE.md or .agents/) or has a workspace.json (or legacy setup.json) sentinel in its XDG workspace data directory.
func IsTrusted ¶
IsTrusted reports whether dir is trusted by any entry in the trust store. If an entry is found, it also checks if the directory's executable configuration fingerprint has changed since it was trusted (re-prompt condition). Returns (isTrusted, fingerprintChanged, error).
func MergeStringArgs ¶
MergeStringArgs copies string arguments into globals map under both their named keys and the "Args" map key.
func MetadataPath ¶
MetadataPath returns the absolute path to workspace.json for dir.
func ParseThinking ¶
func ParseThinking(thinking *warp.AgentThinking) *api.ThinkingSetting
ParseThinking extracts an api.ThinkingSetting from an agent's thinking configuration.
func Presets ¶
func Presets() []*warp.ModelProvider
Presets returns all embedded model provider presets sorted by metadata name.
func ProviderAuthEnvNames ¶
func ProviderAuthEnvNames(auth *warp.ProviderAuth) []string
ProviderAuthEnvNames extracts all environment variable names referenced by ${env:<VAR>} expressions across auth's fields (including nested OAuth fields).
func ProviderAuthPrimaryEnv ¶
func ProviderAuthPrimaryEnv(auth *warp.ProviderAuth) string
ProviderAuthPrimaryEnv returns the primary environment variable name referenced by auth (checking Token first, then any other ${env:...} expression).
func RegisterMigration ¶
func RegisterMigration(action MigrationAction)
RegisterMigration registers a version migration action.
func RunMigrations ¶
RunMigrations checks the stored version of a workspace against runningVersion and executes applicable migrations in ascending semver order.
Rules matching §2.2:
- On workspace open, compare stored version with running version.
- If older, run every registered migration action whose target version is in (stored, running], in ascending semver order. Actions touching committed files are skipped for automatic execution.
- After all succeed, write running version to workspace.json. If one fails, stop, keep the last successfully applied version, and return the error.
- If stored is newer than running (downgrade), run nothing, leave the file untouched, and warn.
- Development builds skip migrations.
func SaveTrustStore ¶
func SaveTrustStore(store *TrustStore) error
SaveTrustStore atomically writes the trust store to XDG_DATA_HOME/trust.json.
func ToAPIArguments ¶
ToAPIArguments converts warp arguments to public API arguments.
func TrustFilePath ¶
TrustFilePath returns the absolute path to $XDG_DATA_HOME/tasksmith/trust.json.
func TrustFolder ¶
func TrustFolder(dir string, scope TrustScope) error
TrustFolder marks a directory as trusted with the given scope.
func WriteMetadata ¶
WriteMetadata writes meta to workspace.json for dir atomically.
Types ¶
type AgentSnapshot ¶
AgentSnapshot pairs an API Agent presentation with its defining warp.Agent and resolved inheritance tree.
type AliasAssignment ¶
type AliasAssignment struct {
Alias string
Owners []AliasOwner
Workspace bool // workspace.spec.modelAliases shadows the bare alias
Duplicates []AliasOwner
}
AliasAssignment is one alias with its current owners across enabled providers. More than one owner means manual YAML edits collided.
type AliasOwner ¶
AliasOwner is one "provider/model" pair declaring an alias.
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog acts as an in-memory query and resolution proxy over a warp.Registry (and scoped registry when cwd is inside a subproject), exposing native warp resource definitions pre-materialized in lock-free point-in-time memdb stores.
func NewCatalog ¶
NewCatalog constructs a Catalog proxying reg for the given cwd and rootDir, pre-materializing all effective resources in lock-free memdb stores.
func (*Catalog) AgentContext ¶
func (c *Catalog) AgentContext(name string) api.ContextBreakdown
AgentContext calculates token breakdown metrics for the named agent.
func (*Catalog) AgentRenderGlobals ¶
func (c *Catalog) AgentRenderGlobals(resolved *warp.ResolvedAgent) map[string]any
AgentRenderGlobals returns the template globals for rendering an agent's system prompt: a HasTool predicate over the agent's eager tools (including tool_search when the agent has deferred tools) and a compact DeferredTools directory for the tool_search section.
func (*Catalog) Agents ¶
func (c *Catalog) Agents() []AgentSnapshot
Agents returns all effective agent snapshots in scope, sorted by metadata name.
func (*Catalog) BuildDeferredToolsCatalog ¶
func (c *Catalog) BuildDeferredToolsCatalog(resolved *warp.ResolvedAgent) *DeferredToolsCatalog
BuildDeferredToolsCatalog groups a resolved agent's deferred tools into a compact directory of custom/built-in tools and MCP servers for the system prompt. It returns nil when the agent has no deferred tools.
func (*Catalog) Commands ¶
func (c *Catalog) Commands() []CommandSnapshot
Commands returns all effective command snapshots in scope, sorted by metadata name.
func (*Catalog) ConditionalTemplateRules ¶
func (c *Catalog) ConditionalTemplateRules(resolved *warp.ResolvedAgent) []templateRule
ConditionalTemplateRules returns the view models for the resolved agent's conditional (non-always) rules, sorted by priority descending then name ascending. Always-active rules are excluded because they are statically injected into <workspace_rules> instead of being surfaced for on-demand loading.
func (*Catalog) DefaultAgentName ¶
DefaultAgentName returns the workspace's configured default agent name, or "main".
func (*Catalog) DeniedMCPToolSnapshots ¶
func (c *Catalog) DeniedMCPToolSnapshots() []ToolSnapshot
DeniedMCPToolSnapshots returns the discovered MCP tools that policy prohibits, sorted by name.
func (*Catalog) GetAgent ¶
func (c *Catalog) GetAgent(name string) (AgentSnapshot, bool)
GetAgent resolves an agent snapshot by name or qualified name.
func (*Catalog) GetCommand ¶
func (c *Catalog) GetCommand(name string) (CommandSnapshot, bool)
GetCommand resolves a command snapshot by name or qualified name.
func (*Catalog) GetDecision ¶
func (c *Catalog) GetDecision(name string) (DecisionSnapshot, bool)
GetDecision resolves an effective Decision by name or qualified name across the standard 4-tier WARP hierarchy (local > workspace > user > system), so a workspace-committed .agents/decisions/<name>.decision.md overrides the built-in system manifest of the same name.
func (*Catalog) GetMCP ¶
GetMCP resolves an effective MCP server definition by name or qualified name.
func (*Catalog) GetMCPSnapshot ¶
func (c *Catalog) GetMCPSnapshot(name string) (MCPSnapshot, bool)
GetMCPSnapshot resolves an effective MCP server snapshot by name or qualified name.
func (*Catalog) GetProvider ¶
func (c *Catalog) GetProvider(name string) (*warp.ModelProvider, bool)
GetProvider resolves an effective model provider by name or qualified name.
func (*Catalog) GetRule ¶
func (c *Catalog) GetRule(name string) (RuleSnapshot, bool)
GetRule resolves a rule snapshot by name or qualified name.
func (*Catalog) GetSkill ¶
func (c *Catalog) GetSkill(name string) (SkillSnapshot, bool)
GetSkill resolves a skill snapshot by name or qualified name.
func (*Catalog) GetToolSnapshot ¶
func (c *Catalog) GetToolSnapshot(name string) (ToolSnapshot, bool)
GetToolSnapshot resolves an effective tool snapshot by name or qualified name.
func (*Catalog) HasAllowedMCPResources ¶
HasAllowedMCPResources reports whether the workspace's MCP runtime exposes a policy-permitted MCP resource. With no runtime probe installed it reports false, so a workspace without an MCP runtime never loads the resource-reading tool.
func (*Catalog) HasConditionalRules ¶
func (c *Catalog) HasConditionalRules(resolved *warp.ResolvedAgent) bool
HasConditionalRules reports whether the resolved agent has at least one rule that is not unconditionally active (i.e. !triggers.always). Such rules are surfaced to the agent via the load_rule tool and the <available_rules> discovery directory rather than being statically injected into the system prompt. It returns false when resolved is nil or all rules are always-active.
func (*Catalog) IsMCPServerAvailable ¶
IsMCPServerAvailable reports whether an MCP server may connect in this workspace: its manifest is enabled and the workspace's WORKSPACE.md policies do not exclude it.
func (*Catalog) IsToolAvailable ¶
IsToolAvailable reports whether a tool can reach an agent in this workspace: its manifest (and, for MCP tools, its parent server) is enabled and neither is excluded by the workspace's WORKSPACE.md policies. Disabled tools remain in listings so /tools can present and re-enable them.
func (*Catalog) MCPServerForTool ¶
MCPServerForTool reports the MCP server a tool was discovered from, or nil when the tool is a regular manifest tool. It is the exported form of the attribution used to give MCP tools their scope label, so a tool container can register MCP tools without duplicating the naming rules.
func (*Catalog) MCPSnapshots ¶
func (c *Catalog) MCPSnapshots() []MCPSnapshot
MCPSnapshots returns all effective MCP server snapshots in scope, sorted by metadata name. Each snapshot carries the manifest-derived api.MCPServer presentation alongside the defining warp.MCP.
func (*Catalog) MCPs ¶
MCPs returns all available MCP server definitions in scope, sorted by metadata name. Servers disabled through spec.enabled or excluded by WORKSPACE.md policies are omitted, so the MCP manager never spawns them; use MCPSnapshots for the superset with availability flags.
func (*Catalog) PartitionAgentTools ¶
func (c *Catalog) PartitionAgentTools(resolved *warp.ResolvedAgent) ToolPartition
PartitionAgentTools computes the eager/deferred tool partition for a resolved agent. When resolved is nil (agentless workspace), every effective tool is eager and nothing is deferred.
Eager tools come from resolved.Tools (WARP-resolved from agent.spec.tools and filtered by workspace and agent policies), excluding MCP tools — which are deferred by default because they are discovered at runtime and can be numerous — unless the agent names one outright in spec.tools, and excluding conditional built-in tools whose preconditions aren't met (invoke_agent/manage_agents when the agent has no subagents, load_skill when it has no skills, read_mcp_resource when no server exposes a permitted resource). tool_search is eager only when explicitly listed.
Deferred tools are every effective tool not already eager, not tool_search or a conditional built-in whose precondition isn't met, and passing the agent's policy ceiling (resolved.ToolAction != ToolPolicyDeny).
func (*Catalog) Plugins ¶
func (c *Catalog) Plugins() []warp.WorkspacePlugin
Plugins returns a deep-copied slice of the plugins declared in WORKSPACE.md (spec.plugins). It returns nil when the workspace spec or its definition is unavailable so callers cannot mutate the catalog's internal state.
func (*Catalog) Project ¶
Project returns the project corresponding to cwd, if cwd is within a project scope.
func (*Catalog) Projects ¶
Projects returns all projects mapped into the workspace, sorted by project name. It returns nil when the catalog has no registry.
func (*Catalog) Providers ¶
func (c *Catalog) Providers() []*warp.ModelProvider
Providers returns all effective model providers in scope, sorted by metadata name.
func (*Catalog) Refresh ¶
Refresh re-materializes every snapshot store from the current registry state. It exists for registry mutations that happen after the catalog was built, such as an MCP server's discovered tools being registered at runtime, so tool lists, agent partitions, and token counts reflect what the registry now holds. Readers keep seeing a consistent point-in-time view because each store and the precomputed state are published atomically.
func (*Catalog) ResolveAgent ¶
func (c *Catalog) ResolveAgent(name string) (*warp.ResolvedAgent, error)
ResolveAgent resolves the fully merged agent definition and capabilities for name.
func (*Catalog) ResolveCommand ¶
func (c *Catalog) ResolveCommand(agentName, cmdRef string) (*warp.ResolvedCommand, error)
ResolveCommand resolves the fully merged command for cmdRef for the named agent (or the workspace default agent when agentName is empty). It verifies command enablement against the agent's spec.commands (unless the command declares an explicit spec.agent override) and eagerly resolves its skills, rules, and effective tools against the workspace and agent tool policy ceilings. When no agent is active (agentless workspace), it delegates to the underlying registry's resolver.
func (*Catalog) ResolveModel ¶
ResolveModel resolves the highest-priority model reference for role and explicit overrides.
func (*Catalog) ResolveModels ¶
ResolveModels returns the prioritized list of resolved models for role.
func (*Catalog) Resolver ¶
Resolver returns the effective WARP resolver for this catalog's cwd (a project-scoped ScopedRegistry when cwd is inside a project, or the root Registry otherwise).
func (*Catalog) Rules ¶
func (c *Catalog) Rules() []RuleSnapshot
Rules returns all effective rule snapshots in scope, sorted by metadata name.
func (*Catalog) ScopeNamespace ¶
func (c *Catalog) ScopeNamespace(b warp.BaseResource) string
ScopeNamespace normalizes a project-slug namespace to warp.NamespaceLocal when reg.GetProject(ns) matches, for display and API conversion.
func (*Catalog) SetDeniedMCPTools ¶
SetDeniedMCPTools records the tools discovered on one MCP server that spec.policies prohibits, replacing any previously recorded set for that server. They stay out of the effective tool list so they can never be called, while still appearing in tool listings as blocked by policy.
func (*Catalog) SetMCPResourceProbe ¶
SetMCPResourceProbe installs the predicate that decides whether the resource-reading built-in tool is worth loading. Passing nil clears it, which makes the tool inactive. The probe is consulted on every rebuild, because MCP resources appear only once a server has connected in the background.
func (*Catalog) Skills ¶
func (c *Catalog) Skills() []SkillSnapshot
Skills returns all effective skill snapshots in scope, sorted by metadata name.
func (*Catalog) ToolNames ¶
ToolNames returns the metadata names of all effective tools in scope, in the same order as [Tools]. It is a convenience for callers that need an explicit allowlist of every workspace tool.
func (*Catalog) ToolSnapshots ¶
func (c *Catalog) ToolSnapshots() []ToolSnapshot
ToolSnapshots returns all effective tool snapshots in scope, sorted by metadata name. Each snapshot carries the pre-materialized api.Tool presentation (scope, schemas, annotations, and token cost) alongside the defining warp.Tool.
func (*Catalog) ToolStatuses ¶
func (c *Catalog) ToolStatuses(resolved *warp.ResolvedAgent) map[string]api.ToolStatus
ToolStatuses classifies every effective tool for a resolved agent as eager, deferred, denied, or inactive, sharing the partition's decision rules so an interactive tool browser can report what the agent can actually reach.
A nil resolved (agentless workspace) makes every effective tool eager, mirroring Catalog.PartitionAgentTools. tool_search is eager whenever any tool is deferred (the session auto-activates it) unless a policy denies it. Tools that are neither eager nor deferred are denied when the workspace or agent policy ceiling blocks them, and inactive otherwise (conditional built-ins whose preconditions are unmet, for example).
func (*Catalog) Tools ¶
Tools returns all available tools in scope, sorted by metadata name. Tools disabled through spec.enabled or excluded by WORKSPACE.md policies are omitted; use ToolSnapshots for the superset with availability flags.
func (*Catalog) ToolsForSkill ¶
ToolsForSkill resolves the tools declared by the skill referenced by skillRef for the named agent (or the workspace default agent when agentName is empty), enforcing both the workspace tool policy ceiling and the agent's full policy ceiling (include, exclude, dangerous, openWorld, readOnly). When no agent is active (agentless workspace), it resolves the skill's tools against the workspace policy ceiling only.
func (*Catalog) Warnings ¶
Warnings returns non-fatal diagnostic warnings collected during registry loading and structural validation. The returned slice is a defensive copy so callers cannot mutate the catalog's internal state.
func (*Catalog) WorkspaceSpec ¶
WorkspaceSpec returns the workspace specification resource from WORKSPACE.md.
type CommandSnapshot ¶
CommandSnapshot pairs an API Command presentation with its defining warp.Command.
type DecisionSnapshot ¶
DecisionSnapshot pairs a Decision manifest with the namespace scope it was resolved from. Decisions have no API presentation surface yet, so the snapshot carries the raw definition plus its normalized scope.
type DeferredMCPSummary ¶
type DeferredMCPSummary struct {
Name string
Prefix string // "<name>__*"
Description string
Tools []string
ExtraCount int
}
DeferredMCPSummary describes an MCP server and its deferred tools for system prompt discovery.
type DeferredToolSummary ¶
DeferredToolSummary describes a non-MCP deferred tool for system prompt discovery.
type DeferredToolsCatalog ¶
type DeferredToolsCatalog struct {
Tools []DeferredToolSummary
MCPServers []DeferredMCPSummary
}
DeferredToolsCatalog groups deferred custom/built-in tools and MCP servers.
type ExecutableConfigSummary ¶
type ExecutableConfigSummary struct {
MCPServers []string `json:"mcp_servers,omitempty"`
CustomTools []string `json:"custom_tools,omitempty"`
Decisions []string `json:"decisions,omitempty"`
HasEnv bool `json:"has_env,omitempty"`
}
ExecutableConfigSummary summarizes the executable configurations found in a folder.
func ScanExecutableConfig ¶
func ScanExecutableConfig(dir string) (ExecutableConfigSummary, error)
ScanExecutableConfig checks what MCP servers, custom tools, and .env files exist in dir.
func (ExecutableConfigSummary) HasExecutables ¶
func (s ExecutableConfigSummary) HasExecutables() bool
HasExecutables reports whether any executable items or local .env are present.
type InitOptions ¶
type InitOptions struct {
Scope string `json:"scope,omitempty"` // "user", "workspace", "project"
ProjectName string `json:"project_name,omitempty"`
Provider string `json:"provider,omitempty"`
SelectedProvider string `json:"selected_provider,omitempty"`
APIKey string `json:"api_key,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
DefaultModels map[warp.ModelRole]string `json:"default_models,omitempty"`
DefaultAgent string `json:"default_agent,omitempty"`
ModelAliases map[string]string `json:"model_aliases,omitempty"`
DisabledTools []string `json:"disabled_tools,omitempty"`
DisabledMCPs []string `json:"disabled_mcps,omitempty"`
AuthorizedTools []string `json:"authorized_tools,omitempty"`
TrustOnly bool `json:"trust_only,omitempty"`
AuthType string `json:"auth_type,omitempty"`
AuthEnv string `json:"auth_env,omitempty"`
AuthFile string `json:"auth_file,omitempty"`
AuthHeader string `json:"auth_header,omitempty"`
}
InitOptions configures the initialization of a workspace directory.
type MCPService ¶
type MCPService interface {
// ListMCPs returns every configured MCP server with live status and
// discovered tools, prompts, and resources, sorted by name.
ListMCPs(ctx context.Context) []api.MCPServer
// RestartMCP reconnects the named server, re-discovers its tools, prompts,
// and resources, refreshes the workspace catalog, and returns the result.
RestartMCP(ctx context.Context, name string) (api.MCPServer, error)
// AuthenticateMCP starts or resumes the interactive authorization flow for
// the named server and reports the URL the user should open.
AuthenticateMCP(ctx context.Context, name string) (api.MCPAuthResponse, error)
// SubmitMCPAuthCallback completes the authorization flow in progress for the
// named server with a redirect URL pasted by the user, for the case where
// their browser could not reach the daemon's loopback callback listener.
SubmitMCPAuthCallback(ctx context.Context, name, callbackURL string) error
// GetMCPPrompt renders the named prompt. When allowProhibited is false, a
// prompt blocked by spec.policies.prompts is rejected.
GetMCPPrompt(ctx context.Context, name, prompt string, args map[string]string, allowProhibited bool) (api.MCPPromptResponse, error)
// ReadMCPResource reads a resource URI. When allowProhibited is false, a
// resource blocked by spec.policies.resources is rejected.
ReadMCPResource(ctx context.Context, name string, req api.MCPResourceRequest) (api.MCPResourceResponse, error)
// AllowPolicyItem updates the named server's writable manifest on disk so
// kind/value is permitted, reloads the server, and returns the result. Kind
// is "tool", "prompt", or "resource".
AllowPolicyItem(ctx context.Context, name string, req api.MCPAllowPolicyRequest) (api.MCPServer, error)
}
MCPService is the runtime contract for an MCP server manager attached to a Workspace. The MCP manager introduced in the runtime milestone implements it; until a manager is attached, a Workspace reports the service as unavailable and every MCP endpoint answers with a descriptive unavailable error.
Implementations must be safe for concurrent use. ListMCPs returns one entry per effective warp.MCP carrying live connection state and everything discovered on the server, including items blocked by spec.policies with Allowed set to false.
type MCPSnapshot ¶
MCPSnapshot pairs an API MCPServer presentation with its defining warp.MCP. The presentation carries only what the manifest declares; live connection state and discovered tools, prompts, and resources are overlaid by the workspace's MCPService.
type Metadata ¶
Metadata represents the persisted workspace.json state.
func EnsureMetadata ¶
EnsureMetadata ensures that workspace.json exists for a configured workspace dir.
func ReadMetadata ¶
ReadMetadata reads and parses the workspace.json file for dir. If workspace.json does not exist but legacy setup.json is found, it parses setup.json and returns a migrated Metadata.
type MigrationAction ¶
type MigrationAction struct {
TargetVersion string // Semver string, e.g. "v1.1.2"
Description string
TouchesCommitted bool // If true, skipped on automatic open and requires review via /setup
Apply func(ctx context.Context, wsDir string) error
}
MigrationAction defines an atomic version migration step for a workspace.
func PendingUpgrades ¶
func PendingUpgrades(dir string, runningVersion string) ([]MigrationAction, error)
PendingUpgrades returns any registered migration actions that touch committed files and are applicable for the current workspace.
func RegisteredMigrations ¶
func RegisteredMigrations() []MigrationAction
RegisteredMigrations returns a copy of all registered migration actions.
type Option ¶
type Option func(*openOptions)
Option configures how a Workspace is opened.
func WithBuiltinFS ¶
WithBuiltinFS registers additional embedded or virtual filesystems (such as builtin tool manifests from internal/daemon/tools) into the "system" namespace.
func WithRestrictedMode ¶
WithRestrictedMode opens the workspace in restricted mode: local project and workspace .env files are ignored, and workspace/project-scoped custom tools and MCP servers are stripped from the registry so only system/user tools remain available.
type ProviderModelEdit ¶
type ProviderModelEdit struct {
ID string
Name string
Label string
Aliases []string
Context int
Output int
// Catalog seeds a new model with metadata from its provider.
Catalog *warp.ProviderModel
}
ProviderModelEdit is one model entry written into a provider manifest.
type ProviderRecord ¶
type ProviderRecord struct {
Name string
Def *warp.ModelProvider // winning manifest definition
Namespace string // winning manifest namespace
Path string // winning manifest file path ("" for embedded)
Enabled bool // spec.enabled on the winner (true when omitted)
Shadowed bool // winner overrides a lower-tier same-name manifest
InheritedEnabled bool // spec.enabled on the shadowed lower-tier winner
InheritedPath string // file path of the shadowed lower-tier winner ("" when unknown)
Writable bool // winner manifest may be patched in place
Overridable bool // winner lives in the user tier (a workspace shadow can mute it)
Inherited []string // namespaces of lower-priority same-name manifests
}
ProviderRecord is one provider name as the workspace resolves it across tiers: the winning (highest-priority) manifest, whether it is enabled, and whether it shadows or is shadowed by another tier.
type ResourceRecord ¶
type ResourceRecord struct {
Name string
Kind warp.Kind
Def warp.Resource
Namespace string
Path string
Available bool
DisabledBy api.DisabledReason
Writable bool // the owning manifest may be patched in place
}
ResourceRecord is one tool or MCP server as the workspace resolves it: which manifest defines it, whether it is available, and where a toggle would land.
type RuleSnapshot ¶
RuleSnapshot pairs an API Rule presentation with its defining warp.Rule.
type SkillSnapshot ¶
SkillSnapshot pairs an API Skill presentation with its defining warp.Skill.
type ToolPartition ¶
ToolPartition splits an agent's effective tools into eager tools (loaded on the first request with DeferLoading: false) and deferred tools (discoverable via tool_search with DeferLoading: true).
type ToolSnapshot ¶
ToolSnapshot pairs an API Tool presentation with its defining warp.Tool.
type TrustScope ¶
type TrustScope string
TrustScope determines the boundary of a trust decision.
const ( // TrustScopeFolder trusts only the specific folder path. TrustScopeFolder TrustScope = "folder" // TrustScopeParent trusts every subfolder under the parent path. TrustScopeParent TrustScope = "parent" )
type TrustStore ¶
type TrustStore struct {
Schema int `json:"schema"`
Folders []TrustedFolder `json:"folders"`
}
TrustStore represents the persisted trust.json schema in XDG_DATA_HOME.
func LoadTrustStore ¶
func LoadTrustStore() (*TrustStore, error)
LoadTrustStore reads and unmarshals trust.json from XDG_DATA_HOME. If the file does not exist, an empty store with Schema=1 is returned.
type TrustedFolder ¶
type TrustedFolder struct {
Path string `json:"path"`
Scope TrustScope `json:"scope"`
TrustedAt time.Time `json:"trustedAt"`
Fingerprint string `json:"fingerprint,omitempty"`
}
TrustedFolder records a trusted path on disk and its fingerprint metadata.
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
Workspace manages an active TaskSmith workspace, encapsulating its 4-tier resource registry and isolated environment variables.
func Open ¶
Open discovers and loads the workspace for dir, applying the 4-tier resource hierarchy (system < user < workspace < local) and isolated .env layering.
func (*Workspace) AliasAssignments ¶
func (w *Workspace) AliasAssignments() []AliasAssignment
AliasAssignments reports every bare alias declared across the workspace's effective providers, mirroring WARP's cross-provider duplicate detection and WORKSPACE.md overrides (spec.defaultProvider ordering, spec.defaultModels completion, and spec.modelAliases) so the alias editor can show live assignment state.
func (*Workspace) AssignModelAliases ¶
func (w *Workspace) AssignModelAliases(providerName, modelID string, aliases []string, defaultHere bool) error
AssignModelAliases saves the exact alias set the target model should own. Every alias in the set is first stripped from any other model across all writable provider manifests (the atomic move that keeps bare aliases 1-to-1), then written onto the target model. "default" is owned by the manifest's spec.defaultModels.completion rather than the aliases list, so defaultHere routes it there. All touched manifests are validated before any file is written, so a rejected save leaves no partial edit behind.
func (*Workspace) CWD ¶
CWD returns the absolute working directory path this Workspace was opened with.
func (*Workspace) Env ¶
Env returns a defensive copy of the workspace's isolated environment variables. It is the daemon-side view used for provider and MCP credential resolution; agent-spawned subprocesses must use SubprocessEnv instead.
func (*Workspace) FilterPresetAliases ¶
func (w *Workspace) FilterPresetAliases(provider, scope string, spec *warp.ModelProviderSpec, overrides map[string]string) []api.SkippedPresetAlias
func (*Workspace) IsRestricted ¶
IsRestricted reports whether the workspace was opened in restricted mode.
func (*Workspace) IsSynthetic ¶
IsSynthetic reports whether the workspace was inferred without an on-disk WORKSPACE.md.
func (*Workspace) MCP ¶
func (w *Workspace) MCP() MCPService
MCP returns the workspace's attached MCP runtime, or nil when no manager is attached (MCP servers are then discoverable as manifests but not connected).
func (*Workspace) MCPDef ¶
MCPDef resolves the effective warp.MCP definition with the given short or qualified name in this workspace's scope.
func (*Workspace) MCPDefinitions ¶
MCPDefinitions returns every effective MCP definition in scope, satisfying the MCP manager's definition resolver.
func (*Workspace) MCPRecord ¶
func (w *Workspace) MCPRecord(name string) (ResourceRecord, bool)
MCPRecord resolves one MCP server across the workspace listing.
func (*Workspace) Name ¶
Name returns the workspace name declared in WORKSPACE.md, or the base directory name of RootDir when unconfigured/synthetic.
func (*Workspace) PortablePath ¶
PortablePath converts targetPath into a portable representation relative to the workspace root, or prefixed with "~" if within the user's home directory.
func (*Workspace) PrepareReload ¶
PrepareReload loads a fresh snapshot of the workspace without mutating the current instance until the returned commit function is invoked.
func (*Workspace) ProviderRecord ¶
func (w *Workspace) ProviderRecord(name string) (ProviderRecord, bool)
ProviderRecord resolves one provider name across tiers.
func (*Workspace) ProviderRecords ¶
func (w *Workspace) ProviderRecords() []ProviderRecord
ProviderRecords returns every configured provider grouped across tiers, including disabled and shadowed ones the effective listing hides.
func (*Workspace) Reload ¶
Reload re-reads all 4 resource tiers and .env layers from disk into the Workspace.
func (*Workspace) RenderOptions ¶
func (w *Workspace) RenderOptions() warp.MCPRenderOptions
RenderOptions builds the MCP render context for this workspace, supplying the workspace and project definitions commands and endpoints may reference.
func (*Workspace) SetMCPEnabled ¶
SetMCPEnabled makes an MCP server available or unavailable for this workspace. A disabled server never spawns and exposes zero tools, prompts, and resources. The landing rules match Workspace.SetToolEnabled, with spec.policies.mcps.exclude as the workspace-level fallback.
func (*Workspace) SetMCPService ¶
func (w *Workspace) SetMCPService(srv MCPService)
SetMCPService attaches srv as the workspace's MCP runtime, replacing any previously attached service. Passing nil detaches the current service so MCP endpoints report that no MCP runtime is attached.
func (*Workspace) SetProviderEnabled ¶
SetProviderEnabled patches spec.enabled for the named provider.
Disabling a provider that lives outside the workspace tier (typically the user tier) writes a workspace-tier shadow manifest carrying only the disable flag, so the inherited endpoint, auth, aliases, and models stay intact and the mute is scoped to this repository. Re-enabling drops that mute-only shadow when the inherited manifest is already enabled (clean restore), and promotes the inherited definition into a full workspace override when the inherited manifest is itself disabled. A full workspace override is only ever edited in place — never deleted.
func (*Workspace) SetToolEnabled ¶
SetToolEnabled makes a tool available or unavailable for this workspace.
Availability is deterministic from manifests, so the toggle writes wherever that resource's opt-out can live:
- Disabling a tool with a writable manifest patches spec.enabled: false into that manifest, so the opt-out travels with the resource.
- Disabling a built-in (or any tool with no writable manifest) adds the name to WORKSPACE.md spec.policies.tools.exclude, scoping the exclusion to this repository without touching a global or built-in file.
- Enabling clears whichever exclusion exists: the WORKSPACE.md entry first, then the manifest flag when the manifest itself is disabled.
func (*Workspace) SetWorkspaceMCPExcluded ¶
SetWorkspaceMCPExcluded adds or removes name in WORKSPACE.md spec.policies.mcps.exclude.
func (*Workspace) SetWorkspaceToolExcluded ¶
SetWorkspaceToolExcluded adds or removes name in WORKSPACE.md spec.policies.tools.exclude, the workspace-scoped exclusion list that also covers built-in and global tools.
func (*Workspace) SubprocessEnv ¶
SubprocessEnv returns the environment passed to agent-spawned child processes (bash commands and custom tools). It preserves the host shell environment and, in trusted workspaces, project .env layers, while excluding TaskSmith's private user .env (~/.config/tasksmith/.env), configured ModelProvider auth env-expression credentials, and the TASKSMITH_* internal namespace.
func (*Workspace) SyncMCPTools ¶
SyncMCPTools registers the tools discovered on one MCP server with the workspace registry and refreshes the catalog so tool lists, statuses, and token counts reflect discovery. rawTools carries everything the server exposes; the registry registers only those spec.policies allows, and the remainder is recorded as policy-blocked so tool listings can show them as denied rather than omit them. Passing an empty slice clears the server's tools. It satisfies the MCP manager's syncer contract.
func (*Workspace) ToolRecord ¶
func (w *Workspace) ToolRecord(name string) (ResourceRecord, bool)
ToolRecord resolves one tool across the workspace listing.
func (*Workspace) UpdateProviderModels ¶
func (w *Workspace) UpdateProviderModels(name string, models []ProviderModelEdit, defaultModel string, defaultSet bool) error
UpdateProviderModels replaces spec.models (and optionally the completion default) on the manifest owning the named provider. Edits to a model that is already declared are applied onto a deep copy of its existing entry, so capabilities, cost tiers, and dimension limits the editor does not surface survive a model add/remove or default change. Only the completion default is touched by defaultSet, and a completion pointing at a removed model is cleared instead of left dangling.