@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.
- package/dist/admob/cli.js +34 -5
- package/dist/admob/errors.js +39 -14
- package/dist/ai/client.js +35 -14
- package/dist/ai/notes.js +14 -3
- package/dist/ai/review.js +17 -4
- package/dist/android/keystore-store.js +28 -8
- package/dist/android/keystore.d.ts +17 -2
- package/dist/android/keystore.js +110 -21
- package/dist/android/messages.d.ts +13 -11
- package/dist/android/messages.js +166 -72
- package/dist/android/playstore-sa.js +6 -3
- package/dist/appstore/analytics.js +46 -14
- package/dist/appstore/app-info-policy.js +7 -1
- package/dist/appstore/app-info.js +13 -3
- package/dist/appstore/apps.js +7 -1
- package/dist/appstore/asset-library-write.js +119 -37
- package/dist/appstore/asset-library.js +19 -5
- package/dist/appstore/auth.d.ts +2 -0
- package/dist/appstore/auth.js +31 -5
- package/dist/appstore/client.js +27 -6
- package/dist/appstore/declarations.js +22 -6
- package/dist/appstore/errors.d.ts +1 -1
- package/dist/appstore/errors.js +60 -34
- package/dist/appstore/http.d.ts +6 -0
- package/dist/appstore/http.js +22 -5
- package/dist/appstore/messages.js +86 -28
- package/dist/appstore/previews.js +22 -6
- package/dist/appstore/product-localization.js +10 -2
- package/dist/appstore/product-review.js +29 -10
- package/dist/appstore/products.js +20 -6
- package/dist/appstore/read-response.js +13 -3
- package/dist/appstore/release-target.js +13 -3
- package/dist/appstore/release.js +59 -22
- package/dist/appstore/review-preview.js +17 -6
- package/dist/appstore/review-submission.js +86 -35
- package/dist/appstore/sales.js +96 -44
- package/dist/appstore/screenshots.js +19 -5
- package/dist/appstore/testflight.js +41 -18
- package/dist/appstore/upload-parts.js +12 -3
- package/dist/appstore/versions.js +22 -10
- package/dist/auth/bigquery-auth.js +44 -15
- package/dist/auth/bigquery-setup-cli.js +1 -1
- package/dist/auth/cli.js +4 -2
- package/dist/auth/constants.js +13 -3
- package/dist/auth/drive-auth.d.ts +3 -2
- package/dist/auth/drive-auth.js +47 -17
- package/dist/auth/drive-setup-cli.js +1 -0
- package/dist/auth/errors.d.ts +75 -0
- package/dist/auth/errors.js +190 -86
- package/dist/auth/google-auth.d.ts +3 -1
- package/dist/auth/google-auth.js +39 -27
- package/dist/auth/playstore-auth.d.ts +1 -0
- package/dist/auth/playstore-auth.js +35 -15
- package/dist/auth/scopes.d.ts +18 -28
- package/dist/auth/scopes.js +53 -14
- package/dist/auth/youtube-channel.d.ts +8 -0
- package/dist/auth/youtube-channel.js +11 -3
- package/dist/bigquery/ids.js +19 -5
- package/dist/bigquery/tools.js +24 -8
- package/dist/billing/tools.js +22 -6
- package/dist/checks/appstore-submission.d.ts +1 -1
- package/dist/checks/appstore-submission.js +29 -8
- package/dist/checks/plan.js +169 -62
- package/dist/checks/release-status.js +10 -2
- package/dist/checks/risks.js +230 -63
- package/dist/checks/screenshots.d.ts +4 -4
- package/dist/checks/screenshots.js +63 -22
- package/dist/ci/config.js +8 -5
- package/dist/ci/gitlab.js +3 -1
- package/dist/core/atomic-write.d.ts +5 -2
- package/dist/core/atomic-write.js +8 -4
- package/dist/core/catch-scan.d.ts +17 -0
- package/dist/core/catch-scan.js +111 -0
- package/dist/core/checks/billing.d.ts +5 -0
- package/dist/core/checks/billing.js +36 -5
- package/dist/core/checks/lockfile.js +2 -0
- package/dist/core/checks/release-doctor/fcm.js +1 -0
- package/dist/core/checks/release-doctor/files.d.ts +3 -1
- package/dist/core/checks/release-doctor/files.js +12 -1
- package/dist/core/checks/release-doctor/gradle-apply.js +1 -0
- package/dist/core/checks/release-doctor/ios-xcode.js +22 -3
- package/dist/core/checks/release-doctor/target-sdk.js +1 -1
- package/dist/core/checks/release-doctor/util.d.ts +5 -0
- package/dist/core/checks/release-doctor/util.js +56 -0
- package/dist/core/checks/release-doctor.js +59 -16
- package/dist/core/credential-envelope.d.ts +25 -0
- package/dist/core/credential-envelope.js +66 -0
- package/dist/core/credential-keystore.d.ts +37 -0
- package/dist/core/credential-keystore.js +275 -0
- package/dist/core/credential-read.d.ts +33 -0
- package/dist/core/credential-read.js +112 -0
- package/dist/core/credential-store.d.ts +61 -0
- package/dist/core/credential-store.js +240 -0
- package/dist/core/http-errors.js +1 -0
- package/dist/core/i18n-scan.d.ts +10 -0
- package/dist/core/i18n-scan.js +79 -0
- package/dist/core/json-file.d.ts +30 -0
- package/dist/core/json-file.js +53 -0
- package/dist/core/lang.d.ts +14 -0
- package/dist/core/lang.js +22 -2
- package/dist/core/project-manifest.d.ts +24 -1
- package/dist/core/project-manifest.js +27 -16
- package/dist/drive/tools.js +86 -34
- package/dist/facebook/api.js +3 -1
- package/dist/facebook/config.js +11 -3
- package/dist/facebook/setup.d.ts +2 -0
- package/dist/facebook/setup.js +32 -9
- package/dist/firebase/cli.js +39 -5
- package/dist/firebase/tools.js +36 -10
- package/dist/ga4/cli.js +48 -4
- package/dist/ga4/tools.js +4 -2
- package/dist/googleads/config.js +24 -8
- package/dist/googleads/tools.js +3 -1
- package/dist/gsc/tools.d.ts +116 -9
- package/dist/gsc/tools.js +101 -17
- package/dist/helpers.d.ts +4 -2
- package/dist/helpers.js +82 -44
- package/dist/i18n/manifest-en.d.ts +6 -0
- package/dist/i18n/manifest-en.js +53 -0
- package/dist/i18n/tools-en/admob.d.ts +25 -0
- package/dist/i18n/tools-en/admob.js +24 -0
- package/dist/i18n/tools-en/ai.d.ts +14 -0
- package/dist/i18n/tools-en/ai.js +13 -0
- package/dist/i18n/tools-en/android.d.ts +14 -0
- package/dist/i18n/tools-en/android.js +13 -0
- package/dist/i18n/tools-en/appstore.d.ts +240 -0
- package/dist/i18n/tools-en/appstore.js +239 -0
- package/dist/i18n/tools-en/auth.d.ts +16 -0
- package/dist/i18n/tools-en/auth.js +15 -0
- package/dist/i18n/tools-en/bigquery.d.ts +16 -0
- package/dist/i18n/tools-en/bigquery.js +15 -0
- package/dist/i18n/tools-en/billing.d.ts +17 -0
- package/dist/i18n/tools-en/billing.js +16 -0
- package/dist/i18n/tools-en/checks.d.ts +23 -0
- package/dist/i18n/tools-en/checks.js +22 -0
- package/dist/i18n/tools-en/ci.d.ts +21 -0
- package/dist/i18n/tools-en/ci.js +20 -0
- package/dist/i18n/tools-en/drive.d.ts +33 -0
- package/dist/i18n/tools-en/drive.js +32 -0
- package/dist/i18n/tools-en/facebook.d.ts +14 -0
- package/dist/i18n/tools-en/facebook.js +13 -0
- package/dist/i18n/tools-en/firebase.d.ts +42 -0
- package/dist/i18n/tools-en/firebase.js +41 -0
- package/dist/i18n/tools-en/ga4.d.ts +35 -0
- package/dist/i18n/tools-en/ga4.js +34 -0
- package/dist/i18n/tools-en/googleads.d.ts +15 -0
- package/dist/i18n/tools-en/googleads.js +14 -0
- package/dist/i18n/tools-en/gsc.d.ts +27 -0
- package/dist/i18n/tools-en/gsc.js +26 -0
- package/dist/i18n/tools-en/iam.d.ts +15 -0
- package/dist/i18n/tools-en/iam.js +14 -0
- package/dist/i18n/tools-en/index.d.ts +7 -0
- package/dist/i18n/tools-en/index.js +58 -0
- package/dist/i18n/tools-en/instagram.d.ts +16 -0
- package/dist/i18n/tools-en/instagram.js +15 -0
- package/dist/i18n/tools-en/jenkins.d.ts +41 -0
- package/dist/i18n/tools-en/jenkins.js +40 -0
- package/dist/i18n/tools-en/naver.d.ts +10 -0
- package/dist/i18n/tools-en/naver.js +9 -0
- package/dist/i18n/tools-en/playstore.d.ts +148 -0
- package/dist/i18n/tools-en/playstore.js +147 -0
- package/dist/i18n/tools-en/registrar.d.ts +6 -0
- package/dist/i18n/tools-en/registrar.js +6 -0
- package/dist/i18n/tools-en/threads.d.ts +21 -0
- package/dist/i18n/tools-en/threads.js +20 -0
- package/dist/i18n/tools-en/tiktok.d.ts +21 -0
- package/dist/i18n/tools-en/tiktok.js +20 -0
- package/dist/i18n/tools-en/video.d.ts +59 -0
- package/dist/i18n/tools-en/video.js +58 -0
- package/dist/i18n/tools-en/youtube.d.ts +44 -0
- package/dist/i18n/tools-en/youtube.js +43 -0
- package/dist/iam/key-files.js +13 -3
- package/dist/instagram/api.js +19 -5
- package/dist/instagram/config.js +11 -3
- package/dist/instagram/setup.js +37 -11
- package/dist/jenkins/builds.d.ts +2 -2
- package/dist/jenkins/builds.js +70 -30
- package/dist/jenkins/config.d.ts +5 -0
- package/dist/jenkins/config.js +25 -6
- package/dist/jenkins/credentials.js +33 -13
- package/dist/jenkins/http.js +6 -3
- package/dist/jenkins/jobs.js +19 -5
- package/dist/jenkins/messages.js +93 -36
- package/dist/lib/cli-args.js +13 -7
- package/dist/lib/google-errors.js +31 -9
- package/dist/lib/http.js +10 -3
- package/dist/lib/json-file.d.ts +15 -0
- package/dist/lib/json-file.js +65 -0
- package/dist/lib/meta-auth.d.ts +1 -1
- package/dist/lib/meta-auth.js +26 -8
- package/dist/lib/package-name.js +15 -4
- package/dist/lib/package-root.js +1 -1
- package/dist/lib/paginate.js +10 -2
- package/dist/lib/path-containment.js +22 -6
- package/dist/lib/resource-id.js +10 -3
- package/dist/lib/store-create-result.js +54 -13
- package/dist/lib/text-validators.js +20 -5
- package/dist/lib/tool-registrar.d.ts +9 -0
- package/dist/lib/tool-registrar.js +33 -14
- package/dist/lib/tool-text.d.ts +31 -0
- package/dist/lib/tool-text.js +52 -0
- package/dist/lib/toolsets.js +13 -3
- package/dist/lib/url-path.js +3 -1
- package/dist/naver/tools.js +138 -46
- package/dist/playstore/data-safety.js +16 -4
- package/dist/playstore/errors.js +33 -8
- package/dist/playstore/financials.js +83 -35
- package/dist/playstore/listing.js +7 -1
- package/dist/playstore/messages.js +179 -57
- package/dist/playstore/products.js +10 -2
- package/dist/playstore/recovery.js +10 -2
- package/dist/playstore/releases.js +34 -14
- package/dist/playstore/reviews.js +14 -4
- package/dist/playstore/statistics.js +3 -1
- package/dist/prompts.js +160 -50
- package/dist/registers/admob.js +36 -11
- package/dist/registers/android.js +25 -9
- package/dist/registers/appstore/apps.js +22 -6
- package/dist/registers/appstore/customer-reviews.js +7 -1
- package/dist/registers/appstore/declarations.js +63 -19
- package/dist/registers/appstore/media.js +76 -24
- package/dist/registers/appstore/metadata.js +26 -8
- package/dist/registers/appstore/products.js +53 -19
- package/dist/registers/appstore/review-submission.js +31 -9
- package/dist/registers/appstore/testflight.js +82 -24
- package/dist/registers/appstore/versions.js +88 -30
- package/dist/registers/auth.js +343 -90
- package/dist/registers/bigquery.js +54 -14
- package/dist/registers/billing.js +18 -4
- package/dist/registers/checks.js +20 -5
- package/dist/registers/ci.js +60 -20
- package/dist/registers/drive.js +18 -7
- package/dist/registers/facebook.js +31 -9
- package/dist/registers/firebase.js +21 -7
- package/dist/registers/googleads.js +23 -6
- package/dist/registers/gsc.js +42 -39
- package/dist/registers/iam.js +44 -13
- package/dist/registers/instagram.js +19 -5
- package/dist/registers/jenkins.js +43 -14
- package/dist/registers/naver.js +13 -3
- package/dist/registers/playstore/financials.d.ts +6 -0
- package/dist/registers/playstore/financials.js +48 -0
- package/dist/registers/playstore/listing.d.ts +15 -0
- package/dist/registers/playstore/listing.js +138 -0
- package/dist/registers/playstore/media.d.ts +6 -0
- package/dist/registers/playstore/media.js +56 -0
- package/dist/registers/playstore/products.d.ts +21 -0
- package/dist/registers/playstore/products.js +238 -0
- package/dist/registers/playstore/recovery.d.ts +11 -0
- package/dist/registers/playstore/recovery.js +105 -0
- package/dist/registers/playstore/releases.d.ts +8 -0
- package/dist/registers/playstore/releases.js +157 -0
- package/dist/registers/playstore/reviews.d.ts +6 -0
- package/dist/registers/playstore/reviews.js +43 -0
- package/dist/registers/playstore/service-accounts.d.ts +13 -0
- package/dist/registers/playstore/service-accounts.js +127 -0
- package/dist/registers/playstore/shared.d.ts +12 -0
- package/dist/registers/playstore/shared.js +24 -0
- package/dist/registers/playstore.d.ts +8 -0
- package/dist/registers/playstore.js +28 -734
- package/dist/registers/threads.js +28 -8
- package/dist/registers/tiktok.js +4 -2
- package/dist/registers/video.js +3 -1
- package/dist/remote-sync.js +80 -28
- package/dist/resources.d.ts +0 -8
- package/dist/resources.js +73 -32
- package/dist/server.d.ts +2 -0
- package/dist/server.js +9 -1
- package/dist/social/profile-store.js +36 -12
- package/dist/social/setup-cli.js +1 -1
- package/dist/threads/api.js +23 -6
- package/dist/threads/setup.js +42 -14
- package/dist/tiktok-business/api.js +13 -3
- package/dist/tiktok-business/auth.js +10 -2
- package/dist/tiktok-business/config.js +8 -3
- package/dist/tiktok-business/posting.d.ts +6 -0
- package/dist/tiktok-business/posting.js +118 -36
- package/dist/tiktok-business/setup-cli.js +3 -1
- package/dist/tools-cli.js +4 -5
- package/dist/video/captions.js +3 -1
- package/dist/video/files.js +13 -3
- package/dist/video/project.js +65 -21
- package/dist/video/providers.js +52 -16
- package/dist/video/render.js +71 -22
- package/dist/video/research.js +10 -2
- package/dist/video/schemas.js +19 -5
- package/dist/video/youtube-publish.js +62 -32
- package/package.json +1 -1
|
@@ -6,6 +6,81 @@ import { CREDENTIAL_DIR_MODE, CREDENTIAL_FILE_MODE, writeJsonAtomic } from '#cor
|
|
|
6
6
|
import { validateVideo } from '../video/render.js';
|
|
7
7
|
import { TikTokApiError, getPublishStatus, getVideoSettings, publishVideo } from './api.js';
|
|
8
8
|
import { ensureTikTokPublishConfig } from './auth.js';
|
|
9
|
+
import { catalog } from '#core/lang.js';
|
|
10
|
+
import { readJsonFile } from '../lib/json-file.js';
|
|
11
|
+
const M = catalog({
|
|
12
|
+
invalidHttps: (field) => `${field}는 유효한 HTTPS URL이어야 합니다.`,
|
|
13
|
+
notHttps: (field) => `${field}는 HTTPS URL이어야 합니다.`,
|
|
14
|
+
captionLength: 'TikTok caption은 UTF-16 기준 2,200자 이하여야 합니다.',
|
|
15
|
+
mentions: 'TikTok caption의 멘션은 최대 30개입니다.',
|
|
16
|
+
noVideoStream: '업로드 파일에 비디오 스트림이 없습니다.',
|
|
17
|
+
noMetadata: 'TikTok 규격 검사에 필요한 영상 메타데이터를 읽지 못했습니다.',
|
|
18
|
+
size: 'TikTok 영상은 0바이트 초과, 1GB 이하여야 합니다.',
|
|
19
|
+
duration: 'TikTok 영상 길이는 3~600초여야 합니다.',
|
|
20
|
+
accountMax: (sec, max) => `영상 길이 ${sec}초가 계정 한도 ${max}초를 초과합니다.`,
|
|
21
|
+
dimensions: 'TikTok 영상의 가로·세로는 각각 최소 360px이어야 합니다.',
|
|
22
|
+
fps: 'TikTok 영상 FPS는 23~60이어야 합니다.',
|
|
23
|
+
thumbnailOffset: 'thumbnailOffsetMs는 영상 길이를 초과할 수 없습니다.',
|
|
24
|
+
sourcePath: 'sourceFilePath는 존재하는 절대경로여야 합니다.',
|
|
25
|
+
sourceNotFile: 'sourceFilePath는 파일이어야 합니다.',
|
|
26
|
+
formats: 'TikTok 지원 영상 형식은 .mp4, .mov, .webm입니다.',
|
|
27
|
+
lockExists: '동일 영상의 게시 예약이 이미 존재합니다. 감사 로그와 TikTok 상태를 먼저 확인하세요.',
|
|
28
|
+
duplicatePlan: (state, publishId) => `동일 영상의 기존 게시 기록이 있습니다 (state=${state}, publishId=${publishId}). `
|
|
29
|
+
+ '중복 자동 게시를 차단했습니다.',
|
|
30
|
+
warnings: [
|
|
31
|
+
'videoUrl은 TikTok API for Business 앱에 등록·검증된 도메인의 HTTPS URL이어야 합니다.',
|
|
32
|
+
'videoUrl은 리디렉션 없이 영상에 직접 2xx로 응답해야 합니다. TikTok은 3xx 리디렉션을 따라가지 않습니다.',
|
|
33
|
+
'URL은 TikTok이 가져갈 때까지 최소 30분 이상 유효해야 합니다.',
|
|
34
|
+
'이 계획은 공개 게시이며 30분 뒤 만료됩니다.',
|
|
35
|
+
],
|
|
36
|
+
badPlanId: 'planId 형식이 올바르지 않습니다.',
|
|
37
|
+
planNotFound: (planId) => `TikTok 게시 계획을 찾지 못했습니다: ${planId}`,
|
|
38
|
+
planExpired: 'TikTok 게시 계획이 만료되었습니다. 다시 계획을 생성하세요.',
|
|
39
|
+
confirmRequired: '공개 게시에는 같은 턴의 명시 승인 후 confirmPublish=true가 필요합니다.',
|
|
40
|
+
accountMismatch: '게시 계획을 만든 TikTok 계정과 현재 연결 계정이 다릅니다.',
|
|
41
|
+
duplicateBlocked: (state) => `중복 게시 차단: 기존 기록 state=${state}.`,
|
|
42
|
+
auditUnreadable: (file, reason) => `중복 게시 차단: 이 영상의 감사 기록을 읽을 수 없습니다 (${reason}): ${file}. 이미 게시됐는지 TikTok 에서 확인한 뒤 파일을 고치거나 지우세요.`,
|
|
43
|
+
outcomeUnknown: (error) => `${error} 게시 결과가 불명확하므로 자동 재시도하지 마세요.`,
|
|
44
|
+
noShareId: 'TikTok 성공 응답에 share_id/publish_id가 없어 게시 결과를 확인할 수 없습니다.',
|
|
45
|
+
noRetry: (error) => `${error} 자동 재시도하지 마세요.`,
|
|
46
|
+
auditFailed: 'TikTok은 게시 요청을 수락했지만 로컬 감사 로그 갱신에 실패했습니다. 자동 재시도하지 마세요.',
|
|
47
|
+
}, {
|
|
48
|
+
invalidHttps: (field) => `${field} must be a valid HTTPS URL.`,
|
|
49
|
+
notHttps: (field) => `${field} must be an HTTPS URL.`,
|
|
50
|
+
captionLength: 'The TikTok caption must be 2,200 characters or less (UTF-16).',
|
|
51
|
+
mentions: 'A TikTok caption can have at most 30 mentions.',
|
|
52
|
+
noVideoStream: 'The upload file has no video stream.',
|
|
53
|
+
noMetadata: 'Could not read the video metadata needed for the TikTok format check.',
|
|
54
|
+
size: 'A TikTok video must be larger than 0 bytes and at most 1GB.',
|
|
55
|
+
duration: 'A TikTok video must be 3-600 seconds long.',
|
|
56
|
+
accountMax: (sec, max) => `The video duration of ${sec}s exceeds the account limit of ${max}s.`,
|
|
57
|
+
dimensions: 'A TikTok video must be at least 360px in both width and height.',
|
|
58
|
+
fps: 'TikTok video FPS must be 23-60.',
|
|
59
|
+
thumbnailOffset: 'thumbnailOffsetMs cannot exceed the video duration.',
|
|
60
|
+
sourcePath: 'sourceFilePath must be an existing absolute path.',
|
|
61
|
+
sourceNotFile: 'sourceFilePath must be a file.',
|
|
62
|
+
formats: 'Supported TikTok video formats are .mp4, .mov, and .webm.',
|
|
63
|
+
lockExists: 'A publish reservation for the same video already exists. Check the audit log and the TikTok status first.',
|
|
64
|
+
duplicatePlan: (state, publishId) => `A previous publish record exists for the same video (state=${state}, publishId=${publishId}). `
|
|
65
|
+
+ 'Duplicate automatic publishing was blocked.',
|
|
66
|
+
warnings: [
|
|
67
|
+
'videoUrl must be an HTTPS URL on a domain registered and verified in the TikTok API for Business app.',
|
|
68
|
+
'videoUrl must respond with 2xx directly with the video, with no redirect. TikTok does not follow 3xx redirects.',
|
|
69
|
+
'The URL must stay valid for at least 30 minutes until TikTok fetches it.',
|
|
70
|
+
'This plan is a public post and expires in 30 minutes.',
|
|
71
|
+
],
|
|
72
|
+
badPlanId: 'Invalid planId format.',
|
|
73
|
+
planNotFound: (planId) => `TikTok publish plan not found: ${planId}`,
|
|
74
|
+
planExpired: 'The TikTok publish plan has expired. Create a new plan.',
|
|
75
|
+
confirmRequired: 'A public post requires confirmPublish=true after the user\'s explicit approval in the same turn.',
|
|
76
|
+
accountMismatch: 'The TikTok account that created the publish plan differs from the currently connected account.',
|
|
77
|
+
duplicateBlocked: (state) => `Duplicate publish blocked: existing record state=${state}.`,
|
|
78
|
+
auditUnreadable: (file, reason) => `Duplicate publish blocked: the audit record for this video cannot be read (${reason}): ${file}. Check on TikTok whether it was already posted, then fix or delete the file.`,
|
|
79
|
+
outcomeUnknown: (error) => `${error} The publish outcome is unknown, so do not retry automatically.`,
|
|
80
|
+
noShareId: 'The TikTok success response has no share_id/publish_id, so the publish outcome cannot be confirmed.',
|
|
81
|
+
noRetry: (error) => `${error} Do not retry automatically.`,
|
|
82
|
+
auditFailed: 'TikTok accepted the publish request, but updating the local audit log failed. Do not retry automatically.',
|
|
83
|
+
});
|
|
9
84
|
const STATE_DIR = path.join(os.homedir(), '.mimi-seed', 'tiktok-business');
|
|
10
85
|
const PLAN_DIR = path.join(STATE_DIR, 'plans');
|
|
11
86
|
const AUDIT_DIR = path.join(STATE_DIR, 'audit');
|
|
@@ -21,10 +96,10 @@ function assertHttpsUrl(value, field) {
|
|
|
21
96
|
url = new URL(value);
|
|
22
97
|
}
|
|
23
98
|
catch {
|
|
24
|
-
throw new Error(
|
|
99
|
+
throw new Error(M().invalidHttps(field));
|
|
25
100
|
}
|
|
26
101
|
if (url.protocol !== 'https:')
|
|
27
|
-
throw new Error(
|
|
102
|
+
throw new Error(M().notHttps(field));
|
|
28
103
|
}
|
|
29
104
|
function safeUrl(value) {
|
|
30
105
|
const url = new URL(value);
|
|
@@ -35,9 +110,9 @@ function countMentions(caption) {
|
|
|
35
110
|
}
|
|
36
111
|
function assertCaption(caption) {
|
|
37
112
|
if (caption.length > 2_200)
|
|
38
|
-
throw new Error(
|
|
113
|
+
throw new Error(M().captionLength);
|
|
39
114
|
if (countMentions(caption) > 30)
|
|
40
|
-
throw new Error(
|
|
115
|
+
throw new Error(M().mentions);
|
|
41
116
|
}
|
|
42
117
|
function numberValue(value) {
|
|
43
118
|
const parsed = Number(value);
|
|
@@ -54,7 +129,7 @@ function factsFromValidation(sourceFilePath, validation) {
|
|
|
54
129
|
const stream = validation.streams.find((item) => typeof item === 'object' && item !== null && item.codec_type === 'video');
|
|
55
130
|
const format = validation.format;
|
|
56
131
|
if (!stream)
|
|
57
|
-
throw new Error(
|
|
132
|
+
throw new Error(M().noVideoStream);
|
|
58
133
|
const facts = {
|
|
59
134
|
sizeBytes: statSync(sourceFilePath).size,
|
|
60
135
|
width: numberValue(stream.width),
|
|
@@ -65,39 +140,39 @@ function factsFromValidation(sourceFilePath, validation) {
|
|
|
65
140
|
codec: typeof stream.codec_name === 'string' ? stream.codec_name : undefined,
|
|
66
141
|
};
|
|
67
142
|
if (Object.values(facts).slice(0, 5).some((value) => typeof value !== 'number' || !Number.isFinite(value))) {
|
|
68
|
-
throw new Error(
|
|
143
|
+
throw new Error(M().noMetadata);
|
|
69
144
|
}
|
|
70
145
|
return facts;
|
|
71
146
|
}
|
|
72
147
|
function assertVideoFacts(facts, settings) {
|
|
73
148
|
if (facts.sizeBytes <= 0 || facts.sizeBytes > MAX_FILE_BYTES)
|
|
74
|
-
throw new Error(
|
|
149
|
+
throw new Error(M().size);
|
|
75
150
|
if (facts.durationSec < 3 || facts.durationSec > 600)
|
|
76
|
-
throw new Error(
|
|
151
|
+
throw new Error(M().duration);
|
|
77
152
|
const accountMax = Number(settings.max_video_post_duration_sec);
|
|
78
153
|
if (Number.isFinite(accountMax) && facts.durationSec > accountMax) {
|
|
79
|
-
throw new Error(
|
|
154
|
+
throw new Error(M().accountMax(facts.durationSec.toFixed(1), accountMax));
|
|
80
155
|
}
|
|
81
156
|
if (facts.width < 360 || facts.height < 360)
|
|
82
|
-
throw new Error(
|
|
157
|
+
throw new Error(M().dimensions);
|
|
83
158
|
if (facts.fps < 23 || facts.fps > 60)
|
|
84
|
-
throw new Error(
|
|
159
|
+
throw new Error(M().fps);
|
|
85
160
|
}
|
|
86
161
|
function assertThumbnailOffset(thumbnailOffsetMs, durationSec) {
|
|
87
162
|
if (thumbnailOffsetMs !== undefined && thumbnailOffsetMs > durationSec * 1000) {
|
|
88
|
-
throw new Error(
|
|
163
|
+
throw new Error(M().thumbnailOffset);
|
|
89
164
|
}
|
|
90
165
|
}
|
|
91
166
|
function assertSourceFile(sourceFilePath) {
|
|
92
167
|
if (!path.isAbsolute(sourceFilePath) || !existsSync(sourceFilePath)) {
|
|
93
|
-
throw new Error(
|
|
168
|
+
throw new Error(M().sourcePath);
|
|
94
169
|
}
|
|
95
170
|
const stat = statSync(sourceFilePath);
|
|
96
171
|
if (!stat.isFile())
|
|
97
|
-
throw new Error(
|
|
172
|
+
throw new Error(M().sourceNotFile);
|
|
98
173
|
const ext = path.extname(sourceFilePath).toLowerCase();
|
|
99
174
|
if (!['.mp4', '.mov', '.webm'].includes(ext)) {
|
|
100
|
-
throw new Error(
|
|
175
|
+
throw new Error(M().formats);
|
|
101
176
|
}
|
|
102
177
|
}
|
|
103
178
|
async function sha256File(filePath) {
|
|
@@ -129,7 +204,7 @@ function acquirePublishLock(openId, contentHash, lockDir = LOCK_DIR) {
|
|
|
129
204
|
}
|
|
130
205
|
catch (error) {
|
|
131
206
|
if (error.code === 'EEXIST') {
|
|
132
|
-
throw new Error(
|
|
207
|
+
throw new Error(M().lockExists, {
|
|
133
208
|
cause: error,
|
|
134
209
|
});
|
|
135
210
|
}
|
|
@@ -151,11 +226,21 @@ function readJson(filePath) {
|
|
|
151
226
|
return JSON.parse(readFileSync(filePath, 'utf8'));
|
|
152
227
|
}
|
|
153
228
|
catch {
|
|
229
|
+
// 계획·감사 목록용 — 깨진 파일은 '없음'. 중복 게시 판정만은 existingBlockingAudit 가 readJsonFile 로 따로 막는다
|
|
154
230
|
return null;
|
|
155
231
|
}
|
|
156
232
|
}
|
|
157
|
-
|
|
158
|
-
|
|
233
|
+
/**
|
|
234
|
+
* 같은 계정·영상의 막아야 할 기존 기록. 기록 파일이 있는데 읽을 수 없으면 "기록 없음"으로 보지 않고 throw —
|
|
235
|
+
* 그 파일이 published 였을 수 있고, 잠금 파일까지 지워진 상태라면 공개 게시가 두 번 나간다.
|
|
236
|
+
*/
|
|
237
|
+
function existingBlockingAudit(openId, contentHash, file = auditPath(openId, contentHash)) {
|
|
238
|
+
const read = readJsonFile(file);
|
|
239
|
+
if (read.state === 'missing')
|
|
240
|
+
return null;
|
|
241
|
+
if (read.state === 'invalid' || read.state === 'locked')
|
|
242
|
+
throw new Error(M().auditUnreadable(file, read.reason));
|
|
243
|
+
const audit = read.value;
|
|
159
244
|
return audit && ['pending', 'published', 'unknown'].includes(audit.state) ? audit : null;
|
|
160
245
|
}
|
|
161
246
|
function postInfo(input) {
|
|
@@ -185,8 +270,7 @@ export async function planVideoPost(input) {
|
|
|
185
270
|
const contentHash = await sha256File(input.sourceFilePath);
|
|
186
271
|
const duplicate = existingBlockingAudit(config.openId, contentHash);
|
|
187
272
|
if (duplicate) {
|
|
188
|
-
throw new Error(
|
|
189
|
-
'중복 자동 게시를 차단했습니다.');
|
|
273
|
+
throw new Error(M().duplicatePlan(duplicate.state, duplicate.publishId ?? 'unknown'));
|
|
190
274
|
}
|
|
191
275
|
const request = {
|
|
192
276
|
business_id: config.openId,
|
|
@@ -209,36 +293,31 @@ export async function planVideoPost(input) {
|
|
|
209
293
|
videoFacts: facts,
|
|
210
294
|
request,
|
|
211
295
|
settings,
|
|
212
|
-
warnings: [
|
|
213
|
-
'videoUrl은 TikTok API for Business 앱에 등록·검증된 도메인의 HTTPS URL이어야 합니다.',
|
|
214
|
-
'videoUrl은 리디렉션 없이 영상에 직접 2xx로 응답해야 합니다. TikTok은 3xx 리디렉션을 따라가지 않습니다.',
|
|
215
|
-
'URL은 TikTok이 가져갈 때까지 최소 30분 이상 유효해야 합니다.',
|
|
216
|
-
'이 계획은 공개 게시이며 30분 뒤 만료됩니다.',
|
|
217
|
-
],
|
|
296
|
+
warnings: [...M().warnings],
|
|
218
297
|
};
|
|
219
298
|
privateWrite(planPath(planId), plan);
|
|
220
299
|
return plan;
|
|
221
300
|
}
|
|
222
301
|
export function loadPostPlan(planId) {
|
|
223
302
|
if (!/^[a-f0-9]{32}$/.test(planId))
|
|
224
|
-
throw new Error(
|
|
303
|
+
throw new Error(M().badPlanId);
|
|
225
304
|
const plan = readJson(planPath(planId));
|
|
226
305
|
if (!plan)
|
|
227
|
-
throw new Error(
|
|
306
|
+
throw new Error(M().planNotFound(planId));
|
|
228
307
|
if (Date.parse(plan.expiresAt) <= Date.now())
|
|
229
|
-
throw new Error(
|
|
308
|
+
throw new Error(M().planExpired);
|
|
230
309
|
return plan;
|
|
231
310
|
}
|
|
232
311
|
export async function publishPlannedVideo(planId, confirmPublish) {
|
|
233
312
|
if (!confirmPublish)
|
|
234
|
-
throw new Error(
|
|
313
|
+
throw new Error(M().confirmRequired);
|
|
235
314
|
const plan = loadPostPlan(planId);
|
|
236
315
|
const config = await ensureTikTokPublishConfig();
|
|
237
316
|
if (config.openId !== plan.openId)
|
|
238
|
-
throw new Error(
|
|
317
|
+
throw new Error(M().accountMismatch);
|
|
239
318
|
const duplicate = existingBlockingAudit(plan.openId, plan.contentHash);
|
|
240
319
|
if (duplicate)
|
|
241
|
-
throw new Error(
|
|
320
|
+
throw new Error(M().duplicateBlocked(duplicate.state));
|
|
242
321
|
acquirePublishLock(plan.openId, plan.contentHash);
|
|
243
322
|
const now = new Date().toISOString();
|
|
244
323
|
const baseAudit = {
|
|
@@ -276,19 +355,19 @@ export async function publishPlannedVideo(planId, confirmPublish) {
|
|
|
276
355
|
releasePublishLock(plan.openId, plan.contentHash);
|
|
277
356
|
}
|
|
278
357
|
else {
|
|
279
|
-
throw new Error(
|
|
358
|
+
throw new Error(M().outcomeUnknown(audit.error ?? ''), { cause: error });
|
|
280
359
|
}
|
|
281
360
|
throw error;
|
|
282
361
|
}
|
|
283
362
|
const publishId = result.share_id ?? result.publish_id;
|
|
284
363
|
if (!publishId) {
|
|
285
|
-
const error =
|
|
364
|
+
const error = M().noShareId;
|
|
286
365
|
privateWrite(auditPath(plan.openId, plan.contentHash), {
|
|
287
366
|
...baseAudit,
|
|
288
367
|
updatedAt: new Date().toISOString(),
|
|
289
368
|
error,
|
|
290
369
|
});
|
|
291
|
-
throw new TikTokApiError(
|
|
370
|
+
throw new TikTokApiError(M().noRetry(error), undefined, undefined, true);
|
|
292
371
|
}
|
|
293
372
|
const audit = {
|
|
294
373
|
...baseAudit,
|
|
@@ -300,7 +379,7 @@ export async function publishPlannedVideo(planId, confirmPublish) {
|
|
|
300
379
|
privateWrite(auditPath(plan.openId, plan.contentHash), audit);
|
|
301
380
|
}
|
|
302
381
|
catch (error) {
|
|
303
|
-
throw new Error(
|
|
382
|
+
throw new Error(M().auditFailed, {
|
|
304
383
|
cause: error,
|
|
305
384
|
});
|
|
306
385
|
}
|
|
@@ -317,6 +396,7 @@ function findAuditByPublishId(publishId) {
|
|
|
317
396
|
}
|
|
318
397
|
}
|
|
319
398
|
catch {
|
|
399
|
+
// 감사 폴더가 없으면 기록도 없다 — 상태 조회는 TikTok 응답만으로 돌려준다
|
|
320
400
|
return null;
|
|
321
401
|
}
|
|
322
402
|
return null;
|
|
@@ -366,6 +446,7 @@ export function listPublishAudits(limit = 20) {
|
|
|
366
446
|
.slice(0, limit);
|
|
367
447
|
}
|
|
368
448
|
catch {
|
|
449
|
+
// 감사 폴더가 없으면 게시 기록이 아직 없다
|
|
369
450
|
return [];
|
|
370
451
|
}
|
|
371
452
|
}
|
|
@@ -375,6 +456,7 @@ export const __testing = {
|
|
|
375
456
|
assertVideoFacts,
|
|
376
457
|
acquirePublishLock,
|
|
377
458
|
countMentions,
|
|
459
|
+
existingBlockingAudit,
|
|
378
460
|
fpsValue,
|
|
379
461
|
releasePublishLock,
|
|
380
462
|
safeUrl,
|
|
@@ -21,6 +21,7 @@ const ko = {
|
|
|
21
21
|
exchanging: ' 🔎 authorization code 교환 및 계정 검증 중...',
|
|
22
22
|
saved: (openId) => ` ✅ 연결 완료 (${openId}) — ~/.mimi-seed/tiktok-business.json (0600)`,
|
|
23
23
|
cancelled: ' 취소됨.',
|
|
24
|
+
noPublishScope: '승인된 권한에 video.publish가 없습니다. 앱 권한을 확인한 뒤 다시 승인하세요.',
|
|
24
25
|
};
|
|
25
26
|
const en = {
|
|
26
27
|
title: ' 🤖 Mimi Seed — Connect TikTok Business',
|
|
@@ -39,6 +40,7 @@ const en = {
|
|
|
39
40
|
exchanging: ' 🔎 Exchanging the authorization code and verifying the account...',
|
|
40
41
|
saved: (openId) => ` ✅ Connected (${openId}) — ~/.mimi-seed/tiktok-business.json (0600)`,
|
|
41
42
|
cancelled: ' Cancelled.',
|
|
43
|
+
noPublishScope: 'The granted scopes do not include video.publish. Check the app permissions, then authorize again.',
|
|
42
44
|
};
|
|
43
45
|
const M = resolveLang() === 'en' ? en : ko;
|
|
44
46
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -70,7 +72,7 @@ async function main() {
|
|
|
70
72
|
const token = await exchangeAuthorizationCode({ clientId, clientSecret, redirectUri, authCode });
|
|
71
73
|
const config = configFromToken({ clientId, clientSecret, redirectUri }, token);
|
|
72
74
|
if (!hasTikTokScope(config, 'video.publish')) {
|
|
73
|
-
throw new Error(
|
|
75
|
+
throw new Error(M.noPublishScope);
|
|
74
76
|
}
|
|
75
77
|
await getBusinessAccount(config);
|
|
76
78
|
saveTikTokBusinessConfig(config);
|
package/dist/tools-cli.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createInterface } from 'node:readline';
|
|
3
|
-
import { resolveLang } from '#core/lang.js';
|
|
3
|
+
import { resolveLang, catalog } from '#core/lang.js';
|
|
4
4
|
import { printJson } from './lib/cli-args.js';
|
|
5
5
|
import { readToolManifest } from './lib/package-root.js';
|
|
6
6
|
import { buildToolMenu, formatToolMenu, selectToolMenu } from './lib/tool-menu.js';
|
|
7
7
|
import { resolveToolsets } from './lib/toolsets.js';
|
|
8
|
+
const M = catalog({ invalid: '목록에서 고른 번호 또는 서비스 ID를 쉼표로 구분해 입력하세요.', prompt: '번호 또는 ID (예 1,2) > ' }, { invalid: 'Enter menu numbers or service IDs separated by commas.', prompt: 'Numbers or IDs (e.g. 1,2) > ' });
|
|
8
9
|
async function main(args) {
|
|
9
10
|
const lang = resolveLang();
|
|
10
11
|
const help = 'mimi-seed tools [--select <areas>]';
|
|
@@ -19,9 +20,7 @@ async function main(args) {
|
|
|
19
20
|
for (const warning of selection.warnings)
|
|
20
21
|
console.error(warning);
|
|
21
22
|
const menu = buildToolMenu(manifest, selection, lang);
|
|
22
|
-
const invalid =
|
|
23
|
-
? '목록에서 고른 번호 또는 서비스 ID를 쉼표로 구분해 입력하세요.'
|
|
24
|
-
: 'Enter menu numbers or service IDs separated by commas.';
|
|
23
|
+
const invalid = M().invalid;
|
|
25
24
|
if (args.length === 2) {
|
|
26
25
|
const selected = selectToolMenu(menu, args[1]);
|
|
27
26
|
if (!selected)
|
|
@@ -33,7 +32,7 @@ async function main(args) {
|
|
|
33
32
|
if (!process.stdin.isTTY || !process.stdout.isTTY || process.env.CI)
|
|
34
33
|
return;
|
|
35
34
|
const readline = createInterface({ input: process.stdin, output: process.stdout });
|
|
36
|
-
readline.setPrompt(
|
|
35
|
+
readline.setPrompt(M().prompt);
|
|
37
36
|
readline.on('SIGINT', () => readline.close());
|
|
38
37
|
try {
|
|
39
38
|
readline.prompt();
|
package/dist/video/captions.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { catalog } from '#core/lang.js';
|
|
2
|
+
const M = catalog({ badColor: (hex) => `잘못된 색상 형식입니다(#RRGGBB): ${hex}` }, { badColor: (hex) => `Invalid color format (#RRGGBB): ${hex}` });
|
|
1
3
|
export function resolveCaptionStyle(width, height, style) {
|
|
2
4
|
const preset = style?.preset ?? 'shorts';
|
|
3
5
|
const vertical = height > width;
|
|
@@ -17,7 +19,7 @@ export function resolveCaptionStyle(width, height, style) {
|
|
|
17
19
|
export function assColor(hex, alpha = '00') {
|
|
18
20
|
const match = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(hex);
|
|
19
21
|
if (!match)
|
|
20
|
-
throw new Error(
|
|
22
|
+
throw new Error(M().badColor(hex));
|
|
21
23
|
const [, r, g, b] = match;
|
|
22
24
|
return `&H${alpha}${b}${g}${r}`.toUpperCase();
|
|
23
25
|
}
|
package/dist/video/files.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { readFileSync, statSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { catalog } from '#core/lang.js';
|
|
4
|
+
const M = catalog({
|
|
5
|
+
tooLarge: (mb, size) => `JSON 파일이 ${mb}MB 제한을 초과합니다 (${size} bytes).`,
|
|
6
|
+
unreadable: (filePath) => `JSON 파일을 읽거나 파싱할 수 없습니다: ${filePath}`,
|
|
7
|
+
notAbsolute: (label) => `${label}은 절대경로여야 합니다.`,
|
|
8
|
+
}, {
|
|
9
|
+
tooLarge: (mb, size) => `The JSON file exceeds the ${mb}MB limit (${size} bytes).`,
|
|
10
|
+
unreadable: (filePath) => `Cannot read or parse the JSON file: ${filePath}`,
|
|
11
|
+
notAbsolute: (label) => `${label} must be an absolute path.`,
|
|
12
|
+
});
|
|
3
13
|
// 구현은 packages/core 의 atomic-write.ts 로 승격됐다 — 같은 원자성 보장이 자격증명 writer 에도 필요했는데
|
|
4
14
|
// video/ 안에 갇혀 있어서 아무도 쓰지 못하고 있었다. video 쪽 호출부를 위해 이름만 재수출한다.
|
|
5
15
|
export { writeJsonAtomic } from '#core/atomic-write.js';
|
|
@@ -7,16 +17,16 @@ export function readJson(filePath, maxBytes = 20 * 1024 * 1024) {
|
|
|
7
17
|
try {
|
|
8
18
|
const size = statSync(filePath).size;
|
|
9
19
|
if (size > maxBytes) {
|
|
10
|
-
throw new Error(
|
|
20
|
+
throw new Error(M().tooLarge(Math.round(maxBytes / 1024 / 1024), size));
|
|
11
21
|
}
|
|
12
22
|
return JSON.parse(readFileSync(filePath, 'utf8'));
|
|
13
23
|
}
|
|
14
24
|
catch (error) {
|
|
15
|
-
throw new Error(
|
|
25
|
+
throw new Error(M().unreadable(filePath), { cause: error });
|
|
16
26
|
}
|
|
17
27
|
}
|
|
18
28
|
export function requireAbsolutePath(value, label) {
|
|
19
29
|
if (!path.isAbsolute(value))
|
|
20
|
-
throw new Error(
|
|
30
|
+
throw new Error(M().notAbsolute(label));
|
|
21
31
|
return path.resolve(value);
|
|
22
32
|
}
|
package/dist/video/project.js
CHANGED
|
@@ -1,12 +1,56 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
2
|
import { closeSync, copyFileSync, existsSync, mkdirSync, openSync, readSync, statSync, unlinkSync, } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { catalog } from '#core/lang.js';
|
|
4
5
|
import { parseJsonResponse, requireApiKey, AI_MODEL } from '../ai/client.js';
|
|
5
6
|
import { readJson, requireAbsolutePath, writeJsonAtomic } from './files.js';
|
|
6
7
|
import { assetManifestSchema, assetSchema, parseFile, projectSchema, timelineSchema } from './schemas.js';
|
|
7
8
|
const PROJECT_FILE = 'project.json';
|
|
8
9
|
const ASSET_FILE = 'assets.json';
|
|
9
10
|
const TIMELINE_FILE = 'timeline.json';
|
|
11
|
+
const M = catalog({
|
|
12
|
+
noScenes: 'AI가 유효한 장면 목록을 만들지 못했습니다. 다시 시도하세요.',
|
|
13
|
+
projectExists: (projectPath) => `이미 영상 프로젝트가 있습니다: ${projectPath}\noverwrite=true로 명시해야 덮어씁니다.`,
|
|
14
|
+
aiProjectLabel: 'AI가 생성한 영상 프로젝트',
|
|
15
|
+
agentProjectLabel: '에이전트가 작성한 영상 프로젝트',
|
|
16
|
+
projectNotFound: (filePath) => `영상 프로젝트를 찾을 수 없습니다: ${filePath}`,
|
|
17
|
+
assetsMismatch: 'assets.json이 현재 project.json과 다른 프로젝트에 속합니다. 프로젝트를 다시 계획하거나 자산 매니페스트를 복구하세요.',
|
|
18
|
+
assetPathInvalid: (p) => `자산 파일은 존재하는 절대경로여야 합니다: ${p}`,
|
|
19
|
+
assetLabel: '등록할 영상 자산',
|
|
20
|
+
filePathInvalid: 'filePath는 존재하는 절대경로여야 합니다.',
|
|
21
|
+
noTimelineScenes: '타임라인에는 장면이 한 개 이상 필요합니다.',
|
|
22
|
+
unknownAsset: (id) => `등록되지 않은 assetId입니다: ${id}`,
|
|
23
|
+
notRenderable: (id) => `렌더링이 허용되지 않은 자산입니다: ${id}`,
|
|
24
|
+
sceneKind: (id) => `장면에는 이미지 또는 영상 자산만 사용할 수 있습니다: ${id}`,
|
|
25
|
+
sceneDuration: (id) => `장면 길이는 0보다 커야 합니다: ${id}`,
|
|
26
|
+
badAudio: (id) => `사용할 수 없는 오디오 자산입니다: ${id}`,
|
|
27
|
+
tooLong: (sec) => `타임라인 총 길이는 300초를 넘을 수 없습니다: ${sec}초`,
|
|
28
|
+
timelineLabel: '생성할 영상 타임라인',
|
|
29
|
+
timelineNotFound: (filePath) => `타임라인을 찾을 수 없습니다: ${filePath}`,
|
|
30
|
+
timelineMismatch: 'timeline.json이 현재 project.json과 다른 프로젝트에 속합니다. 타임라인을 다시 생성하세요.',
|
|
31
|
+
timelineSettings: 'timeline.json의 출력 설정이 현재 프로젝트 설정과 다릅니다. 타임라인을 다시 생성하세요.',
|
|
32
|
+
}, {
|
|
33
|
+
noScenes: 'The AI did not produce a valid scene list. Try again.',
|
|
34
|
+
projectExists: (projectPath) => `A video project already exists: ${projectPath}\nSet overwrite=true explicitly to overwrite it.`,
|
|
35
|
+
aiProjectLabel: 'AI-generated video project',
|
|
36
|
+
agentProjectLabel: 'Agent-written video project',
|
|
37
|
+
projectNotFound: (filePath) => `Video project not found: ${filePath}`,
|
|
38
|
+
assetsMismatch: 'assets.json belongs to a different project than the current project.json. Re-plan the project or restore the asset manifest.',
|
|
39
|
+
assetPathInvalid: (p) => `The asset file must be an existing absolute path: ${p}`,
|
|
40
|
+
assetLabel: 'Video asset to register',
|
|
41
|
+
filePathInvalid: 'filePath must be an existing absolute path.',
|
|
42
|
+
noTimelineScenes: 'A timeline needs at least one scene.',
|
|
43
|
+
unknownAsset: (id) => `Unregistered assetId: ${id}`,
|
|
44
|
+
notRenderable: (id) => `Asset not allowed for rendering: ${id}`,
|
|
45
|
+
sceneKind: (id) => `Scenes can use only image or video assets: ${id}`,
|
|
46
|
+
sceneDuration: (id) => `Scene duration must be greater than 0: ${id}`,
|
|
47
|
+
badAudio: (id) => `Unusable audio asset: ${id}`,
|
|
48
|
+
tooLong: (sec) => `Total timeline duration cannot exceed 300 seconds: ${sec}s`,
|
|
49
|
+
timelineLabel: 'Video timeline to create',
|
|
50
|
+
timelineNotFound: (filePath) => `Timeline not found: ${filePath}`,
|
|
51
|
+
timelineMismatch: 'timeline.json belongs to a different project than the current project.json. Regenerate the timeline.',
|
|
52
|
+
timelineSettings: 'The output settings in timeline.json differ from the current project settings. Regenerate the timeline.',
|
|
53
|
+
});
|
|
10
54
|
function dimensions(aspectRatio) {
|
|
11
55
|
if (aspectRatio === '16:9')
|
|
12
56
|
return { width: 1920, height: 1080 };
|
|
@@ -16,7 +60,7 @@ function dimensions(aspectRatio) {
|
|
|
16
60
|
}
|
|
17
61
|
function normalizeScenes(raw, targetDurationSec) {
|
|
18
62
|
if (!Array.isArray(raw) || raw.length === 0) {
|
|
19
|
-
throw new Error(
|
|
63
|
+
throw new Error(M().noScenes);
|
|
20
64
|
}
|
|
21
65
|
const maxScenes = Math.min(12, Math.max(1, Math.floor(targetDurationSec)));
|
|
22
66
|
const scenes = raw.slice(0, maxScenes).map((scene, index) => ({
|
|
@@ -42,7 +86,7 @@ export async function planStory(input) {
|
|
|
42
86
|
const projectDir = requireAbsolutePath(input.projectDir, 'projectDir');
|
|
43
87
|
const projectPath = path.join(projectDir, PROJECT_FILE);
|
|
44
88
|
if (existsSync(projectPath) && !input.overwrite) {
|
|
45
|
-
throw new Error(
|
|
89
|
+
throw new Error(M().projectExists(projectPath));
|
|
46
90
|
}
|
|
47
91
|
const client = await requireApiKey();
|
|
48
92
|
const response = await client.messages.create({
|
|
@@ -89,7 +133,7 @@ export async function planStory(input) {
|
|
|
89
133
|
style: input.style,
|
|
90
134
|
},
|
|
91
135
|
scenes: normalizeScenes(parsed.scenes ?? [], input.targetDurationSec),
|
|
92
|
-
},
|
|
136
|
+
}, M().aiProjectLabel);
|
|
93
137
|
persistProject(projectDir, project, input.overwrite === true);
|
|
94
138
|
return project;
|
|
95
139
|
}
|
|
@@ -130,7 +174,7 @@ export function savePlan(input) {
|
|
|
130
174
|
const projectDir = requireAbsolutePath(input.projectDir, 'projectDir');
|
|
131
175
|
const projectPath = path.join(projectDir, PROJECT_FILE);
|
|
132
176
|
if (existsSync(projectPath) && !input.overwrite) {
|
|
133
|
-
throw new Error(
|
|
177
|
+
throw new Error(M().projectExists(projectPath));
|
|
134
178
|
}
|
|
135
179
|
const dims = dimensions(input.aspectRatio);
|
|
136
180
|
const project = parseFile(projectSchema, {
|
|
@@ -155,7 +199,7 @@ export function savePlan(input) {
|
|
|
155
199
|
visualPrompt: scene.visualPrompt?.trim() ?? '',
|
|
156
200
|
searchQuery: scene.searchQuery?.trim() || scene.visualPrompt?.trim() || '',
|
|
157
201
|
})),
|
|
158
|
-
},
|
|
202
|
+
}, M().agentProjectLabel);
|
|
159
203
|
persistProject(projectDir, project, input.overwrite === true);
|
|
160
204
|
return project;
|
|
161
205
|
}
|
|
@@ -163,7 +207,7 @@ export function loadProject(projectDir) {
|
|
|
163
207
|
const dir = requireAbsolutePath(projectDir, 'projectDir');
|
|
164
208
|
const filePath = path.join(dir, PROJECT_FILE);
|
|
165
209
|
if (!existsSync(filePath))
|
|
166
|
-
throw new Error(
|
|
210
|
+
throw new Error(M().projectNotFound(filePath));
|
|
167
211
|
return parseFile(projectSchema, readJson(filePath), filePath);
|
|
168
212
|
}
|
|
169
213
|
export function loadAssets(projectDir) {
|
|
@@ -174,7 +218,7 @@ export function loadAssets(projectDir) {
|
|
|
174
218
|
return { version: 1, projectId: project.projectId, assets: [] };
|
|
175
219
|
const manifest = parseFile(assetManifestSchema, readJson(filePath), filePath);
|
|
176
220
|
if (manifest.projectId !== project.projectId) {
|
|
177
|
-
throw new Error(
|
|
221
|
+
throw new Error(M().assetsMismatch);
|
|
178
222
|
}
|
|
179
223
|
return manifest;
|
|
180
224
|
}
|
|
@@ -199,14 +243,14 @@ export function registerAsset(projectDir, asset) {
|
|
|
199
243
|
const dir = requireAbsolutePath(projectDir, 'projectDir');
|
|
200
244
|
loadProject(dir);
|
|
201
245
|
if (!path.isAbsolute(asset.path) || !existsSync(asset.path) || !statSync(asset.path).isFile()) {
|
|
202
|
-
throw new Error(
|
|
246
|
+
throw new Error(M().assetPathInvalid(asset.path));
|
|
203
247
|
}
|
|
204
248
|
const entry = parseFile(assetSchema, {
|
|
205
249
|
...asset,
|
|
206
250
|
path: path.resolve(asset.path),
|
|
207
251
|
sha256: sha256File(asset.path),
|
|
208
252
|
createdAt: new Date().toISOString(),
|
|
209
|
-
},
|
|
253
|
+
}, M().assetLabel);
|
|
210
254
|
const manifest = loadAssets(dir);
|
|
211
255
|
manifest.assets = [...manifest.assets.filter((item) => item.id !== entry.id), entry];
|
|
212
256
|
writeJsonAtomic(path.join(dir, ASSET_FILE), manifest);
|
|
@@ -215,7 +259,7 @@ export function registerAsset(projectDir, asset) {
|
|
|
215
259
|
export function addLocalAsset(input) {
|
|
216
260
|
const projectDir = requireAbsolutePath(input.projectDir, 'projectDir');
|
|
217
261
|
if (!path.isAbsolute(input.filePath) || !existsSync(input.filePath)) {
|
|
218
|
-
throw new Error(
|
|
262
|
+
throw new Error(M().filePathInvalid);
|
|
219
263
|
}
|
|
220
264
|
const id = `local-${randomUUID()}`;
|
|
221
265
|
const ext = path.extname(input.filePath).toLowerCase();
|
|
@@ -238,31 +282,31 @@ export function buildTimeline(projectDir, scenes, audioAssetId, captionStyle) {
|
|
|
238
282
|
const project = loadProject(dir);
|
|
239
283
|
const manifest = loadAssets(dir);
|
|
240
284
|
if (scenes.length === 0)
|
|
241
|
-
throw new Error(
|
|
285
|
+
throw new Error(M().noTimelineScenes);
|
|
242
286
|
const byId = new Map(manifest.assets.map((asset) => [asset.id, asset]));
|
|
243
287
|
for (const scene of scenes) {
|
|
244
288
|
const asset = byId.get(scene.assetId);
|
|
245
289
|
if (!asset)
|
|
246
|
-
throw new Error(
|
|
290
|
+
throw new Error(M().unknownAsset(scene.assetId));
|
|
247
291
|
if (!asset.allowedForRendering || asset.sourceType === 'reference-only') {
|
|
248
|
-
throw new Error(
|
|
292
|
+
throw new Error(M().notRenderable(scene.assetId));
|
|
249
293
|
}
|
|
250
294
|
if (asset.kind !== 'image' && asset.kind !== 'video') {
|
|
251
|
-
throw new Error(
|
|
295
|
+
throw new Error(M().sceneKind(scene.assetId));
|
|
252
296
|
}
|
|
253
297
|
if (!Number.isFinite(scene.durationSec) || scene.durationSec <= 0) {
|
|
254
|
-
throw new Error(
|
|
298
|
+
throw new Error(M().sceneDuration(scene.id));
|
|
255
299
|
}
|
|
256
300
|
}
|
|
257
301
|
if (audioAssetId) {
|
|
258
302
|
const audio = byId.get(audioAssetId);
|
|
259
303
|
if (!audio || audio.kind !== 'audio' || !audio.allowedForRendering) {
|
|
260
|
-
throw new Error(
|
|
304
|
+
throw new Error(M().badAudio(audioAssetId));
|
|
261
305
|
}
|
|
262
306
|
}
|
|
263
307
|
const totalDurationSec = scenes.reduce((sum, scene) => sum + scene.durationSec, 0);
|
|
264
308
|
if (totalDurationSec > 300)
|
|
265
|
-
throw new Error(
|
|
309
|
+
throw new Error(M().tooLong(totalDurationSec));
|
|
266
310
|
const timeline = parseFile(timelineSchema, {
|
|
267
311
|
version: 1,
|
|
268
312
|
projectId: project.projectId,
|
|
@@ -274,7 +318,7 @@ export function buildTimeline(projectDir, scenes, audioAssetId, captionStyle) {
|
|
|
274
318
|
scenes,
|
|
275
319
|
audioAssetId,
|
|
276
320
|
captionStyle,
|
|
277
|
-
},
|
|
321
|
+
}, M().timelineLabel);
|
|
278
322
|
writeJsonAtomic(path.join(dir, TIMELINE_FILE), timeline);
|
|
279
323
|
return timeline;
|
|
280
324
|
}
|
|
@@ -283,15 +327,15 @@ export function loadTimeline(projectDir) {
|
|
|
283
327
|
const project = loadProject(dir);
|
|
284
328
|
const filePath = path.join(dir, TIMELINE_FILE);
|
|
285
329
|
if (!existsSync(filePath))
|
|
286
|
-
throw new Error(
|
|
330
|
+
throw new Error(M().timelineNotFound(filePath));
|
|
287
331
|
const timeline = parseFile(timelineSchema, readJson(filePath), filePath);
|
|
288
332
|
if (timeline.projectId !== project.projectId) {
|
|
289
|
-
throw new Error(
|
|
333
|
+
throw new Error(M().timelineMismatch);
|
|
290
334
|
}
|
|
291
335
|
if (timeline.width !== project.settings.width ||
|
|
292
336
|
timeline.height !== project.settings.height ||
|
|
293
337
|
timeline.fps !== project.settings.fps) {
|
|
294
|
-
throw new Error(
|
|
338
|
+
throw new Error(M().timelineSettings);
|
|
295
339
|
}
|
|
296
340
|
return timeline;
|
|
297
341
|
}
|