@yoonion/mimi-seed-mcp 0.24.0 → 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 (287) 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 +11 -29
  55. package/dist/auth/scopes.js +38 -11
  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.js +10 -2
  115. package/dist/helpers.d.ts +4 -2
  116. package/dist/helpers.js +66 -32
  117. package/dist/i18n/manifest-en.d.ts +6 -0
  118. package/dist/i18n/manifest-en.js +53 -0
  119. package/dist/i18n/tools-en/admob.d.ts +25 -0
  120. package/dist/i18n/tools-en/admob.js +24 -0
  121. package/dist/i18n/tools-en/ai.d.ts +14 -0
  122. package/dist/i18n/tools-en/ai.js +13 -0
  123. package/dist/i18n/tools-en/android.d.ts +14 -0
  124. package/dist/i18n/tools-en/android.js +13 -0
  125. package/dist/i18n/tools-en/appstore.d.ts +240 -0
  126. package/dist/i18n/tools-en/appstore.js +239 -0
  127. package/dist/i18n/tools-en/auth.d.ts +16 -0
  128. package/dist/i18n/tools-en/auth.js +15 -0
  129. package/dist/i18n/tools-en/bigquery.d.ts +16 -0
  130. package/dist/i18n/tools-en/bigquery.js +15 -0
  131. package/dist/i18n/tools-en/billing.d.ts +17 -0
  132. package/dist/i18n/tools-en/billing.js +16 -0
  133. package/dist/i18n/tools-en/checks.d.ts +23 -0
  134. package/dist/i18n/tools-en/checks.js +22 -0
  135. package/dist/i18n/tools-en/ci.d.ts +21 -0
  136. package/dist/i18n/tools-en/ci.js +20 -0
  137. package/dist/i18n/tools-en/drive.d.ts +33 -0
  138. package/dist/i18n/tools-en/drive.js +32 -0
  139. package/dist/i18n/tools-en/facebook.d.ts +14 -0
  140. package/dist/i18n/tools-en/facebook.js +13 -0
  141. package/dist/i18n/tools-en/firebase.d.ts +42 -0
  142. package/dist/i18n/tools-en/firebase.js +41 -0
  143. package/dist/i18n/tools-en/ga4.d.ts +35 -0
  144. package/dist/i18n/tools-en/ga4.js +34 -0
  145. package/dist/i18n/tools-en/googleads.d.ts +15 -0
  146. package/dist/i18n/tools-en/googleads.js +14 -0
  147. package/dist/i18n/tools-en/gsc.d.ts +27 -0
  148. package/dist/i18n/tools-en/gsc.js +26 -0
  149. package/dist/i18n/tools-en/iam.d.ts +15 -0
  150. package/dist/i18n/tools-en/iam.js +14 -0
  151. package/dist/i18n/tools-en/index.d.ts +7 -0
  152. package/dist/i18n/tools-en/index.js +58 -0
  153. package/dist/i18n/tools-en/instagram.d.ts +16 -0
  154. package/dist/i18n/tools-en/instagram.js +15 -0
  155. package/dist/i18n/tools-en/jenkins.d.ts +41 -0
  156. package/dist/i18n/tools-en/jenkins.js +40 -0
  157. package/dist/i18n/tools-en/naver.d.ts +10 -0
  158. package/dist/i18n/tools-en/naver.js +9 -0
  159. package/dist/i18n/tools-en/playstore.d.ts +148 -0
  160. package/dist/i18n/tools-en/playstore.js +147 -0
  161. package/dist/i18n/tools-en/registrar.d.ts +6 -0
  162. package/dist/i18n/tools-en/registrar.js +6 -0
  163. package/dist/i18n/tools-en/threads.d.ts +21 -0
  164. package/dist/i18n/tools-en/threads.js +20 -0
  165. package/dist/i18n/tools-en/tiktok.d.ts +21 -0
  166. package/dist/i18n/tools-en/tiktok.js +20 -0
  167. package/dist/i18n/tools-en/video.d.ts +59 -0
  168. package/dist/i18n/tools-en/video.js +58 -0
  169. package/dist/i18n/tools-en/youtube.d.ts +44 -0
  170. package/dist/i18n/tools-en/youtube.js +43 -0
  171. package/dist/iam/key-files.js +13 -3
  172. package/dist/instagram/api.js +19 -5
  173. package/dist/instagram/config.js +11 -3
  174. package/dist/instagram/setup.js +37 -11
  175. package/dist/jenkins/builds.d.ts +2 -2
  176. package/dist/jenkins/builds.js +70 -30
  177. package/dist/jenkins/config.d.ts +5 -0
  178. package/dist/jenkins/config.js +25 -6
  179. package/dist/jenkins/credentials.js +33 -13
  180. package/dist/jenkins/http.js +6 -3
  181. package/dist/jenkins/jobs.js +19 -5
  182. package/dist/jenkins/messages.js +93 -36
  183. package/dist/lib/cli-args.js +13 -7
  184. package/dist/lib/google-errors.js +31 -9
  185. package/dist/lib/http.js +10 -3
  186. package/dist/lib/json-file.d.ts +15 -0
  187. package/dist/lib/json-file.js +65 -0
  188. package/dist/lib/meta-auth.d.ts +1 -1
  189. package/dist/lib/meta-auth.js +26 -8
  190. package/dist/lib/package-name.js +15 -4
  191. package/dist/lib/package-root.js +1 -1
  192. package/dist/lib/paginate.js +10 -2
  193. package/dist/lib/path-containment.js +22 -6
  194. package/dist/lib/resource-id.js +10 -3
  195. package/dist/lib/store-create-result.js +54 -13
  196. package/dist/lib/text-validators.js +20 -5
  197. package/dist/lib/tool-registrar.d.ts +9 -0
  198. package/dist/lib/tool-registrar.js +33 -14
  199. package/dist/lib/tool-text.d.ts +31 -0
  200. package/dist/lib/tool-text.js +52 -0
  201. package/dist/lib/toolsets.js +13 -3
  202. package/dist/lib/url-path.js +3 -1
  203. package/dist/naver/tools.js +138 -46
  204. package/dist/playstore/data-safety.js +16 -4
  205. package/dist/playstore/errors.js +33 -8
  206. package/dist/playstore/financials.js +83 -35
  207. package/dist/playstore/listing.js +7 -1
  208. package/dist/playstore/messages.js +179 -57
  209. package/dist/playstore/products.js +10 -2
  210. package/dist/playstore/recovery.js +10 -2
  211. package/dist/playstore/releases.js +34 -14
  212. package/dist/playstore/reviews.js +14 -4
  213. package/dist/playstore/statistics.js +3 -1
  214. package/dist/prompts.js +160 -50
  215. package/dist/registers/admob.js +36 -11
  216. package/dist/registers/android.js +25 -9
  217. package/dist/registers/appstore/apps.js +22 -6
  218. package/dist/registers/appstore/customer-reviews.js +7 -1
  219. package/dist/registers/appstore/declarations.js +63 -19
  220. package/dist/registers/appstore/media.js +76 -24
  221. package/dist/registers/appstore/metadata.js +26 -8
  222. package/dist/registers/appstore/products.js +53 -19
  223. package/dist/registers/appstore/review-submission.js +31 -9
  224. package/dist/registers/appstore/testflight.js +82 -24
  225. package/dist/registers/appstore/versions.js +88 -30
  226. package/dist/registers/auth.js +343 -90
  227. package/dist/registers/bigquery.js +54 -14
  228. package/dist/registers/billing.js +18 -4
  229. package/dist/registers/checks.js +20 -5
  230. package/dist/registers/ci.js +60 -20
  231. package/dist/registers/drive.js +18 -7
  232. package/dist/registers/facebook.js +31 -9
  233. package/dist/registers/firebase.js +21 -7
  234. package/dist/registers/googleads.js +23 -6
  235. package/dist/registers/gsc.js +3 -1
  236. package/dist/registers/iam.js +44 -13
  237. package/dist/registers/instagram.js +19 -5
  238. package/dist/registers/jenkins.js +43 -14
  239. package/dist/registers/naver.js +13 -3
  240. package/dist/registers/playstore/financials.d.ts +6 -0
  241. package/dist/registers/playstore/financials.js +48 -0
  242. package/dist/registers/playstore/listing.d.ts +15 -0
  243. package/dist/registers/playstore/listing.js +138 -0
  244. package/dist/registers/playstore/media.d.ts +6 -0
  245. package/dist/registers/playstore/media.js +56 -0
  246. package/dist/registers/playstore/products.d.ts +21 -0
  247. package/dist/registers/playstore/products.js +238 -0
  248. package/dist/registers/playstore/recovery.d.ts +11 -0
  249. package/dist/registers/playstore/recovery.js +105 -0
  250. package/dist/registers/playstore/releases.d.ts +8 -0
  251. package/dist/registers/playstore/releases.js +157 -0
  252. package/dist/registers/playstore/reviews.d.ts +6 -0
  253. package/dist/registers/playstore/reviews.js +43 -0
  254. package/dist/registers/playstore/service-accounts.d.ts +13 -0
  255. package/dist/registers/playstore/service-accounts.js +127 -0
  256. package/dist/registers/playstore/shared.d.ts +12 -0
  257. package/dist/registers/playstore/shared.js +24 -0
  258. package/dist/registers/playstore.d.ts +8 -0
  259. package/dist/registers/playstore.js +28 -734
  260. package/dist/registers/threads.js +28 -8
  261. package/dist/registers/tiktok.js +4 -2
  262. package/dist/registers/video.js +3 -1
  263. package/dist/remote-sync.js +80 -28
  264. package/dist/resources.d.ts +0 -8
  265. package/dist/resources.js +73 -32
  266. package/dist/server.d.ts +2 -0
  267. package/dist/server.js +9 -1
  268. package/dist/social/profile-store.js +36 -12
  269. package/dist/social/setup-cli.js +1 -1
  270. package/dist/threads/api.js +23 -6
  271. package/dist/threads/setup.js +42 -14
  272. package/dist/tiktok-business/api.js +13 -3
  273. package/dist/tiktok-business/auth.js +10 -2
  274. package/dist/tiktok-business/config.js +8 -3
  275. package/dist/tiktok-business/posting.d.ts +6 -0
  276. package/dist/tiktok-business/posting.js +118 -36
  277. package/dist/tiktok-business/setup-cli.js +3 -1
  278. package/dist/tools-cli.js +4 -5
  279. package/dist/video/captions.js +3 -1
  280. package/dist/video/files.js +13 -3
  281. package/dist/video/project.js +65 -21
  282. package/dist/video/providers.js +52 -16
  283. package/dist/video/render.js +71 -22
  284. package/dist/video/research.js +10 -2
  285. package/dist/video/schemas.js +19 -5
  286. package/dist/video/youtube-publish.js +62 -32
  287. package/package.json +1 -1
@@ -1,12 +1,32 @@
1
1
  import fs from 'node:fs';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
- import { findProjectManifest, isValidSocialProfileId, manifestSocialProfile, } from '#core/project-manifest.js';
4
+ import { lookupProjectManifest, isValidSocialProfileId, manifestSocialProfile, } from '#core/project-manifest.js';
5
5
  import { writeCredentialJson } from '#core/atomic-write.js';
6
+ import { catalog } from '#core/lang.js';
7
+ import { readCredentialFileSync } from '#core/credential-read.js';
8
+ const M = catalog({
9
+ invalidId: '소셜 프로필 ID가 올바르지 않습니다. ' +
10
+ '영문자·숫자로 시작하는 1~64자의 영문자/숫자/점/밑줄/하이픈만 사용할 수 있습니다.',
11
+ notObject: '객체 형식이 아닙니다.',
12
+ unreadable: (file, msg) => `기존 소셜 프로필 파일을 읽을 수 없어 덮어쓰지 않았습니다: ${file} ` + `(${msg})`,
13
+ profile: (id) => `프로필 '${id}'`,
14
+ defaultProfile: '기본 프로필',
15
+ manifestInvalid: (file) => `프로젝트 매니페스트를 읽을 수 없어 어느 소셜 계정을 쓸지 정할 수 없습니다: ${file}. ` +
16
+ '기본 계정으로 대신 게시하지 않습니다 — 파일을 고치거나, profile 인자로 프로필을 직접 지정하세요.',
17
+ }, {
18
+ invalidId: 'Invalid social profile ID. ' +
19
+ 'Use 1–64 characters of letters, digits, dots, underscores, or hyphens, starting with a letter or digit.',
20
+ notObject: 'It is not an object.',
21
+ unreadable: (file, msg) => `Could not read the existing social profile file, so it was not overwritten: ${file} (${msg})`,
22
+ profile: (id) => `profile '${id}'`,
23
+ defaultProfile: 'default profile',
24
+ manifestInvalid: (file) => `Cannot read the project manifest, so the social account to use is unknown: ${file}. ` +
25
+ 'Not falling back to the default account — fix the file, or pass the profile argument explicitly.',
26
+ });
6
27
  function validateProfileId(profile) {
7
28
  if (!isValidSocialProfileId(profile)) {
8
- throw new Error('소셜 프로필 ID가 올바르지 않습니다. ' +
9
- '영문자·숫자로 시작하는 1~64자의 영문자/숫자/점/밑줄/하이픈만 사용할 수 있습니다.');
29
+ throw new Error(M().invalidId);
10
30
  }
11
31
  return profile;
12
32
  }
@@ -18,9 +38,13 @@ export function resolveSocialConfigTarget(platform, options = {}) {
18
38
  profile = validateProfileId(options.profile);
19
39
  }
20
40
  else {
21
- const loaded = findProjectManifest(options.startDir ?? process.cwd());
22
- if (loaded)
23
- profile = manifestSocialProfile(loaded.manifest, platform);
41
+ // 매니페스트가 깨졌으면 기본 계정으로 폴백하지 않는다 — 그 파일이 다른 프로필을 지정했을 수 있다(다른 계정에 게시).
42
+ // 매니페스트의 socialProfiles 값이 잘못된 경우(manifestSocialProfile 이 throw)와 같은 취급이다.
43
+ const lookup = lookupProjectManifest(options.startDir ?? process.cwd());
44
+ if (lookup.state === 'invalid')
45
+ throw new Error(M().manifestInvalid(lookup.filePath));
46
+ if (lookup.state === 'ok')
47
+ profile = manifestSocialProfile(lookup.loaded.manifest, platform);
24
48
  }
25
49
  return profile
26
50
  ? { profile, filePath: path.join(root, 'social-profiles', `${profile}.json`) }
@@ -29,7 +53,7 @@ export function resolveSocialConfigTarget(platform, options = {}) {
29
53
  export function loadSocialPlatformConfig(platform, options = {}) {
30
54
  const target = resolveSocialConfigTarget(platform, options);
31
55
  try {
32
- const parsed = JSON.parse(fs.readFileSync(target.filePath, 'utf-8'));
56
+ const parsed = JSON.parse(readCredentialFileSync(target.filePath));
33
57
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
34
58
  return null;
35
59
  if (target.profile) {
@@ -38,6 +62,7 @@ export function loadSocialPlatformConfig(platform, options = {}) {
38
62
  return parsed;
39
63
  }
40
64
  catch {
65
+ // 깨진 설정은 '미설정' — 대상 파일이 이미 정해져 다른 계정으로 넘어가지 않고, 깨진 파일은 mimi_seed_status 가 보고한다
41
66
  return null;
42
67
  }
43
68
  }
@@ -48,15 +73,14 @@ export function saveSocialPlatformConfig(platform, config, options = {}) {
48
73
  let existing = {};
49
74
  if (fs.existsSync(target.filePath)) {
50
75
  try {
51
- const parsed = JSON.parse(fs.readFileSync(target.filePath, 'utf-8'));
76
+ const parsed = JSON.parse(readCredentialFileSync(target.filePath));
52
77
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
53
- throw new Error('객체 형식이 아닙니다.');
78
+ throw new Error(M().notObject);
54
79
  }
55
80
  existing = parsed;
56
81
  }
57
82
  catch (error) {
58
- throw new Error(`기존 소셜 프로필 파일을 읽을 수 없어 덮어쓰지 않았습니다: ${target.filePath} ` +
59
- `(${error instanceof Error ? error.message : String(error)})`, { cause: error });
83
+ throw new Error(M().unreadable(target.filePath, error instanceof Error ? error.message : String(error)), { cause: error });
60
84
  }
61
85
  }
62
86
  value = { ...existing, [platform]: config };
@@ -65,5 +89,5 @@ export function saveSocialPlatformConfig(platform, config, options = {}) {
65
89
  return target;
66
90
  }
67
91
  export function socialTargetLabel(target) {
68
- return target.profile ? `프로필 '${target.profile}'` : '기본 프로필';
92
+ return target.profile ? M().profile(target.profile) : M().defaultProfile;
69
93
  }
@@ -154,7 +154,7 @@ async function setupFacebook(profile) {
154
154
  let result = await connectFacebook(token, pageId || undefined, options);
155
155
  // 토큰이 여러 페이지에 닿으면 connectFacebook 은 목록만 주고 저장하지 않는다.
156
156
  // 다시 실행하라고 내보내지 말고, 여기서 바로 골라 받는다.
157
- if (!result.ok && result.text.includes('여러 페이지에')) {
157
+ if (!result.ok && result.needsPageChoice) {
158
158
  console.log('');
159
159
  console.log(indent(result.text));
160
160
  pageId = await ask(M.fbPickPage);
@@ -1,6 +1,22 @@
1
1
  import { metaApiError } from '../lib/meta-auth.js';
2
2
  import { fetchWithTimeout } from '../lib/http.js';
3
3
  import { encodePathSegment } from '../lib/url-path.js';
4
+ import { catalog } from '#core/lang.js';
5
+ const M = catalog({
6
+ noUserId: 'Threads user ID를 조회하지 못했습니다. 토큰에 threads_basic 권한이 있는지 확인하세요.',
7
+ refreshUnparsable: 'Threads 토큰 갱신 응답을 해석하지 못했습니다. 새 토큰을 발급해 다시 연결하세요.',
8
+ refreshIncomplete: 'Threads 토큰 갱신 응답에 access_token 또는 expires_in이 없습니다.',
9
+ mediaFailed: (status, msg) => `미디어 처리 실패 (${status})${msg ? `: ${msg}` : ''}`,
10
+ mediaTimeout: '미디어 처리 대기 시간 초과 (60초). 잠시 후 다시 시도하세요.',
11
+ carouselCount: (n) => `캐러셀은 2~20장의 이미지가 필요합니다 (받은 수: ${n}).`,
12
+ }, {
13
+ noUserId: 'Could not look up the Threads user ID. Check that the token has the threads_basic permission.',
14
+ refreshUnparsable: 'Could not parse the Threads token refresh response. Issue a new token and connect again.',
15
+ refreshIncomplete: 'The Threads token refresh response has no access_token or expires_in.',
16
+ mediaFailed: (status, msg) => `Media processing failed (${status})${msg ? `: ${msg}` : ''}`,
17
+ mediaTimeout: 'Timed out waiting for media processing (60 seconds). Try again shortly.',
18
+ carouselCount: (n) => `A carousel needs 2–20 images (received: ${n}).`,
19
+ });
4
20
  // Threads Graph API. Instagram 과 달리 base 가 하나뿐이라 토큰 prefix 분기가 없다.
5
21
  // graph.threads.net/v1.0
6
22
  // 게시 흐름은 인스타와 같은 2단계: container 생성(/me/threads) → publish(/me/threads_publish).
@@ -48,7 +64,7 @@ export async function getAccount(cfg) {
48
64
  export async function fetchUserId(accessToken) {
49
65
  const res = await thFetch(accessToken, '/me', { fields: 'id,username', access_token: accessToken });
50
66
  if (!res.id) {
51
- throw new Error('Threads user ID를 조회하지 못했습니다. 토큰에 threads_basic 권한이 있는지 확인하세요.');
67
+ throw new Error(M().noUserId);
52
68
  }
53
69
  return res.id;
54
70
  }
@@ -77,10 +93,10 @@ export async function refreshAccessToken(accessToken) {
77
93
  parsed = JSON.parse(text);
78
94
  }
79
95
  catch {
80
- throw new Error('Threads 토큰 갱신 응답을 해석하지 못했습니다. 새 토큰을 발급해 다시 연결하세요.');
96
+ throw new Error(M().refreshUnparsable);
81
97
  }
82
98
  if (!parsed.access_token || !Number.isFinite(parsed.expires_in) || parsed.expires_in <= 0) {
83
- throw new Error('Threads 토큰 갱신 응답에 access_token 또는 expires_in이 없습니다.');
99
+ throw new Error(M().refreshIncomplete);
84
100
  }
85
101
  return { accessToken: parsed.access_token, expiresInSeconds: parsed.expires_in };
86
102
  }
@@ -90,6 +106,7 @@ async function fetchPermalink(cfg, mediaId) {
90
106
  return meta.permalink;
91
107
  }
92
108
  catch {
109
+ // 게시는 이미 끝났다 — permalink 조회 실패로 성공을 오류로 바꾸면 재시도가 중복 게시를 만든다
93
110
  return undefined;
94
111
  }
95
112
  }
@@ -103,11 +120,11 @@ async function waitForContainer(cfg, containerId) {
103
120
  if (status === 'FINISHED')
104
121
  return;
105
122
  if (status === 'ERROR' || status === 'EXPIRED') {
106
- throw new Error(`미디어 처리 실패 (${status})${error_message ? `: ${error_message}` : ''}`);
123
+ throw new Error(M().mediaFailed(status, error_message));
107
124
  }
108
125
  await new Promise((r) => setTimeout(r, INTERVAL_MS));
109
126
  }
110
- throw new Error('미디어 처리 대기 시간 초과 (60초). 잠시 후 다시 시도하세요.');
127
+ throw new Error(M().mediaTimeout);
111
128
  }
112
129
  async function publish(cfg, creationId) {
113
130
  const published = await thFetch(cfg.accessToken, '/me/threads_publish', { creation_id: creationId, access_token: cfg.accessToken }, 'POST');
@@ -143,7 +160,7 @@ export async function postVideo(cfg, videoUrl, text = '', altText) {
143
160
  }
144
161
  export async function postCarousel(cfg, imageUrls, text) {
145
162
  if (imageUrls.length < 2 || imageUrls.length > 20) {
146
- throw new Error(`캐러셀은 2~20장의 이미지가 필요합니다 (받은 수: ${imageUrls.length}).`);
163
+ throw new Error(M().carouselCount(imageUrls.length));
147
164
  }
148
165
  // Step 1: 각 이미지를 children container 로 생성 (sequential — 부분 실패 시 명확)
149
166
  const childIds = [];
@@ -3,6 +3,34 @@
3
3
  import { saveThreadsConfig } from './config.js';
4
4
  import * as api from './api.js';
5
5
  import { resolveSocialConfigTarget, socialTargetLabel } from '../social/profile-store.js';
6
+ import { catalog } from '#core/lang.js';
7
+ const M = catalog({
8
+ userIdFailed: '❌ userId 자동 조회 실패',
9
+ userIdHint: 'userId를 명시적으로 전달하거나 토큰을 다시 확인하세요.',
10
+ connected: '✅ Threads 연결 확인 완료',
11
+ target: (t) => ` 저장 대상: ${t}`,
12
+ account: (a) => ` 계정: ${a}`,
13
+ expires: (d) => ` 토큰 만료: ${d}`,
14
+ verifyFailed: '❌ 토큰 검증 실패',
15
+ verifyHint: '토큰을 다시 발급받거나 userId를 직접 지정해보세요.',
16
+ refreshed: '✅ Threads 토큰 갱신 완료',
17
+ newExpiry: (d) => ` 새 만료일: ${d}`,
18
+ refreshFailed: '❌ Threads 토큰 자동 갱신 실패 — 기존 설정은 보존했습니다.',
19
+ refreshRecovery: ' 복구: mimi-seed auth threads 로 브라우저에서 다시 로그인하세요.',
20
+ }, {
21
+ userIdFailed: '❌ Could not look up userId automatically',
22
+ userIdHint: 'Pass userId explicitly or check the token again.',
23
+ connected: '✅ Threads connection verified',
24
+ target: (t) => ` Saved to: ${t}`,
25
+ account: (a) => ` Account: ${a}`,
26
+ expires: (d) => ` Token expires: ${d}`,
27
+ verifyFailed: '❌ Token verification failed',
28
+ verifyHint: 'Issue a new token or specify userId directly.',
29
+ refreshed: '✅ Threads token refreshed',
30
+ newExpiry: (d) => ` New expiry: ${d}`,
31
+ refreshFailed: '❌ Automatic Threads token refresh failed — the existing settings were kept.',
32
+ refreshRecovery: ' Recovery: log in again in the browser with mimi-seed auth threads.',
33
+ });
6
34
  const SIXTY_DAYS_MS = 60 * 24 * 60 * 60 * 1000;
7
35
  export async function connectThreads(accessToken, userId, assumeIssuedNow = true, options = {}, expiresInSeconds) {
8
36
  if (expiresInSeconds !== undefined && (!Number.isFinite(expiresInSeconds) || expiresInSeconds <= 0 || expiresInSeconds > 5_184_000)) {
@@ -19,10 +47,10 @@ export async function connectThreads(accessToken, userId, assumeIssuedNow = true
19
47
  return {
20
48
  ok: false,
21
49
  text: [
22
- '❌ userId 자동 조회 실패',
50
+ M().userIdFailed,
23
51
  ` ${err.message}`,
24
52
  '',
25
- 'userId를 명시적으로 전달하거나 토큰을 다시 확인하세요.',
53
+ M().userIdHint,
26
54
  ].join('\n'),
27
55
  };
28
56
  }
@@ -41,11 +69,11 @@ export async function connectThreads(accessToken, userId, assumeIssuedNow = true
41
69
  return {
42
70
  ok: true,
43
71
  text: [
44
- '✅ Threads 연결 확인 완료',
45
- ` 저장 대상: ${socialTargetLabel(target)}`,
46
- ` 계정: @${account.username}${account.name ? ` (${account.name})` : ''}`,
72
+ M().connected,
73
+ M().target(socialTargetLabel(target)),
74
+ M().account(`@${account.username}${account.name ? ` (${account.name})` : ''}`),
47
75
  ` ID: ${account.id}`,
48
- expiresAt ? ` 토큰 만료: ${expiresAt.slice(0, 10)}` : '',
76
+ expiresAt ? M().expires(expiresAt.slice(0, 10)) : '',
49
77
  ]
50
78
  .filter(Boolean)
51
79
  .join('\n'),
@@ -56,11 +84,11 @@ export async function connectThreads(accessToken, userId, assumeIssuedNow = true
56
84
  return {
57
85
  ok: false,
58
86
  text: [
59
- '❌ 토큰 검증 실패',
87
+ M().verifyFailed,
60
88
  ` userId: ${resolvedUserId}`,
61
89
  ` ${err.message}`,
62
90
  '',
63
- '토큰을 다시 발급받거나 userId를 직접 지정해보세요.',
91
+ M().verifyHint,
64
92
  ].join('\n'),
65
93
  };
66
94
  }
@@ -82,10 +110,10 @@ export async function refreshThreadsToken(currentAccessToken, options = {}) {
82
110
  return {
83
111
  ok: true,
84
112
  text: [
85
- '✅ Threads 토큰 갱신 완료',
86
- ` 저장 대상: ${socialTargetLabel(target)}`,
87
- ` 계정: @${account.username}`,
88
- ` 새 만료일: ${expiresAt.slice(0, 10)}`,
113
+ M().refreshed,
114
+ M().target(socialTargetLabel(target)),
115
+ M().account(`@${account.username}`),
116
+ M().newExpiry(expiresAt.slice(0, 10)),
89
117
  ].join('\n'),
90
118
  };
91
119
  }
@@ -93,9 +121,9 @@ export async function refreshThreadsToken(currentAccessToken, options = {}) {
93
121
  return {
94
122
  ok: false,
95
123
  text: [
96
- '❌ Threads 토큰 자동 갱신 실패 — 기존 설정은 보존했습니다.',
124
+ M().refreshFailed,
97
125
  ` ${err.message}`,
98
- ' 복구: mimi-seed auth threads 로 브라우저에서 다시 로그인하세요.',
126
+ M().refreshRecovery,
99
127
  ].join('\n'),
100
128
  };
101
129
  }
@@ -1,5 +1,15 @@
1
1
  import { fetchWithTimeout } from '../lib/http.js';
2
+ import { catalog } from '#core/lang.js';
2
3
  export const TIKTOK_API_BASE = 'https://business-api.tiktok.com/open_api/v1.3';
4
+ const M = catalog({
5
+ unparseable: (endpoint, status) => `TikTok ${endpoint} 응답을 해석하지 못했습니다 (HTTP ${status}).`,
6
+ failed: (endpoint, detail, code) => `TikTok ${endpoint} 실패: ${detail} (code ${String(code)})`,
7
+ noTokenFields: (endpoint) => `TikTok ${endpoint} 응답에 필수 토큰 필드가 없습니다.`,
8
+ }, {
9
+ unparseable: (endpoint, status) => `Could not parse the TikTok ${endpoint} response (HTTP ${status}).`,
10
+ failed: (endpoint, detail, code) => `TikTok ${endpoint} failed: ${detail} (code ${String(code)})`,
11
+ noTokenFields: (endpoint) => `The TikTok ${endpoint} response is missing required token fields.`,
12
+ });
3
13
  export class TikTokApiError extends Error {
4
14
  code;
5
15
  requestId;
@@ -18,10 +28,10 @@ function parseEnvelope(text, status, endpoint) {
18
28
  body = JSON.parse(text);
19
29
  }
20
30
  catch {
21
- throw new TikTokApiError(`TikTok ${endpoint} 응답을 해석하지 못했습니다 (HTTP ${status}).`);
31
+ throw new TikTokApiError(M().unparseable(endpoint, status));
22
32
  }
23
33
  if (status < 200 || status >= 300 || body.code !== 0) {
24
- throw new TikTokApiError(`TikTok ${endpoint} 실패: ${body.message || `HTTP ${status}`} (code ${body.code})`, body.code, body.request_id);
34
+ throw new TikTokApiError(M().failed(endpoint, body.message || `HTTP ${status}`, body.code), body.code, body.request_id);
25
35
  }
26
36
  return body;
27
37
  }
@@ -33,7 +43,7 @@ async function tokenPost(endpoint, payload) {
33
43
  });
34
44
  const envelope = parseEnvelope(await response.text(), response.status, endpoint);
35
45
  if (!envelope.data?.access_token || !envelope.data.refresh_token || !envelope.data.open_id) {
36
- throw new TikTokApiError(`TikTok ${endpoint} 응답에 필수 토큰 필드가 없습니다.`);
46
+ throw new TikTokApiError(M().noTokenFields(endpoint));
37
47
  }
38
48
  return envelope.data;
39
49
  }
@@ -1,5 +1,13 @@
1
1
  import { loadTikTokBusinessConfig, requireTikTokBusinessConfig, saveTikTokBusinessConfig, } from './config.js';
2
2
  import { refreshAccessToken } from './api.js';
3
+ import { catalog } from '#core/lang.js';
4
+ const M = catalog({
5
+ refreshExpired: 'TikTok refresh token이 만료되었습니다. `mimi-seed auth tiktok`으로 다시 연결하세요.',
6
+ noPublishScope: 'TikTok 연결에 video.publish 권한이 없습니다. Developer 앱 권한을 승인한 뒤 `mimi-seed auth tiktok`으로 다시 연결하세요.',
7
+ }, {
8
+ refreshExpired: 'The TikTok refresh token has expired. Reconnect with `mimi-seed auth tiktok`.',
9
+ noPublishScope: 'The TikTok connection lacks the video.publish scope. Approve the Developer app permission, then reconnect with `mimi-seed auth tiktok`.',
10
+ });
3
11
  const REFRESH_EARLY_MS = 5 * 60 * 1000;
4
12
  function expiresAt(seconds, now = Date.now()) {
5
13
  return new Date(now + seconds * 1000).toISOString();
@@ -32,7 +40,7 @@ export async function ensureFreshTikTokConfig() {
32
40
  const config = requireTikTokBusinessConfig();
33
41
  const freshness = tokenFreshness(config);
34
42
  if (freshness.state === 'refresh_expired') {
35
- throw new Error('TikTok refresh token이 만료되었습니다. `mimi-seed auth tiktok`으로 다시 연결하세요.');
43
+ throw new Error(M().refreshExpired);
36
44
  }
37
45
  if (freshness.state === 'fresh')
38
46
  return config;
@@ -60,7 +68,7 @@ export function safeTokenInspection(config, tokenInfo) {
60
68
  export async function ensureTikTokPublishConfig() {
61
69
  const config = await ensureFreshTikTokConfig();
62
70
  if (!hasTikTokScope(config, 'video.publish')) {
63
- throw new Error('TikTok 연결에 video.publish 권한이 없습니다. Developer 앱 권한을 승인한 뒤 `mimi-seed auth tiktok`으로 다시 연결하세요.');
71
+ throw new Error(M().noPublishScope);
64
72
  }
65
73
  return config;
66
74
  }
@@ -1,11 +1,14 @@
1
- import { readFileSync } from 'node:fs';
2
1
  import os from 'node:os';
3
2
  import path from 'node:path';
4
3
  import { writeCredentialJson } from '#core/atomic-write.js';
4
+ import { assertCredentialFileReadable } from '../lib/json-file.js';
5
+ import { catalog } from '#core/lang.js';
6
+ import { readCredentialFileSync } from '#core/credential-read.js';
7
+ const M = catalog({ missing: 'TikTok Business 설정이 없습니다. 터미널에서 `mimi-seed auth tiktok`을 실행하세요.' }, { missing: 'No TikTok Business configuration. Run `mimi-seed auth tiktok` in a terminal.' });
5
8
  export const TIKTOK_BUSINESS_CONFIG_PATH = path.join(os.homedir(), '.mimi-seed', 'tiktok-business.json');
6
9
  export function loadTikTokBusinessConfig() {
7
10
  try {
8
- const value = JSON.parse(readFileSync(TIKTOK_BUSINESS_CONFIG_PATH, 'utf8'));
11
+ const value = JSON.parse(readCredentialFileSync(TIKTOK_BUSINESS_CONFIG_PATH));
9
12
  const required = [
10
13
  'clientId', 'clientSecret', 'redirectUri', 'accessToken', 'refreshToken',
11
14
  'accessTokenExpiresAt', 'refreshTokenExpiresAt', 'openId', 'scope', 'tokenType',
@@ -15,6 +18,7 @@ export function loadTikTokBusinessConfig() {
15
18
  return value;
16
19
  }
17
20
  catch {
21
+ // 읽을 수 없으면 '미설정' — 깨진 파일은 requireTikTokBusinessConfig · mimi_seed_status 가 json-file 로 따로 진단한다
18
22
  return null;
19
23
  }
20
24
  }
@@ -24,7 +28,8 @@ export function saveTikTokBusinessConfig(config) {
24
28
  export function requireTikTokBusinessConfig() {
25
29
  const config = loadTikTokBusinessConfig();
26
30
  if (!config) {
27
- throw new Error('TikTok Business 설정이 없습니다. 터미널에서 `mimi-seed auth tiktok`을 실행하세요.');
31
+ assertCredentialFileReadable(TIKTOK_BUSINESS_CONFIG_PATH, '`mimi-seed auth tiktok`');
32
+ throw new Error(M().missing);
28
33
  }
29
34
  return config;
30
35
  }
@@ -57,6 +57,11 @@ declare function assertVideoFacts(facts: VideoFacts, settings: TikTokVideoSettin
57
57
  declare function assertThumbnailOffset(thumbnailOffsetMs: number | undefined, durationSec: number): void;
58
58
  declare function acquirePublishLock(openId: string, contentHash: string, lockDir?: string): void;
59
59
  declare function releasePublishLock(openId: string, contentHash: string, lockDir?: string): void;
60
+ /**
61
+ * 같은 계정·영상의 막아야 할 기존 기록. 기록 파일이 있는데 읽을 수 없으면 "기록 없음"으로 보지 않고 throw —
62
+ * 그 파일이 published 였을 수 있고, 잠금 파일까지 지워진 상태라면 공개 게시가 두 번 나간다.
63
+ */
64
+ declare function existingBlockingAudit(openId: string, contentHash: string, file?: string): TikTokPublishAudit | null;
60
65
  export declare function planVideoPost(input: PlanVideoPostInput): Promise<TikTokPostPlan>;
61
66
  export declare function loadPostPlan(planId: string): TikTokPostPlan;
62
67
  export declare function publishPlannedVideo(planId: string, confirmPublish: boolean): Promise<{
@@ -96,6 +101,7 @@ export declare const __testing: {
96
101
  assertVideoFacts: typeof assertVideoFacts;
97
102
  acquirePublishLock: typeof acquirePublishLock;
98
103
  countMentions: typeof countMentions;
104
+ existingBlockingAudit: typeof existingBlockingAudit;
99
105
  fpsValue: typeof fpsValue;
100
106
  releasePublishLock: typeof releasePublishLock;
101
107
  safeUrl: typeof safeUrl;