@dawnwood/cli 0.6.0 → 0.8.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 CHANGED
@@ -35,8 +35,9 @@ 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
+ | Drama Center | `dramacenter_check`, `dramacenter_get`, `dramacenter_update`, `dramacenter_package`, `dramacenter_list` |
40
+ | 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
41
 
41
42
  Poll with `get_run`, `art_status` or `job_status`, no more than every 10 seconds.
42
43
  `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.6.0" });
39
+ const server = new McpServer({ name: "dawnwood", version: "0.8.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 = ext === ".mp4" ? "video/mp4" : ext === ".mov" ? "video/quicktime" : "";
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 — the limit is 1 GB`);
30
- const reg = await apiCall("/assets", { method: "POST", tool: "upload_video", agent, fetchImpl,
31
- body: { type: "video", subject_ref: "tool:video", content_type: ct, label_en: basename(path) } });
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,14 +74,26 @@ 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
+ // ---- Drama Center Ready ---------------------------------------------------
87
+ server.tool("dramacenter_check", "Check a season before uploading it to TikTok Drama Center. source = {kind:'series', work_id} (your own series, every finished episode) or {kind:'upload', assets:[{asset_id, name}]} (from upload_video, ordered by the episode number in the name). level 'light' is free (specs, dark edges = code 4, end-card web text = code 6, subtitle area = code 7, cover frame, metadata); 'full' adds picture safety and story risks for 2 cr per episode. meta = {title <=35, description <=1500, free_preview, genres <=3, audience, creation_type, music_source}. Poll with dramacenter_get every >=10 s.", {
88
+ source: z.object({ kind: z.enum(["series", "upload"]), work_id: z.string().optional(), chapters: z.array(z.number().int()).optional(),
89
+ assets: z.array(z.object({ asset_id: z.string(), name: z.string().optional() })).optional() }),
90
+ level: z.enum(["light", "full"]).default("light"),
91
+ meta: z.record(z.string(), z.unknown()).optional(), poster_asset_id: z.string().optional().describe("9:16 or 3:4 poster from upload_image"),
92
+ }, async (a) => call("/v1/dc/jobs", "dramacenter_check", "POST", a));
93
+ server.tool("dramacenter_get", "One Drama Center check: the verdict, the issue queue (needs you / fixed in the package / advisory / passed, with episodes and timestamps) and, once packaged, 24-hour download links. The right tool for polling (every >=10 s).", { check_id: z.string() }, async ({ check_id }) => call(`/v1/dc/jobs/${enc(check_id)}`, "dramacenter_get"));
94
+ server.tool("dramacenter_update", "Clear items on a Drama Center check: meta {title, description, free_preview, genres, audience, creation_type, music_source}, dismiss '<issue key>' (only after the user has looked and says it's fine), poster_asset_id.", { check_id: z.string(), meta: z.record(z.string(), z.unknown()).optional(), dismiss: z.string().optional(), poster_asset_id: z.string().optional() }, async ({ check_id, ...body }) => call(`/v1/dc/jobs/${enc(check_id)}`, "dramacenter_update", "PATCH", body));
95
+ server.tool("dramacenter_package", "Build the upload package once nothing needs the user: every episode fixed (1 s cover opening, end card cut, edges lifted), renamed 'Episode NN - <title>', plus a 3:4 series cover, manifest.json and a field-by-field upload guide, zipped.", { check_id: z.string() }, async ({ check_id }) => call(`/v1/dc/jobs/${enc(check_id)}/package`, "dramacenter_package", "POST", {}));
96
+ server.tool("dramacenter_list", "Your Drama Center checks (newest first) and the price.", async () => call("/v1/dc/jobs", "dramacenter_list"));
73
97
  // ---- Matrix:号与 lane -----------------------------------------------------
74
98
  server.tool("matrix_status", "Whether Matrix is enabled for your workspace, platforms, default caps and posting windows.", async () => call("/v1/matrix", "matrix_status"));
75
99
  server.tool("matrix_accounts", "Your connected social accounts with their Matrix settings: key '<platform>:<account_id>', lane, group, stage (warming/testing/scaling/retired), paused, per-account permissions (publish/insights/comments) and Instagram token expiry.", async () => call("/v1/matrix/accounts", "matrix_accounts"));
@@ -86,10 +110,15 @@ export function registerOpsTools(server, call, ok, fail, agent) {
86
110
  }, async ({ lane_id, ...body }) => call(`/v1/matrix/lanes/${enc(lane_id)}`, "matrix_update_lane", "PATCH", body));
87
111
  // ---- Matrix:素材与排期 ----------------------------------------------------
88
112
  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.", {
113
+ 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
114
  asset_id: z.string().optional(), title: z.string().optional(), hook: z.string().optional(), lane_id: z.string().optional(),
115
+ cover_asset_id: z.string().optional(),
91
116
  work_id: z.string().optional(), chapter: z.number().int().optional(),
92
117
  }, async (a) => call("/v1/matrix/media", "matrix_add_media", "POST", a));
118
+ 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.", {
119
+ media_id: z.string(), title: z.string().optional(), hook: z.string().optional(),
120
+ lane_id: z.string().nullable().optional(), cover_asset_id: z.string().nullable().optional(),
121
+ }, async ({ media_id, ...body }) => call(`/v1/matrix/media/${enc(media_id)}`, "matrix_update_media", "PATCH", body));
93
122
  const scheduleShape = {
94
123
  items: z.array(z.object({
95
124
  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.6.0",
3
+ "version": "0.8.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",