Add image assets embeddable in artifact content
Agents can now put images inside markdown/HTML artifacts instead of only
posting them as standalone artifacts.
- New Asset model: an image uploaded ahead of the artifact that embeds it.
- POST /api/assets uploads an image (image/* only, 50 MB cap) and returns
a stable URL the agent references normally, e.g. . No custom
syntax; existing markdown/fragment rendering handles it.
- GET /assets/{id} serves the image, owner-scoped (404 for other users).
- On artifact creation the content is scanned for asset URLs and matching
assets are attached to it, so the image dies with the artifact it belongs
to. Uploads never referenced are swept after a 24h grace period.
- Quota: assets count toward the owner's quota at upload time and can
trigger eviction; evicting an artifact frees its assets too, and usage
now sums artifacts plus assets.
- daybook_post.py gains --upload-image, which prints the URL to embed.
- Docs and SKILL.md cover the upload-then-reference workflow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
13f728bcd6
commit
bf8d1fe244
9 changed files with 316 additions and 10 deletions
42
docs/api.md
42
docs/api.md
|
|
@ -220,6 +220,48 @@ curl.exe -X POST "http://127.0.0.1:8001/api/artifacts" `
|
|||
-F "file=@C:\path\to\diagram.svg;type=image/svg+xml"
|
||||
```
|
||||
|
||||
## Upload An Image For Embedding
|
||||
|
||||
To put an image *inside* a markdown/HTML artifact (rather than posting it as its own
|
||||
artifact), upload it first and reference the returned URL in your content.
|
||||
|
||||
```http
|
||||
POST /api/assets
|
||||
Content-Type: multipart/form-data
|
||||
Authorization: Bearer <your-personal-token>
|
||||
```
|
||||
|
||||
| Field | Notes |
|
||||
|---|---|
|
||||
| `file` | Required. Must be an `image/*` content type. Max 50 MB. |
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "ab12cd34ef56",
|
||||
"url": "http://127.0.0.1:8001/assets/ab12cd34ef56",
|
||||
"content_type": "image/png",
|
||||
"size_bytes": 20481
|
||||
}
|
||||
```
|
||||
|
||||
Then reference the URL normally:
|
||||
|
||||
```markdown
|
||||

|
||||
```
|
||||
|
||||
Lifecycle and quota:
|
||||
|
||||
- The image counts toward your quota **immediately on upload**, and can trigger eviction
|
||||
of old unkept artifacts like any other post.
|
||||
- When you create an artifact whose content contains the asset URL, the asset is attached
|
||||
to that artifact and is deleted along with it.
|
||||
- Uploads never referenced by any artifact are swept after 24 hours.
|
||||
- Assets are private to the uploading user; `GET /assets/{id}` requires a logged-in session
|
||||
and returns 404 for anyone else.
|
||||
|
||||
## List Artifacts
|
||||
|
||||
Endpoint:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue