@sync.so/mcp-server 0.1.4 → 0.2.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 (261) hide show
  1. package/README.md +261 -86
  2. package/deploy/generation-status/app.html.gz +0 -0
  3. package/deploy/generation-status/release.json +6 -0
  4. package/dist/abort-signals.d.ts +6 -0
  5. package/dist/abort-signals.d.ts.map +1 -0
  6. package/dist/abort-signals.js +23 -0
  7. package/dist/account-features.d.ts +7 -0
  8. package/dist/account-features.d.ts.map +1 -0
  9. package/dist/account-features.js +48 -0
  10. package/dist/app-upload-relay.d.ts +13 -0
  11. package/dist/app-upload-relay.d.ts.map +1 -0
  12. package/dist/app-upload-relay.js +136 -0
  13. package/dist/asset-thumbnail.d.ts +3 -0
  14. package/dist/asset-thumbnail.d.ts.map +1 -0
  15. package/dist/asset-thumbnail.js +2 -0
  16. package/dist/auth/async-context.d.ts +5 -0
  17. package/dist/auth/async-context.d.ts.map +1 -0
  18. package/dist/auth/async-context.js +14 -0
  19. package/dist/auth/bearer-auth.d.ts +16 -0
  20. package/dist/auth/bearer-auth.d.ts.map +1 -0
  21. package/dist/auth/bearer-auth.js +55 -0
  22. package/dist/auth/client-credentials.d.ts +13 -0
  23. package/dist/auth/client-credentials.d.ts.map +1 -0
  24. package/dist/auth/client-credentials.js +67 -0
  25. package/dist/auth/device-auth.d.ts.map +1 -1
  26. package/dist/auth/device-auth.js +3 -2
  27. package/dist/auth/fixture-cleanup.d.ts +4 -0
  28. package/dist/auth/fixture-cleanup.d.ts.map +1 -0
  29. package/dist/auth/fixture-cleanup.js +9 -0
  30. package/dist/auth/index.d.ts +2 -0
  31. package/dist/auth/index.d.ts.map +1 -1
  32. package/dist/auth/index.js +2 -0
  33. package/dist/auth/oauth-diagnostics.d.ts +11 -0
  34. package/dist/auth/oauth-diagnostics.d.ts.map +1 -0
  35. package/dist/auth/oauth-diagnostics.js +78 -0
  36. package/dist/auth/oauth-provider.d.ts +16 -0
  37. package/dist/auth/oauth-provider.d.ts.map +1 -0
  38. package/dist/auth/oauth-provider.js +107 -0
  39. package/dist/auth/resource-metadata.d.ts +2 -0
  40. package/dist/auth/resource-metadata.d.ts.map +1 -0
  41. package/dist/auth/resource-metadata.js +3 -0
  42. package/dist/auth/token-verification.d.ts +11 -0
  43. package/dist/auth/token-verification.d.ts.map +1 -0
  44. package/dist/auth/token-verification.js +99 -0
  45. package/dist/auth/verification-cache.d.ts +8 -0
  46. package/dist/auth/verification-cache.d.ts.map +1 -0
  47. package/dist/auth/verification-cache.js +111 -0
  48. package/dist/chatgpt-analytics.d.ts +22 -0
  49. package/dist/chatgpt-analytics.d.ts.map +1 -0
  50. package/dist/chatgpt-analytics.js +172 -0
  51. package/dist/chatgpt-app.d.ts +15 -0
  52. package/dist/chatgpt-app.d.ts.map +1 -0
  53. package/dist/chatgpt-app.js +133 -0
  54. package/dist/chatgpt-release.d.ts +12 -0
  55. package/dist/chatgpt-release.d.ts.map +1 -0
  56. package/dist/chatgpt-release.js +30 -0
  57. package/dist/cli.js +30 -16
  58. package/dist/client-profile.d.ts +10 -0
  59. package/dist/client-profile.d.ts.map +1 -0
  60. package/dist/client-profile.js +45 -0
  61. package/dist/config.d.ts +17 -0
  62. package/dist/config.d.ts.map +1 -1
  63. package/dist/config.js +52 -0
  64. package/dist/generation-status-html.d.ts +2 -0
  65. package/dist/generation-status-html.d.ts.map +1 -0
  66. package/dist/generation-status-html.js +26 -0
  67. package/dist/generation-status.d.ts +6 -0
  68. package/dist/generation-status.d.ts.map +1 -0
  69. package/dist/generation-status.js +37 -0
  70. package/dist/http-client.d.ts +45 -1
  71. package/dist/http-client.d.ts.map +1 -1
  72. package/dist/http-client.js +171 -34
  73. package/dist/http-server.d.ts +53 -0
  74. package/dist/http-server.d.ts.map +1 -0
  75. package/dist/http-server.js +753 -0
  76. package/dist/http-session.d.ts +18 -0
  77. package/dist/http-session.d.ts.map +1 -0
  78. package/dist/http-session.js +189 -0
  79. package/dist/index.d.ts +4 -3
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +3 -2
  82. package/dist/oauth-response.d.ts +3 -0
  83. package/dist/oauth-response.d.ts.map +1 -0
  84. package/dist/oauth-response.js +30 -0
  85. package/dist/openapi/index.d.ts +2 -2
  86. package/dist/openapi/index.d.ts.map +1 -1
  87. package/dist/openapi/index.js +1 -1
  88. package/dist/openapi/parser.d.ts +2 -0
  89. package/dist/openapi/parser.d.ts.map +1 -1
  90. package/dist/openapi/parser.js +41 -1
  91. package/dist/openapi/types.d.ts +3 -0
  92. package/dist/openapi/types.d.ts.map +1 -1
  93. package/dist/organization-selection.d.ts +61 -0
  94. package/dist/organization-selection.d.ts.map +1 -0
  95. package/dist/organization-selection.js +142 -0
  96. package/dist/rate-limits.d.ts +13 -0
  97. package/dist/rate-limits.d.ts.map +1 -0
  98. package/dist/rate-limits.js +67 -0
  99. package/dist/revision.d.ts +6 -0
  100. package/dist/revision.d.ts.map +1 -0
  101. package/dist/revision.js +17 -0
  102. package/dist/runtime-diagnostics.d.ts +32 -0
  103. package/dist/runtime-diagnostics.d.ts.map +1 -0
  104. package/dist/runtime-diagnostics.js +58 -0
  105. package/dist/server.d.ts +23 -2
  106. package/dist/server.d.ts.map +1 -1
  107. package/dist/server.js +893 -32
  108. package/dist/session-registry.d.ts +54 -0
  109. package/dist/session-registry.d.ts.map +1 -0
  110. package/dist/session-registry.js +202 -0
  111. package/dist/session-telemetry.d.ts +13 -0
  112. package/dist/session-telemetry.d.ts.map +1 -0
  113. package/dist/session-telemetry.js +87 -0
  114. package/dist/spend-confirmation.d.ts +21 -0
  115. package/dist/spend-confirmation.d.ts.map +1 -0
  116. package/dist/spend-confirmation.js +105 -0
  117. package/dist/tool-analytics-context.d.ts +11 -0
  118. package/dist/tool-analytics-context.d.ts.map +1 -0
  119. package/dist/tool-analytics-context.js +8 -0
  120. package/dist/tool-names.d.ts +35 -0
  121. package/dist/tool-names.d.ts.map +1 -0
  122. package/dist/tool-names.js +133 -0
  123. package/dist/tools/account-context.d.ts +5 -0
  124. package/dist/tools/account-context.d.ts.map +1 -0
  125. package/dist/tools/account-context.js +131 -0
  126. package/dist/tools/account-management.d.ts +4 -0
  127. package/dist/tools/account-management.d.ts.map +1 -0
  128. package/dist/tools/account-management.js +111 -0
  129. package/dist/tools/app-tools.d.ts +31 -0
  130. package/dist/tools/app-tools.d.ts.map +1 -0
  131. package/dist/tools/app-tools.js +350 -0
  132. package/dist/tools/asset-analysis.d.ts +4 -0
  133. package/dist/tools/asset-analysis.d.ts.map +1 -0
  134. package/dist/tools/asset-analysis.js +172 -0
  135. package/dist/tools/asset-creators.d.ts +4 -0
  136. package/dist/tools/asset-creators.d.ts.map +1 -0
  137. package/dist/tools/asset-creators.js +38 -0
  138. package/dist/tools/audio-trim.d.ts +6 -0
  139. package/dist/tools/audio-trim.d.ts.map +1 -0
  140. package/dist/tools/audio-trim.js +79 -0
  141. package/dist/tools/batch-results.d.ts +16 -0
  142. package/dist/tools/batch-results.d.ts.map +1 -0
  143. package/dist/tools/batch-results.js +103 -0
  144. package/dist/tools/batches.d.ts +28 -0
  145. package/dist/tools/batches.d.ts.map +1 -0
  146. package/dist/tools/batches.js +293 -0
  147. package/dist/tools/dialogue.d.ts +6 -0
  148. package/dist/tools/dialogue.d.ts.map +1 -0
  149. package/dist/tools/dialogue.js +309 -0
  150. package/dist/tools/estimate-duration.d.ts +35 -0
  151. package/dist/tools/estimate-duration.d.ts.map +1 -0
  152. package/dist/tools/estimate-duration.js +66 -0
  153. package/dist/tools/feedback.d.ts +14 -0
  154. package/dist/tools/feedback.d.ts.map +1 -0
  155. package/dist/tools/feedback.js +72 -0
  156. package/dist/tools/generated-adapters.d.ts +25 -0
  157. package/dist/tools/generated-adapters.d.ts.map +1 -0
  158. package/dist/tools/generated-adapters.js +143 -0
  159. package/dist/tools/generation-context.d.ts +14 -0
  160. package/dist/tools/generation-context.d.ts.map +1 -0
  161. package/dist/tools/generation-context.js +39 -0
  162. package/dist/tools/generation-continuation.d.ts +4 -0
  163. package/dist/tools/generation-continuation.d.ts.map +1 -0
  164. package/dist/tools/generation-continuation.js +124 -0
  165. package/dist/tools/generation-costs.d.ts +6 -0
  166. package/dist/tools/generation-costs.d.ts.map +1 -0
  167. package/dist/tools/generation-costs.js +67 -0
  168. package/dist/tools/generation-output.d.ts +3 -0
  169. package/dist/tools/generation-output.d.ts.map +1 -0
  170. package/dist/tools/generation-output.js +39 -0
  171. package/dist/tools/generator.d.ts +35 -2
  172. package/dist/tools/generator.d.ts.map +1 -1
  173. package/dist/tools/generator.js +127 -9
  174. package/dist/tools/job-status.d.ts +35 -0
  175. package/dist/tools/job-status.d.ts.map +1 -0
  176. package/dist/tools/job-status.js +92 -0
  177. package/dist/tools/job-wait.d.ts +41 -0
  178. package/dist/tools/job-wait.d.ts.map +1 -0
  179. package/dist/tools/job-wait.js +84 -0
  180. package/dist/tools/jobs.d.ts +3 -0
  181. package/dist/tools/jobs.d.ts.map +1 -0
  182. package/dist/tools/jobs.js +210 -0
  183. package/dist/tools/media-upload.d.ts +27 -0
  184. package/dist/tools/media-upload.d.ts.map +1 -0
  185. package/dist/tools/media-upload.js +247 -0
  186. package/dist/tools/model-options.d.ts +36 -0
  187. package/dist/tools/model-options.d.ts.map +1 -0
  188. package/dist/tools/model-options.js +48 -0
  189. package/dist/tools/organization-choice.d.ts +9 -0
  190. package/dist/tools/organization-choice.d.ts.map +1 -0
  191. package/dist/tools/organization-choice.js +136 -0
  192. package/dist/tools/organizations.d.ts +56 -0
  193. package/dist/tools/organizations.d.ts.map +1 -0
  194. package/dist/tools/organizations.js +235 -0
  195. package/dist/tools/output-schemas.d.ts +54 -0
  196. package/dist/tools/output-schemas.d.ts.map +1 -0
  197. package/dist/tools/output-schemas.js +58 -0
  198. package/dist/tools/overrides.d.ts +3 -0
  199. package/dist/tools/overrides.d.ts.map +1 -1
  200. package/dist/tools/overrides.js +113 -15
  201. package/dist/tools/playback-metadata.d.ts +4 -0
  202. package/dist/tools/playback-metadata.d.ts.map +1 -0
  203. package/dist/tools/playback-metadata.js +51 -0
  204. package/dist/tools/project-destination.d.ts +13 -0
  205. package/dist/tools/project-destination.d.ts.map +1 -0
  206. package/dist/tools/project-destination.js +45 -0
  207. package/dist/tools/project-history.d.ts +6 -0
  208. package/dist/tools/project-history.d.ts.map +1 -0
  209. package/dist/tools/project-history.js +45 -0
  210. package/dist/tools/project-intent.d.ts +8 -0
  211. package/dist/tools/project-intent.d.ts.map +1 -0
  212. package/dist/tools/project-intent.js +87 -0
  213. package/dist/tools/running-submissions.d.ts +7 -0
  214. package/dist/tools/running-submissions.d.ts.map +1 -0
  215. package/dist/tools/running-submissions.js +91 -0
  216. package/dist/tools/speech.d.ts +6 -0
  217. package/dist/tools/speech.d.ts.map +1 -0
  218. package/dist/tools/speech.js +116 -0
  219. package/dist/tools/studio-draft.d.ts +7 -0
  220. package/dist/tools/studio-draft.d.ts.map +1 -0
  221. package/dist/tools/studio-draft.js +195 -0
  222. package/dist/tools/studio-view-contract.d.ts +184 -0
  223. package/dist/tools/studio-view-contract.d.ts.map +1 -0
  224. package/dist/tools/studio-view-contract.js +67 -0
  225. package/dist/tools/studio-view.d.ts +6 -0
  226. package/dist/tools/studio-view.d.ts.map +1 -0
  227. package/dist/tools/studio-view.js +126 -0
  228. package/dist/tools/timeline-lipsync.d.ts +316 -0
  229. package/dist/tools/timeline-lipsync.d.ts.map +1 -0
  230. package/dist/tools/timeline-lipsync.js +304 -0
  231. package/dist/tools/translation-preview.d.ts +8 -0
  232. package/dist/tools/translation-preview.d.ts.map +1 -0
  233. package/dist/tools/translation-preview.js +146 -0
  234. package/dist/tools/translation.d.ts +6 -0
  235. package/dist/tools/translation.d.ts.map +1 -0
  236. package/dist/tools/translation.js +131 -0
  237. package/dist/tools/upload-widget.d.ts +13 -0
  238. package/dist/tools/upload-widget.d.ts.map +1 -0
  239. package/dist/tools/upload-widget.js +788 -0
  240. package/dist/toolsets.d.ts +18 -0
  241. package/dist/toolsets.d.ts.map +1 -0
  242. package/dist/toolsets.js +157 -0
  243. package/dist/update-check.d.ts +38 -0
  244. package/dist/update-check.d.ts.map +1 -0
  245. package/dist/update-check.js +150 -0
  246. package/dist/upload-runtime.d.ts +45 -0
  247. package/dist/upload-runtime.d.ts.map +1 -0
  248. package/dist/upload-runtime.js +156 -0
  249. package/dist/upload-source.d.ts +4 -0
  250. package/dist/upload-source.d.ts.map +1 -0
  251. package/dist/upload-source.js +46 -0
  252. package/dist/version.d.ts +2 -0
  253. package/dist/version.d.ts.map +1 -0
  254. package/dist/version.js +3 -0
  255. package/package.json +77 -31
  256. package/dist/openapi/parser.test.d.ts +0 -2
  257. package/dist/openapi/parser.test.d.ts.map +0 -1
  258. package/dist/openapi/parser.test.js +0 -188
  259. package/dist/tools/generator.test.d.ts +0 -2
  260. package/dist/tools/generator.test.d.ts.map +0 -1
  261. package/dist/tools/generator.test.js +0 -178
@@ -0,0 +1,146 @@
1
+ import { z } from 'zod';
2
+ import { schemaProperty } from '../openapi/parser.js';
3
+ import { jobSettled } from './job-status.js';
4
+ import { pollUntil, waitInput } from './job-wait.js';
5
+ const PREVIEW_OPERATIONS = [
6
+ ['post', '/v2/integrations/dubbing'],
7
+ ['post', '/v2/integrations/dubbing/estimate'],
8
+ ['get', '/v2/integrations/dubbing/{id}'],
9
+ ];
10
+ export function translationPreviewOperations(operations) {
11
+ return operations.filter((operation) => PREVIEW_OPERATIONS.some(([method, path]) => operation.method === method && operation.path === path));
12
+ }
13
+ export function translationPreviewAvailable(operations) {
14
+ const matching = translationPreviewOperations(operations);
15
+ return PREVIEW_OPERATIONS.every(([method, path]) => {
16
+ const operation = matching.find((candidate) => candidate.method === method && candidate.path === path);
17
+ if (operation?.savedAssetDubbingVersion !== 1)
18
+ return false;
19
+ if (method === 'get')
20
+ return operation.parameters.some((parameter) => parameter.in === 'query' &&
21
+ parameter.name === 'projectId' &&
22
+ parameter.schema.type === 'string' &&
23
+ parameter.schema.format === 'uuid');
24
+ if (operation.requestBody?.contentType !== 'application/json')
25
+ return false;
26
+ const schema = operation.requestBody.schema;
27
+ if (['audioAssetId', 'projectId'].some((name) => {
28
+ const property = schemaProperty(schema, name);
29
+ return property?.type !== 'string' || property.format !== 'uuid';
30
+ }))
31
+ return false;
32
+ return (path.endsWith('/estimate') ||
33
+ operation.parameters.some((parameter) => parameter.in === 'header' &&
34
+ parameter.name.toLowerCase() === 'idempotency-key' &&
35
+ parameter.schema.type === 'string'));
36
+ });
37
+ }
38
+ const jobSchema = z.object({
39
+ id: z.uuid(),
40
+ projectId: z.uuid(),
41
+ status: z.enum(['PENDING', 'PROCESSING', 'COMPLETING', 'COMPLETED', 'FAILED']),
42
+ sourceAudioUrl: z.string().optional(),
43
+ sourceLang: z.string(),
44
+ targetLang: z.string(),
45
+ cloningStrength: z.number().int().nullable().optional(),
46
+ outputMediaUrl: z.string().nullable(),
47
+ outputDurationSec: z.number().nonnegative().nullable(),
48
+ error: z.object({ code: z.string(), message: z.string() }).nullable(),
49
+ recoveryRequired: z.boolean(),
50
+ createdAt: z.string().optional(),
51
+ startedAt: z.string().nullable().optional(),
52
+ finishedAt: z.string().nullable().optional(),
53
+ });
54
+ const quoteSchema = z.object({
55
+ billing: z.enum(['sync_credits', 'sync_usd', 'included', 'external']),
56
+ estimatedGenerationCost: z.number().nonnegative().nullable(),
57
+ estimatedCredits: z.number().nonnegative().nullable(),
58
+ preview: z
59
+ .object({
60
+ sourceDurationSeconds: z.number().positive(),
61
+ quotedDurationSeconds: z.number().positive(),
62
+ limitSeconds: z.number().positive().nullable(),
63
+ })
64
+ .optional(),
65
+ });
66
+ /** The existing translation API must advertise saved-source authorization and keyed recovery. */
67
+ export function createTranslationPreviewTools(operations, http) {
68
+ if (!translationPreviewAvailable(operations))
69
+ return [];
70
+ const source = z.object({ projectId: z.uuid(), audioAssetId: z.uuid() }).strict();
71
+ const create = source.extend({
72
+ targetLang: z.string().trim().min(1),
73
+ // Detected from the audio. Still accepted from callers holding the old tool list.
74
+ sourceLang: z.string().optional().describe('Optional; the source language is detected.'),
75
+ idempotencyKey: z.uuid(),
76
+ });
77
+ const read = z.object({ projectId: z.uuid(), id: z.uuid() }).strict();
78
+ const waitable = read.extend({ wait: waitInput });
79
+ return [
80
+ {
81
+ name: 'translation-previews_estimate',
82
+ title: 'Estimate translated audio preview',
83
+ description: 'Read the server quote for translating saved audio in an accessible project. Does not translate, create a video, modify saved audio, or incur provider charges. If preview.quotedDurationSeconds is shorter than preview.sourceDurationSeconds, explain the duration limit and offer the bounded preview. Before admission, save a new trimmed audio asset and quote that asset; this estimate never trims the original. External provider charges must be disclosed separately.',
84
+ inputSchema: source.shape,
85
+ outputSchema: quoteSchema.shape,
86
+ annotations: {
87
+ readOnlyHint: true,
88
+ destructiveHint: false,
89
+ idempotentHint: true,
90
+ openWorldHint: false,
91
+ },
92
+ handler: async (args, context) => quoteSchema.parse(await http.request('post', '/v2/integrations/dubbing/estimate', {
93
+ body: { ...source.parse(args), preview: true },
94
+ signal: context?.signal,
95
+ })),
96
+ },
97
+ {
98
+ name: 'translation-previews_create',
99
+ title: 'Translate audio for preview',
100
+ description: 'Create one paid translated-audio preview from a saved audio asset. Confirm language and displayed cost first. Persist one UUID idempotencyKey and reuse the same immutable request after an uncertain response. Poll the returned job; never redub because audio attachment failed. Final video generation is a separate, explicitly approved lip-sync operation using the translated audio asset.',
101
+ inputSchema: create.shape,
102
+ outputSchema: jobSchema.shape,
103
+ annotations: {
104
+ readOnlyHint: false,
105
+ destructiveHint: true,
106
+ // Paid, and only the model-chosen idempotencyKey deduplicates it: a retry with a new key bills again.
107
+ idempotentHint: false,
108
+ openWorldHint: true,
109
+ },
110
+ handler: async (args, context) => {
111
+ const { idempotencyKey, sourceLang, ...fields } = create.parse(args);
112
+ return jobSchema.parse(await http.request('post', '/v2/integrations/dubbing', {
113
+ body: { ...fields, sourceLang: sourceLang ?? 'auto' },
114
+ headers: { 'Idempotency-Key': idempotencyKey },
115
+ signal: context?.signal,
116
+ }));
117
+ },
118
+ },
119
+ {
120
+ name: 'translation-previews_get',
121
+ title: 'Read translated audio preview',
122
+ description: 'Read the same project-authorized translation job; pass wait: true to wait for it on the server. A recoveryRequired result means provider acceptance is uncertain; do not create another job. Does not start or retry translation. When COMPLETED, outputMediaUrl can be registered with assets_create (type=AUDIO) or, when available, passed as a clip audioUrl to lipsync_create-timeline.',
123
+ inputSchema: waitable.shape,
124
+ outputSchema: jobSchema.shape,
125
+ annotations: {
126
+ readOnlyHint: true,
127
+ destructiveHint: false,
128
+ idempotentHint: true,
129
+ openWorldHint: false,
130
+ },
131
+ handler: async (args, context) => {
132
+ const { wait, ...fields } = waitable.parse(args);
133
+ const input = read.parse(fields);
134
+ const get = async (signal = context?.signal) => jobSchema.parse(await http.request('get', `/v2/integrations/dubbing/${input.id}`, {
135
+ query: { projectId: input.projectId },
136
+ signal,
137
+ }));
138
+ if (!wait)
139
+ return get();
140
+ return pollUntil(get, jobSettled, context, {
141
+ describe: (job) => `translation ${job.status.toLowerCase()}`,
142
+ });
143
+ },
144
+ },
145
+ ];
146
+ }
@@ -0,0 +1,6 @@
1
+ import type { HttpClient } from '../http-client.js';
2
+ import type { ParsedOperation } from '../openapi/types.js';
3
+ import type { McpToolDefinition } from './generator.js';
4
+ export declare function translationOperation(operations: ParsedOperation[]): ParsedOperation | undefined;
5
+ export declare function createTranslationTools(operations: ParsedOperation[], httpClient: HttpClient): McpToolDefinition[];
6
+ //# sourceMappingURL=translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/tools/translation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAUxD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,eAAe,GAAG,SAAS,CAQ/F;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAAE,EAC7B,UAAU,EAAE,UAAU,GACrB,iBAAiB,EAAE,CA0IrB"}
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import { schemaProperty as property } from '../openapi/parser.js';
3
+ import { generationContextHeaders, generationContextSchema } from './generation-context.js';
4
+ import { modelOptionsSchema } from './model-options.js';
5
+ import { generationOutputSchema } from './output-schemas.js';
6
+ import { assertProjectDestination, createProjectId, newProjectFields, } from './project-destination.js';
7
+ import { translationPreviewAvailable } from './translation-preview.js';
8
+ export function translationOperation(operations) {
9
+ return operations.find((operation) => operation.operationId === 'GenerateController_createGeneration' &&
10
+ operation.method === 'post' &&
11
+ operation.path === '/v2/generate' &&
12
+ operation.requestBody?.contentType === 'application/json');
13
+ }
14
+ export function createTranslationTools(operations, httpClient) {
15
+ const dub = property(translationOperation(operations)?.requestBody?.schema, 'dubParams');
16
+ const languageList = z.array(z.string().min(1)).nonempty();
17
+ const target = languageList.safeParse(property(dub, 'targetLang')?.enum);
18
+ const source = languageList.safeParse(property(dub, 'sourceLang')?.enum);
19
+ // Older APIs must not advertise a workflow they cannot validate.
20
+ if (!target.success || !source.success || !source.data.includes('auto'))
21
+ return [];
22
+ const schema = z
23
+ .object({
24
+ continuation: generationContextSchema.optional(),
25
+ videoAssetId: z
26
+ .uuid()
27
+ .describe('Existing Sync VIDEO asset in the connected organization. For a social link, first create a NEW project unless the user explicitly chose an existing one. Import via assets_create with type=VIDEO and that projectId, wait for its saved asset id, then pass the same projectId with projectIntent=explicit.'),
28
+ ...newProjectFields,
29
+ projectName: z
30
+ .string()
31
+ .trim()
32
+ .min(1)
33
+ .optional()
34
+ .describe('Name for a NEW project. A matching existing name is never reused.'),
35
+ projectId: z
36
+ .uuid()
37
+ .optional()
38
+ .describe('Project ID only when explicitly selected by the user, or just created for this request. Otherwise omit it to create a new project. Keep unchanged on retries.'),
39
+ targetLang: z.enum(target.data).describe('Target language from the API-supported list.'),
40
+ sourceLang: z.enum(source.data).default('auto'),
41
+ model: z.string().trim().min(1).describe('Video lip-sync model returned by models_list.'),
42
+ options: modelOptionsSchema.optional(),
43
+ idempotencyKey: z
44
+ .string()
45
+ .regex(/^[A-Za-z0-9._~-]{1,128}$/)
46
+ .describe('Persist one unique key per approved generation. Retry an uncertain request with this exact key and unchanged inputs; never automatically create a new key.'),
47
+ })
48
+ .strict();
49
+ return [
50
+ {
51
+ name: 'dubbing_create',
52
+ title: 'Translate and dub a video',
53
+ description: 'Use this when the user wants to translate and dub a video into another language with matching lip movements. Not for subtitles only or translating a text document. Requires a saved video asset, model, and persistent idempotency key. By default creates a NEW project using a fresh projectCreationKey, even when projectName matches existing work. Preserve that UUID and key on retries. Supply projectId only for an explicit selection or the project just created for this request; never infer it from a workflow name or open editor. For social video URLs, import through assets_create and wait for the saved asset before estimating or calling this tool. ' +
54
+ 'This is a paid action: confirm the requested language, configuration and estimated cost with the user before calling. Use generations_estimate-cost with workflow=translate-and-dub when that input is supported, and disclose any excluded external provider charges. Without the combined breakdown, lip-sync pricing is not the full workflow cost. ' +
55
+ 'The API manages dubbing and final rendering under the returned generation id. Poll generations_get for that same id until COMPLETED; do not create another job to finish or recover it.',
56
+ inputSchema: schema.shape,
57
+ outputSchema: generationOutputSchema,
58
+ annotations: {
59
+ readOnlyHint: false,
60
+ destructiveHint: true,
61
+ idempotentHint: false,
62
+ openWorldHint: true,
63
+ },
64
+ handler: async (args, context) => {
65
+ const input = schema.parse(args);
66
+ const signal = context?.signal;
67
+ signal?.throwIfAborted();
68
+ assertProjectDestination(input.projectId, input.projectName, input.projectCreationKey);
69
+ if (input.continuation && !input.projectId)
70
+ throw new Error('A continuation requires its explicitly selected projectId.');
71
+ const projectId = input.projectId ??
72
+ (await createProjectId(httpClient, {
73
+ name: input.projectName ?? 'Translate and Dub',
74
+ projectCreationKey: input.projectCreationKey,
75
+ idempotencyKey: input.idempotencyKey,
76
+ defaultWorkflow: 'translate_and_dub',
77
+ }, signal));
78
+ const project = input.projectId
79
+ ? await httpClient.request('get', `/v2/projects/${projectId}`, {
80
+ signal,
81
+ })
82
+ : { id: projectId };
83
+ if (!project ||
84
+ typeof project !== 'object' ||
85
+ !('id' in project) ||
86
+ project.id !== projectId) {
87
+ throw new Error('Sync could not verify access to this project. Refresh and try again.');
88
+ }
89
+ signal?.throwIfAborted();
90
+ const options = input.options;
91
+ if (typeof options?.active_speaker_detection === 'boolean') {
92
+ options.active_speaker_detection = { auto_detect: options.active_speaker_detection };
93
+ }
94
+ const lineage = await generationContextHeaders(httpClient, args, ['translate_and_dub'], signal);
95
+ return httpClient.request('post', '/v2/generate', {
96
+ signal,
97
+ headers: { ...lineage, 'Idempotency-Key': input.idempotencyKey },
98
+ body: {
99
+ model: input.model,
100
+ projectId,
101
+ input: [{ type: 'video', assetId: input.videoAssetId }],
102
+ dubParams: { targetLang: input.targetLang, sourceLang: input.sourceLang },
103
+ ...(options === undefined ? {} : { options }),
104
+ },
105
+ });
106
+ },
107
+ },
108
+ {
109
+ name: 'dubbing_get-options',
110
+ title: 'Translation options',
111
+ description: 'Read the source and target languages supported by the current translation API. Does not create a generation or estimate pricing.',
112
+ inputSchema: {},
113
+ outputSchema: {
114
+ targetLanguages: languageList,
115
+ sourceLanguages: languageList,
116
+ previewAvailable: z.boolean(),
117
+ },
118
+ annotations: {
119
+ readOnlyHint: true,
120
+ destructiveHint: false,
121
+ idempotentHint: true,
122
+ openWorldHint: false,
123
+ },
124
+ handler: async () => ({
125
+ targetLanguages: target.data,
126
+ sourceLanguages: source.data,
127
+ previewAvailable: translationPreviewAvailable(operations),
128
+ }),
129
+ },
130
+ ];
131
+ }
@@ -0,0 +1,13 @@
1
+ import type { ReadResourceCallback, ResourceMetadata } from '@modelcontextprotocol/server';
2
+ import type { McpToolDefinition } from './generator.js';
3
+ export declare const MCP_APP_RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
4
+ export declare const UPLOAD_WIDGET_URI = "ui://sync/upload-widget-v8.html";
5
+ export declare const UPLOAD_WIDGET_LEGACY_URIS: readonly ['ui://sync/upload-widget-v1.html', 'ui://sync/upload-widget-v2.html', 'ui://sync/upload-widget-v3.html', 'ui://sync/upload-widget-v4.html', 'ui://sync/upload-widget-v5.html', 'ui://sync/upload-widget-v6.html', 'ui://sync/upload-widget-v7.html'];
6
+ type UploadWidgetResourceServer = {
7
+ registerResource(name: string, uri: string, metadata: ResourceMetadata, readCallback: ReadResourceCallback): unknown;
8
+ };
9
+ export declare const UPLOAD_WIDGET_HTML: string;
10
+ export declare function registerUploadWidgetResource(server: UploadWidgetResourceServer): void;
11
+ export declare function createUploadWidgetTool(): McpToolDefinition;
12
+ export {};
13
+ //# sourceMappingURL=upload-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-widget.d.ts","sourceRoot":"","sources":["../../src/tools/upload-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AAEtE,eAAO,MAAM,iBAAiB,oCAAoC,CAAC;AACnE,eAAO,MAAM,yBAAyB,YACpC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,EACjC,iCAAiC,CACzB,CAAC;AAIX,KAAK,0BAA0B,GAAG;IAChC,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,oBAAoB,GACjC,OAAO,CAAC;CACZ,CAAC;AAiCF,eAAO,MAAM,kBAAkB,QAkrBvB,CAAC;AAET,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,0BAA0B,GAAG,IAAI,CAmBrF;AAED,wBAAgB,sBAAsB,IAAI,iBAAiB,CA4C1D"}