SDK
Python
The Driftstone Python SDK wraps repositories, uploads, downloads, branches, copies, sync, comparisons, and agent extensions.
pip install driftstone
from driftstone import Driftstone
client = Driftstone(api_key="dk-...")
repo = client.repos.create(
"hello-world",
)
upload = client.repos.create_upload(
"hello-world",
storage_dir="ver-1234abcd",
branch="main",
message="Update README copy",
files=[{"name": "README.md", "hash": "64-character-sha256-or-client-hash"}],
)
client.repos.complete_upload("hello-world", upload.upload_id)
branch = client.repos.create_branch(
"hello-world",
"feature-readme",
storage_dir="state-123",
transforms={"README.md": "# Example Repo\nUpdated content.\n"},
)
empty_branch = client.repos.create_branch(
"hello-world",
"empty-feature",
derive_from_main=False,
)
branch_upload = client.repos.create_upload(
"hello-world",
storage_dir="state-456",
branch=branch.name,
message="Update feature README",
files=[{"name": "README.md", "hash": "64-character-sha256-or-client-hash"}],
)
client.repos.complete_upload("hello-world", branch_upload.upload_id)
history = client.repos.list_commits("hello-world", branch=branch.name)
older_commit = history.commits[-1]
rollback = client.repos.rollback_branch(
"hello-world",
branch.name,
commit_id=older_commit.id,
expected_head=history.head_identifier,
message="Rollback feature branch to a stable commit",
)
directory_download = client.repos.create_directory_download(
"hello-world",
type="branch",
directory=f"{branch.name}/state-456",
)
extension = client.extensions.create(
name="README reviewer",
prompt="Inspect README changes and suggest concise release-note updates.",
presets=["openclaw"],
)
run = client.extensions.run(
extension.id,
path="organizations/org-.../repositories/hello-world/main/ver-1234abcd",
prompt="Focus on docs/README.md.",
)
print(repo.id, branch.name, run.run_id)The client exposes repository operations through client.repos. Agent extensions are available through client.extensions. The longer form client.repositories is also available for repository operations.
# Repositories
repo = client.repos.create("hello-world")
repos = client.repos.list(page=1, page_size=10)
repo = client.repos.get("hello-world")
delete_result = client.repos.delete("hello-world")
# Branches
branches = client.repos.list_branches("hello-world")
branch = client.repos.get_branch("hello-world", "feature-readme")
branch = client.repos.create_branch(
"hello-world",
"feature-readme",
storage_dir="state-123",
transforms={"README.md": "# Updated\n"},
)
empty_branch = client.repos.create_branch(
"hello-world",
"empty-feature",
derive_from_main=False,
)
branch_delete = client.repos.delete_branch("hello-world", "feature-readme")
# Uploads
upload = client.repos.create_upload(
"hello-world",
storage_dir="ver-1234abcd",
branch="main",
message="Update README copy",
files=[{"name": "README.md", "hash": "64-character-sha256-or-client-hash"}],
)
completed = client.repos.complete_upload("hello-world", upload.upload_id)
# Commits + rollback
history = client.repos.list_commits("hello-world", branch="feature-readme")
rollback = client.repos.rollback_branch(
"hello-world",
"feature-readme",
commit_id=history.commits[-1].id,
expected_head=history.head_identifier,
message="Rollback feature-readme to a stable commit",
)
# Downloads
download = client.repos.create_download(
"hello-world",
type="main",
files=[{"path": "ver-1234abcd/README.md"}],
)
directory_download = client.repos.create_directory_download(
"hello-world",
type="branch",
directory="feature-readme/state-123",
)
# Copies
copy = client.repos.copy_directory(
"hello-world",
source_dir="ver-1234abcd",
dest_dir="state-123",
source_branch="main",
dest_branch="feature-readme",
)
copy_status = client.repos.get_copy_status("hello-world", copy.run_id)
# Sync
sync = client.repos.sync(
"hello-world",
incoming_storage_dir="ver-456",
strategy="smart",
targets=[
{
"branch": "profile-123",
"baseStorageDir": "ver-123",
"currentStorageDir": "state-123",
"outputStorageDir": "state-456",
}
],
)
sync_status = client.repos.get_sync_status("hello-world", sync.run_id)
# Extensions
extension = client.extensions.create(
name="README reviewer",
prompt="Inspect README changes and suggest concise release-note updates.",
presets=["openclaw"],
)
updated_extension = client.extensions.update(
extension.id,
status="active",
prompt="Inspect docs changes and return specific edits only.",
)
run = client.extensions.run(
extension.id,
path="organizations/org-.../repositories/hello-world/main/ver-1234abcd",
prompt="Focus on docs/README.md.",
)
run_status = client.extensions.poll(run.run_id)
delete_result = client.extensions.delete(extension.id)