@dawnwood/cli 0.2.0 → 0.3.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 +35 -23
- package/dist/api.js +5 -5
- package/dist/index.js +15 -15
- package/dist/mcp.js +132 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
# @dawnwood/cli — Dawnwood for agents
|
|
2
2
|
|
|
3
|
-
CLI
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
A CLI and MCP server that lets your local agent (Claude Code, Cursor, Codex) drive
|
|
4
|
+
the full [Dawnwood](https://dawnwood.ai) short-drama pipeline: series bible →
|
|
5
|
+
episode scripts → asset pack → art and renders. Visual review and approvals stay
|
|
6
|
+
with you in the console — the agent hands you a deep link (`get_review_url`).
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## 快速开始
|
|
8
|
+
## Quick start
|
|
10
9
|
|
|
11
10
|
```bash
|
|
12
|
-
# 1.
|
|
13
|
-
#
|
|
11
|
+
# 1. Mint a personal access token in the console
|
|
12
|
+
# (avatar menu → API tokens; shown only once, valid 90 days by default)
|
|
13
|
+
|
|
14
|
+
# 2. Sign in (the token is saved to ~/.config/dawnwood/config.json, mode 0600)
|
|
14
15
|
npx @dawnwood/cli auth login --token dw_pat_v1_...
|
|
15
16
|
|
|
16
|
-
# 3a.
|
|
17
|
+
# 3a. Add it to Claude Code
|
|
17
18
|
claude mcp add dawnwood -- npx -y @dawnwood/cli mcp
|
|
18
19
|
|
|
19
|
-
# 3b.
|
|
20
|
+
# 3b. Or check your identity from the CLI
|
|
20
21
|
npx @dawnwood/cli whoami
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
##
|
|
24
|
+
## Tools
|
|
25
|
+
|
|
26
|
+
| Stage | Tools |
|
|
27
|
+
|---|---|
|
|
28
|
+
| Runs | `list_runs`, `get_run`, `create_run`, `delete_run` |
|
|
29
|
+
| Bible | `generate_bible`, `get_bible`, `update_bible`, `sync_bible`, `approve_bible` |
|
|
30
|
+
| Scripts | `generate_scripts`, `get_script`, `update_script`, `approve_script` |
|
|
31
|
+
| Asset pack | `generate_pack`, `update_pack`, `commit_pack` |
|
|
32
|
+
| Art and render | `art_estimate`, `generate_art`, `art_status`, `upload_character_ref` |
|
|
33
|
+
| Covers | `covers_estimate`, `generate_covers`, `regen_cover`, `set_cover_theme` |
|
|
34
|
+
| Storyboard tools | `flashback_montage`, `reclone_voice`, `likeness_reroll`, `import_clip`, `job_status` |
|
|
35
|
+
| Sign-off and delivery | `signoff_episode`, `build_delivery_pack` |
|
|
36
|
+
| Account | `credits_balance`, `get_review_url` |
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
Poll with `get_run`, `art_status` or `job_status`, no more than every 10 seconds.
|
|
39
|
+
`list_runs` is for browsing, not polling. Approvals are gate actions: give the
|
|
40
|
+
user `get_review_url` first. Spending actions are billed in credits to the
|
|
41
|
+
account that owns the token.
|
|
28
42
|
|
|
29
|
-
##
|
|
43
|
+
## Environment variables
|
|
30
44
|
|
|
31
|
-
- `DAWNWOOD_TOKEN` —
|
|
32
|
-
- `DAWNWOOD_API_BASE` —
|
|
33
|
-
- `DAWNWOOD_AGENT` —
|
|
34
|
-
- `DAWNWOOD_CONFIG_DIR` —
|
|
45
|
+
- `DAWNWOOD_TOKEN` — overrides the saved token (useful in CI)
|
|
46
|
+
- `DAWNWOOD_API_BASE` — defaults to `https://console.dawnwood.ai/api`
|
|
47
|
+
- `DAWNWOOD_AGENT` — agent name reported for usage attribution
|
|
48
|
+
- `DAWNWOOD_CONFIG_DIR` — config directory (default `~/.config/dawnwood`)
|
|
35
49
|
|
|
36
|
-
##
|
|
50
|
+
## Support
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
`.github/workflows/npm-publish.yml`(需 NPM_TOKEN secret;tag 与
|
|
40
|
-
package.json 版本一致性有闸)。
|
|
52
|
+
Questions and issues: [dawnwood.ai/docs](https://dawnwood.ai/docs).
|
package/dist/api.js
CHANGED
|
@@ -22,13 +22,13 @@ function explain(status, body) {
|
|
|
22
22
|
const err = typeof body?.error === "string" ? body.error : JSON.stringify(body);
|
|
23
23
|
switch (status) {
|
|
24
24
|
case 401:
|
|
25
|
-
return `${err} — token
|
|
25
|
+
return `${err} — the token is invalid, expired or revoked. Mint a new one in the console (avatar menu → API tokens), then run \`dawnwood auth login --token <new token>\`.`;
|
|
26
26
|
case 402:
|
|
27
|
-
return `${err} — credits
|
|
27
|
+
return `${err} — not enough credits. Top up or upgrade at ${getApiBase().replace(/\/api$/, "")}/#billing, then retry.`;
|
|
28
28
|
case 403:
|
|
29
|
-
return `${err} —
|
|
29
|
+
return `${err} — this token is not allowed to perform this action (customer tokens only cover the self-serve surface).`;
|
|
30
30
|
case 503:
|
|
31
|
-
return `${err} —
|
|
31
|
+
return `${err} — the server can't verify tokens right now (fail-closed); retry shortly — your token is fine.`;
|
|
32
32
|
default:
|
|
33
33
|
return err;
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ function explain(status, body) {
|
|
|
36
36
|
export async function apiCall(path, opts = {}) {
|
|
37
37
|
const token = opts.token ?? getToken();
|
|
38
38
|
if (!token) {
|
|
39
|
-
throw new ApiError(0, "
|
|
39
|
+
throw new ApiError(0, "Not signed in — run `dawnwood auth login --token <dw_pat_v1_...>` first (mint a token in the console: avatar menu → API tokens).", null);
|
|
40
40
|
}
|
|
41
41
|
const base = opts.base ?? getApiBase();
|
|
42
42
|
const f = opts.fetchImpl ?? fetch;
|
package/dist/index.js
CHANGED
|
@@ -28,33 +28,33 @@ async function main() {
|
|
|
28
28
|
const i = rest.indexOf("--token");
|
|
29
29
|
const token = i >= 0 ? rest[i + 1] : undefined;
|
|
30
30
|
if (!token) {
|
|
31
|
-
die("
|
|
32
|
-
"token
|
|
31
|
+
die("Usage: dawnwood auth login --token <dw_pat_v1_...>\n" +
|
|
32
|
+
"Mint a token in the console (avatar menu → API tokens); it is shown only once.");
|
|
33
33
|
}
|
|
34
34
|
if (!token.startsWith("dw_pat_v1_")) {
|
|
35
|
-
die("
|
|
35
|
+
die("That doesn't look like a dawnwood token (it should start with dw_pat_v1_).");
|
|
36
36
|
}
|
|
37
37
|
// 铸造响应里的占位/截断很常见 —— 落盘前先用一次只读调用验真伪。
|
|
38
38
|
try {
|
|
39
39
|
const me = (await apiCall("/me", { token, tool: "auth_login" }));
|
|
40
40
|
const p = saveConfig({ ...loadConfig(), token });
|
|
41
|
-
out(
|
|
41
|
+
out(`Signed in as ${me.email ?? "?"} (token ${maskToken(token)}) → ${p} (0600)`);
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
die(`
|
|
44
|
+
die(`Token check failed: ${e instanceof Error ? e.message : e}`);
|
|
45
45
|
}
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
if (cmd === "auth" && sub === "status") {
|
|
49
49
|
const t = getToken();
|
|
50
|
-
out(t ?
|
|
50
|
+
out(t ? `Signed in (token ${maskToken(t)}, api ${getApiBase()})` : "Not signed in");
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
if (cmd === "auth" && sub === "logout") {
|
|
54
54
|
const cfg = loadConfig();
|
|
55
55
|
delete cfg.token;
|
|
56
56
|
saveConfig(cfg);
|
|
57
|
-
out("
|
|
57
|
+
out("Signed out (local token deleted; revoke the token in the console to invalidate it completely).");
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
if (cmd === "whoami") {
|
|
@@ -64,15 +64,15 @@ async function main() {
|
|
|
64
64
|
}
|
|
65
65
|
out(`dawnwood — agent access CLI
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
dawnwood auth login --token <dw_pat_v1_...>
|
|
69
|
-
dawnwood auth status
|
|
70
|
-
dawnwood auth logout
|
|
71
|
-
dawnwood whoami
|
|
72
|
-
dawnwood mcp
|
|
67
|
+
Usage:
|
|
68
|
+
dawnwood auth login --token <dw_pat_v1_...> sign in (mint a token in the console: avatar menu → API tokens)
|
|
69
|
+
dawnwood auth status show sign-in status
|
|
70
|
+
dawnwood auth logout sign out (deletes the local token)
|
|
71
|
+
dawnwood whoami check the token / show identity and permissions
|
|
72
|
+
dawnwood mcp start the stdio MCP server (for Claude Code, Cursor, etc.)
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Connect to Claude Code:
|
|
75
75
|
claude mcp add dawnwood -- npx -y @dawnwood/cli mcp
|
|
76
|
-
|
|
76
|
+
Environment: DAWNWOOD_TOKEN / DAWNWOOD_API_BASE / DAWNWOOD_AGENT override the local config.`);
|
|
77
77
|
}
|
|
78
78
|
main().catch((e) => die(e instanceof Error ? e.message : String(e)));
|
package/dist/mcp.js
CHANGED
|
@@ -34,54 +34,154 @@ async function call(path, tool, method, body) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
export function buildServer() {
|
|
37
|
-
const server = new McpServer({ name: "dawnwood", version: "0.1
|
|
37
|
+
const server = new McpServer({ name: "dawnwood", version: "0.3.1" });
|
|
38
38
|
// ---- runs 生命周期 ---------------------------------------------------------
|
|
39
|
-
server.tool("list_runs", "
|
|
40
|
-
server.tool("get_run", "
|
|
41
|
-
server.tool("create_run", "
|
|
42
|
-
run_id: z.string().describe("snake_case
|
|
43
|
-
titles: z.record(z.string(), z.string()).describe('
|
|
39
|
+
server.tool("list_runs", "List your runs (drafts and in progress). For browsing only — **never poll status with it**; use get_run for a single run.", async () => call("/runs", "list_runs"));
|
|
40
|
+
server.tool("get_run", "Read one run's full state (wizard step, bible, scripts, pack, art progress). This is the right tool for polling (O(1) lookup); poll at most every 10 seconds (10s).", { run_id: z.string().describe("run id (snake_case)") }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}`, "get_run"));
|
|
41
|
+
server.tool("create_run", "Create a new series run (wizard step 1: brief). premise is 100–6000 characters; titles must include the primary_locale; compliance_ack=true is required (no real-person likeness, no third-party IP). Episode count defaults to 10 (changing it is an operator privilege).", {
|
|
42
|
+
run_id: z.string().describe("snake_case ASCII id, globally unique"),
|
|
43
|
+
titles: z.record(z.string(), z.string()).describe('title per locale, e.g. {"en": "..."}'),
|
|
44
44
|
primary_locale: z.string().default("en"),
|
|
45
|
-
premise: z.string().describe("
|
|
46
|
-
lang: z.string().default("en").describe("
|
|
45
|
+
premise: z.string().describe("story premise, 100–6000 characters"),
|
|
46
|
+
lang: z.string().default("en").describe("output language (BCP-47)"),
|
|
47
47
|
render_style: z.enum(["real", "comic"]).default("real"),
|
|
48
|
-
compliance_ack: z.boolean().describe("
|
|
48
|
+
compliance_ack: z.boolean().describe("confirms no real-person likeness and no third-party IP; must be true"),
|
|
49
|
+
episodes: z.number().int().optional()
|
|
50
|
+
.describe("episode count (operator privilege: the server requires OPS permission and 6–120; omit = 10)"),
|
|
49
51
|
}, async (a) => call("/runs", "create_run", "POST", {
|
|
50
52
|
id: a.run_id, titles: a.titles, primary_locale: a.primary_locale,
|
|
51
53
|
premise: a.premise, lang: a.lang, render_style: a.render_style,
|
|
52
54
|
compliance_ack: a.compliance_ack,
|
|
55
|
+
...(a.episodes != null ? { episodes: a.episodes } : {}),
|
|
53
56
|
}));
|
|
54
|
-
server.tool("delete_run", "
|
|
57
|
+
server.tool("delete_run", "Discard a draft run (irreversible; self-serve runs only).", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}`, "delete_run", "DELETE"));
|
|
55
58
|
// ---- 圣经(Step 2) ---------------------------------------------------------
|
|
56
|
-
server.tool("generate_bible", "
|
|
57
|
-
server.tool("get_bible", "
|
|
58
|
-
server.tool("
|
|
59
|
-
server.tool("
|
|
59
|
+
server.tool("generate_bible", "Generate the series bible (world, characters, arcs, emotion frame, midpoint, per-episode beats). A long operation; read the result with get_bible. Pass feedback to regenerate. Bible fields: emotion_frame (one of revenge|sweet_healing|angst|benevolence|career|light_mystery|family_ethics, with a four-part arc), midpoint (ally_flip|hidden_truth|major_failure, placed at 40–60% of the season), reveal_ladder, beats[]{hook_0_5s, turn, cliffhanger, payoff_next (the payoff the next episode must deliver first), phase (1–4, never decreasing)}.", { run_id: z.string(), feedback: z.string().optional().describe("notes on the previous version") }, async ({ run_id, feedback }) => call(`/runs/${encodeURIComponent(run_id)}/bible/generate`, "generate_bible", "POST", feedback ? { feedback } : {}));
|
|
60
|
+
server.tool("get_bible", "Read the current bible (with version history). stale_eps = episodes whose beats lag behind the current scripts (trust get_script, not the beat); pending_deltas = bible-level changes detected from script edits (new world rules / cast / reveal ladder) awaiting human confirmation — never write them automatically. content.writing_rules = this series' writing constraints (who may be suspected when, disclosure schedule, colour conventions, banned lines): read them before editing a script and treat them as hard constraints.", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/bible`, "get_bible"));
|
|
61
|
+
server.tool("sync_bible", "Rebuild the bible's beats from the current scripts (async, in the background). With ep, only that episode; without, the whole season from EP1. Normally unnecessary — every script version syncs back automatically; call it only when get_bible reports stale_eps and you need them now.", { run_id: z.string(), ep: z.string().optional().describe("episode number, e.g. '5'; omit = whole season") }, async ({ run_id, ep }) => call(`/runs/${encodeURIComponent(run_id)}/bible/sync`, "sync_bible", "POST", ep ? { ep: String(parseInt(ep, 10)) } : {}));
|
|
62
|
+
server.tool("update_bible", "Overwrite the bible content (full PUT; prefer generate_bible feedback for small changes). Validation: emotion_frame.type / midpoint.type must come from the fixed enums, midpoint.ep must sit at 40–60% of the season, beats[].phase 1–4 and never decreasing across episodes; writing_rules optional, ≤12 strings (series-specific constraints — the general craft rules are built in).", { run_id: z.string(), bible: z.record(z.string(), z.unknown()).describe("the full bible JSON") }, async ({ run_id, bible }) => call(`/runs/${encodeURIComponent(run_id)}/bible`, "update_bible", "PUT", bible));
|
|
63
|
+
server.tool("approve_bible", "Approve the bible and unlock the script chain. A gate action — hand the user get_review_url to look it over in the console first.", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/bible/approve`, "approve_bible", "POST"));
|
|
60
64
|
// ---- 剧本链(Step 3) -------------------------------------------------------
|
|
61
|
-
server.tool("generate_scripts", "
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
server.tool("
|
|
65
|
+
server.tool("generate_scripts", "Run the script chain (episode by episode, each with a recap of what came before). Long operation; poll progress with get_run (≥10s). " +
|
|
66
|
+
"By default it **resumes**: episodes already ready or approved are skipped, so re-calling after a killed or stuck chain is safe. " +
|
|
67
|
+
"force=true regenerates everything (e.g. rewriting the whole chain after bible feedback; every episode becomes a new version).", { run_id: z.string(), force: z.boolean().optional().describe("regenerate every episode (use with care)") }, async ({ run_id, force }) => call(`/runs/${encodeURIComponent(run_id)}/scripts/generate`, "generate_scripts", "POST", force ? { force: true } : {}));
|
|
68
|
+
server.tool("get_script", "Read one episode's script. ep looks like '0001'. The response carries render_lock: {locked, reason} — while locked=true the episode cannot be storyboarded or rendered: " +
|
|
69
|
+
"reason=proposal_pending means a rewrite proposal is waiting for the user (Apply/Reject); reason=unapproved means the new version has not been approved yet. " +
|
|
70
|
+
"When locked, tell the user plainly to resolve it on the console's Script page (or call approve_script only with their explicit consent); never work around it.", { run_id: z.string(), ep: z.string().describe("episode number, e.g. 0001") }, async ({ run_id, ep }) => call(`/runs/${encodeURIComponent(run_id)}/scripts/${encodeURIComponent(ep)}`, "get_script"));
|
|
71
|
+
server.tool("update_script", "Rewrite one episode's script (PUT; edits after approval are billed, feedback regenerations before approval are free). The bible's beat for that episode syncs back automatically. " +
|
|
72
|
+
"**Writing clears the approval**: the response has render_lock.locked=true and the episode cannot be storyboarded or rendered until the user re-approves — remind them to approve (or call approve_script only with explicit consent). Before editing an existing script, read the episodes before and after it (get_script) and keep every beat, prop and character the user did not ask to change. When the user asks you to CHECK whether an episode supports a premise, quote the text and say whether it holds — never add lines to make it true.", { run_id: z.string(), ep: z.string(), body: z.record(z.string(), z.unknown()) }, async ({ run_id, ep, body }) => call(`/runs/${encodeURIComponent(run_id)}/scripts/${encodeURIComponent(ep)}`, "update_script", "PUT", body));
|
|
73
|
+
server.tool("approve_script", "Approve one episode's script (a gate action; hand the user get_review_url to look it over first).", { run_id: z.string(), ep: z.string() }, async ({ run_id, ep }) => call(`/runs/${encodeURIComponent(run_id)}/scripts/${encodeURIComponent(ep)}/approve`, "approve_script", "POST"));
|
|
65
74
|
// ---- 设定包(Step 4) -------------------------------------------------------
|
|
66
|
-
server.tool("generate_pack", "
|
|
67
|
-
server.tool("update_pack", "
|
|
68
|
-
server.tool("commit_pack", "
|
|
75
|
+
server.tool("generate_pack", "Generate the asset-pack draft (visual design of characters, scenes and props).", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/pack/generate`, "generate_pack", "POST"));
|
|
76
|
+
server.tool("update_pack", "Edit the asset-pack draft (full PUT).", { run_id: z.string(), pack: z.record(z.string(), z.unknown()) }, async ({ run_id, pack }) => call(`/runs/${encodeURIComponent(run_id)}/pack`, "update_pack", "PUT", pack));
|
|
77
|
+
server.tool("commit_pack", "Lock the asset pack and move on to art/rendering (a gate action).", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/pack/commit`, "commit_pack", "POST"));
|
|
69
78
|
// ---- 美术/渲染(Step 5) ----------------------------------------------------
|
|
70
|
-
server.tool("art_estimate", "
|
|
71
|
-
server.tool("generate_art", "
|
|
72
|
-
|
|
79
|
+
server.tool("art_estimate", "Credits quote for art/rendering (check it before starting).", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/art/estimate`, "art_estimate"));
|
|
80
|
+
server.tool("generate_art", "Start art/rendering (this step spends credits; run art_estimate first). Poll progress with art_status (≥10s). " +
|
|
81
|
+
"409 with code=script_proposal_pending / script_unapproved = an episode's script is waiting on the user (a proposal not applied/rejected, or a new version not approved): relay the reason and send them to the Script page; do not retry.", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/art/generate`, "generate_art", "POST"));
|
|
82
|
+
server.tool("art_status", "Art/rendering progress (single-run lookup — use this to poll, at most every 10 seconds).", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/art/status`, "art_status"));
|
|
83
|
+
server.tool("covers_estimate", "Quote for generated episode covers before rendering: which episodes still lack a cover, the credits price, and gate blockers " +
|
|
84
|
+
"(all scripts approved + character anchors ready). Read this **before** generate_covers and confirm the count and price with the user.", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/covers/estimate`, "covers_estimate"));
|
|
85
|
+
server.tool("generate_covers", "Generate covers for every episode that lacks one (script → cover scene + hook → face-locked 9:16 image → typeset in the cover theme). " +
|
|
86
|
+
"Async batch; progress in covers_estimate / the covers field of get_run (poll ≥10s). Idempotent: episodes with a cover are skipped; " +
|
|
87
|
+
"covers later taken from the finished footage or fixed by hand naturally replace the generated one (publishing uses the newest).", { run_id: z.string() }, async ({ run_id }) => call(`/runs/${encodeURIComponent(run_id)}/covers/generate`, "generate_covers", "POST", {}));
|
|
88
|
+
server.tool("set_cover_theme", "Set this series' cover theme (when several series share a channel, the profile grid tells them apart by it). All fields optional: " +
|
|
89
|
+
"accent/text/dim are #RRGGBB (defaults gold/white/dim white), wordmark is the series wordmark burned onto every cover " +
|
|
90
|
+
"(≤24 characters, e.g. 'BOUGHT BRIDE'), ep_badge is the episode-line format string ({n}/{title} available). " +
|
|
91
|
+
"Omitted fields keep their defaults; validated on the server.", {
|
|
92
|
+
run_id: z.string().describe("run/work id (snake_case)"),
|
|
93
|
+
accent: z.string().optional().describe("#RRGGBB accent colour (title / divider / wordmark)"),
|
|
94
|
+
text: z.string().optional().describe("#RRGGBB body colour (hook)"),
|
|
95
|
+
dim: z.string().optional().describe("#RRGGBB secondary colour (episode line)"),
|
|
96
|
+
wordmark: z.string().optional().describe("series wordmark, ≤24 characters"),
|
|
97
|
+
ep_badge: z.string().optional().describe("episode-line format string, e.g. 'EP {n}'"),
|
|
98
|
+
}, async ({ run_id, ...t }) => call(`/works/${encodeURIComponent(run_id)}`, "set_cover_theme", "PUT", { cover_theme: Object.fromEntries(Object.entries(t).filter(([, v]) => v != null)) }));
|
|
99
|
+
server.tool("import_clip", "Cut a clip from an earlier finished work into this series (straight reuse or a flashback): source_asset_id is the source work's video asset " +
|
|
100
|
+
"(segment cut / master); [start_ms, end_ms] is cut out and stored as this series' archival_clip asset (with provenance). " +
|
|
101
|
+
"treatment='flashback' burns in a memory grade at extraction. Optional splice={chapter, seg_id, position} " +
|
|
102
|
+
"inserts it straight into that segment's stitch order (no render). Async — poll import_status on the returned asset_id. " +
|
|
103
|
+
"Staff-only (enforced on the server).", {
|
|
104
|
+
run_id: z.string().describe("target run/work id"),
|
|
105
|
+
source_work_id: z.string().describe("source work id (provenance check)"),
|
|
106
|
+
source_asset_id: z.string().describe("source video asset id"),
|
|
107
|
+
start_ms: z.number().int().describe("start, milliseconds"),
|
|
108
|
+
end_ms: z.number().int().describe("end, milliseconds (≤ start + 120000)"),
|
|
109
|
+
treatment: z.enum(["none", "flashback"]).optional(),
|
|
110
|
+
note: z.string().optional().describe("note, e.g. 'EP7 broken engagement'"),
|
|
111
|
+
splice: z.object({ chapter: z.number().int(), seg_id: z.string(),
|
|
112
|
+
position: z.number().int().optional() }).optional()
|
|
113
|
+
.describe("insert as a group right away: target chapter / segment / 1-based group slot (default: end of segment)"),
|
|
114
|
+
}, async ({ run_id, ...body }) => call(`/works/${encodeURIComponent(run_id)}/clips/import`, "import_clip", "POST", body));
|
|
115
|
+
// ---- EP21 感情戏兑现沉淀(TQ 2026-09-25):回忆蒙太奇 / 片中声线重克隆 / KYC 撞脸重抽 ------------
|
|
116
|
+
server.tool("flashback_montage", "Build a flashback from footage the viewer has ALREADY SEEN in earlier episodes: 3–6 short slices, one memory grade, original audio muted (silent footage), " +
|
|
117
|
+
"one inner V.O. line of ≤16 words per slice in the speaker's own cloned voice, assembled into one archival group inside the target segment (position 1-based, default the end) " +
|
|
118
|
+
"with subtitle beats; the segment restitches automatically. Never re-render the past — new renders never match the old faces and costumes. clips' seg_no/group_no are the SOURCE episode's 1-based numbers; " +
|
|
119
|
+
"each slice ≤12s, ≤30s total. If the V.O. doesn't sound like the character, run reclone_voice first. Async — returns job_id; poll job_status (≥10s).", {
|
|
120
|
+
run_id: z.string(),
|
|
121
|
+
episode: z.number().int().describe("episode that receives the flashback"),
|
|
122
|
+
seg_id: z.string().describe("segment id it goes into"),
|
|
123
|
+
clips: z.array(z.object({
|
|
124
|
+
ep: z.number().int(), seg_no: z.number().int(), group_no: z.number().int(),
|
|
125
|
+
t0: z.number(), t1: z.number(), vo: z.string().optional(),
|
|
126
|
+
})).min(1).max(8),
|
|
127
|
+
speaker: z.string().optional().describe("whose memory it is (character name or id); required when any clip has vo"),
|
|
128
|
+
position: z.number().int().optional(),
|
|
129
|
+
silent: z.boolean().optional().describe("default true: mute the original audio, keep only the V.O."),
|
|
130
|
+
}, async ({ run_id, episode, seg_id, ...body }) => call(`/works/${encodeURIComponent(run_id)}/chapters/${episode}/storyboard/segments/${encodeURIComponent(seg_id)}/flashback`, "flashback_montage", "POST", body));
|
|
131
|
+
server.tool("reclone_voice", "Re-clone a character's voice from their own performance in a finished episode (written back as their default voice): vocals are separated per segment, only this character's lines are kept, then instantly cloned. " +
|
|
132
|
+
"Use it when a V.O. or new line doesn't sound like them on screen; pick a finished episode where they talk a lot. With <4s of clean speech the current voice is kept. " +
|
|
133
|
+
"Costs one voice recast. Async — job_id → job_status.", { character_id: z.string(), run_id: z.string().optional(), episode: z.number().int() }, async ({ character_id, run_id, episode }) => call(`/characters/${encodeURIComponent(character_id)}/voice/reclone`, "reclone_voice", "POST", { chapter: episode, ...(run_id ? { work_id: run_id } : {}) }));
|
|
134
|
+
server.tool("likeness_reroll", "When the engine keeps rejecting a group as 'looks like a real person' (even after the shot was changed), temporarily register the flagged actor in the verified asset library (references sent as trusted assets) and re-render the group; " +
|
|
135
|
+
"the library is removed once the group renders. character defaults to whoever appears most in this episode's likeness-rejected groups. Internal shows only (enforced on the server; customer shows get 403 — change the angle or add motion instead).", { run_id: z.string(), episode: z.number().int(), seg_id: z.string(), group_id: z.string(),
|
|
136
|
+
character: z.string().optional(), engine: z.string().optional() }, async ({ run_id, episode, seg_id, group_id, ...body }) => call(`/works/${encodeURIComponent(run_id)}/chapters/${episode}/storyboard/segments/${encodeURIComponent(seg_id)}` +
|
|
137
|
+
`/groups/${encodeURIComponent(group_id)}/likeness-reroll`, "likeness_reroll", "POST", body));
|
|
138
|
+
server.tool("job_status", "Check an async job (the job_id returned by flashback_montage, reclone_voice, etc.): status PENDING/RUNNING/DONE/FAILED plus result/error. Poll at most every 10 seconds.", { job_id: z.string() }, async ({ job_id }) => call(`/jobs/${encodeURIComponent(job_id)}`, "job_status"));
|
|
139
|
+
server.tool("upload_character_ref", "Upload an external reference image for a character (e.g. a face-blend face model): registers a variant='ref' asset and uploads the local file. " +
|
|
140
|
+
"From then on the character's anchor portraits use the newest reference as the face reference. " +
|
|
141
|
+
"Staff-only on the server.", {
|
|
142
|
+
character_id: z.string().describe("character id (snake_case)"),
|
|
143
|
+
file_path: z.string().describe("local image path (png/jpg/webp)"),
|
|
144
|
+
note: z.string().optional().describe("note (stored as label_en, e.g. source/purpose)"),
|
|
145
|
+
}, async ({ character_id, file_path, note }) => {
|
|
146
|
+
try {
|
|
147
|
+
const { readFile } = await import("node:fs/promises");
|
|
148
|
+
const data = await readFile(file_path);
|
|
149
|
+
const ext = (file_path.split(".").pop() || "").toLowerCase();
|
|
150
|
+
const ctype = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg",
|
|
151
|
+
webp: "image/webp" }[ext] || "image/png";
|
|
152
|
+
const reg = await apiCall("/assets", {
|
|
153
|
+
method: "POST", tool: "upload_character_ref", agent: AGENT,
|
|
154
|
+
body: {
|
|
155
|
+
type: "character", subject_ref: `char:${character_id}`,
|
|
156
|
+
variant: "ref", category: "ref", style: "real", content_type: ctype,
|
|
157
|
+
...(note ? { label_en: note } : {}),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
const put = await fetch(reg.upload_url, {
|
|
161
|
+
method: "PUT", headers: { "content-type": ctype }, body: data,
|
|
162
|
+
});
|
|
163
|
+
if (!put.ok)
|
|
164
|
+
throw new Error(`S3 upload failed: HTTP ${put.status}`);
|
|
165
|
+
return ok({ asset_id: reg.asset_id, key: reg.key, uploaded: true });
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
return fail(e);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
73
171
|
// ---- 签收与交付(TQ 2026-08-31:Review 不自动绿,人签字才算) ----------------
|
|
74
|
-
server.tool("signoff_episode", "
|
|
75
|
-
"(signed/total/all_signed)
|
|
76
|
-
"
|
|
77
|
-
server.tool("
|
|
78
|
-
"
|
|
172
|
+
server.tool("signoff_episode", "Sign off one episode (a gate action: sign only after watching the finished episode; publishing and delivery both require sign-off). The response carries series progress " +
|
|
173
|
+
"(signed/total/all_signed) — when all_signed=true, **ask the user** whether to build the full delivery package, " +
|
|
174
|
+
"and call build_delivery_pack only after they confirm; otherwise stop, never package on your own. Pass revoke=true to withdraw a sign-off.", { run_id: z.string(), episode: z.number().int(), revoke: z.boolean().optional() }, async ({ run_id, episode, revoke }) => call(`/works/${encodeURIComponent(run_id)}/chapters/${episode}/signoff`, "signoff_episode", "POST", revoke ? { revoke: true } : {}));
|
|
175
|
+
server.tool("regen_cover", "Regenerate **one** episode's cover (a cover is produced by default at sign-off; call this only when the user dislikes it). Always regenerates; " +
|
|
176
|
+
"publishing picks the newest image automatically. Costs one art reroll.", { run_id: z.string(), episode: z.number().int() }, async ({ run_id, episode }) => call(`/works/${encodeURIComponent(run_id)}/chapters/${episode}/cover/regen`, "regen_cover", "POST", {}));
|
|
177
|
+
server.tool("build_delivery_pack", "Build the full-series delivery package (masters / clean masters / SRT / covers, packaged per episode asynchronously, takes minutes). Call only after the user " +
|
|
178
|
+
"explicitly confirms — usually the follow-up question after signoff_episode returns all_signed.", { run_id: z.string() }, async ({ run_id }) => call(`/works/${encodeURIComponent(run_id)}/delivery-package`, "build_delivery_pack", "POST", {}));
|
|
79
179
|
// ---- 账面 ------------------------------------------------------------------
|
|
80
|
-
server.tool("credits_balance", "
|
|
180
|
+
server.tool("credits_balance", "Credits balance and free allowance, plus usage.by_source (net spend / count per console vs each agent name) and usage.by_token (per PAT); entries list each charge with source/token_id/tool.", async () => call("/credits", "credits_balance"));
|
|
81
181
|
// ---- 人工审核动线(前提 5:console = 审核/裁决面) ---------------------------
|
|
82
|
-
server.tool("get_review_url", "
|
|
182
|
+
server.tool("get_review_url", "Return a console deep link for a human to do the visual review and decisions in the browser (pick images, review footage, approve). Makes no API request. Giving the user this link before any approve_* is the recommended flow.", { run_id: z.string() }, async ({ run_id }) => ok({
|
|
83
183
|
url: `${consoleBase()}/#run-wizard/${encodeURIComponent(run_id)}`,
|
|
84
|
-
note: "
|
|
184
|
+
note: "Open it in a browser (console sign-in required); an agent should not and cannot make visual decisions on the user's behalf.",
|
|
85
185
|
}));
|
|
86
186
|
return server;
|
|
87
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dawnwood/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Dawnwood for agents — CLI + MCP server. Your agent drives the full short-drama pipeline (bible → scripts → pack → renders) against console.dawnwood.ai.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|