@yoonion/mimi-seed-mcp 0.23.4 → 0.25.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.
Files changed (288) hide show
  1. package/dist/admob/cli.js +34 -5
  2. package/dist/admob/errors.js +39 -14
  3. package/dist/ai/client.js +35 -14
  4. package/dist/ai/notes.js +14 -3
  5. package/dist/ai/review.js +17 -4
  6. package/dist/android/keystore-store.js +28 -8
  7. package/dist/android/keystore.d.ts +17 -2
  8. package/dist/android/keystore.js +110 -21
  9. package/dist/android/messages.d.ts +13 -11
  10. package/dist/android/messages.js +166 -72
  11. package/dist/android/playstore-sa.js +6 -3
  12. package/dist/appstore/analytics.js +46 -14
  13. package/dist/appstore/app-info-policy.js +7 -1
  14. package/dist/appstore/app-info.js +13 -3
  15. package/dist/appstore/apps.js +7 -1
  16. package/dist/appstore/asset-library-write.js +119 -37
  17. package/dist/appstore/asset-library.js +19 -5
  18. package/dist/appstore/auth.d.ts +2 -0
  19. package/dist/appstore/auth.js +31 -5
  20. package/dist/appstore/client.js +27 -6
  21. package/dist/appstore/declarations.js +22 -6
  22. package/dist/appstore/errors.d.ts +1 -1
  23. package/dist/appstore/errors.js +60 -34
  24. package/dist/appstore/http.d.ts +6 -0
  25. package/dist/appstore/http.js +22 -5
  26. package/dist/appstore/messages.js +86 -28
  27. package/dist/appstore/previews.js +22 -6
  28. package/dist/appstore/product-localization.js +10 -2
  29. package/dist/appstore/product-review.js +29 -10
  30. package/dist/appstore/products.js +20 -6
  31. package/dist/appstore/read-response.js +13 -3
  32. package/dist/appstore/release-target.js +13 -3
  33. package/dist/appstore/release.js +59 -22
  34. package/dist/appstore/review-preview.js +17 -6
  35. package/dist/appstore/review-submission.js +86 -35
  36. package/dist/appstore/sales.js +96 -44
  37. package/dist/appstore/screenshots.js +19 -5
  38. package/dist/appstore/testflight.js +41 -18
  39. package/dist/appstore/upload-parts.js +12 -3
  40. package/dist/appstore/versions.js +22 -10
  41. package/dist/auth/bigquery-auth.js +44 -15
  42. package/dist/auth/bigquery-setup-cli.js +1 -1
  43. package/dist/auth/cli.js +4 -2
  44. package/dist/auth/constants.js +13 -3
  45. package/dist/auth/drive-auth.d.ts +3 -2
  46. package/dist/auth/drive-auth.js +47 -17
  47. package/dist/auth/drive-setup-cli.js +1 -0
  48. package/dist/auth/errors.d.ts +75 -0
  49. package/dist/auth/errors.js +190 -86
  50. package/dist/auth/google-auth.d.ts +3 -1
  51. package/dist/auth/google-auth.js +39 -27
  52. package/dist/auth/playstore-auth.d.ts +1 -0
  53. package/dist/auth/playstore-auth.js +35 -15
  54. package/dist/auth/scopes.d.ts +18 -28
  55. package/dist/auth/scopes.js +53 -14
  56. package/dist/auth/youtube-channel.d.ts +8 -0
  57. package/dist/auth/youtube-channel.js +11 -3
  58. package/dist/bigquery/ids.js +19 -5
  59. package/dist/bigquery/tools.js +24 -8
  60. package/dist/billing/tools.js +22 -6
  61. package/dist/checks/appstore-submission.d.ts +1 -1
  62. package/dist/checks/appstore-submission.js +29 -8
  63. package/dist/checks/plan.js +169 -62
  64. package/dist/checks/release-status.js +10 -2
  65. package/dist/checks/risks.js +230 -63
  66. package/dist/checks/screenshots.d.ts +4 -4
  67. package/dist/checks/screenshots.js +63 -22
  68. package/dist/ci/config.js +8 -5
  69. package/dist/ci/gitlab.js +3 -1
  70. package/dist/core/atomic-write.d.ts +5 -2
  71. package/dist/core/atomic-write.js +8 -4
  72. package/dist/core/catch-scan.d.ts +17 -0
  73. package/dist/core/catch-scan.js +111 -0
  74. package/dist/core/checks/billing.d.ts +5 -0
  75. package/dist/core/checks/billing.js +36 -5
  76. package/dist/core/checks/lockfile.js +2 -0
  77. package/dist/core/checks/release-doctor/fcm.js +1 -0
  78. package/dist/core/checks/release-doctor/files.d.ts +3 -1
  79. package/dist/core/checks/release-doctor/files.js +12 -1
  80. package/dist/core/checks/release-doctor/gradle-apply.js +1 -0
  81. package/dist/core/checks/release-doctor/ios-xcode.js +22 -3
  82. package/dist/core/checks/release-doctor/target-sdk.js +1 -1
  83. package/dist/core/checks/release-doctor/util.d.ts +5 -0
  84. package/dist/core/checks/release-doctor/util.js +56 -0
  85. package/dist/core/checks/release-doctor.js +59 -16
  86. package/dist/core/credential-envelope.d.ts +25 -0
  87. package/dist/core/credential-envelope.js +66 -0
  88. package/dist/core/credential-keystore.d.ts +37 -0
  89. package/dist/core/credential-keystore.js +275 -0
  90. package/dist/core/credential-read.d.ts +33 -0
  91. package/dist/core/credential-read.js +112 -0
  92. package/dist/core/credential-store.d.ts +61 -0
  93. package/dist/core/credential-store.js +240 -0
  94. package/dist/core/http-errors.js +1 -0
  95. package/dist/core/i18n-scan.d.ts +10 -0
  96. package/dist/core/i18n-scan.js +79 -0
  97. package/dist/core/json-file.d.ts +30 -0
  98. package/dist/core/json-file.js +53 -0
  99. package/dist/core/lang.d.ts +14 -0
  100. package/dist/core/lang.js +22 -2
  101. package/dist/core/project-manifest.d.ts +24 -1
  102. package/dist/core/project-manifest.js +27 -16
  103. package/dist/drive/tools.js +86 -34
  104. package/dist/facebook/api.js +3 -1
  105. package/dist/facebook/config.js +11 -3
  106. package/dist/facebook/setup.d.ts +2 -0
  107. package/dist/facebook/setup.js +32 -9
  108. package/dist/firebase/cli.js +39 -5
  109. package/dist/firebase/tools.js +36 -10
  110. package/dist/ga4/cli.js +48 -4
  111. package/dist/ga4/tools.js +4 -2
  112. package/dist/googleads/config.js +24 -8
  113. package/dist/googleads/tools.js +3 -1
  114. package/dist/gsc/tools.d.ts +116 -9
  115. package/dist/gsc/tools.js +101 -17
  116. package/dist/helpers.d.ts +4 -2
  117. package/dist/helpers.js +82 -44
  118. package/dist/i18n/manifest-en.d.ts +6 -0
  119. package/dist/i18n/manifest-en.js +53 -0
  120. package/dist/i18n/tools-en/admob.d.ts +25 -0
  121. package/dist/i18n/tools-en/admob.js +24 -0
  122. package/dist/i18n/tools-en/ai.d.ts +14 -0
  123. package/dist/i18n/tools-en/ai.js +13 -0
  124. package/dist/i18n/tools-en/android.d.ts +14 -0
  125. package/dist/i18n/tools-en/android.js +13 -0
  126. package/dist/i18n/tools-en/appstore.d.ts +240 -0
  127. package/dist/i18n/tools-en/appstore.js +239 -0
  128. package/dist/i18n/tools-en/auth.d.ts +16 -0
  129. package/dist/i18n/tools-en/auth.js +15 -0
  130. package/dist/i18n/tools-en/bigquery.d.ts +16 -0
  131. package/dist/i18n/tools-en/bigquery.js +15 -0
  132. package/dist/i18n/tools-en/billing.d.ts +17 -0
  133. package/dist/i18n/tools-en/billing.js +16 -0
  134. package/dist/i18n/tools-en/checks.d.ts +23 -0
  135. package/dist/i18n/tools-en/checks.js +22 -0
  136. package/dist/i18n/tools-en/ci.d.ts +21 -0
  137. package/dist/i18n/tools-en/ci.js +20 -0
  138. package/dist/i18n/tools-en/drive.d.ts +33 -0
  139. package/dist/i18n/tools-en/drive.js +32 -0
  140. package/dist/i18n/tools-en/facebook.d.ts +14 -0
  141. package/dist/i18n/tools-en/facebook.js +13 -0
  142. package/dist/i18n/tools-en/firebase.d.ts +42 -0
  143. package/dist/i18n/tools-en/firebase.js +41 -0
  144. package/dist/i18n/tools-en/ga4.d.ts +35 -0
  145. package/dist/i18n/tools-en/ga4.js +34 -0
  146. package/dist/i18n/tools-en/googleads.d.ts +15 -0
  147. package/dist/i18n/tools-en/googleads.js +14 -0
  148. package/dist/i18n/tools-en/gsc.d.ts +27 -0
  149. package/dist/i18n/tools-en/gsc.js +26 -0
  150. package/dist/i18n/tools-en/iam.d.ts +15 -0
  151. package/dist/i18n/tools-en/iam.js +14 -0
  152. package/dist/i18n/tools-en/index.d.ts +7 -0
  153. package/dist/i18n/tools-en/index.js +58 -0
  154. package/dist/i18n/tools-en/instagram.d.ts +16 -0
  155. package/dist/i18n/tools-en/instagram.js +15 -0
  156. package/dist/i18n/tools-en/jenkins.d.ts +41 -0
  157. package/dist/i18n/tools-en/jenkins.js +40 -0
  158. package/dist/i18n/tools-en/naver.d.ts +10 -0
  159. package/dist/i18n/tools-en/naver.js +9 -0
  160. package/dist/i18n/tools-en/playstore.d.ts +148 -0
  161. package/dist/i18n/tools-en/playstore.js +147 -0
  162. package/dist/i18n/tools-en/registrar.d.ts +6 -0
  163. package/dist/i18n/tools-en/registrar.js +6 -0
  164. package/dist/i18n/tools-en/threads.d.ts +21 -0
  165. package/dist/i18n/tools-en/threads.js +20 -0
  166. package/dist/i18n/tools-en/tiktok.d.ts +21 -0
  167. package/dist/i18n/tools-en/tiktok.js +20 -0
  168. package/dist/i18n/tools-en/video.d.ts +59 -0
  169. package/dist/i18n/tools-en/video.js +58 -0
  170. package/dist/i18n/tools-en/youtube.d.ts +44 -0
  171. package/dist/i18n/tools-en/youtube.js +43 -0
  172. package/dist/iam/key-files.js +13 -3
  173. package/dist/instagram/api.js +19 -5
  174. package/dist/instagram/config.js +11 -3
  175. package/dist/instagram/setup.js +37 -11
  176. package/dist/jenkins/builds.d.ts +2 -2
  177. package/dist/jenkins/builds.js +70 -30
  178. package/dist/jenkins/config.d.ts +5 -0
  179. package/dist/jenkins/config.js +25 -6
  180. package/dist/jenkins/credentials.js +33 -13
  181. package/dist/jenkins/http.js +6 -3
  182. package/dist/jenkins/jobs.js +19 -5
  183. package/dist/jenkins/messages.js +93 -36
  184. package/dist/lib/cli-args.js +13 -7
  185. package/dist/lib/google-errors.js +31 -9
  186. package/dist/lib/http.js +10 -3
  187. package/dist/lib/json-file.d.ts +15 -0
  188. package/dist/lib/json-file.js +65 -0
  189. package/dist/lib/meta-auth.d.ts +1 -1
  190. package/dist/lib/meta-auth.js +26 -8
  191. package/dist/lib/package-name.js +15 -4
  192. package/dist/lib/package-root.js +1 -1
  193. package/dist/lib/paginate.js +10 -2
  194. package/dist/lib/path-containment.js +22 -6
  195. package/dist/lib/resource-id.js +10 -3
  196. package/dist/lib/store-create-result.js +54 -13
  197. package/dist/lib/text-validators.js +20 -5
  198. package/dist/lib/tool-registrar.d.ts +9 -0
  199. package/dist/lib/tool-registrar.js +33 -14
  200. package/dist/lib/tool-text.d.ts +31 -0
  201. package/dist/lib/tool-text.js +52 -0
  202. package/dist/lib/toolsets.js +13 -3
  203. package/dist/lib/url-path.js +3 -1
  204. package/dist/naver/tools.js +138 -46
  205. package/dist/playstore/data-safety.js +16 -4
  206. package/dist/playstore/errors.js +33 -8
  207. package/dist/playstore/financials.js +83 -35
  208. package/dist/playstore/listing.js +7 -1
  209. package/dist/playstore/messages.js +179 -57
  210. package/dist/playstore/products.js +10 -2
  211. package/dist/playstore/recovery.js +10 -2
  212. package/dist/playstore/releases.js +34 -14
  213. package/dist/playstore/reviews.js +14 -4
  214. package/dist/playstore/statistics.js +3 -1
  215. package/dist/prompts.js +160 -50
  216. package/dist/registers/admob.js +36 -11
  217. package/dist/registers/android.js +25 -9
  218. package/dist/registers/appstore/apps.js +22 -6
  219. package/dist/registers/appstore/customer-reviews.js +7 -1
  220. package/dist/registers/appstore/declarations.js +63 -19
  221. package/dist/registers/appstore/media.js +76 -24
  222. package/dist/registers/appstore/metadata.js +26 -8
  223. package/dist/registers/appstore/products.js +53 -19
  224. package/dist/registers/appstore/review-submission.js +31 -9
  225. package/dist/registers/appstore/testflight.js +82 -24
  226. package/dist/registers/appstore/versions.js +88 -30
  227. package/dist/registers/auth.js +343 -90
  228. package/dist/registers/bigquery.js +54 -14
  229. package/dist/registers/billing.js +18 -4
  230. package/dist/registers/checks.js +20 -5
  231. package/dist/registers/ci.js +60 -20
  232. package/dist/registers/drive.js +18 -7
  233. package/dist/registers/facebook.js +31 -9
  234. package/dist/registers/firebase.js +21 -7
  235. package/dist/registers/googleads.js +23 -6
  236. package/dist/registers/gsc.js +42 -39
  237. package/dist/registers/iam.js +44 -13
  238. package/dist/registers/instagram.js +19 -5
  239. package/dist/registers/jenkins.js +43 -14
  240. package/dist/registers/naver.js +13 -3
  241. package/dist/registers/playstore/financials.d.ts +6 -0
  242. package/dist/registers/playstore/financials.js +48 -0
  243. package/dist/registers/playstore/listing.d.ts +15 -0
  244. package/dist/registers/playstore/listing.js +138 -0
  245. package/dist/registers/playstore/media.d.ts +6 -0
  246. package/dist/registers/playstore/media.js +56 -0
  247. package/dist/registers/playstore/products.d.ts +21 -0
  248. package/dist/registers/playstore/products.js +238 -0
  249. package/dist/registers/playstore/recovery.d.ts +11 -0
  250. package/dist/registers/playstore/recovery.js +105 -0
  251. package/dist/registers/playstore/releases.d.ts +8 -0
  252. package/dist/registers/playstore/releases.js +157 -0
  253. package/dist/registers/playstore/reviews.d.ts +6 -0
  254. package/dist/registers/playstore/reviews.js +43 -0
  255. package/dist/registers/playstore/service-accounts.d.ts +13 -0
  256. package/dist/registers/playstore/service-accounts.js +127 -0
  257. package/dist/registers/playstore/shared.d.ts +12 -0
  258. package/dist/registers/playstore/shared.js +24 -0
  259. package/dist/registers/playstore.d.ts +8 -0
  260. package/dist/registers/playstore.js +28 -734
  261. package/dist/registers/threads.js +28 -8
  262. package/dist/registers/tiktok.js +4 -2
  263. package/dist/registers/video.js +3 -1
  264. package/dist/remote-sync.js +80 -28
  265. package/dist/resources.d.ts +0 -8
  266. package/dist/resources.js +73 -32
  267. package/dist/server.d.ts +2 -0
  268. package/dist/server.js +9 -1
  269. package/dist/social/profile-store.js +36 -12
  270. package/dist/social/setup-cli.js +1 -1
  271. package/dist/threads/api.js +23 -6
  272. package/dist/threads/setup.js +42 -14
  273. package/dist/tiktok-business/api.js +13 -3
  274. package/dist/tiktok-business/auth.js +10 -2
  275. package/dist/tiktok-business/config.js +8 -3
  276. package/dist/tiktok-business/posting.d.ts +6 -0
  277. package/dist/tiktok-business/posting.js +118 -36
  278. package/dist/tiktok-business/setup-cli.js +3 -1
  279. package/dist/tools-cli.js +4 -5
  280. package/dist/video/captions.js +3 -1
  281. package/dist/video/files.js +13 -3
  282. package/dist/video/project.js +65 -21
  283. package/dist/video/providers.js +52 -16
  284. package/dist/video/render.js +71 -22
  285. package/dist/video/research.js +10 -2
  286. package/dist/video/schemas.js +19 -5
  287. package/dist/video/youtube-publish.js +62 -32
  288. package/package.json +1 -1
@@ -5,10 +5,46 @@ import path from 'node:path';
5
5
  import { writeJsonAtomic } from './files.js';
6
6
  import { loadProject, registerAsset } from './project.js';
7
7
  import { fetchWithTimeout, HTTP_TRANSFER_TIMEOUT_MS } from '../lib/http.js';
8
+ import { catalog } from '#core/lang.js';
9
+ const M = catalog({
10
+ envRequired: (name) => `❌ ${name} 환경변수가 필요합니다.`,
11
+ apiFailed: (status, message) => `외부 API 요청 실패 (${status}): ${message}`,
12
+ noQueries: '검색어가 없습니다. queries를 전달하거나 프로젝트 장면에 searchQuery를 추가하세요.',
13
+ noQueriesShort: '검색어가 없습니다.',
14
+ badPexelsUrl: (host) => `허용되지 않은 Pexels 미디어 URL입니다: ${host}`,
15
+ noLocation: 'Pexels 리디렉션 응답에 Location 헤더가 없습니다.',
16
+ tooManyRedirects: 'Pexels 자산 리디렉션이 3회를 초과했습니다.',
17
+ noBody: '다운로드 응답에 본문이 없습니다.',
18
+ overLimit: (mb) => `자산이 ${mb}MB 제한을 초과합니다.`,
19
+ selectCount: '한 번에 1~5개 자산을 선택하세요.',
20
+ downloadFailed: (status, id) => `Pexels 자산 다운로드 실패 (${status}): ${id}`,
21
+ notMp4: (contentType) => `Pexels 자산이 MP4 응답이 아닙니다: ${contentType}`,
22
+ over100: (id) => `자산이 100MB 제한을 초과합니다: ${id}`,
23
+ badSignature: (id) => `Pexels 자산이 유효한 MP4 시그니처를 갖지 않습니다: ${id}`,
24
+ noImageData: '이미지 생성 응답에 이미지 데이터가 없습니다.',
25
+ badPng: '이미지 생성 응답이 유효한 50MB 이하 PNG가 아닙니다.',
26
+ }, {
27
+ envRequired: (name) => `❌ The ${name} environment variable is required.`,
28
+ apiFailed: (status, message) => `External API request failed (${status}): ${message}`,
29
+ noQueries: 'No search queries. Pass queries or add searchQuery to the project scenes.',
30
+ noQueriesShort: 'No search queries.',
31
+ badPexelsUrl: (host) => `Pexels media URL not allowed: ${host}`,
32
+ noLocation: 'The Pexels redirect response has no Location header.',
33
+ tooManyRedirects: 'Pexels asset redirects exceeded 3.',
34
+ noBody: 'The download response has no body.',
35
+ overLimit: (mb) => `The asset exceeds the ${mb}MB limit.`,
36
+ selectCount: 'Select 1-5 assets at a time.',
37
+ downloadFailed: (status, id) => `Pexels asset download failed (${status}): ${id}`,
38
+ notMp4: (contentType) => `The Pexels asset is not an MP4 response: ${contentType}`,
39
+ over100: (id) => `The asset exceeds the 100MB limit: ${id}`,
40
+ badSignature: (id) => `The Pexels asset does not have a valid MP4 signature: ${id}`,
41
+ noImageData: 'The image generation response has no image data.',
42
+ badPng: 'The image generation response is not a valid PNG of 50MB or less.',
43
+ });
8
44
  function requireEnv(name) {
9
45
  const value = process.env[name]?.trim();
10
46
  if (!value)
11
- throw new Error(`❌ ${name} 환경변수가 필요합니다.`);
47
+ throw new Error(M().envRequired(name));
12
48
  return value;
13
49
  }
14
50
  async function fetchJson(url, init) {
@@ -25,7 +61,7 @@ async function fetchJson(url, init) {
25
61
  const message = typeof body === 'object' && body !== null && 'error' in body
26
62
  ? JSON.stringify((body).error)
27
63
  : String(body).slice(0, 500);
28
- throw new Error(`외부 API 요청 실패 (${response.status}): ${message}`);
64
+ throw new Error(M().apiFailed(response.status, message));
29
65
  }
30
66
  return body;
31
67
  }
@@ -41,7 +77,7 @@ export async function researchYouTube(input) {
41
77
  .filter(Boolean)
42
78
  .slice(0, 5);
43
79
  if (queries.length === 0)
44
- throw new Error('검색어가 없습니다. queries를 전달하거나 프로젝트 장면에 searchQuery를 추가하세요.');
80
+ throw new Error(M().noQueries);
45
81
  const references = [];
46
82
  for (const query of queries) {
47
83
  const params = new URLSearchParams({
@@ -111,7 +147,7 @@ export async function searchStock(input) {
111
147
  .filter(Boolean)
112
148
  .slice(0, 10);
113
149
  if (queries.length === 0)
114
- throw new Error('검색어가 없습니다.');
150
+ throw new Error(M().noQueriesShort);
115
151
  const results = [];
116
152
  for (const query of queries) {
117
153
  const params = new URLSearchParams({
@@ -156,7 +192,7 @@ const PEXELS_MEDIA_HOSTS = new Set([
156
192
  function validatePexelsUrl(value) {
157
193
  const url = new URL(value);
158
194
  if (url.protocol !== 'https:' || !PEXELS_MEDIA_HOSTS.has(url.hostname)) {
159
- throw new Error(`허용되지 않은 Pexels 미디어 URL입니다: ${url.hostname}`);
195
+ throw new Error(M().badPexelsUrl(url.hostname));
160
196
  }
161
197
  return url;
162
198
  }
@@ -169,15 +205,15 @@ async function fetchPexelsMedia(value) {
169
205
  return response;
170
206
  const location = response.headers.get('location');
171
207
  if (!location)
172
- throw new Error('Pexels 리디렉션 응답에 Location 헤더가 없습니다.');
208
+ throw new Error(M().noLocation);
173
209
  await response.body?.cancel();
174
210
  current = validatePexelsUrl(new URL(location, current).toString());
175
211
  }
176
- throw new Error('Pexels 자산 리디렉션이 3회를 초과했습니다.');
212
+ throw new Error(M().tooManyRedirects);
177
213
  }
178
214
  async function downloadLimited(response, destination, maxBytes) {
179
215
  if (!response.body)
180
- throw new Error('다운로드 응답에 본문이 없습니다.');
216
+ throw new Error(M().noBody);
181
217
  const tempPath = `${destination}.${randomUUID()}.tmp`;
182
218
  const writer = createWriteStream(tempPath, { flags: 'wx' });
183
219
  const reader = response.body.getReader();
@@ -190,7 +226,7 @@ async function downloadLimited(response, destination, maxBytes) {
190
226
  total += value.byteLength;
191
227
  if (total > maxBytes) {
192
228
  await reader.cancel();
193
- throw new Error(`자산이 ${Math.round(maxBytes / 1024 / 1024)}MB 제한을 초과합니다.`);
229
+ throw new Error(M().overLimit(Math.round(maxBytes / 1024 / 1024)));
194
230
  }
195
231
  if (!writer.write(Buffer.from(value)))
196
232
  await once(writer, 'drain');
@@ -227,27 +263,27 @@ function hasMp4Signature(filePath) {
227
263
  export async function downloadStockAssets(projectDir, selections) {
228
264
  loadProject(projectDir);
229
265
  if (selections.length === 0 || selections.length > 5)
230
- throw new Error('한 번에 1~5개 자산을 선택하세요.');
266
+ throw new Error(M().selectCount);
231
267
  const assets = [];
232
268
  for (const selection of selections) {
233
269
  const url = validatePexelsUrl(selection.downloadUrl);
234
270
  const response = await fetchPexelsMedia(url.toString());
235
271
  if (!response.ok)
236
- throw new Error(`Pexels 자산 다운로드 실패 (${response.status}): ${selection.id}`);
272
+ throw new Error(M().downloadFailed(response.status, selection.id));
237
273
  const contentType = response.headers.get('content-type')?.split(';')[0].trim().toLowerCase();
238
274
  if (contentType !== 'video/mp4' && contentType !== 'application/octet-stream') {
239
- throw new Error(`Pexels 자산이 MP4 응답이 아닙니다: ${contentType ?? 'unknown'}`);
275
+ throw new Error(M().notMp4(contentType ?? 'unknown'));
240
276
  }
241
277
  const length = Number(response.headers.get('content-length') ?? 0);
242
278
  if (length > 100 * 1024 * 1024)
243
- throw new Error(`자산이 100MB 제한을 초과합니다: ${selection.id}`);
279
+ throw new Error(M().over100(selection.id));
244
280
  const id = `pexels-${selection.id}-${randomUUID().slice(0, 8)}`;
245
281
  const destination = path.join(path.resolve(projectDir), 'assets', 'stock', `${id}.mp4`);
246
282
  mkdirSync(path.dirname(destination), { recursive: true });
247
283
  await downloadLimited(response, destination, 100 * 1024 * 1024);
248
284
  if (!hasMp4Signature(destination)) {
249
285
  unlinkSync(destination);
250
- throw new Error(`Pexels 자산이 유효한 MP4 시그니처를 갖지 않습니다: ${selection.id}`);
286
+ throw new Error(M().badSignature(selection.id));
251
287
  }
252
288
  assets.push(registerAsset(projectDir, {
253
289
  id,
@@ -287,11 +323,11 @@ export async function generateImage(input) {
287
323
  });
288
324
  const base64 = data.data?.[0]?.b64_json;
289
325
  if (!base64)
290
- throw new Error('이미지 생성 응답에 이미지 데이터가 없습니다.');
326
+ throw new Error(M().noImageData);
291
327
  const bytes = Buffer.from(base64, 'base64');
292
328
  const pngSignature = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
293
329
  if (bytes.length === 0 || bytes.length > 50 * 1024 * 1024 || !bytes.subarray(0, 8).equals(pngSignature)) {
294
- throw new Error('이미지 생성 응답이 유효한 50MB 이하 PNG가 아닙니다.');
330
+ throw new Error(M().badPng);
295
331
  }
296
332
  const id = `openai-${randomUUID()}`;
297
333
  const safeName = (input.name ?? id).replace(/[^a-zA-Z0-9_-]+/g, '-').replace(/^-+|-+$/g, '') || id;
@@ -3,11 +3,59 @@ import { randomUUID } from 'node:crypto';
3
3
  import { closeSync, createWriteStream, existsSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { promisify } from 'node:util';
6
+ import { catalog } from '#core/lang.js';
6
7
  import { formatAss, resolveCaptionStyle } from './captions.js';
7
8
  import { readJson, writeJsonAtomic } from './files.js';
8
9
  import { loadAssets, loadProject, loadTimeline } from './project.js';
9
10
  import { parseFile, renderJobSchema } from './schemas.js';
10
11
  const execFileAsync = promisify(execFile);
12
+ const M = catalog({
13
+ sceneAsset: (id) => `렌더링할 수 없는 장면 자산입니다: ${id}`,
14
+ audioAsset: (id) => `렌더링할 수 없는 오디오 자산입니다: ${id}`,
15
+ ffmpegPathInvalid: (why, ffmpegPath) => `ffmpegPath 는 로컬 ffmpeg 실행 파일(ffmpeg 또는 ffmpeg.exe)의 절대경로여야 합니다 (${why}): ${ffmpegPath}`,
16
+ whyUnc: 'UNC·네트워크·장치 경로는 허용하지 않음',
17
+ whyNul: 'NUL 문자',
18
+ whyNotAbsolute: '로컬 절대경로가 아님',
19
+ whyName: '파일 이름이 ffmpeg 가 아님',
20
+ whyMissing: '파일이 없음',
21
+ whyLinkNetwork: '링크가 네트워크 경로를 가리킴',
22
+ whyLinkName: '링크 대상 이름이 ffmpeg 가 아님',
23
+ whyNotFile: '일반 파일이 아님',
24
+ ffmpegUnavailable: (command) => `FFmpeg를 실행할 수 없습니다: ${command}\nFFmpeg를 설치해 PATH 에 두거나 MIMI_SEED_FFMPEG_PATH (ffprobe 는 MIMI_SEED_FFPROBE_PATH) 환경변수에 절대경로를 지정하세요. / Install FFmpeg on PATH or set MIMI_SEED_FFMPEG_PATH (and MIMI_SEED_FFPROBE_PATH) to its absolute path.`,
25
+ renderRunning: (lockPath) => `같은 출력 파일의 렌더 작업이 이미 실행 중입니다: ${lockPath}`,
26
+ outputExists: (outputPath) => `출력 파일이 이미 존재합니다: ${outputPath}\noverwriteOutput=true로 명시해야 덮어씁니다.`,
27
+ ffmpegExit: (code) => `FFmpeg가 종료 코드 ${code}로 실패했습니다.`,
28
+ jobNotFound: (jobId) => `렌더 작업을 찾을 수 없습니다: ${jobId}`,
29
+ queuedStale: '렌더 작업이 시작 대기 상태에서 중단되었습니다. 다시 렌더하세요.',
30
+ runningDead: '렌더 프로세스가 더 이상 실행 중이지 않습니다. 호스트 또는 MCP가 중단되었을 수 있습니다.',
31
+ filePathInvalid: 'filePath는 존재하는 절대경로여야 합니다.',
32
+ noVideoStream: '비디오 스트림이 없습니다.',
33
+ codec: (codec) => `권장 코덱 H.264가 아닙니다: ${codec}`,
34
+ pixFmt: (fmt) => `권장 픽셀 포맷 yuv420p가 아닙니다: ${fmt}`,
35
+ }, {
36
+ sceneAsset: (id) => `Scene asset cannot be rendered: ${id}`,
37
+ audioAsset: (id) => `Audio asset cannot be rendered: ${id}`,
38
+ ffmpegPathInvalid: (why, ffmpegPath) => `ffmpegPath must be the absolute path of a local ffmpeg executable (ffmpeg or ffmpeg.exe) (${why}): ${ffmpegPath}`,
39
+ whyUnc: 'UNC, network, and device paths are not allowed',
40
+ whyNul: 'NUL character',
41
+ whyNotAbsolute: 'not a local absolute path',
42
+ whyName: 'file name is not ffmpeg',
43
+ whyMissing: 'file does not exist',
44
+ whyLinkNetwork: 'link points to a network path',
45
+ whyLinkName: 'link target name is not ffmpeg',
46
+ whyNotFile: 'not a regular file',
47
+ ffmpegUnavailable: (command) => `Cannot run FFmpeg: ${command}\nInstall FFmpeg on PATH or set MIMI_SEED_FFMPEG_PATH (and MIMI_SEED_FFPROBE_PATH) to its absolute path.`,
48
+ renderRunning: (lockPath) => `A render job for the same output file is already running: ${lockPath}`,
49
+ outputExists: (outputPath) => `The output file already exists: ${outputPath}\nSet overwriteOutput=true explicitly to overwrite it.`,
50
+ ffmpegExit: (code) => `FFmpeg failed with exit code ${code}.`,
51
+ jobNotFound: (jobId) => `Render job not found: ${jobId}`,
52
+ queuedStale: 'The render job stopped while waiting to start. Render again.',
53
+ runningDead: 'The render process is no longer running. The host or the MCP server may have stopped.',
54
+ filePathInvalid: 'filePath must be an existing absolute path.',
55
+ noVideoStream: 'No video stream.',
56
+ codec: (codec) => `Not the recommended codec H.264: ${codec}`,
57
+ pixFmt: (fmt) => `Not the recommended pixel format yuv420p: ${fmt}`,
58
+ });
11
59
  function jobPath(projectDir, jobId) {
12
60
  return path.join(path.resolve(projectDir), '.jobs', `${jobId}.json`);
13
61
  }
@@ -54,7 +102,7 @@ export function buildFfmpegPlan(projectDir, outputPath, jobId) {
54
102
  const assets = timeline.scenes.map((scene) => {
55
103
  const asset = byId.get(scene.assetId);
56
104
  if (!asset || !asset.allowedForRendering || !existsSync(asset.path)) {
57
- throw new Error(`렌더링할 수 없는 장면 자산입니다: ${scene.assetId}`);
105
+ throw new Error(M().sceneAsset(scene.assetId));
58
106
  }
59
107
  return asset;
60
108
  });
@@ -71,7 +119,7 @@ export function buildFfmpegPlan(projectDir, outputPath, jobId) {
71
119
  if (timeline.audioAssetId) {
72
120
  const audio = byId.get(timeline.audioAssetId);
73
121
  if (!audio || audio.kind !== 'audio' || !audio.allowedForRendering || !existsSync(audio.path)) {
74
- throw new Error(`렌더링할 수 없는 오디오 자산입니다: ${timeline.audioAssetId}`);
122
+ throw new Error(M().audioAsset(timeline.audioAssetId));
75
123
  }
76
124
  audioIndex = assets.length;
77
125
  args.push('-stream_loop', '-1', '-i', audio.path);
@@ -116,35 +164,35 @@ const FFMPEG_BASENAME = /^ffmpeg(\.exe)?$/i;
116
164
  */
117
165
  export function assertFfmpegPath(ffmpegPath) {
118
166
  const reject = (why) => {
119
- throw new Error(`ffmpegPath 는 로컬 ffmpeg 실행 파일(ffmpeg 또는 ffmpeg.exe)의 절대경로여야 합니다 (${why}): ${ffmpegPath}`);
167
+ throw new Error(M().ffmpegPathInvalid(why, ffmpegPath));
120
168
  };
121
169
  // 구분자는 양쪽 다 본다 — POSIX 의 path.basename 은 백슬래시를 구분자로 보지 않는다.
122
170
  const baseName = (p) => p.split(/[\\/]/).pop() ?? '';
123
171
  if (/^[\\/]{2}/.test(ffmpegPath))
124
- reject('UNC·네트워크·장치 경로는 허용하지 않음');
172
+ reject(M().whyUnc);
125
173
  if (ffmpegPath.includes('\0'))
126
- reject('NUL 문자');
174
+ reject(M().whyNul);
127
175
  const localAbsolute = process.platform === 'win32'
128
176
  ? /^[A-Za-z]:[\\/]/.test(ffmpegPath)
129
177
  : ffmpegPath.startsWith('/');
130
178
  if (!localAbsolute)
131
- reject('로컬 절대경로가 아님');
179
+ reject(M().whyNotAbsolute);
132
180
  if (!FFMPEG_BASENAME.test(baseName(ffmpegPath)))
133
- reject('파일 이름이 ffmpeg 가 아님');
181
+ reject(M().whyName);
134
182
  let real;
135
183
  try {
136
184
  real = realpathSync(ffmpegPath);
137
185
  }
138
186
  catch {
139
- return reject('파일이 없음');
187
+ return reject(M().whyMissing);
140
188
  }
141
189
  // 심볼릭 링크·정션이 네트워크 경로나 다른 실행 파일로 이어지는 경우도 막는다.
142
190
  if (/^[\\/]{2}/.test(real))
143
- reject('링크가 네트워크 경로를 가리킴');
191
+ reject(M().whyLinkNetwork);
144
192
  if (!FFMPEG_BASENAME.test(baseName(real)))
145
- reject('링크 대상 이름이 ffmpeg 가 아님');
193
+ reject(M().whyLinkName);
146
194
  if (!statSync(real).isFile())
147
- reject('일반 파일이 아님');
195
+ reject(M().whyNotFile);
148
196
  return real;
149
197
  }
150
198
  async function verifyExecutable(command) {
@@ -152,7 +200,7 @@ async function verifyExecutable(command) {
152
200
  await execFileAsync(command, ['-version'], { timeout: 10_000, windowsHide: true });
153
201
  }
154
202
  catch (error) {
155
- throw new Error(`FFmpeg를 실행할 수 없습니다: ${command}\nFFmpeg를 설치해 PATH 에 두거나 MIMI_SEED_FFMPEG_PATH (ffprobe 는 MIMI_SEED_FFPROBE_PATH) 환경변수에 절대경로를 지정하세요. / Install FFmpeg on PATH or set MIMI_SEED_FFMPEG_PATH (and MIMI_SEED_FFPROBE_PATH) to its absolute path.`, { cause: error });
203
+ throw new Error(M().ffmpegUnavailable(command), { cause: error });
156
204
  }
157
205
  }
158
206
  function acquireOutputLock(lockPath, projectDir, jobId) {
@@ -184,10 +232,11 @@ function acquireOutputLock(lockPath, projectDir, jobId) {
184
232
  }
185
233
  }
186
234
  catch {
235
+ // 잠금·작업 파일을 못 읽으면 살아 있는 렌더를 증명할 수 없어 오래된 잠금으로 본다 (작업 파일은 원자적 쓰기)
187
236
  active = false;
188
237
  }
189
238
  if (active)
190
- throw new Error(`같은 출력 파일의 렌더 작업이 이미 실행 중입니다: ${lockPath}`);
239
+ throw new Error(M().renderRunning(lockPath));
191
240
  unlinkSync(lockPath);
192
241
  tryCreate();
193
242
  }
@@ -204,7 +253,7 @@ export async function startRender(input) {
204
253
  const finalName = safeOutputName.toLowerCase().endsWith('.mp4') ? safeOutputName : `${safeOutputName}.mp4`;
205
254
  const outputPath = path.join(projectDir, 'render', finalName);
206
255
  if (existsSync(outputPath) && !input.overwriteOutput) {
207
- throw new Error(`출력 파일이 이미 존재합니다: ${outputPath}\noverwriteOutput=true로 명시해야 덮어씁니다.`);
256
+ throw new Error(M().outputExists(outputPath));
208
257
  }
209
258
  const id = randomUUID();
210
259
  const logPath = path.join(projectDir, '.jobs', `${id}.log`);
@@ -268,7 +317,7 @@ export async function startRender(input) {
268
317
  finalize({
269
318
  status: code === 0 ? 'completed' : 'failed',
270
319
  exitCode: code,
271
- error: code === 0 ? undefined : `FFmpeg가 종료 코드 ${code}로 실패했습니다.`,
320
+ error: code === 0 ? undefined : M().ffmpegExit(code),
272
321
  });
273
322
  });
274
323
  return JSON.parse(readFileSync(jobPath(projectDir, id), 'utf8'));
@@ -276,7 +325,7 @@ export async function startRender(input) {
276
325
  export function getRenderJob(projectDir, jobId) {
277
326
  const filePath = jobPath(projectDir, jobId);
278
327
  if (!existsSync(filePath))
279
- throw new Error(`렌더 작업을 찾을 수 없습니다: ${jobId}`);
328
+ throw new Error(M().jobNotFound(jobId));
280
329
  let job = parseFile(renderJobSchema, readJson(filePath), filePath);
281
330
  const queuedStale = job.status === 'queued' && Date.now() - Date.parse(job.updatedAt) >= 60_000;
282
331
  const runningDead = job.status === 'running' &&
@@ -286,8 +335,8 @@ export function getRenderJob(projectDir, jobId) {
286
335
  job = updateJob(projectDir, jobId, {
287
336
  status: 'failed',
288
337
  error: queuedStale
289
- ? '렌더 작업이 시작 대기 상태에서 중단되었습니다. 다시 렌더하세요.'
290
- : '렌더 프로세스가 더 이상 실행 중이지 않습니다. 호스트 또는 MCP가 중단되었을 수 있습니다.',
338
+ ? M().queuedStale
339
+ : M().runningDead,
291
340
  });
292
341
  const lockPath = `${job.outputPath}.render.lock`;
293
342
  try {
@@ -319,7 +368,7 @@ function ffprobeFor(ffmpegPath) {
319
368
  }
320
369
  export async function validateVideo(filePath, ffmpegPath) {
321
370
  if (!path.isAbsolute(filePath) || !existsSync(filePath)) {
322
- throw new Error('filePath는 존재하는 절대경로여야 합니다.');
371
+ throw new Error(M().filePathInvalid);
323
372
  }
324
373
  const ffprobe = ffprobeFor(ffmpegPath);
325
374
  const { stdout } = await execFileAsync(ffprobe, [
@@ -333,11 +382,11 @@ export async function validateVideo(filePath, ffmpegPath) {
333
382
  const video = streams.find((stream) => stream.codec_type === 'video');
334
383
  const issues = [];
335
384
  if (!video)
336
- issues.push('비디오 스트림이 없습니다.');
385
+ issues.push(M().noVideoStream);
337
386
  if (video && video.codec_name !== 'h264')
338
- issues.push(`권장 코덱 H.264가 아닙니다: ${String(video.codec_name)}`);
387
+ issues.push(M().codec(String(video.codec_name)));
339
388
  if (video && video.pix_fmt !== 'yuv420p')
340
- issues.push(`권장 픽셀 포맷 yuv420p가 아닙니다: ${String(video.pix_fmt)}`);
389
+ issues.push(M().pixFmt(String(video.pix_fmt)));
341
390
  return { valid: issues.length === 0, format: data.format ?? {}, streams, issues };
342
391
  }
343
392
  export const __testing = { ffprobeFor, processAlive, acquireOutputLock, readTail };
@@ -4,6 +4,14 @@ import { z } from 'zod';
4
4
  import { parseJsonResponse, requireApiKey, AI_MODEL } from '../ai/client.js';
5
5
  import { readJson, writeJsonAtomic } from './files.js';
6
6
  import { loadProject, sha256File } from './project.js';
7
+ import { catalog } from '#core/lang.js';
8
+ const M = catalog({
9
+ nothing: '종합할 리서치가 없습니다. 먼저 YouTube/Pexels 검색을 실행하거나 observations를 제공하세요.',
10
+ requiredLimitation: '실제 영상 프레임이나 오디오는 분석하지 않았으며, 메타데이터와 사용자 관찰만 종합했습니다.',
11
+ }, {
12
+ nothing: 'No research to synthesize. Run a YouTube/Pexels search first or provide observations.',
13
+ requiredLimitation: 'Actual video frames and audio were not analyzed; only metadata and user observations were synthesized.',
14
+ });
7
15
  const briefSchema = z.object({
8
16
  summary: z.string().min(1).max(10_000),
9
17
  patterns: z.array(z.object({
@@ -53,7 +61,7 @@ export async function synthesizeResearch(input) {
53
61
  const pexels = existsSync(pexelsPath) ? readJson(pexelsPath) : { results: [] };
54
62
  const observations = (input.observations ?? []).slice(0, 20);
55
63
  if (!existsSync(youtubePath) && !existsSync(pexelsPath) && observations.length === 0) {
56
- throw new Error('종합할 리서치가 없습니다. 먼저 YouTube/Pexels 검색을 실행하거나 observations를 제공하세요.');
64
+ throw new Error(M().nothing);
57
65
  }
58
66
  const data = JSON.stringify({ youtube, pexels, observations }).slice(0, 120_000);
59
67
  const client = await requireApiKey();
@@ -87,7 +95,7 @@ export async function synthesizeResearch(input) {
87
95
  const parsed = briefSchema.parse(parseJsonResponse(responseText));
88
96
  const allowedUrls = urlsFromResearch(youtube, pexels, observations);
89
97
  const limitations = [...parsed.limitations];
90
- const requiredLimitation = '실제 영상 프레임이나 오디오는 분석하지 않았으며, 메타데이터와 사용자 관찰만 종합했습니다.';
98
+ const requiredLimitation = M().requiredLimitation;
91
99
  if (!limitations.includes(requiredLimitation))
92
100
  limitations.unshift(requiredLimitation);
93
101
  const brief = {
@@ -1,4 +1,18 @@
1
1
  import { z } from 'zod';
2
+ import { catalog } from '#core/lang.js';
3
+ const M = catalog({
4
+ sceneTotalMismatch: '장면 길이 합계가 targetDurationSec와 다릅니다.',
5
+ referenceOnlyRender: 'reference-only 자산은 렌더링을 허용할 수 없습니다.',
6
+ hexFormat: '#RRGGBB 형식이어야 합니다.',
7
+ timelineTotalMismatch: 'totalDurationSec가 장면 길이 합계와 다릅니다.',
8
+ fileInvalid: (filePath, issues) => `영상 프로젝트 파일 검증 실패: ${filePath}\n${issues}`,
9
+ }, {
10
+ sceneTotalMismatch: 'The sum of scene durations differs from targetDurationSec.',
11
+ referenceOnlyRender: 'A reference-only asset cannot be allowed for rendering.',
12
+ hexFormat: 'Must be in #RRGGBB format.',
13
+ timelineTotalMismatch: 'totalDurationSec differs from the sum of scene durations.',
14
+ fileInvalid: (filePath, issues) => `Video project file validation failed: ${filePath}\n${issues}`,
15
+ });
2
16
  export const aspectRatioSchema = z.enum(['9:16', '16:9', '1:1']);
3
17
  export const assetKindSchema = z.enum(['image', 'video', 'audio']);
4
18
  export const assetSourceSchema = z.enum(['stock', 'generated', 'user-owned', 'licensed', 'reference-only']);
@@ -29,7 +43,7 @@ export const projectSchema = z.object({
29
43
  }).superRefine((project, ctx) => {
30
44
  const total = project.scenes.reduce((sum, scene) => sum + scene.durationSec, 0);
31
45
  if (Math.abs(total - project.settings.targetDurationSec) > 0.11) {
32
- ctx.addIssue({ code: 'custom', message: '장면 길이 합계가 targetDurationSec와 다릅니다.' });
46
+ ctx.addIssue({ code: 'custom', message: M().sceneTotalMismatch });
33
47
  }
34
48
  });
35
49
  export const assetSchema = z.object({
@@ -48,7 +62,7 @@ export const assetSchema = z.object({
48
62
  prompt: z.string().max(100_000).optional(),
49
63
  }).superRefine((asset, ctx) => {
50
64
  if (asset.sourceType === 'reference-only' && asset.allowedForRendering) {
51
- ctx.addIssue({ code: 'custom', message: 'reference-only 자산은 렌더링을 허용할 수 없습니다.' });
65
+ ctx.addIssue({ code: 'custom', message: M().referenceOnlyRender });
52
66
  }
53
67
  });
54
68
  export const assetManifestSchema = z.object({
@@ -56,7 +70,7 @@ export const assetManifestSchema = z.object({
56
70
  projectId: z.string().uuid(),
57
71
  assets: z.array(assetSchema).max(10_000),
58
72
  });
59
- export const hexColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/, '#RRGGBB 형식이어야 합니다.');
73
+ export const hexColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/, { error: () => M().hexFormat });
60
74
  export const captionStyleSchema = z.object({
61
75
  preset: z.enum(['shorts', 'box']).optional(),
62
76
  fontName: z.string().min(1).max(200).optional(),
@@ -87,7 +101,7 @@ export const timelineSchema = z.object({
87
101
  }).superRefine((timeline, ctx) => {
88
102
  const calculated = timeline.scenes.reduce((sum, scene) => sum + scene.durationSec, 0);
89
103
  if (Math.abs(calculated - timeline.totalDurationSec) > 0.01) {
90
- ctx.addIssue({ code: 'custom', message: 'totalDurationSec가 장면 길이 합계와 다릅니다.' });
104
+ ctx.addIssue({ code: 'custom', message: M().timelineTotalMismatch });
91
105
  }
92
106
  });
93
107
  export const renderJobSchema = z.object({
@@ -106,7 +120,7 @@ export function parseFile(schema, value, filePath) {
106
120
  const result = schema.safeParse(value);
107
121
  if (!result.success) {
108
122
  const issues = result.error.issues.slice(0, 10).map((issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`);
109
- throw new Error(`영상 프로젝트 파일 검증 실패: ${filePath}\n${issues.join('\n')}`);
123
+ throw new Error(M().fileInvalid(filePath, issues.join('\n')));
110
124
  }
111
125
  return result.data;
112
126
  }
@@ -6,19 +6,49 @@ import { friendlyGoogleError } from '../lib/google-errors.js';
6
6
  import { mediaUploadOptions } from '../lib/google-timeouts.js';
7
7
  import { validateVideo } from './render.js';
8
8
  import { encodePathSegment } from '../lib/url-path.js';
9
+ import { catalog } from '#core/lang.js';
10
+ const M = catalog({
11
+ confirmVisible: (status) => `${status} 게시에는 confirmVisible=true가 필요합니다.`,
12
+ filePathInvalid: 'filePath는 존재하는 절대경로여야 합니다.',
13
+ emptyFile: '업로드할 영상 파일이 비어 있거나 파일이 아닙니다.',
14
+ formats: '지원 영상 형식은 .mp4, .mov, .webm입니다.',
15
+ tagsLength: 'tags의 전체 길이는 쉼표를 포함해 500자 이하여야 합니다.',
16
+ shortsUnreadable: '쇼츠 규격을 확인할 영상 정보를 읽지 못했습니다.',
17
+ shortsAspect: 'shortsOnly=true일 때 영상은 정사각형 또는 세로형이어야 합니다.',
18
+ shortsDuration: 'YouTube Shorts 영상은 180초 이하여야 합니다.',
19
+ notFound: (videoId) => `YouTube 영상을 찾지 못했습니다: ${videoId}`,
20
+ titleLength: 'title은 1~100자여야 합니다.',
21
+ descriptionLength: 'description은 5,000자 이하여야 합니다.',
22
+ noVideoStream: '업로드 파일에 비디오 스트림이 없습니다.',
23
+ noVideoId: 'YouTube 업로드 응답에 videoId가 없습니다.',
24
+ }, {
25
+ confirmVisible: (status) => `Publishing as ${status} requires confirmVisible=true.`,
26
+ filePathInvalid: 'filePath must be an existing absolute path.',
27
+ emptyFile: 'The video file to upload is empty or not a file.',
28
+ formats: 'Supported video formats are .mp4, .mov, and .webm.',
29
+ tagsLength: 'The total length of tags, including commas, must be 500 characters or less.',
30
+ shortsUnreadable: 'Could not read the video information needed to check the Shorts format.',
31
+ shortsAspect: 'When shortsOnly=true, the video must be square or vertical.',
32
+ shortsDuration: 'YouTube Shorts videos must be 180 seconds or less.',
33
+ notFound: (videoId) => `YouTube video not found: ${videoId}`,
34
+ titleLength: 'title must be 1-100 characters.',
35
+ descriptionLength: 'description must be 5,000 characters or less.',
36
+ noVideoStream: 'The upload file has no video stream.',
37
+ noVideoId: 'The YouTube upload response has no videoId.',
38
+ });
9
39
  export const YOUTUBE_SCOPE = 'https://www.googleapis.com/auth/youtube.force-ssl';
10
40
  function assertVisibilityConfirmed(privacyStatus, confirmVisible) {
11
41
  if (privacyStatus !== 'private' && confirmVisible !== true) {
12
- throw new Error(`${privacyStatus} 게시에는 confirmVisible=true가 필요합니다.`);
42
+ throw new Error(M().confirmVisible(privacyStatus));
13
43
  }
14
44
  }
15
45
  function assertUploadFile(filePath) {
16
46
  if (!path.isAbsolute(filePath) || !existsSync(filePath)) {
17
- throw new Error('filePath는 존재하는 절대경로여야 합니다.');
47
+ throw new Error(M().filePathInvalid);
18
48
  }
19
49
  const stat = statSync(filePath);
20
50
  if (!stat.isFile() || stat.size <= 0)
21
- throw new Error('업로드할 영상 파일이 비어 있거나 파일이 아닙니다.');
51
+ throw new Error(M().emptyFile);
22
52
  const ext = path.extname(filePath).toLowerCase();
23
53
  const mimeType = ext === '.mp4'
24
54
  ? 'video/mp4'
@@ -28,12 +58,12 @@ function assertUploadFile(filePath) {
28
58
  ? 'video/webm'
29
59
  : null;
30
60
  if (!mimeType)
31
- throw new Error('지원 영상 형식은 .mp4, .mov, .webm입니다.');
61
+ throw new Error(M().formats);
32
62
  return { size: stat.size, mimeType };
33
63
  }
34
64
  function assertTags(tags = []) {
35
65
  if (tags.join(',').length > 500)
36
- throw new Error('tags의 전체 길이는 쉼표를 포함해 500자 이하여야 합니다.');
66
+ throw new Error(M().tagsLength);
37
67
  }
38
68
  function videoFacts(validation) {
39
69
  const stream = validation.streams.find((item) => typeof item === 'object' && item !== null && item.codec_type === 'video');
@@ -49,12 +79,12 @@ function videoFacts(validation) {
49
79
  }
50
80
  function assertShortsCompatible(facts) {
51
81
  if (!facts.width || !facts.height || !facts.durationSec) {
52
- throw new Error('쇼츠 규격을 확인할 영상 정보를 읽지 못했습니다.');
82
+ throw new Error(M().shortsUnreadable);
53
83
  }
54
84
  if (facts.width > facts.height)
55
- throw new Error('shortsOnly=true일 때 영상은 정사각형 또는 세로형이어야 합니다.');
85
+ throw new Error(M().shortsAspect);
56
86
  if (facts.durationSec > 180)
57
- throw new Error('YouTube Shorts 영상은 180초 이하여야 합니다.');
87
+ throw new Error(M().shortsDuration);
58
88
  }
59
89
  function safeStatus(video) {
60
90
  return {
@@ -79,21 +109,21 @@ function safeStatus(video) {
79
109
  }
80
110
  export async function getYouTubeVideoStatus(auth, videoId) {
81
111
  const youtube = google.youtube({ version: 'v3', auth });
112
+ // try 는 API 호출만 감싼다 — 우리 검사(영상 없음)를 같은 try 에 두면 catch 에서 메시지 문구로 구분해야 한다.
113
+ let response;
82
114
  try {
83
- const response = await youtube.videos.list({
115
+ response = await youtube.videos.list({
84
116
  part: ['snippet', 'status', 'processingDetails'],
85
117
  id: [videoId],
86
118
  });
87
- const video = response.data.items?.[0];
88
- if (!video)
89
- throw new Error(`YouTube 영상을 찾지 못했습니다: ${videoId}`);
90
- return safeStatus(video);
91
119
  }
92
120
  catch (error) {
93
- if (error instanceof Error && error.message.startsWith('YouTube 영상을 찾지 못했습니다'))
94
- throw error;
95
121
  throw friendlyGoogleError(error);
96
122
  }
123
+ const video = response.data.items?.[0];
124
+ if (!video)
125
+ throw new Error(M().notFound(videoId));
126
+ return safeStatus(video);
97
127
  }
98
128
  export async function uploadYouTubeVideo(auth, input) {
99
129
  if (!input.expectedChannelId)
@@ -103,20 +133,22 @@ export async function uploadYouTubeVideo(auth, input) {
103
133
  assertVisibilityConfirmed(privacyStatus, input.confirmVisible);
104
134
  const file = assertUploadFile(input.filePath);
105
135
  if (!input.title.trim() || input.title.length > 100)
106
- throw new Error('title은 1~100자여야 합니다.');
136
+ throw new Error(M().titleLength);
107
137
  if ((input.description?.length ?? 0) > 5_000)
108
- throw new Error('description은 5,000자 이하여야 합니다.');
138
+ throw new Error(M().descriptionLength);
109
139
  assertTags(input.tags);
110
140
  const validation = await validateVideo(input.filePath);
111
141
  const facts = videoFacts(validation);
112
142
  if (!validation.streams.some((item) => typeof item === 'object' && item !== null && item.codec_type === 'video')) {
113
- throw new Error('업로드 파일에 비디오 스트림이 없습니다.');
143
+ throw new Error(M().noVideoStream);
114
144
  }
115
145
  if (input.shortsOnly)
116
146
  assertShortsCompatible(facts);
117
147
  const youtube = google.youtube({ version: 'v3', auth });
148
+ // try 는 업로드 호출만 감싼다 — 응답 검사(videoId 없음)를 같은 try 에 두면 catch 에서 메시지 문구로 구분해야 했다.
149
+ let response;
118
150
  try {
119
- const response = await youtube.videos.insert({
151
+ response = await youtube.videos.insert({
120
152
  part: ['snippet', 'status'],
121
153
  notifySubscribers: input.notifySubscribers ?? false,
122
154
  requestBody: {
@@ -141,22 +173,20 @@ export async function uploadYouTubeVideo(auth, input) {
141
173
  body: createReadStream(input.filePath),
142
174
  },
143
175
  }, mediaUploadOptions());
144
- const videoId = response.data.id;
145
- if (!videoId)
146
- throw new Error('YouTube 업로드 응답에 videoId가 없습니다.');
147
- return {
148
- ...safeStatus(response.data),
149
- authenticatedChannel: channel,
150
- requestedPrivacyStatus: privacyStatus,
151
- file: { path: input.filePath, size: file.size, ...facts },
152
- validationWarnings: validation.issues,
153
- };
154
176
  }
155
177
  catch (error) {
156
- if (error instanceof Error && error.message.includes('videoId'))
157
- throw error;
158
178
  throw friendlyGoogleError(error);
159
179
  }
180
+ const videoId = response.data.id;
181
+ if (!videoId)
182
+ throw new Error(M().noVideoId);
183
+ return {
184
+ ...safeStatus(response.data),
185
+ authenticatedChannel: channel,
186
+ requestedPrivacyStatus: privacyStatus,
187
+ file: { path: input.filePath, size: file.size, ...facts },
188
+ validationWarnings: validation.issues,
189
+ };
160
190
  }
161
191
  export async function updateYouTubeVideoPrivacy(auth, input) {
162
192
  assertVisibilityConfirmed(input.privacyStatus, input.confirmVisible);
@@ -165,7 +195,7 @@ export async function updateYouTubeVideoPrivacy(auth, input) {
165
195
  const currentResponse = await youtube.videos.list({ part: ['status'], id: [input.videoId] });
166
196
  const current = currentResponse.data.items?.[0];
167
197
  if (!current)
168
- throw new Error(`YouTube 영상을 찾지 못했습니다: ${input.videoId}`);
198
+ throw new Error(M().notFound(input.videoId));
169
199
  await youtube.videos.update({
170
200
  part: ['status'],
171
201
  requestBody: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoonion/mimi-seed-mcp",
3
- "version": "0.23.4",
3
+ "version": "0.25.0",
4
4
  "description": "Mimi Seed MCP server \u2014 Firebase + AdMob + Google Play + App Store management for Claude Code / Codex / Cursor / any MCP client.",
5
5
  "type": "module",
6
6
  "imports": {