dreadnode.storage
API reference for the dreadnode.storage module.
AzureBlobCredentials
Section titled “AzureBlobCredentials”AzureBlobCredentials( account_name: str, account_key: str | None = None, sas_token: str | None = None, connection_string: str | None = None, tenant_id: str | None = None, client_id: str | None = None, client_secret: str | None = None, use_managed_identity: bool = False,)Azure Blob Storage / ADLS Gen2 credentials.
Supports multiple authentication methods:
- Connection string
- Account key
- SAS token
- Service principal (client credentials)
- Managed identity (when running on Azure)
account_key
Section titled “account_key”account_key: str | None = NoneStorage account access key.
account_name
Section titled “account_name”account_name: strAzure storage account name.
client_id
Section titled “client_id”client_id: str | None = NoneAzure AD client/application ID.
client_secret
Section titled “client_secret”client_secret: str | None = NoneAzure AD client secret.
connection_string
Section titled “connection_string”connection_string: str | None = NoneFull connection string (overrides other auth).
sas_token
Section titled “sas_token”sas_token: str | None = NoneShared Access Signature token.
tenant_id
Section titled “tenant_id”tenant_id: str | None = NoneAzure AD tenant ID for service principal auth.
use_managed_identity
Section titled “use_managed_identity”use_managed_identity: bool = FalseUse Azure Managed Identity for auth.
to_storage_options
Section titled “to_storage_options”to_storage_options() -> dict[str, Any]Convert to adlfs storage options.
GCSCredentials
Section titled “GCSCredentials”GCSCredentials( project: str | None = None, token: str | None = None, access: str = "full_control", use_anonymous: bool = False,)Google Cloud Storage credentials.
Supports multiple authentication methods:
- Service account JSON key file
- Service account JSON key content
- Application Default Credentials (ADC)
- Anonymous access (for public buckets)
access
Section titled “access”access: str = 'full_control'Access level: read_only, read_write, full_control.
project
Section titled “project”project: str | None = NoneGCP project ID.
token: str | None = NonePath to service account JSON key file, or the JSON content itself.
use_anonymous
Section titled “use_anonymous”use_anonymous: bool = FalseUse anonymous access (public buckets only).
to_storage_options
Section titled “to_storage_options”to_storage_options() -> dict[str, Any]Convert to gcsfs storage options.
MinioCredentials
Section titled “MinioCredentials”MinioCredentials( access_key_id: str, secret_access_key: str, session_token: str | None = None, endpoint_url: str | None = None, region: str | None = None,)MinIO credentials.
S3Credentials
Section titled “S3Credentials”S3Credentials( access_key_id: str, secret_access_key: str, session_token: str | None = None, endpoint_url: str | None = None, region: str | None = None,)AWS S3 / S3-compatible (R2, MinIO) credentials.
SessionStore
Section titled “SessionStore”SessionStore(path: Path)SQLite-backed session metadata and message index with FTS5 search.
first_user_message
Section titled “first_user_message”first_user_message( session_id: str, *, max_len: int = 200) -> str | NoneReturn the content of the first user message in a session, truncated.
first_user_messages
Section titled “first_user_messages”first_user_messages( session_ids: list[str], *, max_len: int = 200) -> dict[str, str]Batch-fetch first user message for multiple sessions.
persist_session
Section titled “persist_session”persist_session( *, session_id: str, model: str, project: str | None, capability: str | None, agent: str | None, title: str | None, created_at: datetime, updated_at: datetime | None = None, message_count: int = 0, trajectory: dict[str, Any] | None = None, messages: Sequence[Message] | None = None,) -> NoneAtomically persist session metadata and messages in one transaction.
Storage
Section titled “Storage”Storage( profile: Profile | None = None, cache: Path | None = None, api: ApiClient | None = None, provider: StorageProvider | None = None, *, default_project: str | None = None,)Storage manager for local and remote storage.
Directory structure
~/.dreadnode/ packages/ datasets/ agents/ models/ tools/ environments/ capabilities/ / capability.yaml cas/ sha256/ ab/cd/… artifacts/ projects/ / / spans.jsonl metrics.jsonl sessions/ sessions.sqlite3 / chat_.json runtime_.json spans_.jsonl
When running in a sandbox, ~/.dreadnode is mounted via s3fs to the user’s workspace storage, with the S3 prefix already scoped to {org_id}/workspaces/{workspace_id}.
Create storage manager.
Parameters:
profile(Profile | None, default:None) –Authenticated profile for RBAC context.cache(Path | None, default:None) –Root cache directory. Defaults to ~/.dreadnode.api(ApiClient | None, default:None) –API client for remote operations (blob credentials + registry uploads).provider(StorageProvider | None, default:None) –Storage provider for remote operations (s3, r2, minio).default_project(str | None, default:None) –Default project key.
api: ApiClient | NoneGet the API client.
artifacts_path
Section titled “artifacts_path”artifacts_path: PathPath to artifacts CAS.
can_sync
Section titled “can_sync”can_sync: boolWhether remote sync is possible (has API client and profile).
capabilities_path
Section titled “capabilities_path”capabilities_path: PathPath to capabilities directory.
cas_path
Section titled “cas_path”cas_path: PathPath to CAS directory.
local_capability_state_path
Section titled “local_capability_state_path”local_capability_state_path: PathPath to persisted local capability state.
oci_registry_url
Section titled “oci_registry_url”oci_registry_url: strGet the OCI Distribution v2 registry URL.
packages_path
Section titled “packages_path”packages_path: PathPath to packages directory.
profile
Section titled “profile”profile: Profile | NoneGet the current profile.
project_key
Section titled “project_key”project_key: strGet the project key.
project_path
Section titled “project_path”project_path: PathPath to current project directory.
projects_path
Section titled “projects_path”projects_path: PathPath to projects directory.
remote_bucket
Section titled “remote_bucket”remote_bucket: strGet the remote storage bucket from credentials.
remote_prefix
Section titled “remote_prefix”remote_prefix: strGet the remote storage prefix from credentials.
session_db_path
Section titled “session_db_path”session_db_path: PathPath to the local SQLite session index.
session_store
Section titled “session_store”session_store: SessionStoreLazy SQLite-backed session metadata and message store.
sessions_path
Section titled “sessions_path”sessions_path: PathPath to sessions directory.
workspace_capabilities_path
Section titled “workspace_capabilities_path”workspace_capabilities_path: PathPath to workspace capability cache directory (CAP-LOAD-007).
artifact_blob_path
Section titled “artifact_blob_path”artifact_blob_path(oid: str) -> PathPath to artifact blob in workspace CAS.
blob_exists
Section titled “blob_exists”blob_exists(oid: str) -> boolCheck if blob exists in local CAS.
blob_path
Section titled “blob_path”blob_path(oid: str) -> PathPath to blob in CAS.
download_blob
Section titled “download_blob”download_blob(oid: str) -> PathDownload blob from remote to local CAS.
download_blobs
Section titled “download_blobs”download_blobs( oids: list[str], *, skip_existing: bool = True) -> tuple[int, int]Download multiple blobs from remote storage.
Parameters:
oids(list[str]) –Object IDs to download.skip_existing(bool, default:True) –Skip blobs that already exist locally.
Returns:
tuple[int, int]–Tuple of (downloaded_count, skipped_count).
get_artifact
Section titled “get_artifact”get_artifact(oid: str) -> PathGet artifact from workspace CAS, downloading if needed.
get_blob
Section titled “get_blob”get_blob(oid: str) -> PathGet blob from local CAS.
get_manifest
Section titled “get_manifest”get_manifest( package_type: PackageType, name: str, version: str) -> strGet manifest.json content.
hash_files
Section titled “hash_files”hash_files( paths: list[Path], algo: str = "sha256") -> dict[Path, str]Compute hashes for multiple files.
Parameters:
paths(list[Path]) –Files to hash.algo(str, default:'sha256') –Hash algorithm.
Returns:
dict[Path, str]–Mapping of path to hash.
latest_version
Section titled “latest_version”latest_version( package_type: PackageType, name: str) -> str | NoneGet latest version.
list_local_runs
Section titled “list_local_runs”list_local_runs() -> list[str]List locally cached run IDs for the current project.
list_versions
Section titled “list_versions”list_versions( package_type: PackageType, name: str) -> list[str]List available versions.
manifest_exists
Section titled “manifest_exists”manifest_exists( package_type: PackageType, name: str, version: str) -> boolCheck if manifest exists.
manifest_path
Section titled “manifest_path”manifest_path( package_type: PackageType, name: str, version: str) -> PathPath to manifest.json.
oci_client
Section titled “oci_client”oci_client() -> OCIRegistryClientCreate an OCI registry client for push/pull operations.
package_path
Section titled “package_path”package_path( package_type: PackageType, name: str, version: str | None = None,) -> PathPath to package directory.
Returns: ~/.dreadnode/packages///[version/]
remote_artifact_path
Section titled “remote_artifact_path”remote_artifact_path(oid: str) -> strRemote path for artifact blob.
remote_blob_exists
Section titled “remote_blob_exists”remote_blob_exists(oid: str) -> boolCheck if blob exists in remote storage.
remote_blob_path
Section titled “remote_blob_path”remote_blob_path(oid: str) -> strRemote path for blob (includes bucket for s3fs).
resolve
Section titled “resolve”resolve( uri: str, **storage_options: Any) -> tuple[AbstractFileSystem, str]Resolve URI to filesystem and path.
run_path
Section titled “run_path”run_path(run_id: str | UUID) -> PathPath to run directory for trace data.
session_chat_path
Section titled “session_chat_path”session_chat_path( session_id: str | UUID, ext: str = "json") -> PathPath to a session chat file.
Parameters:
session_id(str | UUID) –The session identifier.ext(str, default:'json') –File extension without the leading dot.
Returns:
Path–Full path to the session chat file.
session_path
Section titled “session_path”session_path(session_id: str | UUID) -> PathPath to a session directory.
session_runtime_path
Section titled “session_runtime_path”session_runtime_path( session_id: str | UUID, ext: str = "json") -> PathPath to a session runtime manifest file.
Parameters:
session_id(str | UUID) –The session identifier.ext(str, default:'json') –File extension without the leading dot.
Returns:
Path–Full path to the session runtime manifest file.
session_spans_path
Section titled “session_spans_path”session_spans_path( session_id: str | UUID, ext: str = "jsonl") -> PathPath to a session-scoped tracing file.
store_artifact
Section titled “store_artifact”store_artifact(source: Path, *, upload: bool = True) -> strStore artifact in workspace CAS and optionally upload to remote.
Parameters:
source(Path) –Path to the file to store.upload(bool, default:True) –Whether to upload to remote storage immediately.
Returns:
str–The oid (sha256:) of the stored artifact.
store_blob
Section titled “store_blob”store_blob(oid: str, source: Path) -> PathStore blob in local CAS.
store_manifest
Section titled “store_manifest”store_manifest( package_type: PackageType, name: str, version: str, content: str,) -> PathStore manifest.json.
trace_path
Section titled “trace_path”trace_path( run_id: str | UUID, filename: str = "spans.jsonl") -> PathPath to trace file within a run directory.
Parameters:
run_id(str | UUID) –The run identifier.filename(str, default:'spans.jsonl') –Full filename with extension (e.g., ‘spans.jsonl’, ‘spans.parquet’).
Returns:
Path–Full path to the trace file.
upload_artifact
Section titled “upload_artifact”upload_artifact(oid: str) -> NoneUpload artifact from workspace CAS to remote storage.
upload_blob
Section titled “upload_blob”upload_blob(oid: str) -> NoneUpload blob from local CAS to remote.
upload_blobs
Section titled “upload_blobs”upload_blobs( files: dict[Path, str], *, skip_existing: bool = True) -> tuple[int, int]Upload multiple blobs to remote storage.
Parameters:
files(dict[Path, str]) –Mapping of local path to oid.skip_existing(bool, default:True) –Skip blobs that already exist remotely.
Returns:
tuple[int, int]–Tuple of (uploaded_count, skipped_count).
from_provider
Section titled “from_provider”from_provider( provider: StorageProvider, credentials: dict[str, Any] | None = None,) -> AbstractFileSystemCreate filesystem from provider and credentials.
Parameters:
provider(StorageProvider) –Storage provider type.credentials(dict[str, Any] | None, default:None) –Provider-specific credentials dict.
Returns:
AbstractFileSystem–Configured filesystem instance.
Raises:
ValueError–If provider is unsupported or credentials missing.ImportError–If required package not installed.