workspace

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTenantDir = "_default"

DefaultTenantDir is the local root used when a request carries no session id, and therefore no tenant. Timers, cron tasks and direct library calls land here rather than in some other tenant's directory.

Variables

This section is empty.

Functions

func New

func New(cfg Config) (cw.Service, error)

New registers workspace/default: Dual-root workspace: a global home and a local .agentkit directory under the project.

Best practices:

  • Prefix a path with global: or local: to pin it regardless of scope.

func NewTenant

func NewTenant(cfg TenantConfig) (cw.Service, error)

NewTenant registers workspace/tenant: Per-tenant local root with one shared global root, keyed by the tenant behind the current session.

Every path in the system is resolved through workspace, so scoping the local root per tenant is what actually separates two Slack channels: sessions, the filesystem tool, shell, skills and AGENTS.md all follow without changes.

Best practices:

  • Leave a tenant out of tenants to get LocalBase/<key>; list it only to pin an existing project directory.
  • Keep genuinely shared assets under global: — skills, agent definitions, mcp.json — and everything the agent may write under an unprefixed path.
  • Raise runner.maxConcurrentTurns once roots are separated: the reason it defaults to 1 is that turns share a workdir, which stops being true here.
  • Unlike workspace/default, ".." never leaves a root. A per-tenant root sits beside its siblings, so the parent-directory exemption would be a way out of the tenant. Point a tenant's root at the project directory itself instead of relying on "..".

Types

type Config

type Config struct {
	// Root is single-root shorthand, kept for older configs; prefer Global and Local.
	Root string `json:"root"` // deprecated: alias for global
	// Global is global root, conventionally ~/.agentkit.
	Global string `json:"global"`
	// Local is local root, default .agentkit under cwd.
	Local string `json:"local"`
	// Scope is which root an unprefixed path resolves against: global or local.
	Scope string `json:"scope"` // global | local
}

type Service

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

func (*Service) Resolve

func (s *Service) Resolve(_ context.Context, rel string) (string, error)

type TenantConfig

type TenantConfig struct {
	// Global is the root shared by every tenant, reached with the global: prefix.
	// Conventionally ~/.agentkit. Shared skills, agent definitions and mcp.json
	// live here; nothing under it is tenant-scoped.
	Global string `json:"global"`
	// LocalBase is the parent directory of per-tenant roots. A tenant with no
	// entry in Tenants gets LocalBase/<sanitized tenant key>, so adding a Slack
	// channel needs no configuration at all: it is isolated by default.
	LocalBase string `json:"localBase"`
	// Scope is which root an unprefixed path resolves against: global or local.
	// Defaults to local, because the point of this plugin is that unqualified
	// paths land in the caller's own tenant.
	Scope string `json:"scope"`
	// Tenants pins an explicit root for specific tenant keys, e.g.
	// "slack:C123ABC": {root: ~/work/project-a}. Keys are tenant keys as derived
	// by cap/tenant.Key, not session ids: every thread and every user in a Slack
	// channel shares the channel's entry.
	Tenants map[string]TenantEntry `json:"tenants,omitempty"`
	// OmitPlatformPrefix drops the platform segment from local directory names.
	// slack:C123 -> C123 instead of slack_C123; chat-api:slack_x -> slack_x.
	// Tenant map keys are unchanged; only the default localBase/<dir> layout moves.
	OmitPlatformPrefix bool `json:"omitPlatformPrefix,omitempty"`
}

TenantConfig configures workspace/tenant.

type TenantEntry

type TenantEntry struct {
	// Root is an absolute path or ~/ path used verbatim as this tenant's local root.
	Root string `json:"root"`
}

TenantEntry is one tenant's pinned workspace root.

type TenantService

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

TenantService resolves paths against a shared global root and a per-tenant local root.

func (*TenantService) LocalBaseDir added in v0.1.10

func (s *TenantService) LocalBaseDir() string

LocalBaseDir reports the parent directory of per-tenant local roots.

func (*TenantService) Resolve

func (s *TenantService) Resolve(ctx context.Context, rel string) (string, error)

func (*TenantService) TenantRoot

func (s *TenantService) TenantRoot(ctx context.Context) string

TenantRoot reports the local root the current context resolves against.

Jump to

Keyboard shortcuts

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