Documentation
¶
Index ¶
- Constants
- func RuntimeMCPName(pluginName, componentName string) string
- func ValidateName(name string) error
- func ValidateVersion(version string) error
- type ActivationTransaction
- type ChangeResult
- type ComponentIndex
- type Error
- type Installed
- type MCPComponent
- type MCPReview
- type Manager
- func (m *Manager) AbortActivation(ctx context.Context, name string) error
- func (m *Manager) Acquire(ctx context.Context, name string) (Installed, func(), error)
- func (m *Manager) AcquireActivationCandidate(name string) (Installed, func(), error)
- func (m *Manager) CleanupObsoleteVersions(name string)
- func (m *Manager) EnsureDataDir(name string) (string, error)
- func (m *Manager) FinalizeActivation(name string) error
- func (m *Manager) Inspect(name string) (Installed, error)
- func (m *Manager) InstallReviewedSource(ctx context.Context, source string, enabled bool, reviewToken string) (ChangeResult, error)
- func (m *Manager) List() ([]Installed, error)
- func (m *Manager) Remove(ctx context.Context, name, dataPolicy string) (ChangeResult, error)
- func (m *Manager) RemoveWithLifecycle(ctx context.Context, name, dataPolicy string, lifecycle RemoveLifecycle) (ChangeResult, error)
- func (m *Manager) SetEnabled(ctx context.Context, name string, enabled bool) (ChangeResult, error)
- func (m *Manager) SetEnabledWithLifecycle(ctx context.Context, name string, enabled bool, reconcile func(State) error) (ChangeResult, error)
- func (m *Manager) Store() *Store
- func (m *Manager) UpdateReviewedSource(ctx context.Context, source string, reviewToken string, ...) (ChangeResult, error)
- func (m *Manager) Validate(source string) Review
- func (m *Manager) ValidateSource(_ context.Context, source string) Review
- type Manifest
- type Package
- type Provenance
- type PurgeOwnership
- type RemoveLifecycle
- type Review
- type SkillComponent
- type State
- type Store
- func (s *Store) AcquireBinding(ctx context.Context, name string) (func(), error)
- func (s *Store) AcquireVersionRead(name, version string) (func(), error)
- func (s *Store) AcquireWrite(ctx context.Context, name string) (func(), error)
- func (s *Store) CreateRuntimeSnapshot(name, version, packageRoot string) (string, error)
- func (s *Store) DataPath(name string) (string, error)
- func (s *Store) Delete(name string) error
- func (s *Store) DeleteActivationTransaction(name string) error
- func (s *Store) DeleteRemovalOwnership(name string) error
- func (s *Store) EnsureDataDir(name string) (string, error)
- func (s *Store) EnsurePackageParent(name string) (string, error)
- func (s *Store) Home() string
- func (s *Store) List() ([]State, error)
- func (s *Store) ListActivationTransactions() ([]ActivationTransaction, error)
- func (s *Store) Load(name string) (State, error)
- func (s *Store) LoadActivationTransaction(name string) (ActivationTransaction, error)
- func (s *Store) LoadRemovalOwnership(name string) (PurgeOwnership, error)
- func (s *Store) LoadRemovalRecord(name string) (removalRecord, error)
- func (s *Store) PackagePath(name, version string) (string, error)
- func (s *Store) RemoveData(name string) error
- func (s *Store) RemoveVersionIfIdle(name, version string) (bool, error)
- func (s *Store) Save(state State) error
- func (s *Store) SaveActivationTransaction(transaction ActivationTransaction) error
- func (s *Store) SaveRemovalOwnership(ownership PurgeOwnership) error
- func (s *Store) SaveRemovalRecord(record removalRecord) error
- func (s *Store) StatePath(name string) (string, error)
- func (s *Store) TempPath(prefix string) (string, error)
- func (s *Store) UpdateBackupPath(name string) (string, error)
- func (s *Store) UpdateCandidatePath(name, ownerID string) (string, error)
- func (s *Store) WaitVersionIdle(ctx context.Context, name, version string) error
Constants ¶
const ( StateSchemaVersion = 3 VersionLocal = "local" )
const ActivationTransactionSchemaVersion = 3
Variables ¶
This section is empty.
Functions ¶
func RuntimeMCPName ¶
func ValidateName ¶
func ValidateVersion ¶
Types ¶
type ActivationTransaction ¶
type ActivationTransaction struct {
SchemaVersion int `json:"schema_version"`
Name string `json:"name"`
OwnerID string `json:"owner_id"`
Kind string `json:"kind"`
Phase string `json:"phase"`
Previous *State `json:"previous,omitempty"`
Candidate State `json:"candidate"`
LocalReplacement bool `json:"local_replacement,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type ChangeResult ¶
type ComponentIndex ¶
type ComponentIndex struct {
Skills []SkillComponent `json:"skills,omitempty"`
MCP []MCPComponent `json:"mcp,omitempty"`
}
type MCPComponent ¶
type MCPComponent struct {
Name string `json:"name"`
Description string `json:"description"`
Transport string `json:"transport"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
CWD string `json:"cwd,omitempty"`
Environment map[string]string `json:"env,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
HeaderEnv map[string]string `json:"header_env,omitempty"`
EnvBindings map[string]string `json:"env_bindings,omitempty"`
RequiredEnv []string `json:"required_env,omitempty"`
TimeoutMS int `json:"timeout_ms,omitempty"`
RuntimeName string `json:"runtime_name"`
StorageKey string `json:"storage_key"`
RelativeSource string `json:"source"`
}
type MCPReview ¶
type MCPReview struct {
Name string `json:"name"`
Description string `json:"description"`
Transport string `json:"transport"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
CWD string `json:"cwd,omitempty"`
EnvironmentNames []string `json:"environment_names,omitempty"`
HeaderNames []string `json:"header_names,omitempty"`
RuntimeName string `json:"runtime_name"`
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AbortActivation ¶
AbortActivation 回滚当前 Manager 拥有的 live activation。若当前进程没有 owner,则在取得 writer lease 后恢复持久化的 pending transaction。
func (*Manager) AcquireActivationCandidate ¶
AcquireActivationCandidate 是唯一允许读取 pending candidate 的入口。 普通 Acquire 会被 activation writer lease 阻塞,因此正式 resolver 在 Finalize 前 update 只能看到 Previous,首次 install 则仍表现为未安装。
func (*Manager) CleanupObsoleteVersions ¶
CleanupObsoleteVersions removes package versions that are no longer selected.
func (*Manager) FinalizeActivation ¶
FinalizeActivation 在 runtime activation 成功后才发布 candidate。整个过程 仍持有跨进程 writer lease,并对 journal owner 与正式 state 做 CAS 校验; install 要求正式 state 仍不存在,update 则要求它仍等于 Previous。
func (*Manager) InstallReviewedSource ¶
func (m *Manager) InstallReviewedSource(ctx context.Context, source string, enabled bool, reviewToken string) (ChangeResult, error)
InstallReviewedSource stages the source once, verifies that the exact staged candidate matches a prior security review, and commits that same snapshot.
func (*Manager) RemoveWithLifecycle ¶
func (m *Manager) RemoveWithLifecycle(ctx context.Context, name, dataPolicy string, lifecycle RemoveLifecycle) (ChangeResult, error)
RemoveWithLifecycle 把正式 state、package ownership、Plugin data 和外部 owned state 的清理放在同一个 Plugin writer lease 中。purge 先持久化 tombstone 再进入 不可逆清理,因此失败后只允许向前重试,不会重新暴露为 installed。
func (*Manager) SetEnabled ¶
func (*Manager) SetEnabledWithLifecycle ¶
func (m *Manager) SetEnabledWithLifecycle(ctx context.Context, name string, enabled bool, reconcile func(State) error) (ChangeResult, error)
SetEnabledWithLifecycle keeps runtime reconciliation and formal state mutation under the same Plugin writer lease. The callback receives the target state; if state persistence fails after runtime switched, it is called again with the previous state before the lease is released.
func (*Manager) UpdateReviewedSource ¶
func (m *Manager) UpdateReviewedSource(ctx context.Context, source string, reviewToken string, beforeSwitch func(State) error) (ChangeResult, error)
UpdateReviewedSource verifies and commits one staged Portable Plugin snapshot. beforeSwitch runs only after package/version checks pass, so the runtime layer can stop the current owned MCP immediately before the atomic switch.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Provenance *Provenance `json:"provenance,omitempty"`
}
type Package ¶
type Package struct {
Root string
Manifest Manifest
PackageDigest string
Components ComponentIndex
Warnings []string
Executables []string
Format string
}
func LoadPackage ¶
type Provenance ¶
type Provenance struct {
Origin string `json:"origin"`
Ref string `json:"ref,omitempty"`
Revision string `json:"revision,omitempty"`
Subdir string `json:"subdir,omitempty"`
}
Provenance records where an imported Portable Plugin originally came from. It is part of plugin.json, so it is covered by the package digest and review token.
type PurgeOwnership ¶
type PurgeOwnership struct {
Name string `json:"name"`
MCPStorageKeys []string `json:"mcp_storage_keys,omitempty"`
}
PurgeOwnership 是 remove keep 后仍需保留的最小清理元数据。 Plugin data 与 Plugin Skill data/env 都可由 Name 确定;只有 MCP storage key 可能因为长名称哈希而无法从 Plugin 名反推,因此需要持久化。
type RemoveLifecycle ¶
type Review ¶
type Review struct {
Valid bool `json:"valid"`
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
PackageDigest string `json:"package_digest,omitempty"`
ReviewToken string `json:"review_token,omitempty"`
Provenance *Provenance `json:"provenance,omitempty"`
Skills []SkillComponent `json:"skills"`
MCP []MCPReview `json:"mcp"`
Warnings []string `json:"warnings"`
Executables []string `json:"executables"`
Issues []string `json:"issues"`
Format string `json:"format"`
}
type SkillComponent ¶
type State ¶
type State struct {
SchemaVersion int `json:"schema_version"`
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
PackageDigest string `json:"package_digest"`
Provenance *Provenance `json:"provenance,omitempty"`
Enabled bool `json:"enabled"`
InstalledAt time.Time `json:"installed_at"`
Components ComponentIndex `json:"components"`
MCPStorageKeys []string `json:"mcp_storage_keys,omitempty"`
Format string `json:"format"`
Warnings []string `json:"warnings,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AcquireBinding ¶
AcquireBinding protects only the brief state->version binding window. Long-running Plugin work must use AcquireVersionRead after resolving state.
func (*Store) AcquireVersionRead ¶
func (*Store) AcquireWrite ¶
func (*Store) CreateRuntimeSnapshot ¶
CreateRuntimeSnapshot copies one already-installed Plugin package into a writable runtime generation. The reviewed package itself remains immutable, so runtime-generated files do not invalidate the persisted package digest.
func (*Store) DeleteActivationTransaction ¶
func (*Store) DeleteRemovalOwnership ¶
func (*Store) EnsurePackageParent ¶
func (*Store) ListActivationTransactions ¶
func (s *Store) ListActivationTransactions() ([]ActivationTransaction, error)
func (*Store) LoadActivationTransaction ¶
func (s *Store) LoadActivationTransaction(name string) (ActivationTransaction, error)
func (*Store) LoadRemovalOwnership ¶
func (s *Store) LoadRemovalOwnership(name string) (PurgeOwnership, error)
func (*Store) LoadRemovalRecord ¶
func (*Store) RemoveData ¶
func (*Store) RemoveVersionIfIdle ¶
func (*Store) SaveActivationTransaction ¶
func (s *Store) SaveActivationTransaction(transaction ActivationTransaction) error
func (*Store) SaveRemovalOwnership ¶
func (s *Store) SaveRemovalOwnership(ownership PurgeOwnership) error