@funny-booth/langley-video-mcp 0.9.0 → 0.11.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/dist/client.js CHANGED
@@ -14,7 +14,13 @@ export const DEFAULT_API_URL = "https://langley.funny-booth.jp/video-agent-api";
14
14
  const base = () => (process.env.LANGLEY_VIDEO_API_URL ?? DEFAULT_API_URL).replace(/\/$/, "");
15
15
  export const NO_TOKEN_MESSAGE = "Langley-AgentOS のログインの証明(TOOL_TOKEN)がありません。Langley-AgentOS から起動し直してください";
16
16
  export class AgentError extends Error {
17
+ status;
18
+ constructor(message, status) {
19
+ super(message);
20
+ this.status = status;
21
+ }
17
22
  }
23
+ export const UNKNOWN_RESULT_MESSAGE = "記録されたか不明です。送り直さず、video_my_requests の一覧で確かめてください";
18
24
  /** サーバーの文言をそのまま返す(言い換えない)。文言が無ければ状態コードを伝える */
19
25
  export function explain(status, body) {
20
26
  return typeof body === "object" && body !== null && typeof body.error === "string"
@@ -44,7 +50,7 @@ async function call(path, token, init = {}, f = fetch) {
44
50
  catch {
45
51
  /* 本文が JSON でないときは状態コードだけで説明する */
46
52
  }
47
- throw new AgentError(explain(res.status, body));
53
+ throw new AgentError(explain(res.status, body), res.status);
48
54
  }
49
55
  return res;
50
56
  }
@@ -72,10 +78,27 @@ export const CHANGE_AREAS = ["storyboard", "approval_page", "slack", "video", "m
72
78
  export const CHANGE_URGENCIES = ["today", "this_week", "whenever"];
73
79
  /** 仕組みの改修を依頼する(受け付けて記録するだけ。仕組みはすぐには変わらない) */
74
80
  export async function requestChange(token, body, f = fetch) {
75
- const res = await call("/change-requests", token, {
81
+ // 返事が来なければ、届いたかどうかは分からない。失敗と言い切らない(送り直しによる二重の依頼を防ぐ)
82
+ try {
83
+ const res = await call("/change-requests", token, {
84
+ method: "POST",
85
+ headers: { "Content-Type": "application/json" },
86
+ body: JSON.stringify(body),
87
+ }, f);
88
+ return (await res.json());
89
+ }
90
+ catch (e) {
91
+ if (e instanceof AgentError && (e.status === undefined || e.status < 500))
92
+ throw e;
93
+ throw new AgentError(UNKNOWN_RESULT_MESSAGE);
94
+ }
95
+ }
96
+ /** 受付のうちの自分の依頼を取り下げる */
97
+ export async function withdrawChange(token, id, f = fetch) {
98
+ const res = await call("/change-requests/withdraw", token, {
76
99
  method: "POST",
77
100
  headers: { "Content-Type": "application/json" },
78
- body: JSON.stringify(body),
101
+ body: JSON.stringify({ id }),
79
102
  }, f);
80
103
  return (await res.json());
81
104
  }
@@ -116,8 +139,9 @@ export function planStart(token, body, f = fetch) {
116
139
  export function planAct(token, action, body, f = fetch) {
117
140
  return post(`/plan/${action}`, token, body, f);
118
141
  }
119
- export async function planStatus(token, id, f = fetch) {
142
+ export async function planStatus(token, id, f = fetch, wait = false) {
143
+ // wait: 案を作っている途中なら、受け口ができるまで最大50秒待ってから返す(0.10.0)
120
144
  if (id)
121
- return [(await (await call(`/plan?id=${encodeURIComponent(id)}`, token, {}, f)).json())];
145
+ return [(await (await call(`/plan?id=${encodeURIComponent(id)}${wait ? "&wait=50" : ""}`, token, {}, f)).json())];
122
146
  return (await (await call("/plans", token, {}, f)).json()).plans;
123
147
  }
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
8
  import { z } from "zod";
9
- import { AgentError, CHANGE_AREAS, CHANGE_URGENCIES, appeals, delivery, myRequests, planAct, planStart, planStatus, productions, request, requestChange } from "./client.js";
9
+ import { withdrawChange, AgentError, CHANGE_AREAS, CHANGE_URGENCIES, appeals, delivery, myRequests, planAct, planStart, planStatus, productions, request, requestChange } from "./client.js";
10
10
  // agent-core は CommonJS なので、名前つきの import では起動のときに落ちる(default から取る)
11
11
  import portalClient from "@funny-booth/agent-core/dist/portalClient.js";
12
12
  const portal = portalClient.portalClientFromEnv(); // PORTAL_URL・TOOL_TOKEN が無ければ null
@@ -16,7 +16,7 @@ const fail = (e) => ({
16
16
  content: [{ type: "text", text: e instanceof AgentError ? e.message : `動画の受け口につながりません: ${String(e)}` }],
17
17
  isError: true,
18
18
  });
19
- const server = new McpServer({ name: "langley-video", version: "0.9.0" });
19
+ const server = new McpServer({ name: "langley-video", version: "0.11.0" });
20
20
  server.registerTool("video_productions", {
21
21
  description: "ラングレー動画の制作の一覧(新しい順)。どの動画がどの段階か(絵コンテ承認待ち・最終確認待ち・納品できる)と、承認画面のリンクを返す",
22
22
  inputSchema: {},
@@ -108,10 +108,14 @@ server.registerTool("video_plan_start", {
108
108
  server.registerTool("video_plan_status", {
109
109
  description: "台本づくりの様子(今の段・案づくりの途中か・最新の案の要点とシートの名前・OK 済みの段・誰が始めたか・推す特典を聞く必要があるか)。" +
110
110
  "番号を渡せばその1件(ブリーフの全文も)、渡さなければ新しい順に10件",
111
- inputSchema: { id: z.string().optional().describe("台本づくりの番号(p で始まる)") },
112
- }, async ({ id }) => {
111
+ inputSchema: {
112
+ id: z.string().optional().describe("台本づくりの番号(p で始まる)"),
113
+ wait: z.boolean().optional().describe("true なら、案を作っている途中のとき、できるまで最大50秒待ってから返す(番号が要る)。" +
114
+ "まだなら、もう一度 wait: true で呼ぶ(合わせて10分まで)。平山様に「できた?」と声をかけてもらわずに待てる"),
115
+ },
116
+ }, async ({ id, wait }) => {
113
117
  try {
114
- const list = await planStatus(token(), id);
118
+ const list = await planStatus(token(), id, fetch, Boolean(id && wait));
115
119
  return text(list.length ? list.map((p) => planText(p, Boolean(id))).join("\n\n") : "台本づくりはまだありません");
116
120
  }
117
121
  catch (e) {
@@ -173,27 +177,44 @@ server.registerTool("video_delivery", {
173
177
  }
174
178
  });
175
179
  server.registerTool("video_request_change", {
176
- description: "動画の仕組み(絵コンテ・承認画面・Slack の知らせ・完成した動画・素材選び・エージェント)の改修を依頼する。" +
180
+ description: "動画の仕組み(台本づくり・絵コンテ・承認画面・Slack の知らせ・完成した動画・素材選び・エージェント)の改修を依頼する。" +
177
181
  "仕組みはすぐには変わらない(担当が改修し、確かめてから反映する)。改修の相談のエージェント(@動画改修)を許可された人だけが使える",
178
182
  inputSchema: {
179
- area: z.enum(CHANGE_AREAS).describe("storyboard=絵コンテ(台本・テロップ・ナレーション・カットの選び方)/ approval_page=承認画面 / slack=Slack の知らせ / video=完成した動画・納品セット / materials=素材選び・素材の範囲 / agent=エージェント / other=その他"),
183
+ area: z.enum(CHANGE_AREAS).describe("storyboard=台本づくり・絵コンテ(台本・テロップ・ナレーション・カットの選び方)/ approval_page=承認画面 / slack=Slack の知らせ / video=完成した動画・納品セット / materials=素材選び・素材の範囲 / agent=エージェント / other=その他"),
180
184
  summary: z.string().min(1).max(200).describe("1行の要約"),
181
185
  want: z.string().min(1).max(2000).describe("どう変わってほしいか(見え方・例を含めて)"),
182
186
  current: z.string().min(1).max(1000).optional().describe("今どうなっているか(確かめた事実)"),
183
187
  why: z.string().min(1).max(1000).optional().describe("なぜ変えたいか"),
184
188
  urgency: z.enum(CHANGE_URGENCIES).describe("today=今日中 / this_week=今週中 / whenever=いつでも"),
189
+ consentQuote: z.string().min(1).max(200).describe("復唱を見たあとの、本人の返事の原文(言い換えない)"),
185
190
  },
186
191
  }, async (args) => {
187
192
  try {
188
193
  const r = await requestChange(token(), args);
189
- return text(`受け付けました。受付番号: ${r.id}(状態: ${r.review_status})`);
194
+ return text(r.duplicate
195
+ ? `同じ内容の依頼をすでに受け付けています。二重には依頼していません。受付番号: ${r.id}(状態: ${r.review_status})`
196
+ : `受け付けました。受付番号: ${r.id}(状態: ${r.review_status})`);
197
+ }
198
+ catch (e) {
199
+ return fail(e);
200
+ }
201
+ });
202
+ server.registerTool("video_withdraw_request", {
203
+ description: "自分の改修の依頼を取り下げる。受付(pending)のうちだけできる。本人がはっきり頼んだときだけ使う",
204
+ inputSchema: {
205
+ id: z.string().min(1).describe("受付番号(video_my_requests の id)"),
206
+ },
207
+ }, async ({ id }) => {
208
+ try {
209
+ const r = await withdrawChange(token(), id);
210
+ return text(`取り下げました。受付番号: ${r.id}(状態: ${r.review_status})`);
190
211
  }
191
212
  catch (e) {
192
213
  return fail(e);
193
214
  }
194
215
  });
195
216
  server.registerTool("video_my_requests", {
196
- description: "自分が出した改修の依頼の進み具合(新しい順に20件まで)。review_status は pending=受付 / in_progress=対応中 / done=反映済み / declined=見送り / needs_info=情報が足りない。note は担当からの説明",
217
+ description: "自分が出した改修の依頼の進み具合(新しい順に20件まで)。review_status は pending=受付 / in_progress=対応中 / done=反映済み / declined=見送り / needs_info=情報が足りない / withdrawn=本人が取り下げ。note は担当からの説明",
197
218
  inputSchema: {},
198
219
  }, async () => {
199
220
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funny-booth/langley-video-mcp",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "description": "ラングレー動画の制作の状況・制作の依頼・納品セットの取得(Langley-AgentOS の「WEBマーケクリエイティブ」から使う MCP・stdio)",
6
6
  "publishConfig": {