Skip to main content
Version: 0.4.x(Latest)

Introduction​

Source plugins read visible views of host-managed files through services.Files(). Dynamic plugins declare service: files in plugin.yaml and use BatchGetFiles and EnsureFilesVisible. Trusted source plugins that need to delete host files use services.Admin().Files().DeleteFiles.

The Files capability provides read-only access to the host file management system. Plugins cannot upload files or modify file metadata through this capability.

Capability Phase: Runtime

Supported Plugin Types: Source plugins, Dynamic plugins

Capability Design​

Host File Management Model​

Host file management is centered on the sys_file table, managing the full lifecycle of user-uploaded files:

FieldDescription
idFile primary key
tenant_idTenant ownership
nameStored filename
originalOriginal filename
suffixFile extension
sceneBusiness scene identifier
sizeFile size
hashSHA-256 hash for deduplication
urlAccess path
pathPhysical storage path
engineStorage engine identifier
created_byUploader

The upload process automatically computes the SHA-256 hash, enabling file deduplication within the same tenant. Files with identical hashes reuse physical storage, with only a new metadata record created.

Plugin-Visible View​

Plugins access file information through FileProjection, without exposing physical storage paths, hash values, or underlying storage backends:

FieldDescription
IDFile identifier
NameDisplay filename
MimeTypeMedia type
SizeBytesFile size
BusinessSceneBusiness scene

Relationship with Other Resource Capabilities​

CapabilityPurpose
Files()Reads host file management views, such as user-uploaded files and business attachments
Storage()Plugin-owned object read/write, such as export results and temporary artifacts
Manifest()Reads read-only manifest/ resources published with the plugin artifact
AI AssetRefReferences protected input or output assets in AI capabilities

Interface Definitions​

Source Plugin Interface​

EntryMethodDescription
Files()BatchGetFilesBatch reads visible file views
Files()EnsureFilesVisibleValidates that the target file set is visible to the current calling context
Admin().Files()DeleteFilesDeletes visible files, with the host performing scene and target validation

Dynamic Plugin Interface​

Dynamic plugins can access two types of services:

files service -- Host file views:

Dynamic MethodCapability ConstantDescription
files.batch_gethost:filesBatch reads visible file views
files.visible.ensurehost:filesValidates file visibility

storage service -- Plugin-scoped object storage:

Dynamic MethodDescription
storage.putWrite object
storage.getRead object
storage.deleteDelete object
storage.listList objects
storage.statQuery object metadata

Usage​

Source Plugin Usage​

Source plugins read host-managed file views through services.Files():

// Batch read file views
result, err := services.Files().BatchGetFiles(ctx, capabilityCtx, fileIDs)

// Validate file visibility
err := services.Files().EnsureFilesVisible(ctx, capabilityCtx, fileIDs)

Trusted source plugin deleting files:

err := services.Admin().Files().DeleteFiles(ctx, capabilityCtx, fileIDs)

Dynamic Plugin Usage​

Dynamic plugins declare the files service in plugin.yaml:

hostServices:
- service: files
methods:
- batch_get
- visible.ensure

Design Constraints​

  • Read-only views. Plugins cannot upload or modify files through the Files capability; they can only read and validate.
  • No physical paths exposed. FileProjection does not contain storage paths, hash values, or access URLs.
  • Deletion is a governance command. Delete operations must go through Admin().Files(), with the host performing scene and target validation.
  • Visibility is controlled by the host. Whether a file is visible to the current plugin is determined by the host based on tenant and data scope.