@dawnwood/cli 0.5.0 → 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 CHANGED
@@ -34,6 +34,7 @@ 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`) |
37
38
  | Clips | `upload_video`, `clips_create`, `clips_get_job`, `clips_edit_clip`, `clips_send_to_matrix`, `clips_list_jobs`, `clips_series_episodes`, `clips_retry` |
38
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` |
39
40
 
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
@@ -14,6 +14,7 @@ import { z } from "zod";
14
14
  import { apiCall } from "./api.js";
15
15
  import { CONSOLE_BASE_DEFAULT, getApiBase } from "./config.js";
16
16
  import { registerOpsTools } from "./ops.js";
17
+ import { fetchAgentTools, registerBridgeTools } from "./bridge.js";
17
18
  const AGENT = process.env.DAWNWOOD_AGENT || "mcp";
18
19
  function consoleBase() {
19
20
  return process.env.DAWNWOOD_CONSOLE_BASE ||
@@ -35,7 +36,7 @@ async function call(path, tool, method, body) {
35
36
  }
36
37
  }
37
38
  export function buildServer() {
38
- const server = new McpServer({ name: "dawnwood", version: "0.5.0" });
39
+ const server = new McpServer({ name: "dawnwood", version: "0.6.0" });
39
40
  // ---- runs 生命周期 ---------------------------------------------------------
40
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"));
41
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"));
@@ -214,6 +215,8 @@ export function buildServer() {
214
215
  }
215
216
  export async function runMcp() {
216
217
  const server = buildServer();
218
+ // 看片返工那组工具从服务端内嵌 agent 拉(规矩随服务端更新);拉不到也照常起
219
+ registerBridgeTools(server, await fetchAgentTools(AGENT), AGENT);
217
220
  const transport = new StdioServerTransport();
218
221
  await server.connect(transport);
219
222
  // stdio server:进程由客户端(Claude Code 等)托管,直到 stdin 关闭。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawnwood/cli",
3
- "version": "0.5.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",