feat(upload): 支持 Agent 本地图片安全上传

This commit is contained in:
yuzhe
2026-07-23 13:26:10 +08:00
parent 69cfd0b51d
commit c067881415
12 changed files with 380 additions and 25 deletions

View File

@@ -16,8 +16,9 @@ Use a two-phase plan/apply workflow. Optimize for correct placement, not speed.
- Never create a new round until the operator confirms the resolved work and current round.
- Never retry a timed-out create request. First inspect current server state; otherwise a retry can create a duplicate round.
- Require `externalId` for every agent-created work. Reuse the same value for safe retries.
- Accept 1-30 public `http`/`https` image URLs. Preserve their order; the first image is the cover.
- Accept either 1-30 public `http`/`https` image URLs or 1-30 local image files. Never mix both modes in one plan. Preserve order; the first image is the cover.
- Require an active Tencent COS configuration. URLs already using its public or CDN origin are reused; other public images are downloaded and stored in that COS by the API.
- Upload local files as `multipart/form-data` from the bundled script. Never read image bytes into the conversation, print Base64, or put binary data in the plan.
- Put API keys only in `DELIVERY_DESK_API_KEY`. Do not paste keys into chat, plans, source files, or command history.
- Prefer a project-scoped API key. A platform key has a wider blast radius and always requires explicit group verification.
- Stop on any mismatch, ambiguity, changed project/work state, or missing input. Ask the operator instead of guessing.
@@ -40,8 +41,9 @@ For both operations, require:
- Delivery Desk base URL. Default to `DELIVERY_DESK_BASE_URL` or `http://127.0.0.1:3010` only for local development.
- A valid API key in `DELIVERY_DESK_API_KEY`.
- Exact target project, resolved to group ID/name and project ID/name/slug.
- Ordered public image URLs.
- Confirmation that the source URLs are reachable until the API finishes importing them. After a cross-origin import succeeds, Delivery Desk uses the resulting COS URL.
- Ordered public image URLs or ordered local image paths.
- For URL mode, confirmation that source URLs remain reachable until import finishes.
- For file mode, confirmation that files remain unchanged until apply. The plan records absolute path, byte size, SHA-256, and content type; it never records image bytes.
For `create_work`, also require:
@@ -102,6 +104,20 @@ python $skillScript plan-round `
--output tmp/delivery-plan.json
```
Use local files instead of URLs:
```powershell
python $skillScript plan-work `
--project-id 12 `
--external-id client-2026-002 `
--title "本地生成作品" `
--image-file "D:\generated\01.png" `
--image-file "D:\generated\02.png" `
--output tmp/delivery-plan.json
```
Use repeated `--image-url` or repeated `--image-file`, never both. Local files must be JPEG, PNG, GIF, WebP, or AVIF, each no larger than 20 MB.
Optional `plan-round` content flags:
- `--title`, `--description`, and repeated `--tag` replace current values.
@@ -120,7 +136,7 @@ Show the plan summary exactly, including:
- Work ID and current/next round for `create_round`.
- `externalId` for `create_work`.
- Title, complete description, complete tag list.
- Ordered image URLs with `1` marked as the cover.
- Ordered image URLs, or local file path/name/size/SHA-256, with `1` marked as the cover.
- Confirmation code.
Ask: `确认按以上目标和内容执行吗?请回复“确认 <confirmation_code>”。`
@@ -137,7 +153,7 @@ python $skillScript apply `
--confirm ABCD1234EF56
```
The script re-fetches the project/work, checks for state drift, performs one POST, and reads the created resource back. Treat only a successful verification result as complete.
The script re-fetches the project/work, checks for state drift, revalidates local file hashes when applicable, performs one POST, and reads the created resource back. Local files are streamed by the script as multipart and never enter model context. Treat only a successful verification result as complete.
Report group, project, work ID, `externalId`, created round number, title, image count, and whether the server returned an existing idempotent work.