workspace

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootKind                 artifactstoreSpec.RootKind       = "workspace.root"
	RootDataSchemaID         artifactstoreSpec.SchemaID       = "workspace.root-data.v1"
	AttachmentDataSchemaID   artifactstoreSpec.SchemaID       = "workspace.attachment-data.v1"
	CollectionKind           artifactstoreSpec.CollectionKind = "workspace.collection"
	CollectionDataSchemaID   artifactstoreSpec.SchemaID       = "workspace.collection-data.v1"
	NativeFrontendID         artifactstoreSpec.FrontendID     = "workspace.native"
	CapabilityProfileVersion                                  = "1"
)
View Source
const (
	KindWorkspaceDefinition artifactstoreSpec.ArtifactKind = "workspace.definition"
	KindAgentDefinition     artifactstoreSpec.ArtifactKind = "agent.definition"
	KindSkillDefinition     artifactstoreSpec.ArtifactKind = "skill.definition"
	KindModelDefinition     artifactstoreSpec.ArtifactKind = "model.definition"
	KindMCPServerDefinition artifactstoreSpec.ArtifactKind = "mcp.server.definition"
	KindToolDefinition      artifactstoreSpec.ArtifactKind = "tool.definition"
	KindInstructionDocument artifactstoreSpec.ArtifactKind = "instruction.document"
	KindContextDocument     artifactstoreSpec.ArtifactKind = "context.document"
)
View Source
const (
	RolePrimary         artifactstoreSpec.AttachmentRole = "primary"
	RoleAttachedPackage artifactstoreSpec.AttachmentRole = "attached-package"
	RoleBuiltIn         artifactstoreSpec.AttachmentRole = "built-in"
	RoleAppLibrary      artifactstoreSpec.AttachmentRole = "app-library"
	RoleOverlay         artifactstoreSpec.AttachmentRole = "overlay"
)

Variables

View Source
var (
	ErrInvalidWorkspace               = errors.New("workspace: invalid workspace")
	ErrNotWorkspace                   = errors.New("workspace: root is not a workspace")
	ErrAmbiguousWorkspaceDefinition   = errors.New("workspace: multiple workspace definitions")
	ErrWorkspaceDefinitionUnavailable = errors.New("workspace: workspace definition unavailable")
	ErrProjectionUnavailable          = errors.New("workspace: projector unavailable")
	ErrReferenceUnresolved            = errors.New("workspace: reference unresolved")
)

Functions

func DecodeYAML

func DecodeYAML(ctx context.Context, content []byte) (json.RawMessage, error)

DecodeYAML converts the restricted Workspace YAML profile to canonical JSON. Workspace source files are data documents, not executable YAML. Anchors, aliases, tags, and multiple documents are rejected before YAML decoding.

Types

type ArtifactStore

type ArtifactStore interface {
	RegisterArtifactFrontend(frontend artifactstoreSpec.ArtifactFrontend) error
	RegisterRootKindHook(hook artifactstoreSpec.RootKindHook) error
	RegisterCollectionKindHook(hook artifactstoreSpec.CollectionKindHook) error

	CreateRoot(ctx context.Context, draft artifactstoreSpec.RootDraft) (artifactstoreSpec.ArtifactRoot, error)
	GetRoot(ctx context.Context, rootID artifactstoreSpec.RootID) (artifactstoreSpec.ArtifactRoot, error)
	ListRoots(ctx context.Context, includeSoftDeleted bool) ([]artifactstoreSpec.ArtifactRoot, error)
	DeleteRoot(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		expectedModifiedAt time.Time,
	) (artifactstoreSpec.ArtifactRoot, error)

	CreateSource(ctx context.Context, draft artifactstoreSpec.SourceDraft) (artifactstoreSpec.ArtifactSource, error)
	DeleteSource(
		ctx context.Context,
		sourceID artifactstoreSpec.SourceID,
		expectedModifiedAt time.Time,
	) error
	AttachSource(
		ctx context.Context,
		draft artifactstore.RootSourceAttachmentDraft,
	) (artifactstoreSpec.RootSourceAttachment, error)
	GetRootSourceAttachment(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		sourceID artifactstoreSpec.SourceID,
	) (artifactstoreSpec.RootSourceAttachment, error)
	ListRootSources(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
	) ([]artifactstoreSpec.RootSourceAttachment, error)
	DetachSource(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		sourceID artifactstoreSpec.SourceID,
		expectedModifiedAt time.Time,
	) error

	ScanRoot(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		plan artifactstoreSpec.ScanPlan,
	) (artifactstoreSpec.ScanResult, error)
	GetRootCatalogGeneration(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
	) (artifactstoreSpec.RootCatalogGeneration, error)
	ListCatalogResourcesForRoot(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
	) ([]artifactstoreSpec.CatalogResource, error)
	GetDefinitionByDigest(
		ctx context.Context,
		digest artifactstoreSpec.Digest,
	) (artifactstoreSpec.CanonicalDefinition, error)

	EnsureBaseCollection(
		ctx context.Context,
		draft artifactstoreSpec.CollectionDraft,
	) (artifactstoreSpec.ArtifactCollection, error)
	ListCollections(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		includeSoftDeleted bool,
	) ([]artifactstoreSpec.ArtifactCollection, error)
	ListRecords(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
	) ([]artifactstoreSpec.ArtifactRecord, error)
	GetRecord(
		ctx context.Context,
		recordID artifactstoreSpec.RecordID,
	) (artifactstoreSpec.ArtifactRecord, error)
	SyncRecords(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		policy artifactstoreSpec.RecordSyncPolicy,
	) (artifactstoreSpec.RecordSyncResult, error)
	FindCandidates(
		ctx context.Context,
		rootID artifactstoreSpec.RootID,
		selector artifactstoreSpec.ArtifactSelector,
	) ([]artifactstoreSpec.DependencyCandidate, error)
	BuildDependencyGraph(
		ctx context.Context,
		recordID artifactstoreSpec.RecordID,
	) (artifactstoreSpec.DependencyGraph, error)
}

type AttachSourceRequest

type AttachSourceRequest struct {
	RootID              artifactstoreSpec.RootID
	SourceID            artifactstoreSpec.SourceID
	Role                artifactstoreSpec.AttachmentRole
	Priority            int
	AttachmentData      AttachmentData
	DiscoverImmediately bool
}

AttachSourceRequest attaches an existing Artifact Store source to a Workspace. Source lifecycle remains owned by Artifact Store.

type AttachedPackagePreferences

type AttachedPackagePreferences struct {
	DiscoverRecursively bool `json:"discoverRecursively,omitempty"`
}

type AttachmentData

type AttachmentData struct {
	Recursive     *bool `json:"recursive,omitempty"`
	Authoritative *bool `json:"authoritative,omitempty"`
}

type Catalog

type Catalog struct {
	Workspace  Workspace
	Generation artifactstoreSpec.RootCatalogGeneration
	Resources  []CatalogResource
	Unrecorded []artifactstoreSpec.CatalogResource
}

type CatalogResource

type CatalogResource struct {
	Record         artifactstoreSpec.ArtifactRecord
	Definition     artifactstoreSpec.CanonicalDefinition
	Collection     *artifactstoreSpec.ArtifactCollection
	Occurrence     *artifactstoreSpec.CatalogResource
	CatalogCurrent bool
}

type CollectionData

type CollectionData struct {
	ArtifactKind artifactstoreSpec.ArtifactKind `json:"artifactKind"`
}

type DiscoveryInput

type DiscoveryInput struct {
	Workspace             Workspace
	DefinitionPreferences DiscoveryPreferences
	FrontendIDs           []artifactstoreSpec.FrontendID
}

type DiscoveryPlanner

type DiscoveryPlanner interface {
	BuildBootstrapPlan(ctx context.Context, input DiscoveryInput) (artifactstoreSpec.ScanPlan, error)
	BuildExpandedPlan(ctx context.Context, input DiscoveryInput) (artifactstoreSpec.ScanPlan, error)
}

type DiscoveryPreferences

type DiscoveryPreferences struct {
	AdditionalLocators []artifactstoreSpec.SourceLocator `json:"additionalLocators,omitempty"`
	AdditionalRoots    []DiscoveryRoot                   `json:"additionalRoots,omitempty"`
	IncludeReadme      bool                              `json:"includeReadme,omitempty"`
}

type DiscoveryRoot

type DiscoveryRoot struct {
	Root            artifactstoreSpec.SourceLocator `json:"root"`
	Recursive       bool                            `json:"recursive"`
	IncludePatterns []string                        `json:"includePatterns,omitempty"`
}

type DisplayPreferences

type DisplayPreferences struct {
	DefaultCategory string `json:"defaultCategory,omitempty"`
}

type EmbeddedSourceAttachmentRequest

type EmbeddedSourceAttachmentRequest struct {
	RootID              artifactstoreSpec.RootID
	DisplayName         string
	ProviderKey         string
	RootLocator         artifactstoreSpec.SourceLocator
	Role                artifactstoreSpec.AttachmentRole
	Priority            int
	AttachmentData      AttachmentData
	DiscoverImmediately bool
}

EmbeddedSourceAttachmentRequest creates an app-local embedded filesystem source and attaches it to an existing Workspace.

type EmptyWorkspaceRequest

type EmptyWorkspaceRequest struct {
	DisplayName         string
	Description         string
	TrustReference      string
	Discovery           DiscoveryPreferences
	DiscoverImmediately bool
}

type FilesystemSelectionRequest

type FilesystemSelectionRequest struct {
	DisplayName         string
	Description         string
	RootPath            string
	FollowSymlinks      bool
	ManagedByApp        bool
	TrustReference      string
	Discovery           DiscoveryPreferences
	DiscoverImmediately bool
}

type KindDescriptor

type KindDescriptor struct {
	Kind                  artifactstoreSpec.ArtifactKind
	DefinitionSchemaID    artifactstoreSpec.SchemaID
	CollectionSlug        artifactstoreSpec.CollectionSlug
	CollectionDisplayName string
}

type LoadPlan

type LoadPlan struct {
	RootID      artifactstoreSpec.RootID
	Generation  artifactstoreSpec.RootCatalogGeneration
	Items       []LoadPlanItem
	Diagnostics []artifactstoreSpec.Diagnostic
}

type LoadPlanItem

type LoadPlanItem struct {
	Resource   CatalogResource
	Projection Projection
	Dependency artifactstoreSpec.DependencyGraph
}

type Option

type Option func(*serviceConfig) error

func WithArtifactFrontend

func WithArtifactFrontend(frontend artifactstoreSpec.ArtifactFrontend) Option

func WithDiscoveryPlanner

func WithDiscoveryPlanner(planner DiscoveryPlanner) Option

func WithKindDescriptor

func WithKindDescriptor(descriptor KindDescriptor) Option

func WithResourceProjector

func WithResourceProjector(projector ResourceProjector) Option

func WithYAMLDecoder

func WithYAMLDecoder(decoder YAMLDecoder) Option

type ProjectedDocument

type ProjectedDocument struct {
	RecordID         artifactstoreSpec.RecordID
	DefinitionDigest artifactstoreSpec.Digest
	Kind             artifactstoreSpec.ArtifactKind
	SourceID         artifactstoreSpec.SourceID
	Locator          artifactstoreSpec.SourceLocator
	Name             string
	Markdown         string
}

type ProjectedSkill

type ProjectedSkill struct {
	RecordID         artifactstoreSpec.RecordID
	DefinitionDigest artifactstoreSpec.Digest
	SourceID         artifactstoreSpec.SourceID
	Locator          artifactstoreSpec.SourceLocator
	Name             string
	DisplayName      string
	Description      string
	Insert           string
	Arguments        []ProjectedSkillArgument
	Markdown         string
	Frontmatter      json.RawMessage
}

type ProjectedSkillArgument

type ProjectedSkillArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Default     string `json:"default,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

type ProjectedStructuredDefinition

type ProjectedStructuredDefinition struct {
	RecordID         artifactstoreSpec.RecordID
	DefinitionDigest artifactstoreSpec.Digest
	Kind             artifactstoreSpec.ArtifactKind
	SourceID         artifactstoreSpec.SourceID
	Locator          artifactstoreSpec.SourceLocator
	Name             string
	Definition       json.RawMessage
}

ProjectedStructuredDefinition is the default projection for native Workspace artifact kinds whose external domain adapter has not been installed. The original canonical JSON remains available without coupling Workspace to a legacy persistence model.

type ProjectedWorkspaceDefinition

type ProjectedWorkspaceDefinition struct {
	RecordID   artifactstoreSpec.RecordID
	Discovery  DiscoveryPreferences
	Definition json.RawMessage
}

type Projection

type Projection struct {
	Kind        artifactstoreSpec.ArtifactKind
	RecordID    artifactstoreSpec.RecordID
	Value       any
	Diagnostics []artifactstoreSpec.Diagnostic
}

type ProjectionDiagnosticError

type ProjectionDiagnosticError struct {
	Kind        artifactstoreSpec.ArtifactKind
	Diagnostics []artifactstoreSpec.Diagnostic
}

func (*ProjectionDiagnosticError) Error

func (e *ProjectionDiagnosticError) Error() string

func (*ProjectionDiagnosticError) Unwrap

func (e *ProjectionDiagnosticError) Unwrap() error

type ProjectionInput

type ProjectionInput struct {
	Workspace  Workspace
	Record     artifactstoreSpec.ArtifactRecord
	Definition artifactstoreSpec.CanonicalDefinition
}

type Reference

type Reference struct {
	RecordID *artifactstoreSpec.RecordID
	Selector *artifactstoreSpec.ArtifactSelector
}

type RefreshResult

type RefreshResult struct {
	Workspace   Workspace
	Bootstrap   *artifactstoreSpec.ScanResult
	Published   artifactstoreSpec.ScanResult
	Sync        artifactstoreSpec.RecordSyncResult
	Catalog     Catalog
	Diagnostics []artifactstoreSpec.Diagnostic
}

type ResourceProjector

type ResourceProjector interface {
	Kind() artifactstoreSpec.ArtifactKind
	Project(ctx context.Context, input ProjectionInput) (any, []artifactstoreSpec.Diagnostic)
}

type RootData

type RootData struct {
	Mode                       RootMode                   `json:"mode"`
	PrimarySourceID            artifactstoreSpec.SourceID `json:"primarySourceID,omitempty"`
	RootTrustReference         string                     `json:"rootTrustReference,omitempty"`
	DiscoveryPreferences       DiscoveryPreferences       `json:"discoveryPreferences"`
	AttachedPackagePreferences AttachedPackagePreferences `json:"attachedPackagePreferences"`
	CapabilityProfileVersion   string                     `json:"capabilityProfileVersion"`
	DisplayPreferences         DisplayPreferences         `json:"displayPreferences"`
}

type RootMode

type RootMode string
const (
	RootModeEmpty      RootMode = "empty"
	RootModeFilesystem RootMode = "filesystem"
)

type Service

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

func NewService

func NewService(store ArtifactStore, options ...Option) (*Service, error)

func (*Service) AttachSource

func (s *Service) AttachSource(
	ctx context.Context,
	request AttachSourceRequest,
) (Workspace, error)

AttachSource attaches an existing Artifact Store source to a Workspace. Source configuration and source-kind validation remain Artifact Store responsibilities. Workspace owns only the typed attachment role and data.

func (*Service) Catalog

func (s *Service) Catalog(
	ctx context.Context,
	rootID artifactstoreSpec.RootID,
) (Catalog, error)

func (*Service) ComposeLoadPlan

func (s *Service) ComposeLoadPlan(
	ctx context.Context,
	rootID artifactstoreSpec.RootID,
	recordIDs []artifactstoreSpec.RecordID,
) (LoadPlan, error)

func (*Service) CreateEmptyWorkspace

func (s *Service) CreateEmptyWorkspace(
	ctx context.Context,
	request EmptyWorkspaceRequest,
) (Workspace, error)

func (*Service) DetachSource

func (s *Service) DetachSource(
	ctx context.Context,
	rootID artifactstoreSpec.RootID,
	sourceID artifactstoreSpec.SourceID,
	discoverImmediately bool,
) (Workspace, error)

DetachSource removes only the Workspace root/source relationship. It does not delete the source registration, source catalog, records, or definitions.

func (*Service) GetWorkspace

func (s *Service) GetWorkspace(
	ctx context.Context,
	rootID artifactstoreSpec.RootID,
) (Workspace, error)

func (*Service) ListWorkspaces

func (s *Service) ListWorkspaces(ctx context.Context) ([]Workspace, error)

func (*Service) MountEmbeddedSource

func (s *Service) MountEmbeddedSource(
	ctx context.Context,
	request EmbeddedSourceAttachmentRequest,
) (Workspace, error)

MountEmbeddedSource creates an embedded-fs-directory source and attaches it to a Workspace. The provider must already have been registered while the Artifact Store composition was being built.

func (*Service) Project

func (s *Service) Project(
	ctx context.Context,
	recordID artifactstoreSpec.RecordID,
) (Projection, error)

func (*Service) Refresh

func (s *Service) Refresh(
	ctx context.Context,
	rootID artifactstoreSpec.RootID,
) (RefreshResult, error)

func (*Service) ResolveReference

func (s *Service) ResolveReference(
	ctx context.Context,
	rootID artifactstoreSpec.RootID,
	reference Reference,
) (CatalogResource, error)

func (*Service) SelectFilesystemRoot

func (s *Service) SelectFilesystemRoot(
	ctx context.Context,
	request FilesystemSelectionRequest,
) (Workspace, error)

type Workspace

type Workspace struct {
	Root        artifactstoreSpec.ArtifactRoot
	Data        RootData
	Attachments []artifactstoreSpec.RootSourceAttachment
}

type YAMLDecoder

type YAMLDecoder func(ctx context.Context, content []byte) (json.RawMessage, error)

Jump to

Keyboard shortcuts

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