@dawnwood/cli 0.3.1 → 0.6.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 +3 -0
- package/dist/bridge.js +80 -0
- package/dist/mcp.js +31 -1
- package/dist/ops.js +115 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,9 @@ npx @dawnwood/cli whoami
|
|
|
34
34
|
| Storyboard tools | `flashback_montage`, `reclone_voice`, `likeness_reroll`, `import_clip`, `job_status` |
|
|
35
35
|
| Sign-off and delivery | `signoff_episode`, `build_delivery_pack` |
|
|
36
36
|
| Account | `credits_balance`, `get_review_url` |
|
|
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` |
|
|
37
40
|
|
|
38
41
|
Poll with `get_run`, `art_status` or `job_status`, no more than every 10 seconds.
|
|
39
42
|
`list_runs` is for browsing, not polling. Approvals are gate actions: give the
|
package/dist/bridge.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { apiCall } from "./api.js";
|
|
3
|
+
const USER_MESSAGE = "The user's latest message, verbatim. Required for tools that spend credits: it is how the server knows the user asked for this, and a new message is what lets a retry through after two failed attempts on the same target.";
|
|
4
|
+
/** JSON schema(服务端工具定义的子集)→ zod。不认识的形状一律放宽成 unknown,由服务端校验。 */
|
|
5
|
+
export function toZod(s) {
|
|
6
|
+
if (!s)
|
|
7
|
+
return z.unknown();
|
|
8
|
+
const t = Array.isArray(s.type) ? s.type.find((x) => x !== "null") : s.type;
|
|
9
|
+
let out;
|
|
10
|
+
if (s.enum && s.enum.length && s.enum.every((x) => typeof x === "string")) {
|
|
11
|
+
out = z.enum(s.enum);
|
|
12
|
+
}
|
|
13
|
+
else if (t === "string")
|
|
14
|
+
out = z.string();
|
|
15
|
+
else if (t === "integer")
|
|
16
|
+
out = z.number().int();
|
|
17
|
+
else if (t === "number")
|
|
18
|
+
out = z.number();
|
|
19
|
+
else if (t === "boolean")
|
|
20
|
+
out = z.boolean();
|
|
21
|
+
else if (t === "array")
|
|
22
|
+
out = z.array(toZod(s.items));
|
|
23
|
+
else if (t === "object")
|
|
24
|
+
out = s.properties ? z.object(toShape(s)).passthrough() : z.record(z.string(), z.unknown());
|
|
25
|
+
else
|
|
26
|
+
out = z.unknown();
|
|
27
|
+
if (Array.isArray(s.type) && s.type.includes("null"))
|
|
28
|
+
out = out.nullable();
|
|
29
|
+
return s.description ? out.describe(s.description) : out;
|
|
30
|
+
}
|
|
31
|
+
export function toShape(s) {
|
|
32
|
+
const req = new Set(s.required || []);
|
|
33
|
+
const shape = {};
|
|
34
|
+
for (const [k, v] of Object.entries(s.properties || {})) {
|
|
35
|
+
shape[k] = req.has(k) ? toZod(v) : toZod(v).optional();
|
|
36
|
+
}
|
|
37
|
+
return shape;
|
|
38
|
+
}
|
|
39
|
+
/** 注册本地还没有的工具(重名的保留本地定义)。返回实际注册的名字。 */
|
|
40
|
+
export function registerBridgeTools(server, tools, agent) {
|
|
41
|
+
const added = [];
|
|
42
|
+
for (const t of tools) {
|
|
43
|
+
const shape = { ...toShape(t.input_schema || {}), user_message: z.string().optional().describe(USER_MESSAGE) };
|
|
44
|
+
const desc = `${t.description}${t.spends ? " Spends credits: pass user_message." : ""}`;
|
|
45
|
+
try {
|
|
46
|
+
server.tool(t.name, desc, shape, async (args) => {
|
|
47
|
+
const { user_message, ...input } = args;
|
|
48
|
+
try {
|
|
49
|
+
const r = await apiCall(`/agent/tools/${encodeURIComponent(t.name)}`, {
|
|
50
|
+
method: "POST", tool: t.name, agent, body: { input, ...(user_message ? { user_message } : {}) },
|
|
51
|
+
});
|
|
52
|
+
const link = r.card && r.card.url ? `\n${r.card.label || "Link"}: ${r.card.url}` : "";
|
|
53
|
+
return { content: [{ type: "text", text: `${r.result ?? ""}${link}` }], ...(r.error ? { isError: true } : {}) };
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
return { content: [{ type: "text", text: e instanceof Error ? e.message : String(e) }], isError: true };
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
added.push(t.name);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// 已由本地定义的同名工具(list_runs 等)—— 保留本地版本
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return added;
|
|
66
|
+
}
|
|
67
|
+
/** 拉服务端工具清单;没登录/网络失败 → 空(MCP 照常起,只少这一组)。 */
|
|
68
|
+
export async function fetchAgentTools(agent, timeoutMs = 8000) {
|
|
69
|
+
try {
|
|
70
|
+
const r = await Promise.race([
|
|
71
|
+
apiCall("/agent/tools", { tool: "agent_tools", agent }),
|
|
72
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error("timeout")), timeoutMs)),
|
|
73
|
+
]);
|
|
74
|
+
return Array.isArray(r?.tools) ? r.tools : [];
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
process.stderr.write(`dawnwood: review tools unavailable (${e instanceof Error ? e.message : String(e)}) — the static tools still work\n`);
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
package/dist/mcp.js
CHANGED
|
@@ -13,6 +13,8 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import { apiCall } from "./api.js";
|
|
15
15
|
import { CONSOLE_BASE_DEFAULT, getApiBase } from "./config.js";
|
|
16
|
+
import { registerOpsTools } from "./ops.js";
|
|
17
|
+
import { fetchAgentTools, registerBridgeTools } from "./bridge.js";
|
|
16
18
|
const AGENT = process.env.DAWNWOOD_AGENT || "mcp";
|
|
17
19
|
function consoleBase() {
|
|
18
20
|
return process.env.DAWNWOOD_CONSOLE_BASE ||
|
|
@@ -34,7 +36,7 @@ async function call(path, tool, method, body) {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
export function buildServer() {
|
|
37
|
-
const server = new McpServer({ name: "dawnwood", version: "0.
|
|
39
|
+
const server = new McpServer({ name: "dawnwood", version: "0.6.0" });
|
|
38
40
|
// ---- runs 生命周期 ---------------------------------------------------------
|
|
39
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"));
|
|
40
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"));
|
|
@@ -48,11 +50,24 @@ export function buildServer() {
|
|
|
48
50
|
compliance_ack: z.boolean().describe("confirms no real-person likeness and no third-party IP; must be true"),
|
|
49
51
|
episodes: z.number().int().optional()
|
|
50
52
|
.describe("episode count (operator privilege: the server requires OPS permission and 6–120; omit = 10)"),
|
|
53
|
+
lead_actor_id: z.string().optional()
|
|
54
|
+
.describe("optional: id of a reusable actor (your roster or the shared library) who must play the lead"),
|
|
55
|
+
lead_name: z.string().optional().describe("optional: the lead's name, used to match the role"),
|
|
56
|
+
parent: z.object({
|
|
57
|
+
wid: z.string().describe("id of one of your existing shows"),
|
|
58
|
+
inherit: z.object({
|
|
59
|
+
world: z.boolean().optional(), scenes: z.boolean().optional(), props: z.boolean().optional(),
|
|
60
|
+
characters: z.array(z.string()).optional().describe("character ids that return (same face, voice, looks)"),
|
|
61
|
+
}).optional(),
|
|
62
|
+
exclude_note: z.string().optional().describe("what must NOT carry over"),
|
|
63
|
+
}).optional().describe("optional: make a spinoff in the same universe as one of your shows"),
|
|
51
64
|
}, async (a) => call("/runs", "create_run", "POST", {
|
|
52
65
|
id: a.run_id, titles: a.titles, primary_locale: a.primary_locale,
|
|
53
66
|
premise: a.premise, lang: a.lang, render_style: a.render_style,
|
|
54
67
|
compliance_ack: a.compliance_ack,
|
|
55
68
|
...(a.episodes != null ? { episodes: a.episodes } : {}),
|
|
69
|
+
...(a.parent ? { parent: a.parent } : {}),
|
|
70
|
+
...(a.lead_actor_id ? { cast_pins: [{ actor_id: a.lead_actor_id, ...(a.lead_name ? { name: a.lead_name } : {}) }] } : {}),
|
|
56
71
|
}));
|
|
57
72
|
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"));
|
|
58
73
|
// ---- 圣经(Step 2) ---------------------------------------------------------
|
|
@@ -176,6 +191,17 @@ export function buildServer() {
|
|
|
176
191
|
"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
192
|
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
193
|
"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", {}));
|
|
194
|
+
// ---- 整剧版本(2026-10-03 版本模型第一版)----------------------------------
|
|
195
|
+
// 版本 = 用已出镜头重排 / 重新分集 / 压缩 / 字卡 / 补拍出来的整剧剪辑;原版(v0)和旧版本永远不动,改 = 另存新版本。
|
|
196
|
+
server.tool("list_versions", "List this series' versions: v0 is the original episodes; v1, v2… are re-edits built from already-rendered footage. Each has notes (what changed and why), per-episode build status/duration and a timeline showing which original episode/group every piece comes from. Read before creating a new one.", { run_id: z.string() }, async ({ run_id }) => call(`/works/${encodeURIComponent(run_id)}/versions`, "list_versions"));
|
|
197
|
+
server.tool("version_inventory", "The parts list for a new version: every rendered group of the given episodes — ep, seg, gid, start/end inside the segment cut, position in the original episode, beats and spoken lines. eps like '1-5' or '1,3,901' (901+ are patch-shot episodes). Build version specs only from these ids.", { run_id: z.string(), eps: z.string().default("1-5") }, async ({ run_id, eps }) => call(`/works/${encodeURIComponent(run_id)}/versions/inventory?eps=${encodeURIComponent(eps)}`, "version_inventory"));
|
|
198
|
+
server.tool("create_version", "Create a NEW version from existing footage and queue its cloud build (free; minutes per episode). spec = {title, notes, episodes:[{title, hook, notes, items:[{kind:'clip', ep, gid, trim_head?, trim_tail?} | {kind:'clip', ep, seg, from, to} | {kind:'card', text, secs 0.5–6}]}], then_original_from? (continue with original episode N after these)}. Keep episodes 60–110 s, end each on a hook, keep continuity. The original and older versions are never changed.", { run_id: z.string(), spec: z.record(z.string(), z.unknown()), based_on: z.string().optional() }, async ({ run_id, spec, based_on }) => call(`/works/${encodeURIComponent(run_id)}/versions`, "create_version", "POST", { spec, based_on: based_on || "", build: true }));
|
|
199
|
+
server.tool("build_version", "Re-run the cloud build of a version (all episodes or eps:[n…]) — after a failed build, or once a patch shot it uses is ready. Poll with list_versions at most every 30 s.", { run_id: z.string(), version_id: z.string(), eps: z.array(z.number().int()).optional() }, async ({ run_id, version_id, eps }) => call(`/works/${encodeURIComponent(run_id)}/versions/${encodeURIComponent(version_id)}/build`, "build_version", "POST", { eps: eps || null }));
|
|
200
|
+
server.tool("patch_shot", "Shoot a NEW group a version needs but the footage lacks (a character entrance, a bridge, a key reaction). Renders in a hidden patch episode (901+) next to an anchor group of the original, inheriting its scene/outfits/staging — the original episode is not changed. shots = [{desc, blocking, dialogue?, cast[] (ids from version_inventory), duration ≤8}], ≤15 s total; for a shot with no dialogue add 'AUDIO: quiet room tone only — no music' to blocking. Costs render credits. When ready, reference it as {kind:'clip', ep:<patch_ep>, gid:<group_id>}.", {
|
|
201
|
+
run_id: z.string(), ep: z.number().int(), gid: z.string(),
|
|
202
|
+
position: z.enum(["after", "before"]).default("after"),
|
|
203
|
+
shots: z.array(z.record(z.string(), z.unknown())), note: z.string().optional(),
|
|
204
|
+
}, async (a) => call(`/works/${encodeURIComponent(a.run_id)}/versions/patch`, "patch_shot", "POST", { ep: a.ep, gid: a.gid, position: a.position, shots: a.shots, note: a.note || "" }));
|
|
179
205
|
// ---- 账面 ------------------------------------------------------------------
|
|
180
206
|
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"));
|
|
181
207
|
// ---- 人工审核动线(前提 5:console = 审核/裁决面) ---------------------------
|
|
@@ -183,10 +209,14 @@ export function buildServer() {
|
|
|
183
209
|
url: `${consoleBase()}/#run-wizard/${encodeURIComponent(run_id)}`,
|
|
184
210
|
note: "Open it in a browser (console sign-in required); an agent should not and cannot make visual decisions on the user's behalf.",
|
|
185
211
|
}));
|
|
212
|
+
// ---- Operations(Clips + Matrix,TQ 2026-10-11:本地 agent 也能做运营)----------------
|
|
213
|
+
registerOpsTools(server, call, ok, fail, AGENT);
|
|
186
214
|
return server;
|
|
187
215
|
}
|
|
188
216
|
export async function runMcp() {
|
|
189
217
|
const server = buildServer();
|
|
218
|
+
// 看片返工那组工具从服务端内嵌 agent 拉(规矩随服务端更新);拉不到也照常起
|
|
219
|
+
registerBridgeTools(server, await fetchAgentTools(AGENT), AGENT);
|
|
190
220
|
const transport = new StdioServerTransport();
|
|
191
221
|
await server.connect(transport);
|
|
192
222
|
// stdio server:进程由客户端(Claude Code 等)托管,直到 stdin 关闭。
|
package/dist/ops.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operations 面的 MCP 工具(TQ 2026-10-11:「Operation 这边也要有 API、Agent 和 MCP,这样本地 agent 能操作」)。
|
|
3
|
+
*
|
|
4
|
+
* Clips(切片任务)+ Matrix(号 / lane / 素材库 / 排期 / 读数)+ 本地视频上传。和 runs 那组一样是薄代理:
|
|
5
|
+
* 业务、校验、计费全在服务端(/v1/clips/*、/v1/matrix/*),这里只拼请求。
|
|
6
|
+
*
|
|
7
|
+
* 轮询纪律:clips_get_job 是查单个任务的正确工具,间隔 ≥10 秒;不要拿 list 类工具轮询。
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync, statSync } from "node:fs";
|
|
10
|
+
import { basename, extname } from "node:path";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { apiCall } from "./api.js";
|
|
13
|
+
const enc = encodeURIComponent;
|
|
14
|
+
const MAX_UPLOAD_BYTES = 1024 * 1024 * 1024;
|
|
15
|
+
function qs(params) {
|
|
16
|
+
const p = Object.entries(params).filter(([, v]) => v !== undefined && v !== "").map(([k, v]) => `${k}=${enc(String(v))}`);
|
|
17
|
+
return p.length ? `?${p.join("&")}` : "";
|
|
18
|
+
}
|
|
19
|
+
/** 本地 mp4/mov → POST /assets 拿预签名 → PUT 上传 → asset_id(给 clips_create 或 matrix_add_media 用)。 */
|
|
20
|
+
export async function uploadVideo(path, agent, fetchImpl = fetch) {
|
|
21
|
+
const ext = extname(path).toLowerCase();
|
|
22
|
+
const ct = ext === ".mp4" ? "video/mp4" : ext === ".mov" ? "video/quicktime" : "";
|
|
23
|
+
if (!ct)
|
|
24
|
+
throw new Error("only .mp4 or .mov files can be uploaded");
|
|
25
|
+
const size = statSync(path).size;
|
|
26
|
+
if (!size)
|
|
27
|
+
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) } });
|
|
32
|
+
if (!reg?.upload_url || !reg.asset_id)
|
|
33
|
+
throw new Error("the server did not return an upload URL");
|
|
34
|
+
const put = await fetchImpl(reg.upload_url, { method: "PUT", headers: { "content-type": ct }, body: readFileSync(path) });
|
|
35
|
+
if (!put.ok)
|
|
36
|
+
throw new Error(`upload failed (HTTP ${put.status}) — retry`);
|
|
37
|
+
return { asset_id: reg.asset_id, bytes: size, name: basename(path) };
|
|
38
|
+
}
|
|
39
|
+
export function registerOpsTools(server, call, ok, fail, agent) {
|
|
40
|
+
// ---- 上传 -----------------------------------------------------------------
|
|
41
|
+
server.tool("upload_video", "Upload a local .mp4/.mov (≤1 GB) to your workspace and return its asset_id. Use it as the source of clips_create ({kind:'upload', asset_id}) or register it in the Matrix library with matrix_add_media.", { path: z.string().describe("absolute path of a local video file") }, async ({ path }) => { try {
|
|
42
|
+
return ok(await uploadVideo(path, agent));
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
return fail(e);
|
|
46
|
+
} });
|
|
47
|
+
// ---- Clips ----------------------------------------------------------------
|
|
48
|
+
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
|
+
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"));
|
|
50
|
+
server.tool("clips_create", "Start a clip job: vertical clips with pop captions and an end card, picked for conflict/reveal/hook moments, no spoilers. Source is either {kind:'series', work_id, chapters:[…≤12]} (your own Dawnwood series) or {kind:'upload', asset_id, name} (any video people talk in, ≤60 min; landscape becomes vertical). Charged once the source is ready: 1 cr per started source minute, 3 cr minimum; refunded in full if no clip comes out. Poll with clips_get_job every ≥10 s.", {
|
|
51
|
+
source: z.object({
|
|
52
|
+
kind: z.enum(["series", "upload"]),
|
|
53
|
+
work_id: z.string().optional(), chapters: z.array(z.number().int()).optional(),
|
|
54
|
+
asset_id: z.string().optional(), name: z.string().optional(),
|
|
55
|
+
}),
|
|
56
|
+
durations: z.array(z.tuple([z.number(), z.number()])).optional().describe("clip length range in seconds, e.g. [[20, 50]] (default)"),
|
|
57
|
+
captions: z.enum(["pop", "plain", "none"]).default("pop"),
|
|
58
|
+
end_card: z.object({
|
|
59
|
+
text: z.string().optional().describe("end card headline, default 'Watch the full series'"),
|
|
60
|
+
link: z.string().optional().describe("readable URL burned into the end card; empty = no end card"),
|
|
61
|
+
lane_id: z.string().optional().describe("Matrix lane the clips are meant for (default target of clips_send_to_matrix)"),
|
|
62
|
+
}).optional(),
|
|
63
|
+
}, async (a) => call("/v1/clips/jobs", "clips_create", "POST", a));
|
|
64
|
+
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.", {
|
|
66
|
+
job_id: z.string(), clip_id: z.string(),
|
|
67
|
+
kept: z.boolean().optional(), title: z.string().optional(),
|
|
68
|
+
captions: z.enum(["pop", "plain", "none"]).optional(),
|
|
69
|
+
nudge_start: z.number().int().optional(), nudge_end: z.number().int().optional(),
|
|
70
|
+
}, async ({ job_id, clip_id, ...body }) => call(`/v1/clips/jobs/${enc(job_id)}/clips/${enc(clip_id)}`, "clips_edit_clip", "PATCH", body));
|
|
71
|
+
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
|
+
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 } : {}));
|
|
73
|
+
// ---- Matrix:号与 lane -----------------------------------------------------
|
|
74
|
+
server.tool("matrix_status", "Whether Matrix is enabled for your workspace, platforms, default caps and posting windows.", async () => call("/v1/matrix", "matrix_status"));
|
|
75
|
+
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"));
|
|
76
|
+
server.tool("matrix_update_account", "Change one account's Matrix settings: lane_id, group_id, stage, paused (pausing stops its scheduled posts from going out and stops Autopilot from scheduling it).", {
|
|
77
|
+
key: z.string().describe("'<platform>:<account_id>' from matrix_accounts"),
|
|
78
|
+
lane_id: z.string().nullable().optional(), group_id: z.string().nullable().optional(),
|
|
79
|
+
stage: z.enum(["warming", "testing", "scaling", "retired"]).optional(), paused: z.boolean().optional(),
|
|
80
|
+
}, async ({ key, ...body }) => call(`/v1/matrix/accounts/${enc(key)}`, "matrix_update_account", "PATCH", body));
|
|
81
|
+
server.tool("matrix_lanes", "Your lanes (one niche + one tracked link + posting policy + Autopilot settings each).", async () => call("/v1/matrix/lanes", "matrix_lanes"));
|
|
82
|
+
server.tool("matrix_update_lane", "Edit a lane: name, link, lang, work_id, policy {daily_cap{platform:n}, windows['HH:MM'], tz, jitter_min, dedupe_days, caption_template, first_comment} (merged field by field), autopilot {on, show_link, slots{platform:'HH:MM'}, per_day}.", {
|
|
83
|
+
lane_id: z.string(),
|
|
84
|
+
name: z.string().optional(), link: z.string().optional(), lang: z.string().optional(), work_id: z.string().nullable().optional(),
|
|
85
|
+
policy: z.record(z.string(), z.unknown()).optional(), autopilot: z.record(z.string(), z.unknown()).optional(),
|
|
86
|
+
}, async ({ lane_id, ...body }) => call(`/v1/matrix/lanes/${enc(lane_id)}`, "matrix_update_lane", "PATCH", body));
|
|
87
|
+
// ---- Matrix:素材与排期 ----------------------------------------------------
|
|
88
|
+
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.", {
|
|
90
|
+
asset_id: z.string().optional(), title: z.string().optional(), hook: z.string().optional(), lane_id: z.string().optional(),
|
|
91
|
+
work_id: z.string().optional(), chapter: z.number().int().optional(),
|
|
92
|
+
}, async (a) => call("/v1/matrix/media", "matrix_add_media", "POST", a));
|
|
93
|
+
const scheduleShape = {
|
|
94
|
+
items: z.array(z.object({
|
|
95
|
+
media_id: z.string(), account: z.string().optional().describe("'<platform>:<account_id>'"),
|
|
96
|
+
group: z.string().optional().describe("account group id instead of account: posts to every member"),
|
|
97
|
+
at: z.string().optional().describe("ISO UTC time; omitted = next free window"), caption: z.string().optional(),
|
|
98
|
+
})),
|
|
99
|
+
auto_resolve: z.boolean().default(true).describe("swap duplicate footage for an unused clip and move over-cap posts to the next free window"),
|
|
100
|
+
tiktok: z.object({
|
|
101
|
+
privacy_level: z.string(), disable_comment: z.boolean().optional(), disable_duet: z.boolean().optional(),
|
|
102
|
+
disable_stitch: z.boolean().optional(), consent: z.boolean().describe("the account owner agreed to TikTok's music/branded-content terms"),
|
|
103
|
+
}).optional().describe("required when any item posts to TikTok"),
|
|
104
|
+
};
|
|
105
|
+
server.tool("matrix_plan_posts", "Dry-run a batch of posts (nothing is saved): each item comes back ok / shifted / swapped / blocked with a reason, plus a summary and warnings (comment permission, token expiry, TikTok consent). Always plan before matrix_schedule_posts.", scheduleShape, async (a) => call("/v1/matrix/posts/plan", "matrix_plan_posts", "POST", a));
|
|
106
|
+
server.tool("matrix_schedule_posts", "Save a batch of posts (same body as matrix_plan_posts plus client_token for safe retries and skip_blocked). Fails with 409 and the plan when anything is blocked unless skip_blocked=true. Posts go out from the accounts themselves at their times.", { ...scheduleShape, client_token: z.string().describe("any unique string; replaying it never double-schedules"), skip_blocked: z.boolean().default(false) }, async (a) => call("/v1/matrix/posts", "matrix_schedule_posts", "POST", a));
|
|
107
|
+
server.tool("matrix_posts", "Your posts in a time window (ISO since/until), optionally filtered by status, lane or account. Includes posts scheduled by Autopilot and the publishing pipeline.", {
|
|
108
|
+
since: z.string().optional(), until: z.string().optional(),
|
|
109
|
+
status: z.string().optional(), lane: z.string().optional(), account: z.string().optional(),
|
|
110
|
+
}, async (a) => call(`/v1/matrix/posts${qs(a)}`, "matrix_posts"));
|
|
111
|
+
server.tool("matrix_cancel_post", "Cancel a post that hasn't started going out (a scheduled YouTube video is deleted). Already published posts must be removed on the platform.", { post_id: z.string() }, async ({ post_id }) => call(`/v1/matrix/posts/${enc(post_id)}`, "matrix_cancel_post", "DELETE"));
|
|
112
|
+
server.tool("matrix_comments", "Latest comments (≤25) on one published Facebook/Instagram post plus the first-comment status.", { post_id: z.string() }, async ({ post_id }) => call(`/v1/matrix/posts/${enc(post_id)}/comments`, "matrix_comments"));
|
|
113
|
+
// ---- Matrix:读数 ----------------------------------------------------------
|
|
114
|
+
server.tool("matrix_report", "Performance over the last `days` (default 7) vs the prior period: views, link taps, visits, purchases, revenue, per-account verdicts (scale/keep/kill/warming/check) against each account's own baseline and its lane, and the lane × platform grid.", { days: z.number().int().min(1).max(30).default(7) }, async ({ days }) => call(`/v1/matrix/report${qs({ days })}`, "matrix_report"));
|
|
115
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dawnwood/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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",
|