@dawnwood/cli 0.6.0 → 0.7.0
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 +2 -2
- package/dist/mcp.js +1 -1
- package/dist/ops.js +26 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,8 +35,8 @@ npx @dawnwood/cli whoami
|
|
|
35
35
|
| Sign-off and delivery | `signoff_episode`, `build_delivery_pack` |
|
|
36
36
|
| Account | `credits_balance`, `get_review_url` |
|
|
37
37
|
| Review & rework | loaded at startup from the console agent: `render_status`, `update_shot`, `render_shot`, `rerender_group`, `retake_range`, `propose_fix`, `adopt_take`, … (spending tools need `user_message`) |
|
|
38
|
-
| Clips | `upload_video`, `clips_create`, `clips_get_job`, `clips_edit_clip`, `clips_send_to_matrix`, `clips_list_jobs`, `clips_series_episodes`, `clips_retry` |
|
|
39
|
-
| Matrix (posting) | `matrix_status`, `matrix_accounts`, `matrix_update_account`, `matrix_lanes`, `matrix_update_lane`, `matrix_media`, `matrix_add_media`, `matrix_plan_posts`, `matrix_schedule_posts`, `matrix_posts`, `matrix_cancel_post`, `matrix_comments`, `matrix_report` |
|
|
38
|
+
| Clips | `upload_video`, `upload_image`, `clips_create`, `clips_get_job`, `clips_edit_clip`, `clips_send_to_matrix`, `clips_list_jobs`, `clips_series_episodes`, `clips_retry` |
|
|
39
|
+
| Matrix (posting) | `matrix_status`, `matrix_accounts`, `matrix_update_account`, `matrix_lanes`, `matrix_update_lane`, `matrix_media`, `matrix_add_media`, `matrix_update_media`, `matrix_plan_posts`, `matrix_schedule_posts`, `matrix_posts`, `matrix_cancel_post`, `matrix_comments`, `matrix_report` |
|
|
40
40
|
|
|
41
41
|
Poll with `get_run`, `art_status` or `job_status`, no more than every 10 seconds.
|
|
42
42
|
`list_runs` is for browsing, not polling. Approvals are gate actions: give the
|
package/dist/mcp.js
CHANGED
|
@@ -36,7 +36,7 @@ async function call(path, tool, method, body) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export function buildServer() {
|
|
39
|
-
const server = new McpServer({ name: "dawnwood", version: "0.
|
|
39
|
+
const server = new McpServer({ name: "dawnwood", version: "0.7.0" });
|
|
40
40
|
// ---- runs 生命周期 ---------------------------------------------------------
|
|
41
41
|
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"));
|
|
42
42
|
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"));
|
package/dist/ops.js
CHANGED
|
@@ -16,19 +16,25 @@ function qs(params) {
|
|
|
16
16
|
const p = Object.entries(params).filter(([, v]) => v !== undefined && v !== "").map(([k, v]) => `${k}=${enc(String(v))}`);
|
|
17
17
|
return p.length ? `?${p.join("&")}` : "";
|
|
18
18
|
}
|
|
19
|
+
const VIDEO_TYPES = { ".mp4": "video/mp4", ".mov": "video/quicktime" };
|
|
20
|
+
const IMAGE_TYPES = { ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".png": "image/png" };
|
|
19
21
|
/** 本地 mp4/mov → POST /assets 拿预签名 → PUT 上传 → asset_id(给 clips_create 或 matrix_add_media 用)。 */
|
|
20
22
|
export async function uploadVideo(path, agent, fetchImpl = fetch) {
|
|
23
|
+
return uploadFile(path, "video", agent, fetchImpl);
|
|
24
|
+
}
|
|
25
|
+
/** 本地文件(视频或封面图)直传 → asset_id。 */
|
|
26
|
+
export async function uploadFile(path, kind, agent, fetchImpl = fetch) {
|
|
21
27
|
const ext = extname(path).toLowerCase();
|
|
22
|
-
const ct =
|
|
28
|
+
const ct = (kind === "video" ? VIDEO_TYPES : IMAGE_TYPES)[ext] || "";
|
|
23
29
|
if (!ct)
|
|
24
|
-
throw new Error("only .mp4 or .mov files can be uploaded");
|
|
30
|
+
throw new Error(kind === "video" ? "only .mp4 or .mov files can be uploaded" : "only .jpg or .png images can be uploaded");
|
|
25
31
|
const size = statSync(path).size;
|
|
26
32
|
if (!size)
|
|
27
33
|
throw new Error("the file is empty");
|
|
28
|
-
if (size > MAX_UPLOAD_BYTES)
|
|
29
|
-
throw new Error(`the file is ${(size / 1e6).toFixed(0)} MB —
|
|
30
|
-
const reg = await apiCall("/assets", { method: "POST", tool: "upload_video", agent, fetchImpl,
|
|
31
|
-
body: { type:
|
|
34
|
+
if (size > (kind === "video" ? MAX_UPLOAD_BYTES : 20 * 1024 * 1024))
|
|
35
|
+
throw new Error(`the file is ${(size / 1e6).toFixed(0)} MB — too large`);
|
|
36
|
+
const reg = await apiCall("/assets", { method: "POST", tool: kind === "video" ? "upload_video" : "upload_image", agent, fetchImpl,
|
|
37
|
+
body: { type: kind, subject_ref: `tool:${kind}`, content_type: ct, label_en: basename(path) } });
|
|
32
38
|
if (!reg?.upload_url || !reg.asset_id)
|
|
33
39
|
throw new Error("the server did not return an upload URL");
|
|
34
40
|
const put = await fetchImpl(reg.upload_url, { method: "PUT", headers: { "content-type": ct }, body: readFileSync(path) });
|
|
@@ -44,6 +50,12 @@ export function registerOpsTools(server, call, ok, fail, agent) {
|
|
|
44
50
|
catch (e) {
|
|
45
51
|
return fail(e);
|
|
46
52
|
} });
|
|
53
|
+
server.tool("upload_image", "Upload a local .jpg/.png (≤20 MB) and return its asset_id — e.g. a cover for clips_edit_clip or matrix_update_media.", { path: z.string().describe("absolute path of a local image file") }, async ({ path }) => { try {
|
|
54
|
+
return ok(await uploadFile(path, "image", agent));
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return fail(e);
|
|
58
|
+
} });
|
|
47
59
|
// ---- Clips ----------------------------------------------------------------
|
|
48
60
|
server.tool("clips_list_jobs", "List your clip jobs (newest first, summary only) and the price: per_min cr per started source minute, min cr per job, max upload minutes.", async () => call("/v1/clips/jobs", "clips_list_jobs"));
|
|
49
61
|
server.tool("clips_series_episodes", "For a series you own: the finished episodes you can clip, with each episode's length in seconds (to estimate cost: 1 cr per started minute, 3 cr minimum).", { work_id: z.string() }, async ({ work_id }) => call(`/v1/clips/series/${enc(work_id)}`, "clips_series_episodes"));
|
|
@@ -62,11 +74,12 @@ export function registerOpsTools(server, call, ok, fail, agent) {
|
|
|
62
74
|
}).optional(),
|
|
63
75
|
}, async (a) => call("/v1/clips/jobs", "clips_create", "POST", a));
|
|
64
76
|
server.tool("clips_get_job", "One clip job with every clip: start/end (source seconds), title, opening hook line, why it was picked, score, spoiler flag, kept, status, and 1-hour playback URLs. The right tool for polling (every ≥10 s).", { job_id: z.string() }, async ({ job_id }) => call(`/v1/clips/jobs/${enc(job_id)}`, "clips_get_job"));
|
|
65
|
-
server.tool("clips_edit_clip", "Edit one clip: kept (keep or drop), title, captions ('pop'|'plain'|'none'), nudge_start / nudge_end (move the cut by whole lines, e.g. -1 or 1). Changing the cut or captions re-renders the clip for free.", {
|
|
77
|
+
server.tool("clips_edit_clip", "Edit one clip: kept (keep or drop), title, captions ('pop'|'plain'|'none'), nudge_start / nudge_end (move the cut by whole lines, e.g. -1 or 1), cover_asset_id (your own cover from upload_image; null = back to the automatic cover). Changing the cut or captions re-renders the clip for free. The cover is used as the IG cover, FB opening frame, TikTok cover frame and YouTube thumbnail.", {
|
|
66
78
|
job_id: z.string(), clip_id: z.string(),
|
|
67
79
|
kept: z.boolean().optional(), title: z.string().optional(),
|
|
68
80
|
captions: z.enum(["pop", "plain", "none"]).optional(),
|
|
69
81
|
nudge_start: z.number().int().optional(), nudge_end: z.number().int().optional(),
|
|
82
|
+
cover_asset_id: z.string().nullable().optional(),
|
|
70
83
|
}, async ({ job_id, clip_id, ...body }) => call(`/v1/clips/jobs/${enc(job_id)}/clips/${enc(clip_id)}`, "clips_edit_clip", "PATCH", body));
|
|
71
84
|
server.tool("clips_retry", "Retry a failed clip job from where it stopped (a job that produced nothing was already refunded and is charged again on retry).", { job_id: z.string() }, async ({ job_id }) => call(`/v1/clips/jobs/${enc(job_id)}/retry`, "clips_retry", "POST", {}));
|
|
72
85
|
server.tool("clips_send_to_matrix", "Put every kept, finished clip of a job into the Matrix library (optionally under lane_id); sending twice does not duplicate. Then schedule them with matrix_plan_posts / matrix_schedule_posts.", { job_id: z.string(), lane_id: z.string().optional() }, async ({ job_id, lane_id }) => call(`/v1/clips/jobs/${enc(job_id)}/send`, "clips_send_to_matrix", "POST", lane_id ? { lane_id } : {}));
|
|
@@ -86,10 +99,15 @@ export function registerOpsTools(server, call, ok, fail, agent) {
|
|
|
86
99
|
}, async ({ lane_id, ...body }) => call(`/v1/matrix/lanes/${enc(lane_id)}`, "matrix_update_lane", "PATCH", body));
|
|
87
100
|
// ---- Matrix:素材与排期 ----------------------------------------------------
|
|
88
101
|
server.tool("matrix_media", "Your Matrix library (uploads, imported episodes, clips sent from Clips), newest first.", async () => call("/v1/matrix/media", "matrix_media"));
|
|
89
|
-
server.tool("matrix_add_media", "Register a video in the Matrix library: {asset_id, title?, hook?, lane_id?} after upload_video, or {work_id, chapter} to import one of your own finished episodes.", {
|
|
102
|
+
server.tool("matrix_add_media", "Register a video in the Matrix library: {asset_id, title?, hook?, lane_id?, cover_asset_id?} after upload_video, or {work_id, chapter} to import one of your own finished episodes.", {
|
|
90
103
|
asset_id: z.string().optional(), title: z.string().optional(), hook: z.string().optional(), lane_id: z.string().optional(),
|
|
104
|
+
cover_asset_id: z.string().optional(),
|
|
91
105
|
work_id: z.string().optional(), chapter: z.number().int().optional(),
|
|
92
106
|
}, async (a) => call("/v1/matrix/media", "matrix_add_media", "POST", a));
|
|
107
|
+
server.tool("matrix_update_media", "Edit a library video: title, hook, lane_id, cover_asset_id (from upload_image; null clears it). The cover goes out with every post of this video: IG cover, FB opening frame, TikTok cover frame, YouTube thumbnail.", {
|
|
108
|
+
media_id: z.string(), title: z.string().optional(), hook: z.string().optional(),
|
|
109
|
+
lane_id: z.string().nullable().optional(), cover_asset_id: z.string().nullable().optional(),
|
|
110
|
+
}, async ({ media_id, ...body }) => call(`/v1/matrix/media/${enc(media_id)}`, "matrix_update_media", "PATCH", body));
|
|
93
111
|
const scheduleShape = {
|
|
94
112
|
items: z.array(z.object({
|
|
95
113
|
media_id: z.string(), account: z.string().optional().describe("'<platform>:<account_id>'"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dawnwood/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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",
|