Feat v0.8.0 files sandbox module
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m44s
CI/CD / test-sqlite (pull_request) Successful in 2m57s
CI/CD / build-and-deploy (pull_request) Successful in 1m25s
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m44s
CI/CD / test-sqlite (pull_request) Successful in 2m57s
CI/CD / build-and-deploy (pull_request) Successful in 1m25s
Bridge ObjectStore (PVC/S3) into the Starlark sandbox with extension-scoped key namespacing. New files module with put/get/meta/list/delete/exists builtins gated by files.read and files.write permissions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -275,6 +275,48 @@ results, errors = batch.exec([
|
||||
|
||||
---
|
||||
|
||||
### files
|
||||
|
||||
**Permissions:** `files.read`, `files.write`
|
||||
|
||||
Store and retrieve files via the kernel ObjectStore (PVC or S3).
|
||||
All keys are scoped to `ext/{packageID}/` — extensions cannot access
|
||||
each other's files.
|
||||
|
||||
```python
|
||||
# Store a file with optional metadata
|
||||
files.put("reports/q1.pdf", pdf_bytes,
|
||||
content_type="application/pdf",
|
||||
metadata={"quarter": "Q1", "year": 2026})
|
||||
|
||||
# Read a file
|
||||
result = files.get("reports/q1.pdf")
|
||||
# result = {"content": b"...", "content_type": "application/pdf",
|
||||
# "size": 12345, "metadata": {"quarter": "Q1", "year": 2026}}
|
||||
|
||||
# Metadata only (no content transfer)
|
||||
meta = files.meta("reports/q1.pdf")
|
||||
|
||||
# List files by prefix
|
||||
entries = files.list(prefix="reports/", limit=50)
|
||||
# entries = [{"name": "reports/q1.pdf", "size": 12345, "content_type": "..."}]
|
||||
|
||||
# Check existence
|
||||
if files.exists("reports/q1.pdf"):
|
||||
files.delete("reports/q1.pdf")
|
||||
|
||||
# Bulk delete
|
||||
files.delete_prefix("temp/")
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
- `content` accepts string or bytes; `get()` returns bytes.
|
||||
- Maximum file size: 50 MB (configurable via `EXT_FILES_MAX_SIZE`).
|
||||
- Metadata is stored as a companion JSON object, not in the file itself.
|
||||
- `files.list()` automatically filters out internal metadata companions.
|
||||
|
||||
---
|
||||
|
||||
## Example: automated stage hook
|
||||
|
||||
A simple hook that reads a setting, queries data, and advances:
|
||||
|
||||
Reference in New Issue
Block a user