@5y/cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/lib/commands.mjs +35 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
给 AI 工具(Codex / Claude Code / WorkBuddy)用的 5y 命令行:生图、生视频、素材与任务管理。
|
|
4
4
|
|
|
5
|
+
## For AI agents (read this first)
|
|
6
|
+
|
|
7
|
+
You can call 5y without any background knowledge:
|
|
8
|
+
|
|
9
|
+
1. **You cannot create an API key yourself.** Ask your human to open
|
|
10
|
+
<https://5y.com.cn/settings/api-keys>, create a key, and paste it to you.
|
|
11
|
+
2. Then: `5y login --key <KEY>` → `5y models` → `5y image|video ...`.
|
|
12
|
+
3. Run `5y` with no arguments for a quick start, examples, and the full command list.
|
|
13
|
+
|
|
14
|
+
Contract you can rely on:
|
|
15
|
+
|
|
16
|
+
- **stdout is exactly one line of JSON**; progress goes to stderr
|
|
17
|
+
- success `{"ok":true,...}` / failure `{"ok":false,"error":{"code","message","retryable","request_id"}}`
|
|
18
|
+
- exit codes: `0` ok · `2` usage · `3` auth · `4` business failure · `5` network/upstream
|
|
19
|
+
- **do not retry when `error.retryable === false`** (content rejection, invalid params)
|
|
20
|
+
- never invent `asset_id` / `job_id` — they only come from this CLI's output
|
|
21
|
+
- omitting `--model` is fine: the server picks a default and echoes it in the response
|
|
22
|
+
|
|
5
23
|
## 安装
|
|
6
24
|
|
|
7
25
|
```bash
|
package/lib/commands.mjs
CHANGED
|
@@ -29,14 +29,36 @@ import { VERSION } from './version.mjs';
|
|
|
29
29
|
|
|
30
30
|
const TERMINAL_STATUSES = new Set(['succeeded', 'failed', 'cancelled']);
|
|
31
31
|
|
|
32
|
-
const USAGE = `5y
|
|
32
|
+
const USAGE = `5y — 5y open API CLI (image / video / assets / jobs)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
QUICK START (in order):
|
|
35
|
+
1. Get an API key (a human does this): https://5y.com.cn/settings/api-keys
|
|
36
|
+
2. 5y login --key 5y_xxxxxxxx
|
|
37
|
+
3. 5y models --type image|video # see model ids + supported params
|
|
38
|
+
4. 5y image --prompt "a cat" --out ./out
|
|
39
|
+
|
|
40
|
+
EXAMPLES:
|
|
41
|
+
# text-to-image (model optional; server picks a default and echoes it)
|
|
42
|
+
5y image --prompt "一只橘猫,电影感" --param resolution=2K --out ./out
|
|
43
|
+
|
|
44
|
+
# video edit: swap a face using a reference image (needs a 4-30s input video)
|
|
45
|
+
5y upload ./face.png # -> asset_id
|
|
46
|
+
5y upload ./clip.mp4 # -> asset_id
|
|
47
|
+
5y video --prompt "把视频里的脸换成参考图的脸" --asset source_video=<clip id> --asset image=<face id> --param mode=video_edit --param ratio=adaptive --param duration=-1 --out ./out
|
|
48
|
+
|
|
49
|
+
# fire and forget, then poll
|
|
50
|
+
5y video --prompt "..." --no-wait
|
|
51
|
+
5y job get <job_id>
|
|
52
|
+
|
|
53
|
+
# notify a local service when done (5y never calls your machine)
|
|
54
|
+
5y image --prompt "..." --callback http://127.0.0.1:8787/hook
|
|
55
|
+
|
|
56
|
+
COMMANDS:
|
|
35
57
|
login --key <API_KEY> [--base-url URL]
|
|
36
58
|
whoami
|
|
37
59
|
models [--type image|video]
|
|
38
60
|
upload <file> [--name <name>]
|
|
39
|
-
assets list [--type T] [--limit N]
|
|
61
|
+
assets list [--type T] [--limit N]
|
|
40
62
|
assets get <asset_id>
|
|
41
63
|
assets delete <asset_id>
|
|
42
64
|
image|video --prompt <text> [--model M]
|
|
@@ -44,21 +66,27 @@ Commands:
|
|
|
44
66
|
[--param k=v ...] [--idempotency-key K]
|
|
45
67
|
[--wait | --no-wait | --callback URL]
|
|
46
68
|
[--out <dir>] [--interval <seconds>] [--timeout <seconds>]
|
|
47
|
-
job list [--limit N]
|
|
69
|
+
job list [--limit N]
|
|
48
70
|
job get <job_id>
|
|
49
71
|
job wait <job_id> [--interval <seconds>] [--timeout <seconds>]
|
|
50
72
|
job cancel <job_id>
|
|
51
73
|
job replay <job_id> --callback URL
|
|
52
74
|
download <job_id> [--out <dir>]
|
|
53
75
|
|
|
54
|
-
|
|
55
|
-
|
|
76
|
+
AGENT CONTRACT:
|
|
77
|
+
- stdout is EXACTLY one line of JSON; progress/logs go to stderr
|
|
78
|
+
- success: {"ok":true,...}; failure: {"ok":false,"error":{code,message,retryable,request_id}}
|
|
79
|
+
- exit codes: 0 ok / 2 usage / 3 auth / 4 business failure / 5 network or upstream
|
|
80
|
+
- do NOT auto-retry when error.retryable is false (content rejection, bad params)
|
|
81
|
+
- never invent asset_id / job_id; they come from this CLI's output`;
|
|
82
|
+
|
|
83
|
+
|
|
56
84
|
|
|
57
85
|
function requireAuth(cfg) {
|
|
58
86
|
if (!cfg.apiKey) {
|
|
59
87
|
throw new CliError({
|
|
60
88
|
code: 'UNAUTHORIZED',
|
|
61
|
-
message: 'no API key configured
|
|
89
|
+
message: 'no API key configured. Get one at https://5y.com.cn/settings/api-keys then run: 5y login --key <API_KEY>',
|
|
62
90
|
retryable: false,
|
|
63
91
|
exitCode: EXIT.AUTH,
|
|
64
92
|
});
|