Extensions in Spacedrive are built with Rust macros that generate the integration code for you. Define your data models, jobs, and agents using attributes. The SDK handles sync, permissions, and sandboxing automatically. This page covers the five building blocks: extensions, models, jobs, agents, and actions. Each concept maps to a macro that generates the boilerplate.Documentation Index
Fetch the complete documentation index at: https://v2.spacedrive.com/llms.txt
Use this file to discover all available pages before exploring further.
1. Extension Definition (#[extension])
The #[extension] attribute is the entry point for your extension. It defines metadata, dependencies, and the permissions your extension requires.
- Permissions: Your extension requests permissions, and the user grants them, often scoped to specific parts of their library for privacy.
- Config: You can define a configuration struct that allows users to customize your extension’s behavior.
2. Models (#[model])
Models are the heart of your extension’s data structure. The #[model] attribute allows you to define custom data models that are stored in real database tables, not as JSON blobs. This enables powerful querying, indexing, and relationships.
- Real Tables: Your models become actual SQL tables, prefixed with your extension’s ID (e.g.,
ext_photos_person). - Relationships: You can define foreign key relationships to core Spacedrive objects or other models in your extension.
- Tagging: By including a
#[metadata]field, your models can be tagged and organized just like regular files.
3. Jobs and Tasks (#[job], #[task])
Jobs and tasks are used to perform long-running or background operations, such as analyzing files or processing data. They are durable, resumable, and can be run in parallel.
- Durability: Jobs are persisted and can survive application restarts.
- Triggers: Jobs can be initiated by users, events, or other system triggers.
4. AI Agents (#[agent])
Agents provide a way to create autonomous logic within your extension. They can observe events, reason about data, and act by dispatching jobs or modifying data.
- Observe-Orient-Act: Agents follow a classic AI loop to respond to changes in the system.
- Memory: Agents can have their own memory to store knowledge and plans.
5. Actions (#[action])
Actions are user-invokable operations that can be previewed before execution. This ensures that users always know what changes an extension is about to make.
- Safety: The preview-commit-verify flow ensures that all operations are safe and predictable.
- Universal: Actions work seamlessly across local, cloud, and content-addressed files.
